Skip to content

Commit 2ccbfd6

Browse files
alexanderwachtergalak
authored andcommitted
drivers: can: Add Kconfig option for CANFD datalenght
Add Kconfig option to select appropriate can data field length Signed-off-by: Alexander Wachter <[email protected]>
1 parent 7dc1ef0 commit 2ccbfd6

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

drivers/can/Kconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,18 @@ config CAN_FD_MODE
2929
help
3030
Enable CAN-FD compatible API
3131

32+
if CAN_FD_MODE
33+
34+
config CANFD_MAX_DLC
35+
int "Max data length code in CAN frames"
36+
range 8 15
37+
default 15
38+
help
39+
Maximum allowed DLC in a CAN frame. This parameter sets the
40+
data buffer size in a CAN frame and is therefore only used to
41+
optimize memory consumption.
42+
endif # CAN_FD_MODE
43+
3244
config CAN_INIT_PRIORITY
3345
int "CAN driver init priority"
3446
default 80

include/drivers/can.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,22 @@ extern "C" {
3333
#define CAN_STD_ID_MASK CAN_MAX_STD_ID
3434
#define CAN_EXT_ID_MASK (0x1FFFFFFF)
3535
#define CAN_MAX_DLC (8)
36+
#define CANFD_MAX_DLC CONFIG_CANFD_MAX_DLC
37+
#ifndef CONFIG_CANFD_MAX_DLC
3638
#define CAN_MAX_DLEN 8
39+
#else
40+
#if CONFIG_CANFD_MAX_DLC <= 8
41+
#define CAN_MAX_DLEN CONFIG_CANFD_MAX_DLC
42+
#elif CONFIG_CANFD_MAX_DLC <= 12
43+
#define CAN_MAX_DLEN CONFIG_CANFD_MAX_DLC + (CONFIG_CANFD_MAX_DLC - 8) * 4
44+
#elif CONFIG_CANFD_MAX_DLC == 13
45+
#define CAN_MAX_DLEN 32
46+
#elif CONFIG_CANFD_MAX_DLC == 14
47+
#define CAN_MAX_DLEN 48
48+
#elif CONFIG_CANFD_MAX_DLC == 15
49+
#define CAN_MAX_DLEN 64
50+
#endif
51+
#endif /* CONFIG_CANFD_MAX_DLC */
3752

3853
/* CAN_TX_* are the error flags from tx_callback and send.*/
3954
/** send successfully */

0 commit comments

Comments
 (0)