diff --git a/examples/platform/silabs/efr32/wf200/efr_spi.c b/examples/platform/silabs/efr32/wf200/efr_spi.c index f2a5403cded85a..5d75638b54f49a 100644 --- a/examples/platform/silabs/efr32/wf200/efr_spi.c +++ b/examples/platform/silabs/efr32/wf200/efr_spi.c @@ -33,12 +33,9 @@ #include #include +#include "AppConfig.h" #include "FreeRTOS.h" #include "semphr.h" -#ifdef SLEEP_ENABLED -#include "sl_power_manager.h" -#endif -#include "AppConfig.h" #include "gpiointerrupt.h" @@ -48,6 +45,10 @@ #include "sl_wfx_task.h" #include "wfx_host_events.h" +#if defined(SL_CATALOG_POWER_MANAGER_PRESENT) +#include "sl_power_manager.h" +#endif + #if defined(EFR32MG24) #include "spi_multiplex.h" StaticSemaphore_t spi_sem_peripharal; @@ -166,7 +167,7 @@ sl_status_t sl_wfx_host_spi_cs_deassert() } /**************************************************************************** - * @fn static bool rx_dma_complete(unsigned int channel, unsigned int sequenceNo, void *userParam) + * @fn static bool dma_complete(unsigned int channel, unsigned int sequenceNo, void *userParam) * @brief * function called when the DMA complete * @param[in] channel: @@ -175,7 +176,7 @@ sl_status_t sl_wfx_host_spi_cs_deassert() * @return returns true if suucessful, * false otherwise *****************************************************************************/ -static bool rx_dma_complete(unsigned int channel, unsigned int sequenceNo, void * userParam) +static bool dma_complete(unsigned int channel, unsigned int sequenceNo, void * userParam) { (void) channel; (void) sequenceNo; @@ -185,6 +186,10 @@ static bool rx_dma_complete(unsigned int channel, unsigned int sequenceNo, void xSemaphoreGiveFromISR(spi_sem, &xHigherPriorityTaskWoken); portYIELD_FROM_ISR(xHigherPriorityTaskWoken); +#if defined(SL_CATALOG_POWER_MANAGER_PRESENT) + sl_power_manager_remove_em_requirement(SL_POWER_MANAGER_EM1); +#endif + return true; } @@ -198,9 +203,13 @@ static bool rx_dma_complete(unsigned int channel, unsigned int sequenceNo, void *****************************************************************************/ void receiveDMA(uint8_t * buffer, uint16_t buffer_length) { +#if defined(SL_CATALOG_POWER_MANAGER_PRESENT) + sl_power_manager_add_em_requirement(SL_POWER_MANAGER_EM1); +#endif + // Start receive DMA. DMADRV_PeripheralMemory(rx_dma_channel, MY_USART_RX_SIGNAL, (void *) buffer, (void *) &(MY_USART->RXDATA), true, buffer_length, - dmadrvDataSize1, rx_dma_complete, NULL); + dmadrvDataSize1, dma_complete, NULL); // Start transmit DMA. DMADRV_MemoryPeripheral(tx_dma_channel, MY_USART_TX_SIGNAL, (void *) &(MY_USART->TXDATA), (void *) &(dummy_tx_data), false, @@ -217,10 +226,14 @@ void receiveDMA(uint8_t * buffer, uint16_t buffer_length) *****************************************************************************/ void transmitDMA(uint8_t * buffer, uint16_t buffer_length) { +#if defined(SL_CATALOG_POWER_MANAGER_PRESENT) + sl_power_manager_add_em_requirement(SL_POWER_MANAGER_EM1); +#endif + // Receive DMA runs only to initiate callback // Start receive DMA. DMADRV_PeripheralMemory(rx_dma_channel, MY_USART_RX_SIGNAL, &dummy_rx_data, (void *) &(MY_USART->RXDATA), false, buffer_length, - dmadrvDataSize1, rx_dma_complete, NULL); + dmadrvDataSize1, dma_complete, NULL); // Start transmit DMA. DMADRV_MemoryPeripheral(tx_dma_channel, MY_USART_TX_SIGNAL, (void *) &(MY_USART->TXDATA), (void *) buffer, true, buffer_length, dmadrvDataSize1, NULL, NULL); diff --git a/examples/platform/silabs/efr32/wf200/host_if.cpp b/examples/platform/silabs/efr32/wf200/host_if.cpp index 7e2753a9cdee80..30e2ec1cd53f31 100644 --- a/examples/platform/silabs/efr32/wf200/host_if.cpp +++ b/examples/platform/silabs/efr32/wf200/host_if.cpp @@ -578,6 +578,11 @@ static void wfx_events_task(void * p_arg) { wfx_ipv6_notify(1); hasNotifiedIPV6 = true; + + // send device to power save mode + sl_wfx_set_power_mode(WFM_PM_MODE_DTIM, WFM_PM_POLL_FAST_PS, 0); + sl_wfx_enable_device_power_save(); + if (!hasNotifiedWifiConnectivity) { wfx_connected_notify(CONNECTION_STATUS_SUCCESS, &ap_mac);