RTX_Conf_CM.c 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. /*----------------------------------------------------------------------------
  2. * RL-ARM - RTX
  3. *----------------------------------------------------------------------------
  4. * Name: RTX_CONFIG.C
  5. * Purpose: Configuration of RTX Kernel for Cortex-M
  6. * Rev.: V4.70
  7. *----------------------------------------------------------------------------
  8. * This code is part of the RealView Run-Time Library.
  9. * Copyright (c) 2004-2014 KEIL - An ARM Company. All rights reserved.
  10. *---------------------------------------------------------------------------*/
  11. #include "includes.h"
  12. #include <RTL.h>
  13. /*----------------------------------------------------------------------------
  14. * RTX User configuration part BEGIN
  15. *---------------------------------------------------------------------------*/
  16. //-------- <<< Use Configuration Wizard in Context Menu >>> -----------------
  17. //
  18. // <h>Task Configuration
  19. // =====================
  20. //
  21. // <o>Number of concurrent running tasks <0-250>
  22. // <i> Define max. number of tasks that will run at the same time.
  23. // <i> Default: 6
  24. #ifndef OS_TASKCNT
  25. #define OS_TASKCNT 4
  26. #endif
  27. // <o>Number of tasks with user-provided stack <0-250>
  28. // <i> Define the number of tasks that will use a bigger stack.
  29. // <i> The memory space for the stack is provided by the user.
  30. // <i> Default: 0
  31. #ifndef OS_PRIVCNT
  32. #define OS_PRIVCNT 0
  33. #endif
  34. // <o>Task stack size [bytes] <20-4096:8><#/4>
  35. // <i> Set the stack size for tasks which is assigned by the system.
  36. // <i> Default: 512
  37. #ifndef OS_STKSIZE
  38. #define OS_STKSIZE 50
  39. #endif
  40. // <q>Check for the stack overflow
  41. // ===============================
  42. // <i> Include the stack checking code for a stack overflow.
  43. // <i> Note that additional code reduces the Kernel performance.
  44. #ifndef OS_STKCHECK
  45. #define OS_STKCHECK 1
  46. #endif
  47. // <q>Run in privileged mode
  48. // =========================
  49. // <i> Run all Tasks in privileged mode.
  50. // <i> Default: Unprivileged
  51. #ifndef OS_RUNPRIV
  52. #define OS_RUNPRIV 0
  53. #endif
  54. // </h>
  55. // <h>Tick Timer Configuration
  56. // =============================
  57. // <o>Hardware timer <0=> Core SysTick <1=> Peripheral Timer
  58. // <i> Define the on-chip timer used as a time-base for RTX.
  59. // <i> Default: Core SysTick
  60. #ifndef OS_TIMER
  61. #define OS_TIMER 0
  62. #endif
  63. // <o>Timer clock value [Hz] <1-1000000000>
  64. // <i> Set the timer clock value for selected timer.
  65. // <i> Default: 6000000 (6MHz)
  66. #ifndef OS_CLOCK
  67. #define OS_CLOCK 24000000
  68. #endif
  69. // <o>Timer tick value [us] <1-1000000>
  70. // <i> Set the timer tick value for selected timer.
  71. // <i> Default: 10000 (10ms)
  72. #ifndef OS_TICK
  73. #define OS_TICK 10000
  74. #endif
  75. // </h>
  76. // <h>System Configuration
  77. // =======================
  78. // <e>Round-Robin Task switching
  79. // =============================
  80. // <i> Enable Round-Robin Task switching.
  81. #ifndef OS_ROBIN
  82. #define OS_ROBIN 1
  83. #endif
  84. // <o>Round-Robin Timeout [ticks] <1-1000>
  85. // <i> Define how long a task will execute before a task switch.
  86. // <i> Default: 5
  87. #ifndef OS_ROBINTOUT
  88. #define OS_ROBINTOUT 5
  89. #endif
  90. // </e>
  91. // <o>Number of user timers <0-250>
  92. // <i> Define max. number of user timers that will run at the same time.
  93. // <i> Default: 0 (User timers disabled)
  94. #ifndef OS_TIMERCNT
  95. #define OS_TIMERCNT 2
  96. #endif
  97. // <o>ISR FIFO Queue size<4=> 4 entries <8=> 8 entries
  98. // <12=> 12 entries <16=> 16 entries
  99. // <24=> 24 entries <32=> 32 entries
  100. // <48=> 48 entries <64=> 64 entries
  101. // <96=> 96 entries
  102. // <i> ISR functions store requests to this buffer,
  103. // <i> when they are called from the iterrupt handler.
  104. // <i> Default: 16 entries
  105. #ifndef OS_FIFOSZ
  106. #define OS_FIFOSZ 16
  107. #endif
  108. // </h>
  109. //------------- <<< end of configuration section >>> -----------------------
  110. // Standard library system mutexes
  111. // ===============================
  112. // Define max. number system mutexes that are used to protect
  113. // the arm standard runtime library. For microlib they are not used.
  114. #ifndef OS_MUTEXCNT
  115. #define OS_MUTEXCNT 8
  116. #endif
  117. /*----------------------------------------------------------------------------
  118. * RTX User configuration part END
  119. *---------------------------------------------------------------------------*/
  120. #define OS_TRV ((U32)(((double)OS_CLOCK*(double)OS_TICK)/1E6)-1)
  121. /*----------------------------------------------------------------------------
  122. * Global Functions
  123. *---------------------------------------------------------------------------*/
  124. /*--------------------------- os_idle_demon ---------------------------------*/
  125. __task void os_idle_demon (void) {
  126. /* The idle demon is a system task, running when no other task is ready */
  127. /* to run. The 'os_xxx' function calls are not allowed from this task. */
  128. for (;;) {
  129. /* HERE: include optional user code to be executed when no task runs.*/
  130. }
  131. }
  132. /*--------------------------- os_tick_init ----------------------------------*/
  133. #if (OS_TIMER != 0)
  134. int os_tick_init (void) {
  135. /* Initialize hardware timer as system tick timer. */
  136. /* ... */
  137. return (-1); /* Return IRQ number of timer (0..239) */
  138. }
  139. #endif
  140. /*--------------------------- os_tick_irqack --------------------------------*/
  141. #if (OS_TIMER != 0)
  142. void os_tick_irqack (void) {
  143. /* Acknowledge timer interrupt. */
  144. /* ... */
  145. }
  146. #endif
  147. /*--------------------------- os_tmr_call -----------------------------------*/
  148. void os_tmr_call (U16 info) {
  149. /* This function is called when the user timer has expired. Parameter */
  150. /* 'info' holds the value, defined when the timer was created. */
  151. /* HERE: include optional user code to be executed on timeout. */
  152. // if(info==TMR_INF_BEEP)
  153. // {
  154. // TIM_Cmd(TIM17, DISABLE); //½ûÖ¹/ʹÄÜTIM4
  155. // if(sutPocStatus.Speaker==0)
  156. // {
  157. // SpeakerCtrl(0);
  158. // }
  159. // }
  160. }
  161. /*--------------------------- os_error --------------------------------------*/
  162. void os_error (U32 err_code) {
  163. /* This function is called when a runtime error is detected. Parameter */
  164. /* 'err_code' holds the runtime error code (defined in RTL.H). */
  165. /* HERE: include optional code to be executed on runtime error. */
  166. SlwTrace(INF,"\r\n[OS]Err",1);
  167. for (;;);
  168. }
  169. /*----------------------------------------------------------------------------
  170. * RTX Configuration Functions
  171. *---------------------------------------------------------------------------*/
  172. #include <RTX_lib.c>
  173. /*----------------------------------------------------------------------------
  174. * end of file
  175. *---------------------------------------------------------------------------*/