From 6231ccc26ffa2bc6d1345b8b7e8f82a63da497e7 Mon Sep 17 00:00:00 2001 From: Sergei Lissianoi <54454955+selissia@users.noreply.github.com> Date: Wed, 22 Jun 2022 17:27:42 -0400 Subject: [PATCH] [EFR32] Fix OpenThread and Matter shell operation on EFRMG24 boards (#19858) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Test added march 8 (#15957) * Added new manual scripts * Added Auto generated File * [OTA] Fix OTARequestorDriverImpl inclusion (#15981) * Regen to fix CI failures (#15990) * [ota] Store Default OTA Providers in flash (#15970) * [ota] Store Default OTA Providers in flash Store Default OTA Providers in flash each time the attribute is modified and load it back on the application startup. * Restyled by clang-format * Fix build and reduce flash usage Co-authored-by: Restyled.io * Test VCOM EUSART fix * EUSART init test code * Fix the IRQ handler * Remove merge artifacts * Clean up debug code * Clean up debug code * Restyled by clang-format Co-authored-by: kowsisoundhar12 <57476670+kowsisoundhar12@users.noreply.github.com> Co-authored-by: Carol Yang Co-authored-by: Boris Zbarsky Co-authored-by: Damian Królik <66667989+Damian-Nordic@users.noreply.github.com> Co-authored-by: Restyled.io --- examples/platform/efr32/uart.cpp | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/examples/platform/efr32/uart.cpp b/examples/platform/efr32/uart.cpp index 91c8955525bff7..548416d177ce16 100644 --- a/examples/platform/efr32/uart.cpp +++ b/examples/platform/efr32/uart.cpp @@ -44,10 +44,20 @@ extern "C" { #define MIN(A, B) ((A) < (B) ? (A) : (B)) #endif +#ifdef EFR32MG24 +#define HELPER1(x) EUSART##x##_RX_IRQn +#else #define HELPER1(x) USART##x##_RX_IRQn +#endif + #define HELPER2(x) HELPER1(x) +#ifdef EFR32MG24 +#define HELPER3(x) EUSART##x##_RX_IRQHandler +#else #define HELPER3(x) USART##x##_RX_IRQHandler +#endif + #define HELPER4(x) HELPER3(x) // On MG24 boards VCOM runs on the EUSART device, MG12 uses the UART device @@ -55,7 +65,6 @@ extern "C" { #define USART_IRQ HELPER2(SL_UARTDRV_EUSART_VCOM_PERIPHERAL_NO) #define USART_IRQHandler HELPER4(SL_UARTDRV_EUSART_VCOM_PERIPHERAL_NO) #define vcom_handle sl_uartdrv_eusart_vcom_handle - #else #define USART_IRQ HELPER2(SL_UARTDRV_USART_VCOM_PERIPHERAL_NO) #define USART_IRQHandler HELPER4(SL_UARTDRV_USART_VCOM_PERIPHERAL_NO) @@ -208,12 +217,19 @@ void uartConsoleInit(void) UARTDRV_Receive(vcom_handle, sRxDmaBuffer, MAX_DMA_BUFFER_SIZE, UART_rx_callback); UARTDRV_Receive(vcom_handle, sRxDmaBuffer2, MAX_DMA_BUFFER_SIZE, UART_rx_callback); - // Enable USART0 interrupt to wake OT task when data arrives + // Enable USART0/EUSART0 interrupt to wake OT task when data arrives NVIC_ClearPendingIRQ(USART_IRQ); NVIC_EnableIRQ(USART_IRQ); #ifdef EFR32MG24 - EUSART_IntEnable(SL_UARTDRV_EUSART_VCOM_PERIPHERAL, USART_IF_RXDATAV); + // Clear previous RX interrupts + EUSART_IntClear(SL_UARTDRV_EUSART_VCOM_PERIPHERAL, EUSART_IF_RXFL); + + // Enable RX interrupts + EUSART_IntEnable(SL_UARTDRV_EUSART_VCOM_PERIPHERAL, EUSART_IF_RXFL); + + // Enable EUSART + EUSART_Enable(SL_UARTDRV_EUSART_VCOM_PERIPHERAL, eusartEnable); #else USART_IntEnable(SL_UARTDRV_USART_VCOM_PERIPHERAL, USART_IF_RXDATAV); #endif // EFR32MG24 @@ -229,6 +245,10 @@ void USART_IRQHandler(void) #elif !defined(PW_RPC_ENABLED) otSysEventSignalPending(); #endif + +#ifdef EFR32MG24 + EUSART_IntClear(SL_UARTDRV_EUSART_VCOM_PERIPHERAL, EUSART_IF_RXFL); +#endif } /*