The example shows calls being made to several functions. Only vTaskStepTick() is part of the FreeRTOS API. The other functions are specific to the clocks and power saving modes available on the hardware in use, and as such, must be provided by the application writer.
/* First define the portSUPPRESS_TICKS_AND_SLEEP(). The parameter is the time, in ticks, until the kernel next needs to execute. */ #define portSUPPRESS_TICKS_AND_SLEEP( xIdleTime ) vApplicationSleep( xIdleTime ) /* Define the function that is called by portSUPPRESS_TICKS_AND_SLEEP(). */ void vApplicationSleep( TickType_t xExpectedIdleTime ) { unsigned long ulLowPowerTimeBeforeSleep, ulLowPowerTimeAfterSleep; /* Read the current time from a time source that will remain operational while the microcontroller is in a low power state. */ ulLowPowerTimeBeforeSleep = ulGetExternalTime(); /* Stop the timer that is generating the tick interrupt. */ prvStopTickInterruptTimer(); /* Configure an interrupt to bring the microcontroller out of its low power state at the time the kernel next needs to execute. The interrupt must be generated from a source that is remains operational when the microcontroller is in a low power state. */ vSetWakeTimeInterrupt( xExpectedIdleTime ); /* Enter the low power state. */ prvSleep(); /* Determine how long the microcontroller was actually in a low power state for, which will be less than xExpectedIdleTime if the microcontroller was brought out of low power mode by an interrupt other than that configured by the vSetWakeTimeInterrupt() call. Note that the scheduler is suspended before portSUPPRESS_TICKS_AND_SLEEP() is called, and resumed when portSUPPRESS_TICKS_AND_SLEEP() returns. Therefore no other tasks will execute until this function completes. */ ulLowPowerTimeAfterSleep = ulGetExternalTime(); /* Correct the kernels tick count to account for the time the microcontroller spent in its low power state. */ vTaskStepTick( ulLowPowerTimeAfterSleep - ulLowPowerTimeBeforeSleep ); /* Restart the timer that is generating the tick interrupt. */ prvStartTickInterruptTimer(); }
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|
Latest News
NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS. Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019 Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed. View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS. Careers
FreeRTOS and other embedded software careers at AWS. FreeRTOS Partners
|