Skip to content

Commit 0781caf

Browse files
congnguyenhuuaescolar
authored andcommitted
drivers: can: nxp_s32_canxl: calculate and set the TDCO
Calculate and set the Transceiver Delay Compensation Offset (TDCO). Fixes #73824 Signed-off-by: Cong Nguyen Huu <cong.nguyenhuu@nxp.com>
1 parent 7dc830e commit 0781caf

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

drivers/can/can_nxp_s32_canxl.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@
4343
#define CAN_NXP_S32_MAX_BITRATE 8000000
4444
#define CAN_NXP_S32_DATA_LENGTH 64
4545

46+
#define CAN_NXP_S32_TDCO_MAX FIELD_GET(CANXL_SIC_BTDCC_FTDCOFF_MASK, CANXL_SIC_BTDCC_FTDCOFF_MASK)
47+
4648
#ifdef CONFIG_CAN_NXP_S32_RX_FIFO
4749
/* RX FIFO depth is fixed to the maximum value */
4850
#define CAN_NXP_S32_RX_FIFO_DEPTH 32
@@ -706,6 +708,9 @@ static int can_nxp_s32_set_timing_data(const struct device *dev,
706708
/* Set timing for CAN FD instance*/
707709
CanXL_SetFDBaudRate(config->base_sic, &can_fd_time_segment);
708710

711+
Canexcel_Ip_SetTDCOffsetFD(config->instance, true, false,
712+
CAN_CALC_TDCO((timing_data), 0U, CAN_NXP_S32_TDCO_MAX));
713+
709714
return 0;
710715
}
711716
#endif
@@ -964,6 +969,11 @@ static int can_nxp_s32_init(const struct device *dev)
964969
/* Initialize CAN structure */
965970
Canexcel_Ip_Init(config->instance, config->can_cfg, data->can_state);
966971

972+
#ifdef CAN_NXP_S32_FD_MODE
973+
Canexcel_Ip_SetTDCOffsetFD(config->instance, true, false,
974+
CAN_CALC_TDCO((&data->timing_data), 0U, CAN_NXP_S32_TDCO_MAX));
975+
#endif
976+
967977
/* Configure time stamp */
968978
#ifdef CONFIG_CAN_RX_TIMESTAMP
969979
Canexcel_Ip_ConfigTimeStamp(config->instance, &time_stamp);

0 commit comments

Comments
 (0)