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