os_app_hooks.c 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. /*
  2. ************************************************************************************************************************
  3. * uC/OS-III
  4. * The Real-Time Kernel
  5. *
  6. * (c) Copyright 2009-2011; Micrium, Inc.; Weston, FL
  7. * All rights reserved. Protected by international copyright laws.
  8. *
  9. * APPLICATION HOOKS
  10. *
  11. * File : OS_APP_HOOKS.C
  12. * By : JJL
  13. * Version : V3.02.00
  14. *
  15. * LICENSING TERMS:
  16. * ---------------
  17. * uC/OS-III is provided in source form for FREE short-term evaluation, for educational use or
  18. * for peaceful research. If you plan or intend to use uC/OS-III in a commercial application/
  19. * product then, you need to contact Micrium to properly license uC/OS-III for its use in your
  20. * application/product. We provide ALL the source code for your convenience and to help you
  21. * experience uC/OS-III. The fact that the source is provided does NOT mean that you can use
  22. * it commercially without paying a licensing fee.
  23. *
  24. * Knowledge of the source code may NOT be used to develop a similar product.
  25. *
  26. * Please help us continue to provide the embedded community with the finest software available.
  27. * Your honesty is greatly appreciated.
  28. *
  29. * You can contact us at www.micrium.com, or by phone at +1 (954) 217-2036.
  30. ************************************************************************************************************************
  31. */
  32. #include <os.h>
  33. #include <os_app_hooks.h>
  34. /*$PAGE*/
  35. /*
  36. ************************************************************************************************************************
  37. * SET ALL APPLICATION HOOKS
  38. *
  39. * Description: Set ALL application hooks.
  40. *
  41. * Arguments : none.
  42. *
  43. * Note(s) : none
  44. ************************************************************************************************************************
  45. */
  46. void App_OS_SetAllHooks (void)
  47. {
  48. #if OS_CFG_APP_HOOKS_EN > 0u
  49. CPU_SR_ALLOC();
  50. CPU_CRITICAL_ENTER();
  51. OS_AppTaskCreateHookPtr = App_OS_TaskCreateHook;
  52. OS_AppTaskDelHookPtr = App_OS_TaskDelHook;
  53. OS_AppTaskReturnHookPtr = App_OS_TaskReturnHook;
  54. OS_AppIdleTaskHookPtr = App_OS_IdleTaskHook;
  55. OS_AppStatTaskHookPtr = App_OS_StatTaskHook;
  56. OS_AppTaskSwHookPtr = App_OS_TaskSwHook;
  57. OS_AppTimeTickHookPtr = App_OS_TimeTickHook;
  58. CPU_CRITICAL_EXIT();
  59. #endif
  60. }
  61. /*$PAGE*/
  62. /*
  63. ************************************************************************************************************************
  64. * CLEAR ALL APPLICATION HOOKS
  65. *
  66. * Description: Clear ALL application hooks.
  67. *
  68. * Arguments : none.
  69. *
  70. * Note(s) : none
  71. ************************************************************************************************************************
  72. */
  73. void App_OS_ClrAllHooks (void)
  74. {
  75. #if OS_CFG_APP_HOOKS_EN > 0u
  76. CPU_SR_ALLOC();
  77. CPU_CRITICAL_ENTER();
  78. OS_AppTaskCreateHookPtr = (OS_APP_HOOK_TCB)0;
  79. OS_AppTaskDelHookPtr = (OS_APP_HOOK_TCB)0;
  80. OS_AppTaskReturnHookPtr = (OS_APP_HOOK_TCB)0;
  81. OS_AppIdleTaskHookPtr = (OS_APP_HOOK_VOID)0;
  82. OS_AppStatTaskHookPtr = (OS_APP_HOOK_VOID)0;
  83. OS_AppTaskSwHookPtr = (OS_APP_HOOK_VOID)0;
  84. OS_AppTimeTickHookPtr = (OS_APP_HOOK_VOID)0;
  85. CPU_CRITICAL_EXIT();
  86. #endif
  87. }
  88. /*$PAGE*/
  89. /*
  90. ************************************************************************************************************************
  91. * APPLICATION TASK CREATION HOOK
  92. *
  93. * Description: This function is called when a task is created.
  94. *
  95. * Arguments : p_tcb is a pointer to the task control block of the task being created.
  96. *
  97. * Note(s) : none
  98. ************************************************************************************************************************
  99. */
  100. void App_OS_TaskCreateHook (OS_TCB *p_tcb)
  101. {
  102. (void)&p_tcb;
  103. }
  104. /*$PAGE*/
  105. /*
  106. ************************************************************************************************************************
  107. * APPLICATION TASK DELETION HOOK
  108. *
  109. * Description: This function is called when a task is deleted.
  110. *
  111. * Arguments : p_tcb is a pointer to the task control block of the task being deleted.
  112. *
  113. * Note(s) : none
  114. ************************************************************************************************************************
  115. */
  116. void App_OS_TaskDelHook (OS_TCB *p_tcb)
  117. {
  118. (void)&p_tcb;
  119. }
  120. /*$PAGE*/
  121. /*
  122. ************************************************************************************************************************
  123. * APPLICATION TASK RETURN HOOK
  124. *
  125. * Description: This function is called if a task accidentally returns. In other words, a task should either be an
  126. * infinite loop or delete itself when done.
  127. *
  128. * Arguments : p_tcb is a pointer to the OS_TCB of the task that is returning.
  129. *
  130. * Note(s) : none
  131. ************************************************************************************************************************
  132. */
  133. void App_OS_TaskReturnHook (OS_TCB *p_tcb)
  134. {
  135. (void)&p_tcb;
  136. }
  137. /*$PAGE*/
  138. /*
  139. ************************************************************************************************************************
  140. * APPLICATION IDLE TASK HOOK
  141. *
  142. * Description: This function is called by the idle task. This hook has been added to allow you to do such things as
  143. * STOP the CPU to conserve power.
  144. *
  145. * Arguments : none
  146. *
  147. * Note(s) : none
  148. ************************************************************************************************************************
  149. */
  150. void App_OS_IdleTaskHook (void)
  151. {
  152. }
  153. /*$PAGE*/
  154. /*
  155. ************************************************************************************************************************
  156. * APPLICATION OS INITIALIZATION HOOK
  157. *
  158. * Description: This function is called by OSInit() at the beginning of OSInit().
  159. *
  160. * Arguments : none
  161. *
  162. * Note(s) : none
  163. ************************************************************************************************************************
  164. */
  165. void App_OS_InitHook (void)
  166. {
  167. }
  168. /*$PAGE*/
  169. /*
  170. ************************************************************************************************************************
  171. * APPLICATION STATISTIC TASK HOOK
  172. *
  173. * Description: This function is called every second by uC/OS-III's statistics task. This allows your application to add
  174. * functionality to the statistics task.
  175. *
  176. * Arguments : none
  177. *
  178. * Note(s) : none
  179. ************************************************************************************************************************
  180. */
  181. void App_OS_StatTaskHook (void)
  182. {
  183. }
  184. /*$PAGE*/
  185. /*
  186. ************************************************************************************************************************
  187. * APPLICATION TASK SWITCH HOOK
  188. *
  189. * Description: This function is called when a task switch is performed. This allows you to perform other operations
  190. * during a context switch.
  191. *
  192. * Arguments : none
  193. *
  194. * Note(s) : 1) Interrupts are disabled during this call.
  195. * 2) It is assumed that the global pointer 'OSTCBHighRdyPtr' points to the TCB of the task that will be
  196. * 'switched in' (i.e. the highest priority task) and, 'OSTCBCurPtr' points to the task being switched out
  197. * (i.e. the preempted task).
  198. ************************************************************************************************************************
  199. */
  200. void App_OS_TaskSwHook (void)
  201. {
  202. }
  203. /*$PAGE*/
  204. /*
  205. ************************************************************************************************************************
  206. * APPLICATION TICK HOOK
  207. *
  208. * Description: This function is called every tick.
  209. *
  210. * Arguments : none
  211. *
  212. * Note(s) : 1) This function is assumed to be called from the Tick ISR.
  213. ************************************************************************************************************************
  214. */
  215. void App_OS_TimeTickHook (void)
  216. {
  217. }