?login_element?

Subversion Repositories NedoOS

Rev

Rev 8 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. /**************************************************************************//**
  2.  * @file     core_cm1.h
  3.  * @brief    CMSIS Cortex-M3 Core Peripheral Access Layer Header File
  4.  * @version  V1.30
  5.  * @date     30. October 2009
  6.  *
  7.  * @note
  8.  * Copyright (C) 2009 ARM Limited. All rights reserved.
  9.  *
  10.  * @par
  11.  * ARM Limited (ARM) is supplying this software for use with Cortex-M
  12.  * processor based microcontrollers.  This file can be freely distributed
  13.  * within development tools that are supporting such ARM based processors.
  14.  *
  15.  * @par
  16.  * THIS SOFTWARE IS PROVIDED "AS IS".  NO WARRANTIES, WHETHER EXPRESS, IMPLIED
  17.  * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
  18.  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
  19.  * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
  20.  * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
  21.  *
  22.  ******************************************************************************/
  23.  
  24. #ifndef __CM1_CORE_H__
  25. #define __CM1_CORE_H__
  26.  
  27. /** @addtogroup CMSIS_CM1_core_LintCinfiguration CMSIS CM1 Core Lint Configuration
  28.  *
  29.  * List of Lint messages which will be suppressed and not shown:
  30.  *   - Error 10: \n
  31.  *     register uint32_t __regBasePri         __asm("basepri"); \n
  32.  *     Error 10: Expecting ';'
  33.  * .
  34.  *   - Error 530: \n
  35.  *     return(__regBasePri); \n
  36.  *     Warning 530: Symbol '__regBasePri' (line 264) not initialized
  37.  * .
  38.  *   - Error 550: \n
  39.  *     __regBasePri = (basePri & 0x1ff); \n
  40.  *     Warning 550: Symbol '__regBasePri' (line 271) not accessed
  41.  * .
  42.  *   - Error 754: \n
  43.  *     uint32_t RESERVED0[24]; \n
  44.  *     Info 754: local structure member '<some, not used in the HAL>' (line 109, file ./cm1_core.h) not referenced
  45.  * .
  46.  *   - Error 750: \n
  47.  *     #define __CM1_CORE_H__ \n
  48.  *     Info 750: local macro '__CM1_CORE_H__' (line 43, file./cm1_core.h) not referenced
  49.  * .
  50.  *   - Error 528: \n
  51.  *     static __INLINE void NVIC_DisableIRQ(uint32_t IRQn) \n
  52.  *     Warning 528: Symbol 'NVIC_DisableIRQ(unsigned int)' (line 419, file ./cm1_core.h) not referenced
  53.  * .
  54.  *   - Error 751: \n
  55.  *     } InterruptType_Type; \n
  56.  *     Info 751: local typedef 'InterruptType_Type' (line 170, file ./cm1_core.h) not referenced
  57.  * .
  58.  * Note:  To re-enable a Message, insert a space before 'lint' *
  59.  *
  60.  */
  61.  
  62. /*lint -save */
  63. /*lint -e10  */
  64. /*lint -e530 */
  65. /*lint -e550 */
  66. /*lint -e754 */
  67. /*lint -e750 */
  68. /*lint -e528 */
  69. /*lint -e751 */
  70.  
  71.  
  72. /** @addtogroup CMSIS_CM1_core_definitions CM1 Core Definitions
  73.   This file defines all structures and symbols for CMSIS core:
  74.     - CMSIS version number
  75.     - Cortex-M core registers and bitfields
  76.     - Cortex-M core peripheral base address
  77.   @{
  78.  */
  79.  
  80. #ifdef __cplusplus
  81.  extern "C" {
  82. #endif
  83.  
  84. #define __CM1_CMSIS_VERSION_MAIN  (0x01)                                                       /*!< [31:16] CMSIS HAL main version */
  85. #define __CM1_CMSIS_VERSION_SUB   (0x30)                                                       /*!< [15:0]  CMSIS HAL sub version  */
  86. #define __CM1_CMSIS_VERSION       ((__CM1_CMSIS_VERSION_MAIN << 16) | __CM1_CMSIS_VERSION_SUB) /*!< CMSIS HAL version number       */
  87.  
  88. #define __CORTEX_M                (0x03)                                                       /*!< Cortex core                    */
  89.  
  90. #include <stdint.h>                           /* Include standard types */
  91.  
  92. #if defined (__ICCARM__)
  93.   #include <intrinsics.h>                     /* IAR Intrinsics   */
  94. #endif
  95.  
  96.  
  97. #ifndef __NVIC_PRIO_BITS
  98.   #define __NVIC_PRIO_BITS    4               /*!< standard definition for NVIC Priority Bits */
  99. #endif
  100.  
  101.  
  102.  
  103.  
  104. /**
  105.  * IO definitions
  106.  *
  107.  * define access restrictions to peripheral registers
  108.  */
  109.  
  110. #ifdef __cplusplus
  111.   #define     __I     volatile                /*!< defines 'read only' permissions      */
  112. #else
  113.   #define     __I     volatile const          /*!< defines 'read only' permissions      */
  114. #endif
  115. #define     __O     volatile                  /*!< defines 'write only' permissions     */
  116. #define     __IO    volatile                  /*!< defines 'read / write' permissions   */
  117.  
  118.  
  119.  
  120. /*******************************************************************************
  121.  *                 Register Abstraction
  122.  ******************************************************************************/
  123. /** @addtogroup CMSIS_CM1_core_register CMSIS CM1 Core Register
  124.  @{
  125. */
  126.  
  127.  
  128. /** @addtogroup CMSIS_CM1_NVIC CMSIS CM1 NVIC
  129.   memory mapped structure for Nested Vectored Interrupt Controller (NVIC)
  130.   @{
  131.  */
  132. typedef struct
  133. {
  134.   __IO uint32_t ISER[8];                      /*!< Offset: 0x000  Interrupt Set Enable Register           */
  135.        uint32_t RESERVED0[24];
  136.   __IO uint32_t ICER[8];                      /*!< Offset: 0x080  Interrupt Clear Enable Register         */
  137.        uint32_t RSERVED1[24];
  138.   __IO uint32_t ISPR[8];                      /*!< Offset: 0x100  Interrupt Set Pending Register          */
  139.        uint32_t RESERVED2[24];
  140.   __IO uint32_t ICPR[8];                      /*!< Offset: 0x180  Interrupt Clear Pending Register        */
  141.        uint32_t RESERVED3[24];
  142.   __IO uint32_t IABR[8];                      /*!< Offset: 0x200  Interrupt Active bit Register           */
  143.        uint32_t RESERVED4[56];
  144.   __IO uint8_t  IP[240];                      /*!< Offset: 0x300  Interrupt Priority Register (8Bit wide) */
  145.        uint32_t RESERVED5[644];
  146.   __O  uint32_t STIR;                         /*!< Offset: 0xE00  Software Trigger Interrupt Register     */
  147. }  NVIC_Type;
  148. /*@}*/ /* end of group CMSIS_CM1_NVIC */
  149.  
  150.  
  151. /** @addtogroup CMSIS_CM1_SCB CMSIS CM1 SCB
  152.   memory mapped structure for System Control Block (SCB)
  153.   @{
  154.  */
  155. typedef struct
  156. {
  157.   __I  uint32_t CPUID;                        /*!< Offset: 0x00  CPU ID Base Register                                  */
  158.   __IO uint32_t ICSR;                         /*!< Offset: 0x04  Interrupt Control State Register                      */
  159.   __IO uint32_t VTOR;                         /*!< Offset: 0x08  Vector Table Offset Register                          */
  160.   __IO uint32_t AIRCR;                        /*!< Offset: 0x0C  Application Interrupt / Reset Control Register        */
  161.   __IO uint32_t SCR;                          /*!< Offset: 0x10  System Control Register                               */
  162.   __IO uint32_t CCR;                          /*!< Offset: 0x14  Configuration Control Register                        */
  163.   __IO uint8_t  SHP[12];                      /*!< Offset: 0x18  System Handlers Priority Registers (4-7, 8-11, 12-15) */
  164.   __IO uint32_t SHCSR;                        /*!< Offset: 0x24  System Handler Control and State Register             */
  165.   __IO uint32_t CFSR;                         /*!< Offset: 0x28  Configurable Fault Status Register                    */
  166.   __IO uint32_t HFSR;                         /*!< Offset: 0x2C  Hard Fault Status Register                            */
  167.   __IO uint32_t DFSR;                         /*!< Offset: 0x30  Debug Fault Status Register                           */
  168.   __IO uint32_t MMFAR;                        /*!< Offset: 0x34  Mem Manage Address Register                           */
  169.   __IO uint32_t BFAR;                         /*!< Offset: 0x38  Bus Fault Address Register                            */
  170.   __IO uint32_t AFSR;                         /*!< Offset: 0x3C  Auxiliary Fault Status Register                       */
  171.   __I  uint32_t PFR[2];                       /*!< Offset: 0x40  Processor Feature Register                            */
  172.   __I  uint32_t DFR;                          /*!< Offset: 0x48  Debug Feature Register                                */
  173.   __I  uint32_t ADR;                          /*!< Offset: 0x4C  Auxiliary Feature Register                            */
  174.   __I  uint32_t MMFR[4];                      /*!< Offset: 0x50  Memory Model Feature Register                         */
  175.   __I  uint32_t ISAR[5];                      /*!< Offset: 0x60  ISA Feature Register                                  */
  176. } SCB_Type;
  177.  
  178. /* SCB CPUID Register Definitions */
  179. #define SCB_CPUID_IMPLEMENTER_Pos          24                                             /*!< SCB CPUID: IMPLEMENTER Position */
  180. #define SCB_CPUID_IMPLEMENTER_Msk          (0xFFul << SCB_CPUID_IMPLEMENTER_Pos)          /*!< SCB CPUID: IMPLEMENTER Mask */
  181.  
  182. #define SCB_CPUID_VARIANT_Pos              20                                             /*!< SCB CPUID: VARIANT Position */
  183. #define SCB_CPUID_VARIANT_Msk              (0xFul << SCB_CPUID_VARIANT_Pos)               /*!< SCB CPUID: VARIANT Mask */
  184.  
  185. #define SCB_CPUID_PARTNO_Pos                4                                             /*!< SCB CPUID: PARTNO Position */
  186. #define SCB_CPUID_PARTNO_Msk               (0xFFFul << SCB_CPUID_PARTNO_Pos)              /*!< SCB CPUID: PARTNO Mask */
  187.  
  188. #define SCB_CPUID_REVISION_Pos              0                                             /*!< SCB CPUID: REVISION Position */
  189. #define SCB_CPUID_REVISION_Msk             (0xFul << SCB_CPUID_REVISION_Pos)              /*!< SCB CPUID: REVISION Mask */
  190.  
  191. /* SCB Interrupt Control State Register Definitions */
  192. #define SCB_ICSR_NMIPENDSET_Pos            31                                             /*!< SCB ICSR: NMIPENDSET Position */
  193. #define SCB_ICSR_NMIPENDSET_Msk            (1ul << SCB_ICSR_NMIPENDSET_Pos)               /*!< SCB ICSR: NMIPENDSET Mask */
  194.  
  195. #define SCB_ICSR_PENDSVSET_Pos             28                                             /*!< SCB ICSR: PENDSVSET Position */
  196. #define SCB_ICSR_PENDSVSET_Msk             (1ul << SCB_ICSR_PENDSVSET_Pos)                /*!< SCB ICSR: PENDSVSET Mask */
  197.  
  198. #define SCB_ICSR_PENDSVCLR_Pos             27                                             /*!< SCB ICSR: PENDSVCLR Position */
  199. #define SCB_ICSR_PENDSVCLR_Msk             (1ul << SCB_ICSR_PENDSVCLR_Pos)                /*!< SCB ICSR: PENDSVCLR Mask */
  200.  
  201. #define SCB_ICSR_PENDSTSET_Pos             26                                             /*!< SCB ICSR: PENDSTSET Position */
  202. #define SCB_ICSR_PENDSTSET_Msk             (1ul << SCB_ICSR_PENDSTSET_Pos)                /*!< SCB ICSR: PENDSTSET Mask */
  203.  
  204. #define SCB_ICSR_PENDSTCLR_Pos             25                                             /*!< SCB ICSR: PENDSTCLR Position */
  205. #define SCB_ICSR_PENDSTCLR_Msk             (1ul << SCB_ICSR_PENDSTCLR_Pos)                /*!< SCB ICSR: PENDSTCLR Mask */
  206.  
  207. #define SCB_ICSR_ISRPREEMPT_Pos            23                                             /*!< SCB ICSR: ISRPREEMPT Position */
  208. #define SCB_ICSR_ISRPREEMPT_Msk            (1ul << SCB_ICSR_ISRPREEMPT_Pos)               /*!< SCB ICSR: ISRPREEMPT Mask */
  209.  
  210. #define SCB_ICSR_ISRPENDING_Pos            22                                             /*!< SCB ICSR: ISRPENDING Position */
  211. #define SCB_ICSR_ISRPENDING_Msk            (1ul << SCB_ICSR_ISRPENDING_Pos)               /*!< SCB ICSR: ISRPENDING Mask */
  212.  
  213. #define SCB_ICSR_VECTPENDING_Pos           12                                             /*!< SCB ICSR: VECTPENDING Position */
  214. #define SCB_ICSR_VECTPENDING_Msk           (0x1FFul << SCB_ICSR_VECTPENDING_Pos)          /*!< SCB ICSR: VECTPENDING Mask */
  215.  
  216. #define SCB_ICSR_RETTOBASE_Pos             11                                             /*!< SCB ICSR: RETTOBASE Position */
  217. #define SCB_ICSR_RETTOBASE_Msk             (1ul << SCB_ICSR_RETTOBASE_Pos)                /*!< SCB ICSR: RETTOBASE Mask */
  218.  
  219. #define SCB_ICSR_VECTACTIVE_Pos             0                                             /*!< SCB ICSR: VECTACTIVE Position */
  220. #define SCB_ICSR_VECTACTIVE_Msk            (0x1FFul << SCB_ICSR_VECTACTIVE_Pos)           /*!< SCB ICSR: VECTACTIVE Mask */
  221.  
  222. /* SCB Interrupt Control State Register Definitions */
  223. #define SCB_VTOR_TBLBASE_Pos               29                                             /*!< SCB VTOR: TBLBASE Position */
  224. #define SCB_VTOR_TBLBASE_Msk               (0x1FFul << SCB_VTOR_TBLBASE_Pos)              /*!< SCB VTOR: TBLBASE Mask */
  225.  
  226. #define SCB_VTOR_TBLOFF_Pos                 7                                             /*!< SCB VTOR: TBLOFF Position */
  227. #define SCB_VTOR_TBLOFF_Msk                (0x3FFFFFul << SCB_VTOR_TBLOFF_Pos)            /*!< SCB VTOR: TBLOFF Mask */
  228.  
  229. /* SCB Application Interrupt and Reset Control Register Definitions */
  230. #define SCB_AIRCR_VECTKEY_Pos              16                                             /*!< SCB AIRCR: VECTKEY Position */
  231. #define SCB_AIRCR_VECTKEY_Msk              (0xFFFFul << SCB_AIRCR_VECTKEY_Pos)            /*!< SCB AIRCR: VECTKEY Mask */
  232.  
  233. #define SCB_AIRCR_VECTKEYSTAT_Pos          16                                             /*!< SCB AIRCR: VECTKEYSTAT Position */
  234. #define SCB_AIRCR_VECTKEYSTAT_Msk          (0xFFFFul << SCB_AIRCR_VECTKEYSTAT_Pos)        /*!< SCB AIRCR: VECTKEYSTAT Mask */
  235.  
  236. #define SCB_AIRCR_ENDIANESS_Pos            15                                             /*!< SCB AIRCR: ENDIANESS Position */
  237. #define SCB_AIRCR_ENDIANESS_Msk            (1ul << SCB_AIRCR_ENDIANESS_Pos)               /*!< SCB AIRCR: ENDIANESS Mask */
  238.  
  239. #define SCB_AIRCR_PRIGROUP_Pos              8                                             /*!< SCB AIRCR: PRIGROUP Position */
  240. #define SCB_AIRCR_PRIGROUP_Msk             (7ul << SCB_AIRCR_PRIGROUP_Pos)                /*!< SCB AIRCR: PRIGROUP Mask */
  241.  
  242. #define SCB_AIRCR_SYSRESETREQ_Pos           2                                             /*!< SCB AIRCR: SYSRESETREQ Position */
  243. #define SCB_AIRCR_SYSRESETREQ_Msk          (1ul << SCB_AIRCR_SYSRESETREQ_Pos)             /*!< SCB AIRCR: SYSRESETREQ Mask */
  244.  
  245. #define SCB_AIRCR_VECTCLRACTIVE_Pos         1                                             /*!< SCB AIRCR: VECTCLRACTIVE Position */
  246. #define SCB_AIRCR_VECTCLRACTIVE_Msk        (1ul << SCB_AIRCR_VECTCLRACTIVE_Pos)           /*!< SCB AIRCR: VECTCLRACTIVE Mask */
  247.  
  248. #define SCB_AIRCR_VECTRESET_Pos             0                                             /*!< SCB AIRCR: VECTRESET Position */
  249. #define SCB_AIRCR_VECTRESET_Msk            (1ul << SCB_AIRCR_VECTRESET_Pos)               /*!< SCB AIRCR: VECTRESET Mask */
  250.  
  251. /* SCB System Control Register Definitions */
  252. #define SCB_SCR_SEVONPEND_Pos               4                                             /*!< SCB SCR: SEVONPEND Position */
  253. #define SCB_SCR_SEVONPEND_Msk              (1ul << SCB_SCR_SEVONPEND_Pos)                 /*!< SCB SCR: SEVONPEND Mask */
  254.  
  255. #define SCB_SCR_SLEEPDEEP_Pos               2                                             /*!< SCB SCR: SLEEPDEEP Position */
  256. #define SCB_SCR_SLEEPDEEP_Msk              (1ul << SCB_SCR_SLEEPDEEP_Pos)                 /*!< SCB SCR: SLEEPDEEP Mask */
  257.  
  258. #define SCB_SCR_SLEEPONEXIT_Pos             1                                             /*!< SCB SCR: SLEEPONEXIT Position */
  259. #define SCB_SCR_SLEEPONEXIT_Msk            (1ul << SCB_SCR_SLEEPONEXIT_Pos)               /*!< SCB SCR: SLEEPONEXIT Mask */
  260.  
  261. /* SCB Configuration Control Register Definitions */
  262. #define SCB_CCR_STKALIGN_Pos                9                                             /*!< SCB CCR: STKALIGN Position */
  263. #define SCB_CCR_STKALIGN_Msk               (1ul << SCB_CCR_STKALIGN_Pos)                  /*!< SCB CCR: STKALIGN Mask */
  264.  
  265. #define SCB_CCR_BFHFNMIGN_Pos               8                                             /*!< SCB CCR: BFHFNMIGN Position */
  266. #define SCB_CCR_BFHFNMIGN_Msk              (1ul << SCB_CCR_BFHFNMIGN_Pos)                 /*!< SCB CCR: BFHFNMIGN Mask */
  267.  
  268. #define SCB_CCR_DIV_0_TRP_Pos               4                                             /*!< SCB CCR: DIV_0_TRP Position */
  269. #define SCB_CCR_DIV_0_TRP_Msk              (1ul << SCB_CCR_DIV_0_TRP_Pos)                 /*!< SCB CCR: DIV_0_TRP Mask */
  270.  
  271. #define SCB_CCR_UNALIGN_TRP_Pos             3                                             /*!< SCB CCR: UNALIGN_TRP Position */
  272. #define SCB_CCR_UNALIGN_TRP_Msk            (1ul << SCB_CCR_UNALIGN_TRP_Pos)               /*!< SCB CCR: UNALIGN_TRP Mask */
  273.  
  274. #define SCB_CCR_USERSETMPEND_Pos            1                                             /*!< SCB CCR: USERSETMPEND Position */
  275. #define SCB_CCR_USERSETMPEND_Msk           (1ul << SCB_CCR_USERSETMPEND_Pos)              /*!< SCB CCR: USERSETMPEND Mask */
  276.  
  277. #define SCB_CCR_NONBASETHRDENA_Pos          0                                             /*!< SCB CCR: NONBASETHRDENA Position */
  278. #define SCB_CCR_NONBASETHRDENA_Msk         (1ul << SCB_CCR_NONBASETHRDENA_Pos)            /*!< SCB CCR: NONBASETHRDENA Mask */
  279.  
  280. /* SCB System Handler Control and State Register Definitions */
  281. #define SCB_SHCSR_USGFAULTENA_Pos          18                                             /*!< SCB SHCSR: USGFAULTENA Position */
  282. #define SCB_SHCSR_USGFAULTENA_Msk          (1ul << SCB_SHCSR_USGFAULTENA_Pos)             /*!< SCB SHCSR: USGFAULTENA Mask */
  283.  
  284. #define SCB_SHCSR_BUSFAULTENA_Pos          17                                             /*!< SCB SHCSR: BUSFAULTENA Position */
  285. #define SCB_SHCSR_BUSFAULTENA_Msk          (1ul << SCB_SHCSR_BUSFAULTENA_Pos)             /*!< SCB SHCSR: BUSFAULTENA Mask */
  286.  
  287. #define SCB_SHCSR_MEMFAULTENA_Pos          16                                             /*!< SCB SHCSR: MEMFAULTENA Position */
  288. #define SCB_SHCSR_MEMFAULTENA_Msk          (1ul << SCB_SHCSR_MEMFAULTENA_Pos)             /*!< SCB SHCSR: MEMFAULTENA Mask */
  289.  
  290. #define SCB_SHCSR_SVCALLPENDED_Pos         15                                             /*!< SCB SHCSR: SVCALLPENDED Position */
  291. #define SCB_SHCSR_SVCALLPENDED_Msk         (1ul << SCB_SHCSR_SVCALLPENDED_Pos)            /*!< SCB SHCSR: SVCALLPENDED Mask */
  292.  
  293. #define SCB_SHCSR_BUSFAULTPENDED_Pos       14                                             /*!< SCB SHCSR: BUSFAULTPENDED Position */
  294. #define SCB_SHCSR_BUSFAULTPENDED_Msk       (1ul << SCB_SHCSR_BUSFAULTPENDED_Pos)          /*!< SCB SHCSR: BUSFAULTPENDED Mask */
  295.  
  296. #define SCB_SHCSR_MEMFAULTPENDED_Pos       13                                             /*!< SCB SHCSR: MEMFAULTPENDED Position */
  297. #define SCB_SHCSR_MEMFAULTPENDED_Msk       (1ul << SCB_SHCSR_MEMFAULTPENDED_Pos)          /*!< SCB SHCSR: MEMFAULTPENDED Mask */
  298.  
  299. #define SCB_SHCSR_USGFAULTPENDED_Pos       12                                             /*!< SCB SHCSR: USGFAULTPENDED Position */
  300. #define SCB_SHCSR_USGFAULTPENDED_Msk       (1ul << SCB_SHCSR_USGFAULTPENDED_Pos)          /*!< SCB SHCSR: USGFAULTPENDED Mask */
  301.  
  302. #define SCB_SHCSR_SYSTICKACT_Pos           11                                             /*!< SCB SHCSR: SYSTICKACT Position */
  303. #define SCB_SHCSR_SYSTICKACT_Msk           (1ul << SCB_SHCSR_SYSTICKACT_Pos)              /*!< SCB SHCSR: SYSTICKACT Mask */
  304.  
  305. #define SCB_SHCSR_PENDSVACT_Pos            10                                             /*!< SCB SHCSR: PENDSVACT Position */
  306. #define SCB_SHCSR_PENDSVACT_Msk            (1ul << SCB_SHCSR_PENDSVACT_Pos)               /*!< SCB SHCSR: PENDSVACT Mask */
  307.  
  308. #define SCB_SHCSR_MONITORACT_Pos            8                                             /*!< SCB SHCSR: MONITORACT Position */
  309. #define SCB_SHCSR_MONITORACT_Msk           (1ul << SCB_SHCSR_MONITORACT_Pos)              /*!< SCB SHCSR: MONITORACT Mask */
  310.  
  311. #define SCB_SHCSR_SVCALLACT_Pos             7                                             /*!< SCB SHCSR: SVCALLACT Position */
  312. #define SCB_SHCSR_SVCALLACT_Msk            (1ul << SCB_SHCSR_SVCALLACT_Pos)               /*!< SCB SHCSR: SVCALLACT Mask */
  313.  
  314. #define SCB_SHCSR_USGFAULTACT_Pos           3                                             /*!< SCB SHCSR: USGFAULTACT Position */
  315. #define SCB_SHCSR_USGFAULTACT_Msk          (1ul << SCB_SHCSR_USGFAULTACT_Pos)             /*!< SCB SHCSR: USGFAULTACT Mask */
  316.  
  317. #define SCB_SHCSR_BUSFAULTACT_Pos           1                                             /*!< SCB SHCSR: BUSFAULTACT Position */
  318. #define SCB_SHCSR_BUSFAULTACT_Msk          (1ul << SCB_SHCSR_BUSFAULTACT_Pos)             /*!< SCB SHCSR: BUSFAULTACT Mask */
  319.  
  320. #define SCB_SHCSR_MEMFAULTACT_Pos           0                                             /*!< SCB SHCSR: MEMFAULTACT Position */
  321. #define SCB_SHCSR_MEMFAULTACT_Msk          (1ul << SCB_SHCSR_MEMFAULTACT_Pos)             /*!< SCB SHCSR: MEMFAULTACT Mask */
  322.  
  323. /* SCB Configurable Fault Status Registers Definitions */
  324. #define SCB_CFSR_USGFAULTSR_Pos            16                                             /*!< SCB CFSR: Usage Fault Status Register Position */
  325. #define SCB_CFSR_USGFAULTSR_Msk            (0xFFFFul << SCB_CFSR_USGFAULTSR_Pos)          /*!< SCB CFSR: Usage Fault Status Register Mask */
  326.  
  327. #define SCB_CFSR_BUSFAULTSR_Pos             8                                             /*!< SCB CFSR: Bus Fault Status Register Position */
  328. #define SCB_CFSR_BUSFAULTSR_Msk            (0xFFul << SCB_CFSR_BUSFAULTSR_Pos)            /*!< SCB CFSR: Bus Fault Status Register Mask */
  329.  
  330. #define SCB_CFSR_MEMFAULTSR_Pos             0                                             /*!< SCB CFSR: Memory Manage Fault Status Register Position */
  331. #define SCB_CFSR_MEMFAULTSR_Msk            (0xFFul << SCB_CFSR_MEMFAULTSR_Pos)            /*!< SCB CFSR: Memory Manage Fault Status Register Mask */
  332.  
  333. /* SCB Hard Fault Status Registers Definitions */
  334. #define SCB_HFSR_DEBUGEVT_Pos              31                                             /*!< SCB HFSR: DEBUGEVT Position */
  335. #define SCB_HFSR_DEBUGEVT_Msk              (1ul << SCB_HFSR_DEBUGEVT_Pos)                 /*!< SCB HFSR: DEBUGEVT Mask */
  336.  
  337. #define SCB_HFSR_FORCED_Pos                30                                             /*!< SCB HFSR: FORCED Position */
  338. #define SCB_HFSR_FORCED_Msk                (1ul << SCB_HFSR_FORCED_Pos)                   /*!< SCB HFSR: FORCED Mask */
  339.  
  340. #define SCB_HFSR_VECTTBL_Pos                1                                             /*!< SCB HFSR: VECTTBL Position */
  341. #define SCB_HFSR_VECTTBL_Msk               (1ul << SCB_HFSR_VECTTBL_Pos)                  /*!< SCB HFSR: VECTTBL Mask */
  342.  
  343. /* SCB Debug Fault Status Register Definitions */
  344. #define SCB_DFSR_EXTERNAL_Pos               4                                             /*!< SCB DFSR: EXTERNAL Position */
  345. #define SCB_DFSR_EXTERNAL_Msk              (1ul << SCB_DFSR_EXTERNAL_Pos)                 /*!< SCB DFSR: EXTERNAL Mask */
  346.  
  347. #define SCB_DFSR_VCATCH_Pos                 3                                             /*!< SCB DFSR: VCATCH Position */
  348. #define SCB_DFSR_VCATCH_Msk                (1ul << SCB_DFSR_VCATCH_Pos)                   /*!< SCB DFSR: VCATCH Mask */
  349.  
  350. #define SCB_DFSR_DWTTRAP_Pos                2                                             /*!< SCB DFSR: DWTTRAP Position */
  351. #define SCB_DFSR_DWTTRAP_Msk               (1ul << SCB_DFSR_DWTTRAP_Pos)                  /*!< SCB DFSR: DWTTRAP Mask */
  352.  
  353. #define SCB_DFSR_BKPT_Pos                   1                                             /*!< SCB DFSR: BKPT Position */
  354. #define SCB_DFSR_BKPT_Msk                  (1ul << SCB_DFSR_BKPT_Pos)                     /*!< SCB DFSR: BKPT Mask */
  355.  
  356. #define SCB_DFSR_HALTED_Pos                 0                                             /*!< SCB DFSR: HALTED Position */
  357. #define SCB_DFSR_HALTED_Msk                (1ul << SCB_DFSR_HALTED_Pos)                   /*!< SCB DFSR: HALTED Mask */
  358. /*@}*/ /* end of group CMSIS_CM1_SCB */
  359.  
  360.  
  361. /** @addtogroup CMSIS_CM1_SysTick CMSIS CM1 SysTick
  362.   memory mapped structure for SysTick
  363.   @{
  364.  */
  365. typedef struct
  366. {
  367.   __IO uint32_t CTRL;                         /*!< Offset: 0x00  SysTick Control and Status Register */
  368.   __IO uint32_t LOAD;                         /*!< Offset: 0x04  SysTick Reload Value Register       */
  369.   __IO uint32_t VAL;                          /*!< Offset: 0x08  SysTick Current Value Register      */
  370.   __I  uint32_t CALIB;                        /*!< Offset: 0x0C  SysTick Calibration Register        */
  371. } SysTick_Type;
  372.  
  373. /* SysTick Control / Status Register Definitions */
  374. #define SysTick_CTRL_COUNTFLAG_Pos         16                                             /*!< SysTick CTRL: COUNTFLAG Position */
  375. #define SysTick_CTRL_COUNTFLAG_Msk         (1ul << SysTick_CTRL_COUNTFLAG_Pos)            /*!< SysTick CTRL: COUNTFLAG Mask */
  376.  
  377. #define SysTick_CTRL_CLKSOURCE_Pos          2                                             /*!< SysTick CTRL: CLKSOURCE Position */
  378. #define SysTick_CTRL_CLKSOURCE_Msk         (1ul << SysTick_CTRL_CLKSOURCE_Pos)            /*!< SysTick CTRL: CLKSOURCE Mask */
  379.  
  380. #define SysTick_CTRL_TICKINT_Pos            1                                             /*!< SysTick CTRL: TICKINT Position */
  381. #define SysTick_CTRL_TICKINT_Msk           (1ul << SysTick_CTRL_TICKINT_Pos)              /*!< SysTick CTRL: TICKINT Mask */
  382.  
  383. #define SysTick_CTRL_ENABLE_Pos             0                                             /*!< SysTick CTRL: ENABLE Position */
  384. #define SysTick_CTRL_ENABLE_Msk            (1ul << SysTick_CTRL_ENABLE_Pos)               /*!< SysTick CTRL: ENABLE Mask */
  385.  
  386. /* SysTick Reload Register Definitions */
  387. #define SysTick_LOAD_RELOAD_Pos             0                                             /*!< SysTick LOAD: RELOAD Position */
  388. #define SysTick_LOAD_RELOAD_Msk            (0xFFFFFFul << SysTick_LOAD_RELOAD_Pos)        /*!< SysTick LOAD: RELOAD Mask */
  389.  
  390. /* SysTick Current Register Definitions */
  391. #define SysTick_VAL_CURRENT_Pos             0                                             /*!< SysTick VAL: CURRENT Position */
  392. #define SysTick_VAL_CURRENT_Msk            (0xFFFFFFul << SysTick_VAL_CURRENT_Pos)        /*!< SysTick VAL: CURRENT Mask */
  393.  
  394. /* SysTick Calibration Register Definitions */
  395. #define SysTick_CALIB_NOREF_Pos            31                                             /*!< SysTick CALIB: NOREF Position */
  396. #define SysTick_CALIB_NOREF_Msk            (1ul << SysTick_CALIB_NOREF_Pos)               /*!< SysTick CALIB: NOREF Mask */
  397.  
  398. #define SysTick_CALIB_SKEW_Pos             30                                             /*!< SysTick CALIB: SKEW Position */
  399. #define SysTick_CALIB_SKEW_Msk             (1ul << SysTick_CALIB_SKEW_Pos)                /*!< SysTick CALIB: SKEW Mask */
  400.  
  401. #define SysTick_CALIB_TENMS_Pos             0                                             /*!< SysTick CALIB: TENMS Position */
  402. #define SysTick_CALIB_TENMS_Msk            (0xFFFFFFul << SysTick_VAL_CURRENT_Pos)        /*!< SysTick CALIB: TENMS Mask */
  403. /*@}*/ /* end of group CMSIS_CM1_SysTick */
  404.  
  405.  
  406. /** @addtogroup CMSIS_CM1_ITM CMSIS CM1 ITM
  407.   memory mapped structure for Instrumentation Trace Macrocell (ITM)
  408.   @{
  409.  */
  410. typedef struct
  411. {
  412.   __O  union
  413.   {
  414.     __O  uint8_t    u8;                       /*!< Offset:       ITM Stimulus Port 8-bit                   */
  415.     __O  uint16_t   u16;                      /*!< Offset:       ITM Stimulus Port 16-bit                  */
  416.     __O  uint32_t   u32;                      /*!< Offset:       ITM Stimulus Port 32-bit                  */
  417.   }  PORT [32];                               /*!< Offset: 0x00  ITM Stimulus Port Registers               */
  418.        uint32_t RESERVED0[864];
  419.   __IO uint32_t TER;                          /*!< Offset:       ITM Trace Enable Register                 */
  420.        uint32_t RESERVED1[15];
  421.   __IO uint32_t TPR;                          /*!< Offset:       ITM Trace Privilege Register              */
  422.        uint32_t RESERVED2[15];
  423.   __IO uint32_t TCR;                          /*!< Offset:       ITM Trace Control Register                */
  424.        uint32_t RESERVED3[29];
  425.   __IO uint32_t IWR;                          /*!< Offset:       ITM Integration Write Register            */
  426.   __IO uint32_t IRR;                          /*!< Offset:       ITM Integration Read Register             */
  427.   __IO uint32_t IMCR;                         /*!< Offset:       ITM Integration Mode Control Register     */
  428.        uint32_t RESERVED4[43];
  429.   __IO uint32_t LAR;                          /*!< Offset:       ITM Lock Access Register                  */
  430.   __IO uint32_t LSR;                          /*!< Offset:       ITM Lock Status Register                  */
  431.        uint32_t RESERVED5[6];
  432.   __I  uint32_t PID4;                         /*!< Offset:       ITM Peripheral Identification Register #4 */
  433.   __I  uint32_t PID5;                         /*!< Offset:       ITM Peripheral Identification Register #5 */
  434.   __I  uint32_t PID6;                         /*!< Offset:       ITM Peripheral Identification Register #6 */
  435.   __I  uint32_t PID7;                         /*!< Offset:       ITM Peripheral Identification Register #7 */
  436.   __I  uint32_t PID0;                         /*!< Offset:       ITM Peripheral Identification Register #0 */
  437.   __I  uint32_t PID1;                         /*!< Offset:       ITM Peripheral Identification Register #1 */
  438.   __I  uint32_t PID2;                         /*!< Offset:       ITM Peripheral Identification Register #2 */
  439.   __I  uint32_t PID3;                         /*!< Offset:       ITM Peripheral Identification Register #3 */
  440.   __I  uint32_t CID0;                         /*!< Offset:       ITM Component  Identification Register #0 */
  441.   __I  uint32_t CID1;                         /*!< Offset:       ITM Component  Identification Register #1 */
  442.   __I  uint32_t CID2;                         /*!< Offset:       ITM Component  Identification Register #2 */
  443.   __I  uint32_t CID3;                         /*!< Offset:       ITM Component  Identification Register #3 */
  444. } ITM_Type;
  445.  
  446. /* ITM Trace Privilege Register Definitions */
  447. #define ITM_TPR_PRIVMASK_Pos                0                                             /*!< ITM TPR: PRIVMASK Position */
  448. #define ITM_TPR_PRIVMASK_Msk               (0xFul << ITM_TPR_PRIVMASK_Pos)                /*!< ITM TPR: PRIVMASK Mask */
  449.  
  450. /* ITM Trace Control Register Definitions */
  451. #define ITM_TCR_BUSY_Pos                   23                                             /*!< ITM TCR: BUSY Position */
  452. #define ITM_TCR_BUSY_Msk                   (1ul << ITM_TCR_BUSY_Pos)                      /*!< ITM TCR: BUSY Mask */
  453.  
  454. #define ITM_TCR_ATBID_Pos                  16                                             /*!< ITM TCR: ATBID Position */
  455. #define ITM_TCR_ATBID_Msk                  (0x7Ful << ITM_TCR_ATBID_Pos)                  /*!< ITM TCR: ATBID Mask */
  456.  
  457. #define ITM_TCR_TSPrescale_Pos              8                                             /*!< ITM TCR: TSPrescale Position */
  458. #define ITM_TCR_TSPrescale_Msk             (3ul << ITM_TCR_TSPrescale_Pos)                /*!< ITM TCR: TSPrescale Mask */
  459.  
  460. #define ITM_TCR_SWOENA_Pos                  4                                             /*!< ITM TCR: SWOENA Position */
  461. #define ITM_TCR_SWOENA_Msk                 (1ul << ITM_TCR_SWOENA_Pos)                    /*!< ITM TCR: SWOENA Mask */
  462.  
  463. #define ITM_TCR_DWTENA_Pos                  3                                             /*!< ITM TCR: DWTENA Position */
  464. #define ITM_TCR_DWTENA_Msk                 (1ul << ITM_TCR_DWTENA_Pos)                    /*!< ITM TCR: DWTENA Mask */
  465.  
  466. #define ITM_TCR_SYNCENA_Pos                 2                                             /*!< ITM TCR: SYNCENA Position */
  467. #define ITM_TCR_SYNCENA_Msk                (1ul << ITM_TCR_SYNCENA_Pos)                   /*!< ITM TCR: SYNCENA Mask */
  468.  
  469. #define ITM_TCR_TSENA_Pos                   1                                             /*!< ITM TCR: TSENA Position */
  470. #define ITM_TCR_TSENA_Msk                  (1ul << ITM_TCR_TSENA_Pos)                     /*!< ITM TCR: TSENA Mask */
  471.  
  472. #define ITM_TCR_ITMENA_Pos                  0                                             /*!< ITM TCR: ITM Enable bit Position */
  473. #define ITM_TCR_ITMENA_Msk                 (1ul << ITM_TCR_ITMENA_Pos)                    /*!< ITM TCR: ITM Enable bit Mask */
  474.  
  475. /* ITM Integration Write Register Definitions */
  476. #define ITM_IWR_ATVALIDM_Pos                0                                             /*!< ITM IWR: ATVALIDM Position */
  477. #define ITM_IWR_ATVALIDM_Msk               (1ul << ITM_IWR_ATVALIDM_Pos)                  /*!< ITM IWR: ATVALIDM Mask */
  478.  
  479. /* ITM Integration Read Register Definitions */
  480. #define ITM_IRR_ATREADYM_Pos                0                                             /*!< ITM IRR: ATREADYM Position */
  481. #define ITM_IRR_ATREADYM_Msk               (1ul << ITM_IRR_ATREADYM_Pos)                  /*!< ITM IRR: ATREADYM Mask */
  482.  
  483. /* ITM Integration Mode Control Register Definitions */
  484. #define ITM_IMCR_INTEGRATION_Pos            0                                             /*!< ITM IMCR: INTEGRATION Position */
  485. #define ITM_IMCR_INTEGRATION_Msk           (1ul << ITM_IMCR_INTEGRATION_Pos)              /*!< ITM IMCR: INTEGRATION Mask */
  486.  
  487. /* ITM Lock Status Register Definitions */
  488. #define ITM_LSR_ByteAcc_Pos                 2                                             /*!< ITM LSR: ByteAcc Position */
  489. #define ITM_LSR_ByteAcc_Msk                (1ul << ITM_LSR_ByteAcc_Pos)                   /*!< ITM LSR: ByteAcc Mask */
  490.  
  491. #define ITM_LSR_Access_Pos                  1                                             /*!< ITM LSR: Access Position */
  492. #define ITM_LSR_Access_Msk                 (1ul << ITM_LSR_Access_Pos)                    /*!< ITM LSR: Access Mask */
  493.  
  494. #define ITM_LSR_Present_Pos                 0                                             /*!< ITM LSR: Present Position */
  495. #define ITM_LSR_Present_Msk                (1ul << ITM_LSR_Present_Pos)                   /*!< ITM LSR: Present Mask */
  496. /*@}*/ /* end of group CMSIS_CM1_ITM */
  497.  
  498.  
  499. /** @addtogroup CMSIS_CM1_InterruptType CMSIS CM1 Interrupt Type
  500.   memory mapped structure for Interrupt Type
  501.   @{
  502.  */
  503. typedef struct
  504. {
  505.        uint32_t RESERVED0;
  506.   __I  uint32_t ICTR;                         /*!< Offset: 0x04  Interrupt Control Type Register */
  507. #if ((defined __CM1_REV) && (__CM1_REV >= 0x200))
  508.   __IO uint32_t ACTLR;                        /*!< Offset: 0x08  Auxiliary Control Register      */
  509. #else
  510.        uint32_t RESERVED1;
  511. #endif
  512. } InterruptType_Type;
  513.  
  514. /* Interrupt Controller Type Register Definitions */
  515. #define InterruptType_ICTR_INTLINESNUM_Pos  0                                             /*!< InterruptType ICTR: INTLINESNUM Position */
  516. #define InterruptType_ICTR_INTLINESNUM_Msk (0x1Ful << InterruptType_ICTR_INTLINESNUM_Pos) /*!< InterruptType ICTR: INTLINESNUM Mask */
  517.  
  518. /* Auxiliary Control Register Definitions */
  519. #define InterruptType_ACTLR_DISFOLD_Pos     2                                             /*!< InterruptType ACTLR: DISFOLD Position */
  520. #define InterruptType_ACTLR_DISFOLD_Msk    (1ul << InterruptType_ACTLR_DISFOLD_Pos)       /*!< InterruptType ACTLR: DISFOLD Mask */
  521.  
  522. #define InterruptType_ACTLR_DISDEFWBUF_Pos  1                                             /*!< InterruptType ACTLR: DISDEFWBUF Position */
  523. #define InterruptType_ACTLR_DISDEFWBUF_Msk (1ul << InterruptType_ACTLR_DISDEFWBUF_Pos)    /*!< InterruptType ACTLR: DISDEFWBUF Mask */
  524.  
  525. #define InterruptType_ACTLR_DISMCYCINT_Pos  0                                             /*!< InterruptType ACTLR: DISMCYCINT Position */
  526. #define InterruptType_ACTLR_DISMCYCINT_Msk (1ul << InterruptType_ACTLR_DISMCYCINT_Pos)    /*!< InterruptType ACTLR: DISMCYCINT Mask */
  527. /*@}*/ /* end of group CMSIS_CM1_InterruptType */
  528.  
  529.  
  530. #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1)
  531. /** @addtogroup CMSIS_CM1_MPU CMSIS CM1 MPU
  532.   memory mapped structure for Memory Protection Unit (MPU)
  533.   @{
  534.  */
  535. typedef struct
  536. {
  537.   __I  uint32_t TYPE;                         /*!< Offset: 0x00  MPU Type Register                              */
  538.   __IO uint32_t CTRL;                         /*!< Offset: 0x04  MPU Control Register                           */
  539.   __IO uint32_t RNR;                          /*!< Offset: 0x08  MPU Region RNRber Register                     */
  540.   __IO uint32_t RBAR;                         /*!< Offset: 0x0C  MPU Region Base Address Register               */
  541.   __IO uint32_t RASR;                         /*!< Offset: 0x10  MPU Region Attribute and Size Register         */
  542.   __IO uint32_t RBAR_A1;                      /*!< Offset: 0x14  MPU Alias 1 Region Base Address Register       */
  543.   __IO uint32_t RASR_A1;                      /*!< Offset: 0x18  MPU Alias 1 Region Attribute and Size Register */
  544.   __IO uint32_t RBAR_A2;                      /*!< Offset: 0x1C  MPU Alias 2 Region Base Address Register       */
  545.   __IO uint32_t RASR_A2;                      /*!< Offset: 0x20  MPU Alias 2 Region Attribute and Size Register */
  546.   __IO uint32_t RBAR_A3;                      /*!< Offset: 0x24  MPU Alias 3 Region Base Address Register       */
  547.   __IO uint32_t RASR_A3;                      /*!< Offset: 0x28  MPU Alias 3 Region Attribute and Size Register */
  548. } MPU_Type;
  549.  
  550. /* MPU Type Register */
  551. #define MPU_TYPE_IREGION_Pos               16                                             /*!< MPU TYPE: IREGION Position */
  552. #define MPU_TYPE_IREGION_Msk               (0xFFul << MPU_TYPE_IREGION_Pos)               /*!< MPU TYPE: IREGION Mask */
  553.  
  554. #define MPU_TYPE_DREGION_Pos                8                                             /*!< MPU TYPE: DREGION Position */
  555. #define MPU_TYPE_DREGION_Msk               (0xFFul << MPU_TYPE_DREGION_Pos)               /*!< MPU TYPE: DREGION Mask */
  556.  
  557. #define MPU_TYPE_SEPARATE_Pos               0                                             /*!< MPU TYPE: SEPARATE Position */
  558. #define MPU_TYPE_SEPARATE_Msk              (1ul << MPU_TYPE_SEPARATE_Pos)                 /*!< MPU TYPE: SEPARATE Mask */
  559.  
  560. /* MPU Control Register */
  561. #define MPU_CTRL_PRIVDEFENA_Pos             2                                             /*!< MPU CTRL: PRIVDEFENA Position */
  562. #define MPU_CTRL_PRIVDEFENA_Msk            (1ul << MPU_CTRL_PRIVDEFENA_Pos)               /*!< MPU CTRL: PRIVDEFENA Mask */
  563.  
  564. #define MPU_CTRL_HFNMIENA_Pos               1                                             /*!< MPU CTRL: HFNMIENA Position */
  565. #define MPU_CTRL_HFNMIENA_Msk              (1ul << MPU_CTRL_HFNMIENA_Pos)                 /*!< MPU CTRL: HFNMIENA Mask */
  566.  
  567. #define MPU_CTRL_ENABLE_Pos                 0                                             /*!< MPU CTRL: ENABLE Position */
  568. #define MPU_CTRL_ENABLE_Msk                (1ul << MPU_CTRL_ENABLE_Pos)                   /*!< MPU CTRL: ENABLE Mask */
  569.  
  570. /* MPU Region Number Register */
  571. #define MPU_RNR_REGION_Pos                  0                                             /*!< MPU RNR: REGION Position */
  572. #define MPU_RNR_REGION_Msk                 (0xFFul << MPU_RNR_REGION_Pos)                 /*!< MPU RNR: REGION Mask */
  573.  
  574. /* MPU Region Base Address Register */
  575. #define MPU_RBAR_ADDR_Pos                   5                                             /*!< MPU RBAR: ADDR Position */
  576. #define MPU_RBAR_ADDR_Msk                  (0x7FFFFFFul << MPU_RBAR_ADDR_Pos)             /*!< MPU RBAR: ADDR Mask */
  577.  
  578. #define MPU_RBAR_VALID_Pos                  4                                             /*!< MPU RBAR: VALID Position */
  579. #define MPU_RBAR_VALID_Msk                 (1ul << MPU_RBAR_VALID_Pos)                    /*!< MPU RBAR: VALID Mask */
  580.  
  581. #define MPU_RBAR_REGION_Pos                 0                                             /*!< MPU RBAR: REGION Position */
  582. #define MPU_RBAR_REGION_Msk                (0xFul << MPU_RBAR_REGION_Pos)                 /*!< MPU RBAR: REGION Mask */
  583.  
  584. /* MPU Region Attribute and Size Register */
  585. #define MPU_RASR_XN_Pos                    28                                             /*!< MPU RASR: XN Position */
  586. #define MPU_RASR_XN_Msk                    (1ul << MPU_RASR_XN_Pos)                       /*!< MPU RASR: XN Mask */
  587.  
  588. #define MPU_RASR_AP_Pos                    24                                             /*!< MPU RASR: AP Position */
  589. #define MPU_RASR_AP_Msk                    (7ul << MPU_RASR_AP_Pos)                       /*!< MPU RASR: AP Mask */
  590.  
  591. #define MPU_RASR_TEX_Pos                   19                                             /*!< MPU RASR: TEX Position */
  592. #define MPU_RASR_TEX_Msk                   (7ul << MPU_RASR_TEX_Pos)                      /*!< MPU RASR: TEX Mask */
  593.  
  594. #define MPU_RASR_S_Pos                     18                                             /*!< MPU RASR: Shareable bit Position */
  595. #define MPU_RASR_S_Msk                     (1ul << MPU_RASR_S_Pos)                        /*!< MPU RASR: Shareable bit Mask */
  596.  
  597. #define MPU_RASR_C_Pos                     17                                             /*!< MPU RASR: Cacheable bit Position */
  598. #define MPU_RASR_C_Msk                     (1ul << MPU_RASR_C_Pos)                        /*!< MPU RASR: Cacheable bit Mask */
  599.  
  600. #define MPU_RASR_B_Pos                     16                                             /*!< MPU RASR: Bufferable bit Position */
  601. #define MPU_RASR_B_Msk                     (1ul << MPU_RASR_B_Pos)                        /*!< MPU RASR: Bufferable bit Mask */
  602.  
  603. #define MPU_RASR_SRD_Pos                    8                                             /*!< MPU RASR: Sub-Region Disable Position */
  604. #define MPU_RASR_SRD_Msk                   (0xFFul << MPU_RASR_SRD_Pos)                   /*!< MPU RASR: Sub-Region Disable Mask */
  605.  
  606. #define MPU_RASR_SIZE_Pos                   1                                             /*!< MPU RASR: Region Size Field Position */
  607. #define MPU_RASR_SIZE_Msk                  (0x1Ful << MPU_RASR_SIZE_Pos)                  /*!< MPU RASR: Region Size Field Mask */
  608.  
  609. #define MPU_RASR_ENA_Pos                     0                                            /*!< MPU RASR: Region enable bit Position */
  610. #define MPU_RASR_ENA_Msk                    (0x1Ful << MPU_RASR_ENA_Pos)                  /*!< MPU RASR: Region enable bit Disable Mask */
  611.  
  612. /*@}*/ /* end of group CMSIS_CM1_MPU */
  613. #endif
  614.  
  615.  
  616. /** @addtogroup CMSIS_CM1_CoreDebug CMSIS CM1 Core Debug
  617.   memory mapped structure for Core Debug Register
  618.   @{
  619.  */
  620. typedef struct
  621. {
  622.   __IO uint32_t DHCSR;                        /*!< Offset: 0x00  Debug Halting Control and Status Register    */
  623.   __O  uint32_t DCRSR;                        /*!< Offset: 0x04  Debug Core Register Selector Register        */
  624.   __IO uint32_t DCRDR;                        /*!< Offset: 0x08  Debug Core Register Data Register            */
  625.   __IO uint32_t DEMCR;                        /*!< Offset: 0x0C  Debug Exception and Monitor Control Register */
  626. } CoreDebug_Type;
  627.  
  628. /* Debug Halting Control and Status Register */
  629. #define CoreDebug_DHCSR_DBGKEY_Pos         16                                             /*!< CoreDebug DHCSR: DBGKEY Position */
  630. #define CoreDebug_DHCSR_DBGKEY_Msk         (0xFFFFul << CoreDebug_DHCSR_DBGKEY_Pos)       /*!< CoreDebug DHCSR: DBGKEY Mask */
  631.  
  632. #define CoreDebug_DHCSR_S_RESET_ST_Pos     25                                             /*!< CoreDebug DHCSR: S_RESET_ST Position */
  633. #define CoreDebug_DHCSR_S_RESET_ST_Msk     (1ul << CoreDebug_DHCSR_S_RESET_ST_Pos)        /*!< CoreDebug DHCSR: S_RESET_ST Mask */
  634.  
  635. #define CoreDebug_DHCSR_S_RETIRE_ST_Pos    24                                             /*!< CoreDebug DHCSR: S_RETIRE_ST Position */
  636. #define CoreDebug_DHCSR_S_RETIRE_ST_Msk    (1ul << CoreDebug_DHCSR_S_RETIRE_ST_Pos)       /*!< CoreDebug DHCSR: S_RETIRE_ST Mask */
  637.  
  638. #define CoreDebug_DHCSR_S_LOCKUP_Pos       19                                             /*!< CoreDebug DHCSR: S_LOCKUP Position */
  639. #define CoreDebug_DHCSR_S_LOCKUP_Msk       (1ul << CoreDebug_DHCSR_S_LOCKUP_Pos)          /*!< CoreDebug DHCSR: S_LOCKUP Mask */
  640.  
  641. #define CoreDebug_DHCSR_S_SLEEP_Pos        18                                             /*!< CoreDebug DHCSR: S_SLEEP Position */
  642. #define CoreDebug_DHCSR_S_SLEEP_Msk        (1ul << CoreDebug_DHCSR_S_SLEEP_Pos)           /*!< CoreDebug DHCSR: S_SLEEP Mask */
  643.  
  644. #define CoreDebug_DHCSR_S_HALT_Pos         17                                             /*!< CoreDebug DHCSR: S_HALT Position */
  645. #define CoreDebug_DHCSR_S_HALT_Msk         (1ul << CoreDebug_DHCSR_S_HALT_Pos)            /*!< CoreDebug DHCSR: S_HALT Mask */
  646.  
  647. #define CoreDebug_DHCSR_S_REGRDY_Pos       16                                             /*!< CoreDebug DHCSR: S_REGRDY Position */
  648. #define CoreDebug_DHCSR_S_REGRDY_Msk       (1ul << CoreDebug_DHCSR_S_REGRDY_Pos)          /*!< CoreDebug DHCSR: S_REGRDY Mask */
  649.  
  650. #define CoreDebug_DHCSR_C_SNAPSTALL_Pos     5                                             /*!< CoreDebug DHCSR: C_SNAPSTALL Position */
  651. #define CoreDebug_DHCSR_C_SNAPSTALL_Msk    (1ul << CoreDebug_DHCSR_C_SNAPSTALL_Pos)       /*!< CoreDebug DHCSR: C_SNAPSTALL Mask */
  652.  
  653. #define CoreDebug_DHCSR_C_MASKINTS_Pos      3                                             /*!< CoreDebug DHCSR: C_MASKINTS Position */
  654. #define CoreDebug_DHCSR_C_MASKINTS_Msk     (1ul << CoreDebug_DHCSR_C_MASKINTS_Pos)        /*!< CoreDebug DHCSR: C_MASKINTS Mask */
  655.  
  656. #define CoreDebug_DHCSR_C_STEP_Pos          2                                             /*!< CoreDebug DHCSR: C_STEP Position */
  657. #define CoreDebug_DHCSR_C_STEP_Msk         (1ul << CoreDebug_DHCSR_C_STEP_Pos)            /*!< CoreDebug DHCSR: C_STEP Mask */
  658.  
  659. #define CoreDebug_DHCSR_C_HALT_Pos          1                                             /*!< CoreDebug DHCSR: C_HALT Position */
  660. #define CoreDebug_DHCSR_C_HALT_Msk         (1ul << CoreDebug_DHCSR_C_HALT_Pos)            /*!< CoreDebug DHCSR: C_HALT Mask */
  661.  
  662. #define CoreDebug_DHCSR_C_DEBUGEN_Pos       0                                             /*!< CoreDebug DHCSR: C_DEBUGEN Position */
  663. #define CoreDebug_DHCSR_C_DEBUGEN_Msk      (1ul << CoreDebug_DHCSR_C_DEBUGEN_Pos)         /*!< CoreDebug DHCSR: C_DEBUGEN Mask */
  664.  
  665. /* Debug Core Register Selector Register */
  666. #define CoreDebug_DCRSR_REGWnR_Pos         16                                             /*!< CoreDebug DCRSR: REGWnR Position */
  667. #define CoreDebug_DCRSR_REGWnR_Msk         (1ul << CoreDebug_DCRSR_REGWnR_Pos)            /*!< CoreDebug DCRSR: REGWnR Mask */
  668.  
  669. #define CoreDebug_DCRSR_REGSEL_Pos          0                                             /*!< CoreDebug DCRSR: REGSEL Position */
  670. #define CoreDebug_DCRSR_REGSEL_Msk         (0x1Ful << CoreDebug_DCRSR_REGSEL_Pos)         /*!< CoreDebug DCRSR: REGSEL Mask */
  671.  
  672. /* Debug Exception and Monitor Control Register */
  673. #define CoreDebug_DEMCR_TRCENA_Pos         24                                             /*!< CoreDebug DEMCR: TRCENA Position */
  674. #define CoreDebug_DEMCR_TRCENA_Msk         (1ul << CoreDebug_DEMCR_TRCENA_Pos)            /*!< CoreDebug DEMCR: TRCENA Mask */
  675.  
  676. #define CoreDebug_DEMCR_MON_REQ_Pos        19                                             /*!< CoreDebug DEMCR: MON_REQ Position */
  677. #define CoreDebug_DEMCR_MON_REQ_Msk        (1ul << CoreDebug_DEMCR_MON_REQ_Pos)           /*!< CoreDebug DEMCR: MON_REQ Mask */
  678.  
  679. #define CoreDebug_DEMCR_MON_STEP_Pos       18                                             /*!< CoreDebug DEMCR: MON_STEP Position */
  680. #define CoreDebug_DEMCR_MON_STEP_Msk       (1ul << CoreDebug_DEMCR_MON_STEP_Pos)          /*!< CoreDebug DEMCR: MON_STEP Mask */
  681.  
  682. #define CoreDebug_DEMCR_MON_PEND_Pos       17                                             /*!< CoreDebug DEMCR: MON_PEND Position */
  683. #define CoreDebug_DEMCR_MON_PEND_Msk       (1ul << CoreDebug_DEMCR_MON_PEND_Pos)          /*!< CoreDebug DEMCR: MON_PEND Mask */
  684.  
  685. #define CoreDebug_DEMCR_MON_EN_Pos         16                                             /*!< CoreDebug DEMCR: MON_EN Position */
  686. #define CoreDebug_DEMCR_MON_EN_Msk         (1ul << CoreDebug_DEMCR_MON_EN_Pos)            /*!< CoreDebug DEMCR: MON_EN Mask */
  687.  
  688. #define CoreDebug_DEMCR_VC_HARDERR_Pos     10                                             /*!< CoreDebug DEMCR: VC_HARDERR Position */
  689. #define CoreDebug_DEMCR_VC_HARDERR_Msk     (1ul << CoreDebug_DEMCR_VC_HARDERR_Pos)        /*!< CoreDebug DEMCR: VC_HARDERR Mask */
  690.  
  691. #define CoreDebug_DEMCR_VC_INTERR_Pos       9                                             /*!< CoreDebug DEMCR: VC_INTERR Position */
  692. #define CoreDebug_DEMCR_VC_INTERR_Msk      (1ul << CoreDebug_DEMCR_VC_INTERR_Pos)         /*!< CoreDebug DEMCR: VC_INTERR Mask */
  693.  
  694. #define CoreDebug_DEMCR_VC_BUSERR_Pos       8                                             /*!< CoreDebug DEMCR: VC_BUSERR Position */
  695. #define CoreDebug_DEMCR_VC_BUSERR_Msk      (1ul << CoreDebug_DEMCR_VC_BUSERR_Pos)         /*!< CoreDebug DEMCR: VC_BUSERR Mask */
  696.  
  697. #define CoreDebug_DEMCR_VC_STATERR_Pos      7                                             /*!< CoreDebug DEMCR: VC_STATERR Position */
  698. #define CoreDebug_DEMCR_VC_STATERR_Msk     (1ul << CoreDebug_DEMCR_VC_STATERR_Pos)        /*!< CoreDebug DEMCR: VC_STATERR Mask */
  699.  
  700. #define CoreDebug_DEMCR_VC_CHKERR_Pos       6                                             /*!< CoreDebug DEMCR: VC_CHKERR Position */
  701. #define CoreDebug_DEMCR_VC_CHKERR_Msk      (1ul << CoreDebug_DEMCR_VC_CHKERR_Pos)         /*!< CoreDebug DEMCR: VC_CHKERR Mask */
  702.  
  703. #define CoreDebug_DEMCR_VC_NOCPERR_Pos      5                                             /*!< CoreDebug DEMCR: VC_NOCPERR Position */
  704. #define CoreDebug_DEMCR_VC_NOCPERR_Msk     (1ul << CoreDebug_DEMCR_VC_NOCPERR_Pos)        /*!< CoreDebug DEMCR: VC_NOCPERR Mask */
  705.  
  706. #define CoreDebug_DEMCR_VC_MMERR_Pos        4                                             /*!< CoreDebug DEMCR: VC_MMERR Position */
  707. #define CoreDebug_DEMCR_VC_MMERR_Msk       (1ul << CoreDebug_DEMCR_VC_MMERR_Pos)          /*!< CoreDebug DEMCR: VC_MMERR Mask */
  708.  
  709. #define CoreDebug_DEMCR_VC_CORERESET_Pos    0                                             /*!< CoreDebug DEMCR: VC_CORERESET Position */
  710. #define CoreDebug_DEMCR_VC_CORERESET_Msk   (1ul << CoreDebug_DEMCR_VC_CORERESET_Pos)      /*!< CoreDebug DEMCR: VC_CORERESET Mask */
  711. /*@}*/ /* end of group CMSIS_CM1_CoreDebug */
  712.  
  713.  
  714. /* Memory mapping of Cortex-M3 Hardware */
  715. #define SCS_BASE            (0xE000E000)                              /*!< System Control Space Base Address */
  716. #define ITM_BASE            (0xE0000000)                              /*!< ITM Base Address                  */
  717. #define CoreDebug_BASE      (0xE000EDF0)                              /*!< Core Debug Base Address           */
  718. #define SysTick_BASE        (SCS_BASE +  0x0010)                      /*!< SysTick Base Address              */
  719. #define NVIC_BASE           (SCS_BASE +  0x0100)                      /*!< NVIC Base Address                 */
  720. #define SCB_BASE            (SCS_BASE +  0x0D00)                      /*!< System Control Block Base Address */
  721.  
  722. #define InterruptType       ((InterruptType_Type *) SCS_BASE)         /*!< Interrupt Type Register           */
  723. #define SCB                 ((SCB_Type *)           SCB_BASE)         /*!< SCB configuration struct          */
  724. #define SysTick             ((SysTick_Type *)       SysTick_BASE)     /*!< SysTick configuration struct      */
  725. #define NVIC                ((NVIC_Type *)          NVIC_BASE)        /*!< NVIC configuration struct         */
  726. #define ITM                 ((ITM_Type *)           ITM_BASE)         /*!< ITM configuration struct          */
  727. #define CoreDebug           ((CoreDebug_Type *)     CoreDebug_BASE)   /*!< Core Debug configuration struct   */
  728.  
  729. #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1)
  730.   #define MPU_BASE          (SCS_BASE +  0x0D90)                      /*!< Memory Protection Unit            */
  731.   #define MPU               ((MPU_Type*)            MPU_BASE)         /*!< Memory Protection Unit            */
  732. #endif
  733.  
  734. /*@}*/ /* end of group CMSIS_CM1_core_register */
  735.  
  736.  
  737. /*******************************************************************************
  738.  *                Hardware Abstraction Layer
  739.  ******************************************************************************/
  740.  
  741. #if defined ( __CC_ARM   )
  742.   #define __ASM            __asm                                      /*!< asm keyword for ARM Compiler                 */
  743.   #define __INLINE         __inline                                   /*!< inline keyword for ARM Compiler              */
  744.  
  745. #elif defined ( __ICCARM__ )
  746.   #define __ASM           __asm                                       /*!< asm keyword for IAR Compiler                 */
  747.   #define __INLINE        inline                                      /*!< inline keyword for IAR Compiler. Only avaiable in High optimization mode! */
  748.  
  749. #elif defined   (  __GNUC__  )
  750.   #define __ASM            __asm                                      /*!< asm keyword for GNU Compiler                 */
  751.   #define __INLINE         inline                                     /*!< inline keyword for GNU Compiler              */
  752.  
  753. #elif defined   (  __TASKING__  )
  754.   #define __ASM            __asm                                      /*!< asm keyword for TASKING Compiler             */
  755.   #define __INLINE         inline                                     /*!< inline keyword for TASKING Compiler          */
  756.  
  757. #elif defined ( __CMCARM__ )
  758.   #define __ASM            #pragma asm                                /*!< #pragma asm for Phyton CMC-ARM Compiler      */
  759.   #define __INLINE                                                    /*!< no inline support in Phyton CMC-ARM Compiler */
  760.  
  761. #endif
  762.  
  763.  
  764. /* ###################  Compiler specific Intrinsics  ########################### */
  765.  
  766. #if defined ( __CC_ARM   ) /*------------------RealView Compiler -----------------*/
  767. /* ARM armcc specific functions */
  768.  
  769. #define __enable_fault_irq                __enable_fiq
  770. #define __disable_fault_irq               __disable_fiq
  771.  
  772. #define __NOP                             __nop
  773. #define __WFI                             __wfi
  774. #define __WFE                             __wfe
  775. #define __SEV                             __sev
  776. #define __ISB()                           __isb(0)
  777. #define __DSB()                           __dsb(0)
  778. #define __DMB()                           __dmb(0)
  779. #define __REV                             __rev
  780. #define __RBIT                            __rbit
  781. #define __LDREXB(ptr)                     ((unsigned char ) __ldrex(ptr))
  782. #define __LDREXH(ptr)                     ((unsigned short) __ldrex(ptr))
  783. #define __LDREXW(ptr)                     ((unsigned int  ) __ldrex(ptr))
  784. #define __STREXB(value, ptr)              __strex(value, ptr)
  785. #define __STREXH(value, ptr)              __strex(value, ptr)
  786. #define __STREXW(value, ptr)              __strex(value, ptr)
  787.  
  788.  
  789. /* intrinsic unsigned long long __ldrexd(volatile void *ptr) */
  790. /* intrinsic int __strexd(unsigned long long val, volatile void *ptr) */
  791. /* intrinsic void __enable_irq();     */
  792. /* intrinsic void __disable_irq();    */
  793.  
  794.  
  795. /**
  796.  * @brief  Return the Process Stack Pointer
  797.  *
  798.  * @return ProcessStackPointer
  799.  *
  800.  * Return the actual process stack pointer
  801.  */
  802. extern uint32_t __get_PSP(void);
  803.  
  804. /**
  805.  * @brief  Set the Process Stack Pointer
  806.  *
  807.  * @param  topOfProcStack  Process Stack Pointer
  808.  *
  809.  * Assign the value ProcessStackPointer to the MSP
  810.  * (process stack pointer) Cortex processor register
  811.  */
  812. extern void __set_PSP(uint32_t topOfProcStack);
  813.  
  814. /**
  815.  * @brief  Return the Main Stack Pointer
  816.  *
  817.  * @return Main Stack Pointer
  818.  *
  819.  * Return the current value of the MSP (main stack pointer)
  820.  * Cortex processor register
  821.  */
  822. extern uint32_t __get_MSP(void);
  823.  
  824. /**
  825.  * @brief  Set the Main Stack Pointer
  826.  *
  827.  * @param  topOfMainStack  Main Stack Pointer
  828.  *
  829.  * Assign the value mainStackPointer to the MSP
  830.  * (main stack pointer) Cortex processor register
  831.  */
  832. extern void __set_MSP(uint32_t topOfMainStack);
  833.  
  834. /**
  835.  * @brief  Reverse byte order in unsigned short value
  836.  *
  837.  * @param   value  value to reverse
  838.  * @return         reversed value
  839.  *
  840.  * Reverse byte order in unsigned short value
  841.  */
  842. extern uint32_t __REV16(uint16_t value);
  843.  
  844. /**
  845.  * @brief  Reverse byte order in signed short value with sign extension to integer
  846.  *
  847.  * @param   value  value to reverse
  848.  * @return         reversed value
  849.  *
  850.  * Reverse byte order in signed short value with sign extension to integer
  851.  */
  852. extern int32_t __REVSH(int16_t value);
  853.  
  854.  
  855. #if (__ARMCC_VERSION < 400000)
  856.  
  857. /**
  858.  * @brief  Remove the exclusive lock created by ldrex
  859.  *
  860.  * Removes the exclusive lock which is created by ldrex.
  861.  */
  862. extern void __CLREX(void);
  863.  
  864. /**
  865.  * @brief  Return the Base Priority value
  866.  *
  867.  * @return BasePriority
  868.  *
  869.  * Return the content of the base priority register
  870.  */
  871. extern uint32_t __get_BASEPRI(void);
  872.  
  873. /**
  874.  * @brief  Set the Base Priority value
  875.  *
  876.  * @param  basePri  BasePriority
  877.  *
  878.  * Set the base priority register
  879.  */
  880. extern void __set_BASEPRI(uint32_t basePri);
  881.  
  882. /**
  883.  * @brief  Return the Priority Mask value
  884.  *
  885.  * @return PriMask
  886.  *
  887.  * Return state of the priority mask bit from the priority mask register
  888.  */
  889. extern uint32_t __get_PRIMASK(void);
  890.  
  891. /**
  892.  * @brief  Set the Priority Mask value
  893.  *
  894.  * @param   priMask  PriMask
  895.  *
  896.  * Set the priority mask bit in the priority mask register
  897.  */
  898. extern void __set_PRIMASK(uint32_t priMask);
  899.  
  900. /**
  901.  * @brief  Return the Fault Mask value
  902.  *
  903.  * @return FaultMask
  904.  *
  905.  * Return the content of the fault mask register
  906.  */
  907. extern uint32_t __get_FAULTMASK(void);
  908.  
  909. /**
  910.  * @brief  Set the Fault Mask value
  911.  *
  912.  * @param  faultMask faultMask value
  913.  *
  914.  * Set the fault mask register
  915.  */
  916. extern void __set_FAULTMASK(uint32_t faultMask);
  917.  
  918. /**
  919.  * @brief  Return the Control Register value
  920.  *
  921.  * @return Control value
  922.  *
  923.  * Return the content of the control register
  924.  */
  925. extern uint32_t __get_CONTROL(void);
  926.  
  927. /**
  928.  * @brief  Set the Control Register value
  929.  *
  930.  * @param  control  Control value
  931.  *
  932.  * Set the control register
  933.  */
  934. extern void __set_CONTROL(uint32_t control);
  935.  
  936. #else  /* (__ARMCC_VERSION >= 400000)  */
  937.  
  938. /**
  939.  * @brief  Remove the exclusive lock created by ldrex
  940.  *
  941.  * Removes the exclusive lock which is created by ldrex.
  942.  */
  943. #define __CLREX                           __clrex
  944.  
  945. /**
  946.  * @brief  Return the Base Priority value
  947.  *
  948.  * @return BasePriority
  949.  *
  950.  * Return the content of the base priority register
  951.  */
  952. /*
  953. static __INLINE uint32_t  __get_BASEPRI(void)
  954. {
  955.   register uint32_t __regBasePri         __ASM("basepri");
  956.   return(__regBasePri);
  957. }
  958. */
  959. /**
  960.  * @brief  Set the Base Priority value
  961.  *
  962.  * @param  basePri  BasePriority
  963.  *
  964.  * Set the base priority register
  965.  */
  966.  /*
  967. static __INLINE void __set_BASEPRI(uint32_t basePri)
  968. {
  969.   register uint32_t __regBasePri         __ASM("basepri");
  970.   __regBasePri = (basePri & 0xff);
  971. }
  972. */
  973.  
  974. /**
  975.  * @brief  Return the Priority Mask value
  976.  *
  977.  * @return PriMask
  978.  *
  979.  * Return state of the priority mask bit from the priority mask register
  980.  */
  981.  /*
  982. static __INLINE uint32_t __get_PRIMASK(void)
  983. {
  984.   register uint32_t __regPriMask         __ASM("primask");
  985.   return(__regPriMask);
  986. }
  987. */
  988. /**
  989.  * @brief  Set the Priority Mask value
  990.  *
  991.  * @param  priMask  PriMask
  992.  *
  993.  * Set the priority mask bit in the priority mask register
  994.  */
  995.  /*
  996. static __INLINE void __set_PRIMASK(uint32_t priMask)
  997. {
  998.   register uint32_t __regPriMask         __ASM("primask");
  999.   __regPriMask = (priMask);
  1000. }
  1001. */
  1002. /**
  1003.  * @brief  Return the Fault Mask value
  1004.  *
  1005.  * @return FaultMask
  1006.  *
  1007.  * Return the content of the fault mask register
  1008.  */
  1009.  /*
  1010. static __INLINE uint32_t __get_FAULTMASK(void)
  1011. {
  1012.   register uint32_t __regFaultMask       __ASM("faultmask");
  1013.   return(__regFaultMask);
  1014. }
  1015. */
  1016. /**
  1017.  * @brief  Set the Fault Mask value
  1018.  *
  1019.  * @param  faultMask  faultMask value
  1020.  *
  1021.  * Set the fault mask register
  1022.  */
  1023.  /*
  1024. static __INLINE void __set_FAULTMASK(uint32_t faultMask)
  1025. {
  1026.   register uint32_t __regFaultMask       __ASM("faultmask");
  1027.   __regFaultMask = (faultMask & 1);
  1028. }
  1029. */
  1030. /**
  1031.  * @brief  Return the Control Register value
  1032.  *
  1033.  * @return Control value
  1034.  *
  1035.  * Return the content of the control register
  1036.  */
  1037. static __INLINE uint32_t __get_CONTROL(void)
  1038. {
  1039.   register uint32_t __regControl         __ASM("control");
  1040.   return(__regControl);
  1041. }
  1042.  
  1043. /**
  1044.  * @brief  Set the Control Register value
  1045.  *
  1046.  * @param  control  Control value
  1047.  *
  1048.  * Set the control register
  1049.  */
  1050. static __INLINE void __set_CONTROL(uint32_t control)
  1051. {
  1052.   register uint32_t __regControl         __ASM("control");
  1053.   __regControl = control;
  1054. }
  1055.  
  1056. #endif /* __ARMCC_VERSION  */
  1057.  
  1058.  
  1059.  
  1060. #elif (defined (__ICCARM__)) /*------------------ ICC Compiler -------------------*/
  1061. /* IAR iccarm specific functions */
  1062.  
  1063. #define __enable_irq                              __enable_interrupt        /*!< global Interrupt enable */
  1064. #define __disable_irq                             __disable_interrupt       /*!< global Interrupt disable */
  1065.  
  1066. static __INLINE void __enable_fault_irq()         { __ASM ("cpsie f"); }
  1067. static __INLINE void __disable_fault_irq()        { __ASM ("cpsid f"); }
  1068.  
  1069. #define __NOP                                     __no_operation            /*!< no operation intrinsic in IAR Compiler */
  1070. static __INLINE  void __WFI()                     { __ASM ("wfi"); }
  1071. static __INLINE  void __WFE()                     { __ASM ("wfe"); }
  1072. static __INLINE  void __SEV()                     { __ASM ("sev"); }
  1073. static __INLINE  void __CLREX()                   { __ASM ("clrex"); }
  1074.  
  1075. /* intrinsic void __ISB(void)                                     */
  1076. /* intrinsic void __DSB(void)                                     */
  1077. /* intrinsic void __DMB(void)                                     */
  1078. /* intrinsic void __set_PRIMASK();                                */
  1079. /* intrinsic void __get_PRIMASK();                                */
  1080. /* intrinsic void __set_FAULTMASK();                              */
  1081. /* intrinsic void __get_FAULTMASK();                              */
  1082. /* intrinsic uint32_t __REV(uint32_t value);                      */
  1083. /* intrinsic uint32_t __REVSH(uint32_t value);                    */
  1084. /* intrinsic unsigned long __STREX(unsigned long, unsigned long); */
  1085. /* intrinsic unsigned long __LDREX(unsigned long *);              */
  1086.  
  1087.  
  1088. /**
  1089.  * @brief  Return the Process Stack Pointer
  1090.  *
  1091.  * @return ProcessStackPointer
  1092.  *
  1093.  * Return the actual process stack pointer
  1094.  */
  1095. extern uint32_t __get_PSP(void);
  1096.  
  1097. /**
  1098.  * @brief  Set the Process Stack Pointer
  1099.  *
  1100.  * @param  topOfProcStack  Process Stack Pointer
  1101.  *
  1102.  * Assign the value ProcessStackPointer to the MSP
  1103.  * (process stack pointer) Cortex processor register
  1104.  */
  1105. extern void __set_PSP(uint32_t topOfProcStack);
  1106.  
  1107. /**
  1108.  * @brief  Return the Main Stack Pointer
  1109.  *
  1110.  * @return Main Stack Pointer
  1111.  *
  1112.  * Return the current value of the MSP (main stack pointer)
  1113.  * Cortex processor register
  1114.  */
  1115. extern uint32_t __get_MSP(void);
  1116.  
  1117. /**
  1118.  * @brief  Set the Main Stack Pointer
  1119.  *
  1120.  * @param  topOfMainStack  Main Stack Pointer
  1121.  *
  1122.  * Assign the value mainStackPointer to the MSP
  1123.  * (main stack pointer) Cortex processor register
  1124.  */
  1125. extern void __set_MSP(uint32_t topOfMainStack);
  1126.  
  1127. /**
  1128.  * @brief  Reverse byte order in unsigned short value
  1129.  *
  1130.  * @param  value  value to reverse
  1131.  * @return        reversed value
  1132.  *
  1133.  * Reverse byte order in unsigned short value
  1134.  */
  1135. extern uint32_t __REV16(uint16_t value);
  1136.  
  1137. /**
  1138.  * @brief  Reverse bit order of value
  1139.  *
  1140.  * @param  value  value to reverse
  1141.  * @return        reversed value
  1142.  *
  1143.  * Reverse bit order of value
  1144.  */
  1145. extern uint32_t __RBIT(uint32_t value);
  1146.  
  1147. /**
  1148.  * @brief  LDR Exclusive (8 bit)
  1149.  *
  1150.  * @param  *addr  address pointer
  1151.  * @return        value of (*address)
  1152.  *
  1153.  * Exclusive LDR command for 8 bit values)
  1154.  */
  1155. extern uint8_t __LDREXB(uint8_t *addr);
  1156.  
  1157. /**
  1158.  * @brief  LDR Exclusive (16 bit)
  1159.  *
  1160.  * @param  *addr  address pointer
  1161.  * @return        value of (*address)
  1162.  *
  1163.  * Exclusive LDR command for 16 bit values
  1164.  */
  1165. extern uint16_t __LDREXH(uint16_t *addr);
  1166.  
  1167. /**
  1168.  * @brief  LDR Exclusive (32 bit)
  1169.  *
  1170.  * @param  *addr  address pointer
  1171.  * @return        value of (*address)
  1172.  *
  1173.  * Exclusive LDR command for 32 bit values
  1174.  */
  1175. extern uint32_t __LDREXW(uint32_t *addr);
  1176.  
  1177. /**
  1178.  * @brief  STR Exclusive (8 bit)
  1179.  *
  1180.  * @param  value  value to store
  1181.  * @param  *addr  address pointer
  1182.  * @return        successful / failed
  1183.  *
  1184.  * Exclusive STR command for 8 bit values
  1185.  */
  1186. extern uint32_t __STREXB(uint8_t value, uint8_t *addr);
  1187.  
  1188. /**
  1189.  * @brief  STR Exclusive (16 bit)
  1190.  *
  1191.  * @param  value  value to store
  1192.  * @param  *addr  address pointer
  1193.  * @return        successful / failed
  1194.  *
  1195.  * Exclusive STR command for 16 bit values
  1196.  */
  1197. extern uint32_t __STREXH(uint16_t value, uint16_t *addr);
  1198.  
  1199. /**
  1200.  * @brief  STR Exclusive (32 bit)
  1201.  *
  1202.  * @param  value  value to store
  1203.  * @param  *addr  address pointer
  1204.  * @return        successful / failed
  1205.  *
  1206.  * Exclusive STR command for 32 bit values
  1207.  */
  1208. extern uint32_t __STREXW(uint32_t value, uint32_t *addr);
  1209.  
  1210.  
  1211.  
  1212. #elif (defined (__GNUC__)) /*------------------ GNU Compiler ---------------------*/
  1213. /* GNU gcc specific functions */
  1214.  
  1215. static __INLINE void __enable_irq()               { __ASM volatile ("cpsie i"); }
  1216. static __INLINE void __disable_irq()              { __ASM volatile ("cpsid i"); }
  1217.  
  1218. static __INLINE void __enable_fault_irq()         { __ASM volatile ("cpsie f"); }
  1219. static __INLINE void __disable_fault_irq()        { __ASM volatile ("cpsid f"); }
  1220.  
  1221. static __INLINE void __NOP()                      { __ASM volatile ("nop"); }
  1222. static __INLINE void __WFI()                      { __ASM volatile ("wfi"); }
  1223. static __INLINE void __WFE()                      { __ASM volatile ("wfe"); }
  1224. static __INLINE void __SEV()                      { __ASM volatile ("sev"); }
  1225. static __INLINE void __ISB()                      { __ASM volatile ("isb"); }
  1226. static __INLINE void __DSB()                      { __ASM volatile ("dsb"); }
  1227. static __INLINE void __DMB()                      { __ASM volatile ("dmb"); }
  1228. static __INLINE void __CLREX()                    { __ASM volatile ("clrex"); }
  1229.  
  1230.  
  1231. /**
  1232.  * @brief  Return the Process Stack Pointer
  1233.  *
  1234.  * @return ProcessStackPointer
  1235.  *
  1236.  * Return the actual process stack pointer
  1237.  */
  1238. extern uint32_t __get_PSP(void);
  1239.  
  1240. /**
  1241.  * @brief  Set the Process Stack Pointer
  1242.  *
  1243.  * @param  topOfProcStack  Process Stack Pointer
  1244.  *
  1245.  * Assign the value ProcessStackPointer to the MSP
  1246.  * (process stack pointer) Cortex processor register
  1247.  */
  1248. extern void __set_PSP(uint32_t topOfProcStack);
  1249.  
  1250. /**
  1251.  * @brief  Return the Main Stack Pointer
  1252.  *
  1253.  * @return Main Stack Pointer
  1254.  *
  1255.  * Return the current value of the MSP (main stack pointer)
  1256.  * Cortex processor register
  1257.  */
  1258. extern uint32_t __get_MSP(void);
  1259.  
  1260. /**
  1261.  * @brief  Set the Main Stack Pointer
  1262.  *
  1263.  * @param  topOfMainStack  Main Stack Pointer
  1264.  *
  1265.  * Assign the value mainStackPointer to the MSP
  1266.  * (main stack pointer) Cortex processor register
  1267.  */
  1268. extern void __set_MSP(uint32_t topOfMainStack);
  1269.  
  1270. /**
  1271.  * @brief  Return the Base Priority value
  1272.  *
  1273.  * @return BasePriority
  1274.  *
  1275.  * Return the content of the base priority register
  1276.  */
  1277. extern uint32_t __get_BASEPRI(void);
  1278.  
  1279. /**
  1280.  * @brief  Set the Base Priority value
  1281.  *
  1282.  * @param  basePri  BasePriority
  1283.  *
  1284.  * Set the base priority register
  1285.  */
  1286. extern void __set_BASEPRI(uint32_t basePri);
  1287.  
  1288. /**
  1289.  * @brief  Return the Priority Mask value
  1290.  *
  1291.  * @return PriMask
  1292.  *
  1293.  * Return state of the priority mask bit from the priority mask register
  1294.  */
  1295. extern uint32_t  __get_PRIMASK(void);
  1296.  
  1297. /**
  1298.  * @brief  Set the Priority Mask value
  1299.  *
  1300.  * @param  priMask  PriMask
  1301.  *
  1302.  * Set the priority mask bit in the priority mask register
  1303.  */
  1304. extern void __set_PRIMASK(uint32_t priMask);
  1305.  
  1306. /**
  1307.  * @brief  Return the Fault Mask value
  1308.  *
  1309.  * @return FaultMask
  1310.  *
  1311.  * Return the content of the fault mask register
  1312.  */
  1313. extern uint32_t __get_FAULTMASK(void);
  1314.  
  1315. /**
  1316.  * @brief  Set the Fault Mask value
  1317.  *
  1318.  * @param  faultMask  faultMask value
  1319.  *
  1320.  * Set the fault mask register
  1321.  */
  1322. extern void __set_FAULTMASK(uint32_t faultMask);
  1323.  
  1324. /**
  1325.  * @brief  Return the Control Register value
  1326. *
  1327. *  @return Control value
  1328.  *
  1329.  * Return the content of the control register
  1330.  */
  1331. extern uint32_t __get_CONTROL(void);
  1332.  
  1333. /**
  1334.  * @brief  Set the Control Register value
  1335.  *
  1336.  * @param  control  Control value
  1337.  *
  1338.  * Set the control register
  1339.  */
  1340. extern void __set_CONTROL(uint32_t control);
  1341.  
  1342. /**
  1343.  * @brief  Reverse byte order in integer value
  1344.  *
  1345.  * @param  value  value to reverse
  1346.  * @return        reversed value
  1347.  *
  1348.  * Reverse byte order in integer value
  1349.  */
  1350. extern uint32_t __REV(uint32_t value);
  1351.  
  1352. /**
  1353.  * @brief  Reverse byte order in unsigned short value
  1354.  *
  1355.  * @param  value  value to reverse
  1356.  * @return        reversed value
  1357.  *
  1358.  * Reverse byte order in unsigned short value
  1359.  */
  1360. extern uint32_t __REV16(uint16_t value);
  1361.  
  1362. /**
  1363.  * @brief  Reverse byte order in signed short value with sign extension to integer
  1364.  *
  1365.  * @param  value  value to reverse
  1366.  * @return        reversed value
  1367.  *
  1368.  * Reverse byte order in signed short value with sign extension to integer
  1369.  */
  1370. extern int32_t __REVSH(int16_t value);
  1371.  
  1372. /**
  1373.  * @brief  Reverse bit order of value
  1374.  *
  1375.  * @param  value  value to reverse
  1376.  * @return        reversed value
  1377.  *
  1378.  * Reverse bit order of value
  1379.  */
  1380. extern uint32_t __RBIT(uint32_t value);
  1381.  
  1382. /**
  1383.  * @brief  LDR Exclusive (8 bit)
  1384.  *
  1385.  * @param  *addr  address pointer
  1386.  * @return        value of (*address)
  1387.  *
  1388.  * Exclusive LDR command for 8 bit value
  1389.  */
  1390. extern uint8_t __LDREXB(uint8_t *addr);
  1391.  
  1392. /**
  1393.  * @brief  LDR Exclusive (16 bit)
  1394.  *
  1395.  * @param  *addr  address pointer
  1396.  * @return        value of (*address)
  1397.  *
  1398.  * Exclusive LDR command for 16 bit values
  1399.  */
  1400. extern uint16_t __LDREXH(uint16_t *addr);
  1401.  
  1402. /**
  1403.  * @brief  LDR Exclusive (32 bit)
  1404.  *
  1405.  * @param  *addr  address pointer
  1406.  * @return        value of (*address)
  1407.  *
  1408.  * Exclusive LDR command for 32 bit values
  1409.  */
  1410. extern uint32_t __LDREXW(uint32_t *addr);
  1411.  
  1412. /**
  1413.  * @brief  STR Exclusive (8 bit)
  1414.  *
  1415.  * @param  value  value to store
  1416.  * @param  *addr  address pointer
  1417.  * @return        successful / failed
  1418.  *
  1419.  * Exclusive STR command for 8 bit values
  1420.  */
  1421. extern uint32_t __STREXB(uint8_t value, uint8_t *addr);
  1422.  
  1423. /**
  1424.  * @brief  STR Exclusive (16 bit)
  1425.  *
  1426.  * @param  value  value to store
  1427.  * @param  *addr  address pointer
  1428.  * @return        successful / failed
  1429.  *
  1430.  * Exclusive STR command for 16 bit values
  1431.  */
  1432. extern uint32_t __STREXH(uint16_t value, uint16_t *addr);
  1433.  
  1434. /**
  1435.  * @brief  STR Exclusive (32 bit)
  1436.  *
  1437.  * @param  value  value to store
  1438.  * @param  *addr  address pointer
  1439.  * @return        successful / failed
  1440.  *
  1441.  * Exclusive STR command for 32 bit values
  1442.  */
  1443. extern uint32_t __STREXW(uint32_t value, uint32_t *addr);
  1444.  
  1445.  
  1446. #elif (defined (__TASKING__)) /*------------------ TASKING Compiler ---------------------*/
  1447. /* TASKING carm specific functions */
  1448.  
  1449. /*
  1450.  * The CMSIS functions have been implemented as intrinsics in the compiler.
  1451.  * Please use "carm -?i" to get an up to date list of all instrinsics,
  1452.  * Including the CMSIS ones.
  1453.  */
  1454.  
  1455.  
  1456. #elif (defined (__CMCARM__)) /*----------------- Phyton CMC-ARM Compiler ---------------*/
  1457. /* Phyton CMC-ARM specific functions */
  1458.  
  1459. /*
  1460.  * The CMSIS functions have been implemented as intrinsics in the compiler.
  1461.  */
  1462.  
  1463. #endif
  1464.  
  1465.  
  1466. /** @addtogroup CMSIS_CM1_Core_FunctionInterface CMSIS CM1 Core Function Interface
  1467.   Core  Function Interface containing:
  1468.   - Core NVIC Functions
  1469.   - Core SysTick Functions
  1470.   - Core Reset Functions
  1471. */
  1472. /*@{*/
  1473.  
  1474.  
  1475. /* ##########################   NVIC functions  #################################### */
  1476.  
  1477. /**
  1478.  * @brief  Set the Priority Grouping in NVIC Interrupt Controller
  1479.  *
  1480.  * @param  PriorityGroup is priority grouping field
  1481.  *
  1482.  * Set the priority grouping field using the required unlock sequence.
  1483.  * The parameter priority_grouping is assigned to the field
  1484.  * SCB->AIRCR [10:8] PRIGROUP field. Only values from 0..7 are used.
  1485.  * In case of a conflict between priority grouping and available
  1486.  * priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set.
  1487.  */
  1488. static __INLINE void NVIC_SetPriorityGrouping(uint32_t PriorityGroup)
  1489. {
  1490.   uint32_t reg_value;
  1491.   uint32_t PriorityGroupTmp = (PriorityGroup & 0x07);                         /* only values 0..7 are used          */
  1492.  
  1493.   reg_value  =  SCB->AIRCR;                                                   /* read old register configuration    */
  1494.   reg_value &= ~(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk);             /* clear bits to change               */
  1495.   reg_value  =  (reg_value                       |
  1496.                 (0x5FA << SCB_AIRCR_VECTKEY_Pos) |
  1497.                 (PriorityGroupTmp << 8));                                     /* Insert write key and priorty group */
  1498.   SCB->AIRCR =  reg_value;
  1499. }
  1500.  
  1501. /**
  1502.  * @brief  Get the Priority Grouping from NVIC Interrupt Controller
  1503.  *
  1504.  * @return priority grouping field
  1505.  *
  1506.  * Get the priority grouping from NVIC Interrupt Controller.
  1507.  * priority grouping is SCB->AIRCR [10:8] PRIGROUP field.
  1508.  */
  1509. static __INLINE uint32_t NVIC_GetPriorityGrouping(void)
  1510. {
  1511.   return ((SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos);   /* read priority grouping field */
  1512. }
  1513.  
  1514. /**
  1515.  * @brief  Enable Interrupt in NVIC Interrupt Controller
  1516.  *
  1517.  * @param  IRQn   The positive number of the external interrupt to enable
  1518.  *
  1519.  * Enable a device specific interupt in the NVIC interrupt controller.
  1520.  * The interrupt number cannot be a negative value.
  1521.  */
  1522. static __INLINE void NVIC_EnableIRQ(IRQn_Type IRQn)
  1523. {
  1524.   NVIC->ISER[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F)); /* enable interrupt */
  1525. }
  1526.  
  1527. /**
  1528.  * @brief  Disable the interrupt line for external interrupt specified
  1529.  *
  1530.  * @param  IRQn   The positive number of the external interrupt to disable
  1531.  *
  1532.  * Disable a device specific interupt in the NVIC interrupt controller.
  1533.  * The interrupt number cannot be a negative value.
  1534.  */
  1535. static __INLINE void NVIC_DisableIRQ(IRQn_Type IRQn)
  1536. {
  1537.   NVIC->ICER[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F)); /* disable interrupt */
  1538. }
  1539.  
  1540. /**
  1541.  * @brief  Read the interrupt pending bit for a device specific interrupt source
  1542.  *
  1543.  * @param  IRQn    The number of the device specifc interrupt
  1544.  * @return         1 = interrupt pending, 0 = interrupt not pending
  1545.  *
  1546.  * Read the pending register in NVIC and return 1 if its status is pending,
  1547.  * otherwise it returns 0
  1548.  */
  1549. static __INLINE uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn)
  1550. {
  1551.   return((uint32_t) ((NVIC->ISPR[(uint32_t)(IRQn) >> 5] & (1 << ((uint32_t)(IRQn) & 0x1F)))?1:0)); /* Return 1 if pending else 0 */
  1552. }
  1553.  
  1554. /**
  1555.  * @brief  Set the pending bit for an external interrupt
  1556.  *
  1557.  * @param  IRQn    The number of the interrupt for set pending
  1558.  *
  1559.  * Set the pending bit for the specified interrupt.
  1560.  * The interrupt number cannot be a negative value.
  1561.  */
  1562. static __INLINE void NVIC_SetPendingIRQ(IRQn_Type IRQn)
  1563. {
  1564.   NVIC->ISPR[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F)); /* set interrupt pending */
  1565. }
  1566.  
  1567. /**
  1568.  * @brief  Clear the pending bit for an external interrupt
  1569.  *
  1570.  * @param  IRQn    The number of the interrupt for clear pending
  1571.  *
  1572.  * Clear the pending bit for the specified interrupt.
  1573.  * The interrupt number cannot be a negative value.
  1574.  */
  1575. static __INLINE void NVIC_ClearPendingIRQ(IRQn_Type IRQn)
  1576. {
  1577.   NVIC->ICPR[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F)); /* Clear pending interrupt */
  1578. }
  1579.  
  1580. /**
  1581.  * @brief  Read the active bit for an external interrupt
  1582.  *
  1583.  * @param  IRQn    The number of the interrupt for read active bit
  1584.  * @return         1 = interrupt active, 0 = interrupt not active
  1585.  *
  1586.  * Read the active register in NVIC and returns 1 if its status is active,
  1587.  * otherwise it returns 0.
  1588.  */
  1589. static __INLINE uint32_t NVIC_GetActive(IRQn_Type IRQn)
  1590. {
  1591.   return((uint32_t)((NVIC->IABR[(uint32_t)(IRQn) >> 5] & (1 << ((uint32_t)(IRQn) & 0x1F)))?1:0)); /* Return 1 if active else 0 */
  1592. }
  1593.  
  1594. /**
  1595.  * @brief  Set the priority for an interrupt
  1596.  *
  1597.  * @param  IRQn      The number of the interrupt for set priority
  1598.  * @param  priority  The priority to set
  1599.  *
  1600.  * Set the priority for the specified interrupt. The interrupt
  1601.  * number can be positive to specify an external (device specific)
  1602.  * interrupt, or negative to specify an internal (core) interrupt.
  1603.  *
  1604.  * Note: The priority cannot be set for every core interrupt.
  1605.  */
  1606. static __INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority)
  1607. {
  1608.   if(IRQn < 0) {
  1609.     SCB->SHP[((uint32_t)(IRQn) & 0xF)-4] = ((priority << (8 - __NVIC_PRIO_BITS)) & 0xff); } /* set Priority for Cortex-M3 System Interrupts */
  1610.   else {
  1611.     NVIC->IP[(uint32_t)(IRQn)] = ((priority << (8 - __NVIC_PRIO_BITS)) & 0xff);    }        /* set Priority for device specific Interrupts  */
  1612. }
  1613.  
  1614. /**
  1615.  * @brief  Read the priority for an interrupt
  1616.  *
  1617.  * @param  IRQn      The number of the interrupt for get priority
  1618.  * @return           The priority for the interrupt
  1619.  *
  1620.  * Read the priority for the specified interrupt. The interrupt
  1621.  * number can be positive to specify an external (device specific)
  1622.  * interrupt, or negative to specify an internal (core) interrupt.
  1623.  *
  1624.  * The returned priority value is automatically aligned to the implemented
  1625.  * priority bits of the microcontroller.
  1626.  *
  1627.  * Note: The priority cannot be set for every core interrupt.
  1628.  */
  1629. static __INLINE uint32_t NVIC_GetPriority(IRQn_Type IRQn)
  1630. {
  1631.  
  1632.   if(IRQn < 0) {
  1633.     return((uint32_t)(SCB->SHP[((uint32_t)(IRQn) & 0xF)-4] >> (8 - __NVIC_PRIO_BITS)));  } /* get priority for Cortex-M3 system interrupts */
  1634.   else {
  1635.     return((uint32_t)(NVIC->IP[(uint32_t)(IRQn)]           >> (8 - __NVIC_PRIO_BITS)));  } /* get priority for device specific interrupts  */
  1636. }
  1637.  
  1638.  
  1639. /**
  1640.  * @brief  Encode the priority for an interrupt
  1641.  *
  1642.  * @param  PriorityGroup    The used priority group
  1643.  * @param  PreemptPriority  The preemptive priority value (starting from 0)
  1644.  * @param  SubPriority      The sub priority value (starting from 0)
  1645.  * @return                  The encoded priority for the interrupt
  1646.  *
  1647.  * Encode the priority for an interrupt with the given priority group,
  1648.  * preemptive priority value and sub priority value.
  1649.  * In case of a conflict between priority grouping and available
  1650.  * priority bits (__NVIC_PRIO_BITS) the samllest possible priority group is set.
  1651.  *
  1652.  * The returned priority value can be used for NVIC_SetPriority(...) function
  1653.  */
  1654. static __INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority)
  1655. {
  1656.   uint32_t PriorityGroupTmp = (PriorityGroup & 0x07);          /* only values 0..7 are used          */
  1657.   uint32_t PreemptPriorityBits;
  1658.   uint32_t SubPriorityBits;
  1659.  
  1660.   PreemptPriorityBits = ((7 - PriorityGroupTmp) > __NVIC_PRIO_BITS) ? __NVIC_PRIO_BITS : 7 - PriorityGroupTmp;
  1661.   SubPriorityBits     = ((PriorityGroupTmp + __NVIC_PRIO_BITS) < 7) ? 0 : PriorityGroupTmp - 7 + __NVIC_PRIO_BITS;
  1662.  
  1663.   return (
  1664.            ((PreemptPriority & ((1 << (PreemptPriorityBits)) - 1)) << SubPriorityBits) |
  1665.            ((SubPriority     & ((1 << (SubPriorityBits    )) - 1)))
  1666.          );
  1667. }
  1668.  
  1669.  
  1670. /**
  1671.  * @brief  Decode the priority of an interrupt
  1672.  *
  1673.  * @param  Priority           The priority for the interrupt
  1674.  * @param  PriorityGroup      The used priority group
  1675.  * @param  pPreemptPriority   The preemptive priority value (starting from 0)
  1676.  * @param  pSubPriority       The sub priority value (starting from 0)
  1677.  *
  1678.  * Decode an interrupt priority value with the given priority group to
  1679.  * preemptive priority value and sub priority value.
  1680.  * In case of a conflict between priority grouping and available
  1681.  * priority bits (__NVIC_PRIO_BITS) the samllest possible priority group is set.
  1682.  *
  1683.  * The priority value can be retrieved with NVIC_GetPriority(...) function
  1684.  */
  1685. static __INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* pPreemptPriority, uint32_t* pSubPriority)
  1686. {
  1687.   uint32_t PriorityGroupTmp = (PriorityGroup & 0x07);          /* only values 0..7 are used          */
  1688.   uint32_t PreemptPriorityBits;
  1689.   uint32_t SubPriorityBits;
  1690.  
  1691.   PreemptPriorityBits = ((7 - PriorityGroupTmp) > __NVIC_PRIO_BITS) ? __NVIC_PRIO_BITS : 7 - PriorityGroupTmp;
  1692.   SubPriorityBits     = ((PriorityGroupTmp + __NVIC_PRIO_BITS) < 7) ? 0 : PriorityGroupTmp - 7 + __NVIC_PRIO_BITS;
  1693.  
  1694.   *pPreemptPriority = (Priority >> SubPriorityBits) & ((1 << (PreemptPriorityBits)) - 1);
  1695.   *pSubPriority     = (Priority                   ) & ((1 << (SubPriorityBits    )) - 1);
  1696. }
  1697.  
  1698.  
  1699. /* ##################################    SysTick function  ############################################ */
  1700.  
  1701. #if (!defined (__Vendor_SysTickConfig)) || (__Vendor_SysTickConfig == 0)
  1702.  
  1703. /**
  1704.  * @brief  Initialize and start the SysTick counter and its interrupt.
  1705.  *
  1706.  * @param   ticks   number of ticks between two interrupts
  1707.  * @return  1 = failed, 0 = successful
  1708.  *
  1709.  * Initialise the system tick timer and its interrupt and start the
  1710.  * system tick timer / counter in free running mode to generate
  1711.  * periodical interrupts.
  1712.  */
  1713. static __INLINE uint32_t SysTick_Config(uint32_t ticks)
  1714. {
  1715.   if (ticks > SysTick_LOAD_RELOAD_Msk)  return (1);            /* Reload value impossible */
  1716.  
  1717.   SysTick->LOAD  = (ticks & SysTick_LOAD_RELOAD_Msk) - 1;      /* set reload register */
  1718.   NVIC_SetPriority (SysTick_IRQn, (1<<__NVIC_PRIO_BITS) - 1);  /* set Priority for Cortex-M0 System Interrupts */
  1719.   SysTick->VAL   = 0;                                          /* Load the SysTick Counter Value */
  1720.   SysTick->CTRL  = SysTick_CTRL_CLKSOURCE_Msk |
  1721.                    SysTick_CTRL_TICKINT_Msk   |
  1722.                    SysTick_CTRL_ENABLE_Msk;                    /* Enable SysTick IRQ and SysTick Timer */
  1723.   return (0);                                                  /* Function successful */
  1724. }
  1725.  
  1726. #endif
  1727.  
  1728.  
  1729. /* ##################################    Reset function  ############################################ */
  1730.  
  1731. /**
  1732.  * @brief  Initiate a system reset request.
  1733.  *
  1734.  * Initiate a system reset request to reset the MCU
  1735.  */
  1736. static __INLINE void NVIC_SystemReset(void)
  1737. {
  1738.   SCB->AIRCR  = ((0x5FA << SCB_AIRCR_VECTKEY_Pos)      |
  1739.                  (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) |
  1740.                  SCB_AIRCR_SYSRESETREQ_Msk);                   /* Keep priority group unchanged */
  1741.   __DSB();                                                     /* Ensure completion of memory access */
  1742.   while(1);                                                    /* wait until reset */
  1743. }
  1744.  
  1745.  
  1746. /*@}*/ /* end of group CMSIS_CM1_Core_FunctionInterface */
  1747.  
  1748.  
  1749.  
  1750. /* ##################################### Debug In/Output function ########################################### */
  1751.  
  1752. /** @addtogroup CMSIS_CM1_CoreDebugInterface CMSIS CM1 Core Debug Interface
  1753.   Core Debug Interface containing:
  1754.   - Core Debug Receive / Transmit Functions
  1755.   - Core Debug Defines
  1756.   - Core Debug Variables
  1757. */
  1758. /*@{*/
  1759.  
  1760. extern volatile int ITM_RxBuffer;                    /*!< variable to receive characters                             */
  1761. #define             ITM_RXBUFFER_EMPTY    0x5AA55AA5 /*!< value identifying ITM_RxBuffer is ready for next character */
  1762.  
  1763.  
  1764. /**
  1765.  * @brief  Outputs a character via the ITM channel 0
  1766.  *
  1767.  * @param  ch   character to output
  1768.  * @return      character to output
  1769.  *
  1770.  * The function outputs a character via the ITM channel 0.
  1771.  * The function returns when no debugger is connected that has booked the output.
  1772.  * It is blocking when a debugger is connected, but the previous character send is not transmitted.
  1773.  */
  1774. static __INLINE uint32_t ITM_SendChar (uint32_t ch)
  1775. {
  1776.   if ((CoreDebug->DEMCR & CoreDebug_DEMCR_TRCENA_Msk)  &&      /* Trace enabled */
  1777.       (ITM->TCR & ITM_TCR_ITMENA_Msk)                  &&      /* ITM enabled */
  1778.       (ITM->TER & (1ul << 0)        )                    )     /* ITM Port #0 enabled */
  1779.   {
  1780.     while (ITM->PORT[0].u32 == 0);
  1781.     ITM->PORT[0].u8 = (uint8_t) ch;
  1782.   }
  1783.   return (ch);
  1784. }
  1785.  
  1786.  
  1787. /**
  1788.  * @brief  Inputs a character via variable ITM_RxBuffer
  1789.  *
  1790.  * @return      received character, -1 = no character received
  1791.  *
  1792.  * The function inputs a character via variable ITM_RxBuffer.
  1793.  * The function returns when no debugger is connected that has booked the output.
  1794.  * It is blocking when a debugger is connected, but the previous character send is not transmitted.
  1795.  */
  1796. static __INLINE int ITM_ReceiveChar (void) {
  1797.   int ch = -1;                               /* no character available */
  1798.  
  1799.   if (ITM_RxBuffer != ITM_RXBUFFER_EMPTY) {
  1800.     ch = ITM_RxBuffer;
  1801.     ITM_RxBuffer = ITM_RXBUFFER_EMPTY;       /* ready for next character */
  1802.   }
  1803.  
  1804.   return (ch);
  1805. }
  1806.  
  1807.  
  1808. /**
  1809.  * @brief  Check if a character via variable ITM_RxBuffer is available
  1810.  *
  1811.  * @return      1 = character available, 0 = no character available
  1812.  *
  1813.  * The function checks  variable ITM_RxBuffer whether a character is available or not.
  1814.  * The function returns '1' if a character is available and '0' if no character is available.
  1815.  */
  1816. static __INLINE int ITM_CheckChar (void) {
  1817.  
  1818.   if (ITM_RxBuffer == ITM_RXBUFFER_EMPTY) {
  1819.     return (0);                                 /* no character available */
  1820.   } else {
  1821.     return (1);                                 /*    character available */
  1822.   }
  1823. }
  1824.  
  1825.  
  1826. /*@}*/ /* end of group CMSIS_CM1_core_DebugInterface */
  1827.  
  1828.  
  1829. #ifdef __cplusplus
  1830. }
  1831. #endif
  1832.  
  1833. /*@}*/ /* end of group CMSIS_CM1_core_definitions */
  1834.  
  1835. #endif /* __CM1_CORE_H__ */
  1836.  
  1837. /*lint -restore */
  1838.