From 37908818a0a26977310c593989e9e27c93e4b4e7 Mon Sep 17 00:00:00 2001 From: DingDing Date: Wed, 15 Jan 2025 21:38:09 +0800 Subject: [PATCH] fix GPIO and SCI drivers for RZ series (#9908) fix gpio and sci drivers for RZ series --- bsp/renesas/ebf_qi_min_6m5/.config | 2 +- bsp/renesas/libraries/HAL_Drivers/drv_gpio.c | 53 +++++++++----------- bsp/renesas/libraries/HAL_Drivers/drv_sci.c | 4 ++ bsp/renesas/libraries/Kconfig | 22 ++++---- bsp/renesas/libraries/bsp-template/.config | 2 +- bsp/renesas/ra2l1-cpk/.config | 2 +- bsp/renesas/ra4m2-eco/.config | 2 +- bsp/renesas/ra6e2-fpb/.config | 2 +- bsp/renesas/ra6m3-ek/.config | 2 +- bsp/renesas/ra6m3-hmi-board/.config | 2 +- bsp/renesas/ra6m4-cpk/.config | 2 +- bsp/renesas/ra6m4-iot/.config | 2 +- bsp/renesas/ra8d1-ek/.config | 2 +- bsp/renesas/ra8d1-vision-board/.config | 2 +- bsp/renesas/ra8m1-ek/.config | 2 +- bsp/renesas/rzn2l_rsk/.config | 2 +- bsp/renesas/rzt2m_rsk/.config | 2 +- 17 files changed, 55 insertions(+), 52 deletions(-) diff --git a/bsp/renesas/ebf_qi_min_6m5/.config b/bsp/renesas/ebf_qi_min_6m5/.config index f9857851c2f..7a847706e7b 100644 --- a/bsp/renesas/ebf_qi_min_6m5/.config +++ b/bsp/renesas/ebf_qi_min_6m5/.config @@ -1019,7 +1019,7 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0 # Uncategorized # # CONFIG_PKG_USING_MICRO_ROS_RTTHREAD_PACKAGE is not set -CONFIG_SOC_FAMILY_RENESAS=y +CONFIG_SOC_FAMILY_RENESAS_RA=y # CONFIG_SOC_SERIES_R7FA6M3 is not set # CONFIG_SOC_SERIES_R7FA6M4 is not set # CONFIG_SOC_SERIES_R7FA2L1 is not set diff --git a/bsp/renesas/libraries/HAL_Drivers/drv_gpio.c b/bsp/renesas/libraries/HAL_Drivers/drv_gpio.c index 13dc033a4e3..374a0a6d4df 100644 --- a/bsp/renesas/libraries/HAL_Drivers/drv_gpio.c +++ b/bsp/renesas/libraries/HAL_Drivers/drv_gpio.c @@ -7,6 +7,7 @@ * Date Author Notes * 2021-07-29 KyleChan first version * 2022-01-19 Sherman add PIN2IRQX_TABLE + * 2025-01-13 newflydd pin_get for RZ */ #include @@ -304,37 +305,31 @@ static rt_err_t ra_pin_dettach_irq(struct rt_device *device, rt_base_t pin) static rt_base_t ra_pin_get(const char *name) { - int pin_number = -1, port = -1, pin = -1; - - if (rt_strlen(name) != 4) - return -1; - - if ((name[0] == 'P' || name[0] == 'p')) +#ifdef SOC_FAMILY_RENESAS_RZ + /* RZ series: use "PXX_X" format, like "P01_1" */ + if ((rt_strlen(name) == 5) && + ((name[0] == 'P') || (name[0] == 'p')) && + (name[3] == '_') && + ('0' <= (int) name[1] && (int) name[1] <= '1') && + ('0' <= (int) name[2] && (int) name[2] <= '9') && + ('0' <= (int) name[4] && (int) name[4] <= '7')) { - if ('0' <= name[1] && name[1] <= '9') - { - port = (name[1] - '0') * 16 * 16; - if ('0' <= name[2] && name[2] <= '9' && '0' <= name[3] && name[3] <= '9') - { - pin = (name[2] - '0') * 10 + (name[3] - '0'); - pin_number = port + pin; - - return pin_number; - } - } - else if ('A' <= name[1] && name[1] <= 'Z') - { - port = (name[1] - '0' - 7) * 16 * 16; - if ('0' <= name[2] && name[2] <= '9' && '0' <= name[3] && name[3] <= '9') - { - pin = (name[2] - '0') * 10 + (name[3] - '0'); - pin_number = port + pin; - - return pin_number; - } - } + return (((int) name[1] - '0') * 10 + ((int) name[2] - '0')) * 0x100 + ((int) name[4] - '0'); + } + LOG_W("Invalid pin expression, use `PXX_X` format like `P01_1`"); +#else + /* RA series: use "PXXX" format, like "P101"*/ + if ((rt_strlen(name) == 4) && + (name[0] == 'P' || name[0] == 'p') && + (name[1] >= '0' && name[1] <= '9') && + (name[2] >= '0' && name[1] <= '9') && + (name[3] >= '0' && name[1] <= '9')) + { + return (name[1] - '0') * 0x100 + (name[2] - '0') * 10 + (name[3] - '0'); } - return -1; + LOG_W("Invalid pin expression, use `PXXX` format like `P101`"); +#endif + return -RT_ERROR; } const static struct rt_pin_ops _ra_pin_ops = diff --git a/bsp/renesas/libraries/HAL_Drivers/drv_sci.c b/bsp/renesas/libraries/HAL_Drivers/drv_sci.c index 93d31dd2e3f..1fec7550d49 100644 --- a/bsp/renesas/libraries/HAL_Drivers/drv_sci.c +++ b/bsp/renesas/libraries/HAL_Drivers/drv_sci.c @@ -358,7 +358,11 @@ static int ra_uart_putc(struct rt_serial_device *serial, char c) sci_uart_instance_ctrl_t *p_ctrl = (sci_uart_instance_ctrl_t *)param->sci_ctrl; p_ctrl->p_reg->TDR = c; +#ifdef SOC_SERIES_R9A07G0 + while ((p_ctrl->p_reg->CSR_b.TEND) == 0); +#else while ((p_ctrl->p_reg->SSR_b.TEND) == 0); +#endif return RT_EOK; } diff --git a/bsp/renesas/libraries/Kconfig b/bsp/renesas/libraries/Kconfig index 8aad8b4fc58..3fc28972aa8 100644 --- a/bsp/renesas/libraries/Kconfig +++ b/bsp/renesas/libraries/Kconfig @@ -1,52 +1,56 @@ -config SOC_FAMILY_RENESAS +config SOC_FAMILY_RENESAS_RA + bool + default n + +config SOC_FAMILY_RENESAS_RZ bool default n config SOC_SERIES_R7FA6M3 bool select ARCH_ARM_CORTEX_M4 - select SOC_FAMILY_RENESAS + select SOC_FAMILY_RENESAS_RA default n config SOC_SERIES_R7FA6M4 bool select ARCH_ARM_CORTEX_M4 - select SOC_FAMILY_RENESAS + select SOC_FAMILY_RENESAS_RA default n config SOC_SERIES_R7FA2L1 bool select ARCH_ARM_CORTEX_M23 - select SOC_FAMILY_RENESAS + select SOC_FAMILY_RENESAS_RA default n config SOC_SERIES_R7FA6M5 bool select ARCH_ARM_CORTEX_M33 - select SOC_FAMILY_RENESAS + select SOC_FAMILY_RENESAS_RA default n config SOC_SERIES_R7FA4M2 bool select ARCH_ARM_CORTEX_M4 - select SOC_FAMILY_RENESAS + select SOC_FAMILY_RENESAS_RA default n config SOC_SERIES_R7FA8M85 bool select ARCH_ARM_CORTEX_M85 - select SOC_FAMILY_RENESAS + select SOC_FAMILY_RENESAS_RA default n config SOC_SERIES_R9A07G0 bool select ARCH_ARM_CORTEX_R52 - select SOC_FAMILY_RENESAS + select SOC_FAMILY_RENESAS_RZ default n config SOC_SERIES_R7FA6E2 bool select ARCH_ARM_CORTEX_M33 - select SOC_FAMILY_RENESAS + select SOC_FAMILY_RENESAS_RA default n \ No newline at end of file diff --git a/bsp/renesas/libraries/bsp-template/.config b/bsp/renesas/libraries/bsp-template/.config index 5907b309925..cbf525b8b7a 100644 --- a/bsp/renesas/libraries/bsp-template/.config +++ b/bsp/renesas/libraries/bsp-template/.config @@ -657,7 +657,7 @@ CONFIG_SOC_R7FA6M4AF=y # # On-chip Peripheral Drivers # -CONFIG_SOC_FAMILY_RENESAS=y +CONFIG_SOC_FAMILY_RENESAS_RA=y CONFIG_SOC_SERIES_R7FA6M4=y CONFIG_BSP_USING_GPIO=y # CONFIG_BSP_USING_ONCHIP_FLASH is not set diff --git a/bsp/renesas/ra2l1-cpk/.config b/bsp/renesas/ra2l1-cpk/.config index 980c8b29829..ebe2524e3b6 100644 --- a/bsp/renesas/ra2l1-cpk/.config +++ b/bsp/renesas/ra2l1-cpk/.config @@ -1035,7 +1035,7 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0 # Uncategorized # # CONFIG_PKG_USING_MICRO_ROS_RTTHREAD_PACKAGE is not set -CONFIG_SOC_FAMILY_RENESAS=y +CONFIG_SOC_FAMILY_RENESAS_RA=y # CONFIG_SOC_SERIES_R7FA6M3 is not set # CONFIG_SOC_SERIES_R7FA6M4 is not set CONFIG_SOC_SERIES_R7FA2L1=y diff --git a/bsp/renesas/ra4m2-eco/.config b/bsp/renesas/ra4m2-eco/.config index f14dd22fde9..5daf1c7f7af 100644 --- a/bsp/renesas/ra4m2-eco/.config +++ b/bsp/renesas/ra4m2-eco/.config @@ -1036,7 +1036,7 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0 # Uncategorized # # CONFIG_PKG_USING_MICRO_ROS_RTTHREAD_PACKAGE is not set -CONFIG_SOC_FAMILY_RENESAS=y +CONFIG_SOC_FAMILY_RENESAS_RA=y # CONFIG_SOC_SERIES_R7FA6M3 is not set # CONFIG_SOC_SERIES_R7FA6M4 is not set # CONFIG_SOC_SERIES_R7FA2L1 is not set diff --git a/bsp/renesas/ra6e2-fpb/.config b/bsp/renesas/ra6e2-fpb/.config index 4c0b5775ba9..fe980b065c6 100644 --- a/bsp/renesas/ra6e2-fpb/.config +++ b/bsp/renesas/ra6e2-fpb/.config @@ -1153,7 +1153,7 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0 # end of Arduino libraries # end of RT-Thread online packages -CONFIG_SOC_FAMILY_RENESAS=y +CONFIG_SOC_FAMILY_RENESAS_RA=y CONFIG_SOC_SERIES_R7FA6E2=y # diff --git a/bsp/renesas/ra6m3-ek/.config b/bsp/renesas/ra6m3-ek/.config index f229aa8fc50..2f7745c475e 100644 --- a/bsp/renesas/ra6m3-ek/.config +++ b/bsp/renesas/ra6m3-ek/.config @@ -1021,7 +1021,7 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0 # Uncategorized # # CONFIG_PKG_USING_MICRO_ROS_RTTHREAD_PACKAGE is not set -CONFIG_SOC_FAMILY_RENESAS=y +CONFIG_SOC_FAMILY_RENESAS_RA=y CONFIG_SOC_SERIES_R7FA6M3=y # CONFIG_SOC_SERIES_R7FA6M4 is not set # CONFIG_SOC_SERIES_R7FA2L1 is not set diff --git a/bsp/renesas/ra6m3-hmi-board/.config b/bsp/renesas/ra6m3-hmi-board/.config index 8e4fd18258a..99f43743314 100644 --- a/bsp/renesas/ra6m3-hmi-board/.config +++ b/bsp/renesas/ra6m3-hmi-board/.config @@ -1271,7 +1271,7 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0 # end of Arduino libraries # end of RT-Thread online packages -CONFIG_SOC_FAMILY_RENESAS=y +CONFIG_SOC_FAMILY_RENESAS_RA=y CONFIG_SOC_SERIES_R7FA6M3=y # diff --git a/bsp/renesas/ra6m4-cpk/.config b/bsp/renesas/ra6m4-cpk/.config index a0348aae9b6..e7ec3caa4b9 100644 --- a/bsp/renesas/ra6m4-cpk/.config +++ b/bsp/renesas/ra6m4-cpk/.config @@ -1027,7 +1027,7 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0 # Uncategorized # # CONFIG_PKG_USING_MICRO_ROS_RTTHREAD_PACKAGE is not set -CONFIG_SOC_FAMILY_RENESAS=y +CONFIG_SOC_FAMILY_RENESAS_RA=y # CONFIG_SOC_SERIES_R7FA6M3 is not set CONFIG_SOC_SERIES_R7FA6M4=y # CONFIG_SOC_SERIES_R7FA2L1 is not set diff --git a/bsp/renesas/ra6m4-iot/.config b/bsp/renesas/ra6m4-iot/.config index 5b5b9006da2..8ffe139504b 100644 --- a/bsp/renesas/ra6m4-iot/.config +++ b/bsp/renesas/ra6m4-iot/.config @@ -1021,7 +1021,7 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0 # Uncategorized # # CONFIG_PKG_USING_MICRO_ROS_RTTHREAD_PACKAGE is not set -CONFIG_SOC_FAMILY_RENESAS=y +CONFIG_SOC_FAMILY_RENESAS_RA=y # CONFIG_SOC_SERIES_R7FA6M3 is not set CONFIG_SOC_SERIES_R7FA6M4=y # CONFIG_SOC_SERIES_R7FA2L1 is not set diff --git a/bsp/renesas/ra8d1-ek/.config b/bsp/renesas/ra8d1-ek/.config index 260dee73f5e..9f7c7736081 100644 --- a/bsp/renesas/ra8d1-ek/.config +++ b/bsp/renesas/ra8d1-ek/.config @@ -1022,7 +1022,7 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0 # Uncategorized # # CONFIG_PKG_USING_MICRO_ROS_RTTHREAD_PACKAGE is not set -CONFIG_SOC_FAMILY_RENESAS=y +CONFIG_SOC_FAMILY_RENESAS_RA=y # CONFIG_SOC_SERIES_R7FA6M3 is not set # CONFIG_SOC_SERIES_R7FA6M4 is not set # CONFIG_SOC_SERIES_R7FA2L1 is not set diff --git a/bsp/renesas/ra8d1-vision-board/.config b/bsp/renesas/ra8d1-vision-board/.config index 6be24dfabcb..7407aa269c1 100644 --- a/bsp/renesas/ra8d1-vision-board/.config +++ b/bsp/renesas/ra8d1-vision-board/.config @@ -1057,7 +1057,7 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0 # Uncategorized # # CONFIG_PKG_USING_MICRO_ROS_RTTHREAD_PACKAGE is not set -CONFIG_SOC_FAMILY_RENESAS=y +CONFIG_SOC_FAMILY_RENESAS_RA=y # CONFIG_SOC_SERIES_R7FA6M3 is not set # CONFIG_SOC_SERIES_R7FA6M4 is not set # CONFIG_SOC_SERIES_R7FA2L1 is not set diff --git a/bsp/renesas/ra8m1-ek/.config b/bsp/renesas/ra8m1-ek/.config index 5937a4dbb9c..3d19aca83fa 100644 --- a/bsp/renesas/ra8m1-ek/.config +++ b/bsp/renesas/ra8m1-ek/.config @@ -1054,7 +1054,7 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0 # Uncategorized # # CONFIG_PKG_USING_MICRO_ROS_RTTHREAD_PACKAGE is not set -CONFIG_SOC_FAMILY_RENESAS=y +CONFIG_SOC_FAMILY_RENESAS_RA=y # CONFIG_SOC_SERIES_R7FA6M3 is not set # CONFIG_SOC_SERIES_R7FA6M4 is not set # CONFIG_SOC_SERIES_R7FA2L1 is not set diff --git a/bsp/renesas/rzn2l_rsk/.config b/bsp/renesas/rzn2l_rsk/.config index 6f402d9bc83..fe7576d35f2 100644 --- a/bsp/renesas/rzn2l_rsk/.config +++ b/bsp/renesas/rzn2l_rsk/.config @@ -1151,7 +1151,7 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0 # end of Arduino libraries # end of RT-Thread online packages -CONFIG_SOC_FAMILY_RENESAS=y +CONFIG_SOC_FAMILY_RENESAS_RZ=y CONFIG_SOC_SERIES_R9A07G0=y # diff --git a/bsp/renesas/rzt2m_rsk/.config b/bsp/renesas/rzt2m_rsk/.config index fed1a4dea6e..7beaa50421b 100644 --- a/bsp/renesas/rzt2m_rsk/.config +++ b/bsp/renesas/rzt2m_rsk/.config @@ -1054,7 +1054,7 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0 # Uncategorized # # CONFIG_PKG_USING_MICRO_ROS_RTTHREAD_PACKAGE is not set -CONFIG_SOC_FAMILY_RENESAS=y +CONFIG_SOC_FAMILY_RENESAS_RZ=y # CONFIG_SOC_SERIES_R7FA6M3 is not set # CONFIG_SOC_SERIES_R7FA6M4 is not set # CONFIG_SOC_SERIES_R7FA2L1 is not set