FreeRTOSConfig.h 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. /*
  2. * Copyright (c) 2022 OpenLuat & AirM2M
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  5. * this software and associated documentation files (the "Software"), to deal in
  6. * the Software without restriction, including without limitation the rights to
  7. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  8. * the Software, and to permit persons to whom the Software is furnished to do so,
  9. * subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in all
  12. * copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  16. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  17. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  18. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  19. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  20. */
  21. /*
  22. * FreeRTOS Kernel V10.2.1
  23. * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
  24. *
  25. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  26. * this software and associated documentation files (the "Software"), to deal in
  27. * the Software without restriction, including without limitation the rights to
  28. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  29. * the Software, and to permit persons to whom the Software is furnished to do so,
  30. * subject to the following conditions:
  31. *
  32. * The above copyright notice and this permission notice shall be included in all
  33. * copies or substantial portions of the Software.
  34. *
  35. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  36. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  37. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  38. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  39. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  40. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  41. *
  42. * http://www.FreeRTOS.org
  43. * http://aws.amazon.com/freertos
  44. *
  45. * 1 tab == 4 spaces!
  46. */
  47. #ifndef FREERTOS_CONFIG_H
  48. #define FREERTOS_CONFIG_H
  49. /*-----------------------------------------------------------
  50. * this is a template configuration files
  51. *
  52. * These definitions should be adjusted for your particular hardware and
  53. * application requirements.
  54. *
  55. * These parameters and more are described within the 'configuration' section of the
  56. * FreeRTOS API documentation available on the FreeRTOS.org web site.
  57. *
  58. * See http://www.freertos.org/a00110.html
  59. *----------------------------------------------------------*/
  60. /* Ensure stdint is only used by the compiler, and not the assembler. */
  61. #if defined(__ICCARM__) || defined(__CC_ARM) || defined(__GNUC__)
  62. #include <stdint.h>
  63. extern uint32_t SystemCoreClock;
  64. #endif
  65. #ifdef __AIR105_BSP__
  66. #include "../chip/include/air105.h"
  67. #endif
  68. /* CMSIS-RTOSv2 defines 56 levels of priorities. To be able to use them
  69. * all and avoid application misbehavior, configUSE_PORT_OPTIMISED_TASK_SELECTION
  70. * must be set to 0 and configMAX_PRIORITIES to 56
  71. *
  72. */
  73. /* #define configUSE_PORT_OPTIMISED_TASK_SELECTION 0*/
  74. /* #define configMAX_PRIORITIES ( 56 ) */
  75. #define configUSE_PREEMPTION 1
  76. #define configUSE_IDLE_HOOK 1
  77. #define configUSE_TICK_HOOK 0
  78. #define configMAX_PRIORITIES (7)
  79. #define configSUPPORT_STATIC_ALLOCATION 0
  80. #define configCPU_CLOCK_HZ (SystemCoreClock)
  81. #define configTICK_RATE_HZ ((TickType_t)100)
  82. #define configMINIMAL_STACK_SIZE ((uint16_t)512)
  83. #ifdef __LUATOS__
  84. #define configTOTAL_HEAP_SIZE ((size_t)(264 * 1024))
  85. #else
  86. #define configTOTAL_HEAP_SIZE ((size_t)(64 * 1024))
  87. #endif
  88. #define configMAX_TASK_NAME_LEN (16)
  89. #define configUSE_TRACE_FACILITY 0
  90. #define configUSE_16_BIT_TICKS 0
  91. #define configIDLE_SHOULD_YIELD 1
  92. #define configUSE_MUTEXES 0
  93. #define configQUEUE_REGISTRY_SIZE 8
  94. #define configCHECK_FOR_STACK_OVERFLOW 0
  95. #define configUSE_RECURSIVE_MUTEXES 0
  96. #define configUSE_MALLOC_FAILED_HOOK 0
  97. #define configUSE_APPLICATION_TASK_TAG 0
  98. #define configUSE_COUNTING_SEMAPHORES 1
  99. #define configGENERATE_RUN_TIME_STATS 0
  100. #define configNUM_THREAD_LOCAL_STORAGE_POINTERS 4
  101. #define configUSE_TASK_NOTIFICATIONS 1
  102. #define configTASK_NOTIFICATION_ARRAY_ENTRIES 2
  103. /* Co-routine definitions. */
  104. #define configUSE_CO_ROUTINES 0
  105. #define configMAX_CO_ROUTINE_PRIORITIES (2)
  106. /* Software timer definitions. */
  107. #define configUSE_TIMERS 1
  108. #define configTIMER_TASK_PRIORITY (2)
  109. #define configTIMER_QUEUE_LENGTH 100
  110. #define configTIMER_TASK_STACK_DEPTH (configMINIMAL_STACK_SIZE * 2)
  111. /* Set the following definitions to 1 to include the API function, or zero
  112. to exclude the API function. */
  113. #define INCLUDE_vTaskPrioritySet 1
  114. #define INCLUDE_uxTaskPriorityGet 1
  115. #define INCLUDE_vTaskDelete 1
  116. #define INCLUDE_vTaskCleanUpResources 0
  117. #define INCLUDE_vTaskSuspend 1
  118. #define INCLUDE_vTaskDelayUntil 1
  119. #define INCLUDE_vTaskDelay 1
  120. #define INCLUDE_xTaskGetSchedulerState 1
  121. /*------------- CMSIS-RTOS V2 specific defines -----------*/
  122. /* When using CMSIS-RTOSv2 set configSUPPORT_STATIC_ALLOCATION to 1
  123. * is mandatory to avoid compile errors.
  124. * CMSIS-RTOS V2 implmentation requires the following defines
  125. *
  126. #define configSUPPORT_STATIC_ALLOCATION 1 <-- cmsis_os threads are created using xTaskCreateStatic() API
  127. #define configMAX_PRIORITIES (56) <-- Priority range in CMSIS-RTOS V2 is [0 .. 56]
  128. #define configUSE_PORT_OPTIMISED_TASK_SELECTION 0 <-- when set to 1, configMAX_PRIORITIES can't be more than 32 which is not suitable for the new CMSIS-RTOS v2 priority range
  129. */
  130. /* the CMSIS-RTOS V2 FreeRTOS wrapper is dependent on the heap implementation used
  131. * by the application thus the correct define need to be enabled from the list
  132. * below
  133. *
  134. //define USE_FreeRTOS_HEAP_1
  135. //define USE_FreeRTOS_HEAP_2
  136. //define USE_FreeRTOS_HEAP_3
  137. //define USE_FreeRTOS_HEAP_4
  138. //define USE_FreeRTOS_HEAP_5
  139. */
  140. /* Cortex-M specific definitions. */
  141. #ifdef __NVIC_PRIO_BITS
  142. /* __BVIC_PRIO_BITS will be specified when CMSIS is being used. */
  143. #define configPRIO_BITS __NVIC_PRIO_BITS
  144. #else
  145. #define configPRIO_BITS 3 /* 15 priority levels */
  146. #endif
  147. /* The lowest interrupt priority that can be used in a call to a "set priority"
  148. function. */
  149. #if (configPRIO_BITS > 3)
  150. #define configLIBRARY_LOWEST_INTERRUPT_PRIORITY 0xf
  151. /* The highest interrupt priority that can be used by any interrupt service
  152. routine that makes calls to interrupt safe FreeRTOS API functions. DO NOT CALL
  153. INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A HIGHER
  154. PRIORITY THAN THIS! (higher priorities are lower numeric values. */
  155. #define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 5
  156. #else
  157. #define configLIBRARY_LOWEST_INTERRUPT_PRIORITY 7
  158. /* The highest interrupt priority that can be used by any interrupt service
  159. routine that makes calls to interrupt safe FreeRTOS API functions. DO NOT CALL
  160. INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A HIGHER
  161. PRIORITY THAN THIS! (higher priorities are lower numeric values. */
  162. #define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 2
  163. #endif
  164. /* Interrupt priorities used by the kernel port layer itself. These are generic
  165. to all Cortex-M ports, and do not rely on any particular library functions. */
  166. #define configKERNEL_INTERRUPT_PRIORITY ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
  167. /* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!!
  168. See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
  169. #define configMAX_SYSCALL_INTERRUPT_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
  170. /* Normal assert() semantics without relying on the provision of an assert.h
  171. header file. */
  172. //#define configASSERT( x ) if( ( x ) == 0 ) { taskDISABLE_INTERRUPTS(); for( ;; ); }
  173. #if(defined(__DEBUG__) || defined(DEBUG))
  174. #define configASSERT( x ) if( ( x ) == 0 ) { taskDISABLE_INTERRUPTS(); DBG_Trace("\r\nassert %s,%d", __FUNCTION__, __LINE__); for( ;; ); }
  175. #else
  176. #define configASSERT( x )
  177. #endif
  178. /* Definitions that map the FreeRTOS port interrupt handlers to their CMSIS
  179. standard names. */
  180. #define vPortSVCHandler SVC_Handler
  181. #define xPortPendSVHandler PendSV_Handler
  182. /* IMPORTANT: FreeRTOS is using the SysTick as internal time base, thus make sure the system and peripherials are
  183. using a different time base (TIM based for example).
  184. */
  185. #define xPortSysTickHandler SysTick_Handler
  186. #define traceTASK_SWITCHED_IN OS_SetStartFlag
  187. #define configUSE_TIME_SLICING 0
  188. #endif /* FREERTOS_CONFIG_H */