From 8ff6dbce214de8fef257cbb0785237fca4531ada Mon Sep 17 00:00:00 2001 From: DingDing Date: Thu, 9 Jan 2025 14:41:05 +0800 Subject: [PATCH 1/4] Update drv_gpio.c fix `rt_pin_get` function for RENESAS chips, use "PXX_X" or "pXX_X" string format to define a PIN --- bsp/renesas/libraries/HAL_Drivers/drv_gpio.c | 39 +++++--------------- 1 file changed, 10 insertions(+), 29 deletions(-) diff --git a/bsp/renesas/libraries/HAL_Drivers/drv_gpio.c b/bsp/renesas/libraries/HAL_Drivers/drv_gpio.c index 13dc033a4e3..4f674592a59 100644 --- a/bsp/renesas/libraries/HAL_Drivers/drv_gpio.c +++ b/bsp/renesas/libraries/HAL_Drivers/drv_gpio.c @@ -302,38 +302,19 @@ static rt_err_t ra_pin_dettach_irq(struct rt_device *device, rt_base_t pin) #endif } -static rt_base_t ra_pin_get(const char *name) +// USE "PXX_X" or "pXX_X" format, the character 'P'/'p' and '_' are required. +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')) + 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"); return -1; } From 6aa5b72efa5bf39b33fc18f4a72f67e405146a6d Mon Sep 17 00:00:00 2001 From: DingDing Date: Thu, 9 Jan 2025 14:43:43 +0800 Subject: [PATCH 2/4] Update drv_sci.c fix a register problem for R9A07 series chips --- bsp/renesas/libraries/HAL_Drivers/drv_sci.c | 4 ++++ 1 file changed, 4 insertions(+) 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; } From f5b7844dfc21128f44ee708dc7c755625d698cdc Mon Sep 17 00:00:00 2001 From: DingDing Date: Thu, 9 Jan 2025 15:31:44 +0800 Subject: [PATCH 3/4] Update drv_gpio.c --- bsp/renesas/libraries/HAL_Drivers/drv_gpio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bsp/renesas/libraries/HAL_Drivers/drv_gpio.c b/bsp/renesas/libraries/HAL_Drivers/drv_gpio.c index 4f674592a59..6d340cf8142 100644 --- a/bsp/renesas/libraries/HAL_Drivers/drv_gpio.c +++ b/bsp/renesas/libraries/HAL_Drivers/drv_gpio.c @@ -303,14 +303,14 @@ static rt_err_t ra_pin_dettach_irq(struct rt_device *device, rt_base_t pin) } // USE "PXX_X" or "pXX_X" format, the character 'P'/'p' and '_' are required. -static rt_base_t ra_pin_get(const char *name) +static rt_base_t ra_pin_get(const char *name) { 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')) + ('0' <= (int) name[4] && (int) name[4] <= '7')) { return (((int) name[1] - '0') * 10 + ((int) name[2] - '0')) * 0x100 + ((int) name[4] - '0'); } From 93c1689299e784c633f55f43521e0b06623ccbe8 Mon Sep 17 00:00:00 2001 From: DingDing Date: Fri, 10 Jan 2025 09:04:24 +0800 Subject: [PATCH 4/4] Update drv_gpio.c --- bsp/renesas/libraries/HAL_Drivers/drv_gpio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bsp/renesas/libraries/HAL_Drivers/drv_gpio.c b/bsp/renesas/libraries/HAL_Drivers/drv_gpio.c index 6d340cf8142..c85ec940b7c 100644 --- a/bsp/renesas/libraries/HAL_Drivers/drv_gpio.c +++ b/bsp/renesas/libraries/HAL_Drivers/drv_gpio.c @@ -302,7 +302,7 @@ static rt_err_t ra_pin_dettach_irq(struct rt_device *device, rt_base_t pin) #endif } -// USE "PXX_X" or "pXX_X" format, the character 'P'/'p' and '_' are required. +/* USE "PXX_X" or "pXX_X" format, the character 'P'/'p' and '_' are required, like "P18_1" */ static rt_base_t ra_pin_get(const char *name) { if ((rt_strlen(name) == 5) &&