The tickless feature of FreeRTOS allows the device to sleep for peroids longer than the predefined OS tick rate.
This is useful when no tasks are ready to execute for more than one OS tick. The benefit of this is lower power consumption.
The tickless feature is implemented using a timer, configured with the desired timeout value, to wake the device. The same timer is also used to generate the system tick, so that time is kept in the optimal way, eliminating drift in most cases. If some other source wakes the device before the sleep period is complete, but after more than one OS tick, there will be a slight drift, as the timers count value must be corrected.
Functions | |
void | vPortSuppressTicksAndSleep (TickType_t xExpectedIdleTime) |
Timer Constants | |
#define | TIMER_HZ ( configCPU_CLOCK_HZ ) |
Frequency of timer. More... | |
#define | TIMER_RELOAD_VALUE_ONE_TICK ( TIMER_HZ / configTICK_RATE_HZ ) |
Value per os tick of timer. More... | |
#define | TIMER_MAX_COUNT ( 0xffffffff ) |
Maximum value of timer. More... | |
#define | TIMER_MAX_POSSIBLE_SUPPRESSED_TICKS ( TIMER_MAX_COUNT / TIMER_RELOAD_VALUE_ONE_TICK ) |
Maximum possible suppressed ticks with timer. More... | |
Global instance and prototypes | |
static struct tc_module | tc |
Timer instance. More... | |
bool volatile | tickless_enable = false |
Global variable to control tickless operation. More... | |
bool volatile | tickless_mode = false |
void | xPortSysTickHandler (void) |
External declaration of freeRTOS SysTick handler. More... | |
void | vPortSetupTimerInterrupt (void) |
Function for setting up timer. More... | |
static void | empty_callback (struct tc_module *const module_inst) |
Prototype for empty_callback for sleep timer. More... | |
#define TIMER_HZ ( configCPU_CLOCK_HZ ) |
Frequency of timer.
#define TIMER_MAX_COUNT ( 0xffffffff ) |
Maximum value of timer.
#define TIMER_MAX_POSSIBLE_SUPPRESSED_TICKS ( TIMER_MAX_COUNT / TIMER_RELOAD_VALUE_ONE_TICK ) |
Maximum possible suppressed ticks with timer.
Referenced by vPortSuppressTicksAndSleep().
#define TIMER_RELOAD_VALUE_ONE_TICK ( TIMER_HZ / configTICK_RATE_HZ ) |
Value per os tick of timer.
Referenced by vPortSetupTimerInterrupt(), and vPortSuppressTicksAndSleep().
|
static |
Prototype for empty_callback for sleep timer.
Referenced by vPortSuppressTicksAndSleep().
void vPortSetupTimerInterrupt | ( | void | ) |
Function for setting up timer.
References tc_config::clock_prescaler, tc_config::counter_size, tc_config::run_in_standby, tc, TC_CALLBACK_CC_CHANNEL0, TC_CLOCK_PRESCALER_DIV1, TC_COUNTER_SIZE_32BIT, tc_enable(), tc_enable_callback(), tc_get_config_defaults(), tc_init(), tc_register_callback(), tc_set_top_value(), TC_WAVE_GENERATION_MATCH_FREQ, TIMER_RELOAD_VALUE_ONE_TICK, tc_config::wave_generation, and xPortSysTickHandler().
Referenced by vPortSuppressTicksAndSleep().
void vPortSuppressTicksAndSleep | ( | TickType_t | xExpectedIdleTime | ) |
References eAbortSleep, empty_callback(), eTaskConfirmSleepModeStatus(), tc, TC_CALLBACK_CC_CHANNEL0, tc_disable_callback(), tc_enable_callback(), tc_get_count_value(), tc_register_callback(), tc_set_count_value(), tc_set_top_value(), tc_unregister_callback(), tickless_enable, tickless_mode, TIMER_MAX_POSSIBLE_SUPPRESSED_TICKS, TIMER_RELOAD_VALUE_ONE_TICK, vPortSetupTimerInterrupt(), vTaskStepTick(), and xPortSysTickHandler().
void xPortSysTickHandler | ( | void | ) |
External declaration of freeRTOS SysTick handler.
Referenced by vPortSetupTimerInterrupt(), and vPortSuppressTicksAndSleep().
|
static |
Timer instance.
Referenced by vPortSetupTimerInterrupt(), and vPortSuppressTicksAndSleep().
Global variable to control tickless operation.
Referenced by about_task(), and vPortSuppressTicksAndSleep().
Referenced by vPortSuppressTicksAndSleep().