Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Silabs] Added fixes for hardfault issue with rs9116 when LCD enabled and 917 NCP-LCD enablement #32209

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
f7c41b4
Added fixes for hardfault issue with rs9116 when LCD enabled
bhmanda-silabs Feb 19, 2024
279a735
resolved build errors with mg12
bhmanda-silabs Feb 19, 2024
441feb3
Pull request #1552: [MATTER-2763]wifi-917NCP_enabling LCD
bhmanda-silabs Feb 9, 2024
ab80491
resolved review comments
bhmanda-silabs Feb 21, 2024
eb0fa01
Resolved review comments
bhmanda-silabs Feb 21, 2024
c8c0865
Resolved comments and removed ununsed macros
bhmanda-silabs Feb 22, 2024
da447c7
removed semaphore in header file as it is not being used in this file
bhmanda-silabs Feb 22, 2024
439a5da
resolved the comments
bhmanda-silabs Feb 22, 2024
5f28059
Merge branch 'master' into bugfix/wifi_RS9116_fixes_for_hardfault_issue
bhmanda-silabs Feb 22, 2024
201235c
Merge branch 'master' into bugfix/wifi_RS9116_fixes_for_hardfault_issue
bhmanda-silabs Feb 23, 2024
bb0c44b
Restyled
bhmanda-silabs Feb 23, 2024
eeecacc
Merge branch 'master' into bugfix/wifi_RS9116_fixes_for_hardfault_issue
bhmanda-silabs Feb 23, 2024
997e5d5
Merge branch 'master' into bugfix/wifi_RS9116_fixes_for_hardfault_issue
bhmanda-silabs Feb 26, 2024
5673e9d
Merge branch 'master' into bugfix/wifi_RS9116_fixes_for_hardfault_issue
bhmanda-silabs Feb 26, 2024
a781754
Merge branch 'master' into bugfix/wifi_RS9116_fixes_for_hardfault_issue
bhmanda-silabs Feb 27, 2024
baa3455
Merge branch 'master' into bugfix/wifi_RS9116_fixes_for_hardfault_issue
bhmanda-silabs Feb 28, 2024
6deeb0b
Merge branch 'master' into bugfix/wifi_RS9116_fixes_for_hardfault_issue
bhmanda-silabs Feb 28, 2024
a09be8a
Merge branch 'master' into bugfix/wifi_RS9116_fixes_for_hardfault_issue
bhmanda-silabs Feb 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions examples/platform/silabs/display/demo-ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,18 +103,24 @@ void demoUIInit(GLIB_Context_t * context)

sl_status_t updateDisplay(void)
{
sl_status_t status = SL_STATUS_OK;
#if SIWX_917 && SL_ICD_ENABLED && DISPLAY_ENABLED
sl_memlcd_post_wakeup_init();
#endif // SIWX_917 && SL_ICD_ENABLED && DISPLAY_ENABLED
#if SL_LCDCTRL_MUX
sl_wfx_host_pre_lcd_spi_transfer();
#endif // SL_LCDCTRL_MUX
sl_status_t status = DMD_updateDisplay();
#if SL_LCDCTRL_MUX
sl_wfx_host_post_lcd_spi_transfer();
status = sl_wfx_host_pre_lcd_spi_transfer();
if (status != SL_STATUS_OK)
return status;
#endif // SL_LCDCTRL_MUX
status = DMD_updateDisplay();
if (status != DMD_OK)
return SL_STATUS_FAIL;
#if SL_LCDCTRL_MUX
status = sl_wfx_host_post_lcd_spi_transfer();
if (status != SL_STATUS_OK)
return status;
#endif // SL_LCDCTRL_MUX

return SL_STATUS_OK;
}

Expand Down
26 changes: 18 additions & 8 deletions examples/platform/silabs/efr32/rs911x/hal/efx32_ncp_host.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@
#include "sl_power_manager.h"
#endif

#define USART_INITSYNC_BAUDRATE 12500000
#include "sl_board_control.h"
#include "sl_si91x_ncp_utility.h"
#include "spi_multiplex.h"

static bool dma_callback(unsigned int channel, unsigned int sequenceNo, void * userParam);

unsigned int rx_ldma_channel;
unsigned int tx_ldma_channel;
uint32_t rx_ldma_channel;
uint32_t tx_ldma_channel;
osMutexId_t ncp_transfer_mutex = 0;

static uint32_t dummy_buffer;
Expand Down Expand Up @@ -81,7 +83,7 @@ static void efx32_spi_init(void)
USART_InitSync_TypeDef init = USART_INITSYNC_DEFAULT;

init.msbf = true; // MSB first transmission for SPI compatibility
init.autoCsEnable = true; // Allow the USART to assert CS
init.autoCsEnable = false;
init.baudrate = USART_INITSYNC_BAUDRATE;

// Configure SPI bus pins
Expand Down Expand Up @@ -109,15 +111,15 @@ static void efx32_spi_init(void)
// Enable USART interface pins
GPIO->USARTROUTE[SPI_USART_ROUTE_INDEX].ROUTEEN = GPIO_USART_ROUTEEN_RXPEN | // MISO
GPIO_USART_ROUTEEN_TXPEN | // MOSI
GPIO_USART_ROUTEEN_CLKPEN | GPIO_USART_ROUTEEN_CSPEN;
GPIO_USART_ROUTEEN_CLKPEN;

// Set slew rate for alternate usage pins
GPIO_SlewrateSet(SPI_CLOCK_PIN.port, 7, 7);

// Configure and enable USART
USART_InitSync(SPI_USART, &init);

SPI_USART->TIMING |= /*USART_TIMING_TXDELAY_ONE | USART_TIMING_CSSETUP_ONE |*/ USART_TIMING_CSHOLD_ONE;
SPI_USART->TIMING |= USART_TIMING_TXDELAY_ONE | USART_TIMING_CSSETUP_ONE | USART_TIMING_CSHOLD_ONE;

// SPI_USART->CTRL_SET |= USART_CTRL_SMSDELAY;

Expand Down Expand Up @@ -145,6 +147,14 @@ uint32_t sl_si91x_host_get_wake_indicator(void)

sl_status_t sl_si91x_host_init(sl_si91x_host_init_configuration * config)
{
#if SL_SPICTRL_MUX
sl_status_t status = sl_board_disable_display();
if (SL_STATUS_OK != status)
{
SILABS_LOG("sl_board_disable_display failed with error: %x", status);
return status;
}
#endif // SL_SPICTRL_MUX
init_config.rx_irq = config->rx_irq;
init_config.rx_done = config->rx_done;

Expand Down Expand Up @@ -175,8 +185,8 @@ sl_status_t sl_si91x_host_init(sl_si91x_host_init_configuration * config)
GPIO_PinModeSet(WAKE_INDICATOR_PIN.port, WAKE_INDICATOR_PIN.pin, gpioModeWiredOrPullDown, 0);

DMADRV_Init();
DMADRV_AllocateChannel(&rx_ldma_channel, NULL);
DMADRV_AllocateChannel(&tx_ldma_channel, NULL);
DMADRV_AllocateChannel((unsigned int *) &rx_ldma_channel, NULL);
bhmanda-silabs marked this conversation as resolved.
Show resolved Hide resolved
DMADRV_AllocateChannel((unsigned int *) &tx_ldma_channel, NULL);

return SL_STATUS_OK;
}
Expand Down
95 changes: 34 additions & 61 deletions examples/platform/silabs/efr32/rs911x/hal/efx_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,18 @@
#include "em_gpio.h"
#include "em_ldma.h"
#include "gpiointerrupt.h"
#include "spidrv.h"

#include "sl_board_control.h"
#include "sl_device_init_clocks.h"
#include "sl_device_init_hfxo.h"
#include "sl_spidrv_instances.h"
#include "sl_status.h"
#include "spidrv.h"

#include "silabs_utils.h"
#include "spi_multiplex.h"
#include "wfx_host_events.h"
#include "wfx_rsi.h"

#define DEFAULT_SPI_TRASFER_MODE 0
// Macro to drive semaphore block minimun 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
Expand All @@ -62,29 +59,33 @@
#endif // SL_BTLCTRL_MUX
#if SL_LCDCTRL_MUX
#include "sl_memlcd.h"
#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

#if defined(EFR32MG12)
#include "em_usart.h"

#include "sl_spidrv_exp_config.h"
#define SL_SPIDRV_HANDLE sl_spidrv_exp_handle

#elif defined(EFR32MG24)
#include "em_eusart.h"
#include "sl_spidrv_eusart_exp_config.h"
#include "spi_multiplex.h"
#else
#error "Unknown platform"
#endif

#if defined(EFR32MG24)
#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
#endif

#define CONCAT(A, B) (A##B)
#define SPI_CLOCK(N) CONCAT(cmuClock_USART, N)
// Macro to drive semaphore block minimun timer in milli seconds
#define RSI_SEM_BLOCK_MIN_TIMER_VALUE_MS (50)

#if SL_SPICTRL_MUX
StaticSemaphore_t spi_sem_peripheral;
Expand All @@ -97,16 +98,6 @@ static TaskHandle_t spiInitiatorTaskHandle = NULL;

static uint32_t dummy_buffer; /* Used for DMA - when results don't matter */

#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"
#else
#error "Unknown platform"
#endif

// variable to identify spi configured for expansion header
// EUSART configuration available on the SPIDRV
static bool spi_enabled = false;
Expand All @@ -129,7 +120,7 @@ void sl_wfx_host_gpio_init(void)
#if defined(EFR32MG24)
// Set CS pin to high/inactive
GPIO_PinModeSet(SL_SPIDRV_EUSART_EXP_CS_PORT, SL_SPIDRV_EUSART_EXP_CS_PIN, gpioModePushPull, PINOUT_SET);
#endif
#endif // EFR32MG24

GPIO_PinModeSet(WFX_RESET_PIN.port, WFX_RESET_PIN.pin, gpioModePushPull, PINOUT_SET);
GPIO_PinModeSet(WFX_SLEEP_CONFIRM_PIN.port, WFX_SLEEP_CONFIRM_PIN.pin, gpioModePushPull, PINOUT_CLEAR);
Expand Down Expand Up @@ -171,8 +162,6 @@ void sl_wfx_host_reset_chip(void)
vTaskDelay(pdMS_TO_TICKS(3));
}

void gpio_interrupt([[maybe_unused]] uint8_t interrupt_number) {}

/*****************************************************************
* @fn void rsi_hal_board_init(void)
* @brief
Expand Down Expand Up @@ -201,26 +190,12 @@ void rsi_hal_board_init(void)
sl_wfx_host_reset_chip();
}

void sl_si91x_host_enable_high_speed_bus()
{
// dummy function for wifi-sdk
}

#if SL_SPICTRL_MUX
void SPIDRV_SetBaudrate(uint32_t baudrate)
{
if (EUSART_BaudrateGet(MY_USART) == baudrate)
{
// EUSART synced to baudrate already
return;
}
EUSART_BaudrateSet(MY_USART, 0, baudrate);
}

sl_status_t sl_wfx_host_spi_cs_assert(void)
{
#if SL_SPICTRL_MUX
xSemaphoreTake(spi_sem_sync_hdl, portMAX_DELAY);

#endif // SL_SPICTRL_MUX
if (!spi_enabled) // Reduce sl_spidrv_init_instances
{
sl_spidrv_init_instances();
Expand All @@ -234,22 +209,23 @@ sl_status_t sl_wfx_host_spi_cs_assert(void)

sl_status_t sl_wfx_host_spi_cs_deassert(void)
{
sl_status_t status = SL_STATUS_OK;
if (spi_enabled)
{
if (ECODE_EMDRV_SPIDRV_OK != SPIDRV_DeInit(SL_SPIDRV_HANDLE))
status = SPIDRV_DeInit(SL_SPIDRV_HANDLE);
if (SL_STATUS_OK == status)
{
xSemaphoreGive(spi_sem_sync_hdl);
SILABS_LOG("%s error.", __func__);
return SL_STATUS_FAIL;
}
#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
spi_enabled = false;
spi_enabled = false;
}
}
#if SL_SPICTRL_MUX
xSemaphoreGive(spi_sem_sync_hdl);
return SL_STATUS_OK;
#endif // SL_SPICTRL_MUX
return status;
}
#endif // SL_SPICTRL_MUX

Expand Down Expand Up @@ -320,33 +296,30 @@ 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
if (sl_wfx_host_spi_cs_deassert() != SL_STATUS_OK)
{
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()))
sl_status_t status = sl_board_enable_display();
if (SL_STATUS_OK == status)
{
// sl_memlcd_refresh takes care of SPIDRV_Init()
status = sl_memlcd_refresh(sl_memlcd_get());
}
#if SL_SPICTRL_MUX
xSemaphoreGive(spi_sem_sync_hdl);
xSemaphoreGive(spi_sem_sync_hdl);
#endif // SL_SPICTRL_MUX
SILABS_LOG("%s error.", __func__);
return SL_STATUS_FAIL;
}
return SL_STATUS_OK;
return status;
}

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;
sl_status_t status = sl_board_disable_display();
#if SL_SPICTRL_MUX
xSemaphoreGive(spi_sem_sync_hdl);
#endif // SL_SPICTRL_MUX
return SL_STATUS_OK;
return status;
}
#endif // SL_LCDCTRL_MUX

Expand Down
Loading
Loading