Skip to content

Commit

Permalink
drivers: can: Add Kconfig option for CANFD datalenght
Browse files Browse the repository at this point in the history
Add Kconfig option to select appropriate can data field length

Signed-off-by: Alexander Wachter <[email protected]>
  • Loading branch information
alexanderwachter authored and galak committed May 7, 2021
1 parent 7dc1ef0 commit 2ccbfd6
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
12 changes: 12 additions & 0 deletions drivers/can/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,18 @@ config CAN_FD_MODE
help
Enable CAN-FD compatible API

if CAN_FD_MODE

config CANFD_MAX_DLC
int "Max data length code in CAN frames"
range 8 15
default 15
help
Maximum allowed DLC in a CAN frame. This parameter sets the
data buffer size in a CAN frame and is therefore only used to
optimize memory consumption.
endif # CAN_FD_MODE

config CAN_INIT_PRIORITY
int "CAN driver init priority"
default 80
Expand Down
15 changes: 15 additions & 0 deletions include/drivers/can.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,22 @@ extern "C" {
#define CAN_STD_ID_MASK CAN_MAX_STD_ID
#define CAN_EXT_ID_MASK (0x1FFFFFFF)
#define CAN_MAX_DLC (8)
#define CANFD_MAX_DLC CONFIG_CANFD_MAX_DLC
#ifndef CONFIG_CANFD_MAX_DLC
#define CAN_MAX_DLEN 8
#else
#if CONFIG_CANFD_MAX_DLC <= 8
#define CAN_MAX_DLEN CONFIG_CANFD_MAX_DLC
#elif CONFIG_CANFD_MAX_DLC <= 12
#define CAN_MAX_DLEN CONFIG_CANFD_MAX_DLC + (CONFIG_CANFD_MAX_DLC - 8) * 4
#elif CONFIG_CANFD_MAX_DLC == 13
#define CAN_MAX_DLEN 32
#elif CONFIG_CANFD_MAX_DLC == 14
#define CAN_MAX_DLEN 48
#elif CONFIG_CANFD_MAX_DLC == 15
#define CAN_MAX_DLEN 64
#endif
#endif /* CONFIG_CANFD_MAX_DLC */

/* CAN_TX_* are the error flags from tx_callback and send.*/
/** send successfully */
Expand Down

0 comments on commit 2ccbfd6

Please sign in to comment.