Keyboard firmwares for Atmel AVR and Cortex-M
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

RTX_Conf_CM.c 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. /*----------------------------------------------------------------------------
  2. * RL-ARM - RTX
  3. *----------------------------------------------------------------------------
  4. * Name: RTX_Conf_CM.C
  5. * Purpose: Configuration of CMSIS RTX Kernel for Cortex-M
  6. * Rev.: V4.60
  7. *----------------------------------------------------------------------------
  8. *
  9. * Copyright (c) 1999-2009 KEIL, 2009-2012 ARM Germany GmbH
  10. * All rights reserved.
  11. * Redistribution and use in source and binary forms, with or without
  12. * modification, are permitted provided that the following conditions are met:
  13. * - Redistributions of source code must retain the above copyright
  14. * notice, this list of conditions and the following disclaimer.
  15. * - Redistributions in binary form must reproduce the above copyright
  16. * notice, this list of conditions and the following disclaimer in the
  17. * documentation and/or other materials provided with the distribution.
  18. * - Neither the name of ARM nor the names of its contributors may be used
  19. * to endorse or promote products derived from this software without
  20. * specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  23. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  25. * ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
  26. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  27. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  28. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  29. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  30. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  31. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  32. * POSSIBILITY OF SUCH DAMAGE.
  33. *---------------------------------------------------------------------------*/
  34. #include "cmsis_os.h"
  35. /*----------------------------------------------------------------------------
  36. * RTX User configuration part BEGIN
  37. *---------------------------------------------------------------------------*/
  38. //-------- <<< Use Configuration Wizard in Context Menu >>> -----------------
  39. //
  40. // <h>Thread Configuration
  41. // =======================
  42. //
  43. // <o>Number of concurrent running threads <0-250>
  44. // <i> Defines max. number of threads that will run at the same time.
  45. // counting "main", but not counting "osTimerThread"
  46. // <i> Default: 6
  47. #ifndef OS_TASKCNT
  48. # if defined(TARGET_LPC1768) || defined(TARGET_LPC2368) || defined(TARGET_LPC4088) || defined(TARGET_LPC4088_DM) || defined(TARGET_LPC4330) || defined(TARGET_LPC4337) || defined(TARGET_LPC1347) || defined(TARGET_K64F) || defined(TARGET_STM32F401RE)\
  49. || defined(TARGET_KL46Z) || defined(TARGET_KL43Z) || defined(TARGET_STM32F407) || defined(TARGET_F407VG) || defined(TARGET_STM32F303VC) || defined(TARGET_LPC1549) || defined(TARGET_LPC11U68) \
  50. || defined(TARGET_STM32F411RE) || defined(TARGET_STM32F405RG) || defined(TARGET_K22F) || defined(TARGET_STM32F429ZI) || defined(TARGET_STM32F401VC) || defined(TARGET_MAX32610) || defined(TARGET_MAX32600) || defined(TARGET_TEENSY3_1)
  51. # define OS_TASKCNT 14
  52. # elif defined(TARGET_LPC11U24) || defined(TARGET_STM32F303RE) || defined(TARGET_LPC11U35_401) || defined(TARGET_LPC11U35_501) || defined(TARGET_LPCCAPPUCCINO) || defined(TARGET_LPC1114) \
  53. || defined(TARGET_LPC812) || defined(TARGET_KL25Z) || defined(TARGET_KL05Z) || defined(TARGET_STM32F100RB) || defined(TARGET_STM32F051R8) \
  54. || defined(TARGET_STM32F103RB) || defined(TARGET_LPC824) || defined(TARGET_STM32F302R8) || defined(TARGET_STM32F334R8) || defined(TARGET_STM32F334C8) \
  55. || defined(TARGET_STM32L053R8) || defined(TARGET_STM32L053C8) || defined(TARGET_STM32F072RB) || defined(TARGET_STM32F091RC)
  56. # define OS_TASKCNT 6
  57. # else
  58. # error "no target defined"
  59. # endif
  60. #endif
  61. // <o>Scheduler (+ interrupts) stack size [bytes] <64-4096:8><#/4>
  62. #ifndef OS_SCHEDULERSTKSIZE
  63. # if defined(TARGET_LPC1768) || defined(TARGET_LPC2368) || defined(TARGET_LPC4088) || defined(TARGET_LPC4088_DM) || defined(TARGET_LPC4330) || defined(TARGET_LPC4337) || defined(TARGET_LPC1347) || defined(TARGET_K64F) || defined(TARGET_STM32F401RE)\
  64. || defined(TARGET_KL46Z) || defined(TARGET_KL43Z) || defined(TARGET_STM32F407) || defined(TARGET_F407VG) || defined(TARGET_STM32F303VC) || defined(TARGET_LPC1549) || defined(TARGET_LPC11U68) \
  65. || defined(TARGET_STM32F411RE) || defined(TARGET_STM32F405RG) || defined(TARGET_K22F) || defined(TARGET_STM32F429ZI) || defined(TARGET_STM32F401VC) || defined(TARGET_MAX32610) || defined(TARGET_MAX32600) || defined(TARGET_TEENSY3_1)
  66. # define OS_SCHEDULERSTKSIZE 256
  67. # elif defined(TARGET_LPC11U24) || defined(TARGET_LPC11U35_401) || defined(TARGET_LPC11U35_501) || defined(TARGET_LPCCAPPUCCINO) || defined(TARGET_LPC1114) \
  68. || defined(TARGET_LPC812) || defined(TARGET_KL25Z) || defined(TARGET_KL05Z) || defined(TARGET_STM32F100RB) || defined(TARGET_STM32F051R8) \
  69. || defined(TARGET_STM32F103RB) || defined(TARGET_LPC824) || defined(TARGET_STM32F302R8) || defined(TARGET_STM32F072RB) || defined(TARGET_STM32F091RC)
  70. # define OS_SCHEDULERSTKSIZE 128
  71. # elif defined(TARGET_STM32F334R8) || defined(TARGET_STM32F303RE) || defined(TARGET_STM32F334C8) || defined(TARGET_STM32L053R8) || defined(TARGET_STM32L053C8)
  72. # define OS_SCHEDULERSTKSIZE 112
  73. # else
  74. # error "no target defined"
  75. # endif
  76. #endif
  77. // <o>Idle stack size [bytes] <64-4096:8><#/4>
  78. // <i> Defines default stack size for the Idle thread.
  79. #ifndef OS_IDLESTKSIZE
  80. #define OS_IDLESTKSIZE 128
  81. #endif
  82. // <o>Timer Thread stack size [bytes] <64-4096:8><#/4>
  83. // <i> Defines stack size for Timer thread.
  84. // <i> Default: 200
  85. #ifndef OS_TIMERSTKSZ
  86. #define OS_TIMERSTKSZ WORDS_STACK_SIZE
  87. #endif
  88. // <q>Check for stack overflow
  89. // <i> Includes the stack checking code for stack overflow.
  90. // <i> Note that additional code reduces the Kernel performance.
  91. #ifndef OS_STKCHECK
  92. #define OS_STKCHECK 1
  93. #endif
  94. // <o>Processor mode for thread execution
  95. // <0=> Unprivileged mode
  96. // <1=> Privileged mode
  97. // <i> Default: Privileged mode
  98. #ifndef OS_RUNPRIV
  99. #define OS_RUNPRIV 1
  100. #endif
  101. // </h>
  102. // <h>SysTick Timer Configuration
  103. // ==============================
  104. //
  105. // <o>Timer clock value [Hz] <1-1000000000>
  106. // <i> Defines the timer clock value.
  107. // <i> Default: 6000000 (6MHz)
  108. #ifndef OS_CLOCK
  109. # if defined(TARGET_LPC1768) || defined(TARGET_LPC2368)
  110. # define OS_CLOCK 96000000
  111. # elif defined(TARGET_LPC1347) || defined(TARGET_STM32F303VC) || defined(TARGET_LPC1549) || defined(TARGET_STM32F334R8) || defined(TARGET_STM32F334C8) || defined(TARGET_STM32F303RE) || defined(TARGET_TEENSY3_1)
  112. # define OS_CLOCK 72000000
  113. # elif defined(TARGET_LPC11U24) || defined(TARGET_LPC11U35_401) || defined(TARGET_LPC11U35_501) || defined(TARGET_LPCCAPPUCCINO) || defined(TARGET_LPC1114) || defined(TARGET_KL25Z) \
  114. || defined(TARGET_KL05Z) || defined(TARGET_KL46Z) || defined(TARGET_KL43Z) || defined(TARGET_STM32F051R8) || defined(TARGET_LPC11U68) || defined(TARGET_STM32F072RB) || defined(TARGET_STM32F091RC)
  115. # define OS_CLOCK 48000000
  116. # elif defined(TARGET_LPC812)
  117. # define OS_CLOCK 36000000
  118. # elif defined(TARGET_LPC824)
  119. # define OS_CLOCK 30000000
  120. # elif defined(TARGET_STM32F100RB)
  121. # define OS_CLOCK 24000000
  122. # elif defined(TARGET_LPC4088) || defined(TARGET_LPC4088_DM) || defined(TARGET_K64F) || defined(TARGET_K22F)
  123. # define OS_CLOCK 120000000
  124. # elif defined(TARGET_LPC4330)
  125. # define OS_CLOCK 204000000
  126. # elif defined(TARGET_LPC4337)
  127. # define OS_CLOCK 204000000
  128. # elif defined(TARGET_STM32F407) || defined(TARGET_F407VG)
  129. # define OS_CLOCK 168000000
  130. # elif defined(TARGET_STM32F401RE)
  131. # define OS_CLOCK 84000000
  132. # elif defined(TARGET_STM32F411RE)
  133. # define OS_CLOCK 100000000
  134. #elif defined(TARGET_STM32F103RB)
  135. # define OS_CLOCK 72000000
  136. #elif defined(TARGET_STM32F429ZI)
  137. # define OS_CLOCK 168000000
  138. #elif defined(TARGET_STM32F302R8)
  139. # define OS_CLOCK 64000000
  140. #elif defined(TARGET_STM32L053R8) || defined(TARGET_STM32L053C8)
  141. # define OS_CLOCK 32000000
  142. #elif defined(TARGET_STM32F401VC)
  143. # define OS_CLOCK 84000000
  144. #elif defined(TARGET_MAX32610) || defined(TARGET_MAX32600)
  145. # define OS_CLOCK 24000000
  146. # else
  147. # error "no target defined"
  148. # endif
  149. #endif
  150. // <o>Timer tick value [us] <1-1000000>
  151. // <i> Defines the timer tick value.
  152. // <i> Default: 1000 (1ms)
  153. #ifndef OS_TICK
  154. #define OS_TICK 1000
  155. #endif
  156. // </h>
  157. // <h>System Configuration
  158. // =======================
  159. //
  160. // <e>Round-Robin Thread switching
  161. // ===============================
  162. //
  163. // <i> Enables Round-Robin Thread switching.
  164. #ifndef OS_ROBIN
  165. #define OS_ROBIN 1
  166. #endif
  167. // <o>Round-Robin Timeout [ticks] <1-1000>
  168. // <i> Defines how long a thread will execute before a thread switch.
  169. // <i> Default: 5
  170. #ifndef OS_ROBINTOUT
  171. #define OS_ROBINTOUT 5
  172. #endif
  173. // </e>
  174. // <e>User Timers
  175. // ==============
  176. // <i> Enables user Timers
  177. #ifndef OS_TIMERS
  178. #define OS_TIMERS 1
  179. #endif
  180. // <o>Timer Thread Priority
  181. // <1=> Low
  182. // <2=> Below Normal
  183. // <3=> Normal
  184. // <4=> Above Normal
  185. // <5=> High
  186. // <6=> Realtime (highest)
  187. // <i> Defines priority for Timer Thread
  188. // <i> Default: High
  189. #ifndef OS_TIMERPRIO
  190. #define OS_TIMERPRIO 5
  191. #endif
  192. // <o>Timer Callback Queue size <1-32>
  193. // <i> Number of concurrent active timer callback functions.
  194. // <i> Default: 4
  195. #ifndef OS_TIMERCBQSZ
  196. #define OS_TIMERCBQS 4
  197. #endif
  198. // </e>
  199. // <o>ISR FIFO Queue size<4=> 4 entries <8=> 8 entries
  200. // <12=> 12 entries <16=> 16 entries
  201. // <24=> 24 entries <32=> 32 entries
  202. // <48=> 48 entries <64=> 64 entries
  203. // <96=> 96 entries
  204. // <i> ISR functions store requests to this buffer,
  205. // <i> when they are called from the interrupt handler.
  206. // <i> Default: 16 entries
  207. #ifndef OS_FIFOSZ
  208. #define OS_FIFOSZ 16
  209. #endif
  210. // </h>
  211. //------------- <<< end of configuration section >>> -----------------------
  212. // Standard library system mutexes
  213. // ===============================
  214. // Define max. number system mutexes that are used to protect
  215. // the arm standard runtime library. For microlib they are not used.
  216. #ifndef OS_MUTEXCNT
  217. #define OS_MUTEXCNT 12
  218. #endif
  219. /*----------------------------------------------------------------------------
  220. * RTX User configuration part END
  221. *---------------------------------------------------------------------------*/
  222. #define OS_TRV ((uint32_t)(((double)OS_CLOCK*(double)OS_TICK)/1E6)-1)
  223. /*----------------------------------------------------------------------------
  224. * OS Idle daemon
  225. *---------------------------------------------------------------------------*/
  226. void os_idle_demon (void) {
  227. /* The idle demon is a system thread, running when no other thread is */
  228. /* ready to run. */
  229. /* Sleep: ideally, we should put the chip to sleep.
  230. Unfortunately, this usually requires disconnecting the interface chip (debugger).
  231. This can be done, but it would break the local file system.
  232. */
  233. for (;;) {
  234. // sleep();
  235. }
  236. }
  237. /*----------------------------------------------------------------------------
  238. * RTX Errors
  239. *---------------------------------------------------------------------------*/
  240. extern void mbed_die(void);
  241. void os_error (uint32_t err_code) {
  242. /* This function is called when a runtime error is detected. Parameter */
  243. /* 'err_code' holds the runtime error code (defined in RTX_Conf.h). */
  244. mbed_die();
  245. }
  246. void sysThreadError(osStatus status) {
  247. if (status != osOK) {
  248. mbed_die();
  249. }
  250. }
  251. /*----------------------------------------------------------------------------
  252. * RTX Configuration Functions
  253. *---------------------------------------------------------------------------*/
  254. #include "RTX_CM_lib.h"
  255. /*----------------------------------------------------------------------------
  256. * end of file
  257. *---------------------------------------------------------------------------*/