Skip to content

Commit

Permalink
fix GPIO and SCI drivers for RZ series (#9908)
Browse files Browse the repository at this point in the history
fix gpio and sci drivers for RZ series
  • Loading branch information
newflydd authored Jan 15, 2025
1 parent da6c62c commit 3790881
Show file tree
Hide file tree
Showing 17 changed files with 55 additions and 52 deletions.
2 changes: 1 addition & 1 deletion bsp/renesas/ebf_qi_min_6m5/.config
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
53 changes: 24 additions & 29 deletions bsp/renesas/libraries/HAL_Drivers/drv_gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 <drv_gpio.h>
Expand Down Expand Up @@ -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 =
Expand Down
4 changes: 4 additions & 0 deletions bsp/renesas/libraries/HAL_Drivers/drv_sci.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
22 changes: 13 additions & 9 deletions bsp/renesas/libraries/Kconfig
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion bsp/renesas/libraries/bsp-template/.config
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion bsp/renesas/ra2l1-cpk/.config
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion bsp/renesas/ra4m2-eco/.config
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion bsp/renesas/ra6e2-fpb/.config
Original file line number Diff line number Diff line change
Expand Up @@ -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

#
Expand Down
2 changes: 1 addition & 1 deletion bsp/renesas/ra6m3-ek/.config
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion bsp/renesas/ra6m3-hmi-board/.config
Original file line number Diff line number Diff line change
Expand Up @@ -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

#
Expand Down
2 changes: 1 addition & 1 deletion bsp/renesas/ra6m4-cpk/.config
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion bsp/renesas/ra6m4-iot/.config
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion bsp/renesas/ra8d1-ek/.config
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion bsp/renesas/ra8d1-vision-board/.config
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion bsp/renesas/ra8m1-ek/.config
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion bsp/renesas/rzn2l_rsk/.config
Original file line number Diff line number Diff line change
Expand Up @@ -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

#
Expand Down
2 changes: 1 addition & 1 deletion bsp/renesas/rzt2m_rsk/.config
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3790881

Please sign in to comment.