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

uCOS

开发平台:

C/C++

  1. /*
  2. *********************************************************************************************************
  3. *                                               uC/CPU
  4. *                                    CPU CONFIGURATION & PORT LAYER
  5. *
  6. *                          (c) Copyright 2004-2008; Micrium, Inc.; Weston, FL
  7. *
  8. *               All rights reserved.  Protected by international copyright laws.
  9. *
  10. *               uC/CPU is provided in source form for FREE evaluation, for educational
  11. *               use or peaceful research.  If you plan on using uC/CPU in a commercial
  12. *               product you need to contact Micrium to properly license its use in your
  13. *               product.  We provide ALL the source code for your convenience and to
  14. *               help you experience uC/CPU.  The fact that the source code is provided
  15. *               does NOT mean that you can use it without paying a licensing fee.
  16. *
  17. *               Knowledge of the source code may NOT be used to develop a similar product.
  18. *
  19. *               Please help us continue to provide the Embedded community with the finest
  20. *               software available.  Your honesty is greatly appreciated.
  21. *********************************************************************************************************
  22. */
  23. /*
  24. *********************************************************************************************************
  25. *
  26. *                                            CPU PORT FILE
  27. *
  28. *                                            ARM-Cortex-M3
  29. *                                      RealView Development Suite
  30. *                            RealView Microcontroller Development Kit (MDK)
  31. *                                       ARM Developer Suite (ADS)
  32. *                                            Keil uVision
  33. *
  34. * Filename      : cpu.h
  35. * Version       : V1.19
  36. * Programmer(s) : JJL
  37. *                 BAN
  38. *********************************************************************************************************
  39. */
  40. /*
  41. *********************************************************************************************************
  42. *                                               MODULE
  43. *********************************************************************************************************
  44. */
  45. #ifndef  CPU_CFG_MODULE_PRESENT
  46. #define  CPU_CFG_MODULE_PRESENT
  47. /*
  48. *********************************************************************************************************
  49. *                                          CPU INCLUDE FILES
  50. *
  51. * Note(s) : (1) The following CPU files are located in the following directories :
  52. *
  53. *               (a) <CPU-Compiler Directory>cpu_def.h
  54. *
  55. *               (b) <CPU-Compiler Directory><cpu><compiler>cpu*.*
  56. *
  57. *                       where
  58. *                               <CPU-Compiler Directory>    directory path for common   CPU-compiler software
  59. *                               <cpu>                       directory name for specific CPU
  60. *                               <compiler>                  directory name for specific compiler
  61. *
  62. *           (2) Compiler MUST be configured to include the '<CPU-Compiler Directory>' directory & the
  63. *               specific CPU-compiler directory as additional include path directories.
  64. *********************************************************************************************************
  65. */
  66. #include  <cpu_def.h>
  67. /*$PAGE*/
  68. /*
  69. *********************************************************************************************************
  70. *                                    CONFIGURE STANDARD DATA TYPES
  71. *
  72. * Note(s) : (1) Configure standard data types according to CPU-/compiler-specifications.
  73. *
  74. *           (2) (a) (1) 'CPU_FNCT_VOID' data type defined to replace the commonly-used function pointer
  75. *                       data type of a pointer to a function which returns void & has no arguments.
  76. *
  77. *                   (2) Example function pointer usage :
  78. *
  79. *                           CPU_FNCT_VOID  FnctName;
  80. *
  81. *                           FnctName();
  82. *
  83. *               (b) (1) 'CPU_FNCT_PTR'  data type defined to replace the commonly-used function pointer
  84. *                       data type of a pointer to a function which returns void & has a single void
  85. *                       pointer argument.
  86. *
  87. *                   (2) Example function pointer usage :
  88. *
  89. *                           CPU_FNCT_PTR   FnctName;
  90. *                           void          *pobj
  91. *
  92. *                           FnctName(pobj);
  93. *********************************************************************************************************
  94. */
  95. typedef            void       CPU_VOID;
  96. typedef  unsigned  char       CPU_CHAR;                         /*  8-bit character                                     */
  97. typedef  unsigned  char       CPU_BOOLEAN;                      /*  8-bit boolean or logical                            */
  98. typedef  unsigned  char       CPU_INT08U;                       /*  8-bit unsigned integer                              */
  99. typedef    signed  char       CPU_INT08S;                       /*  8-bit   signed integer                              */
  100. typedef  unsigned  short      CPU_INT16U;                       /* 16-bit unsigned integer                              */
  101. typedef    signed  short      CPU_INT16S;                       /* 16-bit   signed integer                              */
  102. typedef  unsigned  int        CPU_INT32U;                       /* 32-bit unsigned integer                              */
  103. typedef    signed  int        CPU_INT32S;                       /* 32-bit   signed integer                              */
  104. typedef  unsigned  long long  CPU_INT64U;                       /* 64-bit unsigned integer                              */
  105. typedef    signed  long long  CPU_INT64S;                       /* 64-bit   signed integer                              */
  106. typedef            float      CPU_FP32;                         /* 32-bit floating point                                */
  107. typedef            double     CPU_FP64;                         /* 64-bit floating point                                */
  108. typedef            void     (*CPU_FNCT_VOID)(void);             /* See Note #2a.                                        */
  109. typedef            void     (*CPU_FNCT_PTR )(void *);           /* See Note #2b.                                        */
  110. /*$PAGE*/
  111. /*
  112. *********************************************************************************************************
  113. *                                       CPU WORD CONFIGURATION
  114. *
  115. * Note(s) : (1) Configure CPU_CFG_ADDR_SIZE & CPU_CFG_DATA_SIZE with CPU's word sizes :
  116. *
  117. *                   CPU_WORD_SIZE_08             8-bit word size
  118. *                   CPU_WORD_SIZE_16            16-bit word size
  119. *                   CPU_WORD_SIZE_32            32-bit word size
  120. *                   CPU_WORD_SIZE_64            64-bit word size            See Note #1a
  121. *
  122. *               (a) 64-bit word size NOT currently supported.
  123. *
  124. *           (2) Configure CPU_CFG_ENDIAN_TYPE with CPU's data-word-memory order :
  125. *
  126. *                   CPU_ENDIAN_TYPE_BIG         Big-   endian word order (CPU words' most  significant
  127. *                                                                         octet @ lowest memory address)
  128. *                   CPU_ENDIAN_TYPE_LITTLE      Little-endian word order (CPU words' least significant
  129. *                                                                         octet @ lowest memory address)
  130. *********************************************************************************************************
  131. */
  132.                                                                 /* Define  CPU         word sizes (see Note #1) :       */
  133. #define  CPU_CFG_ADDR_SIZE              CPU_WORD_SIZE_32        /* Defines CPU address word size.                       */
  134. #define  CPU_CFG_DATA_SIZE              CPU_WORD_SIZE_32        /* Defines CPU data    word size.                       */
  135. #define  CPU_CFG_ENDIAN_TYPE            CPU_ENDIAN_TYPE_LITTLE  /* Defines CPU data    word-memory order.               */
  136. /*
  137. *********************************************************************************************************
  138. *                                 CONFIGURE CPU ADDRESS & DATA TYPES
  139. *********************************************************************************************************
  140. */
  141.                                                                 /* CPU address type based on address bus size.          */
  142. #if     (CPU_CFG_ADDR_SIZE == CPU_WORD_SIZE_32)
  143. typedef  CPU_INT32U  CPU_ADDR;
  144. #elif   (CPU_CFG_ADDR_SIZE == CPU_WORD_SIZE_16)
  145. typedef  CPU_INT16U  CPU_ADDR;
  146. #else
  147. typedef  CPU_INT08U  CPU_ADDR;
  148. #endif
  149.                                                                 /* CPU data    type based on data    bus size.          */
  150. #if     (CPU_CFG_DATA_SIZE == CPU_WORD_SIZE_32)
  151. typedef  CPU_INT32U  CPU_DATA;
  152. #elif   (CPU_CFG_DATA_SIZE == CPU_WORD_SIZE_16)
  153. typedef  CPU_INT16U  CPU_DATA;
  154. #else
  155. typedef  CPU_INT08U  CPU_DATA;
  156. #endif
  157. typedef  CPU_DATA    CPU_ALIGN;                                 /* Defines CPU data-word-alignment size.                */
  158. typedef  CPU_DATA    CPU_SIZE_T;                                /* Defines CPU standard 'size_t'   size.                */
  159. /*$PAGE*/
  160. /*
  161. *********************************************************************************************************
  162. *                                   CRITICAL SECTION CONFIGURATION
  163. *
  164. * Note(s) : (1) Configure CPU_CFG_CRITICAL_METHOD with CPU's/compiler's critical section method :
  165. *
  166. *                                                       Enter/Exit critical sections by ...
  167. *
  168. *                   CPU_CRITICAL_METHOD_INT_DIS_EN      Disable/Enable interrupts
  169. *                   CPU_CRITICAL_METHOD_STATUS_STK      Push/Pop       interrupt status onto stack
  170. *                   CPU_CRITICAL_METHOD_STATUS_LOCAL    Save/Restore   interrupt status to local variable
  171. *
  172. *               (a) CPU_CRITICAL_METHOD_INT_DIS_EN  is NOT a preferred method since it does NOT support
  173. *                   multiple levels of interrupts.  However, with some CPUs/compilers, this is the only
  174. *                   available method.
  175. *
  176. *               (b) CPU_CRITICAL_METHOD_STATUS_STK    is one preferred method since it DOES support multiple
  177. *                   levels of interrupts.  However, this method assumes that the compiler allows in-line
  178. *                   assembly AND will correctly modify the local stack pointer when interrupt status is
  179. *                   pushed/popped onto the stack.
  180. *
  181. *               (c) CPU_CRITICAL_METHOD_STATUS_LOCAL  is one preferred method since it DOES support multiple
  182. *                   levels of interrupts.  However, this method assumes that the compiler provides C-level
  183. *                   &/or assembly-level functionality for the following :
  184. *
  185. *                     ENTER CRITICAL SECTION :
  186. *                       (a) Save    interrupt status into a local variable
  187. *                       (b) Disable interrupts
  188. *
  189. *                     EXIT  CRITICAL SECTION :
  190. *                       (c) Restore interrupt status from a local variable
  191. *
  192. *           (2) Critical section macro's most likely require inline assembly.  If the compiler does NOT
  193. *               allow inline assembly in C source files, critical section macro's MUST call an assembly
  194. *               subroutine defined in a 'cpu_a.asm' file located in the following software directory :
  195. *
  196. *                   <CPU-Compiler Directory><cpu><compiler>
  197. *
  198. *                       where
  199. *                               <CPU-Compiler Directory>    directory path for common   CPU-compiler software
  200. *                               <cpu>                       directory name for specific CPU
  201. *                               <compiler>                  directory name for specific compiler
  202. *
  203. *           (3) To save/restore interrupt status, a local variable 'cpu_sr' of type 'CPU_SR' MAY need to
  204. *               be declared (e.g. if 'CPU_CRITICAL_METHOD_STATUS_LOCAL' method is configured).  Configure
  205. *               'CPU_SR' data type with the appropriate-sized CPU data type large enough to completely
  206. *               store the CPU's/compiler's status word.
  207. *********************************************************************************************************
  208. */
  209. typedef  CPU_INT32U  CPU_SR;                                    /* Defines   CPU status register size (see Note #3).    */
  210.                                                                 /* Configure CPU critical method      (see Note #1) :   */
  211. #define  CPU_CFG_CRITICAL_METHOD        CPU_CRITICAL_METHOD_STATUS_LOCAL
  212. #define  CPU_CRITICAL_ENTER()           { cpu_sr = CPU_SR_Save(); }
  213. #define  CPU_CRITICAL_EXIT()            { CPU_SR_Restore(cpu_sr); }
  214. /*
  215. *********************************************************************************************************
  216. *                                         FUNCTION PROTOTYPES
  217. *********************************************************************************************************
  218. */
  219. void        CPU_IntDis       (void);
  220. void        CPU_IntEn        (void);
  221. void        CPU_IntSrcDis    (CPU_INT08U  pos);
  222. void        CPU_IntSrcEn     (CPU_INT08U  pos);
  223. CPU_INT16S  CPU_IntSrcPrioGet(CPU_INT08U  pos);
  224. void        CPU_IntSrcPrioSet(CPU_INT08U  pos,
  225.                               CPU_INT08U  prio);
  226. CPU_SR      CPU_SR_Save      (void);
  227. void        CPU_SR_Restore   (CPU_SR      cpu_sr);
  228. CPU_INT32U  CPU_CntLeadZeros (CPU_INT32U  val);
  229. CPU_INT32U  CPU_RevBits      (CPU_INT32U  val);
  230. void        CPU_WaitForInt   (void);
  231. void        CPU_WaitForExcept(void);
  232. void        CPU_BitBandClr   (CPU_ADDR    addr,
  233.                               CPU_INT08U  bit_nbr);
  234. void        CPU_BitBandSet   (CPU_ADDR    addr,
  235.                               CPU_INT08U  bit_nbr);
  236. /*
  237. *********************************************************************************************************
  238. *                                           INTERRUPT SOURCES
  239. *********************************************************************************************************
  240. */
  241. #define  CPU_INT_STK_PTR                                   0
  242. #define  CPU_INT_RESET                                     1
  243. #define  CPU_INT_NMI                                       2
  244. #define  CPU_INT_HFAULT                                    3
  245. #define  CPU_INT_MEM                                       4
  246. #define  CPU_INT_BUSFAULT                                  5
  247. #define  CPU_INT_USAGEFAULT                                6
  248. #define  CPU_INT_RSVD_07                                   7
  249. #define  CPU_INT_RSVD_08                                   8
  250. #define  CPU_INT_RSVD_09                                   9
  251. #define  CPU_INT_RSVD_10                                  10
  252. #define  CPU_INT_SVCALL                                   11
  253. #define  CPU_INT_DBGMON                                   12
  254. #define  CPU_INT_RSVD_13                                  13
  255. #define  CPU_INT_PENDSV                                   14
  256. #define  CPU_INT_SYSTICK                                  15
  257. /*
  258. *********************************************************************************************************
  259. *                                             CPU REGISTERS
  260. *********************************************************************************************************
  261. */
  262. #define  CPU_REG_NVIC_NVIC              (*((volatile CPU_INT32U *)(0xE000E004))) /* Int Ctrl'er Type Reg.               */
  263. #define  CPU_REG_NVIC_ST_CTRL           (*((volatile CPU_INT32U *)(0xE000E010))) /* SysTick Ctrl & Status Reg.          */
  264. #define  CPU_REG_NVIC_ST_RELOAD         (*((volatile CPU_INT32U *)(0xE000E014))) /* SysTick Reload      Value Reg.      */
  265. #define  CPU_REG_NVIC_ST_CURRENT        (*((volatile CPU_INT32U *)(0xE000E018))) /* SysTick Current     Value Reg.      */
  266. #define  CPU_REG_NVIC_ST_CAL            (*((volatile CPU_INT32U *)(0xE000E01C))) /* SysTick Calibration Value Reg.      */
  267.                                                                                  /* IRQ Set En Reg.                     */
  268. #define  CPU_REG_NVIC_SETEN(n)          (*((volatile CPU_INT32U *)(0xE000E100 + (n) * 4)))
  269.                                                                                  /* IRQ Clr En Reg.                     */
  270. #define  CPU_REG_NVIC_CLREN(n)          (*((volatile CPU_INT32U *)(0xE000E180 + (n) * 4)))
  271.                                                                                  /* IRQ Set Pending Reg.                */
  272. #define  CPU_REG_NVIC_SETPEND(n)        (*((volatile CPU_INT32U *)(0xE000E200 + (n) * 4)))
  273.                                                                                  /* IRQ Clr Pending Reg.                */
  274. #define  CPU_REG_NVIC_CLRPEND(n)        (*((volatile CPU_INT32U *)(0xE000E280 + (n) * 4)))
  275.                                                                                  /* IRQ Active Reg.                     */
  276. #define  CPU_REG_NVIC_ACTIVE(n)         (*((volatile CPU_INT32U *)(0xE000E300 + (n) * 4)))
  277.                                                                                  /* IRQ Prio Reg.                       */
  278. #define  CPU_REG_NVIC_PRIO(n)           (*((volatile CPU_INT32U *)(0xE000E400 + (n) * 4)))
  279. #define  CPU_REG_NVIC_CPUID             (*((volatile CPU_INT32U *)(0xE000ED00))) /* CPUID Base Reg.                     */
  280. #define  CPU_REG_NVIC_ICSR              (*((volatile CPU_INT32U *)(0xE000ED04))) /* Int Ctrl State  Reg.                */
  281. #define  CPU_REG_NVIC_VTOR              (*((volatile CPU_INT32U *)(0xE000ED08))) /* Vect Tbl Offset Reg.                */
  282. #define  CPU_REG_NVIC_AIRCR             (*((volatile CPU_INT32U *)(0xE000ED0C))) /* App Int/Reset Ctrl Reg.             */
  283. #define  CPU_REG_NVIC_SCR               (*((volatile CPU_INT32U *)(0xE000ED10))) /* System Ctrl Reg.                    */
  284. #define  CPU_REG_NVIC_CCR               (*((volatile CPU_INT32U *)(0xE000ED14))) /* Cfg    Ctrl Reg.                    */
  285. #define  CPU_REG_NVIC_SHPRI1            (*((volatile CPU_INT32U *)(0xE000ED18))) /* System Handlers  4 to  7 Prio.      */
  286. #define  CPU_REG_NVIC_SHPRI2            (*((volatile CPU_INT32U *)(0xE000ED1C))) /* System Handlers  8 to 11 Prio.      */
  287. #define  CPU_REG_NVIC_SHPRI3            (*((volatile CPU_INT32U *)(0xE000ED20))) /* System Handlers 12 to 15 Prio.      */
  288. #define  CPU_REG_NVIC_SHCSR             (*((volatile CPU_INT32U *)(0xE000ED24))) /* System Handler Ctrl & State Reg.    */
  289. #define  CPU_REG_NVIC_CFSR              (*((volatile CPU_INT32U *)(0xE000ED28))) /* Configurable Fault Status Reg.      */
  290. #define  CPU_REG_NVIC_HFSR              (*((volatile CPU_INT32U *)(0xE000ED2C))) /* Hard  Fault Status Reg.             */
  291. #define  CPU_REG_NVIC_DFSR              (*((volatile CPU_INT32U *)(0xE000ED30))) /* Debug Fault Status Reg.             */
  292. #define  CPU_REG_NVIC_MMFAR             (*((volatile CPU_INT32U *)(0xE000ED34))) /* Mem Manage Addr Reg.                */
  293. #define  CPU_REG_NVIC_BFAR              (*((volatile CPU_INT32U *)(0xE000ED38))) /* Bus Fault  Addr Reg.                */
  294. #define  CPU_REG_NVIC_AFSR              (*((volatile CPU_INT32U *)(0xE000ED3C))) /* Aux Fault Status Reg.               */
  295. #define  CPU_REG_NVIC_PFR0              (*((volatile CPU_INT32U *)(0xE000ED40))) /* Processor Feature Reg 0.            */
  296. #define  CPU_REG_NVIC_PFR1              (*((volatile CPU_INT32U *)(0xE000ED44))) /* Processor Feature Reg 1.            */
  297. #define  CPU_REG_NVIC_DFR0              (*((volatile CPU_INT32U *)(0xE000ED48))) /* Debug     Feature Reg 0.            */
  298. #define  CPU_REG_NVIC_AFR0              (*((volatile CPU_INT32U *)(0xE000ED4C))) /* Aux       Feature Reg 0.            */
  299. #define  CPU_REG_NVIC_MMFR0             (*((volatile CPU_INT32U *)(0xE000ED50))) /* Memory Model Feature Reg 0.         */
  300. #define  CPU_REG_NVIC_MMFR1             (*((volatile CPU_INT32U *)(0xE000ED54))) /* Memory Model Feature Reg 1.         */
  301. #define  CPU_REG_NVIC_MMFR2             (*((volatile CPU_INT32U *)(0xE000ED58))) /* Memory Model Feature Reg 2.         */
  302. #define  CPU_REG_NVIC_MMFR3             (*((volatile CPU_INT32U *)(0xE000ED5C))) /* Memory Model Feature Reg 3.         */
  303. #define  CPU_REG_NVIC_ISAFR0            (*((volatile CPU_INT32U *)(0xE000ED60))) /* ISA Feature Reg 0.                  */
  304. #define  CPU_REG_NVIC_ISAFR1            (*((volatile CPU_INT32U *)(0xE000ED64))) /* ISA Feature Reg 1.                  */
  305. #define  CPU_REG_NVIC_ISAFR2            (*((volatile CPU_INT32U *)(0xE000ED68))) /* ISA Feature Reg 2.                  */
  306. #define  CPU_REG_NVIC_ISAFR3            (*((volatile CPU_INT32U *)(0xE000ED6C))) /* ISA Feature Reg 3.                  */
  307. #define  CPU_REG_NVIC_ISAFR4            (*((volatile CPU_INT32U *)(0xE000ED70))) /* ISA Feature Reg 4.                  */
  308. #define  CPU_REG_NVIC_SW_TRIG           (*((volatile CPU_INT32U *)(0xE000EF00))) /* Software Trigger Int Reg.           */
  309. #define  CPU_REG_MPU_TYPE               (*((volatile CPU_INT32U *)(0xE000ED90))) /* MPU Type Reg.                       */
  310. #define  CPU_REG_MPU_CTRL               (*((volatile CPU_INT32U *)(0xE000ED94))) /* MPU Ctrl Reg.                       */
  311. #define  CPU_REG_MPU_REG_NBR            (*((volatile CPU_INT32U *)(0xE000ED98))) /* MPU Region Nbr Reg.                 */
  312. #define  CPU_REG_MPU_REG_BASE           (*((volatile CPU_INT32U *)(0xE000ED9C))) /* MPU Region Base Addr Reg.           */
  313. #define  CPU_REG_MPU_REG_ATTR           (*((volatile CPU_INT32U *)(0xE000EDA0))) /* MPU Region Attrib & Size Reg.       */
  314. #define  CPU_REG_DBG_CTRL               (*((volatile CPU_INT32U *)(0xE000EDF0))) /* Debug Halting Ctrl & Status Reg.    */
  315. #define  CPU_REG_DBG_SELECT             (*((volatile CPU_INT32U *)(0xE000EDF4))) /* Debug Core Reg Selector Reg.        */
  316. #define  CPU_REG_DBG_DATA               (*((volatile CPU_INT32U *)(0xE000EDF8))) /* Debug Core Reg Data     Reg.        */
  317. #define  CPU_REG_DBG_INT                (*((volatile CPU_INT32U *)(0xE000EDFC))) /* Debug Except & Monitor Ctrl Reg.    */
  318. /*
  319. *********************************************************************************************************
  320. *                                          CPU REGISTER BITS
  321. *********************************************************************************************************
  322. */
  323.                                                                 /* ---------- SYSTICK CTRL & STATUS REG BITS ---------- */
  324. #define  CPU_REG_NVIC_ST_CTRL_COUNTFLAG         DEF_BIT_16
  325. #define  CPU_REG_NVIC_ST_CTRL_CLKSOURCE         DEF_BIT_02
  326. #define  CPU_REG_NVIC_ST_CTRL_TICKINT           DEF_BIT_01
  327. #define  CPU_REG_NVIC_ST_CTRL_ENABLE            DEF_BIT_00
  328.                                                                 /* -------- SYSTICK CALIBRATION VALUE REG BITS -------- */
  329. #define  CPU_REG_NVIC_ST_CAL_NOREF              DEF_BIT_31
  330. #define  CPU_REG_NVIC_ST_CAL_SKEW               DEF_BIT_30
  331.                                                                 /* -------------- INT CTRL STATE REG BITS ------------- */
  332. #define  CPU_REG_NVIC_ICSR_NMIPENDSET           DEF_BIT_31
  333. #define  CPU_REG_NVIC_ICSR_PENDSVSET            DEF_BIT_28
  334. #define  CPU_REG_NVIC_ICSR_PENDSVCLR            DEF_BIT_27
  335. #define  CPU_REG_NVIC_ICSR_PENDSTSET            DEF_BIT_26
  336. #define  CPU_REG_NVIC_ICSR_PENDSTCLR            DEF_BIT_25
  337. #define  CPU_REG_NVIC_ICSR_ISRPREEMPT           DEF_BIT_23
  338. #define  CPU_REG_NVIC_ICSR_ISRPENDING           DEF_BIT_22
  339. #define  CPU_REG_NVIC_ICSR_RETTOBASE            DEF_BIT_11
  340.                                                                 /* ------------- VECT TBL OFFSET REG BITS ------------- */
  341. #define  CPU_REG_NVIC_VTOR_TBLBASE              DEF_BIT_29
  342.                                                                 /* ------------ APP INT/RESET CTRL REG BITS ----------- */
  343. #define  CPU_REG_NVIC_AIRCR_ENDIANNESS          DEF_BIT_15
  344. #define  CPU_REG_NVIC_AIRCR_SYSRESETREQ         DEF_BIT_02
  345. #define  CPU_REG_NVIC_AIRCR_VECTCLRACTIVE       DEF_BIT_01
  346. #define  CPU_REG_NVIC_AIRCR_VECTRESET           DEF_BIT_00
  347.                                                                 /* --------------- SYSTEM CTRL REG BITS --------------- */
  348. #define  CPU_REG_NVIC_SCR_SEVONPEND             DEF_BIT_04
  349. #define  CPU_REG_NVIC_SCR_SLEEPDEEP             DEF_BIT_02
  350. #define  CPU_REG_NVIC_SCR_SLEEPONEXIT           DEF_BIT_01
  351.                                                                 /* ----------------- CFG CTRL REG BITS ---------------- */
  352. #define  CPU_REG_NVIC_CCR_STKALIGN              DEF_BIT_09
  353. #define  CPU_REG_NVIC_CCR_BFHFNMIGN             DEF_BIT_08
  354. #define  CPU_REG_NVIC_CCR_DIV_0_TRP             DEF_BIT_04
  355. #define  CPU_REG_NVIC_CCR_UNALIGN_TRP           DEF_BIT_03
  356. #define  CPU_REG_NVIC_CCR_USERSETMPEND          DEF_BIT_01
  357. #define  CPU_REG_NVIC_CCR_NONBASETHRDENA        DEF_BIT_00
  358.                                                                 /* ------- SYSTEM HANDLER CTRL & STATE REG BITS ------- */
  359. #define  CPU_REG_NVIC_SHCSR_USGFAULTENA         DEF_BIT_18
  360. #define  CPU_REG_NVIC_SHCSR_BUSFAULTENA         DEF_BIT_17
  361. #define  CPU_REG_NVIC_SHCSR_MEMFAULTENA         DEF_BIT_16
  362. #define  CPU_REG_NVIC_SHCSR_SVCALLPENDED        DEF_BIT_15
  363. #define  CPU_REG_NVIC_SHCSR_BUSFAULTPENDED      DEF_BIT_14
  364. #define  CPU_REG_NVIC_SHCSR_MEMFAULTPENDED      DEF_BIT_13
  365. #define  CPU_REG_NVIC_SHCSR_USGFAULTPENDED      DEF_BIT_12
  366. #define  CPU_REG_NVIC_SHCSR_SYSTICKACT          DEF_BIT_11
  367. #define  CPU_REG_NVIC_SHCSR_PENDSVACT           DEF_BIT_10
  368. #define  CPU_REG_NVIC_SHCSR_MONITORACT          DEF_BIT_08
  369. #define  CPU_REG_NVIC_SHCSR_SVCALLACT           DEF_BIT_07
  370. #define  CPU_REG_NVIC_SHCSR_USGFAULTACT         DEF_BIT_03
  371. #define  CPU_REG_NVIC_SHCSR_BUSFAULTACT         DEF_BIT_01
  372. #define  CPU_REG_NVIC_SHCSR_MEMFAULTACT         DEF_BIT_00
  373.                                                                 /* -------- CONFIGURABLE FAULT STATUS REG BITS -------- */
  374. #define  CPU_REG_NVIC_CFSR_DIVBYZERO            DEF_BIT_25
  375. #define  CPU_REG_NVIC_CFSR_UNALIGNED            DEF_BIT_24
  376. #define  CPU_REG_NVIC_CFSR_NOCP                 DEF_BIT_19
  377. #define  CPU_REG_NVIC_CFSR_INVPC                DEF_BIT_18
  378. #define  CPU_REG_NVIC_CFSR_INVSTATE             DEF_BIT_17
  379. #define  CPU_REG_NVIC_CFSR_UNDEFINSTR           DEF_BIT_16
  380. #define  CPU_REG_NVIC_CFSR_BFARVALID            DEF_BIT_15
  381. #define  CPU_REG_NVIC_CFSR_STKERR               DEF_BIT_12
  382. #define  CPU_REG_NVIC_CFSR_UNSTKERR             DEF_BIT_11
  383. #define  CPU_REG_NVIC_CFSR_IMPRECISERR          DEF_BIT_10
  384. #define  CPU_REG_NVIC_CFSR_PRECISERR            DEF_BIT_09
  385. #define  CPU_REG_NVIC_CFSR_IBUSERR              DEF_BIT_08
  386. #define  CPU_REG_NVIC_CFSR_MMARVALID            DEF_BIT_07
  387. #define  CPU_REG_NVIC_CFSR_MSTKERR              DEF_BIT_04
  388. #define  CPU_REG_NVIC_CFSR_MUNSTKERR            DEF_BIT_03
  389. #define  CPU_REG_NVIC_CFSR_DACCVIOL             DEF_BIT_01
  390. #define  CPU_REG_NVIC_CFSR_IACCVIOL             DEF_BIT_00
  391.                                                                 /* ------------ HARD FAULT STATUS REG BITS ------------ */
  392. #define  CPU_REG_NVIC_HFSR_DEBUGEVT             DEF_BIT_31
  393. #define  CPU_REG_NVIC_HFSR_FORCED               DEF_BIT_30
  394. #define  CPU_REG_NVIC_HFSR_VECTTBL              DEF_BIT_01
  395.                                                                 /* ------------ DEBUG FAULT STATUS REG BITS ----------- */
  396. #define  CPU_REG_NVIC_DFSR_EXTERNAL             DEF_BIT_04
  397. #define  CPU_REG_NVIC_DFSR_VCATCH               DEF_BIT_03
  398. #define  CPU_REG_NVIC_DFSR_DWTTRAP              DEF_BIT_02
  399. #define  CPU_REG_NVIC_DFSR_BKPT                 DEF_BIT_01
  400. #define  CPU_REG_NVIC_DFSR_HALTED               DEF_BIT_00
  401. /*$PAGE*/
  402. /*
  403. *********************************************************************************************************
  404. *                                        CONFIGURATION ERRORS
  405. *********************************************************************************************************
  406. */
  407. #ifndef   CPU_CFG_ADDR_SIZE
  408. #error   "CPU_CFG_ADDR_SIZE              not #define'd in 'cpu.h'               "
  409. #error   "                         [MUST be  CPU_WORD_SIZE_08   8-bit alignment]"
  410. #error   "                         [     ||  CPU_WORD_SIZE_16  16-bit alignment]"
  411. #error   "                         [     ||  CPU_WORD_SIZE_32  32-bit alignment]"
  412. #elif   ((CPU_CFG_ADDR_SIZE != CPU_WORD_SIZE_08) && 
  413.          (CPU_CFG_ADDR_SIZE != CPU_WORD_SIZE_16) && 
  414.          (CPU_CFG_ADDR_SIZE != CPU_WORD_SIZE_32))
  415. #error   "CPU_CFG_ADDR_SIZE        illegally #define'd in 'cpu.h'               "
  416. #error   "                         [MUST be  CPU_WORD_SIZE_08   8-bit alignment]"
  417. #error   "                         [     ||  CPU_WORD_SIZE_16  16-bit alignment]"
  418. #error   "                         [     ||  CPU_WORD_SIZE_32  32-bit alignment]"
  419. #endif
  420. #ifndef   CPU_CFG_DATA_SIZE
  421. #error   "CPU_CFG_DATA_SIZE              not #define'd in 'cpu.h'               "
  422. #error   "                         [MUST be  CPU_WORD_SIZE_08   8-bit alignment]"
  423. #error   "                         [     ||  CPU_WORD_SIZE_16  16-bit alignment]"
  424. #error   "                         [     ||  CPU_WORD_SIZE_32  32-bit alignment]"
  425. #elif   ((CPU_CFG_DATA_SIZE != CPU_WORD_SIZE_08) && 
  426.          (CPU_CFG_DATA_SIZE != CPU_WORD_SIZE_16) && 
  427.          (CPU_CFG_DATA_SIZE != CPU_WORD_SIZE_32))
  428. #error   "CPU_CFG_DATA_SIZE        illegally #define'd in 'cpu.h'               "
  429. #error   "                         [MUST be  CPU_WORD_SIZE_08   8-bit alignment]"
  430. #error   "                         [     ||  CPU_WORD_SIZE_16  16-bit alignment]"
  431. #error   "                         [     ||  CPU_WORD_SIZE_32  32-bit alignment]"
  432. #endif
  433. #ifndef   CPU_CFG_ENDIAN_TYPE
  434. #error   "CPU_CFG_ENDIAN_TYPE            not #define'd in 'cpu.h'   "
  435. #error   "                         [MUST be  CPU_ENDIAN_TYPE_BIG   ]"
  436. #error   "                         [     ||  CPU_ENDIAN_TYPE_LITTLE]"
  437. #elif   ((CPU_CFG_ENDIAN_TYPE != CPU_ENDIAN_TYPE_BIG   ) && 
  438.          (CPU_CFG_ENDIAN_TYPE != CPU_ENDIAN_TYPE_LITTLE))
  439. #error   "CPU_CFG_ENDIAN_TYPE      illegally #define'd in 'cpu.h'   "
  440. #error   "                         [MUST be  CPU_ENDIAN_TYPE_BIG   ]"
  441. #error   "                         [     ||  CPU_ENDIAN_TYPE_LITTLE]"
  442. #endif
  443. #ifndef   CPU_CFG_CRITICAL_METHOD
  444. #error   "CPU_CFG_CRITICAL_METHOD        not #define'd in 'cpu.h'             "
  445. #error   "                         [MUST be  CPU_CRITICAL_METHOD_INT_DIS_EN  ]"
  446. #error   "                         [     ||  CPU_CRITICAL_METHOD_STATUS_STK  ]"
  447. #error   "                         [     ||  CPU_CRITICAL_METHOD_STATUS_LOCAL]"
  448. #elif   ((CPU_CFG_CRITICAL_METHOD != CPU_CRITICAL_METHOD_INT_DIS_EN  ) && 
  449.          (CPU_CFG_CRITICAL_METHOD != CPU_CRITICAL_METHOD_STATUS_STK  ) && 
  450.          (CPU_CFG_CRITICAL_METHOD != CPU_CRITICAL_METHOD_STATUS_LOCAL))
  451. #error   "CPU_CFG_CRITICAL_METHOD  illegally #define'd in 'cpu.h'             "
  452. #error   "                         [MUST be  CPU_CRITICAL_METHOD_INT_DIS_EN  ]"
  453. #error   "                         [     ||  CPU_CRITICAL_METHOD_STATUS_STK  ]"
  454. #error   "                         [     ||  CPU_CRITICAL_METHOD_STATUS_LOCAL]"
  455. #endif
  456. /*$PAGE*/
  457. /*
  458. *********************************************************************************************************
  459. *                                             MODULE END
  460. *********************************************************************************************************
  461. */
  462. #endif                                                          /* End of CPU cfg module inclusion.                     */