RTX_Conf_CM.c 6.5 KB

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