Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 

191 linhas
8.4 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.H
  13. * Version : V2.92.09
  14. * By : JJL
  15. * JBL
  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. * application/product. We provide ALL the source code for your convenience and to help you
  23. * experience uC/OS-II. The fact that the source is provided does NOT mean that you can use
  24. * it commercially without paying a licensing fee.
  25. *
  26. * Knowledge of the source code may NOT be used to develop a similar product.
  27. *
  28. * Please help us continue to provide the embedded community with the finest software available.
  29. * Your honesty is greatly appreciated.
  30. *
  31. * You can contact us at www.micrium.com, or by phone at +1 (954) 217-2036.
  32. *
  33. * For : ARMv7 Cortex-M4
  34. * Mode : Thumb-2 ISA
  35. * Toolchain : IAR EWARM
  36. *********************************************************************************************************
  37. */
  38. #ifndef OS_CPU_H
  39. #define OS_CPU_H
  40. #ifdef OS_CPU_GLOBALS
  41. #define OS_CPU_EXT
  42. #else
  43. #define OS_CPU_EXT extern
  44. #endif
  45. #ifndef OS_CPU_EXCEPT_STK_SIZE
  46. #define OS_CPU_EXCEPT_STK_SIZE 128u /* Default exception stack size is 128 OS_STK entries */
  47. #endif
  48. /*
  49. *********************************************************************************************************
  50. * DEFINES
  51. *********************************************************************************************************
  52. */
  53. #ifdef __ARMVFP__
  54. #define OS_CPU_ARM_FP_EN 1u
  55. #else
  56. #define OS_CPU_ARM_FP_EN 0u
  57. #endif
  58. /*
  59. *********************************************************************************************************
  60. * OS TICK INTERRUPT PRIORITY CONFIGURATION
  61. *
  62. * Note(s) : (1) For systems that don't need any high, real-time priority interrupts; the tick interrupt
  63. * should be configured as the highest priority interrupt but won't adversely affect system
  64. * operations.
  65. *
  66. * (2) For systems that need one or more high, real-time interrupts; these should be configured
  67. * higher than the tick interrupt which MAY delay execution of the tick interrupt.
  68. *
  69. * (a) If the higher priority interrupts do NOT continually consume CPU cycles but only
  70. * occasionally delay tick interrupts, then the real-time interrupts can successfully
  71. * handle their intermittent/periodic events with the system not losing tick interrupts
  72. * but only increasing the jitter.
  73. *
  74. * (b) If the higher priority interrupts consume enough CPU cycles to continually delay the
  75. * tick interrupt, then the CPU/system is most likely over-burdened & can't be expected
  76. * to handle all its interrupts/tasks. The system time reference gets compromised as a
  77. * result of losing tick interrupts.
  78. *********************************************************************************************************
  79. */
  80. #define OS_CPU_CFG_SYSTICK_PRIO 0u
  81. /*
  82. *********************************************************************************************************
  83. * DATA TYPES
  84. * (Compiler Specific)
  85. *********************************************************************************************************
  86. */
  87. typedef unsigned char BOOLEAN;
  88. typedef unsigned char INT8U; /* Unsigned 8 bit quantity */
  89. typedef signed char INT8S; /* Signed 8 bit quantity */
  90. typedef unsigned short INT16U; /* Unsigned 16 bit quantity */
  91. typedef signed short INT16S; /* Signed 16 bit quantity */
  92. typedef unsigned int INT32U; /* Unsigned 32 bit quantity */
  93. typedef signed int INT32S; /* Signed 32 bit quantity */
  94. typedef float FP32; /* Single precision floating point */
  95. typedef double FP64; /* Double precision floating point */
  96. typedef unsigned int OS_STK; /* Each stack entry is 32-bit wide */
  97. typedef unsigned int OS_CPU_SR; /* Define size of CPU status register (PSR = 32 bits) */
  98. /*
  99. *********************************************************************************************************
  100. * Cortex-M4
  101. * Critical Section Management
  102. *
  103. * Method #1: Disable/Enable interrupts using simple instructions. After critical section, interrupts
  104. * will be enabled even if they were disabled before entering the critical section.
  105. * NOT IMPLEMENTED
  106. *
  107. * Method #2: Disable/Enable interrupts by preserving the state of interrupts. In other words, if
  108. * interrupts were disabled before entering the critical section, they will be disabled when
  109. * leaving the critical section.
  110. * NOT IMPLEMENTED
  111. *
  112. * Method #3: Disable/Enable interrupts by preserving the state of interrupts. Generally speaking you
  113. * would store the state of the interrupt disable flag in the local variable 'cpu_sr' and then
  114. * disable interrupts. 'cpu_sr' is allocated in all of uC/OS-II's functions that need to
  115. * disable interrupts. You would restore the interrupt disable state by copying back 'cpu_sr'
  116. * into the CPU's status register.
  117. *********************************************************************************************************
  118. */
  119. #define OS_CRITICAL_METHOD 3u
  120. #if OS_CRITICAL_METHOD == 3u
  121. #define OS_ENTER_CRITICAL() {cpu_sr = OS_CPU_SR_Save();}
  122. #define OS_EXIT_CRITICAL() {OS_CPU_SR_Restore(cpu_sr);}
  123. #endif
  124. /*
  125. *********************************************************************************************************
  126. * Cortex-M4 Miscellaneous
  127. *********************************************************************************************************
  128. */
  129. #define OS_STK_GROWTH 1u /* Stack grows from HIGH to LOW memory on ARM */
  130. #define OS_TASK_SW() OSCtxSw()
  131. /*
  132. *********************************************************************************************************
  133. * GLOBAL VARIABLES
  134. *********************************************************************************************************
  135. */
  136. OS_CPU_EXT OS_STK OS_CPU_ExceptStk[OS_CPU_EXCEPT_STK_SIZE];
  137. OS_CPU_EXT OS_STK *OS_CPU_ExceptStkBase;
  138. /*
  139. *********************************************************************************************************
  140. * FUNCTION PROTOTYPES
  141. *********************************************************************************************************
  142. */
  143. #if OS_CRITICAL_METHOD == 3u /* See OS_CPU_A.ASM */
  144. OS_CPU_SR OS_CPU_SR_Save (void);
  145. void OS_CPU_SR_Restore (OS_CPU_SR cpu_sr);
  146. #endif
  147. void OSCtxSw (void);
  148. void OSIntCtxSw (void);
  149. void OSStartHighRdy (void);
  150. void OS_CPU_PendSVHandler (void);
  151. /* See OS_CPU_C.C */
  152. //void OS_CPU_SysTickHandler (void);
  153. //void OS_CPU_SysTickInit (INT32U cnts);
  154. #if (OS_CPU_ARM_FP_EN > 0u)
  155. void OS_CPU_FP_Reg_Push (OS_STK *stkPtr);
  156. void OS_CPU_FP_Reg_Pop (OS_STK *stkPtr);
  157. #endif
  158. #endif