os_cpu_c.c 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. /*
  2. * Copyright (c) 2021, Meco Jianting Man <jiantingman@foxmail.com>
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2020-09-20 Meco Man first version
  9. */
  10. /*
  11. *********************************************************************************************************
  12. * uC/OS-II
  13. * The Real-Time Kernel
  14. *
  15. * Copyright 1992-2020 Silicon Laboratories Inc. www.silabs.com
  16. *
  17. * SPDX-License-Identifier: APACHE-2.0
  18. *
  19. * This software is subject to an open source license and is distributed by
  20. * Silicon Laboratories Inc. pursuant to the terms of the Apache License,
  21. * Version 2.0 available at www.apache.org/licenses/LICENSE-2.0.
  22. *
  23. *********************************************************************************************************
  24. */
  25. #define OS_CPU_GLOBALS
  26. /*
  27. *********************************************************************************************************
  28. * INCLUDE FILES
  29. *********************************************************************************************************
  30. */
  31. #include "ucos_ii.h"
  32. /*
  33. *********************************************************************************************************
  34. * OS INITIALIZATION HOOK
  35. * (BEGINNING)
  36. *
  37. * Description: This function is called by OSInit() at the beginning of OSInit().
  38. *
  39. * Arguments : none
  40. *
  41. * Note(s) : 1) Interrupts should be disabled during this call.
  42. * 2) When using hardware floating point please do the following during the reset handler:
  43. * a) Set full access for CP10 & CP11 bits in CPACR register.
  44. * b) Set bits ASPEN and LSPEN in FPCCR register.
  45. *********************************************************************************************************
  46. */
  47. #if OS_CPU_HOOKS_EN > 0u
  48. void OSInitHookBegin (void)
  49. {
  50. }
  51. #endif
  52. /*
  53. *********************************************************************************************************
  54. * OS INITIALIZATION HOOK
  55. * (END)
  56. *
  57. * Description: This function is called by OSInit() at the end of OSInit().
  58. *
  59. * Arguments : none
  60. *
  61. * Note(s) : 1) Interrupts should be disabled during this call.
  62. *********************************************************************************************************
  63. */
  64. #if OS_CPU_HOOKS_EN > 0u
  65. void OSInitHookEnd (void)
  66. {
  67. }
  68. #endif
  69. /*
  70. *********************************************************************************************************
  71. * TASK CREATION HOOK
  72. *
  73. * Description: This function is called when a task is created.
  74. *
  75. * Arguments : ptcb is a pointer to the task control block of the task being created.
  76. *
  77. * Note(s) : 1) Interrupts are disabled during this call.
  78. *********************************************************************************************************
  79. */
  80. #if OS_CPU_HOOKS_EN > 0u
  81. void OSTaskCreateHook (OS_TCB *ptcb)
  82. {
  83. #if OS_APP_HOOKS_EN > 0u
  84. App_TaskCreateHook(ptcb);
  85. #else
  86. (void)ptcb; /* Prevent compiler warning */
  87. #endif
  88. }
  89. #endif
  90. /*
  91. *********************************************************************************************************
  92. * TASK DELETION HOOK
  93. *
  94. * Description: This function is called when a task is deleted.
  95. *
  96. * Arguments : ptcb is a pointer to the task control block of the task being deleted.
  97. *
  98. * Note(s) : 1) Interrupts are disabled during this call.
  99. *********************************************************************************************************
  100. */
  101. #if OS_CPU_HOOKS_EN > 0u
  102. void OSTaskDelHook (OS_TCB *ptcb)
  103. {
  104. #if OS_APP_HOOKS_EN > 0u
  105. App_TaskDelHook(ptcb);
  106. #else
  107. (void)ptcb; /* Prevent compiler warning */
  108. #endif
  109. }
  110. #endif
  111. #if OS_TASK_STAT_EN > 0u
  112. /*
  113. *********************************************************************************************************
  114. * IDLE TASK HOOK
  115. *
  116. * Description: This function is called by the idle task. This hook has been added to allow you to do
  117. * such things as STOP the CPU to conserve power.
  118. *
  119. * Arguments : none
  120. *
  121. * Note(s) : 1) Interrupts are enabled during this call.
  122. *********************************************************************************************************
  123. */
  124. #if OS_CPU_HOOKS_EN > 0u
  125. void OSTaskIdleHook (void)
  126. {
  127. #if OS_APP_HOOKS_EN > 0u
  128. App_TaskIdleHook();
  129. #endif
  130. }
  131. #endif
  132. /*
  133. *********************************************************************************************************
  134. * STATISTIC TASK HOOK
  135. *
  136. * Description: This function is called every second by uC/OS-II's statistics task. This allows your
  137. * application to add functionality to the statistics task.
  138. *
  139. * Arguments : none
  140. *********************************************************************************************************
  141. */
  142. #if OS_CPU_HOOKS_EN > 0u
  143. void OSTaskStatHook (void)
  144. {
  145. #if OS_APP_HOOKS_EN > 0u
  146. App_TaskStatHook();
  147. #endif
  148. }
  149. #endif
  150. #endif
  151. /*
  152. *********************************************************************************************************
  153. * OS_TCBInit() HOOK
  154. *
  155. * Description: This function is called by OS_TCBInit() after setting up most of the TCB.
  156. *
  157. * Arguments : ptcb is a pointer to the TCB of the task being created.
  158. *
  159. * Note(s) : 1) Interrupts may or may not be ENABLED during this call.
  160. *********************************************************************************************************
  161. */
  162. #if OS_CPU_HOOKS_EN > 0u
  163. void OSTCBInitHook (OS_TCB *ptcb)
  164. {
  165. #if OS_APP_HOOKS_EN > 0u
  166. App_TCBInitHook(ptcb);
  167. #else
  168. (void)ptcb; /* Prevent compiler warning */
  169. #endif
  170. }
  171. #endif