Skip to content

Commit 8a646c5

Browse files
authored
[bsp][renesas] add EK-RA2E2 other device drivers support (#10695)
* [bsp][renesas]add EK-RA2E2 sci_uart support * [bsp][renesas] add EK-RA2E2 (i2c/spi/adc/pwm/flash/gpio interrupt) support * [bsp][renesas] comment drv_flash.c and format drv_i2c.c
1 parent f1bbaf1 commit 8a646c5

File tree

15 files changed

+263
-26
lines changed

15 files changed

+263
-26
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,15 @@ extern "C"
8787

8888
#ifdef SOC_SERIES_R7FA2E2
8989
#include "ra2e2/uart_config.h"
90+
91+
#ifdef BSP_USING_PWM
92+
#include "ra2e2/pwm_config.h"
93+
#endif
94+
95+
#ifdef BSP_USING_ADC
96+
#include "ra2e2/adc_config.h"
97+
#endif
98+
9099
#endif /* SOC_SERIES_R7FA2E2 */
91100

92101
#ifdef SOC_SERIES_R7FA2L1
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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-08-17 CYFS first version
9+
*/
10+
11+
#ifndef __ADC_CONFIG_H__
12+
#define __ADC_CONFIG_H__
13+
14+
#include <rtthread.h>
15+
#include <rtdevice.h>
16+
#include "hal_data.h"
17+
#ifdef __cplusplus
18+
extern "C" {
19+
#endif
20+
21+
#if defined(BSP_USING_ADC0)
22+
23+
struct rt_adc_dev
24+
{
25+
struct rt_adc_ops ops;
26+
struct rt_adc_device adc_device;
27+
};
28+
29+
struct ra_adc_map
30+
{
31+
const char *device_name;
32+
const adc_cfg_t *g_cfg;
33+
const adc_ctrl_t *g_ctrl;
34+
const adc_channel_cfg_t *g_channel_cfg;
35+
};
36+
#endif
37+
#endif
38+
39+
#ifdef __cplusplus
40+
}
41+
#endif
42+
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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-08-17 CYFS first version
9+
*/
10+
#ifndef __PWM_CONFIG_H__
11+
#define __PWM_CONFIG_H__
12+
13+
#include <rtthread.h>
14+
#include <drv_config.h>
15+
#include "hal_data.h"
16+
17+
#ifdef __cplusplus
18+
extern "C" {
19+
#endif
20+
21+
enum
22+
{
23+
#ifdef BSP_USING_PWM4
24+
BSP_PWM4_INDEX,
25+
#endif
26+
#ifdef BSP_USING_PWM5
27+
BSP_PWM5_INDEX,
28+
#endif
29+
#ifdef BSP_USING_PWM6
30+
BSP_PWM6_INDEX,
31+
#endif
32+
#ifdef BSP_USING_PWM7
33+
BSP_PWM7_INDEX,
34+
#endif
35+
#ifdef BSP_USING_PWM8
36+
BSP_PWM8_INDEX,
37+
#endif
38+
#ifdef BSP_USING_PWM9
39+
BSP_PWM9_INDEX,
40+
#endif
41+
BSP_PWMS_NUM
42+
};
43+
44+
#define PWM_DRV_INITIALIZER(num) \
45+
{ \
46+
.name = "pwm"#num , \
47+
.g_cfg = &g_timer##num##_cfg, \
48+
.g_ctrl = &g_timer##num##_ctrl, \
49+
.g_timer = &g_timer##num, \
50+
}
51+
52+
#ifdef __cplusplus
53+
}
54+
#endif
55+
56+
#endif /* __PWM_CONFIG_H__ */

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,11 @@ bool calculate_block_num(int no, size_t addr, size_t size, void *erase_addr, voi
228228
level = rt_hw_interrupt_disable();
229229
R_FLASH_Reset(&g_flash_ctrl);
230230

231+
#if BSP_FEATURE_FLASH_HP_VERSION
231232
fal_block_iter(&_onchip_flash_hp0, &calculate_block_num, (void *)addr, (void *)size, &block_num);
233+
#else
234+
fal_block_iter(&_onchip_flash_lp, &calculate_block_num, (void *)addr, (void *)size, &block_num);
235+
#endif
232236

233237
/* Erase Block */
234238
#if BSP_FEATURE_FLASH_HP_VERSION
@@ -337,6 +341,16 @@ static int fal_flash_lp_erase(long offset, size_t size)
337341
return _flash_lp_erase(_onchip_flash_lp.addr + offset, size);
338342
}
339343

344+
/*
345+
* This callback is intentionally left empty.
346+
* No action is required on flash events in this application.
347+
* If event handling is needed, implement it here.
348+
*/
349+
void flash_callback(flash_callback_args_t * p_args)
350+
{
351+
352+
}
353+
340354
#endif
341355

342356
#endif

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
static rt_base_t ra_pin_get_irqx(rt_uint32_t pin)
2828
{
29-
PIN2IRQX_TABLE(pin)
29+
PIN2IRQX_TABLE(pin);
3030
}
3131

3232
static struct rt_pin_irq_hdr pin_irq_hdr_tab[RA_IRQ_MAX] = {0};

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323
#include <hal_data.h>
2424

2525
#ifndef BIT
26-
#define BIT(idx) (1ul << (idx))
26+
#define BIT(idx) (1ul << (idx))
2727
#endif
2828

2929
#ifndef BITS
30-
#define BITS(b,e) ((((uint32_t)-1)<<(b))&(((uint32_t)-1)>>(31-(e))))
30+
#define BITS(b,e) ((((uint32_t)-1)<<(b))&(((uint32_t)-1)>>(31-(e))))
3131
#endif
3232

3333
#define RA_SCI_EVENT_ABORTED BIT(0)
@@ -36,6 +36,14 @@
3636
#define RA_SCI_EVENT_ERROR BIT(3)
3737
#define RA_SCI_EVENT_ALL BITS(0,3)
3838

39+
#ifdef SOC_SERIES_R7FA2E2
40+
#define R_IIC_MASTER_Open R_IIC_B_MASTER_Open
41+
#define R_IIC_MASTER_Write R_IIC_B_MASTER_Write
42+
#define R_IIC_MASTER_Read R_IIC_B_MASTER_Read
43+
#define R_IIC_MASTER_SlaveAddressSet R_IIC_B_MASTER_SlaveAddressSet
44+
#define R_IIC_MASTER_CallbackSet R_IIC_B_MASTER_CallbackSet
45+
#endif
46+
3947
struct ra_i2c_handle
4048
{
4149
struct rt_i2c_bus_device bus;

bsp/renesas/ra2e2-ek/.config

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ CONFIG_SOC_R7FA2E2A7=y
107107
# end of rt_strnlen options
108108
# end of klibc options
109109

110-
CONFIG_RT_NAME_MAX=8
110+
CONFIG_RT_NAME_MAX=16
111111
# CONFIG_RT_USING_ARCH_DATA_TYPE is not set
112112
# CONFIG_RT_USING_NANO is not set
113113
# CONFIG_RT_USING_SMART is not set
@@ -146,7 +146,7 @@ CONFIG_RT_DEBUGING_CONTEXT=y
146146
#
147147
CONFIG_RT_USING_SEMAPHORE=y
148148
CONFIG_RT_USING_MUTEX=y
149-
# CONFIG_RT_USING_EVENT is not set
149+
CONFIG_RT_USING_EVENT=y
150150
# CONFIG_RT_USING_MAILBOX is not set
151151
# CONFIG_RT_USING_MESSAGEQUEUE is not set
152152
# CONFIG_RT_USING_SIGNALS is not set
@@ -1286,6 +1286,10 @@ CONFIG_BSP_USING_UART9=y
12861286
# CONFIG_BSP_UART9_TX_USING_DMA is not set
12871287
CONFIG_BSP_UART9_RX_BUFSIZE=256
12881288
CONFIG_BSP_UART9_TX_BUFSIZE=0
1289+
# CONFIG_BSP_USING_HW_I2C is not set
1290+
# CONFIG_BSP_USING_SPI is not set
1291+
# CONFIG_BSP_USING_PWM is not set
1292+
# CONFIG_BSP_USING_ADC is not set
12891293
# end of On-chip Peripheral Drivers
12901294

12911295
#

bsp/renesas/ra2e2-ek/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
| GPIO | 支持 | |
3636
| IIC | 支持 | 软件 |
3737
| WDT | 支持 | |
38-
| RTC | 支持 | |
38+
| RTC | 不支持 | |
3939
| ADC | 支持 | |
4040
| SPI | 支持 | |
4141
| FLASH | 支持 | |
@@ -172,4 +172,4 @@ RASC 生成的`bsp_linker_info.h`,要么直接删掉,要么根据使用的
172172
173173
## 贡献代码
174174
175-
如果您对 CPK-RA6M4 感兴趣,并且有一些好玩的项目愿意与大家分享的话欢迎给我们贡献代码,您可以参考 [如何向 RT-Thread 代码贡献](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/development-guide/github/github)。
175+
如果您对 EK-RA2E2 感兴趣,并且有一些好玩的项目愿意与大家分享的话欢迎给我们贡献代码,您可以参考 [如何向 RT-Thread 代码贡献](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/development-guide/github/github)。

bsp/renesas/ra2e2-ek/SConstruct

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,18 @@ Export('SDK_LIB')
4444

4545
rtconfig.BSP_LIBRARY_TYPE = None
4646

47+
def startup_check():
48+
import subprocess
49+
startup_check_path = os.getcwd() + "/../tools/startup_check.py"
50+
51+
if os.path.exists(startup_check_path):
52+
try:
53+
subprocess.call(["python", startup_check_path])
54+
except:
55+
subprocess.call(["python3", startup_check_path])
56+
57+
RegisterPreBuildingAction(startup_check)
58+
4759
# prepare building environment
4860
objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False)
4961

bsp/renesas/ra2e2-ek/board/Kconfig

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,67 @@ menu "Hardware Drivers Config"
4343
endif
4444
endif
4545

46+
menuconfig BSP_USING_HW_I2C
47+
bool "Enable hardware I2C BUS"
48+
default n
49+
select RT_USING_I2C
50+
if BSP_USING_HW_I2C
51+
config BSP_USING_HW_I2C0
52+
bool "Enable Hardware I2C0 BUS"
53+
default n
54+
endif
55+
56+
menuconfig BSP_USING_SPI
57+
bool "Enable hardware SPI BUS"
58+
default n
59+
select RT_USING_SPI
60+
if BSP_USING_SPI
61+
config BSP_USING_SPI0
62+
bool "Enable Hardware SPI0 BUS"
63+
default n
64+
endif
65+
66+
menuconfig BSP_USING_PWM
67+
bool "Enable PWM"
68+
default n
69+
select RT_USING_PWM
70+
if BSP_USING_PWM
71+
config BSP_USING_PWM4
72+
bool "Enable GPT4 (16-Bits) output PWM"
73+
default n
74+
75+
config BSP_USING_PWM5
76+
bool "Enable GPT5 (16-Bits) output PWM"
77+
default n
78+
79+
config BSP_USING_PWM6
80+
bool "Enable GPT6 (16-Bits) output PWM"
81+
default n
82+
83+
config BSP_USING_PWM7
84+
bool "Enable GPT7 (16-Bits) output PWM"
85+
default n
86+
87+
config BSP_USING_PWM8
88+
bool "Enable GPT8 (16-Bits) output PWM"
89+
default n
90+
91+
config BSP_USING_PWM9
92+
bool "Enable GPT9 (16-Bits) output PWM"
93+
default n
94+
95+
endif
96+
97+
menuconfig BSP_USING_ADC
98+
bool "Enable ADC"
99+
default n
100+
select RT_USING_ADC
101+
if BSP_USING_ADC
102+
config BSP_USING_ADC0
103+
bool "Enable ADC0"
104+
default n
105+
endif
106+
46107
endmenu
47108

48109
menu "Board extended module Drivers"

0 commit comments

Comments
 (0)