os_cpu.h
上传用户:yj_qqy
上传日期:2017-01-28
资源大小:2911k
文件大小:5k
源码类别:

uCOS

开发平台:

C/C++

  1. /*
  2. *********************************************************************************************************
  3. *                                               uC/OS-II
  4. *                                         The Real-Time Kernel
  5. *
  6. *
  7. *                                (c) Copyright 2006, Micrium, Weston, FL
  8. *                                          All Rights Reserved
  9. *
  10. *                                           ARM Cortex-M3 Port
  11. *
  12. * File      : OS_CPU.H
  13. * Version   : V2.86
  14. * By        : Jean J. Labrosse
  15. *
  16. * For       : ARMv7M Cortex-M3
  17. * Mode      : Thumb2
  18. * Toolchain : RealView Development Suite
  19. *             RealView Microcontroller Development Kit (MDK)
  20. *             ARM Developer Suite (ADS)
  21. *             Keil uVision
  22. *********************************************************************************************************
  23. */
  24. #ifndef  OS_CPU_H
  25. #define  OS_CPU_H
  26. #ifdef   OS_CPU_GLOBALS
  27. #define  OS_CPU_EXT
  28. #else
  29. #define  OS_CPU_EXT  extern
  30. #endif
  31. /*
  32. *********************************************************************************************************
  33. *                                              DATA TYPES
  34. *                                         (Compiler Specific)
  35. *********************************************************************************************************
  36. */
  37. typedef unsigned char  BOOLEAN;
  38. typedef unsigned char  INT8U;                    /* Unsigned  8 bit quantity                           */
  39. typedef signed   char  INT8S;                    /* Signed    8 bit quantity                           */
  40. typedef unsigned short INT16U;                   /* Unsigned 16 bit quantity                           */
  41. typedef signed   short INT16S;                   /* Signed   16 bit quantity                           */
  42. typedef unsigned int   INT32U;                   /* Unsigned 32 bit quantity                           */
  43. typedef signed   int   INT32S;                   /* Signed   32 bit quantity                           */
  44. typedef float          FP32;                     /* Single precision floating point                    */
  45. typedef double         FP64;                     /* Double precision floating point                    */
  46. typedef unsigned int   OS_STK;                   /* Each stack entry is 32-bit wide                    */
  47. typedef unsigned int   OS_CPU_SR;                /* Define size of CPU status register (PSR = 32 bits) */
  48. /*
  49. *********************************************************************************************************
  50. *                                              Cortex-M1
  51. *                                      Critical Section Management
  52. *
  53. * Method #1:  Disable/Enable interrupts using simple instructions.  After critical section, interrupts
  54. *             will be enabled even if they were disabled before entering the critical section.
  55. *             NOT IMPLEMENTED
  56. *
  57. * Method #2:  Disable/Enable interrupts by preserving the state of interrupts.  In other words, if
  58. *             interrupts were disabled before entering the critical section, they will be disabled when
  59. *             leaving the critical section.
  60. *             NOT IMPLEMENTED
  61. *
  62. * Method #3:  Disable/Enable interrupts by preserving the state of interrupts.  Generally speaking you
  63. *             would store the state of the interrupt disable flag in the local variable 'cpu_sr' and then
  64. *             disable interrupts.  'cpu_sr' is allocated in all of uC/OS-II's functions that need to
  65. *             disable interrupts.  You would restore the interrupt disable state by copying back 'cpu_sr'
  66. *             into the CPU's status register.
  67. *********************************************************************************************************
  68. */
  69. #define  OS_CRITICAL_METHOD   3
  70. #if OS_CRITICAL_METHOD == 3
  71. #define  OS_ENTER_CRITICAL()  {cpu_sr = OS_CPU_SR_Save();}
  72. #define  OS_EXIT_CRITICAL()   {OS_CPU_SR_Restore(cpu_sr);}
  73. #endif
  74. /*
  75. *********************************************************************************************************
  76. *                                        Cortex-M3 Miscellaneous
  77. *********************************************************************************************************
  78. */
  79. #define  OS_STK_GROWTH        1                   /* Stack grows from HIGH to LOW memory on ARM        */
  80. #define  OS_TASK_SW()         OSCtxSw()
  81. /*
  82. *********************************************************************************************************
  83. *                                              PROTOTYPES
  84. *********************************************************************************************************
  85. */
  86. #if OS_CRITICAL_METHOD == 3                       /* See OS_CPU_A.ASM                                  */
  87. OS_CPU_SR  OS_CPU_SR_Save(void);
  88. void       OS_CPU_SR_Restore(OS_CPU_SR cpu_sr);
  89. #endif
  90. void       OSCtxSw(void);
  91. void       OSIntCtxSw(void);
  92. void       OSStartHighRdy(void);
  93. void       OS_CPU_PendSVHandler(void);
  94.                                                   /* See OS_CPU_C.C                                    */
  95. void       OS_CPU_SysTickHandler(void);
  96. void       OS_CPU_SysTickInit(void);
  97.                                                   /* See BSP.C                                         */
  98. INT32U     OS_CPU_SysTickClkFreq(void);
  99. //OS_CPU_EXT INT32U OSInterrputSum;
  100. #endif