No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 

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