rtos.rst 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. .. _design_rtos:
  2. RTOS
  3. ====
  4. .. _design_rtos_overview:
  5. Overview
  6. --------
  7. In Nuclei N100 SDK, we have support three most-used RTOSes in the world,
  8. **FreeRTOS**, **UCOSII** and **RT-Thread** from China.
  9. If you want to use RTOS in your application, you can choose one
  10. of the supported RTOSes.
  11. .. note::
  12. When you want to develop RTOS application in Nuclei N100 SDK, please
  13. don't reconfigure ``SysTimer`` and ``SysTimer Software Interrupt``,
  14. since it is already used by RTOS portable code.
  15. .. _design_rtos_freertos:
  16. FreeRTOS
  17. --------
  18. `FreeRTOS`_ is a market-leading real-time operating system (RTOS) for
  19. microcontrollers and small microprocessors.
  20. In our FreeRTOS portable code, we are using ``SysTimer Interrupt`` as RTOS SysTick
  21. Interrupt, and using ``SysTimer Software Interrupt`` to do task switch.
  22. These two interrupts are kept as lowest level, and ``SysTimer Interrupt``
  23. is initialized as non-vector interrupt, and ``SysTimer Software Interrupt``
  24. is initialized as vector interrupt and interrupt handler implemented using asm code.
  25. If you want to learn about how to use FreeRTOS APIs, you need to go to
  26. its website to learn the FreeRTOS documentation in its website.
  27. In Nuclei N100 SDK, if you want to use **FreeRTOS** in your application, you need
  28. to add ``RTOS = FreeRTOS`` in your application Makefile.
  29. And in your application code, you need to do the following things:
  30. * Add FreeRTOS configuration file -> ``FreeRTOSConfig.h``
  31. * Include FreeRTOS header files
  32. .. note::
  33. * You can check the ``application\freertos\demo`` for reference
  34. * Current version of FreeRTOS used in Nuclei N100 SDK is ``V10.3.1``
  35. * If you want to change the OS ticks per seconds, you can change the ``configTICK_RATE_HZ``
  36. defined in ``FreeRTOSConfig.h``
  37. More information about FreeRTOS get started, please click
  38. https://www.freertos.org/FreeRTOS-quick-start-guide.html
  39. .. _design_rtos_ucosii:
  40. UCOSII
  41. ------
  42. `UCOSII`_ a priority-based preemptive real-time kernel for microprocessors,
  43. written mostly in the programming language C. It is intended for use in embedded systems.
  44. In our UCOSII portable code, we are using ``SysTimer Interrupt`` as RTOS SysTick
  45. Interrupt, and using ``SysTimer Software Interrupt`` to do task switch.
  46. If you want to learn about ``UCOSII``, please click https://www.micrium.com/books/ucosii/
  47. We are using the opensource version of UC-OS2 source code from https://github.com/SiliconLabs/uC-OS2,
  48. with optimized code for Nuclei RISC-V processors.
  49. In Nuclei N100 SDK, if you want to use **UCOSII** in your application, you need
  50. to add ``RTOS = UCOSII`` in your application Makefile.
  51. And in your application code, you need to do the following things:
  52. * Add UCOSII application configuration header file -> ``app_cfg.h`` and ``os_cfg.h``
  53. * Add application hook source file -> ``app_hooks.c``
  54. * Include UCOSII header files
  55. .. note::
  56. * You can check the ``application\ucosii\demo`` for reference
  57. * The UCOS-II application configuration template files can also be found in
  58. https://github.com/SiliconLabs/uC-OS2/tree/master/Cfg/Template
  59. * Current version of UCOSII used in Nuclei N100 SDK is ``V2.93.00``
  60. * If you want to change the OS ticks per seconds, you can change the ``OS_TICKS_PER_SEC``
  61. defined in ``os_cfg.h``
  62. .. warning::
  63. * For Nuclei N100 SDK release > v0.2.2, the UCOSII source code is replaced using the
  64. version from https://github.com/SiliconLabs/uC-OS2/, and application development
  65. for UCOSII is also changed, the ``app_cfg.h``, ``os_cfg.h`` and ``app_hooks.c`` files
  66. are required in application source code.
  67. .. _design_rtos_rtthread:
  68. RT-Thread
  69. ---------
  70. `RT-Thread`_ RT-Thread was born in 2006, it is an open source, neutral,
  71. and community-based real-time operating system (RTOS).
  72. RT-Thread is mainly written in C language, easy to understand and easy
  73. to port(can be quickly port to a wide range of mainstream MCUs and module chips).
  74. It applies object-oriented programming methods to real-time system design,
  75. making the code elegant, structured, modular, and very tailorable.
  76. In our support for RT-Thread, we get the source code of RT-Thread from a project
  77. called `RT-Thread Nano`_, which only provide kernel code of RT-Thread, which is easy
  78. to be integrated with Nuclei N100 SDK.
  79. In our RT-Thread portable code, we are using ``SysTimer Interrupt`` as RTOS SysTick
  80. Interrupt, and using ``SysTimer Software Interrupt`` to do task switch.
  81. And also the ``rt_hw_board_init`` function is implemented in our portable code.
  82. If you want to learn about ``RT-Thread``, please click:
  83. * For Chinese version, click https://www.rt-thread.org/document/site/
  84. * For English version, click https://github.com/RT-Thread/rt-thread#documentation
  85. In Nuclei N100 SDK, if you want to use **RT-Thread** in your application, you need
  86. to add ``RTOS = RTThread`` in your application Makefile.
  87. And in your application code, you need to do the following things:
  88. * Add RT-Thread application configuration header file -> ``rtconfig.h``
  89. * Include RT-Thread header files
  90. * If you want to enable RT-Thread MSH feature, just add ``RTTHREAD_MSH := 1`` in
  91. your application Makefile.
  92. .. note::
  93. * In RT-Thread, the ``main`` function is created as a RT-Thread thread,
  94. so you don't need to do any OS initialization work, it is done before ``main``
  95. * We also provide good support directly through RT-Thread official repo,
  96. you can check Nuclei processor support for RT-Thread in `RT-Thread BSP For Nuclei`_.
  97. .. _FreeRTOS: https://www.freertos.org/
  98. .. _UCOSII: https://www.micrium.com/
  99. .. _RT_Thread: https://www.rt-thread.org/
  100. .. _RT-Thread Nano: https://github.com/RT-Thread/rtthread-nano
  101. .. _RT-Thread BSP For Nuclei: https://github.com/RT-Thread/rt-thread/tree/master/bsp/nuclei/