STM32F10x Standard Peripherals Library  3.5.0
/opt/STM32F10x_StdPeriph_Lib_V3.5.0/Libraries/CMSIS/CM3/CoreSupport/core_cm3.h
Go to the documentation of this file.
00001 /**************************************************************************/
00024 #ifndef __CM3_CORE_H__
00025 #define __CM3_CORE_H__
00026 
00062 /*lint -save */
00063 /*lint -e10  */
00064 /*lint -e530 */
00065 /*lint -e550 */
00066 /*lint -e754 */
00067 /*lint -e750 */
00068 /*lint -e528 */
00069 /*lint -e751 */
00070 
00071 
00080 #ifdef __cplusplus
00081  extern "C" {
00082 #endif 
00083 
00084 #define __CM3_CMSIS_VERSION_MAIN  (0x01)                                                       
00085 #define __CM3_CMSIS_VERSION_SUB   (0x30)                                                       
00086 #define __CM3_CMSIS_VERSION       ((__CM3_CMSIS_VERSION_MAIN << 16) | __CM3_CMSIS_VERSION_SUB) 
00088 #define __CORTEX_M                (0x03)                                                       
00090 #include <stdint.h>                           /* Include standard types */
00091 
00092 #if defined (__ICCARM__)
00093   #include <intrinsics.h>                     /* IAR Intrinsics   */
00094 #endif
00095 
00096 
00097 #ifndef __NVIC_PRIO_BITS
00098   #define __NVIC_PRIO_BITS    4               
00099 #endif
00100 
00101 
00102 
00103 
00110 #ifdef __cplusplus
00111   #define     __I     volatile                
00112 #else
00113   #define     __I     volatile const          
00114 #endif
00115 #define     __O     volatile                  
00116 #define     __IO    volatile                  
00120 /*******************************************************************************
00121  *                 Register Abstraction
00122  ******************************************************************************/
00123 
00132 typedef struct
00133 {
00134   __IO uint32_t ISER[8];                      
00135        uint32_t RESERVED0[24];                                   
00136   __IO uint32_t ICER[8];                      
00137        uint32_t RSERVED1[24];                                    
00138   __IO uint32_t ISPR[8];                      
00139        uint32_t RESERVED2[24];                                   
00140   __IO uint32_t ICPR[8];                      
00141        uint32_t RESERVED3[24];                                   
00142   __IO uint32_t IABR[8];                      
00143        uint32_t RESERVED4[56];                                   
00144   __IO uint8_t  IP[240];                      
00145        uint32_t RESERVED5[644];                                  
00146   __O  uint32_t STIR;                         
00147 }  NVIC_Type;                                                /* end of group CMSIS_CM3_NVIC */
00149 
00150 
00155 typedef struct
00156 {
00157   __I  uint32_t CPUID;                        
00158   __IO uint32_t ICSR;                         
00159   __IO uint32_t VTOR;                         
00160   __IO uint32_t AIRCR;                        
00161   __IO uint32_t SCR;                          
00162   __IO uint32_t CCR;                          
00163   __IO uint8_t  SHP[12];                      
00164   __IO uint32_t SHCSR;                        
00165   __IO uint32_t CFSR;                         
00166   __IO uint32_t HFSR;                         
00167   __IO uint32_t DFSR;                         
00168   __IO uint32_t MMFAR;                        
00169   __IO uint32_t BFAR;                         
00170   __IO uint32_t AFSR;                         
00171   __I  uint32_t PFR[2];                       
00172   __I  uint32_t DFR;                          
00173   __I  uint32_t ADR;                          
00174   __I  uint32_t MMFR[4];                      
00175   __I  uint32_t ISAR[5];                      
00176 } SCB_Type;                                                
00177 
00178 /* SCB CPUID Register Definitions */
00179 #define SCB_CPUID_IMPLEMENTER_Pos          24                                             
00180 #define SCB_CPUID_IMPLEMENTER_Msk          (0xFFul << SCB_CPUID_IMPLEMENTER_Pos)          
00182 #define SCB_CPUID_VARIANT_Pos              20                                             
00183 #define SCB_CPUID_VARIANT_Msk              (0xFul << SCB_CPUID_VARIANT_Pos)               
00185 #define SCB_CPUID_PARTNO_Pos                4                                             
00186 #define SCB_CPUID_PARTNO_Msk               (0xFFFul << SCB_CPUID_PARTNO_Pos)              
00188 #define SCB_CPUID_REVISION_Pos              0                                             
00189 #define SCB_CPUID_REVISION_Msk             (0xFul << SCB_CPUID_REVISION_Pos)              
00191 /* SCB Interrupt Control State Register Definitions */
00192 #define SCB_ICSR_NMIPENDSET_Pos            31                                             
00193 #define SCB_ICSR_NMIPENDSET_Msk            (1ul << SCB_ICSR_NMIPENDSET_Pos)               
00195 #define SCB_ICSR_PENDSVSET_Pos             28                                             
00196 #define SCB_ICSR_PENDSVSET_Msk             (1ul << SCB_ICSR_PENDSVSET_Pos)                
00198 #define SCB_ICSR_PENDSVCLR_Pos             27                                             
00199 #define SCB_ICSR_PENDSVCLR_Msk             (1ul << SCB_ICSR_PENDSVCLR_Pos)                
00201 #define SCB_ICSR_PENDSTSET_Pos             26                                             
00202 #define SCB_ICSR_PENDSTSET_Msk             (1ul << SCB_ICSR_PENDSTSET_Pos)                
00204 #define SCB_ICSR_PENDSTCLR_Pos             25                                             
00205 #define SCB_ICSR_PENDSTCLR_Msk             (1ul << SCB_ICSR_PENDSTCLR_Pos)                
00207 #define SCB_ICSR_ISRPREEMPT_Pos            23                                             
00208 #define SCB_ICSR_ISRPREEMPT_Msk            (1ul << SCB_ICSR_ISRPREEMPT_Pos)               
00210 #define SCB_ICSR_ISRPENDING_Pos            22                                             
00211 #define SCB_ICSR_ISRPENDING_Msk            (1ul << SCB_ICSR_ISRPENDING_Pos)               
00213 #define SCB_ICSR_VECTPENDING_Pos           12                                             
00214 #define SCB_ICSR_VECTPENDING_Msk           (0x1FFul << SCB_ICSR_VECTPENDING_Pos)          
00216 #define SCB_ICSR_RETTOBASE_Pos             11                                             
00217 #define SCB_ICSR_RETTOBASE_Msk             (1ul << SCB_ICSR_RETTOBASE_Pos)                
00219 #define SCB_ICSR_VECTACTIVE_Pos             0                                             
00220 #define SCB_ICSR_VECTACTIVE_Msk            (0x1FFul << SCB_ICSR_VECTACTIVE_Pos)           
00222 /* SCB Interrupt Control State Register Definitions */
00223 #define SCB_VTOR_TBLBASE_Pos               29                                             
00224 #define SCB_VTOR_TBLBASE_Msk               (0x1FFul << SCB_VTOR_TBLBASE_Pos)              
00226 #define SCB_VTOR_TBLOFF_Pos                 7                                             
00227 #define SCB_VTOR_TBLOFF_Msk                (0x3FFFFFul << SCB_VTOR_TBLOFF_Pos)            
00229 /* SCB Application Interrupt and Reset Control Register Definitions */
00230 #define SCB_AIRCR_VECTKEY_Pos              16                                             
00231 #define SCB_AIRCR_VECTKEY_Msk              (0xFFFFul << SCB_AIRCR_VECTKEY_Pos)            
00233 #define SCB_AIRCR_VECTKEYSTAT_Pos          16                                             
00234 #define SCB_AIRCR_VECTKEYSTAT_Msk          (0xFFFFul << SCB_AIRCR_VECTKEYSTAT_Pos)        
00236 #define SCB_AIRCR_ENDIANESS_Pos            15                                             
00237 #define SCB_AIRCR_ENDIANESS_Msk            (1ul << SCB_AIRCR_ENDIANESS_Pos)               
00239 #define SCB_AIRCR_PRIGROUP_Pos              8                                             
00240 #define SCB_AIRCR_PRIGROUP_Msk             (7ul << SCB_AIRCR_PRIGROUP_Pos)                
00242 #define SCB_AIRCR_SYSRESETREQ_Pos           2                                             
00243 #define SCB_AIRCR_SYSRESETREQ_Msk          (1ul << SCB_AIRCR_SYSRESETREQ_Pos)             
00245 #define SCB_AIRCR_VECTCLRACTIVE_Pos         1                                             
00246 #define SCB_AIRCR_VECTCLRACTIVE_Msk        (1ul << SCB_AIRCR_VECTCLRACTIVE_Pos)           
00248 #define SCB_AIRCR_VECTRESET_Pos             0                                             
00249 #define SCB_AIRCR_VECTRESET_Msk            (1ul << SCB_AIRCR_VECTRESET_Pos)               
00251 /* SCB System Control Register Definitions */
00252 #define SCB_SCR_SEVONPEND_Pos               4                                             
00253 #define SCB_SCR_SEVONPEND_Msk              (1ul << SCB_SCR_SEVONPEND_Pos)                 
00255 #define SCB_SCR_SLEEPDEEP_Pos               2                                             
00256 #define SCB_SCR_SLEEPDEEP_Msk              (1ul << SCB_SCR_SLEEPDEEP_Pos)                 
00258 #define SCB_SCR_SLEEPONEXIT_Pos             1                                             
00259 #define SCB_SCR_SLEEPONEXIT_Msk            (1ul << SCB_SCR_SLEEPONEXIT_Pos)               
00261 /* SCB Configuration Control Register Definitions */
00262 #define SCB_CCR_STKALIGN_Pos                9                                             
00263 #define SCB_CCR_STKALIGN_Msk               (1ul << SCB_CCR_STKALIGN_Pos)                  
00265 #define SCB_CCR_BFHFNMIGN_Pos               8                                             
00266 #define SCB_CCR_BFHFNMIGN_Msk              (1ul << SCB_CCR_BFHFNMIGN_Pos)                 
00268 #define SCB_CCR_DIV_0_TRP_Pos               4                                             
00269 #define SCB_CCR_DIV_0_TRP_Msk              (1ul << SCB_CCR_DIV_0_TRP_Pos)                 
00271 #define SCB_CCR_UNALIGN_TRP_Pos             3                                             
00272 #define SCB_CCR_UNALIGN_TRP_Msk            (1ul << SCB_CCR_UNALIGN_TRP_Pos)               
00274 #define SCB_CCR_USERSETMPEND_Pos            1                                             
00275 #define SCB_CCR_USERSETMPEND_Msk           (1ul << SCB_CCR_USERSETMPEND_Pos)              
00277 #define SCB_CCR_NONBASETHRDENA_Pos          0                                             
00278 #define SCB_CCR_NONBASETHRDENA_Msk         (1ul << SCB_CCR_NONBASETHRDENA_Pos)            
00280 /* SCB System Handler Control and State Register Definitions */
00281 #define SCB_SHCSR_USGFAULTENA_Pos          18                                             
00282 #define SCB_SHCSR_USGFAULTENA_Msk          (1ul << SCB_SHCSR_USGFAULTENA_Pos)             
00284 #define SCB_SHCSR_BUSFAULTENA_Pos          17                                             
00285 #define SCB_SHCSR_BUSFAULTENA_Msk          (1ul << SCB_SHCSR_BUSFAULTENA_Pos)             
00287 #define SCB_SHCSR_MEMFAULTENA_Pos          16                                             
00288 #define SCB_SHCSR_MEMFAULTENA_Msk          (1ul << SCB_SHCSR_MEMFAULTENA_Pos)             
00290 #define SCB_SHCSR_SVCALLPENDED_Pos         15                                             
00291 #define SCB_SHCSR_SVCALLPENDED_Msk         (1ul << SCB_SHCSR_SVCALLPENDED_Pos)            
00293 #define SCB_SHCSR_BUSFAULTPENDED_Pos       14                                             
00294 #define SCB_SHCSR_BUSFAULTPENDED_Msk       (1ul << SCB_SHCSR_BUSFAULTPENDED_Pos)          
00296 #define SCB_SHCSR_MEMFAULTPENDED_Pos       13                                             
00297 #define SCB_SHCSR_MEMFAULTPENDED_Msk       (1ul << SCB_SHCSR_MEMFAULTPENDED_Pos)          
00299 #define SCB_SHCSR_USGFAULTPENDED_Pos       12                                             
00300 #define SCB_SHCSR_USGFAULTPENDED_Msk       (1ul << SCB_SHCSR_USGFAULTPENDED_Pos)          
00302 #define SCB_SHCSR_SYSTICKACT_Pos           11                                             
00303 #define SCB_SHCSR_SYSTICKACT_Msk           (1ul << SCB_SHCSR_SYSTICKACT_Pos)              
00305 #define SCB_SHCSR_PENDSVACT_Pos            10                                             
00306 #define SCB_SHCSR_PENDSVACT_Msk            (1ul << SCB_SHCSR_PENDSVACT_Pos)               
00308 #define SCB_SHCSR_MONITORACT_Pos            8                                             
00309 #define SCB_SHCSR_MONITORACT_Msk           (1ul << SCB_SHCSR_MONITORACT_Pos)              
00311 #define SCB_SHCSR_SVCALLACT_Pos             7                                             
00312 #define SCB_SHCSR_SVCALLACT_Msk            (1ul << SCB_SHCSR_SVCALLACT_Pos)               
00314 #define SCB_SHCSR_USGFAULTACT_Pos           3                                             
00315 #define SCB_SHCSR_USGFAULTACT_Msk          (1ul << SCB_SHCSR_USGFAULTACT_Pos)             
00317 #define SCB_SHCSR_BUSFAULTACT_Pos           1                                             
00318 #define SCB_SHCSR_BUSFAULTACT_Msk          (1ul << SCB_SHCSR_BUSFAULTACT_Pos)             
00320 #define SCB_SHCSR_MEMFAULTACT_Pos           0                                             
00321 #define SCB_SHCSR_MEMFAULTACT_Msk          (1ul << SCB_SHCSR_MEMFAULTACT_Pos)             
00323 /* SCB Configurable Fault Status Registers Definitions */
00324 #define SCB_CFSR_USGFAULTSR_Pos            16                                             
00325 #define SCB_CFSR_USGFAULTSR_Msk            (0xFFFFul << SCB_CFSR_USGFAULTSR_Pos)          
00327 #define SCB_CFSR_BUSFAULTSR_Pos             8                                             
00328 #define SCB_CFSR_BUSFAULTSR_Msk            (0xFFul << SCB_CFSR_BUSFAULTSR_Pos)            
00330 #define SCB_CFSR_MEMFAULTSR_Pos             0                                             
00331 #define SCB_CFSR_MEMFAULTSR_Msk            (0xFFul << SCB_CFSR_MEMFAULTSR_Pos)            
00333 /* SCB Hard Fault Status Registers Definitions */
00334 #define SCB_HFSR_DEBUGEVT_Pos              31                                             
00335 #define SCB_HFSR_DEBUGEVT_Msk              (1ul << SCB_HFSR_DEBUGEVT_Pos)                 
00337 #define SCB_HFSR_FORCED_Pos                30                                             
00338 #define SCB_HFSR_FORCED_Msk                (1ul << SCB_HFSR_FORCED_Pos)                   
00340 #define SCB_HFSR_VECTTBL_Pos                1                                             
00341 #define SCB_HFSR_VECTTBL_Msk               (1ul << SCB_HFSR_VECTTBL_Pos)                  
00343 /* SCB Debug Fault Status Register Definitions */
00344 #define SCB_DFSR_EXTERNAL_Pos               4                                             
00345 #define SCB_DFSR_EXTERNAL_Msk              (1ul << SCB_DFSR_EXTERNAL_Pos)                 
00347 #define SCB_DFSR_VCATCH_Pos                 3                                             
00348 #define SCB_DFSR_VCATCH_Msk                (1ul << SCB_DFSR_VCATCH_Pos)                   
00350 #define SCB_DFSR_DWTTRAP_Pos                2                                             
00351 #define SCB_DFSR_DWTTRAP_Msk               (1ul << SCB_DFSR_DWTTRAP_Pos)                  
00353 #define SCB_DFSR_BKPT_Pos                   1                                             
00354 #define SCB_DFSR_BKPT_Msk                  (1ul << SCB_DFSR_BKPT_Pos)                     
00356 #define SCB_DFSR_HALTED_Pos                 0                                             
00357 #define SCB_DFSR_HALTED_Msk                (1ul << SCB_DFSR_HALTED_Pos)                   
00358  /* end of group CMSIS_CM3_SCB */
00359 
00360 
00365 typedef struct
00366 {
00367   __IO uint32_t CTRL;                         
00368   __IO uint32_t LOAD;                         
00369   __IO uint32_t VAL;                          
00370   __I  uint32_t CALIB;                        
00371 } SysTick_Type;
00372 
00373 /* SysTick Control / Status Register Definitions */
00374 #define SysTick_CTRL_COUNTFLAG_Pos         16                                             
00375 #define SysTick_CTRL_COUNTFLAG_Msk         (1ul << SysTick_CTRL_COUNTFLAG_Pos)            
00377 #define SysTick_CTRL_CLKSOURCE_Pos          2                                             
00378 #define SysTick_CTRL_CLKSOURCE_Msk         (1ul << SysTick_CTRL_CLKSOURCE_Pos)            
00380 #define SysTick_CTRL_TICKINT_Pos            1                                             
00381 #define SysTick_CTRL_TICKINT_Msk           (1ul << SysTick_CTRL_TICKINT_Pos)              
00383 #define SysTick_CTRL_ENABLE_Pos             0                                             
00384 #define SysTick_CTRL_ENABLE_Msk            (1ul << SysTick_CTRL_ENABLE_Pos)               
00386 /* SysTick Reload Register Definitions */
00387 #define SysTick_LOAD_RELOAD_Pos             0                                             
00388 #define SysTick_LOAD_RELOAD_Msk            (0xFFFFFFul << SysTick_LOAD_RELOAD_Pos)        
00390 /* SysTick Current Register Definitions */
00391 #define SysTick_VAL_CURRENT_Pos             0                                             
00392 #define SysTick_VAL_CURRENT_Msk            (0xFFFFFFul << SysTick_VAL_CURRENT_Pos)        
00394 /* SysTick Calibration Register Definitions */
00395 #define SysTick_CALIB_NOREF_Pos            31                                             
00396 #define SysTick_CALIB_NOREF_Msk            (1ul << SysTick_CALIB_NOREF_Pos)               
00398 #define SysTick_CALIB_SKEW_Pos             30                                             
00399 #define SysTick_CALIB_SKEW_Msk             (1ul << SysTick_CALIB_SKEW_Pos)                
00401 #define SysTick_CALIB_TENMS_Pos             0                                             
00402 #define SysTick_CALIB_TENMS_Msk            (0xFFFFFFul << SysTick_VAL_CURRENT_Pos)        
00403  /* end of group CMSIS_CM3_SysTick */
00404 
00405 
00410 typedef struct
00411 {
00412   __O  union  
00413   {
00414     __O  uint8_t    u8;                       
00415     __O  uint16_t   u16;                      
00416     __O  uint32_t   u32;                      
00417   }  PORT [32];                               
00418        uint32_t RESERVED0[864];                                 
00419   __IO uint32_t TER;                          
00420        uint32_t RESERVED1[15];                                  
00421   __IO uint32_t TPR;                          
00422        uint32_t RESERVED2[15];                                  
00423   __IO uint32_t TCR;                          
00424        uint32_t RESERVED3[29];                                  
00425   __IO uint32_t IWR;                          
00426   __IO uint32_t IRR;                          
00427   __IO uint32_t IMCR;                         
00428        uint32_t RESERVED4[43];                                  
00429   __IO uint32_t LAR;                          
00430   __IO uint32_t LSR;                          
00431        uint32_t RESERVED5[6];                                   
00432   __I  uint32_t PID4;                         
00433   __I  uint32_t PID5;                         
00434   __I  uint32_t PID6;                         
00435   __I  uint32_t PID7;                         
00436   __I  uint32_t PID0;                         
00437   __I  uint32_t PID1;                         
00438   __I  uint32_t PID2;                         
00439   __I  uint32_t PID3;                         
00440   __I  uint32_t CID0;                         
00441   __I  uint32_t CID1;                         
00442   __I  uint32_t CID2;                         
00443   __I  uint32_t CID3;                         
00444 } ITM_Type;                                                
00445 
00446 /* ITM Trace Privilege Register Definitions */
00447 #define ITM_TPR_PRIVMASK_Pos                0                                             
00448 #define ITM_TPR_PRIVMASK_Msk               (0xFul << ITM_TPR_PRIVMASK_Pos)                
00450 /* ITM Trace Control Register Definitions */
00451 #define ITM_TCR_BUSY_Pos                   23                                             
00452 #define ITM_TCR_BUSY_Msk                   (1ul << ITM_TCR_BUSY_Pos)                      
00454 #define ITM_TCR_ATBID_Pos                  16                                             
00455 #define ITM_TCR_ATBID_Msk                  (0x7Ful << ITM_TCR_ATBID_Pos)                  
00457 #define ITM_TCR_TSPrescale_Pos              8                                             
00458 #define ITM_TCR_TSPrescale_Msk             (3ul << ITM_TCR_TSPrescale_Pos)                
00460 #define ITM_TCR_SWOENA_Pos                  4                                             
00461 #define ITM_TCR_SWOENA_Msk                 (1ul << ITM_TCR_SWOENA_Pos)                    
00463 #define ITM_TCR_DWTENA_Pos                  3                                             
00464 #define ITM_TCR_DWTENA_Msk                 (1ul << ITM_TCR_DWTENA_Pos)                    
00466 #define ITM_TCR_SYNCENA_Pos                 2                                             
00467 #define ITM_TCR_SYNCENA_Msk                (1ul << ITM_TCR_SYNCENA_Pos)                   
00469 #define ITM_TCR_TSENA_Pos                   1                                             
00470 #define ITM_TCR_TSENA_Msk                  (1ul << ITM_TCR_TSENA_Pos)                     
00472 #define ITM_TCR_ITMENA_Pos                  0                                             
00473 #define ITM_TCR_ITMENA_Msk                 (1ul << ITM_TCR_ITMENA_Pos)                    
00475 /* ITM Integration Write Register Definitions */
00476 #define ITM_IWR_ATVALIDM_Pos                0                                             
00477 #define ITM_IWR_ATVALIDM_Msk               (1ul << ITM_IWR_ATVALIDM_Pos)                  
00479 /* ITM Integration Read Register Definitions */
00480 #define ITM_IRR_ATREADYM_Pos                0                                             
00481 #define ITM_IRR_ATREADYM_Msk               (1ul << ITM_IRR_ATREADYM_Pos)                  
00483 /* ITM Integration Mode Control Register Definitions */
00484 #define ITM_IMCR_INTEGRATION_Pos            0                                             
00485 #define ITM_IMCR_INTEGRATION_Msk           (1ul << ITM_IMCR_INTEGRATION_Pos)              
00487 /* ITM Lock Status Register Definitions */
00488 #define ITM_LSR_ByteAcc_Pos                 2                                             
00489 #define ITM_LSR_ByteAcc_Msk                (1ul << ITM_LSR_ByteAcc_Pos)                   
00491 #define ITM_LSR_Access_Pos                  1                                             
00492 #define ITM_LSR_Access_Msk                 (1ul << ITM_LSR_Access_Pos)                    
00494 #define ITM_LSR_Present_Pos                 0                                             
00495 #define ITM_LSR_Present_Msk                (1ul << ITM_LSR_Present_Pos)                   
00496  /* end of group CMSIS_CM3_ITM */
00497 
00498 
00503 typedef struct
00504 {
00505        uint32_t RESERVED0;
00506   __I  uint32_t ICTR;                         
00507 #if ((defined __CM3_REV) && (__CM3_REV >= 0x200))
00508   __IO uint32_t ACTLR;                        
00509 #else
00510        uint32_t RESERVED1;
00511 #endif
00512 } InterruptType_Type;
00513 
00514 /* Interrupt Controller Type Register Definitions */
00515 #define InterruptType_ICTR_INTLINESNUM_Pos  0                                             
00516 #define InterruptType_ICTR_INTLINESNUM_Msk (0x1Ful << InterruptType_ICTR_INTLINESNUM_Pos) 
00518 /* Auxiliary Control Register Definitions */
00519 #define InterruptType_ACTLR_DISFOLD_Pos     2                                             
00520 #define InterruptType_ACTLR_DISFOLD_Msk    (1ul << InterruptType_ACTLR_DISFOLD_Pos)       
00522 #define InterruptType_ACTLR_DISDEFWBUF_Pos  1                                             
00523 #define InterruptType_ACTLR_DISDEFWBUF_Msk (1ul << InterruptType_ACTLR_DISDEFWBUF_Pos)    
00525 #define InterruptType_ACTLR_DISMCYCINT_Pos  0                                             
00526 #define InterruptType_ACTLR_DISMCYCINT_Msk (1ul << InterruptType_ACTLR_DISMCYCINT_Pos)    
00527  /* end of group CMSIS_CM3_InterruptType */
00528 
00529 
00530 #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1)
00531 
00535 typedef struct
00536 {
00537   __I  uint32_t TYPE;                         
00538   __IO uint32_t CTRL;                         
00539   __IO uint32_t RNR;                          
00540   __IO uint32_t RBAR;                         
00541   __IO uint32_t RASR;                         
00542   __IO uint32_t RBAR_A1;                      
00543   __IO uint32_t RASR_A1;                      
00544   __IO uint32_t RBAR_A2;                      
00545   __IO uint32_t RASR_A2;                      
00546   __IO uint32_t RBAR_A3;                      
00547   __IO uint32_t RASR_A3;                      
00548 } MPU_Type;                                                
00549 
00550 /* MPU Type Register */
00551 #define MPU_TYPE_IREGION_Pos               16                                             
00552 #define MPU_TYPE_IREGION_Msk               (0xFFul << MPU_TYPE_IREGION_Pos)               
00554 #define MPU_TYPE_DREGION_Pos                8                                             
00555 #define MPU_TYPE_DREGION_Msk               (0xFFul << MPU_TYPE_DREGION_Pos)               
00557 #define MPU_TYPE_SEPARATE_Pos               0                                             
00558 #define MPU_TYPE_SEPARATE_Msk              (1ul << MPU_TYPE_SEPARATE_Pos)                 
00560 /* MPU Control Register */
00561 #define MPU_CTRL_PRIVDEFENA_Pos             2                                             
00562 #define MPU_CTRL_PRIVDEFENA_Msk            (1ul << MPU_CTRL_PRIVDEFENA_Pos)               
00564 #define MPU_CTRL_HFNMIENA_Pos               1                                             
00565 #define MPU_CTRL_HFNMIENA_Msk              (1ul << MPU_CTRL_HFNMIENA_Pos)                 
00567 #define MPU_CTRL_ENABLE_Pos                 0                                             
00568 #define MPU_CTRL_ENABLE_Msk                (1ul << MPU_CTRL_ENABLE_Pos)                   
00570 /* MPU Region Number Register */
00571 #define MPU_RNR_REGION_Pos                  0                                             
00572 #define MPU_RNR_REGION_Msk                 (0xFFul << MPU_RNR_REGION_Pos)                 
00574 /* MPU Region Base Address Register */
00575 #define MPU_RBAR_ADDR_Pos                   5                                             
00576 #define MPU_RBAR_ADDR_Msk                  (0x7FFFFFFul << MPU_RBAR_ADDR_Pos)             
00578 #define MPU_RBAR_VALID_Pos                  4                                             
00579 #define MPU_RBAR_VALID_Msk                 (1ul << MPU_RBAR_VALID_Pos)                    
00581 #define MPU_RBAR_REGION_Pos                 0                                             
00582 #define MPU_RBAR_REGION_Msk                (0xFul << MPU_RBAR_REGION_Pos)                 
00584 /* MPU Region Attribute and Size Register */
00585 #define MPU_RASR_XN_Pos                    28                                             
00586 #define MPU_RASR_XN_Msk                    (1ul << MPU_RASR_XN_Pos)                       
00588 #define MPU_RASR_AP_Pos                    24                                             
00589 #define MPU_RASR_AP_Msk                    (7ul << MPU_RASR_AP_Pos)                       
00591 #define MPU_RASR_TEX_Pos                   19                                             
00592 #define MPU_RASR_TEX_Msk                   (7ul << MPU_RASR_TEX_Pos)                      
00594 #define MPU_RASR_S_Pos                     18                                             
00595 #define MPU_RASR_S_Msk                     (1ul << MPU_RASR_S_Pos)                        
00597 #define MPU_RASR_C_Pos                     17                                             
00598 #define MPU_RASR_C_Msk                     (1ul << MPU_RASR_C_Pos)                        
00600 #define MPU_RASR_B_Pos                     16                                             
00601 #define MPU_RASR_B_Msk                     (1ul << MPU_RASR_B_Pos)                        
00603 #define MPU_RASR_SRD_Pos                    8                                             
00604 #define MPU_RASR_SRD_Msk                   (0xFFul << MPU_RASR_SRD_Pos)                   
00606 #define MPU_RASR_SIZE_Pos                   1                                             
00607 #define MPU_RASR_SIZE_Msk                  (0x1Ful << MPU_RASR_SIZE_Pos)                  
00609 #define MPU_RASR_ENA_Pos                     0                                            
00610 #define MPU_RASR_ENA_Msk                    (0x1Ful << MPU_RASR_ENA_Pos)                  
00612  /* end of group CMSIS_CM3_MPU */
00613 #endif
00614 
00615 
00620 typedef struct
00621 {
00622   __IO uint32_t DHCSR;                        
00623   __O  uint32_t DCRSR;                        
00624   __IO uint32_t DCRDR;                        
00625   __IO uint32_t DEMCR;                        
00626 } CoreDebug_Type;
00627 
00628 /* Debug Halting Control and Status Register */
00629 #define CoreDebug_DHCSR_DBGKEY_Pos         16                                             
00630 #define CoreDebug_DHCSR_DBGKEY_Msk         (0xFFFFul << CoreDebug_DHCSR_DBGKEY_Pos)       
00632 #define CoreDebug_DHCSR_S_RESET_ST_Pos     25                                             
00633 #define CoreDebug_DHCSR_S_RESET_ST_Msk     (1ul << CoreDebug_DHCSR_S_RESET_ST_Pos)        
00635 #define CoreDebug_DHCSR_S_RETIRE_ST_Pos    24                                             
00636 #define CoreDebug_DHCSR_S_RETIRE_ST_Msk    (1ul << CoreDebug_DHCSR_S_RETIRE_ST_Pos)       
00638 #define CoreDebug_DHCSR_S_LOCKUP_Pos       19                                             
00639 #define CoreDebug_DHCSR_S_LOCKUP_Msk       (1ul << CoreDebug_DHCSR_S_LOCKUP_Pos)          
00641 #define CoreDebug_DHCSR_S_SLEEP_Pos        18                                             
00642 #define CoreDebug_DHCSR_S_SLEEP_Msk        (1ul << CoreDebug_DHCSR_S_SLEEP_Pos)           
00644 #define CoreDebug_DHCSR_S_HALT_Pos         17                                             
00645 #define CoreDebug_DHCSR_S_HALT_Msk         (1ul << CoreDebug_DHCSR_S_HALT_Pos)            
00647 #define CoreDebug_DHCSR_S_REGRDY_Pos       16                                             
00648 #define CoreDebug_DHCSR_S_REGRDY_Msk       (1ul << CoreDebug_DHCSR_S_REGRDY_Pos)          
00650 #define CoreDebug_DHCSR_C_SNAPSTALL_Pos     5                                             
00651 #define CoreDebug_DHCSR_C_SNAPSTALL_Msk    (1ul << CoreDebug_DHCSR_C_SNAPSTALL_Pos)       
00653 #define CoreDebug_DHCSR_C_MASKINTS_Pos      3                                             
00654 #define CoreDebug_DHCSR_C_MASKINTS_Msk     (1ul << CoreDebug_DHCSR_C_MASKINTS_Pos)        
00656 #define CoreDebug_DHCSR_C_STEP_Pos          2                                             
00657 #define CoreDebug_DHCSR_C_STEP_Msk         (1ul << CoreDebug_DHCSR_C_STEP_Pos)            
00659 #define CoreDebug_DHCSR_C_HALT_Pos          1                                             
00660 #define CoreDebug_DHCSR_C_HALT_Msk         (1ul << CoreDebug_DHCSR_C_HALT_Pos)            
00662 #define CoreDebug_DHCSR_C_DEBUGEN_Pos       0                                             
00663 #define CoreDebug_DHCSR_C_DEBUGEN_Msk      (1ul << CoreDebug_DHCSR_C_DEBUGEN_Pos)         
00665 /* Debug Core Register Selector Register */
00666 #define CoreDebug_DCRSR_REGWnR_Pos         16                                             
00667 #define CoreDebug_DCRSR_REGWnR_Msk         (1ul << CoreDebug_DCRSR_REGWnR_Pos)            
00669 #define CoreDebug_DCRSR_REGSEL_Pos          0                                             
00670 #define CoreDebug_DCRSR_REGSEL_Msk         (0x1Ful << CoreDebug_DCRSR_REGSEL_Pos)         
00672 /* Debug Exception and Monitor Control Register */
00673 #define CoreDebug_DEMCR_TRCENA_Pos         24                                             
00674 #define CoreDebug_DEMCR_TRCENA_Msk         (1ul << CoreDebug_DEMCR_TRCENA_Pos)            
00676 #define CoreDebug_DEMCR_MON_REQ_Pos        19                                             
00677 #define CoreDebug_DEMCR_MON_REQ_Msk        (1ul << CoreDebug_DEMCR_MON_REQ_Pos)           
00679 #define CoreDebug_DEMCR_MON_STEP_Pos       18                                             
00680 #define CoreDebug_DEMCR_MON_STEP_Msk       (1ul << CoreDebug_DEMCR_MON_STEP_Pos)          
00682 #define CoreDebug_DEMCR_MON_PEND_Pos       17                                             
00683 #define CoreDebug_DEMCR_MON_PEND_Msk       (1ul << CoreDebug_DEMCR_MON_PEND_Pos)          
00685 #define CoreDebug_DEMCR_MON_EN_Pos         16                                             
00686 #define CoreDebug_DEMCR_MON_EN_Msk         (1ul << CoreDebug_DEMCR_MON_EN_Pos)            
00688 #define CoreDebug_DEMCR_VC_HARDERR_Pos     10                                             
00689 #define CoreDebug_DEMCR_VC_HARDERR_Msk     (1ul << CoreDebug_DEMCR_VC_HARDERR_Pos)        
00691 #define CoreDebug_DEMCR_VC_INTERR_Pos       9                                             
00692 #define CoreDebug_DEMCR_VC_INTERR_Msk      (1ul << CoreDebug_DEMCR_VC_INTERR_Pos)         
00694 #define CoreDebug_DEMCR_VC_BUSERR_Pos       8                                             
00695 #define CoreDebug_DEMCR_VC_BUSERR_Msk      (1ul << CoreDebug_DEMCR_VC_BUSERR_Pos)         
00697 #define CoreDebug_DEMCR_VC_STATERR_Pos      7                                             
00698 #define CoreDebug_DEMCR_VC_STATERR_Msk     (1ul << CoreDebug_DEMCR_VC_STATERR_Pos)        
00700 #define CoreDebug_DEMCR_VC_CHKERR_Pos       6                                             
00701 #define CoreDebug_DEMCR_VC_CHKERR_Msk      (1ul << CoreDebug_DEMCR_VC_CHKERR_Pos)         
00703 #define CoreDebug_DEMCR_VC_NOCPERR_Pos      5                                             
00704 #define CoreDebug_DEMCR_VC_NOCPERR_Msk     (1ul << CoreDebug_DEMCR_VC_NOCPERR_Pos)        
00706 #define CoreDebug_DEMCR_VC_MMERR_Pos        4                                             
00707 #define CoreDebug_DEMCR_VC_MMERR_Msk       (1ul << CoreDebug_DEMCR_VC_MMERR_Pos)          
00709 #define CoreDebug_DEMCR_VC_CORERESET_Pos    0                                             
00710 #define CoreDebug_DEMCR_VC_CORERESET_Msk   (1ul << CoreDebug_DEMCR_VC_CORERESET_Pos)      
00711  /* end of group CMSIS_CM3_CoreDebug */
00712 
00713 
00714 /* Memory mapping of Cortex-M3 Hardware */
00715 #define SCS_BASE            (0xE000E000)                              
00716 #define ITM_BASE            (0xE0000000)                              
00717 #define CoreDebug_BASE      (0xE000EDF0)                              
00718 #define SysTick_BASE        (SCS_BASE +  0x0010)                      
00719 #define NVIC_BASE           (SCS_BASE +  0x0100)                      
00720 #define SCB_BASE            (SCS_BASE +  0x0D00)                      
00722 #define InterruptType       ((InterruptType_Type *) SCS_BASE)         
00723 #define SCB                 ((SCB_Type *)           SCB_BASE)         
00724 #define SysTick             ((SysTick_Type *)       SysTick_BASE)     
00725 #define NVIC                ((NVIC_Type *)          NVIC_BASE)        
00726 #define ITM                 ((ITM_Type *)           ITM_BASE)         
00727 #define CoreDebug           ((CoreDebug_Type *)     CoreDebug_BASE)   
00729 #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1)
00730   #define MPU_BASE          (SCS_BASE +  0x0D90)                      
00731   #define MPU               ((MPU_Type*)            MPU_BASE)         
00732 #endif
00733  /* end of group CMSIS_CM3_core_register */
00735 
00736 
00737 /*******************************************************************************
00738  *                Hardware Abstraction Layer
00739  ******************************************************************************/
00740 
00741 #if defined ( __CC_ARM   )
00742   #define __ASM            __asm                                      
00743   #define __INLINE         __inline                                   
00745 #elif defined ( __ICCARM__ )
00746   #define __ASM           __asm                                       
00747   #define __INLINE        inline                                      
00749 #elif defined   (  __GNUC__  )
00750   #define __ASM            __asm                                      
00751   #define __INLINE         inline                                     
00753 #elif defined   (  __TASKING__  )
00754   #define __ASM            __asm                                      
00755   #define __INLINE         inline                                     
00757 #endif
00758 
00759 
00760 /* ###################  Compiler specific Intrinsics  ########################### */
00761 
00762 #if defined ( __CC_ARM   ) /*------------------RealView Compiler -----------------*/
00763 /* ARM armcc specific functions */
00764 
00765 #define __enable_fault_irq                __enable_fiq
00766 #define __disable_fault_irq               __disable_fiq
00767 
00768 #define __NOP                             __nop
00769 #define __WFI                             __wfi
00770 #define __WFE                             __wfe
00771 #define __SEV                             __sev
00772 #define __ISB()                           __isb(0)
00773 #define __DSB()                           __dsb(0)
00774 #define __DMB()                           __dmb(0)
00775 #define __REV                             __rev
00776 #define __RBIT                            __rbit
00777 #define __LDREXB(ptr)                     ((unsigned char ) __ldrex(ptr))
00778 #define __LDREXH(ptr)                     ((unsigned short) __ldrex(ptr))
00779 #define __LDREXW(ptr)                     ((unsigned int  ) __ldrex(ptr))
00780 #define __STREXB(value, ptr)              __strex(value, ptr)
00781 #define __STREXH(value, ptr)              __strex(value, ptr)
00782 #define __STREXW(value, ptr)              __strex(value, ptr)
00783 
00784 
00785 /* intrinsic unsigned long long __ldrexd(volatile void *ptr) */
00786 /* intrinsic int __strexd(unsigned long long val, volatile void *ptr) */
00787 /* intrinsic void __enable_irq();     */
00788 /* intrinsic void __disable_irq();    */
00789 
00790 
00798 extern uint32_t __get_PSP(void);
00799 
00808 extern void __set_PSP(uint32_t topOfProcStack);
00809 
00818 extern uint32_t __get_MSP(void);
00819 
00828 extern void __set_MSP(uint32_t topOfMainStack);
00829 
00838 extern uint32_t __REV16(uint16_t value);
00839 
00848 extern int32_t __REVSH(int16_t value);
00849 
00850 
00851 #if (__ARMCC_VERSION < 400000)
00852 
00858 extern void __CLREX(void);
00859 
00867 extern uint32_t __get_BASEPRI(void);
00868 
00876 extern void __set_BASEPRI(uint32_t basePri);
00877 
00885 extern uint32_t __get_PRIMASK(void);
00886 
00894 extern void __set_PRIMASK(uint32_t priMask);
00895 
00903 extern uint32_t __get_FAULTMASK(void);
00904 
00912 extern void __set_FAULTMASK(uint32_t faultMask);
00913 
00921 extern uint32_t __get_CONTROL(void);
00922 
00930 extern void __set_CONTROL(uint32_t control);
00931 
00932 #else  /* (__ARMCC_VERSION >= 400000)  */
00933 
00939 #define __CLREX                           __clrex
00940 
00948 static __INLINE uint32_t  __get_BASEPRI(void)
00949 {
00950   register uint32_t __regBasePri         __ASM("basepri");
00951   return(__regBasePri);
00952 }
00953 
00961 static __INLINE void __set_BASEPRI(uint32_t basePri)
00962 {
00963   register uint32_t __regBasePri         __ASM("basepri");
00964   __regBasePri = (basePri & 0xff);
00965 }
00966 
00974 static __INLINE uint32_t __get_PRIMASK(void)
00975 {
00976   register uint32_t __regPriMask         __ASM("primask");
00977   return(__regPriMask);
00978 }
00979 
00987 static __INLINE void __set_PRIMASK(uint32_t priMask)
00988 {
00989   register uint32_t __regPriMask         __ASM("primask");
00990   __regPriMask = (priMask);
00991 }
00992 
01000 static __INLINE uint32_t __get_FAULTMASK(void)
01001 {
01002   register uint32_t __regFaultMask       __ASM("faultmask");
01003   return(__regFaultMask);
01004 }
01005 
01013 static __INLINE void __set_FAULTMASK(uint32_t faultMask)
01014 {
01015   register uint32_t __regFaultMask       __ASM("faultmask");
01016   __regFaultMask = (faultMask & 1);
01017 }
01018 
01026 static __INLINE uint32_t __get_CONTROL(void)
01027 {
01028   register uint32_t __regControl         __ASM("control");
01029   return(__regControl);
01030 }
01031 
01039 static __INLINE void __set_CONTROL(uint32_t control)
01040 {
01041   register uint32_t __regControl         __ASM("control");
01042   __regControl = control;
01043 }
01044 
01045 #endif /* __ARMCC_VERSION  */ 
01046 
01047 
01048 
01049 #elif (defined (__ICCARM__)) /*------------------ ICC Compiler -------------------*/
01050 /* IAR iccarm specific functions */
01051 
01052 #define __enable_irq                              __enable_interrupt        
01053 #define __disable_irq                             __disable_interrupt       
01055 static __INLINE void __enable_fault_irq()         { __ASM ("cpsie f"); }
01056 static __INLINE void __disable_fault_irq()        { __ASM ("cpsid f"); }
01057 
01058 #define __NOP                                     __no_operation            
01059 static __INLINE  void __WFI()                     { __ASM ("wfi"); }
01060 static __INLINE  void __WFE()                     { __ASM ("wfe"); }
01061 static __INLINE  void __SEV()                     { __ASM ("sev"); }
01062 static __INLINE  void __CLREX()                   { __ASM ("clrex"); }
01063 
01064 /* intrinsic void __ISB(void)                                     */
01065 /* intrinsic void __DSB(void)                                     */
01066 /* intrinsic void __DMB(void)                                     */
01067 /* intrinsic void __set_PRIMASK();                                */
01068 /* intrinsic void __get_PRIMASK();                                */
01069 /* intrinsic void __set_FAULTMASK();                              */
01070 /* intrinsic void __get_FAULTMASK();                              */
01071 /* intrinsic uint32_t __REV(uint32_t value);                      */
01072 /* intrinsic uint32_t __REVSH(uint32_t value);                    */
01073 /* intrinsic unsigned long __STREX(unsigned long, unsigned long); */
01074 /* intrinsic unsigned long __LDREX(unsigned long *);              */
01075 
01076 
01084 extern uint32_t __get_PSP(void);
01085 
01094 extern void __set_PSP(uint32_t topOfProcStack);
01095 
01104 extern uint32_t __get_MSP(void);
01105 
01114 extern void __set_MSP(uint32_t topOfMainStack);
01115 
01124 extern uint32_t __REV16(uint16_t value);
01125 
01134 extern uint32_t __RBIT(uint32_t value);
01135 
01144 extern uint8_t __LDREXB(uint8_t *addr);
01145 
01154 extern uint16_t __LDREXH(uint16_t *addr);
01155 
01164 extern uint32_t __LDREXW(uint32_t *addr);
01165 
01175 extern uint32_t __STREXB(uint8_t value, uint8_t *addr);
01176 
01186 extern uint32_t __STREXH(uint16_t value, uint16_t *addr);
01187 
01197 extern uint32_t __STREXW(uint32_t value, uint32_t *addr);
01198 
01199 
01200 
01201 #elif (defined (__GNUC__)) /*------------------ GNU Compiler ---------------------*/
01202 /* GNU gcc specific functions */
01203 
01204 static __INLINE void __enable_irq()               { __ASM volatile ("cpsie i"); }
01205 static __INLINE void __disable_irq()              { __ASM volatile ("cpsid i"); }
01206 
01207 static __INLINE void __enable_fault_irq()         { __ASM volatile ("cpsie f"); }
01208 static __INLINE void __disable_fault_irq()        { __ASM volatile ("cpsid f"); }
01209 
01210 static __INLINE void __NOP()                      { __ASM volatile ("nop"); }
01211 static __INLINE void __WFI()                      { __ASM volatile ("wfi"); }
01212 static __INLINE void __WFE()                      { __ASM volatile ("wfe"); }
01213 static __INLINE void __SEV()                      { __ASM volatile ("sev"); }
01214 static __INLINE void __ISB()                      { __ASM volatile ("isb"); }
01215 static __INLINE void __DSB()                      { __ASM volatile ("dsb"); }
01216 static __INLINE void __DMB()                      { __ASM volatile ("dmb"); }
01217 static __INLINE void __CLREX()                    { __ASM volatile ("clrex"); }
01218 
01219 
01227 extern uint32_t __get_PSP(void);
01228 
01237 extern void __set_PSP(uint32_t topOfProcStack);
01238 
01247 extern uint32_t __get_MSP(void);
01248 
01257 extern void __set_MSP(uint32_t topOfMainStack);
01258 
01266 extern uint32_t __get_BASEPRI(void);
01267 
01275 extern void __set_BASEPRI(uint32_t basePri);
01276 
01284 extern uint32_t  __get_PRIMASK(void);
01285 
01293 extern void __set_PRIMASK(uint32_t priMask);
01294 
01302 extern uint32_t __get_FAULTMASK(void);
01303 
01311 extern void __set_FAULTMASK(uint32_t faultMask);
01312 
01320 extern uint32_t __get_CONTROL(void);
01321 
01329 extern void __set_CONTROL(uint32_t control);
01330 
01339 extern uint32_t __REV(uint32_t value);
01340 
01349 extern uint32_t __REV16(uint16_t value);
01350 
01359 extern int32_t __REVSH(int16_t value);
01360 
01369 extern uint32_t __RBIT(uint32_t value);
01370 
01379 extern uint8_t __LDREXB(uint8_t *addr);
01380 
01389 extern uint16_t __LDREXH(uint16_t *addr);
01390 
01399 extern uint32_t __LDREXW(uint32_t *addr);
01400 
01410 extern uint32_t __STREXB(uint8_t value, uint8_t *addr);
01411 
01421 extern uint32_t __STREXH(uint16_t value, uint16_t *addr);
01422 
01432 extern uint32_t __STREXW(uint32_t value, uint32_t *addr);
01433 
01434 
01435 #elif (defined (__TASKING__)) /*------------------ TASKING Compiler ---------------------*/
01436 /* TASKING carm specific functions */
01437 
01438 /*
01439  * The CMSIS functions have been implemented as intrinsics in the compiler.
01440  * Please use "carm -?i" to get an up to date list of all instrinsics,
01441  * Including the CMSIS ones.
01442  */
01443 
01444 #endif
01445 
01446 
01454 
01455 /* ##########################   NVIC functions  #################################### */
01456 
01468 static __INLINE void NVIC_SetPriorityGrouping(uint32_t PriorityGroup)
01469 {
01470   uint32_t reg_value;
01471   uint32_t PriorityGroupTmp = (PriorityGroup & 0x07);                         /* only values 0..7 are used          */
01472   
01473   reg_value  =  SCB->AIRCR;                                                   /* read old register configuration    */
01474   reg_value &= ~(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk);             /* clear bits to change               */
01475   reg_value  =  (reg_value                       |
01476                 (0x5FA << SCB_AIRCR_VECTKEY_Pos) | 
01477                 (PriorityGroupTmp << 8));                                     /* Insert write key and priorty group */
01478   SCB->AIRCR =  reg_value;
01479 }
01480 
01489 static __INLINE uint32_t NVIC_GetPriorityGrouping(void)
01490 {
01491   return ((SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos);   /* read priority grouping field */
01492 }
01493 
01502 static __INLINE void NVIC_EnableIRQ(IRQn_Type IRQn)
01503 {
01504   NVIC->ISER[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F)); /* enable interrupt */
01505 }
01506 
01515 static __INLINE void NVIC_DisableIRQ(IRQn_Type IRQn)
01516 {
01517   NVIC->ICER[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F)); /* disable interrupt */
01518 }
01519 
01529 static __INLINE uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn)
01530 {
01531   return((uint32_t) ((NVIC->ISPR[(uint32_t)(IRQn) >> 5] & (1 << ((uint32_t)(IRQn) & 0x1F)))?1:0)); /* Return 1 if pending else 0 */
01532 }
01533 
01542 static __INLINE void NVIC_SetPendingIRQ(IRQn_Type IRQn)
01543 {
01544   NVIC->ISPR[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F)); /* set interrupt pending */
01545 }
01546 
01555 static __INLINE void NVIC_ClearPendingIRQ(IRQn_Type IRQn)
01556 {
01557   NVIC->ICPR[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F)); /* Clear pending interrupt */
01558 }
01559 
01569 static __INLINE uint32_t NVIC_GetActive(IRQn_Type IRQn)
01570 {
01571   return((uint32_t)((NVIC->IABR[(uint32_t)(IRQn) >> 5] & (1 << ((uint32_t)(IRQn) & 0x1F)))?1:0)); /* Return 1 if active else 0 */
01572 }
01573 
01586 static __INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority)
01587 {
01588   if(IRQn < 0) {
01589     SCB->SHP[((uint32_t)(IRQn) & 0xF)-4] = ((priority << (8 - __NVIC_PRIO_BITS)) & 0xff); } /* set Priority for Cortex-M3 System Interrupts */
01590   else {
01591     NVIC->IP[(uint32_t)(IRQn)] = ((priority << (8 - __NVIC_PRIO_BITS)) & 0xff);    }        /* set Priority for device specific Interrupts  */
01592 }
01593 
01609 static __INLINE uint32_t NVIC_GetPriority(IRQn_Type IRQn)
01610 {
01611 
01612   if(IRQn < 0) {
01613     return((uint32_t)(SCB->SHP[((uint32_t)(IRQn) & 0xF)-4] >> (8 - __NVIC_PRIO_BITS)));  } /* get priority for Cortex-M3 system interrupts */
01614   else {
01615     return((uint32_t)(NVIC->IP[(uint32_t)(IRQn)]           >> (8 - __NVIC_PRIO_BITS)));  } /* get priority for device specific interrupts  */
01616 }
01617 
01618 
01634 static __INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority)
01635 {
01636   uint32_t PriorityGroupTmp = (PriorityGroup & 0x07);          /* only values 0..7 are used          */
01637   uint32_t PreemptPriorityBits;
01638   uint32_t SubPriorityBits;
01639 
01640   PreemptPriorityBits = ((7 - PriorityGroupTmp) > __NVIC_PRIO_BITS) ? __NVIC_PRIO_BITS : 7 - PriorityGroupTmp;
01641   SubPriorityBits     = ((PriorityGroupTmp + __NVIC_PRIO_BITS) < 7) ? 0 : PriorityGroupTmp - 7 + __NVIC_PRIO_BITS;
01642  
01643   return (
01644            ((PreemptPriority & ((1 << (PreemptPriorityBits)) - 1)) << SubPriorityBits) |
01645            ((SubPriority     & ((1 << (SubPriorityBits    )) - 1)))
01646          );
01647 }
01648 
01649 
01665 static __INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* pPreemptPriority, uint32_t* pSubPriority)
01666 {
01667   uint32_t PriorityGroupTmp = (PriorityGroup & 0x07);          /* only values 0..7 are used          */
01668   uint32_t PreemptPriorityBits;
01669   uint32_t SubPriorityBits;
01670 
01671   PreemptPriorityBits = ((7 - PriorityGroupTmp) > __NVIC_PRIO_BITS) ? __NVIC_PRIO_BITS : 7 - PriorityGroupTmp;
01672   SubPriorityBits     = ((PriorityGroupTmp + __NVIC_PRIO_BITS) < 7) ? 0 : PriorityGroupTmp - 7 + __NVIC_PRIO_BITS;
01673   
01674   *pPreemptPriority = (Priority >> SubPriorityBits) & ((1 << (PreemptPriorityBits)) - 1);
01675   *pSubPriority     = (Priority                   ) & ((1 << (SubPriorityBits    )) - 1);
01676 }
01677 
01678 
01679 
01680 /* ##################################    SysTick function  ############################################ */
01681 
01682 #if (!defined (__Vendor_SysTickConfig)) || (__Vendor_SysTickConfig == 0)
01683 
01694 static __INLINE uint32_t SysTick_Config(uint32_t ticks)
01695 { 
01696   if (ticks > SysTick_LOAD_RELOAD_Msk)  return (1);            /* Reload value impossible */
01697                                                                
01698   SysTick->LOAD  = (ticks & SysTick_LOAD_RELOAD_Msk) - 1;      /* set reload register */
01699   NVIC_SetPriority (SysTick_IRQn, (1<<__NVIC_PRIO_BITS) - 1);  /* set Priority for Cortex-M0 System Interrupts */
01700   SysTick->VAL   = 0;                                          /* Load the SysTick Counter Value */
01701   SysTick->CTRL  = SysTick_CTRL_CLKSOURCE_Msk | 
01702                    SysTick_CTRL_TICKINT_Msk   | 
01703                    SysTick_CTRL_ENABLE_Msk;                    /* Enable SysTick IRQ and SysTick Timer */
01704   return (0);                                                  /* Function successful */
01705 }
01706 
01707 #endif
01708 
01709 
01710 
01711 
01712 /* ##################################    Reset function  ############################################ */
01713 
01719 static __INLINE void NVIC_SystemReset(void)
01720 {
01721   SCB->AIRCR  = ((0x5FA << SCB_AIRCR_VECTKEY_Pos)      | 
01722                  (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) | 
01723                  SCB_AIRCR_SYSRESETREQ_Msk);                   /* Keep priority group unchanged */
01724   __DSB();                                                     /* Ensure completion of memory access */              
01725   while(1);                                                    /* wait until reset */
01726 }
01727  /* end of group CMSIS_CM3_Core_FunctionInterface */
01729 
01730 
01731 
01732 /* ##################################### Debug In/Output function ########################################### */
01733 
01741 
01742 extern volatile int ITM_RxBuffer;                    
01743 #define             ITM_RXBUFFER_EMPTY    0x5AA55AA5 
01756 static __INLINE uint32_t ITM_SendChar (uint32_t ch)
01757 {
01758   if ((CoreDebug->DEMCR & CoreDebug_DEMCR_TRCENA_Msk)  &&      /* Trace enabled */
01759       (ITM->TCR & ITM_TCR_ITMENA_Msk)                  &&      /* ITM enabled */
01760       (ITM->TER & (1ul << 0)        )                    )     /* ITM Port #0 enabled */
01761   {
01762     while (ITM->PORT[0].u32 == 0);
01763     ITM->PORT[0].u8 = (uint8_t) ch;
01764   }  
01765   return (ch);
01766 }
01767 
01768 
01778 static __INLINE int ITM_ReceiveChar (void) {
01779   int ch = -1;                               /* no character available */
01780 
01781   if (ITM_RxBuffer != ITM_RXBUFFER_EMPTY) {
01782     ch = ITM_RxBuffer;
01783     ITM_RxBuffer = ITM_RXBUFFER_EMPTY;       /* ready for next character */
01784   }
01785   
01786   return (ch); 
01787 }
01788 
01789 
01798 static __INLINE int ITM_CheckChar (void) {
01799 
01800   if (ITM_RxBuffer == ITM_RXBUFFER_EMPTY) {
01801     return (0);                                 /* no character available */
01802   } else {
01803     return (1);                                 /*    character available */
01804   }
01805 }
01806  /* end of group CMSIS_CM3_core_DebugInterface */
01808 
01809 
01810 #ifdef __cplusplus
01811 }
01812 #endif
01813  /* end of group CMSIS_CM3_core_definitions */
01815 
01816 #endif /* __CM3_CORE_H__ */
01817 
01818 /*lint -restore */