Commit graph

193 commits

Author SHA1 Message Date
Fabio Baltieri def230187b test: fix more legacy #include paths
Add a bunch of missing "zephyr/" prefixes to #include statements in
various test and test framework files.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2022-08-02 16:41:41 +01:00
Henrik Brix Andersen b3f092a109 tests: drivers: can: timing: exclude 20kbit/s test for ESP32 TWAI
Exclude the 20kbit/s CAN timing test from running on the Espressif ESP32
TWAI driver. The TWAI does not support bitrates below 50kbit/s due to the
combination of CAN clock and prescaler range.

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2022-07-30 17:32:04 +01:00
Henrik Brix Andersen c9b7b4e018 tests: drivers: can: canfd: enable loopback tests on native_posix
Enable the CAN-FD driver loopback tests on native_posix and
native_posix_64.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-07-18 18:43:36 +02:00
Henrik Brix Andersen 097cb04916 tests: drivers: can: api: add test for RTR filter matching
Add test for CAN RX filtering of RTR frames.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-07-18 13:24:54 +00:00
Henrik Brix Andersen 6ce4a46993 tests: drivers: can: canfd: add capabilities test
Test that the CAN controller supports getting the supported capabilities.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-07-13 10:13:56 +02:00
Henrik Brix Andersen ced21269c7 tests: drivers: can: api: add capabilities test
Test that the CAN controller supports getting the supported capabilities.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-07-13 10:13:56 +02:00
Henrik Brix Andersen 9bd97eb0b8 drivers: can: add CAN_MODE_FD
Add support for enabling/disabling CAN-FD frame transmission/reception at
run-time.

Fixes: #45303

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-05-11 10:47:54 +02:00
Henrik Brix Andersen 6a0f3fffb5 tests: drivers: can: canfd: verify FD bit in received frames
Verify that the received frames are of the same type (CAN classic
vs. CAN-FD) as the ones sent.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-05-11 10:47:54 +02:00
Henrik Brix Andersen 3f97d11afd drivers: can: convert enum can_mode to a bit field
Convert the can_mode enum to a bit field to prepare for future extensions
(CAN-FD mode, transmitter delay compensation, one-shot mode, 3-samples
mode, ...).

Rename the existing modes:
- CAN_NORMAL_MODE   -> CAN_MODE_NORMAL
- CAN_SILENT_MODE   -> CAN_MODE_LISTENONLY
- CAN_LOOPBACK_MODE -> CAN_MODE_LOOPBACK

These mode names align with the Linux naming for CAN control modes.

The old CAN_SILENT_LOOPBACK_MODE can be set with the bitmask
(CAN_MODE_LISTENONLY | CAN_MODE_LOOPBACK).

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-05-11 10:47:54 +02:00
Henrik Brix Andersen 2f7c01ba21 drivers: can: rename API functions from timing_*_data to timing_data_*
Rename the CAN data phase API functions to timing_data_* for consistency:
- can_get_timing_min_data() -> can_get_timing_data_min()
- can_get_timing_max_data() -> can_get_timing_data_max()
- .timing_min_data -> timing_data_min
- .timing_max_data -> timing_data_max

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-05-11 10:47:54 +02:00
Henrik Brix Andersen 18890828b8 drivers: can: split CAN classic and CAN-FD syscalls
Split CAN classic and CAN-FD syscalls into two:
- can_set_timing() -> can_set_timing() + can_set_timing_data()
- can_set_bitrate() -> can_set_bitrate() + can_set_bitrate_data()

Fixes: #45303

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-05-11 10:47:54 +02:00
Gerard Marull-Paretas ade7ccb918 tests: migrate includes to <zephyr/...>
In order to bring consistency in-tree, migrate all tests to the new
prefix <zephyr/...>. Note that the conversion has been scripted, refer
to #45388 for more details.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-05-06 20:02:14 +02:00
Henrik Brix Andersen e777aa823b tests: drivers: can: api: verify filters persist through bitrate changes
Verify that added rx filters are preserved through bitrate changes.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-04-21 13:00:46 +02:00
Henrik Brix Andersen 7a5116acb2 tests: drivers: can: timing: print core clock to aid in debugging
Print the CAN core clock frequency along with the device name to aid in
debugging CAN timing test case errors.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-04-21 13:00:20 +02:00
Henrik Brix Andersen 423ae67d5c tests: drivers: can: api: test can_get_max_filters()
Add test for can_get_max_filters() optional API function.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-04-19 11:47:40 +02:00
Henrik Brix Andersen 77fa7709e4 tests: drivers: can: api: add test for can_set_bitrate()
Add test for the can_set_bitrate() syscall.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-04-18 17:23:28 -07:00
Henrik Brix Andersen d39063a20d tests: drivers: can: api: verify filters persist through mode change
Verify that added rx filters are preserved through mode changes.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-04-14 09:06:11 +02:00
Henrik Brix Andersen 3b1527a8f9 tests: drivers: can: timing: tighten the sample point test criteria
Tighten the sample point test acceptance criteria from +/- 10.0% to +/-
5.0%. This is in line with the CAN sample point criteria used by the
Linux kernel.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-04-13 13:28:06 -07:00
Henrik Brix Andersen 5961ad2af8 tests: drivers: can: timing: test more bitrates
Extend the test with more CAN in Automation (CiA) 301 standard bitrates.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-04-13 13:28:06 -07:00
Henrik Brix Andersen ee63bc4a09 tests: drivers: can: timing: do not overwrite sample point error value
Do not overwrite the sample point error value as it is printed at the
very end of the test.

Fixes: 578454b78d

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-04-13 13:28:06 -07:00
Henrik Brix Andersen 3e290c636e tests: drivers: can: api: check frames in test_send_receive_msgq()
Test that the received frames in test_send_receive_msgq() matches the
frames sent.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-04-11 10:16:49 +02:00
Henrik Brix Andersen 203d6f16cf tests: drivers: can: add test of the can_set_state_change_callback() API
Add simple test of the can_set_state_change_callback() API. It is not
possible to trigger a change of state, but at least test the API call
with and without a callback function.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-04-07 09:39:01 +02:00
Henrik Brix Andersen b5dfa3d777 test: drivers: can: canfd: clean up and document the CAN-FD test cases
Clean up (naming, formatting) the CAN-FD test cases and add proper
doxygen documentation.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-04-06 11:23:12 +02:00
Henrik Brix Andersen b71393963a tests: drivers: can: api: add build-only test for MCP2515
Add a build-only test for the Microchip MCP2515 SPI CAN controller
driver since no in-tree boards have this chip.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-04-06 11:23:06 +02:00
Henrik Brix Andersen 47236fbaa5 tests: drivers: can: stm32: clean up and document the CAN STM32 tests
Clean up (naming, formatting) the CAN STM32-specific test cases and add
proper doxygen documentation. No functional changes.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-04-06 11:22:57 +02:00
Henrik Brix Andersen 5a4a15edcf tests: drivers: can: timing: test min/max timing can be set
Test that the minimum and maximum timing parameter values are accepted
by the driver.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-04-05 10:33:08 -07:00
Henrik Brix Andersen 578454b78d tests: drivers: can: timing: test that calculated timings can be set
Test that each calculated set of timing values can be set.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-04-05 10:33:08 -07:00
Henrik Brix Andersen 35a78fd034 tests: drivers: can: timing: adjust sample point locations
Adjust the sample point locations for the higher bitrates to match those
used in the Linux kernel. These sample points are much more likely to be
met for a wider set of CAN controllers and their timing parameter
boundaries.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-04-05 10:33:08 -07:00
Henrik Brix Andersen 36ae046443 tests: drivers: can: api: run can_set_mode() in userspace
Run the test case for can_set_mode() in userspace to validate the
syscall handler.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-04-04 09:41:35 -05:00
Henrik Brix Andersen 28d9278358 tests: drivers: can: test can_get_core_clock() and can_get_max_bitrate()
Add tests for can_get_core_clock() and can_get_max_bitrate() API
functions.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-04-04 11:15:10 +02:00
Henrik Brix Andersen af2e765dd2 tests: drivers: can: api: add test for can_get_state() API call
Add test case for the can_get_state() API call.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-04-01 12:47:04 -05:00
Henrik Brix Andersen 9759431626 tests: drivers: can: api: test send/receive in userspace
Run CAN send/receive API tests without callbacks in userspace.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-04-01 12:45:39 -05:00
Henrik Brix Andersen a6a07deb53 tests: drivers: can: api: add test for can_recover()
Add test case for can_recover().

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-03-31 10:31:15 +02:00
Henrik Brix Andersen 7a042377f4 tests: drivers: can: utilities: add tests for DLC utility functions
Add tests for can_dlc_to_bytes() and can_bytes_to_dlc() utility
functions.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-03-31 10:30:49 +02:00
Henrik Brix Andersen 4ffe961785 tests: drivers: can: utilities: add doxygen documentation
Add minimal doxygen documentation strings to the CAN utilities test
cases.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-03-31 10:30:49 +02:00
Henrik Brix Andersen e94f112614 tests: drivers: can: utilities: limit testing in CI to native_posix
Limit the CAN utilities tests to run on the native_posix/native_posix_64
boards. There is no need to run this on 400+ boards.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-03-31 10:30:49 +02:00
Henrik Brix Andersen 967978a432 tests: drivers: can: move CAN utilities tests to correct location
Move the CAN utilities tests to the tests/drivers/can/ directory. The
tests/subsys/canbus directory is for tests related to code located in
subsys/canbus.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-03-31 10:30:49 +02:00
Henrik Brix Andersen 68174cd6af test: drivers: can: api: clean up and document the CAN API test cases
Clean up (naming, formatting) the CAN API test cases and add proper
doxygen documentation.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-03-29 17:06:10 -07:00
Henrik Brix Andersen 29548dfb23 tests: drivers: can: timing: extend the test to cover data phase timing
Extend the CAN driver timing tests to cover data phase timing on CAN-FD
capable CAN controllers.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-03-29 17:05:56 -07:00
Henrik Brix Andersen df4297e2a0 tests: drivers: can: timing: extend verification to cover prescaler and sjw
Extend the CAN driver timing calculation test verification to cover the
sjw and prescaler values.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-03-29 17:05:56 -07:00
Henrik Brix Andersen f633f74e03 tests: drivers: can: timing: run CAN timing tests in userspace
Convert the CAN driver timing calculation tests to run in userspace
where available.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-03-29 17:05:56 -07:00
Henrik Brix Andersen 67ba9900f0 drivers: can: add struct device argument to callback functions
Include a pointer to the CAN controller device for the CAN
transmit, receive, and state change callback functions.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-03-19 14:31:22 -04:00
Nazar Kazakov f483b1bc4c everywhere: fix typos
Fix a lot of typos

Signed-off-by: Nazar Kazakov <nazar.kazakov.work@gmail.com>
2022-03-18 13:24:08 -04:00
Henrik Brix Andersen 26e95fac28 tests: drivers: can: timing: convert to the new ztest framework
Convert the CAN timing test to the new ztest framework. Restructure the
tests a bit to improve code readability and add doxygen documentation.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-03-14 11:29:30 +01:00
Henrik Brix Andersen 323a98cd34 tests: drivers: can: filter out tests if zephyr,canbus not enabled
- Filter out the CAN controller driver tests if no zephyr,canbus chosen
  node is enabled in the devicetree.
- Rename the tests to follow the general test naming scheme.
- Remove the dedicated test selection for native_posix boards

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-02-24 07:12:54 -06:00
Flavio Ceolin 0c1950f7b0 tests: Fix drivers tests tag
By convention most tests are using "drivers" and not "driver".

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2022-02-02 09:21:07 -05:00
Henrik Brix Andersen dc7903c0dc tests: drivers: can: stm32: filter out boards without st,stm32-can
Filter out boards without st,stm32-can compatibles enabled in their
devicetree in the stm32-specific CAN driver test.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-01-17 11:47:28 -05:00
Henrik Brix Andersen 5d05d2e3c7 tests: drivers: can: timing: switch to DEVICE_DT_GET()
Switch from using device_get_binding() to DEVICE_DT_GET().

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-01-10 11:24:51 +01:00
Henrik Brix Andersen c8f72460be tests: drivers: can: fd: switch to DEVICE_DT_GET()
Switch from using device_get_binding() to DEVICE_DT_GET().

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-01-10 11:24:51 +01:00
Henrik Brix Andersen 1c4d10b8f7 tests: drivers: can: api: switch to DEVICE_DT_GET()
Switch from using device_get_binding() to DEVICE_DT_GET().

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-01-10 11:24:51 +01:00
Henrik Brix Andersen 8af4bb722d drivers: can: rename API functions for better consistency
Rename a few CAN API functions for clarity and consistency with other
Zephyr RTOS APIs.

CAN_DEFINE_MSGQ() becomes CAN_MSGQ_DEFINE() to match K_MSGQ_DEFINE().

can_attach_isr() becomes can_add_rx_filter() since a filter callback
function is not an interrupt service routine (although it is called in
isr context). The word "attach" is replaced with "add" since filters are
added, not attached. This matches the terminology used is other Zephyr
APIs better.

can_detach() becomes can_remove_rx_filter() to pair with
can_add_rx_filter().

can_attach_msgq() becomes can_add_rx_filter_msgq() and documentation is
updated to mention its relationship with can_add_rx_filter().

can_register_state_change_isr() becomes can_set_state_change_callback()
since a state change callback function is not an interrupt service
routine (although it is called in isr context). The word "register" is
replaced with "set" since only one state change callback can be in
place.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-01-10 10:44:37 +01:00
Henrik Brix Andersen 2ff9de3741 tests: drivers: can: timing: enable loopback tests on native_posix
Enable the CAN timing tests on native_posix and native_posix_64.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-01-04 15:13:40 -06:00
Henrik Brix Andersen 5bc57c1139 tests: drivers: can: api: enable loopback tests on native_posix
Enable the CAN driver loopback tests on native_posix and
native_posix_64.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-01-04 15:13:40 -06:00
Henrik Brix Andersen 99a310b29b drivers: can: loopback: convert the CAN loopback driver to dts
Convert the CAN loopback driver from being configured via Kconfig to
multi-instance configured via devicetree.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-01-04 15:13:40 -06:00
Henrik Brix Andersen b1b77c1774 drivers: can: change can_tx_callback_t function signature
Change the can_tx_callback_t function signature to use an "int" (not an
uint32_t) for representing transmission errors.

The "error" callback function parameter is functionally equivalent to
the return value from can_send() and thus needs to use the same data
type and needs to be able to hold negative errno values.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-01-01 07:40:29 -05:00
Henrik Brix Andersen d1ff466ceb tests: drivers: can: fd: remove can_attach_workq() tests
Remove the tests for can_attach_workq().

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2021-12-22 18:04:02 +01:00
Henrik Brix Andersen aace49f600 tests: drivers: can: api: remove can_attach_workq() tests
Remove the tests for can_attach_workq() and convert the
test_send_receive_buffer() test case to using a message queue.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2021-12-22 18:04:02 +01:00
Henrik Brix Andersen f499559434 drivers: can: deprecate the use of CAN-specific error return values
Deprecate the use of CAN-specific error return values and replace them
with standard errno values.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2021-12-09 12:37:40 -05:00
Henrik Brix Andersen 5bc0451f72 drivers: can: remove DT_CHOSEN_ZEPHYR_CANBUS_LABEL macro
Remove the DT_CHOSEN_ZEPHYR_CANBUS_LABEL macro and replace it with
DEVICE_DT_GET(DT_CHOSEN(zephyr_canbus)) were possible.

Where both devicetree CAN controllers and Kconfig specified CAN loopback
controllers are supported, the macro is replaced with
DT_LABEL(DT_CHOSEN(zephyr_canbus)) for now.

This is the first pass for removing the requirement for devicetree
labels for CAN controllers.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2021-11-09 11:19:50 +01:00
Henrik Brix Andersen c817a09b0a canbus: rename zephyr,can-primary chosen property to zephyr,canbus
Rename the Zephyr chosen property for specifying the default CAN bus
controller from "zephyr,can-primary" to "zephyr,canbus".

The "zephyr,can-primary" property name was selected in antipation of
adding support for redundant CAN networks, which we have yet to
add. Meanwhile, the "primary" term causes confusion for non-redundant
CAN bus configurations (and the "can" term doesn't match the name of the
Zephyr CAN bus subsystem).

The CAN in Automation (CiA) 302-6, which deals with CANopen network
redundancy, uses the terms "default interface" and "redundant
interface". If/when we add support for redundant CAN networks, the
"zephyr,canbus" chosen property can be supplemented with a
"zephyr,canbus-redundant" chosen property.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2021-11-07 09:05:39 -05:00
Torsten Rasmussen 1cccc8a8fe cmake: increase minimal required version to 3.20.0
Move to CMake 3.20.0.

At the Toolchain WG it was decided to move to CMake 3.20.0.

The main reason for increasing CMake version is better toolchain
support.

Better toolchain support is added in the following CMake versions:
- armclang, CMake 3.15
- Intel oneAPI, CMake 3.20
- IAR, CMake 3.15 and 3.20

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-08-20 09:47:34 +02:00
Alexander Wachter 3b2fd1ca0d tests: driver: can: canfd: Add CAN-FD tests
This commit adds tests for CAN-FD frames.

Signed-off-by: Alexander Wachter <alexander@wachter.cloud>
2021-05-07 12:36:10 -05:00
Alexander Wachter 4b722b0efc tests: driver: can: api: Enhanced tests to check dispatching
This commit enhances the CAN API test. In the send_receive tests,
we are using two filters and frames at the same time to check
if the frame gets dispatched to the correct filter.

Signed-off-by: Alexander Wachter <alexander@wachter.cloud>
2021-05-07 12:36:10 -05:00
Alexander Wachter 9f858ac1b6 tests: drivers: can: timing: Fix potential div by zero
If the prescaler is zero in the test, a div by zero would happen.
Add an assert to check for zero prescaler.
Fix CID 216790

Signed-off-by: Alexander Wachter <alexander@wachter.cloud>
2021-02-11 08:54:12 -05:00
Alexander Wachter f6ef508f6f tests: drivers: can: timing
Added tests for the timing algorithm.
The tests calculate timings for some bitrates with sample-points
and verify the results.

Signed-off-by: Alexander Wachter <alexander@wachter.cloud>
2020-12-17 11:07:53 +01:00
Alexander Wachter 05275ecf6e drivers: can: rework zcan_frame and zcan_filter
Reordering of the struct elements to match the Linux format.
The __packed() is not necessary anymore.
std_id and ext_id is merged to id in the frame and filter.
Additionally, the frames are ready for CAN-FD.

Signed-off-by: Alexander Wachter <alexander@wachter.cloud>
2020-12-17 11:07:53 +01:00
Alexander Wachter 8b6c1bd4b7 drivers: can: Rework can_configure API
The previous API can't change the sampling-point and only allowed
bitrates that fit the time segments.
The new API allows for shifting the sampling-point and adjusts the
number of time quantum in a bit to all more possible bitrates.
The functions to calculate the timings are moved to the can_common file.
They can be used for all drivers.

Signed-off-by: Alexander Wachter <alexander@wachter.cloud>
2020-12-17 11:07:53 +01:00
Tomasz Bursztyka e18fcbba5a device: Const-ify all device driver instance pointers
Now that device_api attribute is unmodified at runtime, as well as all
the other attributes, it is possible to switch all device driver
instance to be constant.

A coccinelle rule is used for this:

@r_const_dev_1
  disable optional_qualifier
@
@@
-struct device *
+const struct device *

@r_const_dev_2
 disable optional_qualifier
@
@@
-struct device * const
+const struct device *

Fixes #27399

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-09-02 13:48:13 +02:00
Kumar Gala a1b77fd589 zephyr: replace zephyr integer types with C99 types
git grep -l 'u\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/u\(8\|16\|32\|64\)_t/uint\1_t/g"
	git grep -l 's\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/s\(8\|16\|32\|64\)_t/int\1_t/g"

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-06-08 08:23:57 -05:00
Marc Herbert debade9121 tests: make find_package(Zephyr...) REQUIRED
... because it is (required).

This makes a difference when building with CMake and forgetting
ZEPHYR_BASE or not registering Zephyr in the CMake package registry.

In this particular case, REQUIRED turns this harmless looking log
statement:

-- Could NOT find Zephyr (missing: Zephyr_DIR)
-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is GNU 9.3.0
-- Check for working C compiler: /usr/bin/cc
-- ...
-- ...
-- ...
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at CMakeLists.txt:8 (target_sources):
  Cannot specify sources for target "app" which is not built by
  this project.

... into this louder, clearer, faster and (last but not least) final
error:

CMake Error at CMakeLists.txt:5 (find_package):
  Could not find a package configuration file provided by "Zephyr" with
  any of the following names:

    ZephyrConfig.cmake
    zephyr-config.cmake

  Add the installation prefix of "Zephyr" to CMAKE_PREFIX_PATH or set
  "Zephyr_DIR" to a directory containing one of the above files.  If
  "Zephyr" provides a separate development package or SDK, be sure it
  has been installed.

-- Configuring incomplete, errors occurred!

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2020-05-29 10:47:25 +02:00
Kumar Gala 3f236f2183 can: dts: Convert can-primary alias to zephyr,can-primary chosen prop
Convert CAN to use a chosen node property that is similar to how we
handle zephyr,entroy or zephyr,flash-controller as the means to select a
specific peripheral instance utilized by a subsystem.

Replace references of the form:

alias {
	can-primary = &can1;
};

with:

chosen {
	zephyr,can-primary = &can1;
};

Replace various macro/define references with either
DT_CHOSEN(zephyr_can_primary) or replace DT_ALIAS_CAN_PRIMARY_LABEL
with DT_CHOSEN_ZEPHYR_CAN_PRIMARY_LABEL.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-04-29 14:27:31 -05:00
Torsten Rasmussen 407b49b35c cmake: use find_package to locate Zephyr
Using find_package to locate Zephyr.

Old behavior was to use $ENV{ZEPHYR_BASE} for inclusion of boiler plate
code.

Whenever an automatic run of CMake happend by the build system / IDE
then it was required that ZEPHYR_BASE was defined.
Using ZEPHYR_BASE only to locate the Zephyr package allows CMake to
cache the base variable and thus allowing subsequent invocation even
if ZEPHYR_BASE is not set in the environment.

It also removes the risk of strange build results if a user switchs
between different Zephyr based project folders and forgetting to reset
ZEPHYR_BASE before running ninja / make.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-03-27 16:23:46 +01:00
Alexander Wachter 2f44990e9b can: Introduce can-primary alias
This commit introduces the can-primary alias to identify
the primary CAN interface.
This alias is used for all samples and tests, so they don't
need to probe the right interface.

Signed-off-by: Alexander Wachter <alexander@wachter.cloud>
2020-01-27 10:25:00 -06:00
Anas Nashif 70758c4374 tests: fix test identifiers
The seasonal overhaul of test identifiers aligning the terms being used
and creating a structure. This is hopefully the last time we do this,
plan is to document the identifiers and enforce syntax.

The end-goal is to be able to generate a testsuite description from the
existing tests and sync it frequently with the testsuite in Testrail.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-12-09 15:53:44 -05:00
Alexander Wachter 9eacd1725c tests: can: api: Add MCP2515 DT label to the device name list
Add DT_INST_0_MICROCHIP_MCP2515_LABEL to the list of possible
device labels.

Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
2019-11-06 21:43:40 +01:00
Alexander Wachter d558fd055a drivers: CAN: Limit the DLC to 8
This commit limits the data length code to eight.
DLC > 8 returns a newly introduced CAN_TX_EINVAL error code.

Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
2019-11-06 21:00:45 +01:00
Maksim Masalski 21d866e3e9 tests: remove duplicate names for the peripheral tests
According to the comment in #20008 I found out that some test cases
for different tests have same names.
To get rid of it, I decided to change test cases names.

Signed-off-by: Maksim Masalski <maksim.masalski@intel.com>
2019-10-25 00:29:00 -04:00
Alexander Wachter b81d59d4f2 tests: drivers: can: Add test for TX callback
No test verifies a TX callback for successful transfers.
This commit adds a test for those callbacks.

Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
2019-08-18 15:14:30 +02:00
Anas Nashif c0c9396d44 cleanup: include/: move can.h to drivers/can.h
move can.h to drivers/can.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Henrik Brix Andersen 70c47cba04 tests: drivers: can: stm32: determine CAN device at compile-time
Determine the CAN device (CAN_0 or CAN_1) at compile-time.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2019-06-24 14:33:46 -05:00
Henrik Brix Andersen d2f5a2c1dc tests: drivers: can: api: add support for CAN_0
Add support for using CAN_0 interface in the CAN API tests.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2019-06-24 14:33:46 -05:00
Alexander Wachter acf40cabf9 tests: drivers: can: Make CAN dev global
Get the device binding only once and write it to a global variable.

Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
2019-05-12 16:54:49 -04:00
Alexander Wachter 6b9a6f2465 tests: drivers: can: Add testcases for attach_workq
Add testcases for the new attach_workq API.

Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
2019-05-12 16:54:49 -04:00
Alexander Wachter f1b89eda8e tests: drivers: can: api: define DT_CAN_1_NAME if not defined
Define DT_CAN_1_NAME as an empty string if it is not defined.
This is useful for buildtest where no HW is available.

Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
2019-05-12 16:54:49 -04:00
Alexander Wachter b3b43b8921 drivers: can: Extend can_send with void *arg and pass it to the isr cb
This commit extends the CAN api can_send function by an argument
that is passed to the isr callback.
With this extension it is possible to distinguish between sent masseges
when they use the same callback.

Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
2019-05-12 16:54:49 -04:00
Alexander Wachter 1b93522304 drivers: can: Extend attach_isr with void *arg and pass to the isr cb
This commit extends the CAN api attach_isr function by an argument
that is passed to the isr callback.
With this extension it is possible to distinguish between filter matches
when they use the same callback.

Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
2019-05-12 16:54:49 -04:00
Yannis Damigos 95a5f90ce7 tests: can: api: Fix "Device not not found" error message
Fix "Device not not found" error message.

Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
2019-04-18 16:28:09 -04:00
Anas Nashif 3ae52624ff license: cleanup: add SPDX Apache-2.0 license identifier
Update the files which contain no license information with the
'Apache-2.0' SPDX license identifier.  Many source files in the tree are
missing licensing information, which makes it harder for compliance
tools to determine the correct license.

By default all files without license information are under the default
license of Zephyr, which is Apache version 2.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-04-07 08:45:22 -04:00
Patrik Flykt 24d71431e9 all: Add 'U' suffix when using unsigned variables
Add a 'U' suffix to values when computing and comparing against
unsigned variables.

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2019-03-28 17:15:58 -05:00
Kumar Gala bb6b1918b2 drivers: can: stm32: Cleanup Kconfig enablement
Follow the pattern we have for other peripherals in that if the driver
class (CAN) is enabled than enable the driver for that class
(CAN_STM32).  Also have the STM32 CAN driver depend on being on a STM32
SoC.

Remove setting of CONFIG_CAN_STM32 in any .conf files as it will get set
of CONFIG_CAN is set/enabled.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-02-25 10:05:21 -06:00
Jukka Rissanen 23ba884b2b tests: can: Fix name of CAN msg and filter structs
The name of the CAN message and filter was changed so this
needs to be changed too here.

Fixes #13716

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-02-24 19:00:18 -06:00
Alexander Wachter 548f1f1fff tests: drivers: Add aditional tests for stm32 CAN driver
This commit adds specific stm32 CAN driver testing.
The test covers filter handling.

Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
2019-02-12 09:39:30 -05:00
Alexander Wachter 241f945e49 tests: drivers: Add basic tests for CAN driver
This commit adds basic test for the CAN driver and API.

Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
2019-02-12 09:39:30 -05:00