Skip to content

Commit 99e7854

Browse files
yans6666Rbb666
authored andcommitted
[bsp/renesas][drivers] Added adaptation for ra8p1.
1 parent d79475e commit 99e7854

File tree

22 files changed

+737
-75
lines changed

22 files changed

+737
-75
lines changed

bsp/renesas/libraries/HAL_Drivers/drivers/SConscript

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ if GetDepend(['BSP_USING_SDHI']):
6262
if GetDepend(['BSP_USING_LCD']):
6363
src += ['drv_lcd.c']
6464

65+
if GetDepend(['BSP_USING_RS485']):
66+
src += ['drv_rs485.c']
67+
6568
path = [cwd]
6669
path += [cwd + '/config']
6770

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,32 @@ extern "C"
195195

196196
#endif /* SOC_SERIES_R7FA8M85 */
197197

198+
#ifdef SOC_SERIES_R7KA8P1
199+
200+
#include "ra8/uart_config.h"
201+
202+
#ifdef BSP_USING_PWM
203+
#include "ra8/pwm_config.h"
204+
#endif
205+
206+
#ifdef BSP_USING_ADC
207+
#include "ra8/adc_config.h"
208+
#endif
209+
210+
#ifdef BSP_USING_DAC
211+
#include "ra8/dac_config.h"
212+
#endif
213+
214+
#ifdef BSP_USING_TIM
215+
#include "ra8/timer_config.h"
216+
#endif
217+
218+
#ifdef BSP_USING_CANFD
219+
#include "ra8/canfd_config.h"
220+
#endif
221+
222+
#endif /* SOC_SERIES_R7KA8P1 */
223+
198224
#ifdef SOC_SERIES_R9A07G0
199225
#include "rzt/uart_config.h"
200226
#include "rzt/timer_config.h"

bsp/renesas/libraries/HAL_Drivers/drivers/config/ra8/adc_config.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ struct ra_adc_map
3131
const char *device_name;
3232
const adc_cfg_t *g_cfg;
3333
const adc_ctrl_t *g_ctrl;
34-
const adc_channel_cfg_t *g_channel_cfg;
34+
#ifdef SOC_SERIES_R7KA8P1
35+
const adc_b_scan_cfg_t *g_channel_cfg;
36+
#else
37+
const adc_channel_cfg_t *g_channel_cfg;
38+
#endif
3539
};
3640
#endif
3741
#endif
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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+
#if defined(BSP_USING_CANFD)
18+
19+
#ifdef __cplusplus
20+
extern "C"
21+
{
22+
#endif
23+
24+
#if defined(BSP_USING_CAN0)
25+
#ifndef CAN0_CONFIG
26+
#define CAN0_CONFIG \
27+
{ \
28+
.name = "canfd0", \
29+
.num_of_mailboxs = 48, \
30+
.p_api_ctrl = &g_canfd0_ctrl, \
31+
.p_cfg = &g_canfd0_cfg, \
32+
}
33+
#endif /* CAN0_CONFIG */
34+
#endif /* BSP_USING_CAN0 */
35+
36+
#if defined(BSP_USING_CAN1)
37+
#ifndef CAN1_CONFIG
38+
#define CAN1_CONFIG \
39+
{ \
40+
.name = "canfd1", \
41+
.num_of_mailboxs = 48, \
42+
.p_api_ctrl = &g_canfd1_ctrl, \
43+
.p_cfg = &g_canfd1_cfg, \
44+
}
45+
#endif /* CAN1_CONFIG */
46+
#endif /* BSP_USING_CAN1 */
47+
48+
#ifdef __cplusplus
49+
}
50+
#endif
51+
52+
#endif /* BSP_USING_CANFD */
53+
54+
#endif /* __CAN_CONFIG_H__ */

bsp/renesas/libraries/HAL_Drivers/drivers/config/ra8/pwm_config.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ enum
5858
#endif
5959
#ifdef BSP_USING_PWM12
6060
BSP_PWM12_INDEX,
61+
#endif
62+
#ifdef BSP_USING_PWM13
63+
BSP_PWM13_INDEX,
6164
#endif
6265
BSP_PWMS_NUM
6366
};
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/*
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+
* 2023-09-04 Rbb666 first version
9+
*/
10+
11+
#ifndef __TIMER_CONFIG_H__
12+
#define __TIMER_CONFIG_H__
13+
14+
#include <rtthread.h>
15+
#include "hal_data.h"
16+
17+
#ifdef SOC_SERIES_R7KA8P1
18+
19+
#ifdef __cplusplus
20+
extern "C"
21+
{
22+
#endif
23+
24+
#define PLCKD_PRESCALER_MAX_SELECT 9
25+
#define PLCKD_PRESCALER_250M (250000000U)
26+
#define PLCKD_PRESCALER_200M (200000000U)
27+
#define PLCKD_PRESCALER_100M (100000000U)
28+
#define PLCKD_PRESCALER_50M (50000000U)
29+
#define PLCKD_PRESCALER_25M (25000000U)
30+
#define PLCKD_PRESCALER_12_5M (12500000U)
31+
#define PLCKD_PRESCALER_6_25M (6250000U)
32+
#define PLCKD_PRESCALER_3_125M (3125000U)
33+
#define PLCKD_PRESCALER_1_5625M (1562500U)
34+
35+
#ifndef TMR_DEV_INFO_CONFIG
36+
#define TMR_DEV_INFO_CONFIG \
37+
{ \
38+
.maxfreq = 250000000, \
39+
.minfreq = 1562500, \
40+
.maxcnt = 0XFFFFFFFF, \
41+
.cntmode = HWTIMER_CNTMODE_UP, \
42+
}
43+
#endif /* TIM_DEV_INFO_CONFIG */
44+
45+
enum
46+
{
47+
#ifdef BSP_USING_TIM0
48+
BSP_TIMER0_INDEX,
49+
#endif
50+
#ifdef BSP_USING_TIM1
51+
BSP_TIMER1_INDEX,
52+
#endif
53+
BSP_TIMERS_NUM
54+
};
55+
56+
#define TIMER_DRV_INITIALIZER(num) \
57+
{ \
58+
.name = "timer" #num, \
59+
.g_cfg = &g_timer##num##_cfg, \
60+
.g_ctrl = &g_timer##num##_ctrl, \
61+
.g_timer = &g_timer##num, \
62+
}
63+
64+
#ifdef __cplusplus
65+
}
66+
#endif
67+
68+
#endif /* SOC_SERIES_R7KA8P1 */
69+
70+
#endif /* __TIMER_CONFIG_H__ */

bsp/renesas/libraries/HAL_Drivers/drivers/drv_adc.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,29 @@
2020
#endif /* DRV_DEBUG */
2121
#include <rtdbg.h>
2222

23+
#if defined(SOC_SERIES_R7KA8P1)
24+
25+
#define R_ADC_Open R_ADC_B_Open
26+
#define R_ADC_ScanCfg R_ADC_B_ScanCfg
27+
#define R_ADC_ScanStart R_ADC_B_ScanStart
28+
#define R_ADC_Read32 R_ADC_B_Read32
29+
#define R_ADC_Read R_ADC_B_Read
30+
#define R_ADC_ScanStop R_ADC_B_ScanStop
31+
32+
#endif
33+
2334
struct ra_adc_map ra_adc[] =
2435
{
2536
#ifdef BSP_USING_ADC0
2637
{
2738
.device_name = "adc0",
2839
.g_cfg = &g_adc0_cfg,
2940
.g_ctrl = &g_adc0_ctrl,
41+
#ifdef SOC_SERIES_R7KA8P1
42+
.g_channel_cfg = &g_adc0_scan_cfg,
43+
#else
3044
.g_channel_cfg = &g_adc0_channel_cfg,
45+
#endif
3146
},
3247
#endif
3348
#ifdef BSP_USING_ADC1

bsp/renesas/libraries/HAL_Drivers/drivers/drv_can.c

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,45 @@ static const struct ra_baud_rate_tab can_baud_rate_tab[] =
5858
#define R_CAN_InfoGet R_CANFD_InfoGet
5959
#define R_CAN_Write R_CANFD_Write
6060

61+
#define can0_callback canfd0_callback
62+
#define can1_callback canfd1_callback
63+
64+
const canfd_afl_entry_t p_canfd0_afl[CANFD_CFG_AFL_CH0_RULE_NUM] =
65+
{
66+
{
67+
.id =
68+
{
69+
.id = 0x00,
70+
.frame_type = CAN_FRAME_TYPE_DATA,
71+
.id_mode = CAN_ID_MODE_STANDARD
72+
},
73+
.destination =
74+
{
75+
.minimum_dlc = CANFD_MINIMUM_DLC_0,
76+
.rx_buffer = CANFD_RX_MB_NONE,
77+
.fifo_select_flags = CANFD_RX_FIFO_0
78+
}
79+
},
80+
};
81+
82+
const canfd_afl_entry_t p_canfd1_afl[CANFD_CFG_AFL_CH1_RULE_NUM] =
83+
{
84+
{
85+
.id =
86+
{
87+
.id = 0x01,
88+
.frame_type = CAN_FRAME_TYPE_DATA,
89+
.id_mode = CAN_ID_MODE_STANDARD
90+
},
91+
.destination =
92+
{
93+
.minimum_dlc = CANFD_MINIMUM_DLC_1,
94+
.rx_buffer = CANFD_RX_MB_NONE,
95+
.fifo_select_flags = CANFD_RX_FIFO_1
96+
}
97+
},
98+
};
99+
61100
#endif
62101

63102
static rt_uint32_t get_can_baud_index(rt_uint32_t baud)
@@ -193,7 +232,7 @@ rt_ssize_t ra_can_sendmsg(struct rt_can_device *can_dev, const void *buf, rt_uin
193232
g_can_tx_frame.id_mode = msg_rt->ide;
194233
g_can_tx_frame.type = msg_rt->rtr;
195234
g_can_tx_frame.data_length_code = msg_rt->len;
196-
#if defined(BSP_USING_CANFD) && defined(BSP_USING_CAN_RZ)
235+
#if defined(BSP_USING_CANFD) && (defined(BSP_USING_CAN_RZ) || defined(BSP_USING_CAN_RA))
197236
g_can_tx_frame.options = 0;
198237
#elif defined(BSP_USING_CANFD)
199238
g_can_tx_frame.options = CANFD_FRAME_OPTION_FD | CANFD_FRAME_OPTION_BRS;

bsp/renesas/libraries/HAL_Drivers/drivers/drv_dac.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@
2121
#endif /* DRV_DEBUG */
2222
#include <rtdbg.h>
2323

24+
#if defined(SOC_SERIES_R7KA8P1)
25+
26+
#define R_DAC_Open R_DAC_B_Open
27+
#define R_DAC_Write R_DAC_B_Write
28+
#define R_DAC_Start R_DAC_B_Start
29+
#define R_DAC_Stop R_DAC_B_Stop
30+
31+
#endif
32+
2433
struct ra_dac_map ra_dac[] =
2534
{
2635
#ifdef BSP_USING_DAC0

0 commit comments

Comments
 (0)