Skip to content

Commit

Permalink
[Silabs] Enabling the sleepy device for EFR32 and WF200 combo (#25690)
Browse files Browse the repository at this point in the history
* enabling the sleepy device for EFR32 and rs911x combo

* Restyled by whitespace

* Restyled by clang-format

* Restyled by gn

* addressing review comments

* inital wf200 changes

* Added changes for power save mode WF200

* Adds fix for power save mode in WF200

* Revert "addressing review comments"

This reverts commit 5909765.

* Revert "Restyled by gn"

This reverts commit 8156ea9.

* Revert "Restyled by clang-format"

This reverts commit 6786158.

* Revert "Restyled by whitespace"

This reverts commit d35ecfd.

* Revert "enabling the sleepy device for EFR32 and rs911x combo"

This reverts commit 2967ff0.

* Removed the unwanted line

* Adds restyle changes

* Adds fix for function name changes

---------

Co-authored-by: Chirag Bansal <chirag.bansal@silabs.com>
Co-authored-by: Restyled.io <commits@restyled.io>
Co-authored-by: chirag-silabs <100861685+chirag-silabs@users.noreply.github.com>
  • Loading branch information
4 people authored Mar 21, 2023
1 parent abac35a commit deea7f9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
29 changes: 21 additions & 8 deletions examples/platform/silabs/efr32/wf200/efr_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,9 @@
#include <stdlib.h>
#include <string.h>

#include "AppConfig.h"
#include "FreeRTOS.h"
#include "semphr.h"
#ifdef SLEEP_ENABLED
#include "sl_power_manager.h"
#endif
#include "AppConfig.h"

#include "gpiointerrupt.h"

Expand All @@ -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;
Expand Down Expand Up @@ -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:
Expand All @@ -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;
Expand All @@ -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;
}

Expand All @@ -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,
Expand All @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions examples/platform/silabs/efr32/wf200/host_if.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit deea7f9

Please sign in to comment.