drivers: can: Add Kconfig option for CANFD datalenght

Add Kconfig option to select appropriate can data field length

Signed-off-by: Alexander Wachter <alexander@wachter.cloud>
This commit is contained in:
Alexander Wachter 2021-01-17 20:09:05 +01:00 committed by Kumar Gala
commit 2ccbfd661e
2 changed files with 27 additions and 0 deletions

View file

@ -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

View file

@ -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 */