Skip to content

Commit

Permalink
[EFR32] Fix OpenThread and Matter shell operation on EFRMG24 boards (p…
Browse files Browse the repository at this point in the history
…roject-chip#19858)

* Test added march 8 (project-chip#15957)

* Added new manual scripts

* Added Auto generated File

* [OTA] Fix OTARequestorDriverImpl inclusion (project-chip#15981)

* Regen to fix CI failures (project-chip#15990)

* [ota] Store Default OTA Providers in flash (project-chip#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>
  • Loading branch information
6 people authored Jun 22, 2022
1 parent 92eeafc commit 6231ccc
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions examples/platform/efr32/uart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,27 @@ 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
#ifdef EFR32MG24
#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)
Expand Down Expand Up @@ -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
Expand All @@ -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
}

/*
Expand Down

0 comments on commit 6231ccc

Please sign in to comment.