core_cm0.h 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952
  1. /**************************************************************************//**
  2. * @file core_cm0.h
  3. * @brief CMSIS Cortex-M0 Core Peripheral Access Layer Header File
  4. * @version V5.0.6
  5. * @date 13. March 2019
  6. ******************************************************************************/
  7. /*
  8. * Copyright (c) 2009-2019 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. * 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 (__clang__)
  27. #pragma clang system_header /* treat file as system include file */
  28. #endif
  29. #ifndef __CORE_CM0_H_GENERIC
  30. #define __CORE_CM0_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. #include "cmsis_version.h"
  53. /* CMSIS CM0 definitions */
  54. #define __CM0_CMSIS_VERSION_MAIN (__CM_CMSIS_VERSION_MAIN) /*!< \deprecated [31:16] CMSIS HAL main version */
  55. #define __CM0_CMSIS_VERSION_SUB (__CM_CMSIS_VERSION_SUB) /*!< \deprecated [15:0] CMSIS HAL sub version */
  56. #define __CM0_CMSIS_VERSION ((__CM0_CMSIS_VERSION_MAIN << 16U) | \
  57. __CM0_CMSIS_VERSION_SUB ) /*!< \deprecated CMSIS HAL version number */
  58. #define __CORTEX_M (0U) /*!< Cortex-M Core */
  59. /** __FPU_USED indicates whether an FPU is used or not.
  60. This core does not support an FPU at all
  61. */
  62. #define __FPU_USED 0U
  63. #if defined ( __CC_ARM )
  64. #if defined __TARGET_FPU_VFP
  65. #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
  66. #endif
  67. #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
  68. #if defined __ARM_FP
  69. #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
  70. #endif
  71. #elif defined ( __GNUC__ )
  72. #if defined (__VFP_FP__) && !defined(__SOFTFP__)
  73. #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
  74. #endif
  75. #elif defined ( __ICCARM__ )
  76. #if defined __ARMVFP__
  77. #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
  78. #endif
  79. #elif defined ( __TI_ARM__ )
  80. #if defined __TI_VFP_SUPPORT__
  81. #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
  82. #endif
  83. #elif defined ( __TASKING__ )
  84. #if defined __FPU_VFP__
  85. #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
  86. #endif
  87. #elif defined ( __CSMC__ )
  88. #if ( __CSMC__ & 0x400U)
  89. #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
  90. #endif
  91. #endif
  92. #include "cmsis_compiler.h" /* CMSIS compiler specific defines */
  93. #ifdef __cplusplus
  94. }
  95. #endif
  96. #endif /* __CORE_CM0_H_GENERIC */
  97. #ifndef __CMSIS_GENERIC
  98. #ifndef __CORE_CM0_H_DEPENDANT
  99. #define __CORE_CM0_H_DEPENDANT
  100. #ifdef __cplusplus
  101. extern "C" {
  102. #endif
  103. /* check device defines and use defaults */
  104. #if defined __CHECK_DEVICE_DEFINES
  105. #ifndef __CM0_REV
  106. #define __CM0_REV 0x0000U
  107. #warning "__CM0_REV not defined in device header file; using default!"
  108. #endif
  109. #ifndef __NVIC_PRIO_BITS
  110. #define __NVIC_PRIO_BITS 2U
  111. #warning "__NVIC_PRIO_BITS not defined in device header file; using default!"
  112. #endif
  113. #ifndef __Vendor_SysTickConfig
  114. #define __Vendor_SysTickConfig 0U
  115. #warning "__Vendor_SysTickConfig not defined in device header file; using default!"
  116. #endif
  117. #endif
  118. /* IO definitions (access restrictions to peripheral registers) */
  119. /**
  120. \defgroup CMSIS_glob_defs CMSIS Global Defines
  121. <strong>IO Type Qualifiers</strong> are used
  122. \li to specify the access to peripheral variables.
  123. \li for automatic generation of peripheral register debug information.
  124. */
  125. #ifdef __cplusplus
  126. #define __I volatile /*!< Defines 'read only' permissions */
  127. #else
  128. #define __I volatile const /*!< Defines 'read only' permissions */
  129. #endif
  130. #define __O volatile /*!< Defines 'write only' permissions */
  131. #define __IO volatile /*!< Defines 'read / write' permissions */
  132. /* following defines should be used for structure members */
  133. #define __IM volatile const /*! Defines 'read only' structure member permissions */
  134. #define __OM volatile /*! Defines 'write only' structure member permissions */
  135. #define __IOM volatile /*! Defines 'read / write' structure member permissions */
  136. /*@} end of group Cortex_M0 */
  137. /*******************************************************************************
  138. * Register Abstraction
  139. Core Register contain:
  140. - Core Register
  141. - Core NVIC Register
  142. - Core SCB Register
  143. - Core SysTick Register
  144. ******************************************************************************/
  145. /**
  146. \defgroup CMSIS_core_register Defines and Type Definitions
  147. \brief Type definitions and defines for Cortex-M processor based devices.
  148. */
  149. /**
  150. \ingroup CMSIS_core_register
  151. \defgroup CMSIS_CORE Status and Control Registers
  152. \brief Core Register type definitions.
  153. @{
  154. */
  155. /**
  156. \brief Union type to access the Application Program Status Register (APSR).
  157. */
  158. typedef union
  159. {
  160. struct
  161. {
  162. uint32_t _reserved0:28; /*!< bit: 0..27 Reserved */
  163. uint32_t V:1; /*!< bit: 28 Overflow condition code flag */
  164. uint32_t C:1; /*!< bit: 29 Carry condition code flag */
  165. uint32_t Z:1; /*!< bit: 30 Zero condition code flag */
  166. uint32_t N:1; /*!< bit: 31 Negative condition code flag */
  167. } b; /*!< Structure used for bit access */
  168. uint32_t w; /*!< Type used for word access */
  169. } APSR_Type;
  170. /* APSR Register Definitions */
  171. #define APSR_N_Pos 31U /*!< APSR: N Position */
  172. #define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */
  173. #define APSR_Z_Pos 30U /*!< APSR: Z Position */
  174. #define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */
  175. #define APSR_C_Pos 29U /*!< APSR: C Position */
  176. #define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */
  177. #define APSR_V_Pos 28U /*!< APSR: V Position */
  178. #define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */
  179. /**
  180. \brief Union type to access the Interrupt Program Status Register (IPSR).
  181. */
  182. typedef union
  183. {
  184. struct
  185. {
  186. uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */
  187. uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */
  188. } b; /*!< Structure used for bit access */
  189. uint32_t w; /*!< Type used for word access */
  190. } IPSR_Type;
  191. /* IPSR Register Definitions */
  192. #define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */
  193. #define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */
  194. /**
  195. \brief Union type to access the Special-Purpose Program Status Registers (xPSR).
  196. */
  197. typedef union
  198. {
  199. struct
  200. {
  201. uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */
  202. uint32_t _reserved0:15; /*!< bit: 9..23 Reserved */
  203. uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */
  204. uint32_t _reserved1:3; /*!< bit: 25..27 Reserved */
  205. uint32_t V:1; /*!< bit: 28 Overflow condition code flag */
  206. uint32_t C:1; /*!< bit: 29 Carry condition code flag */
  207. uint32_t Z:1; /*!< bit: 30 Zero condition code flag */
  208. uint32_t N:1; /*!< bit: 31 Negative condition code flag */
  209. } b; /*!< Structure used for bit access */
  210. uint32_t w; /*!< Type used for word access */
  211. } xPSR_Type;
  212. /* xPSR Register Definitions */
  213. #define xPSR_N_Pos 31U /*!< xPSR: N Position */
  214. #define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */
  215. #define xPSR_Z_Pos 30U /*!< xPSR: Z Position */
  216. #define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */
  217. #define xPSR_C_Pos 29U /*!< xPSR: C Position */
  218. #define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */
  219. #define xPSR_V_Pos 28U /*!< xPSR: V Position */
  220. #define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */
  221. #define xPSR_T_Pos 24U /*!< xPSR: T Position */
  222. #define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */
  223. #define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */
  224. #define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */
  225. /**
  226. \brief Union type to access the Control Registers (CONTROL).
  227. */
  228. typedef union
  229. {
  230. struct
  231. {
  232. uint32_t _reserved0:1; /*!< bit: 0 Reserved */
  233. uint32_t SPSEL:1; /*!< bit: 1 Stack to be used */
  234. uint32_t _reserved1:30; /*!< bit: 2..31 Reserved */
  235. } b; /*!< Structure used for bit access */
  236. uint32_t w; /*!< Type used for word access */
  237. } CONTROL_Type;
  238. /* CONTROL Register Definitions */
  239. #define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */
  240. #define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */
  241. /*@} end of group CMSIS_CORE */
  242. /**
  243. \ingroup CMSIS_core_register
  244. \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC)
  245. \brief Type definitions for the NVIC Registers
  246. @{
  247. */
  248. /**
  249. \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC).
  250. */
  251. typedef struct
  252. {
  253. __IOM uint32_t ISER[1U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */
  254. uint32_t RESERVED0[31U];
  255. __IOM uint32_t ICER[1U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */
  256. uint32_t RESERVED1[31U];
  257. __IOM uint32_t ISPR[1U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */
  258. uint32_t RESERVED2[31U];
  259. __IOM uint32_t ICPR[1U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */
  260. uint32_t RESERVED3[31U];
  261. uint32_t RESERVED4[64U];
  262. __IOM uint32_t IP[8U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register */
  263. } NVIC_Type;
  264. /*@} end of group CMSIS_NVIC */
  265. /**
  266. \ingroup CMSIS_core_register
  267. \defgroup CMSIS_SCB System Control Block (SCB)
  268. \brief Type definitions for the System Control Block Registers
  269. @{
  270. */
  271. /**
  272. \brief Structure type to access the System Control Block (SCB).
  273. */
  274. typedef struct
  275. {
  276. __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */
  277. __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */
  278. uint32_t RESERVED0;
  279. __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */
  280. __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */
  281. __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */
  282. uint32_t RESERVED1;
  283. __IOM uint32_t SHP[2U]; /*!< Offset: 0x01C (R/W) System Handlers Priority Registers. [0] is RESERVED */
  284. __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */
  285. } SCB_Type;
  286. /* SCB CPUID Register Definitions */
  287. #define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */
  288. #define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */
  289. #define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */
  290. #define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */
  291. #define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */
  292. #define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */
  293. #define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */
  294. #define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */
  295. #define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */
  296. #define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */
  297. /* SCB Interrupt Control State Register Definitions */
  298. #define SCB_ICSR_NMIPENDSET_Pos 31U /*!< SCB ICSR: NMIPENDSET Position */
  299. #define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */
  300. #define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */
  301. #define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */
  302. #define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */
  303. #define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */
  304. #define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */
  305. #define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */
  306. #define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */
  307. #define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */
  308. #define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */
  309. #define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */
  310. #define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */
  311. #define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */
  312. #define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */
  313. #define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */
  314. #define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */
  315. #define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */
  316. /* SCB Application Interrupt and Reset Control Register Definitions */
  317. #define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */
  318. #define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */
  319. #define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */
  320. #define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */
  321. #define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */
  322. #define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */
  323. #define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */
  324. #define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */
  325. #define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */
  326. #define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */
  327. /* SCB System Control Register Definitions */
  328. #define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */
  329. #define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */
  330. #define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */
  331. #define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */
  332. #define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */
  333. #define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */
  334. /* SCB Configuration Control Register Definitions */
  335. #define SCB_CCR_STKALIGN_Pos 9U /*!< SCB CCR: STKALIGN Position */
  336. #define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */
  337. #define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */
  338. #define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */
  339. /* SCB System Handler Control and State Register Definitions */
  340. #define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */
  341. #define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */
  342. /*@} end of group CMSIS_SCB */
  343. /**
  344. \ingroup CMSIS_core_register
  345. \defgroup CMSIS_SysTick System Tick Timer (SysTick)
  346. \brief Type definitions for the System Timer Registers.
  347. @{
  348. */
  349. /**
  350. \brief Structure type to access the System Timer (SysTick).
  351. */
  352. typedef struct
  353. {
  354. __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */
  355. __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */
  356. __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */
  357. __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */
  358. } SysTick_Type;
  359. /* SysTick Control / Status Register Definitions */
  360. #define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */
  361. #define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */
  362. #define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */
  363. #define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */
  364. #define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */
  365. #define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */
  366. #define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */
  367. #define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */
  368. /* SysTick Reload Register Definitions */
  369. #define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */
  370. #define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */
  371. /* SysTick Current Register Definitions */
  372. #define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */
  373. #define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */
  374. /* SysTick Calibration Register Definitions */
  375. #define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */
  376. #define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */
  377. #define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */
  378. #define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */
  379. #define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */
  380. #define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */
  381. /*@} end of group CMSIS_SysTick */
  382. /**
  383. \ingroup CMSIS_core_register
  384. \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug)
  385. \brief Cortex-M0 Core Debug Registers (DCB registers, SHCSR, and DFSR) are only accessible over DAP and not via processor.
  386. Therefore they are not covered by the Cortex-M0 header file.
  387. @{
  388. */
  389. /*@} end of group CMSIS_CoreDebug */
  390. /**
  391. \ingroup CMSIS_core_register
  392. \defgroup CMSIS_core_bitfield Core register bit field macros
  393. \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk).
  394. @{
  395. */
  396. /**
  397. \brief Mask and shift a bit field value for use in a register bit range.
  398. \param[in] field Name of the register bit field.
  399. \param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type.
  400. \return Masked and shifted value.
  401. */
  402. #define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk)
  403. /**
  404. \brief Mask and shift a register value to extract a bit filed value.
  405. \param[in] field Name of the register bit field.
  406. \param[in] value Value of register. This parameter is interpreted as an uint32_t type.
  407. \return Masked and shifted bit field value.
  408. */
  409. #define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos)
  410. /*@} end of group CMSIS_core_bitfield */
  411. /**
  412. \ingroup CMSIS_core_register
  413. \defgroup CMSIS_core_base Core Definitions
  414. \brief Definitions for base addresses, unions, and structures.
  415. @{
  416. */
  417. /* Memory mapping of Core Hardware */
  418. #define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */
  419. #define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */
  420. #define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */
  421. #define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */
  422. #define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */
  423. #define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */
  424. #define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */
  425. /*@} */
  426. /*******************************************************************************
  427. * Hardware Abstraction Layer
  428. Core Function Interface contains:
  429. - Core NVIC Functions
  430. - Core SysTick Functions
  431. - Core Register Access Functions
  432. ******************************************************************************/
  433. /**
  434. \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference
  435. */
  436. /* ########################## NVIC functions #################################### */
  437. /**
  438. \ingroup CMSIS_Core_FunctionInterface
  439. \defgroup CMSIS_Core_NVICFunctions NVIC Functions
  440. \brief Functions that manage interrupts and exceptions via the NVIC.
  441. @{
  442. */
  443. #ifdef CMSIS_NVIC_VIRTUAL
  444. #ifndef CMSIS_NVIC_VIRTUAL_HEADER_FILE
  445. #define CMSIS_NVIC_VIRTUAL_HEADER_FILE "cmsis_nvic_virtual.h"
  446. #endif
  447. #include CMSIS_NVIC_VIRTUAL_HEADER_FILE
  448. #else
  449. #define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping
  450. #define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping
  451. #define NVIC_EnableIRQ __NVIC_EnableIRQ
  452. #define NVIC_GetEnableIRQ __NVIC_GetEnableIRQ
  453. #define NVIC_DisableIRQ __NVIC_DisableIRQ
  454. #define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ
  455. #define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ
  456. #define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ
  457. /*#define NVIC_GetActive __NVIC_GetActive not available for Cortex-M0 */
  458. #define NVIC_SetPriority __NVIC_SetPriority
  459. #define NVIC_GetPriority __NVIC_GetPriority
  460. #define NVIC_SystemReset __NVIC_SystemReset
  461. #endif /* CMSIS_NVIC_VIRTUAL */
  462. #ifdef CMSIS_VECTAB_VIRTUAL
  463. #ifndef CMSIS_VECTAB_VIRTUAL_HEADER_FILE
  464. #define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "cmsis_vectab_virtual.h"
  465. #endif
  466. #include CMSIS_VECTAB_VIRTUAL_HEADER_FILE
  467. #else
  468. #define NVIC_SetVector __NVIC_SetVector
  469. #define NVIC_GetVector __NVIC_GetVector
  470. #endif /* (CMSIS_VECTAB_VIRTUAL) */
  471. #define NVIC_USER_IRQ_OFFSET 16
  472. /* The following EXC_RETURN values are saved the LR on exception entry */
  473. #define EXC_RETURN_HANDLER (0xFFFFFFF1UL) /* return to Handler mode, uses MSP after return */
  474. #define EXC_RETURN_THREAD_MSP (0xFFFFFFF9UL) /* return to Thread mode, uses MSP after return */
  475. #define EXC_RETURN_THREAD_PSP (0xFFFFFFFDUL) /* return to Thread mode, uses PSP after return */
  476. /* Interrupt Priorities are WORD accessible only under Armv6-M */
  477. /* The following MACROS handle generation of the register offset and byte masks */
  478. #define _BIT_SHIFT(IRQn) ( ((((uint32_t)(int32_t)(IRQn)) ) & 0x03UL) * 8UL)
  479. #define _SHP_IDX(IRQn) ( (((((uint32_t)(int32_t)(IRQn)) & 0x0FUL)-8UL) >> 2UL) )
  480. #define _IP_IDX(IRQn) ( (((uint32_t)(int32_t)(IRQn)) >> 2UL) )
  481. #define __NVIC_SetPriorityGrouping(X) (void)(X)
  482. #define __NVIC_GetPriorityGrouping() (0U)
  483. /**
  484. \brief Enable Interrupt
  485. \details Enables a device specific interrupt in the NVIC interrupt controller.
  486. \param [in] IRQn Device specific interrupt number.
  487. \note IRQn must not be negative.
  488. */
  489. __STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn)
  490. {
  491. if ((int32_t)(IRQn) >= 0)
  492. {
  493. __COMPILER_BARRIER();
  494. NVIC->ISER[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL));
  495. __COMPILER_BARRIER();
  496. }
  497. }
  498. /**
  499. \brief Get Interrupt Enable status
  500. \details Returns a device specific interrupt enable status from the NVIC interrupt controller.
  501. \param [in] IRQn Device specific interrupt number.
  502. \return 0 Interrupt is not enabled.
  503. \return 1 Interrupt is enabled.
  504. \note IRQn must not be negative.
  505. */
  506. __STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn)
  507. {
  508. if ((int32_t)(IRQn) >= 0)
  509. {
  510. return((uint32_t)(((NVIC->ISER[0U] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL));
  511. }
  512. else
  513. {
  514. return(0U);
  515. }
  516. }
  517. /**
  518. \brief Disable Interrupt
  519. \details Disables a device specific interrupt in the NVIC interrupt controller.
  520. \param [in] IRQn Device specific interrupt number.
  521. \note IRQn must not be negative.
  522. */
  523. __STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn)
  524. {
  525. if ((int32_t)(IRQn) >= 0)
  526. {
  527. NVIC->ICER[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL));
  528. __DSB();
  529. __ISB();
  530. }
  531. }
  532. /**
  533. \brief Get Pending Interrupt
  534. \details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt.
  535. \param [in] IRQn Device specific interrupt number.
  536. \return 0 Interrupt status is not pending.
  537. \return 1 Interrupt status is pending.
  538. \note IRQn must not be negative.
  539. */
  540. __STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn)
  541. {
  542. if ((int32_t)(IRQn) >= 0)
  543. {
  544. return((uint32_t)(((NVIC->ISPR[0U] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL));
  545. }
  546. else
  547. {
  548. return(0U);
  549. }
  550. }
  551. /**
  552. \brief Set Pending Interrupt
  553. \details Sets the pending bit of a device specific interrupt in the NVIC pending register.
  554. \param [in] IRQn Device specific interrupt number.
  555. \note IRQn must not be negative.
  556. */
  557. __STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn)
  558. {
  559. if ((int32_t)(IRQn) >= 0)
  560. {
  561. NVIC->ISPR[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL));
  562. }
  563. }
  564. /**
  565. \brief Clear Pending Interrupt
  566. \details Clears the pending bit of a device specific interrupt in the NVIC pending register.
  567. \param [in] IRQn Device specific interrupt number.
  568. \note IRQn must not be negative.
  569. */
  570. __STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn)
  571. {
  572. if ((int32_t)(IRQn) >= 0)
  573. {
  574. NVIC->ICPR[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL));
  575. }
  576. }
  577. /**
  578. \brief Set Interrupt Priority
  579. \details Sets the priority of a device specific interrupt or a processor exception.
  580. The interrupt number can be positive to specify a device specific interrupt,
  581. or negative to specify a processor exception.
  582. \param [in] IRQn Interrupt number.
  583. \param [in] priority Priority to set.
  584. \note The priority cannot be set for every processor exception.
  585. */
  586. __STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority)
  587. {
  588. if ((int32_t)(IRQn) >= 0)
  589. {
  590. NVIC->IP[_IP_IDX(IRQn)] = ((uint32_t)(NVIC->IP[_IP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) |
  591. (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn)));
  592. }
  593. else
  594. {
  595. SCB->SHP[_SHP_IDX(IRQn)] = ((uint32_t)(SCB->SHP[_SHP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) |
  596. (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn)));
  597. }
  598. }
  599. /**
  600. \brief Get Interrupt Priority
  601. \details Reads the priority of a device specific interrupt or a processor exception.
  602. The interrupt number can be positive to specify a device specific interrupt,
  603. or negative to specify a processor exception.
  604. \param [in] IRQn Interrupt number.
  605. \return Interrupt Priority.
  606. Value is aligned automatically to the implemented priority bits of the microcontroller.
  607. */
  608. __STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn)
  609. {
  610. if ((int32_t)(IRQn) >= 0)
  611. {
  612. return((uint32_t)(((NVIC->IP[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS)));
  613. }
  614. else
  615. {
  616. return((uint32_t)(((SCB->SHP[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS)));
  617. }
  618. }
  619. /**
  620. \brief Encode Priority
  621. \details Encodes the priority for an interrupt with the given priority group,
  622. preemptive priority value, and subpriority value.
  623. In case of a conflict between priority grouping and available
  624. priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set.
  625. \param [in] PriorityGroup Used priority group.
  626. \param [in] PreemptPriority Preemptive priority value (starting from 0).
  627. \param [in] SubPriority Subpriority value (starting from 0).
  628. \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority().
  629. */
  630. __STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority)
  631. {
  632. uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */
  633. uint32_t PreemptPriorityBits;
  634. uint32_t SubPriorityBits;
  635. PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp);
  636. SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS));
  637. return (
  638. ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) |
  639. ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL)))
  640. );
  641. }
  642. /**
  643. \brief Decode Priority
  644. \details Decodes an interrupt priority value with a given priority group to
  645. preemptive priority value and subpriority value.
  646. In case of a conflict between priority grouping and available
  647. priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set.
  648. \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority().
  649. \param [in] PriorityGroup Used priority group.
  650. \param [out] pPreemptPriority Preemptive priority value (starting from 0).
  651. \param [out] pSubPriority Subpriority value (starting from 0).
  652. */
  653. __STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority)
  654. {
  655. uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */
  656. uint32_t PreemptPriorityBits;
  657. uint32_t SubPriorityBits;
  658. PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp);
  659. SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS));
  660. *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL);
  661. *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL);
  662. }
  663. /**
  664. \brief Set Interrupt Vector
  665. \details Sets an interrupt vector in SRAM based interrupt vector table.
  666. The interrupt number can be positive to specify a device specific interrupt,
  667. or negative to specify a processor exception.
  668. Address 0 must be mapped to SRAM.
  669. \param [in] IRQn Interrupt number
  670. \param [in] vector Address of interrupt handler function
  671. */
  672. __STATIC_INLINE void __NVIC_SetVector(IRQn_Type IRQn, uint32_t vector)
  673. {
  674. uint32_t vectors = 0x0U;
  675. (* (int *) (vectors + ((int32_t)IRQn + NVIC_USER_IRQ_OFFSET) * 4)) = vector;
  676. /* ARM Application Note 321 states that the M0 does not require the architectural barrier */
  677. }
  678. /**
  679. \brief Get Interrupt Vector
  680. \details Reads an interrupt vector from interrupt vector table.
  681. The interrupt number can be positive to specify a device specific interrupt,
  682. or negative to specify a processor exception.
  683. \param [in] IRQn Interrupt number.
  684. \return Address of interrupt handler function
  685. */
  686. __STATIC_INLINE uint32_t __NVIC_GetVector(IRQn_Type IRQn)
  687. {
  688. uint32_t vectors = 0x0U;
  689. return (uint32_t)(* (int *) (vectors + ((int32_t)IRQn + NVIC_USER_IRQ_OFFSET) * 4));
  690. }
  691. /**
  692. \brief System Reset
  693. \details Initiates a system reset request to reset the MCU.
  694. */
  695. __NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void)
  696. {
  697. __DSB(); /* Ensure all outstanding memory accesses included
  698. buffered write are completed before reset */
  699. SCB->AIRCR = ((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) |
  700. SCB_AIRCR_SYSRESETREQ_Msk);
  701. __DSB(); /* Ensure completion of memory access */
  702. for(;;) /* wait until reset */
  703. {
  704. __NOP();
  705. }
  706. }
  707. /*@} end of CMSIS_Core_NVICFunctions */
  708. /* ########################## FPU functions #################################### */
  709. /**
  710. \ingroup CMSIS_Core_FunctionInterface
  711. \defgroup CMSIS_Core_FpuFunctions FPU Functions
  712. \brief Function that provides FPU type.
  713. @{
  714. */
  715. /**
  716. \brief get FPU type
  717. \details returns the FPU type
  718. \returns
  719. - \b 0: No FPU
  720. - \b 1: Single precision FPU
  721. - \b 2: Double + Single precision FPU
  722. */
  723. __STATIC_INLINE uint32_t SCB_GetFPUType(void)
  724. {
  725. return 0U; /* No FPU */
  726. }
  727. /*@} end of CMSIS_Core_FpuFunctions */
  728. /* ################################## SysTick function ############################################ */
  729. /**
  730. \ingroup CMSIS_Core_FunctionInterface
  731. \defgroup CMSIS_Core_SysTickFunctions SysTick Functions
  732. \brief Functions that configure the System.
  733. @{
  734. */
  735. #if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U)
  736. /**
  737. \brief System Tick Configuration
  738. \details Initializes the System Timer and its interrupt, and starts the System Tick Timer.
  739. Counter is in free running mode to generate periodic interrupts.
  740. \param [in] ticks Number of ticks between two interrupts.
  741. \return 0 Function succeeded.
  742. \return 1 Function failed.
  743. \note When the variable <b>__Vendor_SysTickConfig</b> is set to 1, then the
  744. function <b>SysTick_Config</b> is not included. In this case, the file <b><i>device</i>.h</b>
  745. must contain a vendor-specific implementation of this function.
  746. */
  747. __STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks)
  748. {
  749. if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk)
  750. {
  751. return (1UL); /* Reload value impossible */
  752. }
  753. SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */
  754. NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */
  755. SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
  756. SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk |
  757. SysTick_CTRL_TICKINT_Msk |
  758. SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */
  759. return (0UL); /* Function successful */
  760. }
  761. #endif
  762. /*@} end of CMSIS_Core_SysTickFunctions */
  763. #ifdef __cplusplus
  764. }
  765. #endif
  766. #endif /* __CORE_CM0_H_DEPENDANT */
  767. #endif /* __CMSIS_GENERIC */