Commit graph

193 commits

Author SHA1 Message Date
Henrik Brix Andersen a9d3935fa0 drivers: can: solely use sjw from devicetree for initial timing
Update the CAN controller drivers to solely use the sjw and sjw-data
devicetree properties for setting the initial timing when devicetree timing
parameters are specified in Time Quanta (TQ).

Any timing set via the CAN timing APIs will contain either user-provided or
automatically calculated SJW values. This includes any timing parameters
calculated from bus-speed and bus-speed-data devicetree properties.

Update the CAN controller driver tests accordingly and remove the
CAN_SJW_NO_CHANGE definition as it has lost its meaning.

Fixes: #63033

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2023-09-28 16:28:56 +02:00
Lucas Tamborrino acb04612ac tests: drivers: can: api: add esp32 wrover board
Add esp32_devkitc_wrover boards to supported platforms

Signed-off-by: Lucas Tamborrino <lucas.tamborrino@espressif.com>
2023-08-16 10:25:49 +02:00
Marek Matej 3776402f40 boards: xtensa: esp32 board split
Remove virtual esp32 board and replace it with the
real word boards:

- esp32_devkitc_wroom
- esp32_devkitc_wrover (with PSRAM option)

Signed-off-by: Marek Matej <marek.matej@espressif.com>
2023-07-25 18:12:33 +02:00
Lucas Tamborrino b3fbdc158a tests: drivers: can: add esp32 and esp32s2
Add esp32 and esp32s2_saola boards to platform allow list

Signed-off-by: Lucas Tamborrino <lucas.tamborrino@espressif.com>
2023-07-24 13:25:11 +00:00
Eric Holmberg 4f88b831e7 boards: xiao_esp32s3: update CAN support
Add CAN to supported list and update documentation.

Signed-off-by: Eric Holmberg <eric.holmberg@northriversystems.co.nz>
2023-07-10 15:13:52 +02:00
Eric Holmberg e408d0ea06 boards: esp32s3_devkitm: update CAN support
Add CAN to supported list and update documentation.

Signed-off-by: Eric Holmberg <eric.holmberg@northriversystems.co.nz>
2023-07-10 15:13:52 +02:00
Eric Holmberg 1b919bbc28 tests: drivers: can: api: add virtual CAN TX <-> RX Jumper
Remove the need for the can_transceiver fixture by assigning the CAN TX
and CAN RX lines to the same GPIO pin to allow for testing without a
transceiver or physical jumper.

Signed-off-by: Eric Holmberg <eric.holmberg@northriversystems.co.nz>
2023-07-10 15:13:52 +02:00
Henrik Brix Andersen f3cafe7559 tests: drivers: can: api: do not quote overlay file name
Remove quotes from DTC_OVERLAY_FILE as they break the build.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2023-07-04 11:10:35 +00:00
Henrik Brix Andersen 98ba1175fd tests: drivers: can: api: fix test_set_timing_data_while_started test
Change the test_set_timing_data_while_started test to actually attempt to
set the data phase timing parameters instead of attempting to set the
nominal/arbitration timing parameters.

Update test descriptions to explicitly mention data phase timing.

Fixes: #59046

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2023-06-08 06:50:14 -04:00
Gerard Marull-Paretas 93b63df762 samples, tests: convert string-based twister lists to YAML lists
Twister now supports using YAML lists for all fields that were written
as space-separated lists. Used twister_to_list.py script. Some artifacts
on string length are due to how ruamel dumps content.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-05-10 09:52:37 +02:00
Henrik Brix Andersen ef3d01d16f test: drivers: can: move build-only tests to proper location
Move the build-only test for the MCP2515 CAN controller driver to the
tests/drivers/build_all/can/ folder.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2023-05-01 09:30:42 -05:00
Henrik Brix Andersen bd2651537c tests: drivers: can: api: test filters between CAN-FD/classic CAN modes
Test that filters are preserved when changing between CAN-FD mode and
classic CAN mode and vice versa.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2023-04-13 10:00:03 +02:00
Henrik Brix Andersen 702bc0d954 tests: drivers: can: api: fix comment
Fix comment describing CAN-FD format frame number 2.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2023-04-13 10:00:03 +02:00
Henrik Brix Andersen 719ebb6a27 tests: drivers: can: timing: use recommended sample point
Use the recommended sample point of 75.0% for the data phase bitrate test @
1Mbit/s. This matches the default sample point calculated in
can_common.c:sample_point_for_bitrate().

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2023-03-11 19:45:00 +01:00
Henrik Brix Andersen 332f326ab1 tests: drivers: can: timing: remove superfluous timing test
Remove test for attempting to set an arbitration bitrate of
8000001 bit/s. This test belongs in the data phase timing test, where
it already present as well.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2023-03-11 08:47:34 +02:00
Henrik Brix Andersen 79c8d0e6aa tests: drivers: can: api: add tests for can_frame_matches_filter()
Add CAN API tests for the can_frame_matches_filter() utility function.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2023-02-23 09:00:12 +01:00
Henrik Brix Andersen 4e67546321 tests: drivers: can: api: adjust CAN IDs used for testing
Adjust the CAN IDs used for testing in order for them to match the various
can_*_filter_2 as documented in common.h.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2023-02-23 09:00:12 +01:00
Henrik Brix Andersen 9b39c43714 tests: drivers: can: api: use correct CAN ID in test_ext_masked_filter_2
Use the correct CAN ID in struct can_filter test_ext_masked_filter_2.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2023-02-23 09:00:12 +01:00
Henrik Brix Andersen 8875c3b2e9 tests: drivers: can: move CAN utility function tests to API tests
Move the CAN utility functions tests to a separate test suite under the CAN
API tests.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2023-02-23 09:00:12 +01:00
Henrik Brix Andersen 486b96eea8 tests: drivers: can: api: move test data to common files
Move the test definitions, frames, and filters to common.h/common.c and
reuse them between the classic CAN and CAN-FD API tests.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2023-02-21 18:02:37 -05:00
Henrik Brix Andersen f312ab2d61 tests: drivers: can: fold the CAN-FD tests into the main API tests
Fold the CAN-FD specific tests into the main CAN API tests and stop
treating the CAN-FD API functionality as an add-on to CAN API.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2023-02-21 18:02:37 -05:00
Kumar Gala b582e5df99 tests: drivers: can: shell: increase test stack size
The test fails with a stack overflow on qemu_x86 when we build with
llvm.  Bump the test stack a little addresses the issue.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-02-11 08:14:39 +09:00
Henrik Brix Andersen 55d0ffa874 drivers: can: remove CAN_HAS_CANFD Kconfig helper
Remove the CAN_HAS_CANFD Kconfig helper symbol in order to allow enabling
CAN-FD support in the API regardless of driver support.

Change default to CAN-FD support being disabled and have samples and tests
that require CAN-FD support turn it on. This aligns the default
configuration across CAN controller drivers regardless of their
capabilities.

The rationale behind this is that we are starting to see MCUs with multiple
CAN controllers, some CAN-FD compatible, some not (e.g. NXP i.MX RT1060 and
FPGAs). Automatically enabling CAN-FD support based on the presence of a
CAN-FD capable CAN controller leads to different application default
settings based on the CAN controller(s) in use.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2023-01-25 15:00:39 +00:00
Henrik Brix Andersen c6db73e93d tests: drivers: can: timing: use capabilities to skip tests
Use the CAN controller driver capabilities to determine if the CAN-FD
timing tests should be skipped or not. There is no need for special
handling of CONFIG_CAN_FD_MODE.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2023-01-25 15:00:39 +00:00
Cong Nguyen Huu dd468fc261 tests: drivers: can: canfd: add support filter type frame
Add new filter to configure correctly FD frame.

Signed-off-by: Cong Nguyen Huu <cong.nguyenhuu@nxp.com>
2023-01-04 08:18:13 -06:00
Henrik Brix Andersen f30a5969d0 drivers: can: make the fake CAN driver generally available
Make the fake CAN controller driver available for use in tests outside of
the CAN shell test.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-11-02 08:19:33 -07:00
Henrik Brix Andersen 836f582664 drivers: can: skip all CAN loopback mode tests for kvaser,pcican
Skip all CAN controller tests utilizing CAN loopback mode for the
kvaser,pcican CAN controller card as emulated in QEMU.

QEMU emulation of the SJA1000 CAN controller backend does not yet support
the SJA1000 Self Reception Request command which is required for proper
loopback operation.

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2022-11-01 15:22:31 -04:00
Henrik Brix Andersen c49011442a tests: drivers: can: api: test sending CAN-FD frame in non-FD mode
Add test case for verifying that CAN-FD format frames cannot be sent in
non-FD mode.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-10-25 16:32:10 +02:00
Henrik Brix Andersen f8a88cdb27 drivers: can: use flags fields for can_frame and can_filter structs
The can_frame and can_filter structs support a number of different flags
(standard/extended CAN ID type, Remote Transmission Request, CAN-FD format,
Bit Rate Switch, ...). Each of these flags is represented as a discrete bit
in the given structure.

This design pattern requires every user of these structs to initialize all
of these flags to either 0 or 1, which does not scale well for future flag
additions.

Some of these flags have associated enumerations to be used for assignment,
some do not. CAN drivers and protocols tend to rely on the logical value of
the flag instead of using the enumeration, leading to a very fragile
API. The enumerations are used inconsistently between the can_frame and
can_filter structures, which further complicates the API.

Instead, convert these flags to bitfields with separate flag definitions
for the can_frame and can_filter structures. This API allows for future
extensions without having to revisit existing users of the two
structures. Furthermore, this allows driver to easily check for unsupported
flags in the respective API calls.

As this change leads to the "id_mask" field of the can_filter to be the
only mask present in that structure, rename it to "mask" for simplicity.

Fixes: #50776

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-10-25 16:32:10 +02:00
Martin Jäger 2fd5cbdaf4 tests: drivers: can: api: add twai build-test for esp32c3
The TWAI peripheral needs a connected CAN transceiver also for testing
in loopback mode.

As there is no board available with this configuration, at least make
sure the CAN API test is built in CI for esp32c3_devkitm.

Signed-off-by: Martin Jäger <martin@libre.solar>
2022-10-14 09:55:09 +02:00
Martin Jäger 9cec058e8e boards: posix: native_posix: enable can_loopback0 by default
The .yaml file states that CAN is supported, but the basic sample
application samples/drivers/can/counter cannot be compiled without
additional configuration.

The loopback driver does not require any additional steps like the
linux SocketCAN driver, so it is safe to enable it by default and
get rid of the many overlay files in the tests.

ISO-TP tests and the counter sample are excluded via .yaml from
twister tests because of timing issues.

Signed-off-by: Martin Jäger <martin@libre.solar>
2022-10-03 10:17:12 +02:00
Henrik Brix Andersen 707fa6a1f6 tests: drivers: can: api: skip RTR tests if not supported
Skip the Remote Transmission Request (RTR) frame tests if the CAN
controller driver does not support RTR filters.

Fixes: #50218

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-09-21 08:50:47 +00:00
Henrik Brix Andersen b4af14600a tests: drivers: can: shell: add tests for start/stop shell commands
Add tests for the CAN controller start/stop shell commands.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-09-13 16:06:50 +00:00
Henrik Brix Andersen 6cdb418e5d tests: drivers: can: fd: test returned error codes when started/stopped
Add tests for the required error return codes when the CAN controller is
started/stopped.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-09-13 16:06:50 +00:00
Henrik Brix Andersen 94d37023c6 tests: drivers: can: api: test returned error codes when started/stopped
Add tests for the required error return codes when the CAN controller is
started/stopped.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-09-13 16:06:50 +00:00
Henrik Brix Andersen 180cdc105e drivers: can: add start and stop CAN controller API functions
Up until now, the Zephyr CAN controller drivers set a default bitrate (or
timing) specified via devicetree and start the CAN controller in their
respective driver initialization functions.

This is fine for CAN nodes using only one fixed bitrate, but if the bitrate
is set by the user (e.g. via a DIP-switch or other HMI which is very
common), the CAN driver will still initialise with the default
bitrate/timing at boot and use this until the application has determined
the requested bitrate/timing and set it using
can_set_bitrate()/can_set_timing().

During this period, the CAN node will potentially destroy valid CAN frames
on the CAN bus (which is using the soon-to-be-set-by-the-application
bitrate) by sending error frames. This causes interruptions to the ongoing
CAN bus traffic when a Zephyr-based CAN node connected to the bus is
(re-)booted.

Instead, require all configuration (setting bitrate, timing, or mode) to
take place when the CAN controller is stopped. This maps nicely to entering
"reset mode" (called "configuration mode" or "freeze mode" for some CAN
controller implementations) when stopping and exiting this mode when
starting the CAN controller.

Fixes: #45304

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-09-13 16:06:50 +00:00
Henrik Brix Andersen 6d094d0ad5 tests: drivers: can: api: add missing test case documentation
Add missing CAN controller API test case documentation.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-09-13 16:06:50 +00:00
Henrik Brix Andersen 2f925b47a7 tests: drivers: can: shell: poll for the dummy shell to be ready
Poll for the dummy shell to become ready and fail the tests if not.

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2022-09-06 14:12:33 +00:00
Fabio Baltieri e9e7ad388d tests: drivers: can: add a delay for the shell backend to initialize
The CAN shell test is flaky on some qemu platform (qemu_riscv64_smp in
particular), where the first test command occasionally fails as it tries
to run with the backend not initialized.

The tests for subsys/shell/shell/src/main.c have a setup delay, copying
it to the CAN shell test seems to make it work reliably.

Tested with:
  ./scripts/twister -v -n -M -p qemu_riscv64_smp -T tests/drivers/can/shell

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2022-09-05 19:00:18 +00:00
Henrik Brix Andersen 11ed7d62b7 tests: drivers: can: add test for the CAN shell module
Add test for the CAN shell module.

The tests execute a set of CAN shell module commands against a CAN
controller driver mock, verifies that the expected CAN controller driver
API functions are called, and that their arguments are as expected.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-08-31 10:45:35 +02:00
Gerard Marull-Paretas a202341958 devices: constify device pointers initialized at compile time
Many device pointers are initialized at compile and never changed. This
means that the device pointer can be constified (immutable).

Automated using:

```
perl -i -pe 's/const struct device \*(?!const)(.*)= DEVICE/const struct
device *const $1= DEVICE/g' **/*.c
```

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-08-22 17:08:26 +02:00
Gerard Marull-Paretas e0125d04af devices: constify statically initialized device pointers
It is frequent to find variable definitions like this:

```c
static const struct device *dev = DEVICE_DT_GET(...)
```

That is, module level variables that are statically initialized with a
device reference. Such value is, in most cases, never changed meaning
the variable can also be declared as const (immutable). This patch
constifies all such cases.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-08-19 11:51:26 +02:00
Henrik Brix Andersen 13c75417ba drivers: can: remove z prefix from public CAN API types
Remove the "z" prefix from the public CAN controller API types as this
makes them appear as internal APIs.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-08-18 10:19:29 +02:00
Henrik Brix Andersen 6099e180b1 tests: move the SocketCAN tests to tests/net/socket/can
Move the SocketCAN tests from tests/drivers/can/utilities to
tests/net/socket/can to match the location of the code under test.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-08-18 10:19:29 +02:00
Henrik Brix Andersen fe80c1676d drivers: can: move socketcan types and functions to socketcan header
Move the SocketCAN data types and helper functions from
zephyr/drivers/can.h to zephyr/net/socket_can.h as these are not used by
the low-level CAN controller driver API.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-08-18 10:19:29 +02:00
Henrik Brix Andersen f04741da75 tests: drivers: can: utilities: convert to new ztest API
Convert the CAN utilities test suite to use the new ztest API.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-08-12 13:23:00 +02:00
Henrik Brix Andersen b4033d25f6 tests: drivers: can: timing: convert to new ztest API
Convert the CAN controller timing test suite to use the new ztest API.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-08-12 13:23:00 +02:00
Henrik Brix Andersen d6c211ef79 tests: drivers: can: canfd: convert to new ztest API
Convert the CAN-FD controller driver API test suite to use the new ztest
API.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-08-12 13:23:00 +02:00
Henrik Brix Andersen d9a1aab22a tests: drivers: can: api: convert to new ztest API
Convert the CAN controller driver API test suite to use the new ztest API.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-08-12 13:23:00 +02:00
Martin Jäger afb26d0cc9 tests: drivers: can: remove dedicated stm32 bxCAN test
Not needed anymore after simplification of the filter handling.

Signed-off-by: Martin Jäger <martin@libre.solar>
2022-08-03 05:02:09 +01:00
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