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][EFR32] Adds fix for TC-DRLK-2.10 for the EFR32MG24 and WF200 combo #25127

Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
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
51 changes: 50 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,17 @@
* 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"
#include "spi_multiplex.h"
jmartinez-silabs marked this conversation as resolved.
Show resolved Hide resolved

/****************************************************************************
* @fn void spi_drv_reinit()
Expand Down Expand Up @@ -163,3 +167,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