Commit Graph

28 Commits

Author SHA1 Message Date
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
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
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 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 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 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 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 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 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 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 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 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 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 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