Skip to content

Commit

Permalink
fix(BLE): FreeRTOS-tickless (#985)
Browse files Browse the repository at this point in the history
Co-authored-by: EricB-ADI <[email protected]>
  • Loading branch information
EricB-ADI and EricB-ADI authored Apr 12, 2024
1 parent 1644294 commit 52174ec
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 25 deletions.
19 changes: 10 additions & 9 deletions Examples/MAX32655/Bluetooth/BLE_FreeRTOS/freertos_tickless.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,25 +202,26 @@ void vPortSuppressTicksAndSleep(TickType_t xExpectedIdleTime)
if (schTimerActive) {
/* Stop the BLE scheduler timer */
PalTimerStop();

/* Shutdown BB hardware */
PalBbDisable();
}

/*
Shutdown BB hardware
*/

PalBbForceDisable();

LED_Off(SLEEP_LED);
LED_Off(DEEPSLEEP_LED);

MXC_LP_EnterStandbyMode();

LED_On(DEEPSLEEP_LED);
LED_On(SLEEP_LED);

if (schTimerActive) {
/* Enable and restore the BB hardware */
PalBbEnable();

PalBbRestore();
/* Enable and restore the BB hardware */
PalBbEnable();
PalBbRestore();

if (schTimerActive) {
/* Restore the BB counter */
MXC_WUT_RestoreBBClock(MXC_WUT0, BB_CLK_RATE_HZ);

Expand Down
17 changes: 9 additions & 8 deletions Examples/MAX32665/Bluetooth/BLE_FreeRTOS/freertos_tickless.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include "pal_timer.h"
#include "pal_uart.h"
#include "pal_bb.h"
#include "wsf_trace.h"

#define MAX_WUT_TICKS (configRTC_TICK_RATE_HZ) /* Maximum deep sleep time, units of 32 kHz ticks */
#define MIN_WUT_TICKS 100 /* Minimum deep sleep time, units of 32 kHz ticks */
Expand Down Expand Up @@ -239,6 +240,7 @@ void vPortSuppressTicksAndSleep(TickType_t xExpectedIdleTime)
}

/* Disable SysTick */

SysTick->CTRL &= ~(SysTick_CTRL_ENABLE_Msk);

/* Enable wakeup from WUT */
Expand Down Expand Up @@ -290,11 +292,11 @@ void vPortSuppressTicksAndSleep(TickType_t xExpectedIdleTime)
if (schTimerActive) {
/* Stop the BLE scheduler timer */
PalTimerStop();

/* Shutdown BB hardware */
PalBbDisable();
}

/* Shutdown BB hardware */
PalBbDisable();

LED_Off(SLEEP_LED);
LED_Off(DEEPSLEEP_LED);

Expand All @@ -303,12 +305,11 @@ void vPortSuppressTicksAndSleep(TickType_t xExpectedIdleTime)
LED_On(DEEPSLEEP_LED);
LED_On(SLEEP_LED);

if (schTimerActive) {
/* Enable and restore the BB hardware */
PalBbEnable();

PalBbRestore();
/* Enable and restore the BB hardware */
PalBbEnable();
PalBbRestore();

if (schTimerActive) {
/* Restore the BB counter */
MXC_WUT_RestoreBBClock(BB_CLK_RATE_HZ);

Expand Down
15 changes: 7 additions & 8 deletions Examples/MAX32690/Bluetooth/BLE_FreeRTOS/freertos_tickless.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,11 @@ void vPortSuppressTicksAndSleep(TickType_t xExpectedIdleTime)
if (schTimerActive) {
/* Stop the BLE scheduler timer */
PalTimerStop();

/* Shutdown BB hardware */
PalBbDisable();
}

/* Shutdown BB hardware */
PalBbDisable();

LED_Off(SLEEP_LED);
LED_Off(DEEPSLEEP_LED);

Expand All @@ -215,12 +215,11 @@ void vPortSuppressTicksAndSleep(TickType_t xExpectedIdleTime)
LED_On(DEEPSLEEP_LED);
LED_On(SLEEP_LED);

if (schTimerActive) {
/* Enable and restore the BB hardware */
PalBbEnable();

PalBbRestore();
/* Enable and restore the BB hardware */
PalBbEnable();
PalBbRestore();

if (schTimerActive) {
/* Restore the BB counter */
MXC_WUT_RestoreBBClock(BB_CLK_RATE_HZ);

Expand Down
Binary file modified Libraries/BlePhy/MAX32655/libphy.a
Binary file not shown.
10 changes: 10 additions & 0 deletions Libraries/Cordio/platform/include/pal_bb.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,16 @@ void PalBbEnable(void);
/*************************************************************************************************/
void PalBbDisable(void);

/*************************************************************************************************/
/*!
* \brief Force disable the BB hardware irrespective of reference count state.
*
* This routine signals the BB hardware to go into low power (disable power and clocks) after all
* BB operations have been disabled.
*/
/*************************************************************************************************/
void PalBbForceDisable(void);

/*************************************************************************************************/
/*!
* \brief Load BB timing configuration.
Expand Down

0 comments on commit 52174ec

Please sign in to comment.