From 10af54d8821a1e03992d19bf1a70ff91a119489e Mon Sep 17 00:00:00 2001 From: chirag-silabs <100861685+chirag-silabs@users.noreply.github.com> Date: Tue, 11 Apr 2023 18:55:00 +0530 Subject: [PATCH] [Silabs][SiWx917] Fixing uart to read only once (#25902) * fixing uart to read only once * Restyled by clang-format * Uart fix to read character by character * restyling the PR * removing the duplicate files * removing the siwx917 file * Restyled by gn * adding some comments --------- Co-authored-by: Restyled.io --- examples/platform/silabs/SiWx917/uart.cpp | 9 --------- src/lib/shell/BUILD.gn | 12 ++++-------- .../shell/{MainLoopEFR32.cpp => MainLoopSilabs.cpp} | 11 +++++++++++ .../{streamer_efr32.cpp => streamer_silabs.cpp} | 0 4 files changed, 15 insertions(+), 17 deletions(-) rename src/lib/shell/{MainLoopEFR32.cpp => MainLoopSilabs.cpp} (93%) rename src/lib/shell/{streamer_efr32.cpp => streamer_silabs.cpp} (100%) diff --git a/examples/platform/silabs/SiWx917/uart.cpp b/examples/platform/silabs/SiWx917/uart.cpp index 850d9b643026f4..74e77f43f11ad4 100644 --- a/examples/platform/silabs/SiWx917/uart.cpp +++ b/examples/platform/silabs/SiWx917/uart.cpp @@ -33,13 +33,8 @@ extern ARM_DRIVER_USART Driver_USART0; static ARM_DRIVER_USART * UARTdrv = &Driver_USART0; ARM_USART_CAPABILITIES drv_capabilities; -ARM_USART_STATUS status; - -#define BUFFER_SIZE 1 -uint8_t rx_buffer; #define BAUD_VALUE 115200 - #define UART_CONSOLE_ERR -1 // Negative value in case of UART Console action failed. Triggers a failure for PW_RPC void ARM_USART_SignalEvent(uint32_t event); @@ -141,10 +136,6 @@ void uartConsoleInit(void) DEBUGOUT("\r\n Receives data success \r\n"); } - // Creating the receive event as a temp buffer - // this is not used anywhere - status = UARTdrv->Receive(&rx_buffer, 1); - NVIC_EnableIRQ(USART0_IRQn); NVIC_SetPriority(USART0_IRQn, 7); diff --git a/src/lib/shell/BUILD.gn b/src/lib/shell/BUILD.gn index 43b0766a871328..7f3d1d46cb62b1 100644 --- a/src/lib/shell/BUILD.gn +++ b/src/lib/shell/BUILD.gn @@ -50,15 +50,11 @@ static_library("shell") { "MainLoopESP32.cpp", "streamer_esp32.cpp", ] - } else if (chip_device_platform == "efr32") { + } else if (chip_device_platform == "efr32" || + chip_device_platform == "SiWx917") { sources += [ - "MainLoopEFR32.cpp", - "streamer_efr32.cpp", - ] - } else if (chip_device_platform == "SiWx917") { - sources += [ - "MainLoopEFR32.cpp", - "streamer_efr32.cpp", + "MainLoopSilabs.cpp", + "streamer_silabs.cpp", ] } else if (chip_device_platform == "k32w0") { sources += [ diff --git a/src/lib/shell/MainLoopEFR32.cpp b/src/lib/shell/MainLoopSilabs.cpp similarity index 93% rename from src/lib/shell/MainLoopEFR32.cpp rename to src/lib/shell/MainLoopSilabs.cpp index b43673ba526dd6..2b755119fd8cd5 100644 --- a/src/lib/shell/MainLoopEFR32.cpp +++ b/src/lib/shell/MainLoopSilabs.cpp @@ -49,11 +49,22 @@ void ReadLine(char * buffer, size_t max) break; } +#ifdef BRD4325A + // for 917 SoC board, we need to create a rx event before we wait for the shell activity + // NotifyShellProcessFromISR() is called once the buffer is filled + if (streamer_read(streamer_get(), buffer + line_sz, 1) != 1) + { + continue; + } +#endif chip::WaitForShellActivity(); +#ifndef BRD4325A + // for EFR32 boards if (streamer_read(streamer_get(), buffer + line_sz, 1) != 1) { continue; } +#endif // Process character we just read. switch (buffer[line_sz]) diff --git a/src/lib/shell/streamer_efr32.cpp b/src/lib/shell/streamer_silabs.cpp similarity index 100% rename from src/lib/shell/streamer_efr32.cpp rename to src/lib/shell/streamer_silabs.cpp