1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-20 20:13:50 +01:00

7 Commits

Author SHA1 Message Date
Marian Buschsieweke
780a02ef6c
tests/drivers/candev: minor cleanup
- Do not hard code the number of the CAN interface to use. (This
  also allows specifying it via make command line / environment
  variable.)
- Make less use of preprocessor and rely on compiler to eliminate dead
  branches and unused variables.

Co-authored-by: crasbe <crasbe@gmail.com>
2025-04-06 20:19:16 +02:00
Marian Buschsieweke
a9ff36d68e
tests/drivers/candev: Drop SAME54-XPRO hack
Now that power management of the CAN transceiver is done by the driver,
we do no longer need a per-board hack in the app.
2025-03-12 16:05:40 +01:00
Gilles DOFFE
f6f6f6973c can: introduce typedef can_frame_t
Whole CAN code in RIOT is using 'struct can_frame' to represent a CAN
frame.
However incoming CAN FD support will bring 'struct canfd_frame' to
represent CAN FD frames.
Even if the 'struct canfd_frame' has additional flags and a bigger
payload, it is aligned on 'struct can_frame' and thus they can be
referenced by the same pointers in the code.

As it is impossible to predict which one will be used in RIOT, just
define a new type 'can_frame_t' which will map to the right struct
according to the MCU CAN supported format.

Signed-off-by: Gilles DOFFE <gilles.doffe@rtone.fr>
2025-01-29 20:51:22 +01:00
Gilles DOFFE
ae51a22fbb can: use frame len instead of can_dlc
RIOT implementation of CAN bus relies on SocketCAN model.
Since commit c398e56 (can: add optional DLC element to Classical CAN
frame structure), '__u8 can_dlc' attribute of struct can_frame is
considered as deprecated in SocketCAN and kept for legacy support.
Attribute '__u8 len' should be used instead.

	union {
		/* CAN frame payload length in byte (0 .. CAN_MAX_DLEN)
		 * was previously named can_dlc so we need to carry that
		 * name for legacy support
		 */
		__u8 len;
		__u8 can_dlc; /* deprecated */
	};

Moreover, CAN FD frame structure does not support legacy attribute
'can_dlc', making 'len' mandatory for incoming CAN FD support in RIOT.

	struct canfd_frame {
		canid_t can_id;  /* 32 bit CAN_ID + EFF/RTR/ERR flags */
		__u8    len;     /* frame payload length in byte */
		__u8    flags;   /* additional flags for CAN FD */
		__u8    __res0;  /* reserved / padding */
		__u8    __res1;  /* reserved / padding */
		__u8    data[CANFD_MAX_DLEN]
__attribute__((aligned(8)));
	};

Signed-off-by: Gilles DOFFE <gilles.doffe@rtone.fr>
2025-01-29 20:51:22 +01:00
Firas Hamdi
31003bf323 tests/drivers/candev: add debug output concerning errors 2024-05-16 15:00:28 +02:00
Firas Hamdi
491a1cdf2b tests/drivers/candev: add test commands 2024-03-26 15:17:48 +01:00
Alexandre Abadie
4020692be3
tests/candev: move to tests/drivers 2023-05-12 14:24:40 +02:00