freertos.rst 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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_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::
  16. E (25) FreeRTOS: FreeRTOS task should not return. Aborting now!
  17. abort() was called at PC 0x40085c53 on core 0
  18. .. only:: CONFIG_FREERTOS_UNICORE
  19. .. note::
  20. As {IDF_TARGET_NAME} is a single core SoC, the :ref:`CONFIG_FREERTOS_UNICORE` configuration is always set.
  21. .. _freertos-applications:
  22. ESP-IDF FreeRTOS Applications
  23. -----------------------------
  24. 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.
  25. - Typically, users would spawn the rest of their applications task from ``app_main``.
  26. - The ``app_main`` function is allowed to return at any point (i.e., before the application terminates).
  27. - The ``app_main`` function is called from the ``main`` task.
  28. The ``main`` task is one of multiple tasks that are automatically spawned by ESP-IDF during startup. These tasks are:
  29. .. only:: not CONFIG_FREERTOS_UNICORE
  30. .. list-table:: List of Tasks Created During Startup
  31. :widths: 25 25 5 50
  32. :header-rows: 1
  33. * - Task Name
  34. - Affinity
  35. - Priority
  36. - Description
  37. * - Main Task (``main``)
  38. - CPU0
  39. - 1
  40. - Task that simply calls ``app_main``. This task will self delete when ``app_main`` returns
  41. * - Idle Tasks (``IDLEx``)
  42. - CPU0 and CPU1
  43. - 0
  44. - Idle tasks created for (and pinned to) each CPU
  45. * - IPC Tasks (``ipcx``)
  46. - CPU0 and CPU1
  47. - 24
  48. - 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.
  49. .. only:: CONFIG_FREERTOS_UNICORE
  50. .. list-table:: List of Tasks Created During Startup
  51. :widths: 25 25 5 50
  52. :header-rows: 1
  53. * - Task Name
  54. - Affinity
  55. - Priority
  56. - Description
  57. * - Main Task (``main``)
  58. - CPU0
  59. - 1
  60. - Task that simply calls ``app_main``. This task will self delete when ``app_main`` returns
  61. * - Idle Tasks (``IDLEx``)
  62. - CPU0 and CPU1
  63. - 0
  64. - Idle task created for (and pinned to) each CPU
  65. .. note::
  66. Low priority numbers denote low priority tasks.
  67. Task API
  68. --------
  69. .. include-build-file:: inc/task.inc
  70. Queue API
  71. ---------
  72. .. include-build-file:: inc/queue.inc
  73. Semaphore API
  74. -------------
  75. .. include-build-file:: inc/semphr.inc
  76. Timer API
  77. ---------
  78. .. include-build-file:: inc/timers.inc
  79. Event Group API
  80. ---------------
  81. .. include-build-file:: inc/event_groups.inc
  82. Stream Buffer API
  83. -----------------
  84. .. include-build-file:: inc/stream_buffer.inc
  85. Message Buffer API
  86. ------------------
  87. .. include-build-file:: inc/message_buffer.inc