Skip to content

Commit bf0fed2

Browse files
committed
[drivers][bsp][reness] Add Etherkit bsp and RZ series driver compatibility adaptation
1 parent 12fded1 commit bf0fed2

File tree

148 files changed

+91722
-167
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

148 files changed

+91722
-167
lines changed

.github/workflows/bsp_buildings.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ jobs:
248248
- "renesas/ra8d1-vision-board"
249249
- "renesas/rzt2m_rsk"
250250
- "renesas/rzn2l_rsk"
251+
- "renesas/rzn2l_etherkit"
251252
- "frdm-k64f"
252253
- "xplorer4330/M4"
253254
- RTT_BSP: "nuvoton"

bsp/renesas/libraries/HAL_Drivers/SConscript

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ if GetDepend(['BSP_USING_TIM']):
5555
if GetDepend(['BSP_USING_ETH']):
5656
src += ['drv_eth.c']
5757

58-
if GetDepend(['BSP_USING_CAN']):
58+
if GetDepend(['BSP_USING_CAN']) or GetDepend('BSP_USING_CANFD'):
5959
src += ['drv_can.c']
6060

6161
if GetDepend(['BSP_USING_SDHI']):

bsp/renesas/libraries/HAL_Drivers/config/drv_config.h

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
/*
2-
* Copyright (c) 2006-2023, RT-Thread Development Team
3-
*
4-
* SPDX-License-Identifier: Apache-2.0
5-
*
6-
* Change Logs:
7-
* Date Author Notes
8-
* 2021-07-29 KyleChan first version
9-
* 2022-12-7 Vandoul ADD ra4m2
10-
*/
2+
* Copyright (c) 2006-2023, RT-Thread Development Team
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Change Logs:
7+
* Date Author Notes
8+
* 2021-07-29 KyleChan first version
9+
* 2022-12-7 Vandoul ADD ra4m2
10+
*/
1111

1212
#ifndef __DRV_CONFIG_H__
1313
#define __DRV_CONFIG_H__
@@ -145,6 +145,10 @@ extern "C"
145145
#include "rzt/uart_config.h"
146146
#include "rzt/timer_config.h"
147147

148+
#ifdef BSP_USING_CANFD
149+
#include "rzt/canfd_config.h"
150+
#endif
151+
148152
#ifdef BSP_USING_PWM
149153
#include "rzt/pwm_config.h"
150154
#endif
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
/*
2+
* Copyright (c) 2006-2025, RT-Thread Development Team
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Change Logs:
7+
* Date Author Notes
8+
* 2025-02-11 kurisaW first version
9+
*/
10+
11+
#ifndef __CAN_CONFIG_H__
12+
#define __CAN_CONFIG_H__
13+
14+
#include <rtthread.h>
15+
#include "hal_data.h"
16+
17+
#ifdef __cplusplus
18+
extern "C"
19+
{
20+
#endif
21+
22+
#if defined(BSP_USING_CAN0)
23+
#ifndef CANFD0_CONFIG
24+
#define CANFD0_CONFIG \
25+
{ \
26+
.name = "canfd0", \
27+
.num_of_mailboxs = 48, \
28+
.p_api_ctrl = &g_canfd0_ctrl, \
29+
.p_cfg = &g_canfd0_cfg, \
30+
}
31+
#endif /* CAN0_CONFIG */
32+
#endif /* BSP_USING_CAN0 */
33+
34+
#if defined(BSP_USING_CAN1)
35+
#ifndef CANFD1_CONFIG
36+
#define CANFD1_CONFIG \
37+
{ \
38+
.name = "canfd1", \
39+
.num_of_mailboxs = 48, \
40+
.p_api_ctrl = &g_canfd1_ctrl, \
41+
.p_cfg = &g_canfd1_cfg, \
42+
}
43+
#endif /* CAN1_CONFIG */
44+
#endif /* BSP_USING_CAN1 */
45+
46+
const canfd_afl_entry_t p_canfd0_afl[CANFD_CFG_AFL_CH0_RULE_NUM] =
47+
{
48+
{
49+
.id =
50+
{
51+
.id = 0x00,
52+
.frame_type = CAN_FRAME_TYPE_DATA,
53+
.id_mode = CAN_ID_MODE_STANDARD
54+
},
55+
.destination =
56+
{
57+
.minimum_dlc = CANFD_MINIMUM_DLC_0,
58+
.rx_buffer = CANFD_RX_MB_NONE,
59+
.fifo_select_flags = CANFD_RX_FIFO_0
60+
}
61+
},
62+
};
63+
64+
const canfd_afl_entry_t p_canfd1_afl[CANFD_CFG_AFL_CH1_RULE_NUM] =
65+
{
66+
{
67+
.id =
68+
{
69+
.id = 0x01,
70+
.frame_type = CAN_FRAME_TYPE_DATA,
71+
.id_mode = CAN_ID_MODE_STANDARD
72+
},
73+
.destination =
74+
{
75+
.minimum_dlc = CANFD_MINIMUM_DLC_1,
76+
.rx_buffer = CANFD_RX_MB_NONE,
77+
.fifo_select_flags = CANFD_RX_FIFO_1
78+
}
79+
},
80+
};
81+
82+
#ifdef __cplusplus
83+
}
84+
#endif
85+
#endif

bsp/renesas/libraries/HAL_Drivers/drv_can.c

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* Change Logs:
77
* Date Author Notes
88
* 2021-10-29 mazhiyuan first version
9+
* 2025-02-11 kurisaW support can and canfd drivers for RZ family
910
*/
1011

1112
#include "drv_can.h"
@@ -47,6 +48,18 @@ static const struct ra_baud_rate_tab can_baud_rate_tab[] =
4748
{CAN10kBaud, 4, 14, 5, 1 + 249}
4849
};
4950

51+
#if defined(BSP_USING_CANFD)
52+
53+
#define can_instance_ctrl_t canfd_instance_ctrl_t
54+
55+
#define R_CAN_Open R_CANFD_Open
56+
#define R_BSP_IrqStatusClear R_BSP_IrqClearPending
57+
#define R_CAN_ModeTransition R_CANFD_ModeTransition
58+
#define R_CAN_InfoGet R_CANFD_InfoGet
59+
#define R_CAN_Write R_CANFD_Write
60+
61+
#endif
62+
5063
static rt_uint32_t get_can_baud_index(rt_uint32_t baud)
5164
{
5265
rt_uint32_t len, index;
@@ -66,13 +79,13 @@ static void ra_can_get_config(void)
6679
struct can_configure config = CANDEFAULTCONFIG;
6780
#ifdef BSP_USING_CAN0
6881
can_obj[CAN0_INDEX].can_dev.config = config;
69-
can_obj[CAN0_INDEX].can_dev.config.msgboxsz = CAN_NO_OF_MAILBOXES_g_can0;
82+
can_obj[CAN0_INDEX].can_dev.config.msgboxsz = 32;
7083
can_obj[CAN0_INDEX].can_dev.config.sndboxnumber = 1;
7184
can_obj[CAN0_INDEX].can_dev.config.ticks = 50;
7285
#endif
7386
#ifdef BSP_USING_CAN1
7487
can_obj[CAN1_INDEX].can_dev.config = config;
75-
can_obj[CAN1_INDEX].can_dev.config.msgboxsz = CAN_NO_OF_MAILBOXES_g_can1;
88+
can_obj[CAN1_INDEX].can_dev.config.msgboxsz = 32;
7689
can_obj[CAN1_INDEX].can_dev.config.sndboxnumber = 1;
7790
can_obj[CAN1_INDEX].can_dev.config.ticks = 50;
7891
#endif
@@ -168,7 +181,7 @@ rt_err_t ra_can_control(struct rt_can_device *can_dev, int cmd, void *arg)
168181
}
169182
return RT_EOK;
170183
}
171-
int ra_can_sendmsg(struct rt_can_device *can_dev, const void *buf, rt_uint32_t boxno)
184+
rt_ssize_t ra_can_sendmsg(struct rt_can_device *can_dev, const void *buf, rt_uint32_t boxno)
172185
{
173186
struct ra_can *can;
174187
can_frame_t g_can_tx_frame;
@@ -180,7 +193,13 @@ int ra_can_sendmsg(struct rt_can_device *can_dev, const void *buf, rt_uint32_t b
180193
g_can_tx_frame.id_mode = msg_rt->ide;
181194
g_can_tx_frame.type = msg_rt->rtr;
182195
g_can_tx_frame.data_length_code = msg_rt->len;
196+
#if defined(BSP_USING_CANFD) && defined(BSP_USING_CAN_RZ)
197+
g_can_tx_frame.options = 0;
198+
#elif defined(BSP_USING_CANFD)
199+
g_can_tx_frame.options = CANFD_FRAME_OPTION_FD | CANFD_FRAME_OPTION_BRS;
200+
#else
183201
g_can_tx_frame.options = 0;
202+
#endif
184203
memcpy(g_can_tx_frame.data, msg_rt->data, 8);
185204
can = rt_container_of(can_dev, struct ra_can, can_dev);
186205
RT_ASSERT(boxno < can->config->num_of_mailboxs);
@@ -193,7 +212,7 @@ int ra_can_sendmsg(struct rt_can_device *can_dev, const void *buf, rt_uint32_t b
193212
return RT_EOK;
194213
}
195214

196-
int ra_can_recvmsg(struct rt_can_device *can_dev, void *buf, rt_uint32_t boxno)
215+
rt_ssize_t ra_can_recvmsg(struct rt_can_device *can_dev, void *buf, rt_uint32_t boxno)
197216
{
198217
struct rt_can_msg *msg_rt = (struct rt_can_msg *)buf;
199218
can_frame_t *msg_ra;
@@ -205,7 +224,11 @@ int ra_can_recvmsg(struct rt_can_device *can_dev, void *buf, rt_uint32_t boxno)
205224
RT_ASSERT(boxno < can->config->num_of_mailboxs);
206225
if (can->callback_args->mailbox != boxno)
207226
return 0;
227+
#if defined(BSP_USING_CANFD)
228+
msg_ra = &can->callback_args->frame;
229+
#else
208230
msg_ra = can->callback_args->p_frame;
231+
#endif
209232

210233
msg_rt->id = msg_ra->id;
211234
msg_rt->ide = msg_ra->id_mode;

bsp/renesas/libraries/HAL_Drivers/drv_common.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ static void SysTimerInterrupt(void);
3636
static void reboot(uint8_t argc, char **argv)
3737
{
3838
#ifdef SOC_SERIES_R9A07G0
39-
return;
39+
R_BSP_RegisterProtectDisable(BSP_REG_PROTECT_LPC_RESET);
40+
R_BSP_SystemReset();
4041
#else
4142
NVIC_SystemReset();
4243
#endif

0 commit comments

Comments
 (0)