1*61c4878aSAndroid Build Coastguard Worker.. _module-pw_chrono_freertos: 2*61c4878aSAndroid Build Coastguard Worker 3*61c4878aSAndroid Build Coastguard Worker------------------ 4*61c4878aSAndroid Build Coastguard Workerpw_chrono_freertos 5*61c4878aSAndroid Build Coastguard Worker------------------ 6*61c4878aSAndroid Build Coastguard Worker``pw_chrono_freertos`` is a collection of ``pw_chrono`` backends that are 7*61c4878aSAndroid Build Coastguard Workerimplemented using FreeRTOS. 8*61c4878aSAndroid Build Coastguard Worker 9*61c4878aSAndroid Build Coastguard Worker.. warning:: 10*61c4878aSAndroid Build Coastguard Worker This module is still under construction, the API is not yet stable. 11*61c4878aSAndroid Build Coastguard Worker 12*61c4878aSAndroid Build Coastguard WorkerSystemClock backend 13*61c4878aSAndroid Build Coastguard Worker------------------- 14*61c4878aSAndroid Build Coastguard WorkerThe FreeRTOS based ``system_clock`` backend implements the 15*61c4878aSAndroid Build Coastguard Worker``pw_chrono:system_clock`` facade by using ``xTaskGetTickCountFromISR()`` and 16*61c4878aSAndroid Build Coastguard Worker``xTaskGetTickCount()`` based on the current context. An InterruptSpinLock is 17*61c4878aSAndroid Build Coastguard Workerused to manage overflows in a thread and interrupt safe manner to produce a 18*61c4878aSAndroid Build Coastguard Workersigned 64 bit timestamp. 19*61c4878aSAndroid Build Coastguard Worker 20*61c4878aSAndroid Build Coastguard WorkerThe ``SystemClock::now()`` must be used more than once per overflow of the 21*61c4878aSAndroid Build Coastguard Workernative FreeRTOS ``xTaskGetTickCount*()`` overflow. Note that this duration may 22*61c4878aSAndroid Build Coastguard Workervary if ``portSUPPRESS_TICKS_AND_SLEEP()``, ``vTaskStepTick()``, and/or 23*61c4878aSAndroid Build Coastguard Worker``xTaskCatchUpTicks()`` are used. 24*61c4878aSAndroid Build Coastguard Worker 25*61c4878aSAndroid Build Coastguard WorkerSystemTimer backend 26*61c4878aSAndroid Build Coastguard Worker------------------- 27*61c4878aSAndroid Build Coastguard WorkerThe FreeRTOS based ``system_timer`` backend implements the 28*61c4878aSAndroid Build Coastguard Worker``pw_chrono:system_timer`` facade by using FreeRTOS's Software Timers API. 29*61c4878aSAndroid Build Coastguard Worker``pw::chrono::SystemTimer`` instances use ``StaticTimer_t`` & 30*61c4878aSAndroid Build Coastguard Worker``xTimerCreateStatic``, dynamic memory allocation is never used. This means 31*61c4878aSAndroid Build Coastguard Workerthat both ``#define configUSE_TIMERS 1`` and 32*61c4878aSAndroid Build Coastguard Worker``#define configSUPPORT_STATIC_ALLOCATION 1`` must be set in the FreeRTOS 33*61c4878aSAndroid Build Coastguard Workerconfiguration. 34*61c4878aSAndroid Build Coastguard Worker 35*61c4878aSAndroid Build Coastguard WorkerThis also means that FreeRTOS's ``Timer Service Daemon Task`` is used and must 36*61c4878aSAndroid Build Coastguard Workerbe configured appropriately by the user through ``configTIMER_TASK_PRIORITY``, 37*61c4878aSAndroid Build Coastguard Worker``configTIMER_QUEUE_LENGTH``, and ``configTIMER_TASK_STACK_DEPTH``. 38*61c4878aSAndroid Build Coastguard Worker 39*61c4878aSAndroid Build Coastguard WorkerBuild targets 40*61c4878aSAndroid Build Coastguard Worker------------- 41*61c4878aSAndroid Build Coastguard WorkerThe GN build for ``pw_chrono_freertos`` has one target: ``system_clock``. 42*61c4878aSAndroid Build Coastguard WorkerThe ``system_clock`` target provides the 43*61c4878aSAndroid Build Coastguard Worker``pw_chrono_backend/system_clock_config.h`` and ``pw_chrono_freertos/config.h`` 44*61c4878aSAndroid Build Coastguard Workerheaders and the backend for the ``pw_chrono:system_clock``. 45