Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 

623 wiersze
29 KiB

  1. /*
  2. *********************************************************************************************************
  3. * uC/OS-II
  4. * The Real-Time Kernel
  5. *
  6. *
  7. * (c) Copyright 2009-2013; Micrium, Inc.; Weston, FL
  8. * All rights reserved. Protected by international copyright laws.
  9. *
  10. * ARM Cortex-M4 Port
  11. *
  12. * File : OS_CPU_C.C
  13. * Version : V2.92.09
  14. * By : JJL
  15. * BAN
  16. *
  17. * LICENSING TERMS:
  18. * ---------------
  19. * uC/OS-II is provided in source form for FREE short-term evaluation, for educational use or
  20. * for peaceful research. If you plan or intend to use uC/OS-II in a commercial application/
  21. * product then, you need to contact Micrium to properly license uC/OS-II for its use in your
  22. * experience uC/OS-II. The fact that the source is provided does NOT mean that you can use
  23. * it commercially without paying a licensing fee.
  24. *
  25. * Knowledge of the source code may NOT be used to develop a similar product.
  26. *
  27. * Please help us continue to provide the embedded community with the finest software available.
  28. * Your honesty is greatly appreciated.
  29. *
  30. * You can contact us at www.micrium.com, or by phone at +1 (954) 217-2036.
  31. *
  32. * For : ARMv7 Cortex-M4
  33. * Mode : Thumb-2 ISA
  34. * Toolchain : IAR EWARM
  35. *********************************************************************************************************
  36. */
  37. #define OS_CPU_GLOBALS
  38. /*
  39. *********************************************************************************************************
  40. * INCLUDE FILES
  41. *********************************************************************************************************
  42. */
  43. #include <ucos_ii.h>
  44. //#include <lib_def.h>
  45. /*********************************************************************************************************
  46. * LOCAL VARIABLES
  47. *********************************************************************************************************
  48. */
  49. #if OS_TMR_EN > 0u
  50. static INT16U OSTmrCtr;
  51. #endif
  52. /*
  53. *********************************************************************************************************
  54. * SYS TICK DEFINES
  55. *********************************************************************************************************
  56. */
  57. //#define OS_CPU_CM4_NVIC_ST_CTRL (*((volatile INT32U *)0xE000E010uL)) /* SysTick Ctrl & Status Reg. */
  58. //#define OS_CPU_CM4_NVIC_ST_RELOAD (*((volatile INT32U *)0xE000E014uL)) /* SysTick Reload Value Reg. */
  59. //#define OS_CPU_CM4_NVIC_ST_CURRENT (*((volatile INT32U *)0xE000E018uL)) /* SysTick Current Value Reg. */
  60. //#define OS_CPU_CM4_NVIC_ST_CAL (*((volatile INT32U *)0xE000E01CuL)) /* SysTick Cal Value Reg. */
  61. //#define OS_CPU_CM4_NVIC_SHPRI1 (*((volatile INT32U *)0xE000ED18uL)) /* System Handlers 4 to 7 Prio. */
  62. //#define OS_CPU_CM4_NVIC_SHPRI2 (*((volatile INT32U *)0xE000ED1CuL)) /* System Handlers 8 to 11 Prio. */
  63. //#define OS_CPU_CM4_NVIC_SHPRI3 (*((volatile INT32U *)0xE000ED20uL)) /* System Handlers 12 to 15 Prio. */
  64. #define OS_CPU_CM4_NVIC_ST_CTRL_COUNT 0x00010000uL /* Count flag. */
  65. #define OS_CPU_CM4_NVIC_ST_CTRL_CLK_SRC 0x00000004uL /* Clock Source. */
  66. #define OS_CPU_CM4_NVIC_ST_CTRL_INTEN 0x00000002uL /* Interrupt enable. */
  67. #define OS_CPU_CM4_NVIC_ST_CTRL_ENABLE 0x00000001uL /* Counter mode. */
  68. #define OS_CPU_CM4_NVIC_PRIO_MIN 0xFFu /* Min handler prio. */
  69. /*
  70. *********************************************************************************************************
  71. * OS INITIALIZATION HOOK
  72. * (BEGINNING)
  73. *
  74. * Description: This function is called by OSInit() at the beginning of OSInit().
  75. *
  76. * Arguments : none
  77. *
  78. * Note(s) : 1) Interrupts should be disabled during this call.
  79. *********************************************************************************************************
  80. */
  81. #if OS_CPU_HOOKS_EN > 0u
  82. void OSInitHookBegin (void)
  83. {
  84. INT32U size;
  85. OS_STK *pstk;
  86. /* Clear exception stack for stack checking. */
  87. pstk = &OS_CPU_ExceptStk[0];
  88. size = OS_CPU_EXCEPT_STK_SIZE;
  89. while (size > 0u) {
  90. size--;
  91. *pstk++ = (OS_STK)0;
  92. }
  93. /* Align the ISR stack to 8-bytes */
  94. OS_CPU_ExceptStkBase = (OS_STK *)&OS_CPU_ExceptStk[OS_CPU_EXCEPT_STK_SIZE];
  95. OS_CPU_ExceptStkBase = (OS_STK *)((OS_STK)(OS_CPU_ExceptStkBase) & 0xFFFFFFF8);
  96. #if OS_TMR_EN > 0u
  97. OSTmrCtr = 0u;
  98. #endif
  99. }
  100. #endif
  101. /*
  102. *********************************************************************************************************
  103. * OS INITIALIZATION HOOK
  104. * (END)
  105. *
  106. * Description: This function is called by OSInit() at the end of OSInit().
  107. *
  108. * Arguments : none
  109. *
  110. * Note(s) : 1) Interrupts should be disabled during this call.
  111. *********************************************************************************************************
  112. */
  113. #if OS_CPU_HOOKS_EN > 0u
  114. void OSInitHookEnd (void)
  115. {
  116. }
  117. #endif
  118. /*
  119. *********************************************************************************************************
  120. * TASK CREATION HOOK
  121. *
  122. * Description: This function is called when a task is created.
  123. *
  124. * Arguments : ptcb is a pointer to the task control block of the task being created.
  125. *
  126. * Note(s) : 1) Interrupts are disabled during this call.
  127. *********************************************************************************************************
  128. */
  129. #if OS_CPU_HOOKS_EN > 0u
  130. void OSTaskCreateHook (OS_TCB *ptcb)
  131. {
  132. #if OS_APP_HOOKS_EN > 0u
  133. App_TaskCreateHook(ptcb);
  134. #else
  135. (void)ptcb; /* Prevent compiler warning */
  136. #endif
  137. }
  138. #endif
  139. /*
  140. *********************************************************************************************************
  141. * TASK DELETION HOOK
  142. *
  143. * Description: This function is called when a task is deleted.
  144. *
  145. * Arguments : ptcb is a pointer to the task control block of the task being deleted.
  146. *
  147. * Note(s) : 1) Interrupts are disabled during this call.
  148. *********************************************************************************************************
  149. */
  150. #if OS_CPU_HOOKS_EN > 0u
  151. void OSTaskDelHook (OS_TCB *ptcb)
  152. {
  153. #if OS_APP_HOOKS_EN > 0u
  154. App_TaskDelHook(ptcb);
  155. #else
  156. (void)ptcb; /* Prevent compiler warning */
  157. #endif
  158. }
  159. #endif
  160. /*
  161. *********************************************************************************************************
  162. * IDLE TASK HOOK
  163. *
  164. * Description: This function is called by the idle task. This hook has been added to allow you to do
  165. * such things as STOP the CPU to conserve power.
  166. *
  167. * Arguments : none
  168. *
  169. * Note(s) : 1) Interrupts are enabled during this call.
  170. *********************************************************************************************************
  171. */
  172. #if OS_CPU_HOOKS_EN > 0u
  173. void OSTaskIdleHook (void)
  174. {
  175. #if OS_APP_HOOKS_EN > 0u
  176. App_TaskIdleHook();
  177. #endif
  178. }
  179. #endif
  180. /*
  181. *********************************************************************************************************
  182. * TASK RETURN HOOK
  183. *
  184. * Description: This function is called if a task accidentally returns. In other words, a task should
  185. * either be an infinite loop or delete itself when done.
  186. *
  187. * Arguments : ptcb is a pointer to the task control block of the task that is returning.
  188. *
  189. * Note(s) : none
  190. *********************************************************************************************************
  191. */
  192. #if OS_CPU_HOOKS_EN > 0u
  193. void OSTaskReturnHook (OS_TCB *ptcb)
  194. {
  195. #if OS_APP_HOOKS_EN > 0u
  196. App_TaskReturnHook(ptcb);
  197. #else
  198. (void)ptcb;
  199. #endif
  200. }
  201. #endif
  202. /*
  203. *********************************************************************************************************
  204. * STATISTIC TASK HOOK
  205. *
  206. * Description: This function is called every second by uC/OS-II's statistics task. This allows your
  207. * application to add functionality to the statistics task.
  208. *
  209. * Arguments : none
  210. *********************************************************************************************************
  211. */
  212. #if OS_CPU_HOOKS_EN > 0u
  213. void OSTaskStatHook (void)
  214. {
  215. #if OS_APP_HOOKS_EN > 0u
  216. App_TaskStatHook();
  217. #endif
  218. }
  219. #endif
  220. /*
  221. *********************************************************************************************************
  222. * INITIALIZE A TASK'S STACK
  223. *
  224. * Description: This function is called by either OSTaskCreate() or OSTaskCreateExt() to initialize the
  225. * stack frame of the task being created. This function is highly processor specific.
  226. *
  227. * Arguments : task is a pointer to the task code
  228. *
  229. * p_arg is a pointer to a user supplied data area that will be passed to the task
  230. * when the task first executes.
  231. *
  232. * ptos is a pointer to the top of stack. It is assumed that 'ptos' points to
  233. * a 'free' entry on the task stack. If OS_STK_GROWTH is set to 1 then
  234. * 'ptos' will contain the HIGHEST valid address of the stack. Similarly, if
  235. * OS_STK_GROWTH is set to 0, the 'ptos' will contains the LOWEST valid address
  236. * of the stack.
  237. *
  238. * opt specifies options that can be used to alter the behavior of OSTaskStkInit().
  239. * (see uCOS_II.H for OS_TASK_OPT_xxx).
  240. *
  241. * Returns : Always returns the location of the new top-of-stack once the processor registers have
  242. * been placed on the stack in the proper order.
  243. *
  244. * Note(s) : (1) Interrupts are enabled when task starts executing.
  245. *
  246. * (2) All tasks run in Thread mode, using process stack.
  247. *
  248. * (3) There are two different stack frames depending on whether the Floating-Point(FP)
  249. * co-processor is enabled or not.
  250. *
  251. * (a) The stack frame shown in the diagram is used when the FP co-processor is not present and
  252. * OS_TASK_OPT_SAVE_FP is disabled. In this case, the FP registers and FP Status Control
  253. * register are not saved in the stack frame.
  254. *
  255. * (b) If the FP co-processor is present but the OS_TASK_OPT_SAVE_FP is not set, then the stack
  256. * frame is saved as shown in diagram (a). Moreover, if OS_TASK_OPT_SAVE_FP is set, then the
  257. * FP registers and FP Status Control register are saved in the stack frame.
  258. *
  259. * (1) When enabling the FP co-processor, make sure to clear bits ASPEN and LSPEN in the
  260. * Floating-Point Context Control Register (FPCCR).
  261. *
  262. * +------------+ +------------+
  263. * | | | |
  264. * +------------+ +------------+
  265. * | xPSR | | xPSR |
  266. * +------------+ +------------+
  267. * |Return Addr | |Return Addr |
  268. * +------------+ +------------+
  269. * | LR(R14) | | LR(R14) |
  270. * +------------+ +------------+
  271. * | R12 | | R12 |
  272. * +------------+ +------------+
  273. * | R3 | | R3 |
  274. * +------------+ +------------+
  275. * | R2 | | R0 |
  276. * +------------+ +------------+
  277. * | R1 | | R1 |
  278. * +------------+ +------------+
  279. * | R0 | | R0 |
  280. * +------------+ +------------+
  281. * | R11 | | R11 |
  282. * +------------+ +------------+
  283. * | R10 | | R10 |
  284. * +------------+ +------------+
  285. * | R9 | | R9 |
  286. * +------------+ +------------+
  287. * | R8 | | R8 |
  288. * +------------+ +------------+
  289. * | R7 | | R7 |
  290. * +------------+ +------------+
  291. * | R6 | | R6 |
  292. * +------------+ +------------+
  293. * | R5 | | R5 |
  294. * +------------+ +------------+
  295. * | R4 | | R4 |
  296. * +------------+ +------------+
  297. * (a) | FPSCR |
  298. * +------------+
  299. * | S31 |
  300. * +------------+
  301. * .
  302. * .
  303. * .
  304. * +------------+
  305. * | S1 |
  306. +------------+
  307. * | S0 |
  308. * +------------+
  309. * (b)
  310. *
  311. * (4) The SP must be 8-byte aligned in conforming to the Procedure Call Standard for the ARM architecture
  312. *
  313. * (a) Section 2.1 of the ABI for the ARM Architecture Advisory Note. SP must be 8-byte aligned
  314. * on entry to AAPCS-Conforming functions states :
  315. *
  316. * The Procedure Call Standard for the ARM Architecture [AAPCS] requires primitive
  317. * data types to be naturally aligned according to their sizes (for size = 1, 2, 4, 8 bytes).
  318. * Doing otherwise creates more problems than it solves.
  319. *
  320. * In return for preserving the natural alignment of data, conforming code is permitted
  321. * to rely on that alignment. To support aligning data allocated on the stack, the stack
  322. * pointer (SP) is required to be 8-byte aligned on entry to a conforming function. In
  323. * practice this requirement is met if:
  324. *
  325. * (1) At each call site, the current size of the calling function’s stack frame is a multiple of 8 bytes.
  326. * This places an obligation on compilers and assembly language programmers.
  327. *
  328. * (2) SP is a multiple of 8 when control first enters a program.
  329. * This places an obligation on authors of low level OS, RTOS, and runtime library
  330. * code to align SP at all points at which control first enters
  331. * a body of (AAPCS-conforming) code.
  332. *
  333. * In turn, this requires the value of SP to be aligned to 0 modulo 8:
  334. *
  335. * (3) By exception handlers, before calling AAPCS-conforming code.
  336. *
  337. * (4) By OS/RTOS/run-time system code, before giving control to an application.
  338. *
  339. * (b) Section 2.3.1 corrective steps from the the SP must be 8-byte aligned on entry
  340. * to AAPCS-conforming functions advisory note also states.
  341. *
  342. * " This requirement extends to operating systems and run-time code for all architecture versions
  343. * prior to ARMV7 and to the A, R and M architecture profiles thereafter. Special considerations
  344. * associated with ARMV7M are discussed in §2.3.3"
  345. *
  346. * (1) Even if the SP 8-byte aligment is not a requirement for the ARMv7M profile, the stack is aligned
  347. * to 8-byte boundaries to support legacy execution enviroments.
  348. *
  349. * (c) Section 5.2.1.2 from the Procedure Call Standard for the ARM
  350. * architecture states : "The stack must also conform to the following
  351. * constraint at a public interface:
  352. *
  353. * (1) SP mod 8 = 0. The stack must be double-word aligned"
  354. *
  355. * (d) From the ARM Technical Support Knowledge Base. 8 Byte stack aligment.
  356. *
  357. * "8 byte stack alignment is a requirement of the ARM Architecture Procedure
  358. * Call Standard [AAPCS]. This specifies that functions must maintain an 8 byte
  359. * aligned stack address (e.g. 0x00, 0x08, 0x10, 0x18, 0x20) on all external
  360. * interfaces. In practice this requirement is met if:
  361. *
  362. * (1) At each external interface, the current stack pointer
  363. * is a multiple of 8 bytes.
  364. *
  365. * (2) Your OS maintains 8 byte stack alignment on its external interfaces
  366. * e.g. on task switches"
  367. *
  368. **********************************************************************************************************
  369. */
  370. OS_STK *OSTaskStkInit (void (*task)(void *p_arg), void *p_arg, OS_STK *ptos, INT16U opt)
  371. {
  372. OS_STK *p_stk;
  373. p_stk = ptos + 1u; /* Load stack pointer */
  374. /* Align the stack to 8-bytes. */
  375. p_stk = (OS_STK *)((OS_STK)(p_stk) & 0xFFFFFFF8u);
  376. /* Registers stacked as if auto-saved on exception */
  377. *(--p_stk) = (OS_STK)0x01000000uL; /* xPSR */
  378. *(--p_stk) = (OS_STK)task; /* Entry Point */
  379. *(--p_stk) = (OS_STK)OS_TaskReturn; /* R14 (LR) */
  380. *(--p_stk) = (OS_STK)0x12121212uL; /* R12 */
  381. *(--p_stk) = (OS_STK)0x03030303uL; /* R3 */
  382. *(--p_stk) = (OS_STK)0x02020202uL; /* R2 */
  383. *(--p_stk) = (OS_STK)0x01010101uL; /* R1 */
  384. *(--p_stk) = (OS_STK)p_arg; /* R0 : argument */
  385. /* Remaining registers saved on process stack */
  386. *(--p_stk) = (OS_STK)0x11111111uL; /* R11 */
  387. *(--p_stk) = (OS_STK)0x10101010uL; /* R10 */
  388. *(--p_stk) = (OS_STK)0x09090909uL; /* R9 */
  389. *(--p_stk) = (OS_STK)0x08080808uL; /* R8 */
  390. *(--p_stk) = (OS_STK)0x07070707uL; /* R7 */
  391. *(--p_stk) = (OS_STK)0x06060606uL; /* R6 */
  392. *(--p_stk) = (OS_STK)0x05050505uL; /* R5 */
  393. *(--p_stk) = (OS_STK)0x04040404uL; /* R4 */
  394. #if (OS_CPU_ARM_FP_EN > 0u)
  395. if ((opt & OS_TASK_OPT_SAVE_FP) != (INT16U)0) {
  396. *--p_stk = (OS_STK)0x02000000u; /* FPSCR */
  397. /* Initialize S0-S31 floating point registers */
  398. *--p_stk = (OS_STK)0x41F80000u; /* S31 */
  399. *--p_stk = (OS_STK)0x41F00000u; /* S30 */
  400. *--p_stk = (OS_STK)0x41E80000u; /* S29 */
  401. *--p_stk = (OS_STK)0x41E00000u; /* S28 */
  402. *--p_stk = (OS_STK)0x41D80000u; /* S27 */
  403. *--p_stk = (OS_STK)0x41D00000u; /* S26 */
  404. *--p_stk = (OS_STK)0x41C80000u; /* S25 */
  405. *--p_stk = (OS_STK)0x41C00000u; /* S24 */
  406. *--p_stk = (OS_STK)0x41B80000u; /* S23 */
  407. *--p_stk = (OS_STK)0x41B00000u; /* S22 */
  408. *--p_stk = (OS_STK)0x41A80000u; /* S21 */
  409. *--p_stk = (OS_STK)0x41A00000u; /* S20 */
  410. *--p_stk = (OS_STK)0x41980000u; /* S19 */
  411. *--p_stk = (OS_STK)0x41900000u; /* S18 */
  412. *--p_stk = (OS_STK)0x41880000u; /* S17 */
  413. *--p_stk = (OS_STK)0x41800000u; /* S16 */
  414. *--p_stk = (OS_STK)0x41700000u; /* S15 */
  415. *--p_stk = (OS_STK)0x41600000u; /* S14 */
  416. *--p_stk = (OS_STK)0x41500000u; /* S13 */
  417. *--p_stk = (OS_STK)0x41400000u; /* S12 */
  418. *--p_stk = (OS_STK)0x41300000u; /* S11 */
  419. *--p_stk = (OS_STK)0x41200000u; /* S10 */
  420. *--p_stk = (OS_STK)0x41100000u; /* S9 */
  421. *--p_stk = (OS_STK)0x41000000u; /* S8 */
  422. *--p_stk = (OS_STK)0x40E00000u; /* S7 */
  423. *--p_stk = (OS_STK)0x40C00000u; /* S6 */
  424. *--p_stk = (OS_STK)0x40A00000u; /* S5 */
  425. *--p_stk = (OS_STK)0x40800000u; /* S4 */
  426. *--p_stk = (OS_STK)0x40400000u; /* S3 */
  427. *--p_stk = (OS_STK)0x40000000u; /* S2 */
  428. *--p_stk = (OS_STK)0x3F800000u; /* S1 */
  429. *--p_stk = (OS_STK)0x00000000u; /* S0 */
  430. }
  431. #endif
  432. return (p_stk);
  433. }
  434. /*
  435. *********************************************************************************************************
  436. * TASK SWITCH HOOK
  437. *
  438. * Description: This function is called when a task switch is performed. This allows you to perform other
  439. * operations during a context switch.
  440. *
  441. * Arguments : none
  442. *
  443. * Note(s) : 1) Interrupts are disabled during this call.
  444. * 2) It is assumed that the global pointer 'OSTCBHighRdy' points to the TCB of the task that
  445. * will be 'switched in' (i.e. the highest priority task) and, 'OSTCBCur' points to the
  446. * task being switched out (i.e. the preempted task).
  447. *********************************************************************************************************
  448. */
  449. #if (OS_CPU_HOOKS_EN > 0u) && (OS_TASK_SW_HOOK_EN > 0u)
  450. void OSTaskSwHook (void)
  451. {
  452. #if (OS_CPU_ARM_FP_EN > 0u)
  453. if ((OSTCBCur->OSTCBOpt & OS_TASK_OPT_SAVE_FP) != (INT16U)0) {
  454. OS_CPU_FP_Reg_Push(OSTCBCur->OSTCBStkPtr);
  455. }
  456. if ((OSTCBHighRdy->OSTCBOpt & OS_TASK_OPT_SAVE_FP) != (INT16U)0) {
  457. OS_CPU_FP_Reg_Pop(OSTCBHighRdy->OSTCBStkPtr);
  458. }
  459. #endif
  460. #if OS_APP_HOOKS_EN > 0u
  461. App_TaskSwHook();
  462. #endif
  463. }
  464. #endif
  465. /*
  466. *********************************************************************************************************
  467. * OS_TCBInit() HOOK
  468. *
  469. * Description: This function is called by OS_TCBInit() after setting up most of the TCB.
  470. *
  471. * Arguments : ptcb is a pointer to the TCB of the task being created.
  472. *
  473. * Note(s) : 1) Interrupts may or may not be ENABLED during this call.
  474. *********************************************************************************************************
  475. */
  476. #if OS_CPU_HOOKS_EN > 0u
  477. void OSTCBInitHook (OS_TCB *ptcb)
  478. {
  479. #if OS_APP_HOOKS_EN > 0u
  480. App_TCBInitHook(ptcb);
  481. #else
  482. (void)ptcb; /* Prevent compiler warning */
  483. #endif
  484. }
  485. #endif
  486. /*
  487. *********************************************************************************************************
  488. * TICK HOOK
  489. *
  490. * Description: This function is called every tick.
  491. *
  492. * Arguments : none
  493. *
  494. * Note(s) : 1) Interrupts may or may not be ENABLED during this call.
  495. *********************************************************************************************************
  496. */
  497. #if (OS_CPU_HOOKS_EN > 0u) && (OS_TIME_TICK_HOOK_EN > 0u)
  498. void OSTimeTickHook (void)
  499. {
  500. #if OS_APP_HOOKS_EN > 0u
  501. App_TimeTickHook();
  502. #endif
  503. #if OS_TMR_EN > 0u
  504. OSTmrCtr++;
  505. if (OSTmrCtr >= (OS_TICKS_PER_SEC / OS_TMR_CFG_TICKS_PER_SEC)) {
  506. OSTmrCtr = 0;
  507. OSTmrSignal();
  508. }
  509. #endif
  510. }
  511. #endif
  512. /*
  513. *********************************************************************************************************
  514. * SYS TICK HANDLER
  515. *
  516. * Description: Handle the system tick (SysTick) interrupt, which is used to generate the uC/OS-II tick
  517. * interrupt.
  518. *
  519. * Arguments : None.
  520. *
  521. * Note(s) : 1) This function MUST be placed on entry 15 of the Cortex-M3 vector table.
  522. *********************************************************************************************************
  523. */
  524. /*
  525. void OS_CPU_SysTickHandler (void)
  526. {
  527. OS_CPU_SR cpu_sr;
  528. OS_ENTER_CRITICAL();
  529. OSIntNesting++;
  530. OS_EXIT_CRITICAL();
  531. OSTimeTick();
  532. OSIntExit();
  533. }
  534. */
  535. /*
  536. *********************************************************************************************************
  537. * INITIALIZE SYS TICK
  538. *
  539. * Description: Initialize the SysTick.
  540. *
  541. * Arguments : cnts Number of SysTick counts between two OS tick interrupts.
  542. *
  543. * Note(s) : 1) This function MUST be called after OSStart() & after processor initialization.
  544. *********************************************************************************************************
  545. */
  546. /*void OS_CPU_SysTickInit (INT32U cnts)
  547. {
  548. INT32U prio;
  549. OS_CPU_CM4_NVIC_ST_RELOAD = cnts - 1u;
  550. prio = OS_CPU_CM4_NVIC_SHPRI3;
  551. prio &= DEF_BIT_FIELD(24, 0);
  552. prio |= DEF_BIT_MASK(OS_CPU_CFG_SYSTICK_PRIO, 24);
  553. OS_CPU_CM4_NVIC_SHPRI3 = prio;
  554. OS_CPU_CM4_NVIC_ST_CTRL |= OS_CPU_CM4_NVIC_ST_CTRL_CLK_SRC |
  555. OS_CPU_CM4_NVIC_ST_CTRL_ENABLE;
  556. OS_CPU_CM4_NVIC_ST_CTRL |= OS_CPU_CM4_NVIC_ST_CTRL_INTEN;
  557. }
  558. */