Skip to content

Commit

Permalink
[Silabs][EFR32] Adds fix for TC-DRLK-2.10 for the EFR32MG24 and WF200…
Browse files Browse the repository at this point in the history
… combo (#25127)

* Adds code to enable VCOM UART and MATTER shell

* Adds fix to omit header file unless needed

* Restyled by whitespace

* Restyled by clang-format

* Adds fix for compilation on BRD4161A

* Incorporate feedback

---------

Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
2 people authored and pull[bot] committed Feb 13, 2024
1 parent de4e569 commit 6027525
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 9 deletions.
53 changes: 52 additions & 1 deletion examples/platform/silabs/efr32/spi_multiplex.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,19 @@
* limitations under the License.
*/

#include "spi_multiplex.h"
#if (defined(EFR32MG24) && defined(WF200_WIFI))
#include "sl_wfx.h"
#endif /* EFR32MG24 && WF200_WIFI */

#include "dmadrv.h"
#include "em_bus.h"
#include "em_cmu.h"
#include "em_gpio.h"
#include "em_ldma.h"
#include "em_usart.h"
#if SL_WIFI
#include "spi_multiplex.h"
#endif /* SL_WIFI */

/****************************************************************************
* @fn void spi_drv_reinit()
Expand Down Expand Up @@ -163,3 +169,48 @@ void post_lcd_spi_transfer(void)
{
xSemaphoreGive(spi_sem_sync_hdl);
}
#if (defined(EFR32MG24) && defined(WF200_WIFI))
/****************************************************************************
* @fn void pre_uart_transfer()
* @brief
* Take a semaphore and setting GPIO, disable IRQ
* @param[in] None
* @return returns void
*****************************************************************************/
void pre_uart_transfer(void)
{
if (spi_sem_sync_hdl == NULL)
{
// UART is initialized before host SPI interface
// spi_sem_sync_hdl will not be initalized during execution
GPIO_PinModeSet(gpioPortA, 8, gpioModePushPull, 1);
return;
}
sl_wfx_disable_irq();
sl_wfx_host_disable_platform_interrupt();
if (xSemaphoreTake(spi_sem_sync_hdl, portMAX_DELAY) != pdTRUE)
{
return;
}
GPIO_PinModeSet(gpioPortA, 8, gpioModePushPull, 1);
}
/****************************************************************************
* @fn void post_uart_transfer()
* @brief
* Reset GPIO, enabled IRQ, release semaphore
* @param[in] None
* @return returns void
*****************************************************************************/
void post_uart_transfer(void)
{
if (spi_sem_sync_hdl == NULL)
{
return;
}
GPIO_PinModeSet(gpioPortA, 8, gpioModeInputPull, 1);
set_spi_baudrate(EXP_HDR);
xSemaphoreGive(spi_sem_sync_hdl);
sl_wfx_host_enable_platform_interrupt();
sl_wfx_enable_irq();
}
#endif /* EFR32MG24 && WF200_WIFI */
5 changes: 5 additions & 0 deletions examples/platform/silabs/efr32/spi_multiplex.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ void post_bootloader_spi_transfer(void);
void pre_lcd_spi_transfer(void);
void post_lcd_spi_transfer(void);

#if (defined(EFR32MG24) && defined(WF200_WIFI))
void pre_uart_transfer(void);
void post_uart_transfer(void);
#endif /* EFR32MG24 && WF200_WIFI */

#ifdef __cplusplus
}
#endif
25 changes: 17 additions & 8 deletions examples/platform/silabs/efr32/uart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ 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"
Expand Down Expand Up @@ -294,20 +297,26 @@ int16_t uartConsoleWrite(const char * Buf, uint16_t BufLength)
sl_power_manager_add_em_requirement(SL_POWER_MANAGER_EM1);
#endif

#if (defined(EFR32MG24) && defined(WF200_WIFI))
pre_uart_transfer();
#endif /* EFR32MG24 && WF200_WIFI */

// Use of ForceTransmit here. Transmit with DMA was causing errors with PW_RPC
// TODO Use DMA and find/fix what causes the issue with PW
if (UARTDRV_ForceTransmit(vcom_handle, (uint8_t *) Buf, BufLength) == ECODE_EMDRV_UARTDRV_OK)
{
#if defined(SL_CATALOG_POWER_MANAGER_PRESENT)
sl_power_manager_remove_em_requirement(SL_POWER_MANAGER_EM1);
#endif
return BufLength;
}
// TODO: Use DMA and find/fix what causes the issue with PW
Ecode_t ecode_status = UARTDRV_ForceTransmit(vcom_handle, (uint8_t *) Buf, BufLength);

#if (defined(EFR32MG24) && defined(WF200_WIFI))
post_uart_transfer();
#endif /* EFR32MG24 && WF200_WIFI */

#if defined(SL_CATALOG_POWER_MANAGER_PRESENT)
sl_power_manager_remove_em_requirement(SL_POWER_MANAGER_EM1);
#endif

if (ECODE_EMDRV_UARTDRV_OK == ecode_status)
{
return BufLength;
}
return UART_CONSOLE_ERR;
}

Expand Down

0 comments on commit 6027525

Please sign in to comment.