From 5c8099003c5db6c398efa611f041f8280e7a32e3 Mon Sep 17 00:00:00 2001 From: iabdalkader Date: Wed, 20 Sep 2023 14:59:28 +0200 Subject: [PATCH] renesas-ra/boards/ARDUINO_PORTENTA_C33: Update WiFi config. Changes are: - Enable IRQ on WiFi data ready pin. - Fix WiFi SPI clock (an exact 30MHz is not possible). - Update WiFi pins. Signed-off-by: iabdalkader --- .../ARDUINO_PORTENTA_C33/mpconfigboard.h | 3 ++- .../ARDUINO_PORTENTA_C33/ra_gen/common_data.c | 24 +++++++++++++++++++ .../ARDUINO_PORTENTA_C33/ra_gen/common_data.h | 12 +++++++++- .../ARDUINO_PORTENTA_C33/ra_gen/pin_data.c | 2 ++ .../ARDUINO_PORTENTA_C33/ra_gen/vector_data.c | 2 ++ .../ARDUINO_PORTENTA_C33/ra_gen/vector_data.h | 4 +++- 6 files changed, 44 insertions(+), 3 deletions(-) diff --git a/ports/renesas-ra/boards/ARDUINO_PORTENTA_C33/mpconfigboard.h b/ports/renesas-ra/boards/ARDUINO_PORTENTA_C33/mpconfigboard.h index ed19f60e9e..aa1e28ab9d 100644 --- a/ports/renesas-ra/boards/ARDUINO_PORTENTA_C33/mpconfigboard.h +++ b/ports/renesas-ra/boards/ARDUINO_PORTENTA_C33/mpconfigboard.h @@ -98,9 +98,10 @@ void PORTENTA_C33_board_enter_bootloader(void); // WiFi config. #define MICROPY_HW_WIFI_SPI_ID (1) #define MICROPY_HW_WIFI_SPI_CS (pin_P104) -#define MICROPY_HW_WIFI_SPI_BAUDRATE (30 * 1000 * 1000) +#define MICROPY_HW_WIFI_SPI_BAUDRATE (25 * 1000 * 1000) #define MICROPY_HW_WIFI_DATAREADY (pin_P803) #define MICROPY_HW_WIFI_HANDSHAKE (pin_P806) +#define MICROPY_HW_WIFI_IRQ_PIN (MICROPY_HW_WIFI_DATAREADY) // ESP hosted control pins #define MICROPY_HW_ESP_HOSTED_RESET (pin_P804) diff --git a/ports/renesas-ra/boards/ARDUINO_PORTENTA_C33/ra_gen/common_data.c b/ports/renesas-ra/boards/ARDUINO_PORTENTA_C33/ra_gen/common_data.c index 50a3f6046b..edc031ea90 100644 --- a/ports/renesas-ra/boards/ARDUINO_PORTENTA_C33/ra_gen/common_data.c +++ b/ports/renesas-ra/boards/ARDUINO_PORTENTA_C33/ra_gen/common_data.c @@ -1,5 +1,29 @@ /* generated common source file - do not edit */ #include "common_data.h" +icu_instance_ctrl_t g_external_irq1_ctrl; +const external_irq_cfg_t g_external_irq1_cfg = +{ .channel = 2, + .trigger = EXTERNAL_IRQ_TRIG_RISING, + .filter_enable = false, + .pclk_div = EXTERNAL_IRQ_PCLK_DIV_BY_64, + .p_callback = NULL, + /** If NULL then do not add & */ + #if defined(NULL) + .p_context = NULL, + #else + .p_context = &NULL, + #endif + .p_extend = NULL, + .ipl = (12), + #if defined(VECTOR_NUMBER_ICU_IRQ2) + .irq = VECTOR_NUMBER_ICU_IRQ2, + #else + .irq = FSP_INVALID_VECTOR, + #endif +}; +/* Instance structure to use this module. */ +const external_irq_instance_t g_external_irq1 = +{ .p_ctrl = &g_external_irq1_ctrl, .p_cfg = &g_external_irq1_cfg, .p_api = &g_external_irq_on_icu }; sce_instance_ctrl_t sce_ctrl; const sce_cfg_t sce_cfg = { .lifecycle = SCE_SSD }; diff --git a/ports/renesas-ra/boards/ARDUINO_PORTENTA_C33/ra_gen/common_data.h b/ports/renesas-ra/boards/ARDUINO_PORTENTA_C33/ra_gen/common_data.h index 0f5a143ff6..3573218160 100644 --- a/ports/renesas-ra/boards/ARDUINO_PORTENTA_C33/ra_gen/common_data.h +++ b/ports/renesas-ra/boards/ARDUINO_PORTENTA_C33/ra_gen/common_data.h @@ -3,12 +3,22 @@ #define COMMON_DATA_H_ #include #include "bsp_api.h" -#include "r_sce.h" #include "r_icu.h" #include "r_external_irq_api.h" +#include "r_sce.h" #include "r_ioport.h" #include "bsp_pin_cfg.h" FSP_HEADER +/** External IRQ on ICU Instance. */ +extern const external_irq_instance_t g_external_irq1; + +/** Access the ICU instance using these structures when calling API functions directly (::p_api is not used). */ +extern icu_instance_ctrl_t g_external_irq1_ctrl; +extern const external_irq_cfg_t g_external_irq1_cfg; + +#ifndef NULL +void NULL(external_irq_callback_args_t *p_args); +#endif extern sce_instance_ctrl_t sce_ctrl; extern const sce_cfg_t sce_cfg; /** External IRQ on ICU Instance. */ diff --git a/ports/renesas-ra/boards/ARDUINO_PORTENTA_C33/ra_gen/pin_data.c b/ports/renesas-ra/boards/ARDUINO_PORTENTA_C33/ra_gen/pin_data.c index 895f662f27..ac0f7b5ddf 100644 --- a/ports/renesas-ra/boards/ARDUINO_PORTENTA_C33/ra_gen/pin_data.c +++ b/ports/renesas-ra/boards/ARDUINO_PORTENTA_C33/ra_gen/pin_data.c @@ -34,6 +34,8 @@ const ioport_pin_cfg_t g_bsp_pin_cfg_data[] = | (uint32_t)IOPORT_PERIPHERAL_SCI1_3_5_7_9) }, { .pin = BSP_IO_PORT_06_PIN_07, .pin_cfg = ((uint32_t)IOPORT_CFG_PERIPHERAL_PIN | (uint32_t)IOPORT_PERIPHERAL_SCI0_2_4_6_8) }, + { .pin = BSP_IO_PORT_08_PIN_03, .pin_cfg = ((uint32_t)IOPORT_CFG_IRQ_ENABLE + | (uint32_t)IOPORT_CFG_PORT_DIRECTION_INPUT) }, { .pin = BSP_IO_PORT_10_PIN_00, .pin_cfg = ((uint32_t)IOPORT_CFG_PERIPHERAL_PIN | (uint32_t)IOPORT_PERIPHERAL_SCI0_2_4_6_8) }, }; diff --git a/ports/renesas-ra/boards/ARDUINO_PORTENTA_C33/ra_gen/vector_data.c b/ports/renesas-ra/boards/ARDUINO_PORTENTA_C33/ra_gen/vector_data.c index ea8b0511ba..cb4da4cf34 100644 --- a/ports/renesas-ra/boards/ARDUINO_PORTENTA_C33/ra_gen/vector_data.c +++ b/ports/renesas-ra/boards/ARDUINO_PORTENTA_C33/ra_gen/vector_data.c @@ -33,6 +33,7 @@ BSP_DONT_REMOVE const fsp_vector_t g_vector_table[BSP_ICU_VECTOR_MAX_ENTRIES] BS [26] = spi_txi_isr, /* SPI1 TXI (Transmit buffer empty) */ [27] = spi_tei_isr, /* SPI1 TEI (Transmission complete event) */ [28] = spi_eri_isr, /* SPI1 ERI (Error) */ + [29] = r_icu_isr, /* ICU IRQ2 (External pin interrupt 2) */ }; const bsp_interrupt_event_t g_interrupt_event_link_select[BSP_ICU_VECTOR_MAX_ENTRIES] = { @@ -65,5 +66,6 @@ const bsp_interrupt_event_t g_interrupt_event_link_select[BSP_ICU_VECTOR_MAX_ENT [26] = BSP_PRV_IELS_ENUM(EVENT_SPI1_TXI), /* SPI1 TXI (Transmit buffer empty) */ [27] = BSP_PRV_IELS_ENUM(EVENT_SPI1_TEI), /* SPI1 TEI (Transmission complete event) */ [28] = BSP_PRV_IELS_ENUM(EVENT_SPI1_ERI), /* SPI1 ERI (Error) */ + [29] = BSP_PRV_IELS_ENUM(EVENT_ICU_IRQ2), /* ICU IRQ2 (External pin interrupt 2) */ }; #endif diff --git a/ports/renesas-ra/boards/ARDUINO_PORTENTA_C33/ra_gen/vector_data.h b/ports/renesas-ra/boards/ARDUINO_PORTENTA_C33/ra_gen/vector_data.h index 2342dbbab1..c5ccb9e3cf 100644 --- a/ports/renesas-ra/boards/ARDUINO_PORTENTA_C33/ra_gen/vector_data.h +++ b/ports/renesas-ra/boards/ARDUINO_PORTENTA_C33/ra_gen/vector_data.h @@ -6,7 +6,7 @@ extern "C" { #endif /* Number of interrupts allocated */ #ifndef VECTOR_DATA_IRQ_COUNT -#define VECTOR_DATA_IRQ_COUNT (29) +#define VECTOR_DATA_IRQ_COUNT (30) #endif /* ISR prototypes */ void sci_uart_rxi_isr(void); @@ -92,6 +92,8 @@ void spi_eri_isr(void); #define SPI1_TEI_IRQn ((IRQn_Type)27) /* SPI1 TEI (Transmission complete event) */ #define VECTOR_NUMBER_SPI1_ERI ((IRQn_Type)28) /* SPI1 ERI (Error) */ #define SPI1_ERI_IRQn ((IRQn_Type)28) /* SPI1 ERI (Error) */ +#define VECTOR_NUMBER_ICU_IRQ2 ((IRQn_Type)29) /* ICU IRQ2 (External pin interrupt 2) */ +#define ICU_IRQ2_IRQn ((IRQn_Type)29) /* ICU IRQ2 (External pin interrupt 2) */ #ifdef __cplusplus } #endif