Commit graph

9 commits

Author SHA1 Message Date
Henrik Brix Andersen a57db0ddcb drivers: can: rework support for manual bus-off recovery
Since all CAN controllers drivers seem to support automatic recovery (for
any future drivers for hardware without this hardware capability this can
easily be implemented in the driver), change the Zephyr CAN controller API
policy to:

- Always enable automatic bus recovery upon driver initialization,
  regardless of Kconfig options. Since CAN controllers are initialized in
  "stopped" state, no unwanted bus-off recovery will be started at this
  point.

- Invert and rename the Kconfig CONFIG_CAN_AUTO_BUS_OFF_RECOVERY, which is
  enabled by default, to CONFIG_CAN_MANUAL_RECOVERY_MODE, which is disabled
  by default. Enabling CONFIG_CAN_MANUAL_RECOVERY_MODE=y enables support
  for the can_recover() API function and a new manual recovery mode (see
  next bullet). Keeping this guarded by Kconfig allows keeping the flash
  footprint down for applications not using manual bus-off recovery.

- Introduce a new CAN controller operational mode
  CAN_MODE_MANUAL_RECOVERY. Support for this is only enabled if
  CONFIG_CAN_MANUAL_RECOVERY_MODE=y. Having this as a mode allows
  applications to inquire whether the CAN controller supports manual
  recovery mode via the can_get_capabilities() API function and either fail
  or rely on automatic recovery - and it allows CAN controller drivers not
  supporting manual recovery mode to fail early in can_set_mode() during
  application startup instead of failing when can_recover() is called at a
  later point in time.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2024-03-02 18:26:48 +01:00
Henrik Brix Andersen 8beb0a3564 tests: drivers: can: api: add simple test for CAN stats accessors
Add a simple test to validate that the CAN statistics accessor functions
can be called from user mode threads.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2023-10-23 10:33:04 +02:00
Anas Nashif 345735d0a8 tests: remove CONFIG_ZTEST_NEW_API in all tests
Remove all usage of CONFIG_ZTEST_NEW_API from tests and sample as this
is now enabled by default.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-10-20 15:04:29 +02: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
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 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
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
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 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