freertos.rst 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. FreeRTOS
  2. ========
  3. Overview
  4. --------
  5. This section contains documentation of FreeRTOS types, functions, and macros. It is automatically generated from FreeRTOS header files.
  6. .. note::
  7. ESP-IDF FreeRTOS is based on Vanilla FreeRTOS v10.4.3
  8. - For more information about the SMP changes of ESP-IDF FreeRTOS, see :doc:`/api-guides/freertos-smp`
  9. - For more information about the features added to ESP-IDF FreeRTOS, see :doc:`/api-reference/system/freertos_additions`.
  10. Configuration
  11. -------------
  12. Vanilla FreeRTOS allows ports and applications to configure the kernel by adding various ``#define config...`` macros to ``FreeRTOSConfig.h``. Through these macros, the kernel's scheduling behavior and various kernel features can be enabled or disabled. **However, in ESP-IDF FreeRTOS, the ``FreeRTOSConfig.h`` file is considered a private and must not be modified by users**. Any FreeRTOS configuration that is exposed to the user will be done so via menuconfig.
  13. ESP-IDF FreeRTOS can be configured in the project configuration menu (``idf.py menuconfig``) under ``Component Config/FreeRTOS``. The following section highlights some of the ESP-IDF FreeRTOS configuration options. For a full list of ESP-IDF FreeRTOS configurations, see :doc:`/api-reference/kconfig`
  14. - :ref:`CONFIG_FREERTOS_UNICORE` will run ESP-IDF FreeRTOS only on CPU0. Note that this is **not equivalent to running Vanilla FreeRTOS**. Futhermore, this option may affect behavior of components other than :component:`freertos`. For more details regarding the effects of running ESP-IDF FreeRTOS on a single core, refer to :ref:`freertos-smp-single-core`. Alternatively, users can also search for occurrences of ``CONFIG_FREERTOS_UNICORE`` in the ESP-IDF components.
  15. - :ref:`CONFIG_FREERTOS_ASSERT_ON_UNTESTED_FUNCTION` will trigger a halt in functions in ESP-IDF FreeRTOS that have not been fully tested in an SMP context.
  16. - :ref:`CONFIG_FREERTOS_TASK_FUNCTION_WRAPPER` will enclose all task functions within a wrapper function. In the case that a task function mistakenly returns (i.e. does not call :cpp:func:`vTaskDelete`), the call flow will return to the wrapper function. The wrapper function will then log an error and abort the application, as illustrated below::
  17. E (25) FreeRTOS: FreeRTOS task should not return. Aborting now!
  18. abort() was called at PC 0x40085c53 on core 0
  19. .. only:: CONFIG_FREERTOS_UNICORE
  20. .. note::
  21. As {IDF_TARGET_NAME} is a single core SoC, the :ref:`CONFIG_FREERTOS_UNICORE` configuration is always set.
  22. .. _freertos-applications:
  23. ESP-IDF FreeRTOS Applications
  24. -----------------------------
  25. Unlike Vanilla FreeRTOS, users must not call :cpp:func:`vTaskStartScheduler`. Instead, ESP-IDF FreeRTOS is started automatically. The entry point is a user defined ``void app_main(void)`` function.
  26. - Typically, users would spawn the rest of their applications task from ``app_main``.
  27. - The ``app_main`` function is allowed to return at any point (i.e., before the application terminates).
  28. - The ``app_main`` function is called from the ``main`` task.
  29. The ``main`` task is one of multiple tasks that are automatically spawned by ESP-IDF during startup. These tasks are:
  30. .. only:: not CONFIG_FREERTOS_UNICORE
  31. .. list-table:: List of Tasks Created During Startup
  32. :widths: 25 25 5 50
  33. :header-rows: 1
  34. * - Task Name
  35. - Affinity
  36. - Priority
  37. - Description
  38. * - Main Task (``main``)
  39. - CPU0
  40. - 1
  41. - Task that simply calls ``app_main``. This task will self delete when ``app_main`` returns
  42. * - Idle Tasks (``IDLEx``)
  43. - CPU0 and CPU1
  44. - 0
  45. - Idle tasks created for (and pinned to) each CPU
  46. * - IPC Tasks (``ipcx``)
  47. - CPU0 and CPU1
  48. - 24
  49. - IPC tasks created for (and pinned to ) each CPU. IPC tasks are used to implement the IPC feature. See :doc:`/api-reference/system/ipc` for more details.
  50. .. only:: CONFIG_FREERTOS_UNICORE
  51. .. list-table:: List of Tasks Created During Startup
  52. :widths: 25 25 5 50
  53. :header-rows: 1
  54. * - Task Name
  55. - Affinity
  56. - Priority
  57. - Description
  58. * - Main Task (``main``)
  59. - CPU0
  60. - 1
  61. - Task that simply calls ``app_main``. This task will self delete when ``app_main`` returns
  62. * - Idle Tasks (``IDLEx``)
  63. - CPU0 and CPU1
  64. - 0
  65. - Idle task created for (and pinned to) each CPU
  66. .. note::
  67. Low priority numbers denote low priority tasks.
  68. Task API
  69. --------
  70. .. include-build-file:: inc/task.inc
  71. Queue API
  72. ---------
  73. .. include-build-file:: inc/queue.inc
  74. Semaphore API
  75. -------------
  76. .. include-build-file:: inc/semphr.inc
  77. Timer API
  78. ---------
  79. .. include-build-file:: inc/timers.inc
  80. Event Group API
  81. ---------------
  82. .. include-build-file:: inc/event_groups.inc
  83. Stream Buffer API
  84. -----------------
  85. .. include-build-file:: inc/stream_buffer.inc
  86. Message Buffer API
  87. ------------------
  88. .. include-build-file:: inc/message_buffer.inc