Skip to content

Commit 6231ccc

Browse files
selissiakowsisoundhar12carol-applebzbarsky-appleDamian-Nordic
authored
[EFR32] Fix OpenThread and Matter shell operation on EFRMG24 boards (#19858)
* 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 <commits@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 <clyang@apple.com> Co-authored-by: Boris Zbarsky <bzbarsky@apple.com> Co-authored-by: Damian Królik <66667989+Damian-Nordic@users.noreply.github.com> Co-authored-by: Restyled.io <commits@restyled.io>
1 parent 92eeafc commit 6231ccc

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

examples/platform/efr32/uart.cpp

+23-3
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,27 @@ extern "C" {
4444
#define MIN(A, B) ((A) < (B) ? (A) : (B))
4545
#endif
4646

47+
#ifdef EFR32MG24
48+
#define HELPER1(x) EUSART##x##_RX_IRQn
49+
#else
4750
#define HELPER1(x) USART##x##_RX_IRQn
51+
#endif
52+
4853
#define HELPER2(x) HELPER1(x)
4954

55+
#ifdef EFR32MG24
56+
#define HELPER3(x) EUSART##x##_RX_IRQHandler
57+
#else
5058
#define HELPER3(x) USART##x##_RX_IRQHandler
59+
#endif
60+
5161
#define HELPER4(x) HELPER3(x)
5262

5363
// On MG24 boards VCOM runs on the EUSART device, MG12 uses the UART device
5464
#ifdef EFR32MG24
5565
#define USART_IRQ HELPER2(SL_UARTDRV_EUSART_VCOM_PERIPHERAL_NO)
5666
#define USART_IRQHandler HELPER4(SL_UARTDRV_EUSART_VCOM_PERIPHERAL_NO)
5767
#define vcom_handle sl_uartdrv_eusart_vcom_handle
58-
5968
#else
6069
#define USART_IRQ HELPER2(SL_UARTDRV_USART_VCOM_PERIPHERAL_NO)
6170
#define USART_IRQHandler HELPER4(SL_UARTDRV_USART_VCOM_PERIPHERAL_NO)
@@ -208,12 +217,19 @@ void uartConsoleInit(void)
208217
UARTDRV_Receive(vcom_handle, sRxDmaBuffer, MAX_DMA_BUFFER_SIZE, UART_rx_callback);
209218
UARTDRV_Receive(vcom_handle, sRxDmaBuffer2, MAX_DMA_BUFFER_SIZE, UART_rx_callback);
210219

211-
// Enable USART0 interrupt to wake OT task when data arrives
220+
// Enable USART0/EUSART0 interrupt to wake OT task when data arrives
212221
NVIC_ClearPendingIRQ(USART_IRQ);
213222
NVIC_EnableIRQ(USART_IRQ);
214223

215224
#ifdef EFR32MG24
216-
EUSART_IntEnable(SL_UARTDRV_EUSART_VCOM_PERIPHERAL, USART_IF_RXDATAV);
225+
// Clear previous RX interrupts
226+
EUSART_IntClear(SL_UARTDRV_EUSART_VCOM_PERIPHERAL, EUSART_IF_RXFL);
227+
228+
// Enable RX interrupts
229+
EUSART_IntEnable(SL_UARTDRV_EUSART_VCOM_PERIPHERAL, EUSART_IF_RXFL);
230+
231+
// Enable EUSART
232+
EUSART_Enable(SL_UARTDRV_EUSART_VCOM_PERIPHERAL, eusartEnable);
217233
#else
218234
USART_IntEnable(SL_UARTDRV_USART_VCOM_PERIPHERAL, USART_IF_RXDATAV);
219235
#endif // EFR32MG24
@@ -229,6 +245,10 @@ void USART_IRQHandler(void)
229245
#elif !defined(PW_RPC_ENABLED)
230246
otSysEventSignalPending();
231247
#endif
248+
249+
#ifdef EFR32MG24
250+
EUSART_IntClear(SL_UARTDRV_EUSART_VCOM_PERIPHERAL, EUSART_IF_RXFL);
251+
#endif
232252
}
233253

234254
/*

0 commit comments

Comments
 (0)