From 67ec6f009a628a06a90c1b802e851c7726ad3c67 Mon Sep 17 00:00:00 2001 From: rosahay-silabs Date: Sun, 3 Sep 2023 02:58:34 +0530 Subject: [PATCH 01/29] Adds DISPLAY_ENABLED macro for SPI multiplexed functions --- examples/platform/silabs/display/demo-ui.c | 4 ++-- examples/platform/silabs/efr32/rs911x/hal/efx_spi.c | 3 ++- examples/platform/silabs/efr32/spi_multiplex.h | 2 ++ examples/platform/silabs/efr32/wf200/efr_spi.c | 2 ++ 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/examples/platform/silabs/display/demo-ui.c b/examples/platform/silabs/display/demo-ui.c index e430e01ddb82dd..018ff0e15fd32c 100644 --- a/examples/platform/silabs/display/demo-ui.c +++ b/examples/platform/silabs/display/demo-ui.c @@ -102,11 +102,11 @@ void demoUIInit(GLIB_Context_t * context) sl_status_t updateDisplay(void) { -#if (defined(EFR32MG24) && defined(SL_WIFI)) +#if (defined(EFR32MG24) && defined(SL_WIFI) && defined(DISPLAY_ENABLED)) sl_wfx_host_pre_lcd_spi_transfer(); #endif sl_status_t status = DMD_updateDisplay(); -#if (defined(EFR32MG24) && defined(SL_WIFI)) +#if (defined(EFR32MG24) && defined(SL_WIFI) && defined(DISPLAY_ENABLED)) sl_wfx_host_post_lcd_spi_transfer(); #endif if (status != DMD_OK) diff --git a/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c b/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c index aff756aad8888a..68de71400999ed 100644 --- a/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c +++ b/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c @@ -297,6 +297,7 @@ sl_status_t sl_wfx_host_post_bootloader_spi_transfer(void) return SL_STATUS_OK; } +#if defined(DISPLAY_ENABLED) sl_status_t sl_wfx_host_pre_lcd_spi_transfer(void) { xSemaphoreTake(spi_sem_sync_hdl, portMAX_DELAY); @@ -326,7 +327,7 @@ sl_status_t sl_wfx_host_post_lcd_spi_transfer(void) xSemaphoreGive(spi_sem_sync_hdl); return SL_STATUS_OK; } - +#endif // DISPLAY_ENABLED #endif /* EFR32MG24 */ /***************************************************************************** diff --git a/examples/platform/silabs/efr32/spi_multiplex.h b/examples/platform/silabs/efr32/spi_multiplex.h index 0c926b809fab1a..34455349441b55 100644 --- a/examples/platform/silabs/efr32/spi_multiplex.h +++ b/examples/platform/silabs/efr32/spi_multiplex.h @@ -124,6 +124,7 @@ sl_status_t sl_wfx_host_pre_bootloader_spi_transfer(void); *****************************************************************************/ sl_status_t sl_wfx_host_post_bootloader_spi_transfer(void); +#if defined(DISPLAY_ENABLED) /**************************************************************************** * @fn sl_status_t sl_wfx_host_pre_lcd_spi_transfer() * @brief @@ -141,6 +142,7 @@ sl_status_t sl_wfx_host_pre_lcd_spi_transfer(void); * @return SL_STATUS_OK *****************************************************************************/ sl_status_t sl_wfx_host_post_lcd_spi_transfer(void); +#endif // DISPLAY_ENABLED #if defined(WF200_WIFI) /**************************************************************************** diff --git a/examples/platform/silabs/efr32/wf200/efr_spi.c b/examples/platform/silabs/efr32/wf200/efr_spi.c index ab5a4e64ab73c1..779079c4010cf5 100644 --- a/examples/platform/silabs/efr32/wf200/efr_spi.c +++ b/examples/platform/silabs/efr32/wf200/efr_spi.c @@ -425,6 +425,7 @@ sl_status_t sl_wfx_host_post_bootloader_spi_transfer(void) return SL_STATUS_OK; } +#if defined(DISPLAY_ENABLED) sl_status_t sl_wfx_host_pre_lcd_spi_transfer(void) { xSemaphoreTake(spi_sem_sync_hdl, portMAX_DELAY); @@ -438,6 +439,7 @@ sl_status_t sl_wfx_host_post_lcd_spi_transfer(void) xSemaphoreGive(spi_sem_sync_hdl); return SL_STATUS_OK; } +#endif // DISPLAY_ENABLED sl_status_t sl_wfx_host_pre_uart_transfer(void) { From 49e53ea57dbc2a0465a0241c6cd364025541ec82 Mon Sep 17 00:00:00 2001 From: rosahay-silabs Date: Sun, 3 Sep 2023 03:03:52 +0530 Subject: [PATCH 02/29] Adds CONFIG_USE_EXTERNAL_FLASH macro for SPI multiplex functions --- examples/platform/silabs/efr32/rs911x/hal/efx_spi.c | 7 ++++++- examples/platform/silabs/efr32/spi_multiplex.h | 2 ++ examples/platform/silabs/efr32/wf200/efr_spi.c | 7 ++++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c b/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c index 68de71400999ed..0093812fd7c81b 100644 --- a/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c +++ b/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c @@ -245,6 +245,7 @@ sl_status_t sl_wfx_host_spi_cs_deassert(void) return SL_STATUS_OK; } +#if defined(CONFIG_USE_EXTERNAL_FLASH) sl_status_t sl_wfx_host_spiflash_cs_assert(void) { GPIO_PinOutClear(SL_MX25_FLASH_SHUTDOWN_CS_PORT, SL_MX25_FLASH_SHUTDOWN_CS_PIN); @@ -256,7 +257,7 @@ sl_status_t sl_wfx_host_spiflash_cs_deassert(void) GPIO_PinOutSet(SL_MX25_FLASH_SHUTDOWN_CS_PORT, SL_MX25_FLASH_SHUTDOWN_CS_PIN); return SL_STATUS_OK; } - +#endif // CONFIG_USE_EXTERNAL_FLASH sl_status_t sl_wfx_host_pre_bootloader_spi_transfer(void) { xSemaphoreTake(spi_sem_sync_hdl, portMAX_DELAY); @@ -277,7 +278,9 @@ sl_status_t sl_wfx_host_pre_bootloader_spi_transfer(void) xSemaphoreGive(spi_sem_sync_hdl); return SL_STATUS_FAIL; } +#if defined(CONFIG_USE_EXTERNAL_FLASH) sl_wfx_host_spiflash_cs_assert(); +#endif // CONFIG_USE_EXTERNAL_FLASH return SL_STATUS_OK; } @@ -292,7 +295,9 @@ sl_status_t sl_wfx_host_post_bootloader_spi_transfer(void) return SL_STATUS_FAIL; } GPIO->USARTROUTE[SL_MX25_FLASH_SHUTDOWN_PERIPHERAL_NO].ROUTEEN = PINOUT_CLEAR; +#if defined(CONFIG_USE_EXTERNAL_FLASH) sl_wfx_host_spiflash_cs_deassert(); +#endif // CONFIG_USE_EXTERNAL_FLASH xSemaphoreGive(spi_sem_sync_hdl); return SL_STATUS_OK; } diff --git a/examples/platform/silabs/efr32/spi_multiplex.h b/examples/platform/silabs/efr32/spi_multiplex.h index 34455349441b55..cf8bcccc5f062b 100644 --- a/examples/platform/silabs/efr32/spi_multiplex.h +++ b/examples/platform/silabs/efr32/spi_multiplex.h @@ -88,6 +88,7 @@ sl_status_t sl_wfx_host_spi_cs_assert(void); sl_status_t sl_wfx_host_spi_cs_deassert(void); #endif /* RS911X_WIFI */ +#if defined(CONFIG_USE_EXTERNAL_FLASH) /**************************************************************************** * @fn sl_status_t sl_wfx_host_spiflash_cs_assert() * @brief @@ -105,6 +106,7 @@ sl_status_t sl_wfx_host_spiflash_cs_assert(void); * @return returns SL_STATUS_OK *****************************************************************************/ sl_status_t sl_wfx_host_spiflash_cs_deassert(void); +#endif // CONFIG_USE_EXTERNAL_FLASH /**************************************************************************** * @fn sl_status_t sl_wfx_host_pre_bootloader_spi_transfer() diff --git a/examples/platform/silabs/efr32/wf200/efr_spi.c b/examples/platform/silabs/efr32/wf200/efr_spi.c index 779079c4010cf5..8da72dc773251f 100644 --- a/examples/platform/silabs/efr32/wf200/efr_spi.c +++ b/examples/platform/silabs/efr32/wf200/efr_spi.c @@ -391,7 +391,7 @@ void SPIDRV_SetBaudrate(uint32_t baudrate) USART_InitSync(MY_USART, &usartInit); } - +#if defined(CONFIG_USE_EXTERNAL_FLASH) sl_status_t sl_wfx_host_spiflash_cs_assert(void) { GPIO_PinOutClear(SL_MX25_FLASH_SHUTDOWN_CS_PORT, SL_MX25_FLASH_SHUTDOWN_CS_PIN); @@ -403,6 +403,7 @@ sl_status_t sl_wfx_host_spiflash_cs_deassert(void) GPIO_PinOutSet(SL_MX25_FLASH_SHUTDOWN_CS_PORT, SL_MX25_FLASH_SHUTDOWN_CS_PIN); return SL_STATUS_OK; } +#endif // CONFIG_USE_EXTERNAL_FLASH sl_status_t sl_wfx_host_pre_bootloader_spi_transfer(void) { @@ -411,7 +412,9 @@ sl_status_t sl_wfx_host_pre_bootloader_spi_transfer(void) * Assert CS pin for EXT SPI Flash */ SPIDRV_SetBaudrate(SL_SPIDRV_MX25_FLASH_BITRATE); +#if defined(CONFIG_USE_EXTERNAL_FLASH) sl_wfx_host_spiflash_cs_assert(); +#endif // CONFIG_USE_EXTERNAL_FLASH return SL_STATUS_OK; } @@ -420,7 +423,9 @@ sl_status_t sl_wfx_host_post_bootloader_spi_transfer(void) /* * De-Assert CS pin for EXT SPI Flash */ +#if defined(CONFIG_USE_EXTERNAL_FLASH) sl_wfx_host_spiflash_cs_deassert(); +#endif // CONFIG_USE_EXTERNAL_FLASH xSemaphoreGive(spi_sem_sync_hdl); return SL_STATUS_OK; } From f5cfc3444aa74b3ec49c0e2be5b8cfb0f434428c Mon Sep 17 00:00:00 2001 From: Rohan Sahay Date: Mon, 11 Sep 2023 15:59:20 +0530 Subject: [PATCH 03/29] Added proper MACROs for the features that require multiplexing --- examples/platform/silabs/display/demo-ui.c | 10 +-- .../silabs/efr32/rs911x/hal/efx_spi.c | 69 ++++++++++------ .../platform/silabs/efr32/spi_multiplex.h | 56 +++++++++---- .../platform/silabs/efr32/wf200/efr_spi.c | 79 ++++++++++++------- .../silabs/efr32/OTAImageProcessorImpl.cpp | 42 +++++----- 5 files changed, 162 insertions(+), 94 deletions(-) diff --git a/examples/platform/silabs/display/demo-ui.c b/examples/platform/silabs/display/demo-ui.c index 018ff0e15fd32c..dc18d20d4b19b2 100644 --- a/examples/platform/silabs/display/demo-ui.c +++ b/examples/platform/silabs/display/demo-ui.c @@ -25,7 +25,7 @@ #include "glib.h" #include #include -#if (defined(EFR32MG24) && defined(SL_WIFI)) +#if SL_LCDCTRL_MUX #include "spi_multiplex.h" #endif @@ -102,13 +102,13 @@ void demoUIInit(GLIB_Context_t * context) sl_status_t updateDisplay(void) { -#if (defined(EFR32MG24) && defined(SL_WIFI) && defined(DISPLAY_ENABLED)) +#if SL_LCDCTRL_MUX sl_wfx_host_pre_lcd_spi_transfer(); -#endif +#endif // SL_LCDCTRL_MUX sl_status_t status = DMD_updateDisplay(); -#if (defined(EFR32MG24) && defined(SL_WIFI) && defined(DISPLAY_ENABLED)) +#if SL_LCDCTRL_MUX sl_wfx_host_post_lcd_spi_transfer(); -#endif +#endif // SL_LCDCTRL_MUX if (status != DMD_OK) return SL_STATUS_FAIL; return SL_STATUS_OK; diff --git a/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c b/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c index 0093812fd7c81b..b81d7ef07a2922 100644 --- a/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c +++ b/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c @@ -33,6 +33,7 @@ #include "em_usart.h" #elif defined(EFR32MG24) #include "em_eusart.h" +#include "sl_spidrv_eusart_exp_config.h" #endif #include "spidrv.h" @@ -42,6 +43,7 @@ #include "sl_device_init_clocks.h" #include "sl_memlcd.h" #include "sl_status.h" +#include "spi_multiplex.h" #include "FreeRTOS.h" #include "event_groups.h" @@ -78,10 +80,10 @@ #define CONCAT(A, B) (A##B) #define SPI_CLOCK(N) CONCAT(cmuClock_USART, N) -#if defined(EFR32MG24) +#if SL_SPICTRL_MUX StaticSemaphore_t spi_sem_peripheral; -SemaphoreHandle_t spi_sem_sync_hdl; -#endif /* EFR32MG24 */ +static SemaphoreHandle_t spi_sem_sync_hdl; +#endif // SL_SPICTRL_MUX StaticSemaphore_t xEfxSpiIntfSemaBuffer; static SemaphoreHandle_t spiTransferLock; @@ -89,12 +91,11 @@ static TaskHandle_t spiInitiatorTaskHandle = NULL; static uint32_t dummy_buffer; /* Used for DMA - when results don't matter */ +#include "sl_spidrv_instances.h" #if defined(EFR32MG12) -#include "sl_spidrv_exp_config.h" -extern SPIDRV_Handle_t sl_spidrv_exp_handle; #define SL_SPIDRV_HANDLE sl_spidrv_exp_handle #elif defined(EFR32MG24) -#include "spi_multiplex.h" +#define SL_SPIDRV_HANDLE sl_spidrv_eusart_exp_handle #else #error "Unknown platform" #endif @@ -175,14 +176,14 @@ void rsi_hal_board_init(void) spiTransferLock = xSemaphoreCreateBinaryStatic(&xEfxSpiIntfSemaBuffer); xSemaphoreGive(spiTransferLock); -#if defined(EFR32MG24) +#if SL_SPICTRL_MUX if (spi_sem_sync_hdl == NULL) { spi_sem_sync_hdl = xSemaphoreCreateBinaryStatic(&spi_sem_peripheral); } configASSERT(spi_sem_sync_hdl); xSemaphoreGive(spi_sem_sync_hdl); -#endif /* EFR32MG24 */ +#endif /* SL_SPICTRL_MUX */ /* GPIO INIT of MG12 & MG24 : Reset, Wakeup, Interrupt */ sl_wfx_host_gpio_init(); @@ -203,8 +204,7 @@ void sl_si91x_host_enable_high_speed_bus() // dummy function for wifi-sdk } -#if defined(EFR32MG24) - +#if SL_SPICTRL_MUX void SPIDRV_SetBaudrate(uint32_t baudrate) { if (EUSART_BaudrateGet(MY_USART) == baudrate) @@ -214,9 +214,11 @@ void SPIDRV_SetBaudrate(uint32_t baudrate) } EUSART_BaudrateSet(MY_USART, 0, baudrate); } +#endif // SL_SPICTRL_MUX sl_status_t sl_wfx_host_spi_cs_assert(void) { +#if SL_SPICTRL_MUX xSemaphoreTake(spi_sem_sync_hdl, portMAX_DELAY); if (!spi_enabled) // Reduce sl_spidrv_init_instances @@ -224,12 +226,16 @@ sl_status_t sl_wfx_host_spi_cs_assert(void) sl_spidrv_init_instances(); spi_enabled = true; } +#endif // SL_SPICTRL_MUX +#if defined(EFR32MG24) GPIO_PinOutClear(SL_SPIDRV_EUSART_EXP_CS_PORT, SL_SPIDRV_EUSART_EXP_CS_PIN); +#endif // EFR32MG24 return SL_STATUS_OK; } sl_status_t sl_wfx_host_spi_cs_deassert(void) { +#if SL_SPICTRL_MUX if (spi_enabled) { if (ECODE_EMDRV_SPIDRV_OK != SPIDRV_DeInit(SL_SPIDRV_HANDLE)) @@ -239,13 +245,18 @@ sl_status_t sl_wfx_host_spi_cs_deassert(void) } spi_enabled = false; } +#endif // SL_SPICTRL_MUX +#if defined(EFR32MG24) GPIO_PinOutSet(SL_SPIDRV_EUSART_EXP_CS_PORT, SL_SPIDRV_EUSART_EXP_CS_PIN); GPIO->EUSARTROUTE[SL_SPIDRV_EUSART_EXP_PERIPHERAL_NO].ROUTEEN = PINOUT_CLEAR; +#endif // EFR32MG24 +#if SL_SPICTRL_MUX xSemaphoreGive(spi_sem_sync_hdl); +#endif // SL_SPICTRL_MUX return SL_STATUS_OK; } -#if defined(CONFIG_USE_EXTERNAL_FLASH) +#if SL_MUX25CTRL_MUX sl_status_t sl_wfx_host_spiflash_cs_assert(void) { GPIO_PinOutClear(SL_MX25_FLASH_SHUTDOWN_CS_PORT, SL_MX25_FLASH_SHUTDOWN_CS_PIN); @@ -257,9 +268,12 @@ sl_status_t sl_wfx_host_spiflash_cs_deassert(void) GPIO_PinOutSet(SL_MX25_FLASH_SHUTDOWN_CS_PORT, SL_MX25_FLASH_SHUTDOWN_CS_PIN); return SL_STATUS_OK; } -#endif // CONFIG_USE_EXTERNAL_FLASH +#endif // SL_MUX25CTRL_MUX + +#if SL_BTLCTRL_MUX sl_status_t sl_wfx_host_pre_bootloader_spi_transfer(void) { +#if SL_SPICTRL_MUX xSemaphoreTake(spi_sem_sync_hdl, portMAX_DELAY); if (spi_enabled) { @@ -270,17 +284,20 @@ sl_status_t sl_wfx_host_pre_bootloader_spi_transfer(void) } spi_enabled = false; } +#endif // SL_SPICTRL_MUX // bootloader_init takes care of SPIDRV_Init() int32_t status = bootloader_init(); if (status != BOOTLOADER_OK) { SILABS_LOG("bootloader_init error: %x", status); +#if SL_SPICTRL_MUX xSemaphoreGive(spi_sem_sync_hdl); +#endif // SL_SPICTRL_MUX return SL_STATUS_FAIL; } -#if defined(CONFIG_USE_EXTERNAL_FLASH) +#if SL_MUX25CTRL_MUX sl_wfx_host_spiflash_cs_assert(); -#endif // CONFIG_USE_EXTERNAL_FLASH +#endif // SL_MUX25CTRL_MUX return SL_STATUS_OK; } @@ -291,20 +308,26 @@ sl_status_t sl_wfx_host_post_bootloader_spi_transfer(void) if (status != BOOTLOADER_OK) { SILABS_LOG("bootloader_deinit error: %x", status); +#if SL_SPICTRL_MUX xSemaphoreGive(spi_sem_sync_hdl); +#endif // SL_SPICTRL_MUX return SL_STATUS_FAIL; } GPIO->USARTROUTE[SL_MX25_FLASH_SHUTDOWN_PERIPHERAL_NO].ROUTEEN = PINOUT_CLEAR; -#if defined(CONFIG_USE_EXTERNAL_FLASH) +#if SL_MUX25CTRL_MUX sl_wfx_host_spiflash_cs_deassert(); -#endif // CONFIG_USE_EXTERNAL_FLASH +#endif // SL_MUX25CTRL_MUX +#if SL_SPICTRL_MUX xSemaphoreGive(spi_sem_sync_hdl); +#endif // SL_SPICTRL_MUX return SL_STATUS_OK; } +#endif // SL_BTLCTRL_MUX -#if defined(DISPLAY_ENABLED) +#if SL_LCDCTRL_MUX sl_status_t sl_wfx_host_pre_lcd_spi_transfer(void) { +#if SL_SPICTRL_MUX xSemaphoreTake(spi_sem_sync_hdl, portMAX_DELAY); if (spi_enabled) { @@ -315,10 +338,13 @@ sl_status_t sl_wfx_host_pre_lcd_spi_transfer(void) } spi_enabled = false; } +#endif // SL_SPICTRL_MUX // sl_memlcd_refresh takes care of SPIDRV_Init() if (SL_STATUS_OK != sl_memlcd_refresh(sl_memlcd_get())) { +#if SL_SPICTRL_MUX xSemaphoreGive(spi_sem_sync_hdl); +#endif // SL_SPICTRL_MUX return SL_STATUS_FAIL; } return SL_STATUS_OK; @@ -329,11 +355,12 @@ sl_status_t sl_wfx_host_post_lcd_spi_transfer(void) USART_Enable(SL_MEMLCD_SPI_PERIPHERAL, usartDisable); CMU_ClockEnable(SPI_CLOCK(SL_MEMLCD_SPI_PERIPHERAL_NO), false); GPIO->USARTROUTE[SL_MEMLCD_SPI_PERIPHERAL_NO].ROUTEEN = PINOUT_CLEAR; +#if SL_SPICTRL_MUX xSemaphoreGive(spi_sem_sync_hdl); +#endif // SL_SPICTRL_MUX return SL_STATUS_OK; } -#endif // DISPLAY_ENABLED -#endif /* EFR32MG24 */ +#endif // SL_LCDCTRL_MUX /***************************************************************************** *@brief @@ -369,9 +396,7 @@ static void spi_dmaTransfertComplete(SPIDRV_HandleData_t * pxHandle, Ecode_t tra **************************************************************************/ int16_t rsi_spi_transfer(uint8_t * tx_buf, uint8_t * rx_buf, uint16_t xlen, uint8_t mode) { -#if defined(EFR32MG24) sl_wfx_host_spi_cs_assert(); -#endif /* EFR32MG24 */ /* TODO: tx_buf and rx_buf needs to be replaced with a dummy buffer of length xlen to align with SDK of WiFi */ @@ -429,9 +454,7 @@ int16_t rsi_spi_transfer(uint8_t * tx_buf, uint8_t * rx_buf, uint16_t xlen, uint } xSemaphoreGive(spiTransferLock); -#if defined(EFR32MG24) sl_wfx_host_spi_cs_deassert(); -#endif /* EFR32MG24 */ return rsiError; } diff --git a/examples/platform/silabs/efr32/spi_multiplex.h b/examples/platform/silabs/efr32/spi_multiplex.h index cf8bcccc5f062b..283370eb0d99a3 100644 --- a/examples/platform/silabs/efr32/spi_multiplex.h +++ b/examples/platform/silabs/efr32/spi_multiplex.h @@ -24,7 +24,30 @@ #pragma once -#if defined(EFR32MG24) +#ifndef SL_LCDCTRL_MUX +#define SL_LCDCTRL_MUX (EFR32MG24 && DISPLAY_ENABLED) +#endif // SL_LCDCTRL_MUX + +#ifndef SL_UARTCTRL_MUX +#define SL_UARTCTRL_MUX (EFR32MG24 && WF200_WIFI && ENABLE_CHIP_SHELL) +#endif // SL_UARTCTRL_MUX + +#ifndef SL_MX25CTRL_MUX +#define SL_MUX25CTRL_MUX (EFR32MG24 && CONFIG_USE_EXTERNAL_FLASH) +#endif // SL_MX25CTRL_MUX + +#ifndef SL_BTLCTRL_MUX +#define SL_BTLCTRL_MUX SL_MUX25CTRL_MUX +#endif // SL_BTLCTRL_MUX + +#ifndef SL_SPICTRL_MUX +#define SL_SPICTRL_MUX (EFR32MG24 && SL_WIFI && (SL_LCDCTRL_MUX || SL_UARTCTRL_MUX || SL_MX25CTRL_MUX || SL_BTLCTRL_MUX)) +#endif // SL_SPICTRL_MUX + +// CONFIG_USE_EXTERNAL_FLASH +// DISPLAY_ENABLED + +#if SL_SPICTRL_MUX #ifdef __cplusplus extern "C" { #endif @@ -33,7 +56,7 @@ extern "C" { #include "semphr.h" #include "sl_memlcd_display.h" #include "sl_mx25_flash_shutdown_usart_config.h" -#include "sl_spidrv_instances.h" + #include "spidrv.h" #define SL_SPIDRV_LCD_BITRATE SL_MEMLCD_SCLK_FREQ @@ -41,24 +64,24 @@ extern "C" { #ifdef RS911X_WIFI #include "sl_spidrv_eusart_exp_config.h" - #define SL_SPIDRV_EXP_BITRATE_MULTIPLEXED SL_SPIDRV_EUSART_EXP_BITRATE #define SL_SPIDRV_UART_CONSOLE_BITRATE SL_UARTDRV_EUSART_VCOM_BAUDRATE #define SL_SPIDRV_FRAME_LENGTH SL_SPIDRV_EUSART_EXP_FRAME_LENGTH -#define SL_SPIDRV_HANDLE sl_spidrv_eusart_exp_handle #elif WF200_WIFI -#include "sl_spidrv_exp_config.h" -#include "sl_wfx_host_api.h" - // TODO: (MATTER-1906) Investigate why using SL_SPIDRV_EXP_BITRATE is causing WF200 init failure // REF: sl_spidrv_exp_config.h +#include "sl_spidrv_exp_config.h" #define SL_SPIDRV_EXP_BITRATE_MULTIPLEXED 10000000 #define SL_SPIDRV_UART_CONSOLE_BITRATE SL_UARTDRV_USART_VCOM_BAUDRATE #define SL_SPIDRV_FRAME_LENGTH SL_SPIDRV_EXP_FRAME_LENGTH -#define SL_SPIDRV_HANDLE sl_spidrv_exp_handle + +#else +#error "Unknown platform" + #endif /* RS911X_WIFI || WF200_WIFI */ +#if SL_SPICTRL_MUX /**************************************************************************** * @fn void SPIDRV_SetBaudrate() * @brief @@ -87,8 +110,9 @@ sl_status_t sl_wfx_host_spi_cs_assert(void); *****************************************************************************/ sl_status_t sl_wfx_host_spi_cs_deassert(void); #endif /* RS911X_WIFI */ +#endif // SL_SPICTRL_MUX -#if defined(CONFIG_USE_EXTERNAL_FLASH) +#if SL_MUX25CTRL_MUX /**************************************************************************** * @fn sl_status_t sl_wfx_host_spiflash_cs_assert() * @brief @@ -106,8 +130,9 @@ sl_status_t sl_wfx_host_spiflash_cs_assert(void); * @return returns SL_STATUS_OK *****************************************************************************/ sl_status_t sl_wfx_host_spiflash_cs_deassert(void); -#endif // CONFIG_USE_EXTERNAL_FLASH +#endif // SL_MUX25CTRL_MUX +#if SL_BTLCTRL_MUX /**************************************************************************** * @fn sl_status_t sl_wfx_host_pre_bootloader_spi_transfer() * @brief @@ -125,8 +150,9 @@ sl_status_t sl_wfx_host_pre_bootloader_spi_transfer(void); * @return SL_STATUS_OK *****************************************************************************/ sl_status_t sl_wfx_host_post_bootloader_spi_transfer(void); +#endif // SL_BTLCTRL_MUX -#if defined(DISPLAY_ENABLED) +#if SL_LCDCTRL_MUX /**************************************************************************** * @fn sl_status_t sl_wfx_host_pre_lcd_spi_transfer() * @brief @@ -144,9 +170,9 @@ sl_status_t sl_wfx_host_pre_lcd_spi_transfer(void); * @return SL_STATUS_OK *****************************************************************************/ sl_status_t sl_wfx_host_post_lcd_spi_transfer(void); -#endif // DISPLAY_ENABLED +#endif // SL_LCDCTRL_MUX -#if defined(WF200_WIFI) +#if SL_UARTCTRL_MUX /**************************************************************************** * @fn sl_status_t sl_wfx_host_pre_uart_transfer() * @brief @@ -164,9 +190,9 @@ sl_status_t sl_wfx_host_pre_uart_transfer(void); * @return SL_STATUS_OK *****************************************************************************/ sl_status_t sl_wfx_host_post_uart_transfer(void); -#endif /* WF200_WIFI */ +#endif // SL_UARTCTRL_MUX #ifdef __cplusplus } #endif -#endif /* EFR32MG24 */ +#endif // SL_SPICTRL_MUX \ No newline at end of file diff --git a/examples/platform/silabs/efr32/wf200/efr_spi.c b/examples/platform/silabs/efr32/wf200/efr_spi.c index 8da72dc773251f..1598fd895228a2 100644 --- a/examples/platform/silabs/efr32/wf200/efr_spi.c +++ b/examples/platform/silabs/efr32/wf200/efr_spi.c @@ -41,6 +41,7 @@ #include "sl_wfx_board.h" #include "sl_wfx_host.h" +#include "sl_wfx_host_api.h" #include "sl_wfx_task.h" #include "wfx_host_events.h" @@ -48,23 +49,21 @@ #include "sl_power_manager.h" #endif -#if defined(EFR32MG12) #include "sl_spidrv_exp_config.h" -extern SPIDRV_Handle_t sl_spidrv_exp_handle; -#define SL_SPIDRV_HANDLE sl_spidrv_exp_handle -#elif defined(EFR32MG24) -#include "sl_spidrv_eusart_exp_config.h" +#include "sl_spidrv_instances.h" #include "spi_multiplex.h" +#if (defined(EFR32MG12) || defined(EFR32MG24)) +#define SL_SPIDRV_HANDLE sl_spidrv_exp_handle #else #error "Unknown platform" #endif #define USART SL_WFX_HOST_PINOUT_SPI_PERIPHERAL -#if defined(EFR32MG24) +#if SL_SPICTRL_MUX StaticSemaphore_t spi_sem_peripheral; -SemaphoreHandle_t spi_sem_sync_hdl; -#endif /* EFR32MG24 */ +static SemaphoreHandle_t spi_sem_sync_hdl; +#endif // SL_SPICTRL_MUX StaticSemaphore_t xEfrSpiSemaBuffer; static SemaphoreHandle_t spi_sem; @@ -113,23 +112,23 @@ sl_status_t sl_wfx_host_init_bus(void) spi_sem = xSemaphoreCreateBinaryStatic(&xEfrSpiSemaBuffer); xSemaphoreGive(spi_sem); -#if defined(EFR32MG24) +#if SL_SPICTRL_MUX if (spi_sem_sync_hdl == NULL) { spi_sem_sync_hdl = xSemaphoreCreateBinaryStatic(&spi_sem_peripheral); } configASSERT(spi_sem_sync_hdl); xSemaphoreGive(spi_sem_sync_hdl); -#endif /* EFR32MG24 */ +#endif /* SL_SPICTRL_MUX */ return SL_STATUS_OK; } sl_status_t sl_wfx_host_deinit_bus(void) { vSemaphoreDelete(spi_sem); -#if defined(EFR32MG24) +#if SL_SPICTRL_MUX vSemaphoreDelete(spi_sem_sync_hdl); -#endif /* EFR32MG24 */ +#endif /* SL_SPICTRL_MUX */ // Stop DMAs. DMADRV_StopTransfer(rx_dma_channel); DMADRV_StopTransfer(tx_dma_channel); @@ -142,10 +141,10 @@ sl_status_t sl_wfx_host_deinit_bus(void) sl_status_t sl_wfx_host_spi_cs_assert() { -#if defined(EFR32MG24) +#if SL_SPICTRL_MUX xSemaphoreTake(spi_sem_sync_hdl, portMAX_DELAY); SPIDRV_SetBaudrate(SL_SPIDRV_EXP_BITRATE_MULTIPLEXED); -#endif /* EFR32MG24 */ +#endif /* SL_SPICTRL_MUX */ GPIO_PinOutClear(SL_SPIDRV_EXP_CS_PORT, SL_SPIDRV_EXP_CS_PIN); return SL_STATUS_OK; } @@ -153,9 +152,9 @@ sl_status_t sl_wfx_host_spi_cs_assert() sl_status_t sl_wfx_host_spi_cs_deassert() { GPIO_PinOutSet(SL_SPIDRV_EXP_CS_PORT, SL_SPIDRV_EXP_CS_PIN); -#if defined(EFR32MG24) +#if SL_SPICTRL_MUX xSemaphoreGive(spi_sem_sync_hdl); -#endif /* EFR32MG24 */ +#endif /* SL_SPICTRL_MUX */ return SL_STATUS_OK; } @@ -370,9 +369,7 @@ void sl_wfx_host_gpio_init(void) NVIC_SetPriority(GPIO_EVEN_IRQn, 5); NVIC_SetPriority(GPIO_ODD_IRQn, 5); } - -#if defined(EFR32MG24) - +#if SL_SPICTRL_MUX void SPIDRV_SetBaudrate(uint32_t baudrate) { if (USART_BaudrateGet(MY_USART) == baudrate) @@ -391,7 +388,8 @@ void SPIDRV_SetBaudrate(uint32_t baudrate) USART_InitSync(MY_USART, &usartInit); } -#if defined(CONFIG_USE_EXTERNAL_FLASH) +#endif // SL_SPICTRL_MUX +#if SL_MUX25CTRL_MUX sl_status_t sl_wfx_host_spiflash_cs_assert(void) { GPIO_PinOutClear(SL_MX25_FLASH_SHUTDOWN_CS_PORT, SL_MX25_FLASH_SHUTDOWN_CS_PIN); @@ -403,18 +401,21 @@ sl_status_t sl_wfx_host_spiflash_cs_deassert(void) GPIO_PinOutSet(SL_MX25_FLASH_SHUTDOWN_CS_PORT, SL_MX25_FLASH_SHUTDOWN_CS_PIN); return SL_STATUS_OK; } -#endif // CONFIG_USE_EXTERNAL_FLASH +#endif // SL_MUX25CTRL_MUX +#if SL_BTLCTRL_MUX sl_status_t sl_wfx_host_pre_bootloader_spi_transfer(void) { +#if SL_SPICTRL_MUX xSemaphoreTake(spi_sem_sync_hdl, portMAX_DELAY); +#endif // SL_SPICTRL_MUX /* * Assert CS pin for EXT SPI Flash */ SPIDRV_SetBaudrate(SL_SPIDRV_MX25_FLASH_BITRATE); -#if defined(CONFIG_USE_EXTERNAL_FLASH) +#if SL_MUX25CTRL_MUX sl_wfx_host_spiflash_cs_assert(); -#endif // CONFIG_USE_EXTERNAL_FLASH +#endif // SL_MUX25CTRL_MUX return SL_STATUS_OK; } @@ -423,17 +424,22 @@ sl_status_t sl_wfx_host_post_bootloader_spi_transfer(void) /* * De-Assert CS pin for EXT SPI Flash */ -#if defined(CONFIG_USE_EXTERNAL_FLASH) +#if SL_MUX25CTRL_MUX sl_wfx_host_spiflash_cs_deassert(); -#endif // CONFIG_USE_EXTERNAL_FLASH +#endif // SL_MUX25CTRL_MUX +#if SL_SPICTRL_MUX xSemaphoreGive(spi_sem_sync_hdl); +#endif // SL_SPICTRL_MUX return SL_STATUS_OK; } +#endif // SL_BTLCTRL_MUX -#if defined(DISPLAY_ENABLED) +#if SL_LCDCTRL_MUX sl_status_t sl_wfx_host_pre_lcd_spi_transfer(void) { +#if SL_SPICTRL_MUX xSemaphoreTake(spi_sem_sync_hdl, portMAX_DELAY); +#endif // SL_SPICTRL_MUX SPIDRV_SetBaudrate(SL_SPIDRV_LCD_BITRATE); /*LCD CS is handled as part of LCD gsdk*/ return SL_STATUS_OK; @@ -441,37 +447,50 @@ sl_status_t sl_wfx_host_pre_lcd_spi_transfer(void) sl_status_t sl_wfx_host_post_lcd_spi_transfer(void) { +#if SL_SPICTRL_MUX xSemaphoreGive(spi_sem_sync_hdl); +#endif // SL_SPICTRL_MUX return SL_STATUS_OK; } -#endif // DISPLAY_ENABLED +#endif // SL_LCDCTRL_MUX +#if SL_UARTCTRL_MUX sl_status_t sl_wfx_host_pre_uart_transfer(void) { +#if SL_SPICTRL_MUX if (spi_sem_sync_hdl == NULL) { - // UART is initialized before host SPI interface - // spi_sem_sync_hdl will not be initalized during execution +#endif // SL_SPICTRL_MUX + // UART is initialized before host SPI interface + // spi_sem_sync_hdl will not be initalized during execution GPIO_PinModeSet(gpioPortA, 8, gpioModePushPull, 1); +#if SL_SPICTRL_MUX return SL_STATUS_OK; } +#endif // SL_SPICTRL_MUX sl_wfx_disable_irq(); sl_wfx_host_disable_platform_interrupt(); +#if SL_SPICTRL_MUX xSemaphoreTake(spi_sem_sync_hdl, portMAX_DELAY); +#endif // SL_SPICTRL_MUX GPIO_PinModeSet(gpioPortA, 8, gpioModePushPull, 1); return SL_STATUS_OK; } sl_status_t sl_wfx_host_post_uart_transfer(void) { +#if SL_SPICTRL_MUX if (spi_sem_sync_hdl == NULL) { return SL_STATUS_OK; } +#endif // SL_SPICTRL_MUX GPIO_PinModeSet(gpioPortA, 8, gpioModeInputPull, 1); +#if SL_SPICTRL_MUX xSemaphoreGive(spi_sem_sync_hdl); +#endif // SL_SPICTRL_MUX sl_wfx_host_enable_platform_interrupt(); sl_wfx_enable_irq(); return SL_STATUS_OK; } -#endif /* EFR32MG24 */ +#endif // SL_UARTCTRL_MUX diff --git a/src/platform/silabs/efr32/OTAImageProcessorImpl.cpp b/src/platform/silabs/efr32/OTAImageProcessorImpl.cpp index 85118f9559ac1c..407f28b72207a5 100644 --- a/src/platform/silabs/efr32/OTAImageProcessorImpl.cpp +++ b/src/platform/silabs/efr32/OTAImageProcessorImpl.cpp @@ -23,12 +23,12 @@ extern "C" { #include "btl_interface.h" #include "em_bus.h" // For CORE_CRITICAL_SECTION -#if (defined(EFR32MG24) && defined(SL_WIFI)) +#if SL_BTLCTRL_MUX #include "spi_multiplex.h" -#ifdef WF200_WIFI // TODO: (MATTER-1905) clean up of MACROs -#include "sl_wfx_host_api.h" -#endif -#endif +// #ifdef WF200_WIFI // TODO: (MATTER-1905) clean up of MACROs +// #include "sl_wfx_host_api.h" +// #endif +#endif // SL_BTLCTRL_MUX } #include @@ -170,23 +170,23 @@ void OTAImageProcessorImpl::HandleFinalize(intptr_t context) writeBuffer[writeBufOffset] = 0; writeBufOffset++; } -#if (defined(EFR32MG24) && defined(SL_WIFI)) +#if SL_BTLCTRL_MUX err = sl_wfx_host_pre_bootloader_spi_transfer(); if (err != SL_STATUS_OK) { ChipLogError(SoftwareUpdate, "sl_wfx_host_pre_bootloader_spi_transfer() error: %ld", err); return; } -#endif +#endif // SL_BTLCTRL_MUX CORE_CRITICAL_SECTION(err = bootloader_eraseWriteStorage(mSlotId, mWriteOffset, writeBuffer, kAlignmentBytes);) -#if (defined(EFR32MG24) && defined(SL_WIFI)) +#if SL_BTLCTRL_MUX err = sl_wfx_host_post_bootloader_spi_transfer(); if (err != SL_STATUS_OK) { ChipLogError(SoftwareUpdate, "sl_wfx_host_post_bootloader_spi_transfer() error: %ld", err); return; } -#endif +#endif // SL_BTLCTRL_MUX if (err) { ChipLogError(SoftwareUpdate, "bootloader_eraseWriteStorage() error: %ld", err); @@ -208,28 +208,28 @@ void OTAImageProcessorImpl::HandleApply(intptr_t context) // Force KVS to store pending keys such as data from StoreCurrentUpdateInfo() chip::DeviceLayer::PersistedStorage::KeyValueStoreMgrImpl().ForceKeyMapSave(); -#if (defined(EFR32MG24) && defined(SL_WIFI)) +#if SL_BTLCTRL_MUX err = sl_wfx_host_pre_bootloader_spi_transfer(); if (err != SL_STATUS_OK) { ChipLogError(SoftwareUpdate, "sl_wfx_host_pre_bootloader_spi_transfer() error: %ld", err); return; } -#endif +#endif // SL_BTLCTRL_MUX CORE_CRITICAL_SECTION(err = bootloader_verifyImage(mSlotId, NULL);) if (err != SL_BOOTLOADER_OK) { ChipLogError(SoftwareUpdate, "bootloader_verifyImage() error: %ld", err); // Call the OTARequestor API to reset the state GetRequestorInstance()->CancelImageUpdate(); -#if (defined(EFR32MG24) && defined(SL_WIFI)) +#if SL_BTLCTRL_MUX err = sl_wfx_host_post_bootloader_spi_transfer(); if (err != SL_STATUS_OK) { ChipLogError(SoftwareUpdate, "sl_wfx_host_post_bootloader_spi_transfer() error: %ld", err); return; } -#endif +#endif // SL_BTLCTRL_MUX return; } @@ -239,25 +239,25 @@ void OTAImageProcessorImpl::HandleApply(intptr_t context) ChipLogError(SoftwareUpdate, "bootloader_setImageToBootload() error: %ld", err); // Call the OTARequestor API to reset the state GetRequestorInstance()->CancelImageUpdate(); -#if (defined(EFR32MG24) && defined(SL_WIFI)) +#if SL_BTLCTRL_MUX err = sl_wfx_host_post_bootloader_spi_transfer(); if (err != SL_STATUS_OK) { ChipLogError(SoftwareUpdate, "sl_wfx_host_post_bootloader_spi_transfer() error: %ld", err); return; } -#endif +#endif // SL_BTLCTRL_MUX return; } -#if (defined(EFR32MG24) && defined(SL_WIFI)) +#if SL_BTLCTRL_MUX err = sl_wfx_host_post_bootloader_spi_transfer(); if (err != SL_STATUS_OK) { ChipLogError(SoftwareUpdate, "sl_wfx_host_post_bootloader_spi_transfer() error: %ld", err); return; } -#endif +#endif // SL_BTLCTRL_MUX // This reboots the device CORE_CRITICAL_SECTION(bootloader_rebootAndInstall();) } @@ -310,23 +310,23 @@ void OTAImageProcessorImpl::HandleProcessBlock(intptr_t context) if (writeBufOffset == kAlignmentBytes) { writeBufOffset = 0; -#if (defined(EFR32MG24) && defined(SL_WIFI)) +#if SL_BTLCTRL_MUX err = sl_wfx_host_pre_bootloader_spi_transfer(); if (err != SL_STATUS_OK) { ChipLogError(SoftwareUpdate, "sl_wfx_host_pre_bootloader_spi_transfer() error: %ld", err); return; } -#endif +#endif // SL_BTLCTRL_MUX CORE_CRITICAL_SECTION(err = bootloader_eraseWriteStorage(mSlotId, mWriteOffset, writeBuffer, kAlignmentBytes);) -#if (defined(EFR32MG24) && defined(SL_WIFI)) +#if SL_BTLCTRL_MUX err = sl_wfx_host_post_bootloader_spi_transfer(); if (err != SL_STATUS_OK) { ChipLogError(SoftwareUpdate, "sl_wfx_host_post_bootloader_spi_transfer() error: %ld", err); return; } -#endif +#endif // SL_BTLCTRL_MUX if (err) { ChipLogError(SoftwareUpdate, "bootloader_eraseWriteStorage() error: %ld", err); From 41828932341fd62044563cec3ca34d42e792ae3a Mon Sep 17 00:00:00 2001 From: Rohan Sahay Date: Tue, 12 Sep 2023 12:48:42 +0530 Subject: [PATCH 04/29] temp commit with test file --- gn_build_silabs_wifi.sh | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 gn_build_silabs_wifi.sh diff --git a/gn_build_silabs_wifi.sh b/gn_build_silabs_wifi.sh new file mode 100755 index 00000000000000..73e24d40a95f7e --- /dev/null +++ b/gn_build_silabs_wifi.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash + +set -e + +## BRD4161A +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug BRD4161A --wifi SiWx917 disable_lcd=true use_external_flash=true | tee lighting-app.build.log +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug BRD4161A --wifi SiWx917 disable_lcd=true use_external_flash=false | tee lighting-app.build.log +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug BRD4161A --wifi SiWx917 disable_lcd=false use_external_flash=true | tee lighting-app.build.log +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug BRD4161A --wifi SiWx917 disable_lcd=false use_external_flash=false | tee lighting-app.build.log + +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug BRD4161A --wifi rs9116 disable_lcd=true use_external_flash=true | tee lighting-app.build.log +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug BRD4161A --wifi rs9116 disable_lcd=true use_external_flash=false | tee lighting-app.build.log +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug BRD4161A --wifi rs9116 disable_lcd=false use_external_flash=true | tee lighting-app.build.log +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug BRD4161A --wifi rs9116 disable_lcd=false use_external_flash=false | tee lighting-app.build.log + +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug BRD4161A --wifi wf200 disable_lcd=true use_external_flash=true chip_logging=false silabs_log_enabled=false is_debug=false | tee lighting-app.build.log +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug BRD4161A --wifi wf200 disable_lcd=true use_external_flash=false chip_logging=false silabs_log_enabled=false is_debug=false | tee lighting-app.build.log +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug BRD4161A --wifi wf200 disable_lcd=false use_external_flash=true chip_logging=false silabs_log_enabled=false is_debug=false | tee lighting-app.build.log +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug BRD4161A --wifi wf200 disable_lcd=false use_external_flash=false chip_logging=false silabs_log_enabled=false is_debug=false | tee lighting-app.build.log + +## BRD4187C +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug BRD4187C --wifi SiWx917 disable_lcd=true use_external_flash=true | tee lighting-app.build.log +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug BRD4187C --wifi SiWx917 disable_lcd=true use_external_flash=false | tee lighting-app.build.log +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug BRD4187C --wifi SiWx917 disable_lcd=false use_external_flash=true | tee lighting-app.build.log +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug BRD4187C --wifi SiWx917 disable_lcd=false use_external_flash=false | tee lighting-app.build.log + +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug BRD4187C --wifi rs9116 disable_lcd=true use_external_flash=true | tee lighting-app.build.log +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug BRD4187C --wifi rs9116 disable_lcd=true use_external_flash=false | tee lighting-app.build.log +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug BRD4187C --wifi rs9116 disable_lcd=false use_external_flash=true | tee lighting-app.build.log +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug BRD4187C --wifi rs9116 disable_lcd=false use_external_flash=false | tee lighting-app.build.log + +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug BRD4187C --wifi wf200 disable_lcd=true use_external_flash=true | tee lighting-app.build.log +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug BRD4187C --wifi wf200 disable_lcd=true use_external_flash=false | tee lighting-app.build.log +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug BRD4187C --wifi wf200 disable_lcd=false use_external_flash=true | tee lighting-app.build.log +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug BRD4187C --wifi wf200 disable_lcd=false use_external_flash=false | tee lighting-app.build.log From d8c9ccb230c1496b8e2d4157baf0b2fcdd39c22c Mon Sep 17 00:00:00 2001 From: Rohan Sahay Date: Wed, 13 Sep 2023 07:20:39 +0530 Subject: [PATCH 05/29] Adds fix for crash on rs91x --- examples/platform/silabs/efr32/rs911x/hal/efx_spi.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c b/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c index b81d7ef07a2922..c80f66e2b16883 100644 --- a/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c +++ b/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c @@ -396,7 +396,9 @@ static void spi_dmaTransfertComplete(SPIDRV_HandleData_t * pxHandle, Ecode_t tra **************************************************************************/ int16_t rsi_spi_transfer(uint8_t * tx_buf, uint8_t * rx_buf, uint16_t xlen, uint8_t mode) { +#if SL_SPICTRL_MUX sl_wfx_host_spi_cs_assert(); +#endif // SL_SPICTRL_MUX /* TODO: tx_buf and rx_buf needs to be replaced with a dummy buffer of length xlen to align with SDK of WiFi */ @@ -454,7 +456,9 @@ int16_t rsi_spi_transfer(uint8_t * tx_buf, uint8_t * rx_buf, uint16_t xlen, uint } xSemaphoreGive(spiTransferLock); +#if SL_SPICTRL_MUX sl_wfx_host_spi_cs_deassert(); +#endif // SL_SPICTRL_MUX return rsiError; } From 7df92b0eb96abe2a4685c8e522e30c552155d520 Mon Sep 17 00:00:00 2001 From: Rohan Sahay Date: Wed, 13 Sep 2023 13:20:43 +0530 Subject: [PATCH 06/29] Adds updated build commands --- gn_build_silabs_wifi.sh | 48 ++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/gn_build_silabs_wifi.sh b/gn_build_silabs_wifi.sh index 73e24d40a95f7e..c4e82fcfa5ed14 100755 --- a/gn_build_silabs_wifi.sh +++ b/gn_build_silabs_wifi.sh @@ -3,33 +3,33 @@ set -e ## BRD4161A -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug BRD4161A --wifi SiWx917 disable_lcd=true use_external_flash=true | tee lighting-app.build.log -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug BRD4161A --wifi SiWx917 disable_lcd=true use_external_flash=false | tee lighting-app.build.log -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug BRD4161A --wifi SiWx917 disable_lcd=false use_external_flash=true | tee lighting-app.build.log -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug BRD4161A --wifi SiWx917 disable_lcd=false use_external_flash=false | tee lighting-app.build.log +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_true_use_external_flash_true_SiWx917 BRD4161A --wifi SiWx917 disable_lcd=true use_external_flash=true | tee lighting-app.build.log +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_true_use_external_flash_false_SiWx917 BRD4161A --wifi SiWx917 disable_lcd=true use_external_flash=false | tee lighting-app.build.log +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_false_use_external_flash_true_SiWx917 BRD4161A --wifi SiWx917 disable_lcd=false use_external_flash=true | tee lighting-app.build.log +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_false_use_external_flash_false_SiWx917 BRD4161A --wifi SiWx917 disable_lcd=false use_external_flash=false | tee lighting-app.build.log -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug BRD4161A --wifi rs9116 disable_lcd=true use_external_flash=true | tee lighting-app.build.log -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug BRD4161A --wifi rs9116 disable_lcd=true use_external_flash=false | tee lighting-app.build.log -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug BRD4161A --wifi rs9116 disable_lcd=false use_external_flash=true | tee lighting-app.build.log -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug BRD4161A --wifi rs9116 disable_lcd=false use_external_flash=false | tee lighting-app.build.log +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_true_use_external_flash_true_rs9116 BRD4161A --wifi rs9116 disable_lcd=true use_external_flash=true | tee lighting-app.build.log +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_true_use_external_flash_false_rs9116 BRD4161A --wifi rs9116 disable_lcd=true use_external_flash=false | tee lighting-app.build.log +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_false_use_external_flash_true_rs9116 BRD4161A --wifi rs9116 disable_lcd=false use_external_flash=true | tee lighting-app.build.log +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_false_use_external_flash_false_rs9116 BRD4161A --wifi rs9116 disable_lcd=false use_external_flash=false | tee lighting-app.build.log -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug BRD4161A --wifi wf200 disable_lcd=true use_external_flash=true chip_logging=false silabs_log_enabled=false is_debug=false | tee lighting-app.build.log -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug BRD4161A --wifi wf200 disable_lcd=true use_external_flash=false chip_logging=false silabs_log_enabled=false is_debug=false | tee lighting-app.build.log -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug BRD4161A --wifi wf200 disable_lcd=false use_external_flash=true chip_logging=false silabs_log_enabled=false is_debug=false | tee lighting-app.build.log -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug BRD4161A --wifi wf200 disable_lcd=false use_external_flash=false chip_logging=false silabs_log_enabled=false is_debug=false | tee lighting-app.build.log +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_true_use_external_flash_true_wf200 BRD4161A --wifi wf200 disable_lcd=true use_external_flash=true chip_logging=false silabs_log_enabled=false is_debug=false | tee lighting-app.build.log +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_true_use_external_flash_false_wf200 BRD4161A --wifi wf200 disable_lcd=true use_external_flash=false chip_logging=false silabs_log_enabled=false is_debug=false | tee lighting-app.build.log +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_false_use_external_flash_true_wf200 BRD4161A --wifi wf200 disable_lcd=false use_external_flash=true chip_logging=false silabs_log_enabled=false is_debug=false | tee lighting-app.build.log +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_false_use_external_flash_false_wf200 BRD4161A --wifi wf200 disable_lcd=false use_external_flash=false chip_logging=false silabs_log_enabled=false is_debug=false | tee lighting-app.build.log ## BRD4187C -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug BRD4187C --wifi SiWx917 disable_lcd=true use_external_flash=true | tee lighting-app.build.log -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug BRD4187C --wifi SiWx917 disable_lcd=true use_external_flash=false | tee lighting-app.build.log -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug BRD4187C --wifi SiWx917 disable_lcd=false use_external_flash=true | tee lighting-app.build.log -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug BRD4187C --wifi SiWx917 disable_lcd=false use_external_flash=false | tee lighting-app.build.log +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_true_use_external_flash_true_SiWx917 BRD4187C --wifi SiWx917 disable_lcd=true use_external_flash=true | tee lighting-app.build.log +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_true_use_external_flash_false_SiWx917 BRD4187C --wifi SiWx917 disable_lcd=true use_external_flash=false | tee lighting-app.build.log +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_false_use_external_flash_true_SiWx917 BRD4187C --wifi SiWx917 disable_lcd=false use_external_flash=true | tee lighting-app.build.log +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_false_use_external_flash_false_SiWx917 BRD4187C --wifi SiWx917 disable_lcd=false use_external_flash=false | tee lighting-app.build.log -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug BRD4187C --wifi rs9116 disable_lcd=true use_external_flash=true | tee lighting-app.build.log -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug BRD4187C --wifi rs9116 disable_lcd=true use_external_flash=false | tee lighting-app.build.log -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug BRD4187C --wifi rs9116 disable_lcd=false use_external_flash=true | tee lighting-app.build.log -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug BRD4187C --wifi rs9116 disable_lcd=false use_external_flash=false | tee lighting-app.build.log +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_true_use_external_flash_true_rs9116 BRD4187C --wifi rs9116 disable_lcd=true use_external_flash=true | tee lighting-app.build.log +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_true_use_external_flash_false_rs9116 BRD4187C --wifi rs9116 disable_lcd=true use_external_flash=false | tee lighting-app.build.log +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_false_use_external_flash_true_rs9116 BRD4187C --wifi rs9116 disable_lcd=false use_external_flash=true | tee lighting-app.build.log +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_false_use_external_flash_false_rs9116 BRD4187C --wifi rs9116 disable_lcd=false use_external_flash=false | tee lighting-app.build.log -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug BRD4187C --wifi wf200 disable_lcd=true use_external_flash=true | tee lighting-app.build.log -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug BRD4187C --wifi wf200 disable_lcd=true use_external_flash=false | tee lighting-app.build.log -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug BRD4187C --wifi wf200 disable_lcd=false use_external_flash=true | tee lighting-app.build.log -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug BRD4187C --wifi wf200 disable_lcd=false use_external_flash=false | tee lighting-app.build.log +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_true_use_external_flash_true_wf200 BRD4187C --wifi wf200 disable_lcd=true use_external_flash=true | tee lighting-app.build.log +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_true_use_external_flash_false_wf200 BRD4187C --wifi wf200 disable_lcd=true use_external_flash=false | tee lighting-app.build.log +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_false_use_external_flash_true_wf200 BRD4187C --wifi wf200 disable_lcd=false use_external_flash=true | tee lighting-app.build.log +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_false_use_external_flash_false_wf200 BRD4187C --wifi wf200 disable_lcd=false use_external_flash=false | tee lighting-app.build.log From 2eedaf27bb55f5a185aaedff305834d889b36add Mon Sep 17 00:00:00 2001 From: Rohan Sahay Date: Wed, 13 Sep 2023 13:21:21 +0530 Subject: [PATCH 07/29] adds DEBUG logs --- .../platform/silabs/efr32/rs911x/hal/efx_spi.c | 16 ++++++++++++++++ examples/platform/silabs/efr32/wf200/efr_spi.c | 4 ++++ 2 files changed, 20 insertions(+) diff --git a/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c b/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c index c80f66e2b16883..89ad9d319b8f0a 100644 --- a/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c +++ b/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c @@ -218,6 +218,7 @@ void SPIDRV_SetBaudrate(uint32_t baudrate) sl_status_t sl_wfx_host_spi_cs_assert(void) { + SILABS_LOG("sl_wfx_host_spi_cs_assert started."); #if SL_SPICTRL_MUX xSemaphoreTake(spi_sem_sync_hdl, portMAX_DELAY); @@ -230,11 +231,13 @@ sl_status_t sl_wfx_host_spi_cs_assert(void) #if defined(EFR32MG24) GPIO_PinOutClear(SL_SPIDRV_EUSART_EXP_CS_PORT, SL_SPIDRV_EUSART_EXP_CS_PIN); #endif // EFR32MG24 + SILABS_LOG("sl_wfx_host_spi_cs_assert completed."); return SL_STATUS_OK; } sl_status_t sl_wfx_host_spi_cs_deassert(void) { + SILABS_LOG("sl_wfx_host_spi_cs_deassert started."); #if SL_SPICTRL_MUX if (spi_enabled) { @@ -253,19 +256,24 @@ sl_status_t sl_wfx_host_spi_cs_deassert(void) #if SL_SPICTRL_MUX xSemaphoreGive(spi_sem_sync_hdl); #endif // SL_SPICTRL_MUX + SILABS_LOG("sl_wfx_host_spi_cs_deassert completed."); return SL_STATUS_OK; } #if SL_MUX25CTRL_MUX sl_status_t sl_wfx_host_spiflash_cs_assert(void) { + SILABS_LOG("sl_wfx_host_spiflash_cs_assert started."); GPIO_PinOutClear(SL_MX25_FLASH_SHUTDOWN_CS_PORT, SL_MX25_FLASH_SHUTDOWN_CS_PIN); + SILABS_LOG("sl_wfx_host_spiflash_cs_assert completed."); return SL_STATUS_OK; } sl_status_t sl_wfx_host_spiflash_cs_deassert(void) { + SILABS_LOG("sl_wfx_host_spiflash_cs_deassert started."); GPIO_PinOutSet(SL_MX25_FLASH_SHUTDOWN_CS_PORT, SL_MX25_FLASH_SHUTDOWN_CS_PIN); + SILABS_LOG("sl_wfx_host_spiflash_cs_deassert completed."); return SL_STATUS_OK; } #endif // SL_MUX25CTRL_MUX @@ -273,6 +281,7 @@ sl_status_t sl_wfx_host_spiflash_cs_deassert(void) #if SL_BTLCTRL_MUX sl_status_t sl_wfx_host_pre_bootloader_spi_transfer(void) { + SILABS_LOG("sl_wfx_host_pre_bootloader_spi_transfer started."); #if SL_SPICTRL_MUX xSemaphoreTake(spi_sem_sync_hdl, portMAX_DELAY); if (spi_enabled) @@ -298,11 +307,13 @@ sl_status_t sl_wfx_host_pre_bootloader_spi_transfer(void) #if SL_MUX25CTRL_MUX sl_wfx_host_spiflash_cs_assert(); #endif // SL_MUX25CTRL_MUX + SILABS_LOG("sl_wfx_host_pre_bootloader_spi_transfer completed."); return SL_STATUS_OK; } sl_status_t sl_wfx_host_post_bootloader_spi_transfer(void) { + SILABS_LOG("sl_wfx_host_post_bootloader_spi_transfer started."); // bootloader_deinit will do USART disable int32_t status = bootloader_deinit(); if (status != BOOTLOADER_OK) @@ -320,6 +331,7 @@ sl_status_t sl_wfx_host_post_bootloader_spi_transfer(void) #if SL_SPICTRL_MUX xSemaphoreGive(spi_sem_sync_hdl); #endif // SL_SPICTRL_MUX + SILABS_LOG("sl_wfx_host_post_bootloader_spi_transfer completed."); return SL_STATUS_OK; } #endif // SL_BTLCTRL_MUX @@ -327,6 +339,7 @@ sl_status_t sl_wfx_host_post_bootloader_spi_transfer(void) #if SL_LCDCTRL_MUX sl_status_t sl_wfx_host_pre_lcd_spi_transfer(void) { + SILABS_LOG("sl_wfx_host_pre_lcd_spi_transfer started."); #if SL_SPICTRL_MUX xSemaphoreTake(spi_sem_sync_hdl, portMAX_DELAY); if (spi_enabled) @@ -347,17 +360,20 @@ sl_status_t sl_wfx_host_pre_lcd_spi_transfer(void) #endif // SL_SPICTRL_MUX return SL_STATUS_FAIL; } + SILABS_LOG("sl_wfx_host_pre_lcd_spi_transfer completed."); return SL_STATUS_OK; } sl_status_t sl_wfx_host_post_lcd_spi_transfer(void) { + SILABS_LOG("sl_wfx_host_post_lcd_spi_transfer started."); USART_Enable(SL_MEMLCD_SPI_PERIPHERAL, usartDisable); CMU_ClockEnable(SPI_CLOCK(SL_MEMLCD_SPI_PERIPHERAL_NO), false); GPIO->USARTROUTE[SL_MEMLCD_SPI_PERIPHERAL_NO].ROUTEEN = PINOUT_CLEAR; #if SL_SPICTRL_MUX xSemaphoreGive(spi_sem_sync_hdl); #endif // SL_SPICTRL_MUX + SILABS_LOG("sl_wfx_host_post_lcd_spi_transfer completed."); return SL_STATUS_OK; } #endif // SL_LCDCTRL_MUX diff --git a/examples/platform/silabs/efr32/wf200/efr_spi.c b/examples/platform/silabs/efr32/wf200/efr_spi.c index 1598fd895228a2..47e20d1c7c18ce 100644 --- a/examples/platform/silabs/efr32/wf200/efr_spi.c +++ b/examples/platform/silabs/efr32/wf200/efr_spi.c @@ -141,20 +141,24 @@ sl_status_t sl_wfx_host_deinit_bus(void) sl_status_t sl_wfx_host_spi_cs_assert() { + SILABS_LOG("sl_wfx_host_spi_cs_assert started."); #if SL_SPICTRL_MUX xSemaphoreTake(spi_sem_sync_hdl, portMAX_DELAY); SPIDRV_SetBaudrate(SL_SPIDRV_EXP_BITRATE_MULTIPLEXED); #endif /* SL_SPICTRL_MUX */ GPIO_PinOutClear(SL_SPIDRV_EXP_CS_PORT, SL_SPIDRV_EXP_CS_PIN); + SILABS_LOG("sl_wfx_host_spi_cs_assert completed."); return SL_STATUS_OK; } sl_status_t sl_wfx_host_spi_cs_deassert() { + SILABS_LOG("sl_wfx_host_spi_cs_deassert started."); GPIO_PinOutSet(SL_SPIDRV_EXP_CS_PORT, SL_SPIDRV_EXP_CS_PIN); #if SL_SPICTRL_MUX xSemaphoreGive(spi_sem_sync_hdl); #endif /* SL_SPICTRL_MUX */ + SILABS_LOG("sl_wfx_host_spi_cs_deassert completed."); return SL_STATUS_OK; } From 65efc777ea4fbef6e2453e802391d1155d54f971 Mon Sep 17 00:00:00 2001 From: Rohan Sahay Date: Fri, 15 Sep 2023 08:36:03 +0530 Subject: [PATCH 08/29] Adds bugfixes to MACROs --- examples/platform/silabs/display/demo-ui.c | 4 +--- examples/platform/silabs/efr32/spi_multiplex.h | 6 +++--- src/platform/silabs/efr32/OTAImageProcessorImpl.cpp | 5 ----- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/examples/platform/silabs/display/demo-ui.c b/examples/platform/silabs/display/demo-ui.c index dc18d20d4b19b2..f4f472222050ae 100644 --- a/examples/platform/silabs/display/demo-ui.c +++ b/examples/platform/silabs/display/demo-ui.c @@ -23,11 +23,9 @@ #include "dmd/dmd.h" #include "em_types.h" #include "glib.h" +#include "spi_multiplex.h" #include #include -#if SL_LCDCTRL_MUX -#include "spi_multiplex.h" -#endif // Main Logo and App image #define SILICONLABS_X_POSITION ((glibContext.pDisplayGeometry->xSize - SILICONLABS_BITMAP_WIDTH) / 2) diff --git a/examples/platform/silabs/efr32/spi_multiplex.h b/examples/platform/silabs/efr32/spi_multiplex.h index 283370eb0d99a3..e8a412bfa6ed9d 100644 --- a/examples/platform/silabs/efr32/spi_multiplex.h +++ b/examples/platform/silabs/efr32/spi_multiplex.h @@ -25,7 +25,7 @@ #pragma once #ifndef SL_LCDCTRL_MUX -#define SL_LCDCTRL_MUX (EFR32MG24 && DISPLAY_ENABLED) +#define SL_LCDCTRL_MUX (EFR32MG24 && SL_WIFI && DISPLAY_ENABLED) #endif // SL_LCDCTRL_MUX #ifndef SL_UARTCTRL_MUX @@ -33,11 +33,11 @@ #endif // SL_UARTCTRL_MUX #ifndef SL_MX25CTRL_MUX -#define SL_MUX25CTRL_MUX (EFR32MG24 && CONFIG_USE_EXTERNAL_FLASH) +#define SL_MUX25CTRL_MUX (EFR32MG24 && SL_WIFI && CONFIG_USE_EXTERNAL_FLASH) #endif // SL_MX25CTRL_MUX #ifndef SL_BTLCTRL_MUX -#define SL_BTLCTRL_MUX SL_MUX25CTRL_MUX +#define SL_BTLCTRL_MUX (EFR32MG24 && SL_WIFI && CONFIG_USE_EXTERNAL_FLASH) #endif // SL_BTLCTRL_MUX #ifndef SL_SPICTRL_MUX diff --git a/src/platform/silabs/efr32/OTAImageProcessorImpl.cpp b/src/platform/silabs/efr32/OTAImageProcessorImpl.cpp index 407f28b72207a5..f452dad88946fd 100644 --- a/src/platform/silabs/efr32/OTAImageProcessorImpl.cpp +++ b/src/platform/silabs/efr32/OTAImageProcessorImpl.cpp @@ -23,12 +23,7 @@ extern "C" { #include "btl_interface.h" #include "em_bus.h" // For CORE_CRITICAL_SECTION -#if SL_BTLCTRL_MUX #include "spi_multiplex.h" -// #ifdef WF200_WIFI // TODO: (MATTER-1905) clean up of MACROs -// #include "sl_wfx_host_api.h" -// #endif -#endif // SL_BTLCTRL_MUX } #include From 0a5168046af92f7053a21e3c781381eb5b8a6d5d Mon Sep 17 00:00:00 2001 From: Rohan Sahay Date: Fri, 15 Sep 2023 13:33:01 +0530 Subject: [PATCH 09/29] Adds additional logs --- .../silabs/efr32/rs911x/hal/efx_spi.c | 36 +++++++++---------- .../platform/silabs/efr32/wf200/efr_spi.c | 20 +++++++++++ 2 files changed, 38 insertions(+), 18 deletions(-) diff --git a/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c b/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c index 89ad9d319b8f0a..fd891f107a80d6 100644 --- a/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c +++ b/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c @@ -207,58 +207,55 @@ void sl_si91x_host_enable_high_speed_bus() #if SL_SPICTRL_MUX void SPIDRV_SetBaudrate(uint32_t baudrate) { + SILABS_LOG("%s started.", __func__); if (EUSART_BaudrateGet(MY_USART) == baudrate) { // EUSART synced to baudrate already return; } EUSART_BaudrateSet(MY_USART, 0, baudrate); + SILABS_LOG("%s completed.", __func__); } -#endif // SL_SPICTRL_MUX sl_status_t sl_wfx_host_spi_cs_assert(void) { - SILABS_LOG("sl_wfx_host_spi_cs_assert started."); -#if SL_SPICTRL_MUX + // SILABS_LOG("sl_wfx_host_spi_cs_assert started."); xSemaphoreTake(spi_sem_sync_hdl, portMAX_DELAY); if (!spi_enabled) // Reduce sl_spidrv_init_instances { sl_spidrv_init_instances(); - spi_enabled = true; - } -#endif // SL_SPICTRL_MUX #if defined(EFR32MG24) - GPIO_PinOutClear(SL_SPIDRV_EUSART_EXP_CS_PORT, SL_SPIDRV_EUSART_EXP_CS_PIN); + GPIO_PinOutClear(SL_SPIDRV_EUSART_EXP_CS_PORT, SL_SPIDRV_EUSART_EXP_CS_PIN); #endif // EFR32MG24 - SILABS_LOG("sl_wfx_host_spi_cs_assert completed."); + spi_enabled = true; + } + // SILABS_LOG("sl_wfx_host_spi_cs_assert completed."); return SL_STATUS_OK; } sl_status_t sl_wfx_host_spi_cs_deassert(void) { - SILABS_LOG("sl_wfx_host_spi_cs_deassert started."); -#if SL_SPICTRL_MUX + // SILABS_LOG("sl_wfx_host_spi_cs_deassert started."); if (spi_enabled) { if (ECODE_EMDRV_SPIDRV_OK != SPIDRV_DeInit(SL_SPIDRV_HANDLE)) { xSemaphoreGive(spi_sem_sync_hdl); + SILABS_LOG("%s error.", __func__); return SL_STATUS_FAIL; } - spi_enabled = false; - } -#endif // SL_SPICTRL_MUX #if defined(EFR32MG24) - GPIO_PinOutSet(SL_SPIDRV_EUSART_EXP_CS_PORT, SL_SPIDRV_EUSART_EXP_CS_PIN); - GPIO->EUSARTROUTE[SL_SPIDRV_EUSART_EXP_PERIPHERAL_NO].ROUTEEN = PINOUT_CLEAR; + GPIO_PinOutSet(SL_SPIDRV_EUSART_EXP_CS_PORT, SL_SPIDRV_EUSART_EXP_CS_PIN); + GPIO->EUSARTROUTE[SL_SPIDRV_EUSART_EXP_PERIPHERAL_NO].ROUTEEN = PINOUT_CLEAR; #endif // EFR32MG24 -#if SL_SPICTRL_MUX + spi_enabled = false; + } xSemaphoreGive(spi_sem_sync_hdl); -#endif // SL_SPICTRL_MUX - SILABS_LOG("sl_wfx_host_spi_cs_deassert completed."); + // SILABS_LOG("sl_wfx_host_spi_cs_deassert completed."); return SL_STATUS_OK; } +#endif // SL_SPICTRL_MUX #if SL_MUX25CTRL_MUX sl_status_t sl_wfx_host_spiflash_cs_assert(void) @@ -289,6 +286,7 @@ sl_status_t sl_wfx_host_pre_bootloader_spi_transfer(void) if (ECODE_EMDRV_SPIDRV_OK != SPIDRV_DeInit(SL_SPIDRV_HANDLE)) { xSemaphoreGive(spi_sem_sync_hdl); + SILABS_LOG("%s error.", __func__); return SL_STATUS_FAIL; } spi_enabled = false; @@ -347,6 +345,7 @@ sl_status_t sl_wfx_host_pre_lcd_spi_transfer(void) if (ECODE_EMDRV_SPIDRV_OK != SPIDRV_DeInit(SL_SPIDRV_HANDLE)) { xSemaphoreGive(spi_sem_sync_hdl); + SILABS_LOG("%s error.", __func__); return SL_STATUS_FAIL; } spi_enabled = false; @@ -358,6 +357,7 @@ sl_status_t sl_wfx_host_pre_lcd_spi_transfer(void) #if SL_SPICTRL_MUX xSemaphoreGive(spi_sem_sync_hdl); #endif // SL_SPICTRL_MUX + SILABS_LOG("%s error.", __func__); return SL_STATUS_FAIL; } SILABS_LOG("sl_wfx_host_pre_lcd_spi_transfer completed."); diff --git a/examples/platform/silabs/efr32/wf200/efr_spi.c b/examples/platform/silabs/efr32/wf200/efr_spi.c index 47e20d1c7c18ce..33f0d4ddb50e00 100644 --- a/examples/platform/silabs/efr32/wf200/efr_spi.c +++ b/examples/platform/silabs/efr32/wf200/efr_spi.c @@ -376,6 +376,7 @@ void sl_wfx_host_gpio_init(void) #if SL_SPICTRL_MUX void SPIDRV_SetBaudrate(uint32_t baudrate) { + SILABS_LOG("%s started.", __func__); if (USART_BaudrateGet(MY_USART) == baudrate) { // USART synced to baudrate already @@ -391,18 +392,23 @@ void SPIDRV_SetBaudrate(uint32_t baudrate) usartInit.autoCsEnable = true; USART_InitSync(MY_USART, &usartInit); + SILABS_LOG("%s completed.", __func__); } #endif // SL_SPICTRL_MUX #if SL_MUX25CTRL_MUX sl_status_t sl_wfx_host_spiflash_cs_assert(void) { + SILABS_LOG("%s started.", __func__); GPIO_PinOutClear(SL_MX25_FLASH_SHUTDOWN_CS_PORT, SL_MX25_FLASH_SHUTDOWN_CS_PIN); + SILABS_LOG("%s completed.", __func__); return SL_STATUS_OK; } sl_status_t sl_wfx_host_spiflash_cs_deassert(void) { + SILABS_LOG("%s started.", __func__); GPIO_PinOutSet(SL_MX25_FLASH_SHUTDOWN_CS_PORT, SL_MX25_FLASH_SHUTDOWN_CS_PIN); + SILABS_LOG("%s completed.", __func__); return SL_STATUS_OK; } #endif // SL_MUX25CTRL_MUX @@ -410,6 +416,7 @@ sl_status_t sl_wfx_host_spiflash_cs_deassert(void) #if SL_BTLCTRL_MUX sl_status_t sl_wfx_host_pre_bootloader_spi_transfer(void) { + SILABS_LOG("%s started.", __func__); #if SL_SPICTRL_MUX xSemaphoreTake(spi_sem_sync_hdl, portMAX_DELAY); #endif // SL_SPICTRL_MUX @@ -420,11 +427,13 @@ sl_status_t sl_wfx_host_pre_bootloader_spi_transfer(void) #if SL_MUX25CTRL_MUX sl_wfx_host_spiflash_cs_assert(); #endif // SL_MUX25CTRL_MUX + SILABS_LOG("%s completed.", __func__); return SL_STATUS_OK; } sl_status_t sl_wfx_host_post_bootloader_spi_transfer(void) { + SILABS_LOG("%s started.", __func__); /* * De-Assert CS pin for EXT SPI Flash */ @@ -434,6 +443,7 @@ sl_status_t sl_wfx_host_post_bootloader_spi_transfer(void) #if SL_SPICTRL_MUX xSemaphoreGive(spi_sem_sync_hdl); #endif // SL_SPICTRL_MUX + SILABS_LOG("%s completed.", __func__); return SL_STATUS_OK; } #endif // SL_BTLCTRL_MUX @@ -441,19 +451,23 @@ sl_status_t sl_wfx_host_post_bootloader_spi_transfer(void) #if SL_LCDCTRL_MUX sl_status_t sl_wfx_host_pre_lcd_spi_transfer(void) { + SILABS_LOG("%s started.", __func__); #if SL_SPICTRL_MUX xSemaphoreTake(spi_sem_sync_hdl, portMAX_DELAY); #endif // SL_SPICTRL_MUX SPIDRV_SetBaudrate(SL_SPIDRV_LCD_BITRATE); /*LCD CS is handled as part of LCD gsdk*/ + SILABS_LOG("%s completed.", __func__); return SL_STATUS_OK; } sl_status_t sl_wfx_host_post_lcd_spi_transfer(void) { + SILABS_LOG("%s started.", __func__); #if SL_SPICTRL_MUX xSemaphoreGive(spi_sem_sync_hdl); #endif // SL_SPICTRL_MUX + SILABS_LOG("%s completed.", __func__); return SL_STATUS_OK; } #endif // SL_LCDCTRL_MUX @@ -461,6 +475,7 @@ sl_status_t sl_wfx_host_post_lcd_spi_transfer(void) #if SL_UARTCTRL_MUX sl_status_t sl_wfx_host_pre_uart_transfer(void) { + SILABS_LOG("%s started.", __func__); #if SL_SPICTRL_MUX if (spi_sem_sync_hdl == NULL) { @@ -469,6 +484,7 @@ sl_status_t sl_wfx_host_pre_uart_transfer(void) // spi_sem_sync_hdl will not be initalized during execution GPIO_PinModeSet(gpioPortA, 8, gpioModePushPull, 1); #if SL_SPICTRL_MUX + SILABS_LOG("%s completed.", __func__); return SL_STATUS_OK; } #endif // SL_SPICTRL_MUX @@ -478,14 +494,17 @@ sl_status_t sl_wfx_host_pre_uart_transfer(void) xSemaphoreTake(spi_sem_sync_hdl, portMAX_DELAY); #endif // SL_SPICTRL_MUX GPIO_PinModeSet(gpioPortA, 8, gpioModePushPull, 1); + SILABS_LOG("%s completed.", __func__); return SL_STATUS_OK; } sl_status_t sl_wfx_host_post_uart_transfer(void) { + SILABS_LOG("%s started.", __func__); #if SL_SPICTRL_MUX if (spi_sem_sync_hdl == NULL) { + SILABS_LOG("%s completed.", __func__); return SL_STATUS_OK; } #endif // SL_SPICTRL_MUX @@ -495,6 +514,7 @@ sl_status_t sl_wfx_host_post_uart_transfer(void) #endif // SL_SPICTRL_MUX sl_wfx_host_enable_platform_interrupt(); sl_wfx_enable_irq(); + SILABS_LOG("%s completed.", __func__); return SL_STATUS_OK; } #endif // SL_UARTCTRL_MUX From c6c2034c794a5b327ca53346b5deb718de541243 Mon Sep 17 00:00:00 2001 From: Rohan Sahay Date: Mon, 18 Sep 2023 14:10:41 +0530 Subject: [PATCH 10/29] Adds fix to UART multiplexing --- examples/platform/silabs/efr32/uart.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/examples/platform/silabs/efr32/uart.cpp b/examples/platform/silabs/efr32/uart.cpp index 1576e67f4fc907..20b629cfd515aa 100644 --- a/examples/platform/silabs/efr32/uart.cpp +++ b/examples/platform/silabs/efr32/uart.cpp @@ -34,9 +34,7 @@ extern "C" { #include "sl_uartdrv_instances.h" #ifdef SL_CATALOG_UARTDRV_EUSART_PRESENT #include "sl_uartdrv_eusart_vcom_config.h" -#if (defined(EFR32MG24) && defined(WF200_WIFI)) #include "spi_multiplex.h" -#endif /* EFR32MG24 && WF200_WIFI */ #endif #ifdef SL_CATALOG_UARTDRV_USART_PRESENT #include "sl_uartdrv_usart_vcom_config.h" @@ -474,18 +472,21 @@ void uartSendBytes(uint8_t * buffer, uint16_t nbOfBytes) #if defined(SL_CATALOG_POWER_MANAGER_PRESENT) sl_power_manager_add_em_requirement(SL_POWER_MANAGER_EM1); #endif - +#if SL_UARTCTRL_MUX + sl_wfx_host_pre_uart_transfer(); +#endif // SL_UARTCTRL_MUX #if (defined(EFR32MG24) && defined(WF200_WIFI)) // Blocking transmit for the MG24 + WF200 since UART TX is multiplexed with // WF200 SPI IRQ - sl_wfx_host_pre_uart_transfer(); UARTDRV_ForceTransmit(vcom_handle, (uint8_t *) buffer, nbOfBytes); - sl_wfx_host_post_uart_transfer(); #else // Non Blocking Transmit UARTDRV_Transmit(vcom_handle, (uint8_t *) buffer, nbOfBytes, UART_tx_callback); ulTaskNotifyTake(pdTRUE, portMAX_DELAY); #endif /* EFR32MG24 && WF200_WIFI */ +#if SL_UARTCTRL_MUX + sl_wfx_host_post_uart_transfer(); +#endif // SL_UARTCTRL_MUX #if defined(SL_CATALOG_POWER_MANAGER_PRESENT) sl_power_manager_remove_em_requirement(SL_POWER_MANAGER_EM1); From b201d905810a9011a79383d4ec19191b192fd9bd Mon Sep 17 00:00:00 2001 From: Rohan Sahay Date: Mon, 18 Sep 2023 14:10:55 +0530 Subject: [PATCH 11/29] Remove comments --- examples/platform/silabs/efr32/spi_multiplex.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/examples/platform/silabs/efr32/spi_multiplex.h b/examples/platform/silabs/efr32/spi_multiplex.h index e8a412bfa6ed9d..7c9ab741805e9c 100644 --- a/examples/platform/silabs/efr32/spi_multiplex.h +++ b/examples/platform/silabs/efr32/spi_multiplex.h @@ -44,9 +44,6 @@ #define SL_SPICTRL_MUX (EFR32MG24 && SL_WIFI && (SL_LCDCTRL_MUX || SL_UARTCTRL_MUX || SL_MX25CTRL_MUX || SL_BTLCTRL_MUX)) #endif // SL_SPICTRL_MUX -// CONFIG_USE_EXTERNAL_FLASH -// DISPLAY_ENABLED - #if SL_SPICTRL_MUX #ifdef __cplusplus extern "C" { From f38f1f3bff26793e7ba65531f6c2490188ab4a51 Mon Sep 17 00:00:00 2001 From: Rohan Sahay Date: Mon, 18 Sep 2023 14:13:24 +0530 Subject: [PATCH 12/29] Adds ported changes --- examples/platform/silabs/efr32/uart.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/platform/silabs/efr32/uart.cpp b/examples/platform/silabs/efr32/uart.cpp index 20b629cfd515aa..d712f83cce06c6 100644 --- a/examples/platform/silabs/efr32/uart.cpp +++ b/examples/platform/silabs/efr32/uart.cpp @@ -32,9 +32,9 @@ extern "C" { #include "sl_board_control.h" #endif #include "sl_uartdrv_instances.h" +#include "spi_multiplex.h" #ifdef SL_CATALOG_UARTDRV_EUSART_PRESENT #include "sl_uartdrv_eusart_vcom_config.h" -#include "spi_multiplex.h" #endif #ifdef SL_CATALOG_UARTDRV_USART_PRESENT #include "sl_uartdrv_usart_vcom_config.h" From f6e8c6241bc0cab3aa0236c993c5b3b915cb21d5 Mon Sep 17 00:00:00 2001 From: Rohan Sahay Date: Tue, 19 Sep 2023 10:54:04 +0530 Subject: [PATCH 13/29] Adds use of SL_CATALOG_UARTDRV_USART_PRESENT, SL_CATALOG_UARTDRV_EUSART_PRESENT --- examples/platform/silabs/efr32/rs911x/hal/efx_spi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c b/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c index fd891f107a80d6..ded122eee1a3c1 100644 --- a/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c +++ b/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c @@ -92,9 +92,9 @@ static TaskHandle_t spiInitiatorTaskHandle = NULL; static uint32_t dummy_buffer; /* Used for DMA - when results don't matter */ #include "sl_spidrv_instances.h" -#if defined(EFR32MG12) +#if defined(SL_CATALOG_UARTDRV_USART_PRESENT) #define SL_SPIDRV_HANDLE sl_spidrv_exp_handle -#elif defined(EFR32MG24) +#elif defined(SL_CATALOG_UARTDRV_EUSART_PRESENT) #define SL_SPIDRV_HANDLE sl_spidrv_eusart_exp_handle #else #error "Unknown platform" From c85ba9d28e651520e514dd8d28d38c538f277a19 Mon Sep 17 00:00:00 2001 From: Rohan Sahay Date: Tue, 19 Sep 2023 10:54:55 +0530 Subject: [PATCH 14/29] Removes code since WF200 requires SL_CATALOG_UARTDRV_USART_PRESENT only --- examples/platform/silabs/efr32/wf200/efr_spi.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/examples/platform/silabs/efr32/wf200/efr_spi.c b/examples/platform/silabs/efr32/wf200/efr_spi.c index 33f0d4ddb50e00..2883ab5f38aab6 100644 --- a/examples/platform/silabs/efr32/wf200/efr_spi.c +++ b/examples/platform/silabs/efr32/wf200/efr_spi.c @@ -52,11 +52,7 @@ #include "sl_spidrv_exp_config.h" #include "sl_spidrv_instances.h" #include "spi_multiplex.h" -#if (defined(EFR32MG12) || defined(EFR32MG24)) #define SL_SPIDRV_HANDLE sl_spidrv_exp_handle -#else -#error "Unknown platform" -#endif #define USART SL_WFX_HOST_PINOUT_SPI_PERIPHERAL From 90c21f7db9a3d51fe3caa6a470a1f1085b323d8a Mon Sep 17 00:00:00 2001 From: Rohan Sahay Date: Wed, 4 Oct 2023 12:54:49 +0530 Subject: [PATCH 15/29] Restyler changes --- examples/platform/silabs/efr32/rs911x/hal/efx_spi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c b/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c index ded122eee1a3c1..80153647c21592 100644 --- a/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c +++ b/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c @@ -492,4 +492,4 @@ int16_t rsi_spi_transfer(uint8_t * tx_buf, uint8_t * rx_buf, uint16_t xlen, uint sl_status_t sl_si91x_host_spi_transfer(const void * tx_buf, void * rx_buf, uint16_t xlen) { return (rsi_spi_transfer((uint8_t *) tx_buf, rx_buf, xlen, DEFAULT_SPI_TRASFER_MODE)); -} +} \ No newline at end of file From 857253a14737c52aa8a96ae5be95e448baf0b062 Mon Sep 17 00:00:00 2001 From: Rohan Sahay Date: Wed, 4 Oct 2023 13:03:49 +0530 Subject: [PATCH 16/29] Adds additional changes to wrap multiplexing with MACROs --- examples/platform/silabs/display/demo-ui.c | 2 ++ examples/platform/silabs/display/lcd.cpp | 3 -- .../silabs/efr32/rs911x/hal/efx_spi.c | 29 ++++++++++--------- .../platform/silabs/efr32/spi_multiplex.h | 24 +++------------ examples/platform/silabs/efr32/uart.cpp | 2 ++ .../platform/silabs/efr32/wf200/efr_spi.c | 5 ++++ .../silabs/efr32/OTAImageProcessorImpl.cpp | 2 ++ 7 files changed, 30 insertions(+), 37 deletions(-) diff --git a/examples/platform/silabs/display/demo-ui.c b/examples/platform/silabs/display/demo-ui.c index f4f472222050ae..082f79eea0e10f 100644 --- a/examples/platform/silabs/display/demo-ui.c +++ b/examples/platform/silabs/display/demo-ui.c @@ -23,7 +23,9 @@ #include "dmd/dmd.h" #include "em_types.h" #include "glib.h" +#if SL_WIFI && !SIWX_917 #include "spi_multiplex.h" +#endif // SL_WIFI && !SIWX_917 #include #include diff --git a/examples/platform/silabs/display/lcd.cpp b/examples/platform/silabs/display/lcd.cpp index 63a91795487963..adcb4aea019e40 100644 --- a/examples/platform/silabs/display/lcd.cpp +++ b/examples/platform/silabs/display/lcd.cpp @@ -35,9 +35,6 @@ #include "sl_board_control.h" -#if (defined(EFR32MG24) && defined(SL_WIFI)) -#include "spi_multiplex.h" -#endif #define LCD_SIZE 128 #define QR_CODE_VERSION 4 #define QR_CODE_MODULE_SIZE 3 diff --git a/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c b/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c index 80153647c21592..5a20d04494482c 100644 --- a/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c +++ b/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c @@ -29,21 +29,31 @@ #include "em_device.h" #include "em_gpio.h" #include "em_ldma.h" +#include "sl_spidrv_instances.h" +#include "spi_multiplex.h" +#include "spidrv.h" +#if SL_LCDCTRL_MUX +#include "sl_memlcd.h" +#endif // SL_LCDCTRL_MUX #if defined(EFR32MG12) #include "em_usart.h" + +#define SL_SPIDRV_HANDLE sl_spidrv_exp_handle + #elif defined(EFR32MG24) #include "em_eusart.h" #include "sl_spidrv_eusart_exp_config.h" -#endif -#include "spidrv.h" -#include "silabs_utils.h" +#define SL_SPIDRV_HANDLE sl_spidrv_eusart_exp_handle +#define SL_SPIDRV_EXP_BITRATE_MULTIPLEXED SL_SPIDRV_EUSART_EXP_BITRATE +#define SL_SPIDRV_UART_CONSOLE_BITRATE SL_UARTDRV_EUSART_VCOM_BAUDRATE +#define SL_SPIDRV_FRAME_LENGTH SL_SPIDRV_EUSART_EXP_FRAME_LENGTH + +#endif // EFR32MG12 || EFR32MG24 #include "gpiointerrupt.h" #include "sl_device_init_clocks.h" -#include "sl_memlcd.h" #include "sl_status.h" -#include "spi_multiplex.h" #include "FreeRTOS.h" #include "event_groups.h" @@ -91,15 +101,6 @@ static TaskHandle_t spiInitiatorTaskHandle = NULL; static uint32_t dummy_buffer; /* Used for DMA - when results don't matter */ -#include "sl_spidrv_instances.h" -#if defined(SL_CATALOG_UARTDRV_USART_PRESENT) -#define SL_SPIDRV_HANDLE sl_spidrv_exp_handle -#elif defined(SL_CATALOG_UARTDRV_EUSART_PRESENT) -#define SL_SPIDRV_HANDLE sl_spidrv_eusart_exp_handle -#else -#error "Unknown platform" -#endif - // variable to identify spi configured for expansion header // EUSART configuration available on the SPIDRV static bool spi_enabled = false; diff --git a/examples/platform/silabs/efr32/spi_multiplex.h b/examples/platform/silabs/efr32/spi_multiplex.h index 7c9ab741805e9c..953becdacbff31 100644 --- a/examples/platform/silabs/efr32/spi_multiplex.h +++ b/examples/platform/silabs/efr32/spi_multiplex.h @@ -49,35 +49,19 @@ extern "C" { #endif #include "FreeRTOS.h" -#include "em_eusart.h" #include "semphr.h" +#if SL_LCDCTRL_MUX #include "sl_memlcd_display.h" +#endif // SL_LCDCTRL_MUX +#if SL_MX25CTRL_MUX #include "sl_mx25_flash_shutdown_usart_config.h" +#endif // SL_MX25CTRL_MUX #include "spidrv.h" #define SL_SPIDRV_LCD_BITRATE SL_MEMLCD_SCLK_FREQ #define SL_SPIDRV_MX25_FLASH_BITRATE 16000000 -#ifdef RS911X_WIFI -#include "sl_spidrv_eusart_exp_config.h" -#define SL_SPIDRV_EXP_BITRATE_MULTIPLEXED SL_SPIDRV_EUSART_EXP_BITRATE -#define SL_SPIDRV_UART_CONSOLE_BITRATE SL_UARTDRV_EUSART_VCOM_BAUDRATE -#define SL_SPIDRV_FRAME_LENGTH SL_SPIDRV_EUSART_EXP_FRAME_LENGTH - -#elif WF200_WIFI -// TODO: (MATTER-1906) Investigate why using SL_SPIDRV_EXP_BITRATE is causing WF200 init failure -// REF: sl_spidrv_exp_config.h -#include "sl_spidrv_exp_config.h" -#define SL_SPIDRV_EXP_BITRATE_MULTIPLEXED 10000000 -#define SL_SPIDRV_UART_CONSOLE_BITRATE SL_UARTDRV_USART_VCOM_BAUDRATE -#define SL_SPIDRV_FRAME_LENGTH SL_SPIDRV_EXP_FRAME_LENGTH - -#else -#error "Unknown platform" - -#endif /* RS911X_WIFI || WF200_WIFI */ - #if SL_SPICTRL_MUX /**************************************************************************** * @fn void SPIDRV_SetBaudrate() diff --git a/examples/platform/silabs/efr32/uart.cpp b/examples/platform/silabs/efr32/uart.cpp index d712f83cce06c6..3941114218a664 100644 --- a/examples/platform/silabs/efr32/uart.cpp +++ b/examples/platform/silabs/efr32/uart.cpp @@ -32,7 +32,9 @@ extern "C" { #include "sl_board_control.h" #endif #include "sl_uartdrv_instances.h" +#if SL_WIFI #include "spi_multiplex.h" +#endif // SL_WIFI #ifdef SL_CATALOG_UARTDRV_EUSART_PRESENT #include "sl_uartdrv_eusart_vcom_config.h" #endif diff --git a/examples/platform/silabs/efr32/wf200/efr_spi.c b/examples/platform/silabs/efr32/wf200/efr_spi.c index 2883ab5f38aab6..5367e16510db9d 100644 --- a/examples/platform/silabs/efr32/wf200/efr_spi.c +++ b/examples/platform/silabs/efr32/wf200/efr_spi.c @@ -52,6 +52,11 @@ #include "sl_spidrv_exp_config.h" #include "sl_spidrv_instances.h" #include "spi_multiplex.h" +// TODO: (MATTER-1906) Investigate why using SL_SPIDRV_EXP_BITRATE is causing WF200 init failure +// REF: sl_spidrv_exp_config.h +#define SL_SPIDRV_EXP_BITRATE_MULTIPLEXED 10000000 +#define SL_SPIDRV_UART_CONSOLE_BITRATE SL_UARTDRV_USART_VCOM_BAUDRATE +#define SL_SPIDRV_FRAME_LENGTH SL_SPIDRV_EXP_FRAME_LENGTH #define SL_SPIDRV_HANDLE sl_spidrv_exp_handle #define USART SL_WFX_HOST_PINOUT_SPI_PERIPHERAL diff --git a/src/platform/silabs/efr32/OTAImageProcessorImpl.cpp b/src/platform/silabs/efr32/OTAImageProcessorImpl.cpp index f452dad88946fd..a2544f879a8ff5 100644 --- a/src/platform/silabs/efr32/OTAImageProcessorImpl.cpp +++ b/src/platform/silabs/efr32/OTAImageProcessorImpl.cpp @@ -23,7 +23,9 @@ extern "C" { #include "btl_interface.h" #include "em_bus.h" // For CORE_CRITICAL_SECTION +#if SL_WIFI #include "spi_multiplex.h" +#endif // SL_WIFI } #include From 848efa345188ee958df05ca9ae9adde370cd246e Mon Sep 17 00:00:00 2001 From: Rohan Sahay Date: Wed, 4 Oct 2023 13:04:33 +0530 Subject: [PATCH 17/29] Remove log commit --- .../silabs/efr32/rs911x/hal/efx_spi.c | 14 ----------- .../platform/silabs/efr32/wf200/efr_spi.c | 24 ------------------- 2 files changed, 38 deletions(-) diff --git a/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c b/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c index 5a20d04494482c..5393068f4b4d27 100644 --- a/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c +++ b/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c @@ -208,14 +208,12 @@ void sl_si91x_host_enable_high_speed_bus() #if SL_SPICTRL_MUX void SPIDRV_SetBaudrate(uint32_t baudrate) { - SILABS_LOG("%s started.", __func__); if (EUSART_BaudrateGet(MY_USART) == baudrate) { // EUSART synced to baudrate already return; } EUSART_BaudrateSet(MY_USART, 0, baudrate); - SILABS_LOG("%s completed.", __func__); } sl_status_t sl_wfx_host_spi_cs_assert(void) @@ -261,17 +259,13 @@ sl_status_t sl_wfx_host_spi_cs_deassert(void) #if SL_MUX25CTRL_MUX sl_status_t sl_wfx_host_spiflash_cs_assert(void) { - SILABS_LOG("sl_wfx_host_spiflash_cs_assert started."); GPIO_PinOutClear(SL_MX25_FLASH_SHUTDOWN_CS_PORT, SL_MX25_FLASH_SHUTDOWN_CS_PIN); - SILABS_LOG("sl_wfx_host_spiflash_cs_assert completed."); return SL_STATUS_OK; } sl_status_t sl_wfx_host_spiflash_cs_deassert(void) { - SILABS_LOG("sl_wfx_host_spiflash_cs_deassert started."); GPIO_PinOutSet(SL_MX25_FLASH_SHUTDOWN_CS_PORT, SL_MX25_FLASH_SHUTDOWN_CS_PIN); - SILABS_LOG("sl_wfx_host_spiflash_cs_deassert completed."); return SL_STATUS_OK; } #endif // SL_MUX25CTRL_MUX @@ -279,7 +273,6 @@ sl_status_t sl_wfx_host_spiflash_cs_deassert(void) #if SL_BTLCTRL_MUX sl_status_t sl_wfx_host_pre_bootloader_spi_transfer(void) { - SILABS_LOG("sl_wfx_host_pre_bootloader_spi_transfer started."); #if SL_SPICTRL_MUX xSemaphoreTake(spi_sem_sync_hdl, portMAX_DELAY); if (spi_enabled) @@ -306,13 +299,11 @@ sl_status_t sl_wfx_host_pre_bootloader_spi_transfer(void) #if SL_MUX25CTRL_MUX sl_wfx_host_spiflash_cs_assert(); #endif // SL_MUX25CTRL_MUX - SILABS_LOG("sl_wfx_host_pre_bootloader_spi_transfer completed."); return SL_STATUS_OK; } sl_status_t sl_wfx_host_post_bootloader_spi_transfer(void) { - SILABS_LOG("sl_wfx_host_post_bootloader_spi_transfer started."); // bootloader_deinit will do USART disable int32_t status = bootloader_deinit(); if (status != BOOTLOADER_OK) @@ -330,7 +321,6 @@ sl_status_t sl_wfx_host_post_bootloader_spi_transfer(void) #if SL_SPICTRL_MUX xSemaphoreGive(spi_sem_sync_hdl); #endif // SL_SPICTRL_MUX - SILABS_LOG("sl_wfx_host_post_bootloader_spi_transfer completed."); return SL_STATUS_OK; } #endif // SL_BTLCTRL_MUX @@ -338,7 +328,6 @@ sl_status_t sl_wfx_host_post_bootloader_spi_transfer(void) #if SL_LCDCTRL_MUX sl_status_t sl_wfx_host_pre_lcd_spi_transfer(void) { - SILABS_LOG("sl_wfx_host_pre_lcd_spi_transfer started."); #if SL_SPICTRL_MUX xSemaphoreTake(spi_sem_sync_hdl, portMAX_DELAY); if (spi_enabled) @@ -361,20 +350,17 @@ sl_status_t sl_wfx_host_pre_lcd_spi_transfer(void) SILABS_LOG("%s error.", __func__); return SL_STATUS_FAIL; } - SILABS_LOG("sl_wfx_host_pre_lcd_spi_transfer completed."); return SL_STATUS_OK; } sl_status_t sl_wfx_host_post_lcd_spi_transfer(void) { - SILABS_LOG("sl_wfx_host_post_lcd_spi_transfer started."); USART_Enable(SL_MEMLCD_SPI_PERIPHERAL, usartDisable); CMU_ClockEnable(SPI_CLOCK(SL_MEMLCD_SPI_PERIPHERAL_NO), false); GPIO->USARTROUTE[SL_MEMLCD_SPI_PERIPHERAL_NO].ROUTEEN = PINOUT_CLEAR; #if SL_SPICTRL_MUX xSemaphoreGive(spi_sem_sync_hdl); #endif // SL_SPICTRL_MUX - SILABS_LOG("sl_wfx_host_post_lcd_spi_transfer completed."); return SL_STATUS_OK; } #endif // SL_LCDCTRL_MUX diff --git a/examples/platform/silabs/efr32/wf200/efr_spi.c b/examples/platform/silabs/efr32/wf200/efr_spi.c index 5367e16510db9d..d0e97fed235255 100644 --- a/examples/platform/silabs/efr32/wf200/efr_spi.c +++ b/examples/platform/silabs/efr32/wf200/efr_spi.c @@ -142,24 +142,20 @@ sl_status_t sl_wfx_host_deinit_bus(void) sl_status_t sl_wfx_host_spi_cs_assert() { - SILABS_LOG("sl_wfx_host_spi_cs_assert started."); #if SL_SPICTRL_MUX xSemaphoreTake(spi_sem_sync_hdl, portMAX_DELAY); SPIDRV_SetBaudrate(SL_SPIDRV_EXP_BITRATE_MULTIPLEXED); #endif /* SL_SPICTRL_MUX */ GPIO_PinOutClear(SL_SPIDRV_EXP_CS_PORT, SL_SPIDRV_EXP_CS_PIN); - SILABS_LOG("sl_wfx_host_spi_cs_assert completed."); return SL_STATUS_OK; } sl_status_t sl_wfx_host_spi_cs_deassert() { - SILABS_LOG("sl_wfx_host_spi_cs_deassert started."); GPIO_PinOutSet(SL_SPIDRV_EXP_CS_PORT, SL_SPIDRV_EXP_CS_PIN); #if SL_SPICTRL_MUX xSemaphoreGive(spi_sem_sync_hdl); #endif /* SL_SPICTRL_MUX */ - SILABS_LOG("sl_wfx_host_spi_cs_deassert completed."); return SL_STATUS_OK; } @@ -377,7 +373,6 @@ void sl_wfx_host_gpio_init(void) #if SL_SPICTRL_MUX void SPIDRV_SetBaudrate(uint32_t baudrate) { - SILABS_LOG("%s started.", __func__); if (USART_BaudrateGet(MY_USART) == baudrate) { // USART synced to baudrate already @@ -393,23 +388,18 @@ void SPIDRV_SetBaudrate(uint32_t baudrate) usartInit.autoCsEnable = true; USART_InitSync(MY_USART, &usartInit); - SILABS_LOG("%s completed.", __func__); } #endif // SL_SPICTRL_MUX #if SL_MUX25CTRL_MUX sl_status_t sl_wfx_host_spiflash_cs_assert(void) { - SILABS_LOG("%s started.", __func__); GPIO_PinOutClear(SL_MX25_FLASH_SHUTDOWN_CS_PORT, SL_MX25_FLASH_SHUTDOWN_CS_PIN); - SILABS_LOG("%s completed.", __func__); return SL_STATUS_OK; } sl_status_t sl_wfx_host_spiflash_cs_deassert(void) { - SILABS_LOG("%s started.", __func__); GPIO_PinOutSet(SL_MX25_FLASH_SHUTDOWN_CS_PORT, SL_MX25_FLASH_SHUTDOWN_CS_PIN); - SILABS_LOG("%s completed.", __func__); return SL_STATUS_OK; } #endif // SL_MUX25CTRL_MUX @@ -417,7 +407,6 @@ sl_status_t sl_wfx_host_spiflash_cs_deassert(void) #if SL_BTLCTRL_MUX sl_status_t sl_wfx_host_pre_bootloader_spi_transfer(void) { - SILABS_LOG("%s started.", __func__); #if SL_SPICTRL_MUX xSemaphoreTake(spi_sem_sync_hdl, portMAX_DELAY); #endif // SL_SPICTRL_MUX @@ -428,13 +417,11 @@ sl_status_t sl_wfx_host_pre_bootloader_spi_transfer(void) #if SL_MUX25CTRL_MUX sl_wfx_host_spiflash_cs_assert(); #endif // SL_MUX25CTRL_MUX - SILABS_LOG("%s completed.", __func__); return SL_STATUS_OK; } sl_status_t sl_wfx_host_post_bootloader_spi_transfer(void) { - SILABS_LOG("%s started.", __func__); /* * De-Assert CS pin for EXT SPI Flash */ @@ -444,7 +431,6 @@ sl_status_t sl_wfx_host_post_bootloader_spi_transfer(void) #if SL_SPICTRL_MUX xSemaphoreGive(spi_sem_sync_hdl); #endif // SL_SPICTRL_MUX - SILABS_LOG("%s completed.", __func__); return SL_STATUS_OK; } #endif // SL_BTLCTRL_MUX @@ -452,23 +438,19 @@ sl_status_t sl_wfx_host_post_bootloader_spi_transfer(void) #if SL_LCDCTRL_MUX sl_status_t sl_wfx_host_pre_lcd_spi_transfer(void) { - SILABS_LOG("%s started.", __func__); #if SL_SPICTRL_MUX xSemaphoreTake(spi_sem_sync_hdl, portMAX_DELAY); #endif // SL_SPICTRL_MUX SPIDRV_SetBaudrate(SL_SPIDRV_LCD_BITRATE); /*LCD CS is handled as part of LCD gsdk*/ - SILABS_LOG("%s completed.", __func__); return SL_STATUS_OK; } sl_status_t sl_wfx_host_post_lcd_spi_transfer(void) { - SILABS_LOG("%s started.", __func__); #if SL_SPICTRL_MUX xSemaphoreGive(spi_sem_sync_hdl); #endif // SL_SPICTRL_MUX - SILABS_LOG("%s completed.", __func__); return SL_STATUS_OK; } #endif // SL_LCDCTRL_MUX @@ -476,7 +458,6 @@ sl_status_t sl_wfx_host_post_lcd_spi_transfer(void) #if SL_UARTCTRL_MUX sl_status_t sl_wfx_host_pre_uart_transfer(void) { - SILABS_LOG("%s started.", __func__); #if SL_SPICTRL_MUX if (spi_sem_sync_hdl == NULL) { @@ -485,7 +466,6 @@ sl_status_t sl_wfx_host_pre_uart_transfer(void) // spi_sem_sync_hdl will not be initalized during execution GPIO_PinModeSet(gpioPortA, 8, gpioModePushPull, 1); #if SL_SPICTRL_MUX - SILABS_LOG("%s completed.", __func__); return SL_STATUS_OK; } #endif // SL_SPICTRL_MUX @@ -495,17 +475,14 @@ sl_status_t sl_wfx_host_pre_uart_transfer(void) xSemaphoreTake(spi_sem_sync_hdl, portMAX_DELAY); #endif // SL_SPICTRL_MUX GPIO_PinModeSet(gpioPortA, 8, gpioModePushPull, 1); - SILABS_LOG("%s completed.", __func__); return SL_STATUS_OK; } sl_status_t sl_wfx_host_post_uart_transfer(void) { - SILABS_LOG("%s started.", __func__); #if SL_SPICTRL_MUX if (spi_sem_sync_hdl == NULL) { - SILABS_LOG("%s completed.", __func__); return SL_STATUS_OK; } #endif // SL_SPICTRL_MUX @@ -515,7 +492,6 @@ sl_status_t sl_wfx_host_post_uart_transfer(void) #endif // SL_SPICTRL_MUX sl_wfx_host_enable_platform_interrupt(); sl_wfx_enable_irq(); - SILABS_LOG("%s completed.", __func__); return SL_STATUS_OK; } #endif // SL_UARTCTRL_MUX From 7fa5f11d120c94f55f9d8b93ff70c8fb43f5274d Mon Sep 17 00:00:00 2001 From: Rohan Sahay Date: Wed, 4 Oct 2023 13:08:00 +0530 Subject: [PATCH 18/29] Adds dummy buffer length check --- examples/platform/silabs/efr32/rs911x/hal/efx_spi.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c b/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c index 5393068f4b4d27..1d3cd4b6e40f6a 100644 --- a/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c +++ b/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c @@ -407,6 +407,10 @@ int16_t rsi_spi_transfer(uint8_t * tx_buf, uint8_t * rx_buf, uint16_t xlen, uint */ if (xlen <= MIN_XLEN || (tx_buf == NULL && rx_buf == NULL)) { + if (xlen > sizeof(dummy_buffer)) + { + return RSI_ERROR_INVALID_PARAM; // Ensuring that the dummy buffer won't corrupt the memory + } rx_buf = (uint8_t *) &dummy_buffer; tx_buf = (uint8_t *) &dummy_buffer; } From c5cccd0828e626c3348ce6fc2e3b2e5f839dcaba Mon Sep 17 00:00:00 2001 From: Rohan Sahay Date: Wed, 4 Oct 2023 21:08:59 +0530 Subject: [PATCH 19/29] Restyler changes --- .../silabs/efr32/rs911x/hal/efx_spi.c | 62 ++++++++++--------- .../platform/silabs/efr32/wf200/efr_spi.c | 32 ++++------ 2 files changed, 45 insertions(+), 49 deletions(-) diff --git a/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c b/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c index 1d3cd4b6e40f6a..f13615223c9357 100644 --- a/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c +++ b/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c @@ -22,6 +22,11 @@ #include #include +#include "FreeRTOS.h" +#include "event_groups.h" +#include "task.h" + +#include "btl_interface.h" #include "dmadrv.h" #include "em_chip.h" #include "em_cmu.h" @@ -29,37 +34,17 @@ #include "em_device.h" #include "em_gpio.h" #include "em_ldma.h" -#include "sl_spidrv_instances.h" -#include "spi_multiplex.h" +#include "gpiointerrupt.h" #include "spidrv.h" -#if SL_LCDCTRL_MUX -#include "sl_memlcd.h" -#endif // SL_LCDCTRL_MUX -#if defined(EFR32MG12) -#include "em_usart.h" - -#define SL_SPIDRV_HANDLE sl_spidrv_exp_handle -#elif defined(EFR32MG24) -#include "em_eusart.h" -#include "sl_spidrv_eusart_exp_config.h" - -#define SL_SPIDRV_HANDLE sl_spidrv_eusart_exp_handle -#define SL_SPIDRV_EXP_BITRATE_MULTIPLEXED SL_SPIDRV_EUSART_EXP_BITRATE -#define SL_SPIDRV_UART_CONSOLE_BITRATE SL_UARTDRV_EUSART_VCOM_BAUDRATE -#define SL_SPIDRV_FRAME_LENGTH SL_SPIDRV_EUSART_EXP_FRAME_LENGTH - -#endif // EFR32MG12 || EFR32MG24 - -#include "gpiointerrupt.h" #include "sl_device_init_clocks.h" +#include "sl_device_init_dpll.h" +#include "sl_device_init_hfxo.h" +#include "sl_spidrv_instances.h" #include "sl_status.h" -#include "FreeRTOS.h" -#include "event_groups.h" -#include "task.h" - -#include "btl_interface.h" +#include "silabs_utils.h" +#include "spi_multiplex.h" #include "wfx_host_events.h" #include "wfx_rsi.h" @@ -77,16 +62,33 @@ #include "rsi_driver.h" #endif -#include "sl_device_init_dpll.h" -#include "sl_device_init_hfxo.h" +#if defined(EFR32MG12) +#include "em_usart.h" -#define DEFAULT_SPI_TRASFER_MODE 0 -// Macro to drive semaphore block minimun timer in milli seconds +#define SL_SPIDRV_HANDLE sl_spidrv_exp_handle + +#elif defined(EFR32MG24) +#include "em_eusart.h" +#include "sl_spidrv_eusart_exp_config.h" + +#define SL_SPIDRV_HANDLE sl_spidrv_eusart_exp_handle +#define SL_SPIDRV_EXP_BITRATE_MULTIPLEXED SL_SPIDRV_EUSART_EXP_BITRATE +#define SL_SPIDRV_UART_CONSOLE_BITRATE SL_UARTDRV_EUSART_VCOM_BAUDRATE +#define SL_SPIDRV_FRAME_LENGTH SL_SPIDRV_EUSART_EXP_FRAME_LENGTH + +#endif // EFR32MG12 || EFR32MG24 + +#if SL_LCDCTRL_MUX +#include "sl_memlcd.h" +#endif // SL_LCDCTRL_MUX + +// Macro to drive semaphore block minimum timer in milli seconds #define RSI_SEM_BLOCK_MIN_TIMER_VALUE_MS (50) #if defined(SL_CATALOG_POWER_MANAGER_PRESENT) #include "sl_power_manager.h" #endif +#define DEFAULT_SPI_TRASFER_MODE 0 #define CONCAT(A, B) (A##B) #define SPI_CLOCK(N) CONCAT(cmuClock_USART, N) diff --git a/examples/platform/silabs/efr32/wf200/efr_spi.c b/examples/platform/silabs/efr32/wf200/efr_spi.c index d0e97fed235255..f18d40c77ab6bc 100644 --- a/examples/platform/silabs/efr32/wf200/efr_spi.c +++ b/examples/platform/silabs/efr32/wf200/efr_spi.c @@ -14,21 +14,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -#include "sl_wfx_configuration_defaults.h" - -#include "sl_wfx.h" -#include "sl_wfx_board.h" -#include "sl_wfx_host_api.h" - -#include "dmadrv.h" -#include "em_bus.h" -#include "em_cmu.h" -#include "em_gpio.h" -#include "em_ldma.h" -#include "em_usart.h" -#include "spidrv.h" - #include #include #include @@ -37,21 +22,30 @@ #include "FreeRTOS.h" #include "semphr.h" +#include "dmadrv.h" +#include "em_bus.h" +#include "em_cmu.h" +#include "em_gpio.h" +#include "em_ldma.h" +#include "em_usart.h" #include "gpiointerrupt.h" - +#include "sl_spidrv_exp_config.h" +#include "sl_spidrv_instances.h" +#include "sl_wfx.h" #include "sl_wfx_board.h" +#include "sl_wfx_configuration_defaults.h" #include "sl_wfx_host.h" #include "sl_wfx_host_api.h" #include "sl_wfx_task.h" +#include "spidrv.h" + +#include "spi_multiplex.h" #include "wfx_host_events.h" #if defined(SL_CATALOG_POWER_MANAGER_PRESENT) #include "sl_power_manager.h" #endif -#include "sl_spidrv_exp_config.h" -#include "sl_spidrv_instances.h" -#include "spi_multiplex.h" // TODO: (MATTER-1906) Investigate why using SL_SPIDRV_EXP_BITRATE is causing WF200 init failure // REF: sl_spidrv_exp_config.h #define SL_SPIDRV_EXP_BITRATE_MULTIPLEXED 10000000 From 852e7b5d769c75e156dbaa14ae8a0ee774efb295 Mon Sep 17 00:00:00 2001 From: Rohan Sahay Date: Wed, 4 Oct 2023 21:37:31 +0530 Subject: [PATCH 20/29] Removes use of unnecessary MACRO --- examples/platform/silabs/efr32/rs911x/hal/efx_spi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c b/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c index f13615223c9357..e607066805c249 100644 --- a/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c +++ b/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c @@ -88,7 +88,6 @@ #include "sl_power_manager.h" #endif -#define DEFAULT_SPI_TRASFER_MODE 0 #define CONCAT(A, B) (A##B) #define SPI_CLOCK(N) CONCAT(cmuClock_USART, N) @@ -484,5 +483,5 @@ int16_t rsi_spi_transfer(uint8_t * tx_buf, uint8_t * rx_buf, uint16_t xlen, uint **************************************************************************/ sl_status_t sl_si91x_host_spi_transfer(const void * tx_buf, void * rx_buf, uint16_t xlen) { - return (rsi_spi_transfer((uint8_t *) tx_buf, rx_buf, xlen, DEFAULT_SPI_TRASFER_MODE)); + return (rsi_spi_transfer((uint8_t *) tx_buf, rx_buf, xlen, RSI_MODE_8BIT)); } \ No newline at end of file From 2c36bdb8916db4449b4e89432ff139b646fd757d Mon Sep 17 00:00:00 2001 From: Rohan Sahay Date: Wed, 4 Oct 2023 23:34:58 +0530 Subject: [PATCH 21/29] adds thread check --- gn_build_silabs_wifi.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gn_build_silabs_wifi.sh b/gn_build_silabs_wifi.sh index c4e82fcfa5ed14..a8d5c6da054f36 100755 --- a/gn_build_silabs_wifi.sh +++ b/gn_build_silabs_wifi.sh @@ -3,6 +3,8 @@ set -e ## BRD4161A +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_true_use_external_flash_true_SiWx917 BRD4161A disable_lcd=false use_external_flash=true | tee lighting-app.build.log + ./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_true_use_external_flash_true_SiWx917 BRD4161A --wifi SiWx917 disable_lcd=true use_external_flash=true | tee lighting-app.build.log ./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_true_use_external_flash_false_SiWx917 BRD4161A --wifi SiWx917 disable_lcd=true use_external_flash=false | tee lighting-app.build.log ./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_false_use_external_flash_true_SiWx917 BRD4161A --wifi SiWx917 disable_lcd=false use_external_flash=true | tee lighting-app.build.log @@ -19,6 +21,8 @@ set -e ./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_false_use_external_flash_false_wf200 BRD4161A --wifi wf200 disable_lcd=false use_external_flash=false chip_logging=false silabs_log_enabled=false is_debug=false | tee lighting-app.build.log ## BRD4187C +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_true_use_external_flash_true_SiWx917 BRD4187C disable_lcd=false use_external_flash=true | tee lighting-app.build.log + ./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_true_use_external_flash_true_SiWx917 BRD4187C --wifi SiWx917 disable_lcd=true use_external_flash=true | tee lighting-app.build.log ./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_true_use_external_flash_false_SiWx917 BRD4187C --wifi SiWx917 disable_lcd=true use_external_flash=false | tee lighting-app.build.log ./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_false_use_external_flash_true_SiWx917 BRD4187C --wifi SiWx917 disable_lcd=false use_external_flash=true | tee lighting-app.build.log From 1d2a15f13d826e40a8bdb020ff6e5cd7f3f4b05a Mon Sep 17 00:00:00 2001 From: Rohan Sahay Date: Wed, 4 Oct 2023 23:45:35 +0530 Subject: [PATCH 22/29] Adds comment --- .../silabs/efr32/rs911x/hal/efx_spi.c | 35 +++++++++---------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c b/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c index e607066805c249..43cec5f0a4f5ba 100644 --- a/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c +++ b/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c @@ -388,15 +388,15 @@ static void spi_dmaTransfertComplete(SPIDRV_HandleData_t * pxHandle, Ecode_t tra } /********************************************************************* - * @fn int16_t rsi_spi_transfer(uint8_t *tx_buf, uint8_t *rx_buf, uint16_t xlen, uint8_t mode) - * @brief - * Do a SPI transfer - Mode is 8/16 bit - But every 8 bit is aligned - * @param[in] tx_buf: - * @param[in] rx_buf: - * @param[in] xlen: - * @param[in] mode: - * @return - * None + * @fn int16_t rsi_spi_transfer(uint8_t *ptrBuf,uint16_t bufLen,uint8_t *valBuf,uint8_t mode) + * @param[in] uint8_t *tx_buff, pointer to the buffer with the data to be transfered + * @param[in] uint8_t *rx_buff, pointer to the buffer to store the data received + * @param[in] uint16_t transfer_length, Number of bytes to send and receive + * @param[in] uint8_t mode, To indicate mode 8 BIT/32 BIT mode transfers. + * @param[out] None + * @return 0, 0=success + * @section description + * This API is used to transfer/receive data to the Wi-Fi module through the SPI interface. **************************************************************************/ int16_t rsi_spi_transfer(uint8_t * tx_buf, uint8_t * rx_buf, uint16_t xlen, uint8_t mode) { @@ -471,15 +471,14 @@ int16_t rsi_spi_transfer(uint8_t * tx_buf, uint8_t * rx_buf, uint16_t xlen, uint } /********************************************************************* - * @fn int16_t rsi_spi_transfer(uint8_t *tx_buf, uint8_t *rx_buf, uint16_t xlen, uint8_t mode) - * @brief - * Do a SPI transfer - Mode is 8/16 bit - But every 8 bit is aligned - * @param[in] tx_buf: - * @param[in] rx_buf: - * @param[in] xlen: - * @param[in] mode: - * @return - * None + * @fn int16_t sl_si91x_host_spi_transfer(uint8_t *tx_buf, uint8_t *rx_buf, uint16_t xlen) + * @param[in] uint8_t *tx_buff, pointer to the buffer with the data to be transferred + * @param[in] uint8_t *rx_buff, pointer to the buffer to store the data received + * @param[in] uint16_t transfer_length, Number of bytes to send and receive + * @param[out] None + * @return 0, 0=success + * @section description + * This API is used to transfer/receive data to the Wi-Fi module through the SPI interface. **************************************************************************/ sl_status_t sl_si91x_host_spi_transfer(const void * tx_buf, void * rx_buf, uint16_t xlen) { From 32d8413f1a4f7a4b3f5e0a9ace0acdfc9e6ff507 Mon Sep 17 00:00:00 2001 From: Rohan S <3526930+brosahay@users.noreply.github.com> Date: Thu, 5 Oct 2023 02:35:04 +0000 Subject: [PATCH 23/29] updated build script --- gn_build_silabs_wifi.sh | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/gn_build_silabs_wifi.sh b/gn_build_silabs_wifi.sh index a8d5c6da054f36..4114696b01c98d 100755 --- a/gn_build_silabs_wifi.sh +++ b/gn_build_silabs_wifi.sh @@ -1,19 +1,19 @@ #!/usr/bin/env bash -set -e +set -ex ## BRD4161A -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_true_use_external_flash_true_SiWx917 BRD4161A disable_lcd=false use_external_flash=true | tee lighting-app.build.log +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/ BRD4161A disable_lcd=false use_external_flash=true | tee lighting-app.build.log -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_true_use_external_flash_true_SiWx917 BRD4161A --wifi SiWx917 disable_lcd=true use_external_flash=true | tee lighting-app.build.log -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_true_use_external_flash_false_SiWx917 BRD4161A --wifi SiWx917 disable_lcd=true use_external_flash=false | tee lighting-app.build.log -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_false_use_external_flash_true_SiWx917 BRD4161A --wifi SiWx917 disable_lcd=false use_external_flash=true | tee lighting-app.build.log -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_false_use_external_flash_false_SiWx917 BRD4161A --wifi SiWx917 disable_lcd=false use_external_flash=false | tee lighting-app.build.log +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_true_use_external_flash_true_SiWx917 BRD4161A --wifi SiWx917 chip_enable_ble_rs911x=true disable_lcd=true use_external_flash=true | tee lighting-app.build.log +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_true_use_external_flash_false_SiWx917 BRD4161A --wifi SiWx917 chip_enable_ble_rs911x=true disable_lcd=true use_external_flash=false | tee lighting-app.build.log +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_false_use_external_flash_true_SiWx917 BRD4161A --wifi SiWx917 chip_enable_ble_rs911x=true disable_lcd=false use_external_flash=true | tee lighting-app.build.log +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_false_use_external_flash_false_SiWx917 BRD4161A --wifi SiWx917 chip_enable_ble_rs911x=true disable_lcd=false use_external_flash=false | tee lighting-app.build.log -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_true_use_external_flash_true_rs9116 BRD4161A --wifi rs9116 disable_lcd=true use_external_flash=true | tee lighting-app.build.log -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_true_use_external_flash_false_rs9116 BRD4161A --wifi rs9116 disable_lcd=true use_external_flash=false | tee lighting-app.build.log -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_false_use_external_flash_true_rs9116 BRD4161A --wifi rs9116 disable_lcd=false use_external_flash=true | tee lighting-app.build.log -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_false_use_external_flash_false_rs9116 BRD4161A --wifi rs9116 disable_lcd=false use_external_flash=false | tee lighting-app.build.log +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_true_use_external_flash_true_rs9116 BRD4161A --wifi rs9116 chip_enable_ble_rs911x=true disable_lcd=true use_external_flash=true | tee lighting-app.build.log +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_true_use_external_flash_false_rs9116 BRD4161A --wifi rs9116 chip_enable_ble_rs911x=true disable_lcd=true use_external_flash=false | tee lighting-app.build.log +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_false_use_external_flash_true_rs9116 BRD4161A --wifi rs9116 chip_enable_ble_rs911x=true disable_lcd=false use_external_flash=true | tee lighting-app.build.log +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_false_use_external_flash_false_rs9116 BRD4161A --wifi rs9116 chip_enable_ble_rs911x=true disable_lcd=false use_external_flash=false | tee lighting-app.build.log ./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_true_use_external_flash_true_wf200 BRD4161A --wifi wf200 disable_lcd=true use_external_flash=true chip_logging=false silabs_log_enabled=false is_debug=false | tee lighting-app.build.log ./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_true_use_external_flash_false_wf200 BRD4161A --wifi wf200 disable_lcd=true use_external_flash=false chip_logging=false silabs_log_enabled=false is_debug=false | tee lighting-app.build.log @@ -21,17 +21,17 @@ set -e ./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_false_use_external_flash_false_wf200 BRD4161A --wifi wf200 disable_lcd=false use_external_flash=false chip_logging=false silabs_log_enabled=false is_debug=false | tee lighting-app.build.log ## BRD4187C -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_true_use_external_flash_true_SiWx917 BRD4187C disable_lcd=false use_external_flash=true | tee lighting-app.build.log +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/ BRD4187C disable_lcd=false use_external_flash=true | tee lighting-app.build.log -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_true_use_external_flash_true_SiWx917 BRD4187C --wifi SiWx917 disable_lcd=true use_external_flash=true | tee lighting-app.build.log -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_true_use_external_flash_false_SiWx917 BRD4187C --wifi SiWx917 disable_lcd=true use_external_flash=false | tee lighting-app.build.log -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_false_use_external_flash_true_SiWx917 BRD4187C --wifi SiWx917 disable_lcd=false use_external_flash=true | tee lighting-app.build.log -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_false_use_external_flash_false_SiWx917 BRD4187C --wifi SiWx917 disable_lcd=false use_external_flash=false | tee lighting-app.build.log +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_true_use_external_flash_true_SiWx917 BRD4187C --wifi SiWx917 chip_enable_ble_rs911x=true disable_lcd=true use_external_flash=true | tee lighting-app.build.log +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_true_use_external_flash_false_SiWx917 BRD4187C --wifi SiWx917 chip_enable_ble_rs911x=true disable_lcd=true use_external_flash=false | tee lighting-app.build.log +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_false_use_external_flash_true_SiWx917 BRD4187C --wifi SiWx917 chip_enable_ble_rs911x=true disable_lcd=false use_external_flash=true | tee lighting-app.build.log +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_false_use_external_flash_false_SiWx917 BRD4187C --wifi SiWx917 chip_enable_ble_rs911x=true disable_lcd=false use_external_flash=false | tee lighting-app.build.log -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_true_use_external_flash_true_rs9116 BRD4187C --wifi rs9116 disable_lcd=true use_external_flash=true | tee lighting-app.build.log -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_true_use_external_flash_false_rs9116 BRD4187C --wifi rs9116 disable_lcd=true use_external_flash=false | tee lighting-app.build.log -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_false_use_external_flash_true_rs9116 BRD4187C --wifi rs9116 disable_lcd=false use_external_flash=true | tee lighting-app.build.log -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_false_use_external_flash_false_rs9116 BRD4187C --wifi rs9116 disable_lcd=false use_external_flash=false | tee lighting-app.build.log +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_true_use_external_flash_true_rs9116 BRD4187C --wifi rs9116 chip_enable_ble_rs911x=true disable_lcd=true use_external_flash=true | tee lighting-app.build.log +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_true_use_external_flash_false_rs9116 BRD4187C --wifi rs9116 chip_enable_ble_rs911x=true disable_lcd=true use_external_flash=false | tee lighting-app.build.log +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_false_use_external_flash_true_rs9116 BRD4187C --wifi rs9116 chip_enable_ble_rs911x=true disable_lcd=false use_external_flash=true | tee lighting-app.build.log +./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_false_use_external_flash_false_rs9116 BRD4187C --wifi rs9116 chip_enable_ble_rs911x=true disable_lcd=false use_external_flash=false | tee lighting-app.build.log ./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_true_use_external_flash_true_wf200 BRD4187C --wifi wf200 disable_lcd=true use_external_flash=true | tee lighting-app.build.log ./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_true_use_external_flash_false_wf200 BRD4187C --wifi wf200 disable_lcd=true use_external_flash=false | tee lighting-app.build.log From 27cf906777bbaf178a446a18a2ee11180c7bfa0a Mon Sep 17 00:00:00 2001 From: Rohan S <3526930+brosahay@users.noreply.github.com> Date: Thu, 5 Oct 2023 03:17:45 +0000 Subject: [PATCH 24/29] Adds refactored includes and define macros --- .../silabs/efr32/rs911x/hal/efx_spi.c | 32 ++++++++++++------- .../platform/silabs/efr32/spi_multiplex.h | 15 +-------- .../platform/silabs/efr32/wf200/efr_spi.c | 9 ++++++ 3 files changed, 30 insertions(+), 26 deletions(-) diff --git a/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c b/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c index 43cec5f0a4f5ba..ac4d48b0c28ac1 100644 --- a/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c +++ b/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c @@ -24,6 +24,7 @@ #include "FreeRTOS.h" #include "event_groups.h" +#include "semphr.h" #include "task.h" #include "btl_interface.h" @@ -48,6 +49,10 @@ #include "wfx_host_events.h" #include "wfx_rsi.h" +#if defined(SL_CATALOG_POWER_MANAGER_PRESENT) +#include "sl_power_manager.h" +#endif + #ifdef CHIP_9117 #include "cmsis_os2.h" #include "sl_board_configuration.h" @@ -57,10 +62,21 @@ #include "sl_wifi_callback_framework.h" #include "sl_wifi_constants.h" #include "sl_wifi_types.h" + +// macro to drive semaphore block minimum timer in milli seconds +// ported from rsi_hal.h (rs911x) +#define RSI_SEM_BLOCK_MIN_TIMER_VALUE_MS (50) #else #include "rsi_board_configuration.h" #include "rsi_driver.h" -#endif +#endif // CHIP_9117 + +#if SL_LCDCTRL_MUX +#include "sl_memlcd.h" +#endif // SL_LCDCTRL_MUX +#if SL_MX25CTRL_MUX +#include "sl_mx25_flash_shutdown_usart_config.h" +#endif // SL_MX25CTRL_MUX #if defined(EFR32MG12) #include "em_usart.h" @@ -78,16 +94,6 @@ #endif // EFR32MG12 || EFR32MG24 -#if SL_LCDCTRL_MUX -#include "sl_memlcd.h" -#endif // SL_LCDCTRL_MUX - -// Macro to drive semaphore block minimum timer in milli seconds -#define RSI_SEM_BLOCK_MIN_TIMER_VALUE_MS (50) -#if defined(SL_CATALOG_POWER_MANAGER_PRESENT) -#include "sl_power_manager.h" -#endif - #define CONCAT(A, B) (A##B) #define SPI_CLOCK(N) CONCAT(cmuClock_USART, N) @@ -470,6 +476,7 @@ int16_t rsi_spi_transfer(uint8_t * tx_buf, uint8_t * rx_buf, uint16_t xlen, uint return rsiError; } +#ifdef CHIP_9117 /********************************************************************* * @fn int16_t sl_si91x_host_spi_transfer(uint8_t *tx_buf, uint8_t *rx_buf, uint16_t xlen) * @param[in] uint8_t *tx_buff, pointer to the buffer with the data to be transferred @@ -483,4 +490,5 @@ int16_t rsi_spi_transfer(uint8_t * tx_buf, uint8_t * rx_buf, uint16_t xlen, uint sl_status_t sl_si91x_host_spi_transfer(const void * tx_buf, void * rx_buf, uint16_t xlen) { return (rsi_spi_transfer((uint8_t *) tx_buf, rx_buf, xlen, RSI_MODE_8BIT)); -} \ No newline at end of file +} +#endif // CHIP_9117 diff --git a/examples/platform/silabs/efr32/spi_multiplex.h b/examples/platform/silabs/efr32/spi_multiplex.h index 953becdacbff31..14d825379e2bd7 100644 --- a/examples/platform/silabs/efr32/spi_multiplex.h +++ b/examples/platform/silabs/efr32/spi_multiplex.h @@ -48,19 +48,6 @@ #ifdef __cplusplus extern "C" { #endif -#include "FreeRTOS.h" -#include "semphr.h" -#if SL_LCDCTRL_MUX -#include "sl_memlcd_display.h" -#endif // SL_LCDCTRL_MUX -#if SL_MX25CTRL_MUX -#include "sl_mx25_flash_shutdown_usart_config.h" -#endif // SL_MX25CTRL_MUX - -#include "spidrv.h" - -#define SL_SPIDRV_LCD_BITRATE SL_MEMLCD_SCLK_FREQ -#define SL_SPIDRV_MX25_FLASH_BITRATE 16000000 #if SL_SPICTRL_MUX /**************************************************************************** @@ -176,4 +163,4 @@ sl_status_t sl_wfx_host_post_uart_transfer(void); #ifdef __cplusplus } #endif -#endif // SL_SPICTRL_MUX \ No newline at end of file +#endif // SL_SPICTRL_MUX diff --git a/examples/platform/silabs/efr32/wf200/efr_spi.c b/examples/platform/silabs/efr32/wf200/efr_spi.c index f18d40c77ab6bc..dfa6109496d436 100644 --- a/examples/platform/silabs/efr32/wf200/efr_spi.c +++ b/examples/platform/silabs/efr32/wf200/efr_spi.c @@ -46,6 +46,15 @@ #include "sl_power_manager.h" #endif +#if SL_LCDCTRL_MUX +#include "sl_memlcd_display.h" +#define SL_SPIDRV_LCD_BITRATE SL_MEMLCD_SCLK_FREQ +#endif // SL_LCDCTRL_MUX +#if SL_MX25CTRL_MUX +#include "sl_mx25_flash_shutdown_usart_config.h" +#define SL_SPIDRV_MX25_FLASH_BITRATE 16000000 +#endif // SL_MX25CTRL_MUX + // TODO: (MATTER-1906) Investigate why using SL_SPIDRV_EXP_BITRATE is causing WF200 init failure // REF: sl_spidrv_exp_config.h #define SL_SPIDRV_EXP_BITRATE_MULTIPLEXED 10000000 From 5d6a7a9c0bfcb26237c349a479f4341dd464a9ed Mon Sep 17 00:00:00 2001 From: Rohan Sahay Date: Thu, 5 Oct 2023 10:56:30 +0530 Subject: [PATCH 25/29] Adds spell fix --- examples/platform/silabs/efr32/rs911x/hal/efx_spi.c | 12 ++++++------ examples/platform/silabs/efr32/spi_multiplex.h | 2 +- examples/platform/silabs/efr32/wf200/efr_spi.c | 12 ++++++------ 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c b/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c index ac4d48b0c28ac1..d6a0a590891cff 100644 --- a/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c +++ b/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c @@ -263,7 +263,7 @@ sl_status_t sl_wfx_host_spi_cs_deassert(void) } #endif // SL_SPICTRL_MUX -#if SL_MUX25CTRL_MUX +#if SL_MX25CTRL_MUX sl_status_t sl_wfx_host_spiflash_cs_assert(void) { GPIO_PinOutClear(SL_MX25_FLASH_SHUTDOWN_CS_PORT, SL_MX25_FLASH_SHUTDOWN_CS_PIN); @@ -275,7 +275,7 @@ sl_status_t sl_wfx_host_spiflash_cs_deassert(void) GPIO_PinOutSet(SL_MX25_FLASH_SHUTDOWN_CS_PORT, SL_MX25_FLASH_SHUTDOWN_CS_PIN); return SL_STATUS_OK; } -#endif // SL_MUX25CTRL_MUX +#endif // SL_MX25CTRL_MUX #if SL_BTLCTRL_MUX sl_status_t sl_wfx_host_pre_bootloader_spi_transfer(void) @@ -303,9 +303,9 @@ sl_status_t sl_wfx_host_pre_bootloader_spi_transfer(void) #endif // SL_SPICTRL_MUX return SL_STATUS_FAIL; } -#if SL_MUX25CTRL_MUX +#if SL_MX25CTRL_MUX sl_wfx_host_spiflash_cs_assert(); -#endif // SL_MUX25CTRL_MUX +#endif // SL_MX25CTRL_MUX return SL_STATUS_OK; } @@ -322,9 +322,9 @@ sl_status_t sl_wfx_host_post_bootloader_spi_transfer(void) return SL_STATUS_FAIL; } GPIO->USARTROUTE[SL_MX25_FLASH_SHUTDOWN_PERIPHERAL_NO].ROUTEEN = PINOUT_CLEAR; -#if SL_MUX25CTRL_MUX +#if SL_MX25CTRL_MUX sl_wfx_host_spiflash_cs_deassert(); -#endif // SL_MUX25CTRL_MUX +#endif // SL_MX25CTRL_MUX #if SL_SPICTRL_MUX xSemaphoreGive(spi_sem_sync_hdl); #endif // SL_SPICTRL_MUX diff --git a/examples/platform/silabs/efr32/spi_multiplex.h b/examples/platform/silabs/efr32/spi_multiplex.h index 14d825379e2bd7..82eaf3991bdf4e 100644 --- a/examples/platform/silabs/efr32/spi_multiplex.h +++ b/examples/platform/silabs/efr32/spi_multiplex.h @@ -33,7 +33,7 @@ #endif // SL_UARTCTRL_MUX #ifndef SL_MX25CTRL_MUX -#define SL_MUX25CTRL_MUX (EFR32MG24 && SL_WIFI && CONFIG_USE_EXTERNAL_FLASH) +#define SL_MX25CTRL_MUX (EFR32MG24 && SL_WIFI && CONFIG_USE_EXTERNAL_FLASH) #endif // SL_MX25CTRL_MUX #ifndef SL_BTLCTRL_MUX diff --git a/examples/platform/silabs/efr32/wf200/efr_spi.c b/examples/platform/silabs/efr32/wf200/efr_spi.c index dfa6109496d436..4cb83427ca3a49 100644 --- a/examples/platform/silabs/efr32/wf200/efr_spi.c +++ b/examples/platform/silabs/efr32/wf200/efr_spi.c @@ -393,7 +393,7 @@ void SPIDRV_SetBaudrate(uint32_t baudrate) USART_InitSync(MY_USART, &usartInit); } #endif // SL_SPICTRL_MUX -#if SL_MUX25CTRL_MUX +#if SL_MX25CTRL_MUX sl_status_t sl_wfx_host_spiflash_cs_assert(void) { GPIO_PinOutClear(SL_MX25_FLASH_SHUTDOWN_CS_PORT, SL_MX25_FLASH_SHUTDOWN_CS_PIN); @@ -405,7 +405,7 @@ sl_status_t sl_wfx_host_spiflash_cs_deassert(void) GPIO_PinOutSet(SL_MX25_FLASH_SHUTDOWN_CS_PORT, SL_MX25_FLASH_SHUTDOWN_CS_PIN); return SL_STATUS_OK; } -#endif // SL_MUX25CTRL_MUX +#endif // SL_MX25CTRL_MUX #if SL_BTLCTRL_MUX sl_status_t sl_wfx_host_pre_bootloader_spi_transfer(void) @@ -417,9 +417,9 @@ sl_status_t sl_wfx_host_pre_bootloader_spi_transfer(void) * Assert CS pin for EXT SPI Flash */ SPIDRV_SetBaudrate(SL_SPIDRV_MX25_FLASH_BITRATE); -#if SL_MUX25CTRL_MUX +#if SL_MX25CTRL_MUX sl_wfx_host_spiflash_cs_assert(); -#endif // SL_MUX25CTRL_MUX +#endif // SL_MX25CTRL_MUX return SL_STATUS_OK; } @@ -428,9 +428,9 @@ sl_status_t sl_wfx_host_post_bootloader_spi_transfer(void) /* * De-Assert CS pin for EXT SPI Flash */ -#if SL_MUX25CTRL_MUX +#if SL_MX25CTRL_MUX sl_wfx_host_spiflash_cs_deassert(); -#endif // SL_MUX25CTRL_MUX +#endif // SL_MX25CTRL_MUX #if SL_SPICTRL_MUX xSemaphoreGive(spi_sem_sync_hdl); #endif // SL_SPICTRL_MUX From cdf8414c2082d918b44388a16e7a2388b1ee7236 Mon Sep 17 00:00:00 2001 From: Rohan Sahay Date: Tue, 10 Oct 2023 09:34:00 +0530 Subject: [PATCH 26/29] Adds feature macro for header include --- examples/platform/silabs/efr32/rs911x/hal/efx_spi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c b/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c index d6a0a590891cff..edc579e24b4394 100644 --- a/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c +++ b/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c @@ -27,7 +27,6 @@ #include "semphr.h" #include "task.h" -#include "btl_interface.h" #include "dmadrv.h" #include "em_chip.h" #include "em_cmu.h" @@ -71,6 +70,9 @@ #include "rsi_driver.h" #endif // CHIP_9117 +#if SL_BTLCTRL_MUX +#include "btl_interface.h" +#endif // SL_BTLCTRL_MUX #if SL_LCDCTRL_MUX #include "sl_memlcd.h" #endif // SL_LCDCTRL_MUX From 88e216d3e55d4297011b2a8b784dc6edfa3c925e Mon Sep 17 00:00:00 2001 From: Rohan Sahay Date: Tue, 10 Oct 2023 11:22:37 +0530 Subject: [PATCH 27/29] Remove temp code --- .../silabs/efr32/rs911x/hal/efx_spi.c | 4 -- gn_build_silabs_wifi.sh | 39 ------------------- 2 files changed, 43 deletions(-) delete mode 100755 gn_build_silabs_wifi.sh diff --git a/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c b/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c index edc579e24b4394..809ff833ff5a98 100644 --- a/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c +++ b/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c @@ -227,7 +227,6 @@ void SPIDRV_SetBaudrate(uint32_t baudrate) sl_status_t sl_wfx_host_spi_cs_assert(void) { - // SILABS_LOG("sl_wfx_host_spi_cs_assert started."); xSemaphoreTake(spi_sem_sync_hdl, portMAX_DELAY); if (!spi_enabled) // Reduce sl_spidrv_init_instances @@ -238,13 +237,11 @@ sl_status_t sl_wfx_host_spi_cs_assert(void) #endif // EFR32MG24 spi_enabled = true; } - // SILABS_LOG("sl_wfx_host_spi_cs_assert completed."); return SL_STATUS_OK; } sl_status_t sl_wfx_host_spi_cs_deassert(void) { - // SILABS_LOG("sl_wfx_host_spi_cs_deassert started."); if (spi_enabled) { if (ECODE_EMDRV_SPIDRV_OK != SPIDRV_DeInit(SL_SPIDRV_HANDLE)) @@ -260,7 +257,6 @@ sl_status_t sl_wfx_host_spi_cs_deassert(void) spi_enabled = false; } xSemaphoreGive(spi_sem_sync_hdl); - // SILABS_LOG("sl_wfx_host_spi_cs_deassert completed."); return SL_STATUS_OK; } #endif // SL_SPICTRL_MUX diff --git a/gn_build_silabs_wifi.sh b/gn_build_silabs_wifi.sh deleted file mode 100755 index 4114696b01c98d..00000000000000 --- a/gn_build_silabs_wifi.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/env bash - -set -ex - -## BRD4161A -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/ BRD4161A disable_lcd=false use_external_flash=true | tee lighting-app.build.log - -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_true_use_external_flash_true_SiWx917 BRD4161A --wifi SiWx917 chip_enable_ble_rs911x=true disable_lcd=true use_external_flash=true | tee lighting-app.build.log -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_true_use_external_flash_false_SiWx917 BRD4161A --wifi SiWx917 chip_enable_ble_rs911x=true disable_lcd=true use_external_flash=false | tee lighting-app.build.log -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_false_use_external_flash_true_SiWx917 BRD4161A --wifi SiWx917 chip_enable_ble_rs911x=true disable_lcd=false use_external_flash=true | tee lighting-app.build.log -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_false_use_external_flash_false_SiWx917 BRD4161A --wifi SiWx917 chip_enable_ble_rs911x=true disable_lcd=false use_external_flash=false | tee lighting-app.build.log - -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_true_use_external_flash_true_rs9116 BRD4161A --wifi rs9116 chip_enable_ble_rs911x=true disable_lcd=true use_external_flash=true | tee lighting-app.build.log -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_true_use_external_flash_false_rs9116 BRD4161A --wifi rs9116 chip_enable_ble_rs911x=true disable_lcd=true use_external_flash=false | tee lighting-app.build.log -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_false_use_external_flash_true_rs9116 BRD4161A --wifi rs9116 chip_enable_ble_rs911x=true disable_lcd=false use_external_flash=true | tee lighting-app.build.log -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_false_use_external_flash_false_rs9116 BRD4161A --wifi rs9116 chip_enable_ble_rs911x=true disable_lcd=false use_external_flash=false | tee lighting-app.build.log - -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_true_use_external_flash_true_wf200 BRD4161A --wifi wf200 disable_lcd=true use_external_flash=true chip_logging=false silabs_log_enabled=false is_debug=false | tee lighting-app.build.log -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_true_use_external_flash_false_wf200 BRD4161A --wifi wf200 disable_lcd=true use_external_flash=false chip_logging=false silabs_log_enabled=false is_debug=false | tee lighting-app.build.log -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_false_use_external_flash_true_wf200 BRD4161A --wifi wf200 disable_lcd=false use_external_flash=true chip_logging=false silabs_log_enabled=false is_debug=false | tee lighting-app.build.log -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_false_use_external_flash_false_wf200 BRD4161A --wifi wf200 disable_lcd=false use_external_flash=false chip_logging=false silabs_log_enabled=false is_debug=false | tee lighting-app.build.log - -## BRD4187C -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/ BRD4187C disable_lcd=false use_external_flash=true | tee lighting-app.build.log - -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_true_use_external_flash_true_SiWx917 BRD4187C --wifi SiWx917 chip_enable_ble_rs911x=true disable_lcd=true use_external_flash=true | tee lighting-app.build.log -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_true_use_external_flash_false_SiWx917 BRD4187C --wifi SiWx917 chip_enable_ble_rs911x=true disable_lcd=true use_external_flash=false | tee lighting-app.build.log -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_false_use_external_flash_true_SiWx917 BRD4187C --wifi SiWx917 chip_enable_ble_rs911x=true disable_lcd=false use_external_flash=true | tee lighting-app.build.log -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_false_use_external_flash_false_SiWx917 BRD4187C --wifi SiWx917 chip_enable_ble_rs911x=true disable_lcd=false use_external_flash=false | tee lighting-app.build.log - -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_true_use_external_flash_true_rs9116 BRD4187C --wifi rs9116 chip_enable_ble_rs911x=true disable_lcd=true use_external_flash=true | tee lighting-app.build.log -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_true_use_external_flash_false_rs9116 BRD4187C --wifi rs9116 chip_enable_ble_rs911x=true disable_lcd=true use_external_flash=false | tee lighting-app.build.log -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_false_use_external_flash_true_rs9116 BRD4187C --wifi rs9116 chip_enable_ble_rs911x=true disable_lcd=false use_external_flash=true | tee lighting-app.build.log -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_false_use_external_flash_false_rs9116 BRD4187C --wifi rs9116 chip_enable_ble_rs911x=true disable_lcd=false use_external_flash=false | tee lighting-app.build.log - -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_true_use_external_flash_true_wf200 BRD4187C --wifi wf200 disable_lcd=true use_external_flash=true | tee lighting-app.build.log -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_true_use_external_flash_false_wf200 BRD4187C --wifi wf200 disable_lcd=true use_external_flash=false | tee lighting-app.build.log -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_false_use_external_flash_true_wf200 BRD4187C --wifi wf200 disable_lcd=false use_external_flash=true | tee lighting-app.build.log -./scripts/examples/gn_silabs_example.sh ./examples/lighting-app/silabs ./out/debug/disable_lcd_false_use_external_flash_false_wf200 BRD4187C --wifi wf200 disable_lcd=false use_external_flash=false | tee lighting-app.build.log From 1063c6d616672e47fec236f9eac058e43a2f7a90 Mon Sep 17 00:00:00 2001 From: Rohan Sahay Date: Mon, 16 Oct 2023 09:05:31 +0530 Subject: [PATCH 28/29] Adds refactored deassert --- .../silabs/efr32/rs911x/hal/efx_spi.c | 24 +++++-------------- 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c b/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c index 809ff833ff5a98..d69434b7ae3cdf 100644 --- a/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c +++ b/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c @@ -279,17 +279,11 @@ sl_status_t sl_wfx_host_spiflash_cs_deassert(void) sl_status_t sl_wfx_host_pre_bootloader_spi_transfer(void) { #if SL_SPICTRL_MUX - xSemaphoreTake(spi_sem_sync_hdl, portMAX_DELAY); - if (spi_enabled) + if (sl_wfx_host_spi_cs_deassert() != SL_STATUS_OK) { - if (ECODE_EMDRV_SPIDRV_OK != SPIDRV_DeInit(SL_SPIDRV_HANDLE)) - { - xSemaphoreGive(spi_sem_sync_hdl); - SILABS_LOG("%s error.", __func__); - return SL_STATUS_FAIL; - } - spi_enabled = false; + return SL_STATUS_FAIL; } + xSemaphoreTake(spi_sem_sync_hdl, portMAX_DELAY); #endif // SL_SPICTRL_MUX // bootloader_init takes care of SPIDRV_Init() int32_t status = bootloader_init(); @@ -334,17 +328,11 @@ sl_status_t sl_wfx_host_post_bootloader_spi_transfer(void) sl_status_t sl_wfx_host_pre_lcd_spi_transfer(void) { #if SL_SPICTRL_MUX - xSemaphoreTake(spi_sem_sync_hdl, portMAX_DELAY); - if (spi_enabled) + if (sl_wfx_host_spi_cs_deassert() != SL_STATUS_OK) { - if (ECODE_EMDRV_SPIDRV_OK != SPIDRV_DeInit(SL_SPIDRV_HANDLE)) - { - xSemaphoreGive(spi_sem_sync_hdl); - SILABS_LOG("%s error.", __func__); - return SL_STATUS_FAIL; - } - spi_enabled = false; + return SL_STATUS_FAIL; } + xSemaphoreTake(spi_sem_sync_hdl, portMAX_DELAY); #endif // SL_SPICTRL_MUX // sl_memlcd_refresh takes care of SPIDRV_Init() if (SL_STATUS_OK != sl_memlcd_refresh(sl_memlcd_get())) From c603239809d91401d5fac7fbac2a91d01214be8a Mon Sep 17 00:00:00 2001 From: Rohan Sahay Date: Mon, 16 Oct 2023 09:53:27 +0530 Subject: [PATCH 29/29] Comment reformatting --- examples/platform/silabs/efr32/rs911x/hal/efx_spi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c b/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c index d69434b7ae3cdf..1e30b8bdf2f9c6 100644 --- a/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c +++ b/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c @@ -380,7 +380,7 @@ static void spi_dmaTransfertComplete(SPIDRV_HandleData_t * pxHandle, Ecode_t tra } /********************************************************************* - * @fn int16_t rsi_spi_transfer(uint8_t *ptrBuf,uint16_t bufLen,uint8_t *valBuf,uint8_t mode) + * @fn int16_t rsi_spi_transfer(uint8_t *ptrBuf, uint16_t bufLen, uint8_t *valBuf, uint8_t mode) * @param[in] uint8_t *tx_buff, pointer to the buffer with the data to be transfered * @param[in] uint8_t *rx_buff, pointer to the buffer to store the data received * @param[in] uint16_t transfer_length, Number of bytes to send and receive