Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions arch/arm/src/imxrt/imxrt_flexcan.c
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ static int imxrt_transmit(struct imxrt_driver_s *priv)

cs.rtr = frame->can_id & FLAGRTR ? 1 : 0;

cs.dlc = len_to_can_dlc[frame->len];
cs.dlc = g_len_to_can_dlc[frame->len];

frame_data_word = (uint32_t *)&frame->data[0];

Expand Down Expand Up @@ -877,7 +877,7 @@ static void imxrt_receive(struct imxrt_driver_s *priv,
frame->can_id |= FLAGRTR;
}

frame->len = can_dlc_to_len[rf->cs.dlc];
frame->len = g_can_dlc_to_len[rf->cs.dlc];

frame_data_word = (uint32_t *)&frame->data[0];

Expand Down
4 changes: 2 additions & 2 deletions arch/arm/src/kinetis/kinetis_flexcan.c
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ static int kinetis_transmit(struct kinetis_driver_s *priv)

cs.rtr = frame->can_id & FLAGRTR ? 1 : 0;

cs.dlc = len_to_can_dlc[frame->len];
cs.dlc = g_len_to_can_dlc[frame->len];

frame_data_word = (uint32_t *)&frame->data[0];

Expand Down Expand Up @@ -877,7 +877,7 @@ static void kinetis_receive(struct kinetis_driver_s *priv,
frame->can_id |= FLAGRTR;
}

frame->len = can_dlc_to_len[rf->cs.dlc];
frame->len = g_can_dlc_to_len[rf->cs.dlc];

frame_data_word = (uint32_t *)&frame->data[0];

Expand Down
4 changes: 2 additions & 2 deletions arch/arm/src/s32k1xx/s32k1xx_flexcan.c
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ static int s32k1xx_transmit(struct s32k1xx_driver_s *priv)

cs.rtr = frame->can_id & FLAGRTR ? 1 : 0;

cs.dlc = len_to_can_dlc[frame->len];
cs.dlc = g_len_to_can_dlc[frame->len];

frame_data_word = (uint32_t *)&frame->data[0];

Expand Down Expand Up @@ -881,7 +881,7 @@ static void s32k1xx_receive(struct s32k1xx_driver_s *priv,
frame->can_id |= FLAGRTR;
}

frame->len = can_dlc_to_len[rf->cs.dlc];
frame->len = g_can_dlc_to_len[rf->cs.dlc];

frame_data_word = (uint32_t *)&frame->data[0];

Expand Down
4 changes: 2 additions & 2 deletions arch/arm/src/s32k3xx/s32k3xx_flexcan.c
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,7 @@ static int s32k3xx_transmit(struct s32k3xx_driver_s *priv)

cs.rtr = frame->can_id & FLAGRTR ? 1 : 0;

cs.dlc = len_to_can_dlc[frame->len];
cs.dlc = g_len_to_can_dlc[frame->len];

frame_data_word = (uint32_t *)&frame->data[0];

Expand Down Expand Up @@ -1041,7 +1041,7 @@ static void s32k3xx_receive(struct s32k3xx_driver_s *priv, uint32_t flags)
frame->can_id |= FLAGRTR;
}

frame->len = can_dlc_to_len[rf->cs.dlc];
frame->len = g_can_dlc_to_len[rf->cs.dlc];

frame_data_word = (uint32_t *)&frame->data[0];

Expand Down
6 changes: 3 additions & 3 deletions arch/arm/src/stm32/stm32_fdcan_sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -1749,7 +1749,7 @@ static int fdcan_send(struct stm32_fdcan_s *priv)

/* Set DLC */

txbuffer[1] |= BUFFER_R1_DLC(len_to_can_dlc[frame->len]);
txbuffer[1] |= BUFFER_R1_DLC(g_len_to_can_dlc[frame->len]);

/* Set flags */

Expand Down Expand Up @@ -2467,8 +2467,8 @@ static void fdcan_receive(struct stm32_fdcan_s *priv,

/* Word R1 contains the DLC and timestamp */

frame->len = can_dlc_to_len[((rxbuffer[1] & BUFFER_R1_DLC_MASK) >>
BUFFER_R1_DLC_SHIFT)];
frame->len = g_can_dlc_to_len[((rxbuffer[1] & BUFFER_R1_DLC_MASK) >>
BUFFER_R1_DLC_SHIFT)];

/* Get CANFD flags */

Expand Down
4 changes: 2 additions & 2 deletions arch/arm/src/stm32h7/stm32_fdcan_sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ static int fdcan_transmit(struct fdcan_driver_s *priv)

header.id.esi = (frame->can_id & CAN_ERR_FLAG) ? 1 : 0;
header.id.rtr = (frame->can_id & CAN_RTR_FLAG) ? 1 : 0;
header.dlc = len_to_can_dlc[frame->len];
header.dlc = g_len_to_can_dlc[frame->len];
header.brs = brs; /* Bitrate switching */
header.fdf = 1; /* CAN-FD frame */
header.efc = 0; /* Don't store Tx events */
Expand Down Expand Up @@ -1161,7 +1161,7 @@ static void fdcan_receive_work(void *arg)
frame->can_id |= CAN_RTR_FLAG;
}

frame->len = can_dlc_to_len[rf->header.dlc];
frame->len = g_can_dlc_to_len[rf->header.dlc];

uint32_t *frame_data_word = (uint32_t *)&frame->data[0];

Expand Down
9 changes: 5 additions & 4 deletions include/nuttx/net/can.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,11 @@
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/

#ifdef CONFIG_NET_CAN_CANFD
#define NET_CAN_PKTSIZE sizeof(struct canfd_frame)
# define NET_CAN_PKTSIZE sizeof(struct canfd_frame)
#else
#define NET_CAN_PKTSIZE sizeof(struct can_frame)
# define NET_CAN_PKTSIZE sizeof(struct can_frame)
#endif

/****************************************************************************
Expand All @@ -70,8 +71,8 @@

/* Lookup tables convert can_dlc <-> payload len */

extern const uint8_t can_dlc_to_len[16];
extern const uint8_t len_to_can_dlc[65];
extern const uint8_t g_can_dlc_to_len[16];
extern const uint8_t g_len_to_can_dlc[65];

#endif

Expand Down
166 changes: 83 additions & 83 deletions net/can/can_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,92 +40,92 @@
* Public Data
****************************************************************************/

const uint8_t can_dlc_to_len[16] =
const uint8_t g_can_dlc_to_len[16] =
{
0,
1,
2,
3,
4,
5,
6,
7,
8,
12,
16,
20,
24,
32,
48,
64,
0,
1,
2,
3,
4,
5,
6,
7,
8,
12,
16,
20,
24,
32,
48,
64,
};
const uint8_t len_to_can_dlc[65] =
const uint8_t g_len_to_can_dlc[65] =
{
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
9,
9,
9,
10,
10,
10,
10,
11,
11,
11,
11,
12,
12,
12,
12,
13,
13,
13,
13,
13,
13,
13,
13,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
9,
9,
9,
10,
10,
10,
10,
11,
11,
11,
11,
12,
12,
12,
12,
13,
13,
13,
13,
13,
13,
13,
13,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
14,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
};

/****************************************************************************
Expand Down