core_cm4.h 77 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379
  1. /**************************************************************************//**
  2. * @file core_cm4.h
  3. * @brief CMSIS Cortex-M4 Core Peripheral Access Layer Header File
  4. * @version V2.10
  5. * @date 19. July 2011
  6. *
  7. * @note
  8. * Copyright (C) 2009-2011 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. #if defined ( __ICCARM__ )
  24. #pragma system_include /* treat file as system include file for MISRA check */
  25. #endif
  26. #ifdef __cplusplus
  27. extern "C" {
  28. #endif
  29. #ifndef __CORE_CM4_H_GENERIC
  30. #define __CORE_CM4_H_GENERIC
  31. /** \mainpage CMSIS Cortex-M4
  32. This documentation describes the CMSIS Cortex-M Core Peripheral Access Layer.
  33. It consists of:
  34. - Cortex-M Core Register Definitions
  35. - Cortex-M functions
  36. - Cortex-M instructions
  37. - Cortex-M SIMD instructions
  38. The CMSIS Cortex-M4 Core Peripheral Access Layer contains C and assembly functions that ease
  39. access to the Cortex-M Core
  40. */
  41. /** \defgroup CMSIS_MISRA_Exceptions CMSIS MISRA-C:2004 Compliance Exceptions
  42. CMSIS violates following MISRA-C2004 Rules:
  43. - Violates MISRA 2004 Required Rule 8.5, object/function definition in header file.<br>
  44. Function definitions in header files are used to allow 'inlining'.
  45. - Violates MISRA 2004 Required Rule 18.4, declaration of union type or object of union type: '{...}'.<br>
  46. Unions are used for effective representation of core registers.
  47. - Violates MISRA 2004 Advisory Rule 19.7, Function-like macro defined.<br>
  48. Function-like macros are used to allow more efficient code.
  49. */
  50. /*******************************************************************************
  51. * CMSIS definitions
  52. ******************************************************************************/
  53. /** \defgroup CMSIS_core_definitions CMSIS Core Definitions
  54. This file defines all structures and symbols for CMSIS core:
  55. - CMSIS version number
  56. - Cortex-M core
  57. - Cortex-M core Revision Number
  58. @{
  59. */
  60. /* CMSIS CM4 definitions */
  61. #define __CM4_CMSIS_VERSION_MAIN (0x02) /*!< [31:16] CMSIS HAL main version */
  62. #define __CM4_CMSIS_VERSION_SUB (0x10) /*!< [15:0] CMSIS HAL sub version */
  63. #define __CM4_CMSIS_VERSION ((__CM4_CMSIS_VERSION_MAIN << 16) | __CM4_CMSIS_VERSION_SUB) /*!< CMSIS HAL version number */
  64. #define __CORTEX_M (0x04) /*!< Cortex core */
  65. #if defined ( __CC_ARM )
  66. #define __ASM __asm /*!< asm keyword for ARM Compiler */
  67. #define __INLINE __inline /*!< inline keyword for ARM Compiler */
  68. #elif defined ( __ICCARM__ )
  69. #define __ASM __asm /*!< asm keyword for IAR Compiler */
  70. #define __INLINE inline /*!< inline keyword for IAR Compiler. Only available in High optimization mode! */
  71. #elif defined ( __GNUC__ )
  72. #define __ASM __asm /*!< asm keyword for GNU Compiler */
  73. #define __INLINE inline /*!< inline keyword for GNU Compiler */
  74. #elif defined ( __TASKING__ )
  75. #define __ASM __asm /*!< asm keyword for TASKING Compiler */
  76. #define __INLINE inline /*!< inline keyword for TASKING Compiler */
  77. #endif
  78. /*!< __FPU_USED to be checked prior to making use of FPU specific registers and functions */
  79. #if defined ( __CC_ARM )
  80. #if defined __TARGET_FPU_VFP
  81. #if (__FPU_PRESENT == 1)
  82. #define __FPU_USED 1
  83. #else
  84. #warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
  85. #define __FPU_USED 0
  86. #endif
  87. #else
  88. #define __FPU_USED 0
  89. #endif
  90. #elif defined ( __ICCARM__ )
  91. #if defined __ARMVFP__
  92. #if (__FPU_PRESENT == 1)
  93. #define __FPU_USED 1
  94. #else
  95. #warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
  96. #define __FPU_USED 0
  97. #endif
  98. #else
  99. #define __FPU_USED 0
  100. #endif
  101. #elif defined ( __GNUC__ )
  102. #if defined (__VFP_FP__) && !defined(__SOFTFP__)
  103. #if (__FPU_PRESENT == 1)
  104. #define __FPU_USED 1
  105. #else
  106. #warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
  107. #define __FPU_USED 0
  108. #endif
  109. #else
  110. #define __FPU_USED 0
  111. #endif
  112. #elif defined ( __TASKING__ )
  113. /* add preprocessor checks to define __FPU_USED */
  114. #define __FPU_USED 0
  115. #endif
  116. #include <stdint.h> /*!< standard types definitions */
  117. #include <core_cmInstr.h> /*!< Core Instruction Access */
  118. #include <core_cmFunc.h> /*!< Core Function Access */
  119. #include <core_cm4_simd.h> /*!< Compiler specific SIMD Intrinsics */
  120. #endif /* __CORE_CM4_H_GENERIC */
  121. #ifndef __CMSIS_GENERIC
  122. #ifndef __CORE_CM4_H_DEPENDANT
  123. #define __CORE_CM4_H_DEPENDANT
  124. /* check device defines and use defaults */
  125. #if defined __CHECK_DEVICE_DEFINES
  126. #ifndef __CM4_REV
  127. #define __CM4_REV 0x0000
  128. #warning "__CM4_REV not defined in device header file; using default!"
  129. #endif
  130. #ifndef __FPU_PRESENT
  131. #define __FPU_PRESENT 0
  132. #warning "__FPU_PRESENT not defined in device header file; using default!"
  133. #endif
  134. #ifndef __MPU_PRESENT
  135. #define __MPU_PRESENT 0
  136. #warning "__MPU_PRESENT not defined in device header file; using default!"
  137. #endif
  138. #ifndef __NVIC_PRIO_BITS
  139. #define __NVIC_PRIO_BITS 4
  140. #warning "__NVIC_PRIO_BITS not defined in device header file; using default!"
  141. #endif
  142. #ifndef __Vendor_SysTickConfig
  143. #define __Vendor_SysTickConfig 0
  144. #warning "__Vendor_SysTickConfig not defined in device header file; using default!"
  145. #endif
  146. #endif
  147. /* IO definitions (access restrictions to peripheral registers) */
  148. #ifdef __cplusplus
  149. #define __I volatile /*!< defines 'read only' permissions */
  150. #else
  151. #define __I volatile const /*!< defines 'read only' permissions */
  152. #endif
  153. #define __O volatile /*!< defines 'write only' permissions */
  154. #define __IO volatile /*!< defines 'read / write' permissions */
  155. /*@} end of group CMSIS_core_definitions */
  156. /*******************************************************************************
  157. * Register Abstraction
  158. ******************************************************************************/
  159. /** \defgroup CMSIS_core_register CMSIS Core Register
  160. Core Register contain:
  161. - Core Register
  162. - Core NVIC Register
  163. - Core SCB Register
  164. - Core SysTick Register
  165. - Core Debug Register
  166. - Core MPU Register
  167. - Core FPU Register
  168. */
  169. /** \ingroup CMSIS_core_register
  170. \defgroup CMSIS_CORE CMSIS Core
  171. Type definitions for the Cortex-M Core Registers
  172. @{
  173. */
  174. /** \brief Union type to access the Application Program Status Register (APSR).
  175. */
  176. typedef union
  177. {
  178. struct
  179. {
  180. #if (__CORTEX_M != 0x04)
  181. uint32_t _reserved0:27; /*!< bit: 0..26 Reserved */
  182. #else
  183. uint32_t _reserved0:16; /*!< bit: 0..15 Reserved */
  184. uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */
  185. uint32_t _reserved1:7; /*!< bit: 20..26 Reserved */
  186. #endif
  187. uint32_t Q:1; /*!< bit: 27 Saturation condition flag */
  188. uint32_t V:1; /*!< bit: 28 Overflow condition code flag */
  189. uint32_t C:1; /*!< bit: 29 Carry condition code flag */
  190. uint32_t Z:1; /*!< bit: 30 Zero condition code flag */
  191. uint32_t N:1; /*!< bit: 31 Negative condition code flag */
  192. } b; /*!< Structure used for bit access */
  193. uint32_t w; /*!< Type used for word access */
  194. } APSR_Type;
  195. /** \brief Union type to access the Interrupt Program Status Register (IPSR).
  196. */
  197. typedef union
  198. {
  199. struct
  200. {
  201. uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */
  202. uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */
  203. } b; /*!< Structure used for bit access */
  204. uint32_t w; /*!< Type used for word access */
  205. } IPSR_Type;
  206. /** \brief Union type to access the Special-Purpose Program Status Registers (xPSR).
  207. */
  208. typedef union
  209. {
  210. struct
  211. {
  212. uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */
  213. #if (__CORTEX_M != 0x04)
  214. uint32_t _reserved0:15; /*!< bit: 9..23 Reserved */
  215. #else
  216. uint32_t _reserved0:7; /*!< bit: 9..15 Reserved */
  217. uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */
  218. uint32_t _reserved1:4; /*!< bit: 20..23 Reserved */
  219. #endif
  220. uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */
  221. uint32_t IT:2; /*!< bit: 25..26 saved IT state (read 0) */
  222. uint32_t Q:1; /*!< bit: 27 Saturation condition flag */
  223. uint32_t V:1; /*!< bit: 28 Overflow condition code flag */
  224. uint32_t C:1; /*!< bit: 29 Carry condition code flag */
  225. uint32_t Z:1; /*!< bit: 30 Zero condition code flag */
  226. uint32_t N:1; /*!< bit: 31 Negative condition code flag */
  227. } b; /*!< Structure used for bit access */
  228. uint32_t w; /*!< Type used for word access */
  229. } xPSR_Type;
  230. /** \brief Union type to access the Control Registers (CONTROL).
  231. */
  232. typedef union
  233. {
  234. struct
  235. {
  236. uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */
  237. uint32_t SPSEL:1; /*!< bit: 1 Stack to be used */
  238. uint32_t FPCA:1; /*!< bit: 2 FP extension active flag */
  239. uint32_t _reserved0:29; /*!< bit: 3..31 Reserved */
  240. } b; /*!< Structure used for bit access */
  241. uint32_t w; /*!< Type used for word access */
  242. } CONTROL_Type;
  243. /*@} end of group CMSIS_CORE */
  244. /** \ingroup CMSIS_core_register
  245. \defgroup CMSIS_NVIC CMSIS NVIC
  246. Type definitions for the Cortex-M NVIC Registers
  247. @{
  248. */
  249. /** \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC).
  250. */
  251. typedef struct
  252. {
  253. __IO uint32_t ISER[8]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */
  254. uint32_t RESERVED0[24];
  255. __IO uint32_t ICER[8]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */
  256. uint32_t RSERVED1[24];
  257. __IO uint32_t ISPR[8]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */
  258. uint32_t RESERVED2[24];
  259. __IO uint32_t ICPR[8]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */
  260. uint32_t RESERVED3[24];
  261. __IO uint32_t IABR[8]; /*!< Offset: 0x200 (R/W) Interrupt Active bit Register */
  262. uint32_t RESERVED4[56];
  263. __IO uint8_t IP[240]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register (8Bit wide) */
  264. uint32_t RESERVED5[644];
  265. __O uint32_t STIR; /*!< Offset: 0xE00 ( /W) Software Trigger Interrupt Register */
  266. } NVIC_Type;
  267. /* Software Triggered Interrupt Register Definitions */
  268. #define NVIC_STIR_INTID_Pos 0 /*!< STIR: INTLINESNUM Position */
  269. #define NVIC_STIR_INTID_Msk (0x1FFUL << NVIC_STIR_INTID_Pos) /*!< STIR: INTLINESNUM Mask */
  270. /*@} end of group CMSIS_NVIC */
  271. /** \ingroup CMSIS_core_register
  272. \defgroup CMSIS_SCB CMSIS SCB
  273. Type definitions for the Cortex-M System Control Block Registers
  274. @{
  275. */
  276. /** \brief Structure type to access the System Control Block (SCB).
  277. */
  278. typedef struct
  279. {
  280. __I uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */
  281. __IO uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */
  282. __IO uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */
  283. __IO uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */
  284. __IO uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */
  285. __IO uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */
  286. __IO uint8_t SHP[12]; /*!< Offset: 0x018 (R/W) System Handlers Priority Registers (4-7, 8-11, 12-15) */
  287. __IO uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */
  288. __IO uint32_t CFSR; /*!< Offset: 0x028 (R/W) Configurable Fault Status Register */
  289. __IO uint32_t HFSR; /*!< Offset: 0x02C (R/W) HardFault Status Register */
  290. __IO uint32_t DFSR; /*!< Offset: 0x030 (R/W) Debug Fault Status Register */
  291. __IO uint32_t MMFAR; /*!< Offset: 0x034 (R/W) MemManage Fault Address Register */
  292. __IO uint32_t BFAR; /*!< Offset: 0x038 (R/W) BusFault Address Register */
  293. __IO uint32_t AFSR; /*!< Offset: 0x03C (R/W) Auxiliary Fault Status Register */
  294. __I uint32_t PFR[2]; /*!< Offset: 0x040 (R/ ) Processor Feature Register */
  295. __I uint32_t DFR; /*!< Offset: 0x048 (R/ ) Debug Feature Register */
  296. __I uint32_t ADR; /*!< Offset: 0x04C (R/ ) Auxiliary Feature Register */
  297. __I uint32_t MMFR[4]; /*!< Offset: 0x050 (R/ ) Memory Model Feature Register */
  298. __I uint32_t ISAR[5]; /*!< Offset: 0x060 (R/ ) Instruction Set Attributes Register */
  299. uint32_t RESERVED0[5];
  300. __IO uint32_t CPACR; /*!< Offset: 0x088 (R/W) Coprocessor Access Control Register */
  301. } SCB_Type;
  302. /* SCB CPUID Register Definitions */
  303. #define SCB_CPUID_IMPLEMENTER_Pos 24 /*!< SCB CPUID: IMPLEMENTER Position */
  304. #define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */
  305. #define SCB_CPUID_VARIANT_Pos 20 /*!< SCB CPUID: VARIANT Position */
  306. #define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */
  307. #define SCB_CPUID_ARCHITECTURE_Pos 16 /*!< SCB CPUID: ARCHITECTURE Position */
  308. #define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */
  309. #define SCB_CPUID_PARTNO_Pos 4 /*!< SCB CPUID: PARTNO Position */
  310. #define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */
  311. #define SCB_CPUID_REVISION_Pos 0 /*!< SCB CPUID: REVISION Position */
  312. #define SCB_CPUID_REVISION_Msk (0xFUL << SCB_CPUID_REVISION_Pos) /*!< SCB CPUID: REVISION Mask */
  313. /* SCB Interrupt Control State Register Definitions */
  314. #define SCB_ICSR_NMIPENDSET_Pos 31 /*!< SCB ICSR: NMIPENDSET Position */
  315. #define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */
  316. #define SCB_ICSR_PENDSVSET_Pos 28 /*!< SCB ICSR: PENDSVSET Position */
  317. #define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */
  318. #define SCB_ICSR_PENDSVCLR_Pos 27 /*!< SCB ICSR: PENDSVCLR Position */
  319. #define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */
  320. #define SCB_ICSR_PENDSTSET_Pos 26 /*!< SCB ICSR: PENDSTSET Position */
  321. #define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */
  322. #define SCB_ICSR_PENDSTCLR_Pos 25 /*!< SCB ICSR: PENDSTCLR Position */
  323. #define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */
  324. #define SCB_ICSR_ISRPREEMPT_Pos 23 /*!< SCB ICSR: ISRPREEMPT Position */
  325. #define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */
  326. #define SCB_ICSR_ISRPENDING_Pos 22 /*!< SCB ICSR: ISRPENDING Position */
  327. #define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */
  328. #define SCB_ICSR_VECTPENDING_Pos 12 /*!< SCB ICSR: VECTPENDING Position */
  329. #define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */
  330. #define SCB_ICSR_RETTOBASE_Pos 11 /*!< SCB ICSR: RETTOBASE Position */
  331. #define SCB_ICSR_RETTOBASE_Msk (1UL << SCB_ICSR_RETTOBASE_Pos) /*!< SCB ICSR: RETTOBASE Mask */
  332. #define SCB_ICSR_VECTACTIVE_Pos 0 /*!< SCB ICSR: VECTACTIVE Position */
  333. #define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL << SCB_ICSR_VECTACTIVE_Pos) /*!< SCB ICSR: VECTACTIVE Mask */
  334. /* SCB Vector Table Offset Register Definitions */
  335. #define SCB_VTOR_TBLOFF_Pos 7 /*!< SCB VTOR: TBLOFF Position */
  336. #define SCB_VTOR_TBLOFF_Msk (0x1FFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */
  337. /* SCB Application Interrupt and Reset Control Register Definitions */
  338. #define SCB_AIRCR_VECTKEY_Pos 16 /*!< SCB AIRCR: VECTKEY Position */
  339. #define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */
  340. #define SCB_AIRCR_VECTKEYSTAT_Pos 16 /*!< SCB AIRCR: VECTKEYSTAT Position */
  341. #define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */
  342. #define SCB_AIRCR_ENDIANESS_Pos 15 /*!< SCB AIRCR: ENDIANESS Position */
  343. #define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */
  344. #define SCB_AIRCR_PRIGROUP_Pos 8 /*!< SCB AIRCR: PRIGROUP Position */
  345. #define SCB_AIRCR_PRIGROUP_Msk (7UL << SCB_AIRCR_PRIGROUP_Pos) /*!< SCB AIRCR: PRIGROUP Mask */
  346. #define SCB_AIRCR_SYSRESETREQ_Pos 2 /*!< SCB AIRCR: SYSRESETREQ Position */
  347. #define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */
  348. #define SCB_AIRCR_VECTCLRACTIVE_Pos 1 /*!< SCB AIRCR: VECTCLRACTIVE Position */
  349. #define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */
  350. #define SCB_AIRCR_VECTRESET_Pos 0 /*!< SCB AIRCR: VECTRESET Position */
  351. #define SCB_AIRCR_VECTRESET_Msk (1UL << SCB_AIRCR_VECTRESET_Pos) /*!< SCB AIRCR: VECTRESET Mask */
  352. /* SCB System Control Register Definitions */
  353. #define SCB_SCR_SEVONPEND_Pos 4 /*!< SCB SCR: SEVONPEND Position */
  354. #define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */
  355. #define SCB_SCR_SLEEPDEEP_Pos 2 /*!< SCB SCR: SLEEPDEEP Position */
  356. #define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */
  357. #define SCB_SCR_SLEEPONEXIT_Pos 1 /*!< SCB SCR: SLEEPONEXIT Position */
  358. #define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */
  359. /* SCB Configuration Control Register Definitions */
  360. #define SCB_CCR_STKALIGN_Pos 9 /*!< SCB CCR: STKALIGN Position */
  361. #define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */
  362. #define SCB_CCR_BFHFNMIGN_Pos 8 /*!< SCB CCR: BFHFNMIGN Position */
  363. #define SCB_CCR_BFHFNMIGN_Msk (1UL << SCB_CCR_BFHFNMIGN_Pos) /*!< SCB CCR: BFHFNMIGN Mask */
  364. #define SCB_CCR_DIV_0_TRP_Pos 4 /*!< SCB CCR: DIV_0_TRP Position */
  365. #define SCB_CCR_DIV_0_TRP_Msk (1UL << SCB_CCR_DIV_0_TRP_Pos) /*!< SCB CCR: DIV_0_TRP Mask */
  366. #define SCB_CCR_UNALIGN_TRP_Pos 3 /*!< SCB CCR: UNALIGN_TRP Position */
  367. #define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */
  368. #define SCB_CCR_USERSETMPEND_Pos 1 /*!< SCB CCR: USERSETMPEND Position */
  369. #define SCB_CCR_USERSETMPEND_Msk (1UL << SCB_CCR_USERSETMPEND_Pos) /*!< SCB CCR: USERSETMPEND Mask */
  370. #define SCB_CCR_NONBASETHRDENA_Pos 0 /*!< SCB CCR: NONBASETHRDENA Position */
  371. #define SCB_CCR_NONBASETHRDENA_Msk (1UL << SCB_CCR_NONBASETHRDENA_Pos) /*!< SCB CCR: NONBASETHRDENA Mask */
  372. /* SCB System Handler Control and State Register Definitions */
  373. #define SCB_SHCSR_USGFAULTENA_Pos 18 /*!< SCB SHCSR: USGFAULTENA Position */
  374. #define SCB_SHCSR_USGFAULTENA_Msk (1UL << SCB_SHCSR_USGFAULTENA_Pos) /*!< SCB SHCSR: USGFAULTENA Mask */
  375. #define SCB_SHCSR_BUSFAULTENA_Pos 17 /*!< SCB SHCSR: BUSFAULTENA Position */
  376. #define SCB_SHCSR_BUSFAULTENA_Msk (1UL << SCB_SHCSR_BUSFAULTENA_Pos) /*!< SCB SHCSR: BUSFAULTENA Mask */
  377. #define SCB_SHCSR_MEMFAULTENA_Pos 16 /*!< SCB SHCSR: MEMFAULTENA Position */
  378. #define SCB_SHCSR_MEMFAULTENA_Msk (1UL << SCB_SHCSR_MEMFAULTENA_Pos) /*!< SCB SHCSR: MEMFAULTENA Mask */
  379. #define SCB_SHCSR_SVCALLPENDED_Pos 15 /*!< SCB SHCSR: SVCALLPENDED Position */
  380. #define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */
  381. #define SCB_SHCSR_BUSFAULTPENDED_Pos 14 /*!< SCB SHCSR: BUSFAULTPENDED Position */
  382. #define SCB_SHCSR_BUSFAULTPENDED_Msk (1UL << SCB_SHCSR_BUSFAULTPENDED_Pos) /*!< SCB SHCSR: BUSFAULTPENDED Mask */
  383. #define SCB_SHCSR_MEMFAULTPENDED_Pos 13 /*!< SCB SHCSR: MEMFAULTPENDED Position */
  384. #define SCB_SHCSR_MEMFAULTPENDED_Msk (1UL << SCB_SHCSR_MEMFAULTPENDED_Pos) /*!< SCB SHCSR: MEMFAULTPENDED Mask */
  385. #define SCB_SHCSR_USGFAULTPENDED_Pos 12 /*!< SCB SHCSR: USGFAULTPENDED Position */
  386. #define SCB_SHCSR_USGFAULTPENDED_Msk (1UL << SCB_SHCSR_USGFAULTPENDED_Pos) /*!< SCB SHCSR: USGFAULTPENDED Mask */
  387. #define SCB_SHCSR_SYSTICKACT_Pos 11 /*!< SCB SHCSR: SYSTICKACT Position */
  388. #define SCB_SHCSR_SYSTICKACT_Msk (1UL << SCB_SHCSR_SYSTICKACT_Pos) /*!< SCB SHCSR: SYSTICKACT Mask */
  389. #define SCB_SHCSR_PENDSVACT_Pos 10 /*!< SCB SHCSR: PENDSVACT Position */
  390. #define SCB_SHCSR_PENDSVACT_Msk (1UL << SCB_SHCSR_PENDSVACT_Pos) /*!< SCB SHCSR: PENDSVACT Mask */
  391. #define SCB_SHCSR_MONITORACT_Pos 8 /*!< SCB SHCSR: MONITORACT Position */
  392. #define SCB_SHCSR_MONITORACT_Msk (1UL << SCB_SHCSR_MONITORACT_Pos) /*!< SCB SHCSR: MONITORACT Mask */
  393. #define SCB_SHCSR_SVCALLACT_Pos 7 /*!< SCB SHCSR: SVCALLACT Position */
  394. #define SCB_SHCSR_SVCALLACT_Msk (1UL << SCB_SHCSR_SVCALLACT_Pos) /*!< SCB SHCSR: SVCALLACT Mask */
  395. #define SCB_SHCSR_USGFAULTACT_Pos 3 /*!< SCB SHCSR: USGFAULTACT Position */
  396. #define SCB_SHCSR_USGFAULTACT_Msk (1UL << SCB_SHCSR_USGFAULTACT_Pos) /*!< SCB SHCSR: USGFAULTACT Mask */
  397. #define SCB_SHCSR_BUSFAULTACT_Pos 1 /*!< SCB SHCSR: BUSFAULTACT Position */
  398. #define SCB_SHCSR_BUSFAULTACT_Msk (1UL << SCB_SHCSR_BUSFAULTACT_Pos) /*!< SCB SHCSR: BUSFAULTACT Mask */
  399. #define SCB_SHCSR_MEMFAULTACT_Pos 0 /*!< SCB SHCSR: MEMFAULTACT Position */
  400. #define SCB_SHCSR_MEMFAULTACT_Msk (1UL << SCB_SHCSR_MEMFAULTACT_Pos) /*!< SCB SHCSR: MEMFAULTACT Mask */
  401. /* SCB Configurable Fault Status Registers Definitions */
  402. #define SCB_CFSR_USGFAULTSR_Pos 16 /*!< SCB CFSR: Usage Fault Status Register Position */
  403. #define SCB_CFSR_USGFAULTSR_Msk (0xFFFFUL << SCB_CFSR_USGFAULTSR_Pos) /*!< SCB CFSR: Usage Fault Status Register Mask */
  404. #define SCB_CFSR_BUSFAULTSR_Pos 8 /*!< SCB CFSR: Bus Fault Status Register Position */
  405. #define SCB_CFSR_BUSFAULTSR_Msk (0xFFUL << SCB_CFSR_BUSFAULTSR_Pos) /*!< SCB CFSR: Bus Fault Status Register Mask */
  406. #define SCB_CFSR_MEMFAULTSR_Pos 0 /*!< SCB CFSR: Memory Manage Fault Status Register Position */
  407. #define SCB_CFSR_MEMFAULTSR_Msk (0xFFUL << SCB_CFSR_MEMFAULTSR_Pos) /*!< SCB CFSR: Memory Manage Fault Status Register Mask */
  408. /* SCB Hard Fault Status Registers Definitions */
  409. #define SCB_HFSR_DEBUGEVT_Pos 31 /*!< SCB HFSR: DEBUGEVT Position */
  410. #define SCB_HFSR_DEBUGEVT_Msk (1UL << SCB_HFSR_DEBUGEVT_Pos) /*!< SCB HFSR: DEBUGEVT Mask */
  411. #define SCB_HFSR_FORCED_Pos 30 /*!< SCB HFSR: FORCED Position */
  412. #define SCB_HFSR_FORCED_Msk (1UL << SCB_HFSR_FORCED_Pos) /*!< SCB HFSR: FORCED Mask */
  413. #define SCB_HFSR_VECTTBL_Pos 1 /*!< SCB HFSR: VECTTBL Position */
  414. #define SCB_HFSR_VECTTBL_Msk (1UL << SCB_HFSR_VECTTBL_Pos) /*!< SCB HFSR: VECTTBL Mask */
  415. /* SCB Debug Fault Status Register Definitions */
  416. #define SCB_DFSR_EXTERNAL_Pos 4 /*!< SCB DFSR: EXTERNAL Position */
  417. #define SCB_DFSR_EXTERNAL_Msk (1UL << SCB_DFSR_EXTERNAL_Pos) /*!< SCB DFSR: EXTERNAL Mask */
  418. #define SCB_DFSR_VCATCH_Pos 3 /*!< SCB DFSR: VCATCH Position */
  419. #define SCB_DFSR_VCATCH_Msk (1UL << SCB_DFSR_VCATCH_Pos) /*!< SCB DFSR: VCATCH Mask */
  420. #define SCB_DFSR_DWTTRAP_Pos 2 /*!< SCB DFSR: DWTTRAP Position */
  421. #define SCB_DFSR_DWTTRAP_Msk (1UL << SCB_DFSR_DWTTRAP_Pos) /*!< SCB DFSR: DWTTRAP Mask */
  422. #define SCB_DFSR_BKPT_Pos 1 /*!< SCB DFSR: BKPT Position */
  423. #define SCB_DFSR_BKPT_Msk (1UL << SCB_DFSR_BKPT_Pos) /*!< SCB DFSR: BKPT Mask */
  424. #define SCB_DFSR_HALTED_Pos 0 /*!< SCB DFSR: HALTED Position */
  425. #define SCB_DFSR_HALTED_Msk (1UL << SCB_DFSR_HALTED_Pos) /*!< SCB DFSR: HALTED Mask */
  426. /*@} end of group CMSIS_SCB */
  427. /** \ingroup CMSIS_core_register
  428. \defgroup CMSIS_SCnSCB CMSIS System Control and ID Register not in the SCB
  429. Type definitions for the Cortex-M System Control and ID Register not in the SCB
  430. @{
  431. */
  432. /** \brief Structure type to access the System Control and ID Register not in the SCB.
  433. */
  434. typedef struct
  435. {
  436. uint32_t RESERVED0[1];
  437. __I uint32_t ICTR; /*!< Offset: 0x004 (R/ ) Interrupt Controller Type Register */
  438. __IO uint32_t ACTLR; /*!< Offset: 0x008 (R/W) Auxiliary Control Register */
  439. } SCnSCB_Type;
  440. /* Interrupt Controller Type Register Definitions */
  441. #define SCnSCB_ICTR_INTLINESNUM_Pos 0 /*!< ICTR: INTLINESNUM Position */
  442. #define SCnSCB_ICTR_INTLINESNUM_Msk (0xFUL << SCnSCB_ICTR_INTLINESNUM_Pos) /*!< ICTR: INTLINESNUM Mask */
  443. /* Auxiliary Control Register Definitions */
  444. #define SCnSCB_ACTLR_DISOOFP_Pos 9 /*!< ACTLR: DISOOFP Position */
  445. #define SCnSCB_ACTLR_DISOOFP_Msk (1UL << SCnSCB_ACTLR_DISOOFP_Pos) /*!< ACTLR: DISOOFP Mask */
  446. #define SCnSCB_ACTLR_DISFPCA_Pos 8 /*!< ACTLR: DISFPCA Position */
  447. #define SCnSCB_ACTLR_DISFPCA_Msk (1UL << SCnSCB_ACTLR_DISFPCA_Pos) /*!< ACTLR: DISFPCA Mask */
  448. #define SCnSCB_ACTLR_DISFOLD_Pos 2 /*!< ACTLR: DISFOLD Position */
  449. #define SCnSCB_ACTLR_DISFOLD_Msk (1UL << SCnSCB_ACTLR_DISFOLD_Pos) /*!< ACTLR: DISFOLD Mask */
  450. #define SCnSCB_ACTLR_DISDEFWBUF_Pos 1 /*!< ACTLR: DISDEFWBUF Position */
  451. #define SCnSCB_ACTLR_DISDEFWBUF_Msk (1UL << SCnSCB_ACTLR_DISDEFWBUF_Pos) /*!< ACTLR: DISDEFWBUF Mask */
  452. #define SCnSCB_ACTLR_DISMCYCINT_Pos 0 /*!< ACTLR: DISMCYCINT Position */
  453. #define SCnSCB_ACTLR_DISMCYCINT_Msk (1UL << SCnSCB_ACTLR_DISMCYCINT_Pos) /*!< ACTLR: DISMCYCINT Mask */
  454. /*@} end of group CMSIS_SCnotSCB */
  455. /** \ingroup CMSIS_core_register
  456. \defgroup CMSIS_SysTick CMSIS SysTick
  457. Type definitions for the Cortex-M System Timer Registers
  458. @{
  459. */
  460. /** \brief Structure type to access the System Timer (SysTick).
  461. */
  462. typedef struct
  463. {
  464. __IO uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */
  465. __IO uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */
  466. __IO uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */
  467. __I uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */
  468. } SysTick_Type;
  469. /* SysTick Control / Status Register Definitions */
  470. #define SysTick_CTRL_COUNTFLAG_Pos 16 /*!< SysTick CTRL: COUNTFLAG Position */
  471. #define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */
  472. #define SysTick_CTRL_CLKSOURCE_Pos 2 /*!< SysTick CTRL: CLKSOURCE Position */
  473. #define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */
  474. #define SysTick_CTRL_TICKINT_Pos 1 /*!< SysTick CTRL: TICKINT Position */
  475. #define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */
  476. #define SysTick_CTRL_ENABLE_Pos 0 /*!< SysTick CTRL: ENABLE Position */
  477. #define SysTick_CTRL_ENABLE_Msk (1UL << SysTick_CTRL_ENABLE_Pos) /*!< SysTick CTRL: ENABLE Mask */
  478. /* SysTick Reload Register Definitions */
  479. #define SysTick_LOAD_RELOAD_Pos 0 /*!< SysTick LOAD: RELOAD Position */
  480. #define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL << SysTick_LOAD_RELOAD_Pos) /*!< SysTick LOAD: RELOAD Mask */
  481. /* SysTick Current Register Definitions */
  482. #define SysTick_VAL_CURRENT_Pos 0 /*!< SysTick VAL: CURRENT Position */
  483. #define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL << SysTick_VAL_CURRENT_Pos) /*!< SysTick VAL: CURRENT Mask */
  484. /* SysTick Calibration Register Definitions */
  485. #define SysTick_CALIB_NOREF_Pos 31 /*!< SysTick CALIB: NOREF Position */
  486. #define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */
  487. #define SysTick_CALIB_SKEW_Pos 30 /*!< SysTick CALIB: SKEW Position */
  488. #define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */
  489. #define SysTick_CALIB_TENMS_Pos 0 /*!< SysTick CALIB: TENMS Position */
  490. #define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL << SysTick_VAL_CURRENT_Pos) /*!< SysTick CALIB: TENMS Mask */
  491. /*@} end of group CMSIS_SysTick */
  492. /** \ingroup CMSIS_core_register
  493. \defgroup CMSIS_ITM CMSIS ITM
  494. Type definitions for the Cortex-M Instrumentation Trace Macrocell (ITM)
  495. @{
  496. */
  497. /** \brief Structure type to access the Instrumentation Trace Macrocell Register (ITM).
  498. */
  499. typedef struct
  500. {
  501. __O union
  502. {
  503. __O uint8_t u8; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 8-bit */
  504. __O uint16_t u16; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 16-bit */
  505. __O uint32_t u32; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 32-bit */
  506. } PORT [32]; /*!< Offset: 0x000 ( /W) ITM Stimulus Port Registers */
  507. uint32_t RESERVED0[864];
  508. __IO uint32_t TER; /*!< Offset: 0xE00 (R/W) ITM Trace Enable Register */
  509. uint32_t RESERVED1[15];
  510. __IO uint32_t TPR; /*!< Offset: 0xE40 (R/W) ITM Trace Privilege Register */
  511. uint32_t RESERVED2[15];
  512. __IO uint32_t TCR; /*!< Offset: 0xE80 (R/W) ITM Trace Control Register */
  513. } ITM_Type;
  514. /* ITM Trace Privilege Register Definitions */
  515. #define ITM_TPR_PRIVMASK_Pos 0 /*!< ITM TPR: PRIVMASK Position */
  516. #define ITM_TPR_PRIVMASK_Msk (0xFUL << ITM_TPR_PRIVMASK_Pos) /*!< ITM TPR: PRIVMASK Mask */
  517. /* ITM Trace Control Register Definitions */
  518. #define ITM_TCR_BUSY_Pos 23 /*!< ITM TCR: BUSY Position */
  519. #define ITM_TCR_BUSY_Msk (1UL << ITM_TCR_BUSY_Pos) /*!< ITM TCR: BUSY Mask */
  520. #define ITM_TCR_TraceBusID_Pos 16 /*!< ITM TCR: ATBID Position */
  521. #define ITM_TCR_TraceBusID_Msk (0x7FUL << ITM_TCR_TraceBusID_Pos) /*!< ITM TCR: ATBID Mask */
  522. #define ITM_TCR_GTSFREQ_Pos 10 /*!< ITM TCR: Global timestamp frequency Position */
  523. #define ITM_TCR_GTSFREQ_Msk (3UL << ITM_TCR_GTSFREQ_Pos) /*!< ITM TCR: Global timestamp frequency Mask */
  524. #define ITM_TCR_TSPrescale_Pos 8 /*!< ITM TCR: TSPrescale Position */
  525. #define ITM_TCR_TSPrescale_Msk (3UL << ITM_TCR_TSPrescale_Pos) /*!< ITM TCR: TSPrescale Mask */
  526. #define ITM_TCR_SWOENA_Pos 4 /*!< ITM TCR: SWOENA Position */
  527. #define ITM_TCR_SWOENA_Msk (1UL << ITM_TCR_SWOENA_Pos) /*!< ITM TCR: SWOENA Mask */
  528. #define ITM_TCR_TXENA_Pos 3 /*!< ITM TCR: TXENA Position */
  529. #define ITM_TCR_TXENA_Msk (1UL << ITM_TCR_TXENA_Pos) /*!< ITM TCR: TXENA Mask */
  530. #define ITM_TCR_SYNCENA_Pos 2 /*!< ITM TCR: SYNCENA Position */
  531. #define ITM_TCR_SYNCENA_Msk (1UL << ITM_TCR_SYNCENA_Pos) /*!< ITM TCR: SYNCENA Mask */
  532. #define ITM_TCR_TSENA_Pos 1 /*!< ITM TCR: TSENA Position */
  533. #define ITM_TCR_TSENA_Msk (1UL << ITM_TCR_TSENA_Pos) /*!< ITM TCR: TSENA Mask */
  534. #define ITM_TCR_ITMENA_Pos 0 /*!< ITM TCR: ITM Enable bit Position */
  535. #define ITM_TCR_ITMENA_Msk (1UL << ITM_TCR_ITMENA_Pos) /*!< ITM TCR: ITM Enable bit Mask */
  536. /*@}*/ /* end of group CMSIS_ITM */
  537. #if (__MPU_PRESENT == 1)
  538. /** \ingroup CMSIS_core_register
  539. \defgroup CMSIS_MPU CMSIS MPU
  540. Type definitions for the Cortex-M Memory Protection Unit (MPU)
  541. @{
  542. */
  543. /** \brief Structure type to access the Memory Protection Unit (MPU).
  544. */
  545. typedef struct
  546. {
  547. __I uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */
  548. __IO uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */
  549. __IO uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region RNRber Register */
  550. __IO uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */
  551. __IO uint32_t RASR; /*!< Offset: 0x010 (R/W) MPU Region Attribute and Size Register */
  552. __IO uint32_t RBAR_A1; /*!< Offset: 0x014 (R/W) MPU Alias 1 Region Base Address Register */
  553. __IO uint32_t RASR_A1; /*!< Offset: 0x018 (R/W) MPU Alias 1 Region Attribute and Size Register */
  554. __IO uint32_t RBAR_A2; /*!< Offset: 0x01C (R/W) MPU Alias 2 Region Base Address Register */
  555. __IO uint32_t RASR_A2; /*!< Offset: 0x020 (R/W) MPU Alias 2 Region Attribute and Size Register */
  556. __IO uint32_t RBAR_A3; /*!< Offset: 0x024 (R/W) MPU Alias 3 Region Base Address Register */
  557. __IO uint32_t RASR_A3; /*!< Offset: 0x028 (R/W) MPU Alias 3 Region Attribute and Size Register */
  558. } MPU_Type;
  559. /* MPU Type Register */
  560. #define MPU_TYPE_IREGION_Pos 16 /*!< MPU TYPE: IREGION Position */
  561. #define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */
  562. #define MPU_TYPE_DREGION_Pos 8 /*!< MPU TYPE: DREGION Position */
  563. #define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */
  564. #define MPU_TYPE_SEPARATE_Pos 0 /*!< MPU TYPE: SEPARATE Position */
  565. #define MPU_TYPE_SEPARATE_Msk (1UL << MPU_TYPE_SEPARATE_Pos) /*!< MPU TYPE: SEPARATE Mask */
  566. /* MPU Control Register */
  567. #define MPU_CTRL_PRIVDEFENA_Pos 2 /*!< MPU CTRL: PRIVDEFENA Position */
  568. #define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */
  569. #define MPU_CTRL_HFNMIENA_Pos 1 /*!< MPU CTRL: HFNMIENA Position */
  570. #define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */
  571. #define MPU_CTRL_ENABLE_Pos 0 /*!< MPU CTRL: ENABLE Position */
  572. #define MPU_CTRL_ENABLE_Msk (1UL << MPU_CTRL_ENABLE_Pos) /*!< MPU CTRL: ENABLE Mask */
  573. /* MPU Region Number Register */
  574. #define MPU_RNR_REGION_Pos 0 /*!< MPU RNR: REGION Position */
  575. #define MPU_RNR_REGION_Msk (0xFFUL << MPU_RNR_REGION_Pos) /*!< MPU RNR: REGION Mask */
  576. /* MPU Region Base Address Register */
  577. #define MPU_RBAR_ADDR_Pos 5 /*!< MPU RBAR: ADDR Position */
  578. #define MPU_RBAR_ADDR_Msk (0x7FFFFFFUL << MPU_RBAR_ADDR_Pos) /*!< MPU RBAR: ADDR Mask */
  579. #define MPU_RBAR_VALID_Pos 4 /*!< MPU RBAR: VALID Position */
  580. #define MPU_RBAR_VALID_Msk (1UL << MPU_RBAR_VALID_Pos) /*!< MPU RBAR: VALID Mask */
  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. /* MPU Region Attribute and Size Register */
  584. #define MPU_RASR_ATTRS_Pos 16 /*!< MPU RASR: MPU Region Attribute field Position */
  585. #define MPU_RASR_ATTRS_Msk (0xFFFFUL << MPU_RASR_ATTRS_Pos) /*!< MPU RASR: MPU Region Attribute field Mask */
  586. #define MPU_RASR_SRD_Pos 8 /*!< MPU RASR: Sub-Region Disable Position */
  587. #define MPU_RASR_SRD_Msk (0xFFUL << MPU_RASR_SRD_Pos) /*!< MPU RASR: Sub-Region Disable Mask */
  588. #define MPU_RASR_SIZE_Pos 1 /*!< MPU RASR: Region Size Field Position */
  589. #define MPU_RASR_SIZE_Msk (0x1FUL << MPU_RASR_SIZE_Pos) /*!< MPU RASR: Region Size Field Mask */
  590. #define MPU_RASR_ENABLE_Pos 0 /*!< MPU RASR: Region enable bit Position */
  591. #define MPU_RASR_ENABLE_Msk (1UL << MPU_RASR_ENABLE_Pos) /*!< MPU RASR: Region enable bit Disable Mask */
  592. /*@} end of group CMSIS_MPU */
  593. #endif
  594. #if (__FPU_PRESENT == 1)
  595. /** \ingroup CMSIS_core_register
  596. \defgroup CMSIS_FPU CMSIS FPU
  597. Type definitions for the Cortex-M Floating Point Unit (FPU)
  598. @{
  599. */
  600. /** \brief Structure type to access the Floating Point Unit (FPU).
  601. */
  602. typedef struct
  603. {
  604. uint32_t RESERVED0[1];
  605. __IO uint32_t FPCCR; /*!< Offset: 0x004 (R/W) Floating-Point Context Control Register */
  606. __IO uint32_t FPCAR; /*!< Offset: 0x008 (R/W) Floating-Point Context Address Register */
  607. __IO uint32_t FPDSCR; /*!< Offset: 0x00C (R/W) Floating-Point Default Status Control Register */
  608. __I uint32_t MVFR0; /*!< Offset: 0x010 (R/ ) Media and FP Feature Register 0 */
  609. __I uint32_t MVFR1; /*!< Offset: 0x014 (R/ ) Media and FP Feature Register 1 */
  610. } FPU_Type;
  611. /* Floating-Point Context Control Register */
  612. #define FPU_FPCCR_ASPEN_Pos 31 /*!< FPCCR: ASPEN bit Position */
  613. #define FPU_FPCCR_ASPEN_Msk (1UL << FPU_FPCCR_ASPEN_Pos) /*!< FPCCR: ASPEN bit Mask */
  614. #define FPU_FPCCR_LSPEN_Pos 30 /*!< FPCCR: LSPEN Position */
  615. #define FPU_FPCCR_LSPEN_Msk (1UL << FPU_FPCCR_LSPEN_Pos) /*!< FPCCR: LSPEN bit Mask */
  616. #define FPU_FPCCR_MONRDY_Pos 8 /*!< FPCCR: MONRDY Position */
  617. #define FPU_FPCCR_MONRDY_Msk (1UL << FPU_FPCCR_MONRDY_Pos) /*!< FPCCR: MONRDY bit Mask */
  618. #define FPU_FPCCR_BFRDY_Pos 6 /*!< FPCCR: BFRDY Position */
  619. #define FPU_FPCCR_BFRDY_Msk (1UL << FPU_FPCCR_BFRDY_Pos) /*!< FPCCR: BFRDY bit Mask */
  620. #define FPU_FPCCR_MMRDY_Pos 5 /*!< FPCCR: MMRDY Position */
  621. #define FPU_FPCCR_MMRDY_Msk (1UL << FPU_FPCCR_MMRDY_Pos) /*!< FPCCR: MMRDY bit Mask */
  622. #define FPU_FPCCR_HFRDY_Pos 4 /*!< FPCCR: HFRDY Position */
  623. #define FPU_FPCCR_HFRDY_Msk (1UL << FPU_FPCCR_HFRDY_Pos) /*!< FPCCR: HFRDY bit Mask */
  624. #define FPU_FPCCR_THREAD_Pos 3 /*!< FPCCR: processor mode bit Position */
  625. #define FPU_FPCCR_THREAD_Msk (1UL << FPU_FPCCR_THREAD_Pos) /*!< FPCCR: processor mode active bit Mask */
  626. #define FPU_FPCCR_USER_Pos 1 /*!< FPCCR: privilege level bit Position */
  627. #define FPU_FPCCR_USER_Msk (1UL << FPU_FPCCR_USER_Pos) /*!< FPCCR: privilege level bit Mask */
  628. #define FPU_FPCCR_LSPACT_Pos 0 /*!< FPCCR: Lazy state preservation active bit Position */
  629. #define FPU_FPCCR_LSPACT_Msk (1UL << FPU_FPCCR_LSPACT_Pos) /*!< FPCCR: Lazy state preservation active bit Mask */
  630. /* Floating-Point Context Address Register */
  631. #define FPU_FPCAR_ADDRESS_Pos 3 /*!< FPCAR: ADDRESS bit Position */
  632. #define FPU_FPCAR_ADDRESS_Msk (0x1FFFFFFFUL << FPU_FPCAR_ADDRESS_Pos) /*!< FPCAR: ADDRESS bit Mask */
  633. /* Floating-Point Default Status Control Register */
  634. #define FPU_FPDSCR_AHP_Pos 26 /*!< FPDSCR: AHP bit Position */
  635. #define FPU_FPDSCR_AHP_Msk (1UL << FPU_FPDSCR_AHP_Pos) /*!< FPDSCR: AHP bit Mask */
  636. #define FPU_FPDSCR_DN_Pos 25 /*!< FPDSCR: DN bit Position */
  637. #define FPU_FPDSCR_DN_Msk (1UL << FPU_FPDSCR_DN_Pos) /*!< FPDSCR: DN bit Mask */
  638. #define FPU_FPDSCR_FZ_Pos 24 /*!< FPDSCR: FZ bit Position */
  639. #define FPU_FPDSCR_FZ_Msk (1UL << FPU_FPDSCR_FZ_Pos) /*!< FPDSCR: FZ bit Mask */
  640. #define FPU_FPDSCR_RMode_Pos 22 /*!< FPDSCR: RMode bit Position */
  641. #define FPU_FPDSCR_RMode_Msk (3UL << FPU_FPDSCR_RMode_Pos) /*!< FPDSCR: RMode bit Mask */
  642. /* Media and FP Feature Register 0 */
  643. #define FPU_MVFR0_FP_rounding_modes_Pos 28 /*!< MVFR0: FP rounding modes bits Position */
  644. #define FPU_MVFR0_FP_rounding_modes_Msk (0xFUL << FPU_MVFR0_FP_rounding_modes_Pos) /*!< MVFR0: FP rounding modes bits Mask */
  645. #define FPU_MVFR0_Short_vectors_Pos 24 /*!< MVFR0: Short vectors bits Position */
  646. #define FPU_MVFR0_Short_vectors_Msk (0xFUL << FPU_MVFR0_Short_vectors_Pos) /*!< MVFR0: Short vectors bits Mask */
  647. #define FPU_MVFR0_Square_root_Pos 20 /*!< MVFR0: Square root bits Position */
  648. #define FPU_MVFR0_Square_root_Msk (0xFUL << FPU_MVFR0_Square_root_Pos) /*!< MVFR0: Square root bits Mask */
  649. #define FPU_MVFR0_Divide_Pos 16 /*!< MVFR0: Divide bits Position */
  650. #define FPU_MVFR0_Divide_Msk (0xFUL << FPU_MVFR0_Divide_Pos) /*!< MVFR0: Divide bits Mask */
  651. #define FPU_MVFR0_FP_excep_trapping_Pos 12 /*!< MVFR0: FP exception trapping bits Position */
  652. #define FPU_MVFR0_FP_excep_trapping_Msk (0xFUL << FPU_MVFR0_FP_excep_trapping_Pos) /*!< MVFR0: FP exception trapping bits Mask */
  653. #define FPU_MVFR0_Double_precision_Pos 8 /*!< MVFR0: Double-precision bits Position */
  654. #define FPU_MVFR0_Double_precision_Msk (0xFUL << FPU_MVFR0_Double_precision_Pos) /*!< MVFR0: Double-precision bits Mask */
  655. #define FPU_MVFR0_Single_precision_Pos 4 /*!< MVFR0: Single-precision bits Position */
  656. #define FPU_MVFR0_Single_precision_Msk (0xFUL << FPU_MVFR0_Single_precision_Pos) /*!< MVFR0: Single-precision bits Mask */
  657. #define FPU_MVFR0_A_SIMD_registers_Pos 0 /*!< MVFR0: A_SIMD registers bits Position */
  658. #define FPU_MVFR0_A_SIMD_registers_Msk (0xFUL << FPU_MVFR0_A_SIMD_registers_Pos) /*!< MVFR0: A_SIMD registers bits Mask */
  659. /* Media and FP Feature Register 1 */
  660. #define FPU_MVFR1_FP_fused_MAC_Pos 28 /*!< MVFR1: FP fused MAC bits Position */
  661. #define FPU_MVFR1_FP_fused_MAC_Msk (0xFUL << FPU_MVFR1_FP_fused_MAC_Pos) /*!< MVFR1: FP fused MAC bits Mask */
  662. #define FPU_MVFR1_FP_HPFP_Pos 24 /*!< MVFR1: FP HPFP bits Position */
  663. #define FPU_MVFR1_FP_HPFP_Msk (0xFUL << FPU_MVFR1_FP_HPFP_Pos) /*!< MVFR1: FP HPFP bits Mask */
  664. #define FPU_MVFR1_D_NaN_mode_Pos 4 /*!< MVFR1: D_NaN mode bits Position */
  665. #define FPU_MVFR1_D_NaN_mode_Msk (0xFUL << FPU_MVFR1_D_NaN_mode_Pos) /*!< MVFR1: D_NaN mode bits Mask */
  666. #define FPU_MVFR1_FtZ_mode_Pos 0 /*!< MVFR1: FtZ mode bits Position */
  667. #define FPU_MVFR1_FtZ_mode_Msk (0xFUL << FPU_MVFR1_FtZ_mode_Pos) /*!< MVFR1: FtZ mode bits Mask */
  668. /*@} end of group CMSIS_FPU */
  669. #endif
  670. /** \ingroup CMSIS_core_register
  671. \defgroup CMSIS_CoreDebug CMSIS Core Debug
  672. Type definitions for the Cortex-M Core Debug Registers
  673. @{
  674. */
  675. /** \brief Structure type to access the Core Debug Register (CoreDebug).
  676. */
  677. typedef struct
  678. {
  679. __IO uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */
  680. __O uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */
  681. __IO uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */
  682. __IO uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */
  683. } CoreDebug_Type;
  684. /* Debug Halting Control and Status Register */
  685. #define CoreDebug_DHCSR_DBGKEY_Pos 16 /*!< CoreDebug DHCSR: DBGKEY Position */
  686. #define CoreDebug_DHCSR_DBGKEY_Msk (0xFFFFUL << CoreDebug_DHCSR_DBGKEY_Pos) /*!< CoreDebug DHCSR: DBGKEY Mask */
  687. #define CoreDebug_DHCSR_S_RESET_ST_Pos 25 /*!< CoreDebug DHCSR: S_RESET_ST Position */
  688. #define CoreDebug_DHCSR_S_RESET_ST_Msk (1UL << CoreDebug_DHCSR_S_RESET_ST_Pos) /*!< CoreDebug DHCSR: S_RESET_ST Mask */
  689. #define CoreDebug_DHCSR_S_RETIRE_ST_Pos 24 /*!< CoreDebug DHCSR: S_RETIRE_ST Position */
  690. #define CoreDebug_DHCSR_S_RETIRE_ST_Msk (1UL << CoreDebug_DHCSR_S_RETIRE_ST_Pos) /*!< CoreDebug DHCSR: S_RETIRE_ST Mask */
  691. #define CoreDebug_DHCSR_S_LOCKUP_Pos 19 /*!< CoreDebug DHCSR: S_LOCKUP Position */
  692. #define CoreDebug_DHCSR_S_LOCKUP_Msk (1UL << CoreDebug_DHCSR_S_LOCKUP_Pos) /*!< CoreDebug DHCSR: S_LOCKUP Mask */
  693. #define CoreDebug_DHCSR_S_SLEEP_Pos 18 /*!< CoreDebug DHCSR: S_SLEEP Position */
  694. #define CoreDebug_DHCSR_S_SLEEP_Msk (1UL << CoreDebug_DHCSR_S_SLEEP_Pos) /*!< CoreDebug DHCSR: S_SLEEP Mask */
  695. #define CoreDebug_DHCSR_S_HALT_Pos 17 /*!< CoreDebug DHCSR: S_HALT Position */
  696. #define CoreDebug_DHCSR_S_HALT_Msk (1UL << CoreDebug_DHCSR_S_HALT_Pos) /*!< CoreDebug DHCSR: S_HALT Mask */
  697. #define CoreDebug_DHCSR_S_REGRDY_Pos 16 /*!< CoreDebug DHCSR: S_REGRDY Position */
  698. #define CoreDebug_DHCSR_S_REGRDY_Msk (1UL << CoreDebug_DHCSR_S_REGRDY_Pos) /*!< CoreDebug DHCSR: S_REGRDY Mask */
  699. #define CoreDebug_DHCSR_C_SNAPSTALL_Pos 5 /*!< CoreDebug DHCSR: C_SNAPSTALL Position */
  700. #define CoreDebug_DHCSR_C_SNAPSTALL_Msk (1UL << CoreDebug_DHCSR_C_SNAPSTALL_Pos) /*!< CoreDebug DHCSR: C_SNAPSTALL Mask */
  701. #define CoreDebug_DHCSR_C_MASKINTS_Pos 3 /*!< CoreDebug DHCSR: C_MASKINTS Position */
  702. #define CoreDebug_DHCSR_C_MASKINTS_Msk (1UL << CoreDebug_DHCSR_C_MASKINTS_Pos) /*!< CoreDebug DHCSR: C_MASKINTS Mask */
  703. #define CoreDebug_DHCSR_C_STEP_Pos 2 /*!< CoreDebug DHCSR: C_STEP Position */
  704. #define CoreDebug_DHCSR_C_STEP_Msk (1UL << CoreDebug_DHCSR_C_STEP_Pos) /*!< CoreDebug DHCSR: C_STEP Mask */
  705. #define CoreDebug_DHCSR_C_HALT_Pos 1 /*!< CoreDebug DHCSR: C_HALT Position */
  706. #define CoreDebug_DHCSR_C_HALT_Msk (1UL << CoreDebug_DHCSR_C_HALT_Pos) /*!< CoreDebug DHCSR: C_HALT Mask */
  707. #define CoreDebug_DHCSR_C_DEBUGEN_Pos 0 /*!< CoreDebug DHCSR: C_DEBUGEN Position */
  708. #define CoreDebug_DHCSR_C_DEBUGEN_Msk (1UL << CoreDebug_DHCSR_C_DEBUGEN_Pos) /*!< CoreDebug DHCSR: C_DEBUGEN Mask */
  709. /* Debug Core Register Selector Register */
  710. #define CoreDebug_DCRSR_REGWnR_Pos 16 /*!< CoreDebug DCRSR: REGWnR Position */
  711. #define CoreDebug_DCRSR_REGWnR_Msk (1UL << CoreDebug_DCRSR_REGWnR_Pos) /*!< CoreDebug DCRSR: REGWnR Mask */
  712. #define CoreDebug_DCRSR_REGSEL_Pos 0 /*!< CoreDebug DCRSR: REGSEL Position */
  713. #define CoreDebug_DCRSR_REGSEL_Msk (0x1FUL << CoreDebug_DCRSR_REGSEL_Pos) /*!< CoreDebug DCRSR: REGSEL Mask */
  714. /* Debug Exception and Monitor Control Register */
  715. #define CoreDebug_DEMCR_TRCENA_Pos 24 /*!< CoreDebug DEMCR: TRCENA Position */
  716. #define CoreDebug_DEMCR_TRCENA_Msk (1UL << CoreDebug_DEMCR_TRCENA_Pos) /*!< CoreDebug DEMCR: TRCENA Mask */
  717. #define CoreDebug_DEMCR_MON_REQ_Pos 19 /*!< CoreDebug DEMCR: MON_REQ Position */
  718. #define CoreDebug_DEMCR_MON_REQ_Msk (1UL << CoreDebug_DEMCR_MON_REQ_Pos) /*!< CoreDebug DEMCR: MON_REQ Mask */
  719. #define CoreDebug_DEMCR_MON_STEP_Pos 18 /*!< CoreDebug DEMCR: MON_STEP Position */
  720. #define CoreDebug_DEMCR_MON_STEP_Msk (1UL << CoreDebug_DEMCR_MON_STEP_Pos) /*!< CoreDebug DEMCR: MON_STEP Mask */
  721. #define CoreDebug_DEMCR_MON_PEND_Pos 17 /*!< CoreDebug DEMCR: MON_PEND Position */
  722. #define CoreDebug_DEMCR_MON_PEND_Msk (1UL << CoreDebug_DEMCR_MON_PEND_Pos) /*!< CoreDebug DEMCR: MON_PEND Mask */
  723. #define CoreDebug_DEMCR_MON_EN_Pos 16 /*!< CoreDebug DEMCR: MON_EN Position */
  724. #define CoreDebug_DEMCR_MON_EN_Msk (1UL << CoreDebug_DEMCR_MON_EN_Pos) /*!< CoreDebug DEMCR: MON_EN Mask */
  725. #define CoreDebug_DEMCR_VC_HARDERR_Pos 10 /*!< CoreDebug DEMCR: VC_HARDERR Position */
  726. #define CoreDebug_DEMCR_VC_HARDERR_Msk (1UL << CoreDebug_DEMCR_VC_HARDERR_Pos) /*!< CoreDebug DEMCR: VC_HARDERR Mask */
  727. #define CoreDebug_DEMCR_VC_INTERR_Pos 9 /*!< CoreDebug DEMCR: VC_INTERR Position */
  728. #define CoreDebug_DEMCR_VC_INTERR_Msk (1UL << CoreDebug_DEMCR_VC_INTERR_Pos) /*!< CoreDebug DEMCR: VC_INTERR Mask */
  729. #define CoreDebug_DEMCR_VC_BUSERR_Pos 8 /*!< CoreDebug DEMCR: VC_BUSERR Position */
  730. #define CoreDebug_DEMCR_VC_BUSERR_Msk (1UL << CoreDebug_DEMCR_VC_BUSERR_Pos) /*!< CoreDebug DEMCR: VC_BUSERR Mask */
  731. #define CoreDebug_DEMCR_VC_STATERR_Pos 7 /*!< CoreDebug DEMCR: VC_STATERR Position */
  732. #define CoreDebug_DEMCR_VC_STATERR_Msk (1UL << CoreDebug_DEMCR_VC_STATERR_Pos) /*!< CoreDebug DEMCR: VC_STATERR Mask */
  733. #define CoreDebug_DEMCR_VC_CHKERR_Pos 6 /*!< CoreDebug DEMCR: VC_CHKERR Position */
  734. #define CoreDebug_DEMCR_VC_CHKERR_Msk (1UL << CoreDebug_DEMCR_VC_CHKERR_Pos) /*!< CoreDebug DEMCR: VC_CHKERR Mask */
  735. #define CoreDebug_DEMCR_VC_NOCPERR_Pos 5 /*!< CoreDebug DEMCR: VC_NOCPERR Position */
  736. #define CoreDebug_DEMCR_VC_NOCPERR_Msk (1UL << CoreDebug_DEMCR_VC_NOCPERR_Pos) /*!< CoreDebug DEMCR: VC_NOCPERR Mask */
  737. #define CoreDebug_DEMCR_VC_MMERR_Pos 4 /*!< CoreDebug DEMCR: VC_MMERR Position */
  738. #define CoreDebug_DEMCR_VC_MMERR_Msk (1UL << CoreDebug_DEMCR_VC_MMERR_Pos) /*!< CoreDebug DEMCR: VC_MMERR Mask */
  739. #define CoreDebug_DEMCR_VC_CORERESET_Pos 0 /*!< CoreDebug DEMCR: VC_CORERESET Position */
  740. #define CoreDebug_DEMCR_VC_CORERESET_Msk (1UL << CoreDebug_DEMCR_VC_CORERESET_Pos) /*!< CoreDebug DEMCR: VC_CORERESET Mask */
  741. /*@} end of group CMSIS_CoreDebug */
  742. /** \ingroup CMSIS_core_register
  743. @{
  744. */
  745. /* Memory mapping of Cortex-M4 Hardware */
  746. #define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */
  747. #define ITM_BASE (0xE0000000UL) /*!< ITM Base Address */
  748. #define CoreDebug_BASE (0xE000EDF0UL) /*!< Core Debug Base Address */
  749. #define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */
  750. #define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */
  751. #define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */
  752. #define SCnSCB ((SCnSCB_Type *) SCS_BASE ) /*!< System control Register not in SCB */
  753. #define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */
  754. #define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */
  755. #define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */
  756. #define ITM ((ITM_Type *) ITM_BASE ) /*!< ITM configuration struct */
  757. #define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE) /*!< Core Debug configuration struct */
  758. #if (__MPU_PRESENT == 1)
  759. #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */
  760. #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */
  761. #endif
  762. #if (__FPU_PRESENT == 1)
  763. #define FPU_BASE (SCS_BASE + 0x0F30UL) /*!< Floating Point Unit */
  764. #define FPU ((FPU_Type *) FPU_BASE ) /*!< Floating Point Unit */
  765. #endif
  766. /*@} */
  767. /*******************************************************************************
  768. * Hardware Abstraction Layer
  769. ******************************************************************************/
  770. /** \defgroup CMSIS_Core_FunctionInterface CMSIS Core Function Interface
  771. Core Function Interface contains:
  772. - Core NVIC Functions
  773. - Core SysTick Functions
  774. - Core Debug Functions
  775. - Core Register Access Functions
  776. */
  777. /* ########################## NVIC functions #################################### */
  778. /** \ingroup CMSIS_Core_FunctionInterface
  779. \defgroup CMSIS_Core_NVICFunctions CMSIS Core NVIC Functions
  780. @{
  781. */
  782. /** \brief Set Priority Grouping
  783. This function sets the priority grouping field using the required unlock sequence.
  784. The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field.
  785. Only values from 0..7 are used.
  786. In case of a conflict between priority grouping and available
  787. priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set.
  788. \param [in] PriorityGroup Priority grouping field
  789. */
  790. static __INLINE void NVIC_SetPriorityGrouping(uint32_t PriorityGroup)
  791. {
  792. uint32_t reg_value;
  793. uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07); /* only values 0..7 are used */
  794. reg_value = SCB->AIRCR; /* read old register configuration */
  795. reg_value &= ~(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk); /* clear bits to change */
  796. reg_value = (reg_value |
  797. ((uint32_t)0x5FA << SCB_AIRCR_VECTKEY_Pos) |
  798. (PriorityGroupTmp << 8)); /* Insert write key and priorty group */
  799. SCB->AIRCR = reg_value;
  800. }
  801. /** \brief Get Priority Grouping
  802. This function gets the priority grouping from NVIC Interrupt Controller.
  803. Priority grouping is SCB->AIRCR [10:8] PRIGROUP field.
  804. \return Priority grouping field
  805. */
  806. static __INLINE uint32_t NVIC_GetPriorityGrouping(void)
  807. {
  808. return ((SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos); /* read priority grouping field */
  809. }
  810. /** \brief Enable External Interrupt
  811. This function enables a device specific interrupt in the NVIC interrupt controller.
  812. The interrupt number cannot be a negative value.
  813. \param [in] IRQn Number of the external interrupt to enable
  814. */
  815. static __INLINE void NVIC_EnableIRQ(IRQn_Type IRQn)
  816. {
  817. /* NVIC->ISER[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F)); enable interrupt */
  818. NVIC->ISER[(uint32_t)((int32_t)IRQn) >> 5] = (uint32_t)(1 << ((uint32_t)((int32_t)IRQn) & (uint32_t)0x1F)); /* enable interrupt */
  819. }
  820. /** \brief Disable External Interrupt
  821. This function disables a device specific interrupt in the NVIC interrupt controller.
  822. The interrupt number cannot be a negative value.
  823. \param [in] IRQn Number of the external interrupt to disable
  824. */
  825. static __INLINE void NVIC_DisableIRQ(IRQn_Type IRQn)
  826. {
  827. NVIC->ICER[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F)); /* disable interrupt */
  828. }
  829. /** \brief Get Pending Interrupt
  830. This function reads the pending register in the NVIC and returns the pending bit
  831. for the specified interrupt.
  832. \param [in] IRQn Number of the interrupt for get pending
  833. \return 0 Interrupt status is not pending
  834. \return 1 Interrupt status is pending
  835. */
  836. static __INLINE uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn)
  837. {
  838. return((uint32_t) ((NVIC->ISPR[(uint32_t)(IRQn) >> 5] & (1 << ((uint32_t)(IRQn) & 0x1F)))?1:0)); /* Return 1 if pending else 0 */
  839. }
  840. /** \brief Set Pending Interrupt
  841. This function sets the pending bit for the specified interrupt.
  842. The interrupt number cannot be a negative value.
  843. \param [in] IRQn Number of the interrupt for set pending
  844. */
  845. static __INLINE void NVIC_SetPendingIRQ(IRQn_Type IRQn)
  846. {
  847. NVIC->ISPR[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F)); /* set interrupt pending */
  848. }
  849. /** \brief Clear Pending Interrupt
  850. This function clears the pending bit for the specified interrupt.
  851. The interrupt number cannot be a negative value.
  852. \param [in] IRQn Number of the interrupt for clear pending
  853. */
  854. static __INLINE void NVIC_ClearPendingIRQ(IRQn_Type IRQn)
  855. {
  856. NVIC->ICPR[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F)); /* Clear pending interrupt */
  857. }
  858. /** \brief Get Active Interrupt
  859. This function reads the active register in NVIC and returns the active bit.
  860. \param [in] IRQn Number of the interrupt for get active
  861. \return 0 Interrupt status is not active
  862. \return 1 Interrupt status is active
  863. */
  864. static __INLINE uint32_t NVIC_GetActive(IRQn_Type IRQn)
  865. {
  866. return((uint32_t)((NVIC->IABR[(uint32_t)(IRQn) >> 5] & (1 << ((uint32_t)(IRQn) & 0x1F)))?1:0)); /* Return 1 if active else 0 */
  867. }
  868. /** \brief Set Interrupt Priority
  869. This function sets the priority for the specified interrupt. The interrupt
  870. number can be positive to specify an external (device specific)
  871. interrupt, or negative to specify an internal (core) interrupt.
  872. Note: The priority cannot be set for every core interrupt.
  873. \param [in] IRQn Number of the interrupt for set priority
  874. \param [in] priority Priority to set
  875. */
  876. static __INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority)
  877. {
  878. if(IRQn < 0) {
  879. SCB->SHP[((uint32_t)(IRQn) & 0xF)-4] = ((priority << (8 - __NVIC_PRIO_BITS)) & 0xff); } /* set Priority for Cortex-M System Interrupts */
  880. else {
  881. NVIC->IP[(uint32_t)(IRQn)] = ((priority << (8 - __NVIC_PRIO_BITS)) & 0xff); } /* set Priority for device specific Interrupts */
  882. }
  883. /** \brief Get Interrupt Priority
  884. This function reads the priority for the specified interrupt. The interrupt
  885. number can be positive to specify an external (device specific)
  886. interrupt, or negative to specify an internal (core) interrupt.
  887. The returned priority value is automatically aligned to the implemented
  888. priority bits of the microcontroller.
  889. \param [in] IRQn Number of the interrupt for get priority
  890. \return Interrupt Priority
  891. */
  892. static __INLINE uint32_t NVIC_GetPriority(IRQn_Type IRQn)
  893. {
  894. if(IRQn < 0) {
  895. return((uint32_t)(SCB->SHP[((uint32_t)(IRQn) & 0xF)-4] >> (8 - __NVIC_PRIO_BITS))); } /* get priority for Cortex-M system interrupts */
  896. else {
  897. return((uint32_t)(NVIC->IP[(uint32_t)(IRQn)] >> (8 - __NVIC_PRIO_BITS))); } /* get priority for device specific interrupts */
  898. }
  899. /** \brief Encode Priority
  900. This function encodes the priority for an interrupt with the given priority group,
  901. preemptive priority value and sub priority value.
  902. In case of a conflict between priority grouping and available
  903. priority bits (__NVIC_PRIO_BITS) the samllest possible priority group is set.
  904. The returned priority value can be used for NVIC_SetPriority(...) function
  905. \param [in] PriorityGroup Used priority group
  906. \param [in] PreemptPriority Preemptive priority value (starting from 0)
  907. \param [in] SubPriority Sub priority value (starting from 0)
  908. \return Encoded priority for the interrupt
  909. */
  910. static __INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority)
  911. {
  912. uint32_t PriorityGroupTmp = (PriorityGroup & 0x07); /* only values 0..7 are used */
  913. uint32_t PreemptPriorityBits;
  914. uint32_t SubPriorityBits;
  915. PreemptPriorityBits = ((7 - PriorityGroupTmp) > __NVIC_PRIO_BITS) ? __NVIC_PRIO_BITS : 7 - PriorityGroupTmp;
  916. SubPriorityBits = ((PriorityGroupTmp + __NVIC_PRIO_BITS) < 7) ? 0 : PriorityGroupTmp - 7 + __NVIC_PRIO_BITS;
  917. return (
  918. ((PreemptPriority & ((1 << (PreemptPriorityBits)) - 1)) << SubPriorityBits) |
  919. ((SubPriority & ((1 << (SubPriorityBits )) - 1)))
  920. );
  921. }
  922. /** \brief Decode Priority
  923. This function decodes an interrupt priority value with the given priority group to
  924. preemptive priority value and sub priority value.
  925. In case of a conflict between priority grouping and available
  926. priority bits (__NVIC_PRIO_BITS) the samllest possible priority group is set.
  927. The priority value can be retrieved with NVIC_GetPriority(...) function
  928. \param [in] Priority Priority value
  929. \param [in] PriorityGroup Used priority group
  930. \param [out] pPreemptPriority Preemptive priority value (starting from 0)
  931. \param [out] pSubPriority Sub priority value (starting from 0)
  932. */
  933. static __INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* pPreemptPriority, uint32_t* pSubPriority)
  934. {
  935. uint32_t PriorityGroupTmp = (PriorityGroup & 0x07); /* only values 0..7 are used */
  936. uint32_t PreemptPriorityBits;
  937. uint32_t SubPriorityBits;
  938. PreemptPriorityBits = ((7 - PriorityGroupTmp) > __NVIC_PRIO_BITS) ? __NVIC_PRIO_BITS : 7 - PriorityGroupTmp;
  939. SubPriorityBits = ((PriorityGroupTmp + __NVIC_PRIO_BITS) < 7) ? 0 : PriorityGroupTmp - 7 + __NVIC_PRIO_BITS;
  940. *pPreemptPriority = (Priority >> SubPriorityBits) & ((1 << (PreemptPriorityBits)) - 1);
  941. *pSubPriority = (Priority ) & ((1 << (SubPriorityBits )) - 1);
  942. }
  943. /** \brief System Reset
  944. This function initiate a system reset request to reset the MCU.
  945. */
  946. static __INLINE void NVIC_SystemReset(void)
  947. {
  948. __DSB(); /* Ensure all outstanding memory accesses included
  949. buffered write are completed before reset */
  950. SCB->AIRCR = ((0x5FA << SCB_AIRCR_VECTKEY_Pos) |
  951. (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) |
  952. SCB_AIRCR_SYSRESETREQ_Msk); /* Keep priority group unchanged */
  953. __DSB(); /* Ensure completion of memory access */
  954. while(1); /* wait until reset */
  955. }
  956. /*@} end of CMSIS_Core_NVICFunctions */
  957. /* ################################## SysTick function ############################################ */
  958. /** \ingroup CMSIS_Core_FunctionInterface
  959. \defgroup CMSIS_Core_SysTickFunctions CMSIS Core SysTick Functions
  960. @{
  961. */
  962. #if (__Vendor_SysTickConfig == 0)
  963. /** \brief System Tick Configuration
  964. This function initialises the system tick timer and its interrupt and start the system tick timer.
  965. Counter is in free running mode to generate periodical interrupts.
  966. \param [in] ticks Number of ticks between two interrupts
  967. \return 0 Function succeeded
  968. \return 1 Function failed
  969. */
  970. static __INLINE uint32_t SysTick_Config(uint32_t ticks)
  971. {
  972. if (ticks > SysTick_LOAD_RELOAD_Msk) return (1); /* Reload value impossible */
  973. SysTick->LOAD = (ticks & SysTick_LOAD_RELOAD_Msk) - 1; /* set reload register */
  974. NVIC_SetPriority (SysTick_IRQn, (1<<__NVIC_PRIO_BITS) - 1); /* set Priority for Cortex-M0 System Interrupts */
  975. SysTick->VAL = 0; /* Load the SysTick Counter Value */
  976. SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk |
  977. SysTick_CTRL_TICKINT_Msk |
  978. SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */
  979. return (0); /* Function successful */
  980. }
  981. #endif
  982. /*@} end of CMSIS_Core_SysTickFunctions */
  983. /* ##################################### Debug In/Output function ########################################### */
  984. /** \ingroup CMSIS_Core_FunctionInterface
  985. \defgroup CMSIS_core_DebugFunctions CMSIS Core Debug Functions
  986. @{
  987. */
  988. extern volatile int32_t ITM_RxBuffer; /*!< external variable to receive characters */
  989. #define ITM_RXBUFFER_EMPTY 0x5AA55AA5 /*!< value identifying ITM_RxBuffer is ready for next character */
  990. /** \brief ITM Send Character
  991. This function transmits a character via the ITM channel 0.
  992. It just returns when no debugger is connected that has booked the output.
  993. It is blocking when a debugger is connected, but the previous character send is not transmitted.
  994. \param [in] ch Character to transmit
  995. \return Character to transmit
  996. */
  997. static __INLINE uint32_t ITM_SendChar (uint32_t ch)
  998. {
  999. if ((CoreDebug->DEMCR & CoreDebug_DEMCR_TRCENA_Msk) && /* Trace enabled */
  1000. (ITM->TCR & ITM_TCR_ITMENA_Msk) && /* ITM enabled */
  1001. (ITM->TER & (1UL << 0) ) ) /* ITM Port #0 enabled */
  1002. {
  1003. while (ITM->PORT[0].u32 == 0);
  1004. ITM->PORT[0].u8 = (uint8_t) ch;
  1005. }
  1006. return (ch);
  1007. }
  1008. /** \brief ITM Receive Character
  1009. This function inputs a character via external variable ITM_RxBuffer.
  1010. It just returns when no debugger is connected that has booked the output.
  1011. It is blocking when a debugger is connected, but the previous character send is not transmitted.
  1012. \return Received character
  1013. \return -1 No character received
  1014. */
  1015. static __INLINE int32_t ITM_ReceiveChar (void) {
  1016. int32_t ch = -1; /* no character available */
  1017. if (ITM_RxBuffer != ITM_RXBUFFER_EMPTY) {
  1018. ch = ITM_RxBuffer;
  1019. ITM_RxBuffer = ITM_RXBUFFER_EMPTY; /* ready for next character */
  1020. }
  1021. return (ch);
  1022. }
  1023. /** \brief ITM Check Character
  1024. This function checks external variable ITM_RxBuffer whether a character is available or not.
  1025. It returns '1' if a character is available and '0' if no character is available.
  1026. \return 0 No character available
  1027. \return 1 Character available
  1028. */
  1029. static __INLINE int32_t ITM_CheckChar (void) {
  1030. if (ITM_RxBuffer == ITM_RXBUFFER_EMPTY) {
  1031. return (0); /* no character available */
  1032. } else {
  1033. return (1); /* character available */
  1034. }
  1035. }
  1036. /*@} end of CMSIS_core_DebugFunctions */
  1037. #endif /* __CORE_CM4_H_DEPENDANT */
  1038. #endif /* __CMSIS_GENERIC */
  1039. #ifdef __cplusplus
  1040. }
  1041. #endif