app_hooks.c 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. /*
  2. *********************************************************************************************************
  3. * EXAMPLE CODE
  4. *
  5. * This file is provided as an example on how to use Micrium products.
  6. *
  7. * Please feel free to use any application code labeled as 'EXAMPLE CODE' in
  8. * your application products. Example code may be used as is, in whole or in
  9. * part, or may be used as a reference only. This file can be modified as
  10. * required to meet the end-product requirements.
  11. *
  12. * Please help us continue to provide the Embedded community with the finest
  13. * software available. Your honesty is greatly appreciated.
  14. *
  15. * You can find our product's user manual, API reference, release notes and
  16. * more information at https://doc.micrium.com.
  17. * You can contact us at www.micrium.com.
  18. *********************************************************************************************************
  19. */
  20. /*
  21. *********************************************************************************************************
  22. *
  23. * uC/OS-II
  24. * Application Hooks
  25. *
  26. * Filename : app_hooks.c
  27. * Version : V1.00
  28. * Programmer(s) : FT
  29. *********************************************************************************************************
  30. */
  31. /*
  32. *********************************************************************************************************
  33. * INCLUDE FILES
  34. *********************************************************************************************************
  35. */
  36. #include <includes.h>
  37. /*
  38. *********************************************************************************************************
  39. * EXTERN GLOBAL VARIABLES
  40. *********************************************************************************************************
  41. */
  42. /*
  43. *********************************************************************************************************
  44. * LOCAL CONSTANTS
  45. *********************************************************************************************************
  46. */
  47. /*
  48. *********************************************************************************************************
  49. * LOCAL DATA TYPES
  50. *********************************************************************************************************
  51. */
  52. /*
  53. *********************************************************************************************************
  54. * LOCAL TABLES
  55. *********************************************************************************************************
  56. */
  57. /*
  58. *********************************************************************************************************
  59. * LOCAL GLOBAL VARIABLES
  60. *********************************************************************************************************
  61. */
  62. /*
  63. *********************************************************************************************************
  64. * LOCAL FUNCTION PROTOTYPES
  65. *********************************************************************************************************
  66. */
  67. /*
  68. **********************************************************************************************************
  69. **********************************************************************************************************
  70. ** GLOBAL FUNCTIONS
  71. **********************************************************************************************************
  72. **********************************************************************************************************
  73. */
  74. /*
  75. *********************************************************************************************************
  76. *********************************************************************************************************
  77. ** uC/OS-II APP HOOKS
  78. *********************************************************************************************************
  79. *********************************************************************************************************
  80. */
  81. #if (OS_APP_HOOKS_EN > 0)
  82. /*
  83. *********************************************************************************************************
  84. * TASK CREATION HOOK (APPLICATION)
  85. *
  86. * Description : This function is called when a task is created.
  87. *
  88. * Argument(s) : ptcb is a pointer to the task control block of the task being created.
  89. *
  90. * Note(s) : (1) Interrupts are disabled during this call.
  91. *********************************************************************************************************
  92. */
  93. void App_TaskCreateHook(OS_TCB *ptcb)
  94. {
  95. #if (APP_CFG_PROBE_OS_PLUGIN_EN == DEF_ENABLED) && (OS_PROBE_HOOKS_EN > 0)
  96. OSProbe_TaskCreateHook(ptcb);
  97. #endif
  98. }
  99. /*
  100. *********************************************************************************************************
  101. * TASK DELETION HOOK (APPLICATION)
  102. *
  103. * Description : This function is called when a task is deleted.
  104. *
  105. * Argument(s) : ptcb is a pointer to the task control block of the task being deleted.
  106. *
  107. * Note(s) : (1) Interrupts are disabled during this call.
  108. *********************************************************************************************************
  109. */
  110. void App_TaskDelHook(OS_TCB *ptcb)
  111. {
  112. (void)ptcb;
  113. }
  114. /*
  115. *********************************************************************************************************
  116. * IDLE TASK HOOK (APPLICATION)
  117. *
  118. * Description : This function is called by OSTaskIdleHook(), which is called by the idle task. This hook
  119. * has been added to allow you to do such things as STOP the CPU to conserve power.
  120. *
  121. * Argument(s) : none.
  122. *
  123. * Note(s) : (1) Interrupts are enabled during this call.
  124. *********************************************************************************************************
  125. */
  126. #if OS_VERSION >= 251
  127. void App_TaskIdleHook(void)
  128. {
  129. }
  130. #endif
  131. /*
  132. *********************************************************************************************************
  133. * STATISTIC TASK HOOK (APPLICATION)
  134. *
  135. * Description : This function is called by OSTaskStatHook(), which is called every second by uC/OS-II's
  136. * statistics task. This allows your application to add functionality to the statistics task.
  137. *
  138. * Argument(s) : none.
  139. *********************************************************************************************************
  140. */
  141. void App_TaskStatHook(void)
  142. {
  143. }
  144. /*
  145. *********************************************************************************************************
  146. * TASK RETURN HOOK (APPLICATION)
  147. *
  148. * Description: This function is called if a task accidentally returns. In other words, a task should
  149. * either be an infinite loop or delete itself when done.
  150. *
  151. * Arguments : ptcb is a pointer to the task control block of the task that is returning.
  152. *
  153. * Note(s) : none
  154. *********************************************************************************************************
  155. */
  156. #if OS_VERSION >= 289
  157. void App_TaskReturnHook(OS_TCB *ptcb)
  158. {
  159. (void)ptcb;
  160. }
  161. #endif
  162. /*
  163. *********************************************************************************************************
  164. * TASK SWITCH HOOK (APPLICATION)
  165. *
  166. * Description : This function is called when a task switch is performed. This allows you to perform other
  167. * operations during a context switch.
  168. *
  169. * Argument(s) : none.
  170. *
  171. * Note(s) : (1) Interrupts are disabled during this call.
  172. *
  173. * (2) It is assumed that the global pointer 'OSTCBHighRdy' points to the TCB of the task that
  174. * will be 'switched in' (i.e. the highest priority task) and, 'OSTCBCur' points to the
  175. * task being switched out (i.e. the preempted task).
  176. *********************************************************************************************************
  177. */
  178. #if OS_TASK_SW_HOOK_EN > 0
  179. void App_TaskSwHook(void)
  180. {
  181. #if (APP_CFG_PROBE_OS_PLUGIN_EN > 0) && (OS_PROBE_HOOKS_EN > 0)
  182. OSProbe_TaskSwHook();
  183. #endif
  184. }
  185. #endif
  186. /*
  187. *********************************************************************************************************
  188. * OS_TCBInit() HOOK (APPLICATION)
  189. *
  190. * Description : This function is called by OSTCBInitHook(), which is called by OS_TCBInit() after setting
  191. * up most of the TCB.
  192. *
  193. * Argument(s) : ptcb is a pointer to the TCB of the task being created.
  194. *
  195. * Note(s) : (1) Interrupts may or may not be ENABLED during this call.
  196. *********************************************************************************************************
  197. */
  198. #if OS_VERSION >= 204
  199. void App_TCBInitHook(OS_TCB *ptcb)
  200. {
  201. (void)ptcb;
  202. }
  203. #endif
  204. /*
  205. *********************************************************************************************************
  206. * TICK HOOK (APPLICATION)
  207. *
  208. * Description : This function is called every tick.
  209. *
  210. * Argument(s) : none.
  211. *
  212. * Note(s) : (1) Interrupts may or may not be ENABLED during this call.
  213. *********************************************************************************************************
  214. */
  215. #if OS_TIME_TICK_HOOK_EN > 0
  216. void App_TimeTickHook(void)
  217. {
  218. #if (APP_CFG_PROBE_OS_PLUGIN_EN == DEF_ENABLED) && (OS_PROBE_HOOKS_EN > 0)
  219. OSProbe_TickHook();
  220. #endif
  221. HAL_IncTick(); /* STM32CubeF4 library function call. */
  222. }
  223. #endif
  224. #endif