hooks.rst 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. .. _hooks_api_reference:
  2. FreeRTOS Hooks
  3. ==============
  4. Overview
  5. --------
  6. FreeRTOS consists of Idle Hooks and Tick Hooks which allow for application
  7. specific funtiionality to be added to the Idle Task and Tick Interrupt. The
  8. ESP32 is dual core in nature, hence the ESP-IDF provides its own Idle and Tick
  9. Hooks that are dual core compatible in addition to the hooks provided by Vanilla
  10. FreeRTOS.
  11. Vanilla FreeRTOS Hooks
  12. ----------------------
  13. Idle and Tick Hooks in vanilla FreeRTOS are implemented by defining
  14. implementations for the functions ``vApplicationIdleHook`` and
  15. ``vApplicationTickHook`` respectively somewhere in the application. Vanilla
  16. FreeRTOS will run the user defined Idle Hook every iteration of the Idle Task,
  17. whereas the user defined Tick Hook will run once per tick interrupt (given that
  18. there are no pended ticks).
  19. Due to vanilla FreeRTOS being designed for single core, ``vApplicationIdleHook``
  20. and ``vApplicationTickHook`` will be run in both cores on the ESP32. In
  21. other words, the same Idle Hook and Tick Hook are used for both cores.
  22. To enable the vanilla FreeRTOS hooks in ESP-IDF, :ref:`CONFIG_FREERTOS_LEGACY_HOOKS`
  23. must be enabled in ``make menuconfig``. :ref:`CONFIG_FREERTOS_LEGACY_IDLE_HOOK`
  24. and :ref:`CONFIG_FREERTOS_LEGACY_TICK_HOOK` should also be enabled.
  25. ESP-IDF Idle and Tick Hooks
  26. ---------------------------
  27. Due to the dual core nature of the ESP32, it may be necessary for some
  28. applications to have seperate Idle Hooks for each core. Furthermore, it may
  29. be necessary for Idle and Tick Hooks to have execute multiple functionalities
  30. that are configurable at run time. Therefore the ESP-IDF provides it's own Idle
  31. and Tick Hooks in addition to the hooks provided by Vanilla FreeRTOS.
  32. The ESP-IDF Hooks do not operate in the same way as Vanilla FreeRTOS Hooks
  33. where users provide a definition for each of the hooks. Instead, the ESP-IDF
  34. Hooks are predefined to call a list of user registered callbacks specific to
  35. each core. Users can register and deregister callbacks which are run on the
  36. Idle or Tick Hook of a specific core.
  37. API Reference
  38. -------------
  39. .. include:: /_build/inc/esp_freertos_hooks.inc