core_cm0plus.h 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029
  1. /**************************************************************************//**
  2. * @file core_cm0plus.h
  3. * @brief CMSIS Cortex-M0+ Core Peripheral Access Layer Header File
  4. * @version V5.00
  5. * @date 29. June 2016
  6. ******************************************************************************/
  7. /*
  8. * Copyright (c) 2009-2016 ARM Limited. All rights reserved.
  9. *
  10. * SPDX-License-Identifier: Apache-2.0
  11. *
  12. * Licensed under the Apache License, Version 2.0 (the License); you may
  13. * not use this file except in compliance with the License.
  14. * You may obtain a copy of the License at
  15. *
  16. * http://www.apache.org/licenses/LICENSE-2.0
  17. *
  18. * Unless required by applicable law or agreed to in writing, software
  19. * distributed under the License is distributed on an AS IS BASIS, WITHOUT
  20. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  21. * See the License for the specific language governing permissions and
  22. * limitations under the License.
  23. */
  24. #if defined ( __ICCARM__ )
  25. #pragma system_include /* treat file as system include file for MISRA check */
  26. #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
  27. #pragma clang system_header /* treat file as system include file */
  28. #endif
  29. #ifndef __CORE_CM0PLUS_H_GENERIC
  30. #define __CORE_CM0PLUS_H_GENERIC
  31. #include <stdint.h>
  32. #ifdef __cplusplus
  33. extern "C" {
  34. #endif
  35. /**
  36. \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions
  37. CMSIS violates the following MISRA-C:2004 rules:
  38. \li Required Rule 8.5, object/function definition in header file.<br>
  39. Function definitions in header files are used to allow 'inlining'.
  40. \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.<br>
  41. Unions are used for effective representation of core registers.
  42. \li Advisory Rule 19.7, Function-like macro defined.<br>
  43. Function-like macros are used to allow more efficient code.
  44. */
  45. /*******************************************************************************
  46. * CMSIS definitions
  47. ******************************************************************************/
  48. /**
  49. \ingroup Cortex-M0+
  50. @{
  51. */
  52. /* CMSIS CM0+ definitions */
  53. #define __CM0PLUS_CMSIS_VERSION_MAIN ( 5U) /*!< [31:16] CMSIS HAL main version */
  54. #define __CM0PLUS_CMSIS_VERSION_SUB ( 0U) /*!< [15:0] CMSIS HAL sub version */
  55. #define __CM0PLUS_CMSIS_VERSION ((__CM0PLUS_CMSIS_VERSION_MAIN << 16U) | \
  56. __CM0PLUS_CMSIS_VERSION_SUB ) /*!< CMSIS HAL version number */
  57. #define __CORTEX_M (0U) /*!< Cortex-M Core */
  58. /* Common defines in core_*.h files
  59. - #define __ASM Compiler keyword for asm
  60. - #define __INLINE Compiler keyword for inline
  61. - #define __STATIC_INLINE Compiler keyword for static inline
  62. - #define __NO_RETURN function that never returns
  63. - #define __USED function or variable that is not optimized away
  64. - #define __WEAK weak function or variable
  65. - #define __UNALIGNED_UINT32 pointer to unaligned uint32_t variable
  66. - #define __ALIGNED(x) compiler keyword to align a variable
  67. */
  68. #if defined ( __CC_ARM ) /* ARM Compiler 4/5 */
  69. #define __ASM __asm
  70. #define __INLINE __inline
  71. #define __STATIC_INLINE static __inline
  72. #define __NO_RETURN __declspec(noreturn)
  73. #define __USED __attribute__((used))
  74. #define __WEAK __attribute__((weak))
  75. #define __UNALIGNED_UINT32(x) (*((__packed uint32_t *)(x)))
  76. #define __ALIGNED(x) __attribute__((aligned(x)))
  77. #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) /* ARM Compiler 6 */
  78. #define __ASM __asm
  79. #define __INLINE __inline
  80. #define __STATIC_INLINE static __inline
  81. #define __NO_RETURN __attribute__((noreturn))
  82. #define __USED __attribute__((used))
  83. #define __WEAK __attribute__((weak))
  84. #pragma clang diagnostic push
  85. #pragma clang diagnostic ignored "-Wpacked"
  86. struct __attribute__((packed)) T_UINT32 { uint32_t v; };
  87. #pragma clang diagnostic pop
  88. #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
  89. #define __ALIGNED(x) __attribute__((aligned(x)))
  90. #elif defined ( __GNUC__ ) /* GNU Compiler */
  91. #define __ASM __asm
  92. #define __INLINE inline
  93. #define __STATIC_INLINE static inline
  94. #define __NO_RETURN __attribute__((noreturn))
  95. #define __USED __attribute__((used))
  96. #define __WEAK __attribute__((weak))
  97. struct __attribute__((packed)) T_UINT32 { uint32_t v; };
  98. #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
  99. #define __ALIGNED(x) __attribute__((aligned(x)))
  100. #elif defined ( __ICCARM__ ) /* IAR Compiler */
  101. #define __ASM __asm
  102. #define __INLINE inline
  103. #define __STATIC_INLINE static inline
  104. #define __NO_RETURN __noreturn
  105. #define __USED
  106. #define __WEAK __weak
  107. struct __packed T_UINT32 { uint32_t v; };
  108. #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
  109. #define __ALIGNED(x)
  110. #elif defined ( __TI_ARM__ ) /* TI ARM Compiler */
  111. #define __ASM __asm
  112. #define __INLINE inline
  113. #define __STATIC_INLINE static inline
  114. #define __NO_RETURN __attribute__((noreturn))
  115. #define __USED __attribute__((used))
  116. #define __WEAK __attribute__((weak))
  117. struct __attribute__((packed)) T_UINT32 { uint32_t v; };
  118. #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
  119. #define __ALIGNED(x)
  120. #elif defined ( __TASKING__ ) /* TASKING Compiler */
  121. #define __ASM __asm
  122. #define __INLINE inline
  123. #define __STATIC_INLINE static inline
  124. #define __NO_RETURN __attribute__((noreturn))
  125. #define __USED __attribute__((used))
  126. #define __WEAK __attribute__((weak))
  127. struct __packed__ T_UINT32 { uint32_t v; };
  128. #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
  129. #define __ALIGNED(x) __align(x)
  130. #elif defined ( __CSMC__ ) /* COSMIC Compiler */
  131. #define __packed
  132. #define __ASM _asm
  133. #define __INLINE inline
  134. #define __STATIC_INLINE static inline
  135. #define __NO_RETURN
  136. #define __USED
  137. #define __WEAK
  138. #define __UNALIGNED_UINT32(x) (*x)
  139. #define __ALIGNED(x)
  140. #else
  141. #error Unknown compiler
  142. #endif
  143. /** __FPU_USED indicates whether an FPU is used or not.
  144. This core does not support an FPU at all
  145. */
  146. #define __FPU_USED 0U
  147. #if defined ( __CC_ARM )
  148. #if defined __TARGET_FPU_VFP
  149. #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
  150. #endif
  151. #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
  152. #if defined __ARM_PCS_VFP
  153. #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
  154. #endif
  155. #elif defined ( __GNUC__ )
  156. #if defined (__VFP_FP__) && !defined(__SOFTFP__)
  157. #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
  158. #endif
  159. #elif defined ( __ICCARM__ )
  160. #if defined __ARMVFP__
  161. #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
  162. #endif
  163. #elif defined ( __TI_ARM__ )
  164. #if defined __TI_VFP_SUPPORT__
  165. #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
  166. #endif
  167. #elif defined ( __TASKING__ )
  168. #if defined __FPU_VFP__
  169. #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
  170. #endif
  171. #elif defined ( __CSMC__ )
  172. #if ( __CSMC__ & 0x400U)
  173. #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
  174. #endif
  175. #endif
  176. #include "core_cminstr.h" /* Core Instruction Access */
  177. #include "core_cmfunc.h" /* Core Function Access */
  178. #ifdef __cplusplus
  179. }
  180. #endif
  181. #endif /* __CORE_CM0PLUS_H_GENERIC */
  182. #ifndef __CMSIS_GENERIC
  183. #ifndef __CORE_CM0PLUS_H_DEPENDANT
  184. #define __CORE_CM0PLUS_H_DEPENDANT
  185. #ifdef __cplusplus
  186. extern "C" {
  187. #endif
  188. /* check device defines and use defaults */
  189. #if defined __CHECK_DEVICE_DEFINES
  190. #ifndef __CM0PLUS_REV
  191. #define __CM0PLUS_REV 0x0000U
  192. #warning "__CM0PLUS_REV not defined in device header file; using default!"
  193. #endif
  194. #ifndef __MPU_PRESENT
  195. #define __MPU_PRESENT 0U
  196. #warning "__MPU_PRESENT not defined in device header file; using default!"
  197. #endif
  198. #ifndef __VTOR_PRESENT
  199. #define __VTOR_PRESENT 0U
  200. #warning "__VTOR_PRESENT not defined in device header file; using default!"
  201. #endif
  202. #ifndef __NVIC_PRIO_BITS
  203. #define __NVIC_PRIO_BITS 2U
  204. #warning "__NVIC_PRIO_BITS not defined in device header file; using default!"
  205. #endif
  206. #ifndef __Vendor_SysTickConfig
  207. #define __Vendor_SysTickConfig 0U
  208. #warning "__Vendor_SysTickConfig not defined in device header file; using default!"
  209. #endif
  210. #endif
  211. /* IO definitions (access restrictions to peripheral registers) */
  212. /**
  213. \defgroup CMSIS_glob_defs CMSIS Global Defines
  214. <strong>IO Type Qualifiers</strong> are used
  215. \li to specify the access to peripheral variables.
  216. \li for automatic generation of peripheral register debug information.
  217. */
  218. #ifdef __cplusplus
  219. #define __I volatile /*!< Defines 'read only' permissions */
  220. #else
  221. #define __I volatile const /*!< Defines 'read only' permissions */
  222. #endif
  223. #define __O volatile /*!< Defines 'write only' permissions */
  224. #define __IO volatile /*!< Defines 'read / write' permissions */
  225. /* following defines should be used for structure members */
  226. #define __IM volatile const /*! Defines 'read only' structure member permissions */
  227. #define __OM volatile /*! Defines 'write only' structure member permissions */
  228. #define __IOM volatile /*! Defines 'read / write' structure member permissions */
  229. /*@} end of group Cortex-M0+ */
  230. /*******************************************************************************
  231. * Register Abstraction
  232. Core Register contain:
  233. - Core Register
  234. - Core NVIC Register
  235. - Core SCB Register
  236. - Core SysTick Register
  237. - Core MPU Register
  238. ******************************************************************************/
  239. /**
  240. \defgroup CMSIS_core_register Defines and Type Definitions
  241. \brief Type definitions and defines for Cortex-M processor based devices.
  242. */
  243. /**
  244. \ingroup CMSIS_core_register
  245. \defgroup CMSIS_CORE Status and Control Registers
  246. \brief Core Register type definitions.
  247. @{
  248. */
  249. /**
  250. \brief Union type to access the Application Program Status Register (APSR).
  251. */
  252. typedef union
  253. {
  254. struct
  255. {
  256. uint32_t _reserved0:28; /*!< bit: 0..27 Reserved */
  257. uint32_t V:1; /*!< bit: 28 Overflow condition code flag */
  258. uint32_t C:1; /*!< bit: 29 Carry condition code flag */
  259. uint32_t Z:1; /*!< bit: 30 Zero condition code flag */
  260. uint32_t N:1; /*!< bit: 31 Negative condition code flag */
  261. } b; /*!< Structure used for bit access */
  262. uint32_t w; /*!< Type used for word access */
  263. } APSR_Type;
  264. /* APSR Register Definitions */
  265. #define APSR_N_Pos 31U /*!< APSR: N Position */
  266. #define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */
  267. #define APSR_Z_Pos 30U /*!< APSR: Z Position */
  268. #define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */
  269. #define APSR_C_Pos 29U /*!< APSR: C Position */
  270. #define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */
  271. #define APSR_V_Pos 28U /*!< APSR: V Position */
  272. #define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */
  273. /**
  274. \brief Union type to access the Interrupt Program Status Register (IPSR).
  275. */
  276. typedef union
  277. {
  278. struct
  279. {
  280. uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */
  281. uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */
  282. } b; /*!< Structure used for bit access */
  283. uint32_t w; /*!< Type used for word access */
  284. } IPSR_Type;
  285. /* IPSR Register Definitions */
  286. #define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */
  287. #define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */
  288. /**
  289. \brief Union type to access the Special-Purpose Program Status Registers (xPSR).
  290. */
  291. typedef union
  292. {
  293. struct
  294. {
  295. uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */
  296. uint32_t _reserved0:15; /*!< bit: 9..23 Reserved */
  297. uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */
  298. uint32_t _reserved1:3; /*!< bit: 25..27 Reserved */
  299. uint32_t V:1; /*!< bit: 28 Overflow condition code flag */
  300. uint32_t C:1; /*!< bit: 29 Carry condition code flag */
  301. uint32_t Z:1; /*!< bit: 30 Zero condition code flag */
  302. uint32_t N:1; /*!< bit: 31 Negative condition code flag */
  303. } b; /*!< Structure used for bit access */
  304. uint32_t w; /*!< Type used for word access */
  305. } xPSR_Type;
  306. /* xPSR Register Definitions */
  307. #define xPSR_N_Pos 31U /*!< xPSR: N Position */
  308. #define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */
  309. #define xPSR_Z_Pos 30U /*!< xPSR: Z Position */
  310. #define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */
  311. #define xPSR_C_Pos 29U /*!< xPSR: C Position */
  312. #define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */
  313. #define xPSR_V_Pos 28U /*!< xPSR: V Position */
  314. #define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */
  315. #define xPSR_T_Pos 24U /*!< xPSR: T Position */
  316. #define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */
  317. #define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */
  318. #define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */
  319. /**
  320. \brief Union type to access the Control Registers (CONTROL).
  321. */
  322. typedef union
  323. {
  324. struct
  325. {
  326. uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */
  327. uint32_t SPSEL:1; /*!< bit: 1 Stack to be used */
  328. uint32_t _reserved1:30; /*!< bit: 2..31 Reserved */
  329. } b; /*!< Structure used for bit access */
  330. uint32_t w; /*!< Type used for word access */
  331. } CONTROL_Type;
  332. /* CONTROL Register Definitions */
  333. #define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */
  334. #define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */
  335. #define CONTROL_nPRIV_Pos 0U /*!< CONTROL: nPRIV Position */
  336. #define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */
  337. /*@} end of group CMSIS_CORE */
  338. /**
  339. \ingroup CMSIS_core_register
  340. \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC)
  341. \brief Type definitions for the NVIC Registers
  342. @{
  343. */
  344. /**
  345. \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC).
  346. */
  347. typedef struct
  348. {
  349. __IOM uint32_t ISER[1U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */
  350. uint32_t RESERVED0[31U];
  351. __IOM uint32_t ICER[1U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */
  352. uint32_t RSERVED1[31U];
  353. __IOM uint32_t ISPR[1U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */
  354. uint32_t RESERVED2[31U];
  355. __IOM uint32_t ICPR[1U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */
  356. uint32_t RESERVED3[31U];
  357. uint32_t RESERVED4[64U];
  358. __IOM uint32_t IP[8U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register */
  359. } NVIC_Type;
  360. /*@} end of group CMSIS_NVIC */
  361. /**
  362. \ingroup CMSIS_core_register
  363. \defgroup CMSIS_SCB System Control Block (SCB)
  364. \brief Type definitions for the System Control Block Registers
  365. @{
  366. */
  367. /**
  368. \brief Structure type to access the System Control Block (SCB).
  369. */
  370. typedef struct
  371. {
  372. __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */
  373. __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */
  374. #if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1U)
  375. __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */
  376. #else
  377. uint32_t RESERVED0;
  378. #endif
  379. __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */
  380. __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */
  381. __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */
  382. uint32_t RESERVED1;
  383. __IOM uint32_t SHP[2U]; /*!< Offset: 0x01C (R/W) System Handlers Priority Registers. [0] is RESERVED */
  384. __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */
  385. } SCB_Type;
  386. /* SCB CPUID Register Definitions */
  387. #define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */
  388. #define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */
  389. #define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */
  390. #define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */
  391. #define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */
  392. #define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */
  393. #define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */
  394. #define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */
  395. #define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */
  396. #define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */
  397. /* SCB Interrupt Control State Register Definitions */
  398. #define SCB_ICSR_NMIPENDSET_Pos 31U /*!< SCB ICSR: NMIPENDSET Position */
  399. #define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */
  400. #define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */
  401. #define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */
  402. #define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */
  403. #define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */
  404. #define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */
  405. #define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */
  406. #define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */
  407. #define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */
  408. #define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */
  409. #define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */
  410. #define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */
  411. #define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */
  412. #define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */
  413. #define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */
  414. #define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */
  415. #define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */
  416. #if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1U)
  417. /* SCB Interrupt Control State Register Definitions */
  418. #define SCB_VTOR_TBLOFF_Pos 8U /*!< SCB VTOR: TBLOFF Position */
  419. #define SCB_VTOR_TBLOFF_Msk (0xFFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */
  420. #endif
  421. /* SCB Application Interrupt and Reset Control Register Definitions */
  422. #define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */
  423. #define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */
  424. #define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */
  425. #define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */
  426. #define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */
  427. #define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */
  428. #define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */
  429. #define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */
  430. #define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */
  431. #define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */
  432. /* SCB System Control Register Definitions */
  433. #define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */
  434. #define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */
  435. #define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */
  436. #define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */
  437. #define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */
  438. #define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */
  439. /* SCB Configuration Control Register Definitions */
  440. #define SCB_CCR_STKALIGN_Pos 9U /*!< SCB CCR: STKALIGN Position */
  441. #define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */
  442. #define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */
  443. #define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */
  444. /* SCB System Handler Control and State Register Definitions */
  445. #define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */
  446. #define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */
  447. /*@} end of group CMSIS_SCB */
  448. /**
  449. \ingroup CMSIS_core_register
  450. \defgroup CMSIS_SysTick System Tick Timer (SysTick)
  451. \brief Type definitions for the System Timer Registers.
  452. @{
  453. */
  454. /**
  455. \brief Structure type to access the System Timer (SysTick).
  456. */
  457. typedef struct
  458. {
  459. __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */
  460. __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */
  461. __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */
  462. __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */
  463. } SysTick_Type;
  464. /* SysTick Control / Status Register Definitions */
  465. #define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */
  466. #define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */
  467. #define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */
  468. #define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */
  469. #define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */
  470. #define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */
  471. #define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */
  472. #define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */
  473. /* SysTick Reload Register Definitions */
  474. #define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */
  475. #define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */
  476. /* SysTick Current Register Definitions */
  477. #define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */
  478. #define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */
  479. /* SysTick Calibration Register Definitions */
  480. #define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */
  481. #define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */
  482. #define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */
  483. #define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */
  484. #define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */
  485. #define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */
  486. /*@} end of group CMSIS_SysTick */
  487. #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U)
  488. /**
  489. \ingroup CMSIS_core_register
  490. \defgroup CMSIS_MPU Memory Protection Unit (MPU)
  491. \brief Type definitions for the Memory Protection Unit (MPU)
  492. @{
  493. */
  494. /**
  495. \brief Structure type to access the Memory Protection Unit (MPU).
  496. */
  497. typedef struct
  498. {
  499. __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */
  500. __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */
  501. __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region RNRber Register */
  502. __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */
  503. __IOM uint32_t RASR; /*!< Offset: 0x010 (R/W) MPU Region Attribute and Size Register */
  504. } MPU_Type;
  505. /* MPU Type Register Definitions */
  506. #define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */
  507. #define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */
  508. #define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */
  509. #define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */
  510. #define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */
  511. #define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */
  512. /* MPU Control Register Definitions */
  513. #define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */
  514. #define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */
  515. #define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */
  516. #define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */
  517. #define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */
  518. #define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */
  519. /* MPU Region Number Register Definitions */
  520. #define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */
  521. #define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */
  522. /* MPU Region Base Address Register Definitions */
  523. #define MPU_RBAR_ADDR_Pos 8U /*!< MPU RBAR: ADDR Position */
  524. #define MPU_RBAR_ADDR_Msk (0xFFFFFFUL << MPU_RBAR_ADDR_Pos) /*!< MPU RBAR: ADDR Mask */
  525. #define MPU_RBAR_VALID_Pos 4U /*!< MPU RBAR: VALID Position */
  526. #define MPU_RBAR_VALID_Msk (1UL << MPU_RBAR_VALID_Pos) /*!< MPU RBAR: VALID Mask */
  527. #define MPU_RBAR_REGION_Pos 0U /*!< MPU RBAR: REGION Position */
  528. #define MPU_RBAR_REGION_Msk (0xFUL /*<< MPU_RBAR_REGION_Pos*/) /*!< MPU RBAR: REGION Mask */
  529. /* MPU Region Attribute and Size Register Definitions */
  530. #define MPU_RASR_ATTRS_Pos 16U /*!< MPU RASR: MPU Region Attribute field Position */
  531. #define MPU_RASR_ATTRS_Msk (0xFFFFUL << MPU_RASR_ATTRS_Pos) /*!< MPU RASR: MPU Region Attribute field Mask */
  532. #define MPU_RASR_XN_Pos 28U /*!< MPU RASR: ATTRS.XN Position */
  533. #define MPU_RASR_XN_Msk (1UL << MPU_RASR_XN_Pos) /*!< MPU RASR: ATTRS.XN Mask */
  534. #define MPU_RASR_AP_Pos 24U /*!< MPU RASR: ATTRS.AP Position */
  535. #define MPU_RASR_AP_Msk (0x7UL << MPU_RASR_AP_Pos) /*!< MPU RASR: ATTRS.AP Mask */
  536. #define MPU_RASR_TEX_Pos 19U /*!< MPU RASR: ATTRS.TEX Position */
  537. #define MPU_RASR_TEX_Msk (0x7UL << MPU_RASR_TEX_Pos) /*!< MPU RASR: ATTRS.TEX Mask */
  538. #define MPU_RASR_S_Pos 18U /*!< MPU RASR: ATTRS.S Position */
  539. #define MPU_RASR_S_Msk (1UL << MPU_RASR_S_Pos) /*!< MPU RASR: ATTRS.S Mask */
  540. #define MPU_RASR_C_Pos 17U /*!< MPU RASR: ATTRS.C Position */
  541. #define MPU_RASR_C_Msk (1UL << MPU_RASR_C_Pos) /*!< MPU RASR: ATTRS.C Mask */
  542. #define MPU_RASR_B_Pos 16U /*!< MPU RASR: ATTRS.B Position */
  543. #define MPU_RASR_B_Msk (1UL << MPU_RASR_B_Pos) /*!< MPU RASR: ATTRS.B Mask */
  544. #define MPU_RASR_SRD_Pos 8U /*!< MPU RASR: Sub-Region Disable Position */
  545. #define MPU_RASR_SRD_Msk (0xFFUL << MPU_RASR_SRD_Pos) /*!< MPU RASR: Sub-Region Disable Mask */
  546. #define MPU_RASR_SIZE_Pos 1U /*!< MPU RASR: Region Size Field Position */
  547. #define MPU_RASR_SIZE_Msk (0x1FUL << MPU_RASR_SIZE_Pos) /*!< MPU RASR: Region Size Field Mask */
  548. #define MPU_RASR_ENABLE_Pos 0U /*!< MPU RASR: Region enable bit Position */
  549. #define MPU_RASR_ENABLE_Msk (1UL /*<< MPU_RASR_ENABLE_Pos*/) /*!< MPU RASR: Region enable bit Disable Mask */
  550. /*@} end of group CMSIS_MPU */
  551. #endif
  552. /**
  553. \ingroup CMSIS_core_register
  554. \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug)
  555. \brief Cortex-M0+ Core Debug Registers (DCB registers, SHCSR, and DFSR) are only accessible over DAP and not via processor.
  556. Therefore they are not covered by the Cortex-M0+ header file.
  557. @{
  558. */
  559. /*@} end of group CMSIS_CoreDebug */
  560. /**
  561. \ingroup CMSIS_core_register
  562. \defgroup CMSIS_core_bitfield Core register bit field macros
  563. \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk).
  564. @{
  565. */
  566. /**
  567. \brief Mask and shift a bit field value for use in a register bit range.
  568. \param[in] field Name of the register bit field.
  569. \param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type.
  570. \return Masked and shifted value.
  571. */
  572. #define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk)
  573. /**
  574. \brief Mask and shift a register value to extract a bit filed value.
  575. \param[in] field Name of the register bit field.
  576. \param[in] value Value of register. This parameter is interpreted as an uint32_t type.
  577. \return Masked and shifted bit field value.
  578. */
  579. #define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos)
  580. /*@} end of group CMSIS_core_bitfield */
  581. /**
  582. \ingroup CMSIS_core_register
  583. \defgroup CMSIS_core_base Core Definitions
  584. \brief Definitions for base addresses, unions, and structures.
  585. @{
  586. */
  587. /* Memory mapping of Cortex-M0+ Hardware */
  588. #define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */
  589. #define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */
  590. #define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */
  591. #define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */
  592. #define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */
  593. #define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */
  594. #define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */
  595. #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U)
  596. #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */
  597. #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */
  598. #endif
  599. /*@} */
  600. /*******************************************************************************
  601. * Hardware Abstraction Layer
  602. Core Function Interface contains:
  603. - Core NVIC Functions
  604. - Core SysTick Functions
  605. - Core Register Access Functions
  606. ******************************************************************************/
  607. /**
  608. \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference
  609. */
  610. /* ########################## NVIC functions #################################### */
  611. /**
  612. \ingroup CMSIS_Core_FunctionInterface
  613. \defgroup CMSIS_Core_NVICFunctions NVIC Functions
  614. \brief Functions that manage interrupts and exceptions via the NVIC.
  615. @{
  616. */
  617. /* Interrupt Priorities are WORD accessible only under ARMv6M */
  618. /* The following MACROS handle generation of the register offset and byte masks */
  619. #define _BIT_SHIFT(IRQn) ( ((((uint32_t)(int32_t)(IRQn)) ) & 0x03UL) * 8UL)
  620. #define _SHP_IDX(IRQn) ( (((((uint32_t)(int32_t)(IRQn)) & 0x0FUL)-8UL) >> 2UL) )
  621. #define _IP_IDX(IRQn) ( (((uint32_t)(int32_t)(IRQn)) >> 2UL) )
  622. /**
  623. \brief Enable Interrupt
  624. \details Enables a device specific interrupt in the NVIC interrupt controller.
  625. \param [in] IRQn Device specific interrupt number.
  626. \note IRQn must not be negative.
  627. */
  628. __STATIC_INLINE void NVIC_EnableIRQ(IRQn_Type IRQn)
  629. {
  630. if ((int32_t)(IRQn) >= 0)
  631. {
  632. NVIC->ISER[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));
  633. }
  634. }
  635. /**
  636. \brief Get Interrupt Enable status
  637. \details Returns a device specific interrupt enable status from the NVIC interrupt controller.
  638. \param [in] IRQn Device specific interrupt number.
  639. \return 0 Interrupt is not enabled.
  640. \return 1 Interrupt is enabled.
  641. \note IRQn must not be negative.
  642. */
  643. __STATIC_INLINE uint32_t NVIC_GetEnableIRQ(IRQn_Type IRQn)
  644. {
  645. if ((int32_t)(IRQn) >= 0)
  646. {
  647. return((uint32_t)(((NVIC->ISER[0U] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL));
  648. }
  649. else
  650. {
  651. return(0U);
  652. }
  653. }
  654. /**
  655. \brief Disable Interrupt
  656. \details Disables a device specific interrupt in the NVIC interrupt controller.
  657. \param [in] IRQn Device specific interrupt number.
  658. \note IRQn must not be negative.
  659. */
  660. __STATIC_INLINE void NVIC_DisableIRQ(IRQn_Type IRQn)
  661. {
  662. if ((int32_t)(IRQn) >= 0)
  663. {
  664. NVIC->ICER[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));
  665. }
  666. }
  667. /**
  668. \brief Get Pending Interrupt
  669. \details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt.
  670. \param [in] IRQn Device specific interrupt number.
  671. \return 0 Interrupt status is not pending.
  672. \return 1 Interrupt status is pending.
  673. \note IRQn must not be negative.
  674. */
  675. __STATIC_INLINE uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn)
  676. {
  677. if ((int32_t)(IRQn) >= 0)
  678. {
  679. return((uint32_t)(((NVIC->ISPR[0U] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL));
  680. }
  681. else
  682. {
  683. return(0U);
  684. }
  685. }
  686. /**
  687. \brief Set Pending Interrupt
  688. \details Sets the pending bit of a device specific interrupt in the NVIC pending register.
  689. \param [in] IRQn Device specific interrupt number.
  690. \note IRQn must not be negative.
  691. */
  692. __STATIC_INLINE void NVIC_SetPendingIRQ(IRQn_Type IRQn)
  693. {
  694. if ((int32_t)(IRQn) >= 0)
  695. {
  696. NVIC->ISPR[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));
  697. }
  698. }
  699. /**
  700. \brief Clear Pending Interrupt
  701. \details Clears the pending bit of a device specific interrupt in the NVIC pending register.
  702. \param [in] IRQn Device specific interrupt number.
  703. \note IRQn must not be negative.
  704. */
  705. __STATIC_INLINE void NVIC_ClearPendingIRQ(IRQn_Type IRQn)
  706. {
  707. if ((int32_t)(IRQn) >= 0)
  708. {
  709. NVIC->ICPR[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));
  710. }
  711. }
  712. /**
  713. \brief Set Interrupt Priority
  714. \details Sets the priority of a device specific interrupt or a processor exception.
  715. The interrupt number can be positive to specify a device specific interrupt,
  716. or negative to specify a processor exception.
  717. \param [in] IRQn Interrupt number.
  718. \param [in] priority Priority to set.
  719. \note The priority cannot be set for every processor exception.
  720. */
  721. __STATIC_INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority)
  722. {
  723. if ((int32_t)(IRQn) >= 0)
  724. {
  725. NVIC->IP[_IP_IDX(IRQn)] = ((uint32_t)(NVIC->IP[_IP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) |
  726. (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn)));
  727. }
  728. else
  729. {
  730. SCB->SHP[_SHP_IDX(IRQn)] = ((uint32_t)(SCB->SHP[_SHP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) |
  731. (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn)));
  732. }
  733. }
  734. /**
  735. \brief Get Interrupt Priority
  736. \details Reads the priority of a device specific interrupt or a processor exception.
  737. The interrupt number can be positive to specify a device specific interrupt,
  738. or negative to specify a processor exception.
  739. \param [in] IRQn Interrupt number.
  740. \return Interrupt Priority.
  741. Value is aligned automatically to the implemented priority bits of the microcontroller.
  742. */
  743. __STATIC_INLINE uint32_t NVIC_GetPriority(IRQn_Type IRQn)
  744. {
  745. if ((int32_t)(IRQn) >= 0)
  746. {
  747. return((uint32_t)(((NVIC->IP[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS)));
  748. }
  749. else
  750. {
  751. return((uint32_t)(((SCB->SHP[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS)));
  752. }
  753. }
  754. /**
  755. \brief System Reset
  756. \details Initiates a system reset request to reset the MCU.
  757. */
  758. __STATIC_INLINE void NVIC_SystemReset(void)
  759. {
  760. __DSB(); /* Ensure all outstanding memory accesses included
  761. buffered write are completed before reset */
  762. SCB->AIRCR = ((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) |
  763. SCB_AIRCR_SYSRESETREQ_Msk);
  764. __DSB(); /* Ensure completion of memory access */
  765. for(;;) /* wait until reset */
  766. {
  767. __NOP();
  768. }
  769. }
  770. /*@} end of CMSIS_Core_NVICFunctions */
  771. /* ########################## FPU functions #################################### */
  772. /**
  773. \ingroup CMSIS_Core_FunctionInterface
  774. \defgroup CMSIS_Core_FpuFunctions FPU Functions
  775. \brief Function that provides FPU type.
  776. @{
  777. */
  778. /**
  779. \brief get FPU type
  780. \details returns the FPU type
  781. \returns
  782. - \b 0: No FPU
  783. - \b 1: Single precision FPU
  784. - \b 2: Double + Single precision FPU
  785. */
  786. __STATIC_INLINE uint32_t SCB_GetFPUType(void)
  787. {
  788. return 0U; /* No FPU */
  789. }
  790. /*@} end of CMSIS_Core_FpuFunctions */
  791. /* ################################## SysTick function ############################################ */
  792. /**
  793. \ingroup CMSIS_Core_FunctionInterface
  794. \defgroup CMSIS_Core_SysTickFunctions SysTick Functions
  795. \brief Functions that configure the System.
  796. @{
  797. */
  798. #if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U)
  799. /**
  800. \brief System Tick Configuration
  801. \details Initializes the System Timer and its interrupt, and starts the System Tick Timer.
  802. Counter is in free running mode to generate periodic interrupts.
  803. \param [in] ticks Number of ticks between two interrupts.
  804. \return 0 Function succeeded.
  805. \return 1 Function failed.
  806. \note When the variable <b>__Vendor_SysTickConfig</b> is set to 1, then the
  807. function <b>SysTick_Config</b> is not included. In this case, the file <b><i>device</i>.h</b>
  808. must contain a vendor-specific implementation of this function.
  809. */
  810. __STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks)
  811. {
  812. if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk)
  813. {
  814. return (1UL); /* Reload value impossible */
  815. }
  816. SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */
  817. NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */
  818. SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
  819. SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk |
  820. SysTick_CTRL_TICKINT_Msk |
  821. SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */
  822. return (0UL); /* Function successful */
  823. }
  824. #endif
  825. /*@} end of CMSIS_Core_SysTickFunctions */
  826. #ifdef __cplusplus
  827. }
  828. #endif
  829. #endif /* __CORE_CM0PLUS_H_DEPENDANT */
  830. #endif /* __CMSIS_GENERIC */