core_cm23.h 102 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993
  1. /**************************************************************************//**
  2. * @file core_cm23.h
  3. * @brief CMSIS Cortex-M23 Core Peripheral Access Layer Header File
  4. * @version V5.0.7
  5. * @date 22. June 2018
  6. ******************************************************************************/
  7. /*
  8. * Copyright (c) 2009-2018 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_CM23_H_GENERIC
  30. #define __CORE_CM23_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_M23
  50. @{
  51. */
  52. #include "cmsis_version.h"
  53. /* CMSIS definitions */
  54. #define __CM23_CMSIS_VERSION_MAIN (__CM_CMSIS_VERSION_MAIN) /*!< \deprecated [31:16] CMSIS HAL main version */
  55. #define __CM23_CMSIS_VERSION_SUB (__CM_CMSIS_VERSION_SUB) /*!< \deprecated [15:0] CMSIS HAL sub version */
  56. #define __CM23_CMSIS_VERSION ((__CM23_CMSIS_VERSION_MAIN << 16U) | \
  57. __CM23_CMSIS_VERSION_SUB ) /*!< \deprecated CMSIS HAL version number */
  58. #define __CORTEX_M (23U) /*!< 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_PCS_VFP
  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_CM23_H_GENERIC */
  97. #ifndef __CMSIS_GENERIC
  98. #ifndef __CORE_CM23_H_DEPENDANT
  99. #define __CORE_CM23_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 __CM23_REV
  106. #define __CM23_REV 0x0000U
  107. #warning "__CM23_REV not defined in device header file; using default!"
  108. #endif
  109. #ifndef __FPU_PRESENT
  110. #define __FPU_PRESENT 0U
  111. #warning "__FPU_PRESENT not defined in device header file; using default!"
  112. #endif
  113. #ifndef __MPU_PRESENT
  114. #define __MPU_PRESENT 0U
  115. #warning "__MPU_PRESENT not defined in device header file; using default!"
  116. #endif
  117. #ifndef __SAUREGION_PRESENT
  118. #define __SAUREGION_PRESENT 0U
  119. #warning "__SAUREGION_PRESENT not defined in device header file; using default!"
  120. #endif
  121. #ifndef __VTOR_PRESENT
  122. #define __VTOR_PRESENT 0U
  123. #warning "__VTOR_PRESENT not defined in device header file; using default!"
  124. #endif
  125. #ifndef __NVIC_PRIO_BITS
  126. #define __NVIC_PRIO_BITS 2U
  127. #warning "__NVIC_PRIO_BITS not defined in device header file; using default!"
  128. #endif
  129. #ifndef __Vendor_SysTickConfig
  130. #define __Vendor_SysTickConfig 0U
  131. #warning "__Vendor_SysTickConfig not defined in device header file; using default!"
  132. #endif
  133. #ifndef __ETM_PRESENT
  134. #define __ETM_PRESENT 0U
  135. #warning "__ETM_PRESENT not defined in device header file; using default!"
  136. #endif
  137. #ifndef __MTB_PRESENT
  138. #define __MTB_PRESENT 0U
  139. #warning "__MTB_PRESENT not defined in device header file; using default!"
  140. #endif
  141. #endif
  142. /* IO definitions (access restrictions to peripheral registers) */
  143. /**
  144. \defgroup CMSIS_glob_defs CMSIS Global Defines
  145. <strong>IO Type Qualifiers</strong> are used
  146. \li to specify the access to peripheral variables.
  147. \li for automatic generation of peripheral register debug information.
  148. */
  149. #ifdef __cplusplus
  150. #define __I volatile /*!< Defines 'read only' permissions */
  151. #else
  152. #define __I volatile const /*!< Defines 'read only' permissions */
  153. #endif
  154. #define __O volatile /*!< Defines 'write only' permissions */
  155. #define __IO volatile /*!< Defines 'read / write' permissions */
  156. /* following defines should be used for structure members */
  157. #define __IM volatile const /*! Defines 'read only' structure member permissions */
  158. #define __OM volatile /*! Defines 'write only' structure member permissions */
  159. #define __IOM volatile /*! Defines 'read / write' structure member permissions */
  160. /*@} end of group Cortex_M23 */
  161. /*******************************************************************************
  162. * Register Abstraction
  163. Core Register contain:
  164. - Core Register
  165. - Core NVIC Register
  166. - Core SCB Register
  167. - Core SysTick Register
  168. - Core Debug Register
  169. - Core MPU Register
  170. - Core SAU Register
  171. ******************************************************************************/
  172. /**
  173. \defgroup CMSIS_core_register Defines and Type Definitions
  174. \brief Type definitions and defines for Cortex-M processor based devices.
  175. */
  176. /**
  177. \ingroup CMSIS_core_register
  178. \defgroup CMSIS_CORE Status and Control Registers
  179. \brief Core Register type definitions.
  180. @{
  181. */
  182. /**
  183. \brief Union type to access the Application Program Status Register (APSR).
  184. */
  185. typedef union
  186. {
  187. struct
  188. {
  189. uint32_t _reserved0:28; /*!< bit: 0..27 Reserved */
  190. uint32_t V:1; /*!< bit: 28 Overflow condition code flag */
  191. uint32_t C:1; /*!< bit: 29 Carry condition code flag */
  192. uint32_t Z:1; /*!< bit: 30 Zero condition code flag */
  193. uint32_t N:1; /*!< bit: 31 Negative condition code flag */
  194. } b; /*!< Structure used for bit access */
  195. uint32_t w; /*!< Type used for word access */
  196. } APSR_Type;
  197. /* APSR Register Definitions */
  198. #define APSR_N_Pos 31U /*!< APSR: N Position */
  199. #define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */
  200. #define APSR_Z_Pos 30U /*!< APSR: Z Position */
  201. #define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */
  202. #define APSR_C_Pos 29U /*!< APSR: C Position */
  203. #define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */
  204. #define APSR_V_Pos 28U /*!< APSR: V Position */
  205. #define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */
  206. /**
  207. \brief Union type to access the Interrupt Program Status Register (IPSR).
  208. */
  209. typedef union
  210. {
  211. struct
  212. {
  213. uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */
  214. uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */
  215. } b; /*!< Structure used for bit access */
  216. uint32_t w; /*!< Type used for word access */
  217. } IPSR_Type;
  218. /* IPSR Register Definitions */
  219. #define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */
  220. #define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */
  221. /**
  222. \brief Union type to access the Special-Purpose Program Status Registers (xPSR).
  223. */
  224. typedef union
  225. {
  226. struct
  227. {
  228. uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */
  229. uint32_t _reserved0:15; /*!< bit: 9..23 Reserved */
  230. uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */
  231. uint32_t _reserved1:3; /*!< bit: 25..27 Reserved */
  232. uint32_t V:1; /*!< bit: 28 Overflow condition code flag */
  233. uint32_t C:1; /*!< bit: 29 Carry condition code flag */
  234. uint32_t Z:1; /*!< bit: 30 Zero condition code flag */
  235. uint32_t N:1; /*!< bit: 31 Negative condition code flag */
  236. } b; /*!< Structure used for bit access */
  237. uint32_t w; /*!< Type used for word access */
  238. } xPSR_Type;
  239. /* xPSR Register Definitions */
  240. #define xPSR_N_Pos 31U /*!< xPSR: N Position */
  241. #define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */
  242. #define xPSR_Z_Pos 30U /*!< xPSR: Z Position */
  243. #define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */
  244. #define xPSR_C_Pos 29U /*!< xPSR: C Position */
  245. #define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */
  246. #define xPSR_V_Pos 28U /*!< xPSR: V Position */
  247. #define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */
  248. #define xPSR_T_Pos 24U /*!< xPSR: T Position */
  249. #define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */
  250. #define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */
  251. #define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */
  252. /**
  253. \brief Union type to access the Control Registers (CONTROL).
  254. */
  255. typedef union
  256. {
  257. struct
  258. {
  259. uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */
  260. uint32_t SPSEL:1; /*!< bit: 1 Stack-pointer select */
  261. uint32_t _reserved1:30; /*!< bit: 2..31 Reserved */
  262. } b; /*!< Structure used for bit access */
  263. uint32_t w; /*!< Type used for word access */
  264. } CONTROL_Type;
  265. /* CONTROL Register Definitions */
  266. #define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */
  267. #define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */
  268. #define CONTROL_nPRIV_Pos 0U /*!< CONTROL: nPRIV Position */
  269. #define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */
  270. /*@} end of group CMSIS_CORE */
  271. /**
  272. \ingroup CMSIS_core_register
  273. \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC)
  274. \brief Type definitions for the NVIC Registers
  275. @{
  276. */
  277. /**
  278. \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC).
  279. */
  280. typedef struct
  281. {
  282. __IOM uint32_t ISER[16U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */
  283. uint32_t RESERVED0[16U];
  284. __IOM uint32_t ICER[16U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */
  285. uint32_t RSERVED1[16U];
  286. __IOM uint32_t ISPR[16U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */
  287. uint32_t RESERVED2[16U];
  288. __IOM uint32_t ICPR[16U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */
  289. uint32_t RESERVED3[16U];
  290. __IOM uint32_t IABR[16U]; /*!< Offset: 0x200 (R/W) Interrupt Active bit Register */
  291. uint32_t RESERVED4[16U];
  292. __IOM uint32_t ITNS[16U]; /*!< Offset: 0x280 (R/W) Interrupt Non-Secure State Register */
  293. uint32_t RESERVED5[16U];
  294. __IOM uint32_t IPR[124U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register */
  295. } NVIC_Type;
  296. /*@} end of group CMSIS_NVIC */
  297. /**
  298. \ingroup CMSIS_core_register
  299. \defgroup CMSIS_SCB System Control Block (SCB)
  300. \brief Type definitions for the System Control Block Registers
  301. @{
  302. */
  303. /**
  304. \brief Structure type to access the System Control Block (SCB).
  305. */
  306. typedef struct
  307. {
  308. __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */
  309. __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */
  310. #if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1U)
  311. __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */
  312. #else
  313. uint32_t RESERVED0;
  314. #endif
  315. __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */
  316. __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */
  317. __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */
  318. uint32_t RESERVED1;
  319. __IOM uint32_t SHPR[2U]; /*!< Offset: 0x01C (R/W) System Handlers Priority Registers. [0] is RESERVED */
  320. __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */
  321. } SCB_Type;
  322. /* SCB CPUID Register Definitions */
  323. #define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */
  324. #define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */
  325. #define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */
  326. #define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */
  327. #define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */
  328. #define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */
  329. #define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */
  330. #define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */
  331. #define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */
  332. #define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */
  333. /* SCB Interrupt Control State Register Definitions */
  334. #define SCB_ICSR_PENDNMISET_Pos 31U /*!< SCB ICSR: PENDNMISET Position */
  335. #define SCB_ICSR_PENDNMISET_Msk (1UL << SCB_ICSR_PENDNMISET_Pos) /*!< SCB ICSR: PENDNMISET Mask */
  336. #define SCB_ICSR_NMIPENDSET_Pos SCB_ICSR_PENDNMISET_Pos /*!< SCB ICSR: NMIPENDSET Position, backward compatibility */
  337. #define SCB_ICSR_NMIPENDSET_Msk SCB_ICSR_PENDNMISET_Msk /*!< SCB ICSR: NMIPENDSET Mask, backward compatibility */
  338. #define SCB_ICSR_PENDNMICLR_Pos 30U /*!< SCB ICSR: PENDNMICLR Position */
  339. #define SCB_ICSR_PENDNMICLR_Msk (1UL << SCB_ICSR_PENDNMICLR_Pos) /*!< SCB ICSR: PENDNMICLR Mask */
  340. #define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */
  341. #define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */
  342. #define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */
  343. #define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */
  344. #define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */
  345. #define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */
  346. #define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */
  347. #define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */
  348. #define SCB_ICSR_STTNS_Pos 24U /*!< SCB ICSR: STTNS Position (Security Extension) */
  349. #define SCB_ICSR_STTNS_Msk (1UL << SCB_ICSR_STTNS_Pos) /*!< SCB ICSR: STTNS Mask (Security Extension) */
  350. #define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */
  351. #define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */
  352. #define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */
  353. #define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */
  354. #define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */
  355. #define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */
  356. #define SCB_ICSR_RETTOBASE_Pos 11U /*!< SCB ICSR: RETTOBASE Position */
  357. #define SCB_ICSR_RETTOBASE_Msk (1UL << SCB_ICSR_RETTOBASE_Pos) /*!< SCB ICSR: RETTOBASE Mask */
  358. #define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */
  359. #define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */
  360. #if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1U)
  361. /* SCB Vector Table Offset Register Definitions */
  362. #define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */
  363. #define SCB_VTOR_TBLOFF_Msk (0x1FFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */
  364. #endif
  365. /* SCB Application Interrupt and Reset Control Register Definitions */
  366. #define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */
  367. #define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */
  368. #define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */
  369. #define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */
  370. #define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */
  371. #define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */
  372. #define SCB_AIRCR_PRIS_Pos 14U /*!< SCB AIRCR: PRIS Position */
  373. #define SCB_AIRCR_PRIS_Msk (1UL << SCB_AIRCR_PRIS_Pos) /*!< SCB AIRCR: PRIS Mask */
  374. #define SCB_AIRCR_BFHFNMINS_Pos 13U /*!< SCB AIRCR: BFHFNMINS Position */
  375. #define SCB_AIRCR_BFHFNMINS_Msk (1UL << SCB_AIRCR_BFHFNMINS_Pos) /*!< SCB AIRCR: BFHFNMINS Mask */
  376. #define SCB_AIRCR_SYSRESETREQS_Pos 3U /*!< SCB AIRCR: SYSRESETREQS Position */
  377. #define SCB_AIRCR_SYSRESETREQS_Msk (1UL << SCB_AIRCR_SYSRESETREQS_Pos) /*!< SCB AIRCR: SYSRESETREQS Mask */
  378. #define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */
  379. #define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */
  380. #define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */
  381. #define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */
  382. /* SCB System Control Register Definitions */
  383. #define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */
  384. #define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */
  385. #define SCB_SCR_SLEEPDEEPS_Pos 3U /*!< SCB SCR: SLEEPDEEPS Position */
  386. #define SCB_SCR_SLEEPDEEPS_Msk (1UL << SCB_SCR_SLEEPDEEPS_Pos) /*!< SCB SCR: SLEEPDEEPS Mask */
  387. #define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */
  388. #define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */
  389. #define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */
  390. #define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */
  391. /* SCB Configuration Control Register Definitions */
  392. #define SCB_CCR_BP_Pos 18U /*!< SCB CCR: BP Position */
  393. #define SCB_CCR_BP_Msk (1UL << SCB_CCR_BP_Pos) /*!< SCB CCR: BP Mask */
  394. #define SCB_CCR_IC_Pos 17U /*!< SCB CCR: IC Position */
  395. #define SCB_CCR_IC_Msk (1UL << SCB_CCR_IC_Pos) /*!< SCB CCR: IC Mask */
  396. #define SCB_CCR_DC_Pos 16U /*!< SCB CCR: DC Position */
  397. #define SCB_CCR_DC_Msk (1UL << SCB_CCR_DC_Pos) /*!< SCB CCR: DC Mask */
  398. #define SCB_CCR_STKOFHFNMIGN_Pos 10U /*!< SCB CCR: STKOFHFNMIGN Position */
  399. #define SCB_CCR_STKOFHFNMIGN_Msk (1UL << SCB_CCR_STKOFHFNMIGN_Pos) /*!< SCB CCR: STKOFHFNMIGN Mask */
  400. #define SCB_CCR_BFHFNMIGN_Pos 8U /*!< SCB CCR: BFHFNMIGN Position */
  401. #define SCB_CCR_BFHFNMIGN_Msk (1UL << SCB_CCR_BFHFNMIGN_Pos) /*!< SCB CCR: BFHFNMIGN Mask */
  402. #define SCB_CCR_DIV_0_TRP_Pos 4U /*!< SCB CCR: DIV_0_TRP Position */
  403. #define SCB_CCR_DIV_0_TRP_Msk (1UL << SCB_CCR_DIV_0_TRP_Pos) /*!< SCB CCR: DIV_0_TRP Mask */
  404. #define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */
  405. #define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */
  406. #define SCB_CCR_USERSETMPEND_Pos 1U /*!< SCB CCR: USERSETMPEND Position */
  407. #define SCB_CCR_USERSETMPEND_Msk (1UL << SCB_CCR_USERSETMPEND_Pos) /*!< SCB CCR: USERSETMPEND Mask */
  408. /* SCB System Handler Control and State Register Definitions */
  409. #define SCB_SHCSR_HARDFAULTPENDED_Pos 21U /*!< SCB SHCSR: HARDFAULTPENDED Position */
  410. #define SCB_SHCSR_HARDFAULTPENDED_Msk (1UL << SCB_SHCSR_HARDFAULTPENDED_Pos) /*!< SCB SHCSR: HARDFAULTPENDED Mask */
  411. #define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */
  412. #define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */
  413. #define SCB_SHCSR_SYSTICKACT_Pos 11U /*!< SCB SHCSR: SYSTICKACT Position */
  414. #define SCB_SHCSR_SYSTICKACT_Msk (1UL << SCB_SHCSR_SYSTICKACT_Pos) /*!< SCB SHCSR: SYSTICKACT Mask */
  415. #define SCB_SHCSR_PENDSVACT_Pos 10U /*!< SCB SHCSR: PENDSVACT Position */
  416. #define SCB_SHCSR_PENDSVACT_Msk (1UL << SCB_SHCSR_PENDSVACT_Pos) /*!< SCB SHCSR: PENDSVACT Mask */
  417. #define SCB_SHCSR_SVCALLACT_Pos 7U /*!< SCB SHCSR: SVCALLACT Position */
  418. #define SCB_SHCSR_SVCALLACT_Msk (1UL << SCB_SHCSR_SVCALLACT_Pos) /*!< SCB SHCSR: SVCALLACT Mask */
  419. #define SCB_SHCSR_NMIACT_Pos 5U /*!< SCB SHCSR: NMIACT Position */
  420. #define SCB_SHCSR_NMIACT_Msk (1UL << SCB_SHCSR_NMIACT_Pos) /*!< SCB SHCSR: NMIACT Mask */
  421. #define SCB_SHCSR_HARDFAULTACT_Pos 2U /*!< SCB SHCSR: HARDFAULTACT Position */
  422. #define SCB_SHCSR_HARDFAULTACT_Msk (1UL << SCB_SHCSR_HARDFAULTACT_Pos) /*!< SCB SHCSR: HARDFAULTACT Mask */
  423. /*@} end of group CMSIS_SCB */
  424. /**
  425. \ingroup CMSIS_core_register
  426. \defgroup CMSIS_SysTick System Tick Timer (SysTick)
  427. \brief Type definitions for the System Timer Registers.
  428. @{
  429. */
  430. /**
  431. \brief Structure type to access the System Timer (SysTick).
  432. */
  433. typedef struct
  434. {
  435. __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */
  436. __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */
  437. __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */
  438. __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */
  439. } SysTick_Type;
  440. /* SysTick Control / Status Register Definitions */
  441. #define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */
  442. #define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */
  443. #define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */
  444. #define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */
  445. #define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */
  446. #define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */
  447. #define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */
  448. #define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */
  449. /* SysTick Reload Register Definitions */
  450. #define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */
  451. #define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */
  452. /* SysTick Current Register Definitions */
  453. #define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */
  454. #define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */
  455. /* SysTick Calibration Register Definitions */
  456. #define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */
  457. #define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */
  458. #define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */
  459. #define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */
  460. #define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */
  461. #define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */
  462. /*@} end of group CMSIS_SysTick */
  463. /**
  464. \ingroup CMSIS_core_register
  465. \defgroup CMSIS_DWT Data Watchpoint and Trace (DWT)
  466. \brief Type definitions for the Data Watchpoint and Trace (DWT)
  467. @{
  468. */
  469. /**
  470. \brief Structure type to access the Data Watchpoint and Trace Register (DWT).
  471. */
  472. typedef struct
  473. {
  474. __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */
  475. uint32_t RESERVED0[6U];
  476. __IM uint32_t PCSR; /*!< Offset: 0x01C (R/ ) Program Counter Sample Register */
  477. __IOM uint32_t COMP0; /*!< Offset: 0x020 (R/W) Comparator Register 0 */
  478. uint32_t RESERVED1[1U];
  479. __IOM uint32_t FUNCTION0; /*!< Offset: 0x028 (R/W) Function Register 0 */
  480. uint32_t RESERVED2[1U];
  481. __IOM uint32_t COMP1; /*!< Offset: 0x030 (R/W) Comparator Register 1 */
  482. uint32_t RESERVED3[1U];
  483. __IOM uint32_t FUNCTION1; /*!< Offset: 0x038 (R/W) Function Register 1 */
  484. uint32_t RESERVED4[1U];
  485. __IOM uint32_t COMP2; /*!< Offset: 0x040 (R/W) Comparator Register 2 */
  486. uint32_t RESERVED5[1U];
  487. __IOM uint32_t FUNCTION2; /*!< Offset: 0x048 (R/W) Function Register 2 */
  488. uint32_t RESERVED6[1U];
  489. __IOM uint32_t COMP3; /*!< Offset: 0x050 (R/W) Comparator Register 3 */
  490. uint32_t RESERVED7[1U];
  491. __IOM uint32_t FUNCTION3; /*!< Offset: 0x058 (R/W) Function Register 3 */
  492. uint32_t RESERVED8[1U];
  493. __IOM uint32_t COMP4; /*!< Offset: 0x060 (R/W) Comparator Register 4 */
  494. uint32_t RESERVED9[1U];
  495. __IOM uint32_t FUNCTION4; /*!< Offset: 0x068 (R/W) Function Register 4 */
  496. uint32_t RESERVED10[1U];
  497. __IOM uint32_t COMP5; /*!< Offset: 0x070 (R/W) Comparator Register 5 */
  498. uint32_t RESERVED11[1U];
  499. __IOM uint32_t FUNCTION5; /*!< Offset: 0x078 (R/W) Function Register 5 */
  500. uint32_t RESERVED12[1U];
  501. __IOM uint32_t COMP6; /*!< Offset: 0x080 (R/W) Comparator Register 6 */
  502. uint32_t RESERVED13[1U];
  503. __IOM uint32_t FUNCTION6; /*!< Offset: 0x088 (R/W) Function Register 6 */
  504. uint32_t RESERVED14[1U];
  505. __IOM uint32_t COMP7; /*!< Offset: 0x090 (R/W) Comparator Register 7 */
  506. uint32_t RESERVED15[1U];
  507. __IOM uint32_t FUNCTION7; /*!< Offset: 0x098 (R/W) Function Register 7 */
  508. uint32_t RESERVED16[1U];
  509. __IOM uint32_t COMP8; /*!< Offset: 0x0A0 (R/W) Comparator Register 8 */
  510. uint32_t RESERVED17[1U];
  511. __IOM uint32_t FUNCTION8; /*!< Offset: 0x0A8 (R/W) Function Register 8 */
  512. uint32_t RESERVED18[1U];
  513. __IOM uint32_t COMP9; /*!< Offset: 0x0B0 (R/W) Comparator Register 9 */
  514. uint32_t RESERVED19[1U];
  515. __IOM uint32_t FUNCTION9; /*!< Offset: 0x0B8 (R/W) Function Register 9 */
  516. uint32_t RESERVED20[1U];
  517. __IOM uint32_t COMP10; /*!< Offset: 0x0C0 (R/W) Comparator Register 10 */
  518. uint32_t RESERVED21[1U];
  519. __IOM uint32_t FUNCTION10; /*!< Offset: 0x0C8 (R/W) Function Register 10 */
  520. uint32_t RESERVED22[1U];
  521. __IOM uint32_t COMP11; /*!< Offset: 0x0D0 (R/W) Comparator Register 11 */
  522. uint32_t RESERVED23[1U];
  523. __IOM uint32_t FUNCTION11; /*!< Offset: 0x0D8 (R/W) Function Register 11 */
  524. uint32_t RESERVED24[1U];
  525. __IOM uint32_t COMP12; /*!< Offset: 0x0E0 (R/W) Comparator Register 12 */
  526. uint32_t RESERVED25[1U];
  527. __IOM uint32_t FUNCTION12; /*!< Offset: 0x0E8 (R/W) Function Register 12 */
  528. uint32_t RESERVED26[1U];
  529. __IOM uint32_t COMP13; /*!< Offset: 0x0F0 (R/W) Comparator Register 13 */
  530. uint32_t RESERVED27[1U];
  531. __IOM uint32_t FUNCTION13; /*!< Offset: 0x0F8 (R/W) Function Register 13 */
  532. uint32_t RESERVED28[1U];
  533. __IOM uint32_t COMP14; /*!< Offset: 0x100 (R/W) Comparator Register 14 */
  534. uint32_t RESERVED29[1U];
  535. __IOM uint32_t FUNCTION14; /*!< Offset: 0x108 (R/W) Function Register 14 */
  536. uint32_t RESERVED30[1U];
  537. __IOM uint32_t COMP15; /*!< Offset: 0x110 (R/W) Comparator Register 15 */
  538. uint32_t RESERVED31[1U];
  539. __IOM uint32_t FUNCTION15; /*!< Offset: 0x118 (R/W) Function Register 15 */
  540. } DWT_Type;
  541. /* DWT Control Register Definitions */
  542. #define DWT_CTRL_NUMCOMP_Pos 28U /*!< DWT CTRL: NUMCOMP Position */
  543. #define DWT_CTRL_NUMCOMP_Msk (0xFUL << DWT_CTRL_NUMCOMP_Pos) /*!< DWT CTRL: NUMCOMP Mask */
  544. #define DWT_CTRL_NOTRCPKT_Pos 27U /*!< DWT CTRL: NOTRCPKT Position */
  545. #define DWT_CTRL_NOTRCPKT_Msk (0x1UL << DWT_CTRL_NOTRCPKT_Pos) /*!< DWT CTRL: NOTRCPKT Mask */
  546. #define DWT_CTRL_NOEXTTRIG_Pos 26U /*!< DWT CTRL: NOEXTTRIG Position */
  547. #define DWT_CTRL_NOEXTTRIG_Msk (0x1UL << DWT_CTRL_NOEXTTRIG_Pos) /*!< DWT CTRL: NOEXTTRIG Mask */
  548. #define DWT_CTRL_NOCYCCNT_Pos 25U /*!< DWT CTRL: NOCYCCNT Position */
  549. #define DWT_CTRL_NOCYCCNT_Msk (0x1UL << DWT_CTRL_NOCYCCNT_Pos) /*!< DWT CTRL: NOCYCCNT Mask */
  550. #define DWT_CTRL_NOPRFCNT_Pos 24U /*!< DWT CTRL: NOPRFCNT Position */
  551. #define DWT_CTRL_NOPRFCNT_Msk (0x1UL << DWT_CTRL_NOPRFCNT_Pos) /*!< DWT CTRL: NOPRFCNT Mask */
  552. /* DWT Comparator Function Register Definitions */
  553. #define DWT_FUNCTION_ID_Pos 27U /*!< DWT FUNCTION: ID Position */
  554. #define DWT_FUNCTION_ID_Msk (0x1FUL << DWT_FUNCTION_ID_Pos) /*!< DWT FUNCTION: ID Mask */
  555. #define DWT_FUNCTION_MATCHED_Pos 24U /*!< DWT FUNCTION: MATCHED Position */
  556. #define DWT_FUNCTION_MATCHED_Msk (0x1UL << DWT_FUNCTION_MATCHED_Pos) /*!< DWT FUNCTION: MATCHED Mask */
  557. #define DWT_FUNCTION_DATAVSIZE_Pos 10U /*!< DWT FUNCTION: DATAVSIZE Position */
  558. #define DWT_FUNCTION_DATAVSIZE_Msk (0x3UL << DWT_FUNCTION_DATAVSIZE_Pos) /*!< DWT FUNCTION: DATAVSIZE Mask */
  559. #define DWT_FUNCTION_ACTION_Pos 4U /*!< DWT FUNCTION: ACTION Position */
  560. #define DWT_FUNCTION_ACTION_Msk (0x3UL << DWT_FUNCTION_ACTION_Pos) /*!< DWT FUNCTION: ACTION Mask */
  561. #define DWT_FUNCTION_MATCH_Pos 0U /*!< DWT FUNCTION: MATCH Position */
  562. #define DWT_FUNCTION_MATCH_Msk (0xFUL /*<< DWT_FUNCTION_MATCH_Pos*/) /*!< DWT FUNCTION: MATCH Mask */
  563. /*@}*/ /* end of group CMSIS_DWT */
  564. /**
  565. \ingroup CMSIS_core_register
  566. \defgroup CMSIS_TPI Trace Port Interface (TPI)
  567. \brief Type definitions for the Trace Port Interface (TPI)
  568. @{
  569. */
  570. /**
  571. \brief Structure type to access the Trace Port Interface Register (TPI).
  572. */
  573. typedef struct
  574. {
  575. __IM uint32_t SSPSR; /*!< Offset: 0x000 (R/ ) Supported Parallel Port Size Register */
  576. __IOM uint32_t CSPSR; /*!< Offset: 0x004 (R/W) Current Parallel Port Size Register */
  577. uint32_t RESERVED0[2U];
  578. __IOM uint32_t ACPR; /*!< Offset: 0x010 (R/W) Asynchronous Clock Prescaler Register */
  579. uint32_t RESERVED1[55U];
  580. __IOM uint32_t SPPR; /*!< Offset: 0x0F0 (R/W) Selected Pin Protocol Register */
  581. uint32_t RESERVED2[131U];
  582. __IM uint32_t FFSR; /*!< Offset: 0x300 (R/ ) Formatter and Flush Status Register */
  583. __IOM uint32_t FFCR; /*!< Offset: 0x304 (R/W) Formatter and Flush Control Register */
  584. __IOM uint32_t PSCR; /*!< Offset: 0x308 (R/W) Periodic Synchronization Control Register */
  585. uint32_t RESERVED3[759U];
  586. __IM uint32_t TRIGGER; /*!< Offset: 0xEE8 (R/ ) TRIGGER Register */
  587. __IM uint32_t ITFTTD0; /*!< Offset: 0xEEC (R/ ) Integration Test FIFO Test Data 0 Register */
  588. __IOM uint32_t ITATBCTR2; /*!< Offset: 0xEF0 (R/W) Integration Test ATB Control Register 2 */
  589. uint32_t RESERVED4[1U];
  590. __IM uint32_t ITATBCTR0; /*!< Offset: 0xEF8 (R/ ) Integration Test ATB Control Register 0 */
  591. __IM uint32_t ITFTTD1; /*!< Offset: 0xEFC (R/ ) Integration Test FIFO Test Data 1 Register */
  592. __IOM uint32_t ITCTRL; /*!< Offset: 0xF00 (R/W) Integration Mode Control */
  593. uint32_t RESERVED5[39U];
  594. __IOM uint32_t CLAIMSET; /*!< Offset: 0xFA0 (R/W) Claim tag set */
  595. __IOM uint32_t CLAIMCLR; /*!< Offset: 0xFA4 (R/W) Claim tag clear */
  596. uint32_t RESERVED7[8U];
  597. __IM uint32_t DEVID; /*!< Offset: 0xFC8 (R/ ) Device Configuration Register */
  598. __IM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/ ) Device Type Identifier Register */
  599. } TPI_Type;
  600. /* TPI Asynchronous Clock Prescaler Register Definitions */
  601. #define TPI_ACPR_PRESCALER_Pos 0U /*!< TPI ACPR: PRESCALER Position */
  602. #define TPI_ACPR_PRESCALER_Msk (0x1FFFUL /*<< TPI_ACPR_PRESCALER_Pos*/) /*!< TPI ACPR: PRESCALER Mask */
  603. /* TPI Selected Pin Protocol Register Definitions */
  604. #define TPI_SPPR_TXMODE_Pos 0U /*!< TPI SPPR: TXMODE Position */
  605. #define TPI_SPPR_TXMODE_Msk (0x3UL /*<< TPI_SPPR_TXMODE_Pos*/) /*!< TPI SPPR: TXMODE Mask */
  606. /* TPI Formatter and Flush Status Register Definitions */
  607. #define TPI_FFSR_FtNonStop_Pos 3U /*!< TPI FFSR: FtNonStop Position */
  608. #define TPI_FFSR_FtNonStop_Msk (0x1UL << TPI_FFSR_FtNonStop_Pos) /*!< TPI FFSR: FtNonStop Mask */
  609. #define TPI_FFSR_TCPresent_Pos 2U /*!< TPI FFSR: TCPresent Position */
  610. #define TPI_FFSR_TCPresent_Msk (0x1UL << TPI_FFSR_TCPresent_Pos) /*!< TPI FFSR: TCPresent Mask */
  611. #define TPI_FFSR_FtStopped_Pos 1U /*!< TPI FFSR: FtStopped Position */
  612. #define TPI_FFSR_FtStopped_Msk (0x1UL << TPI_FFSR_FtStopped_Pos) /*!< TPI FFSR: FtStopped Mask */
  613. #define TPI_FFSR_FlInProg_Pos 0U /*!< TPI FFSR: FlInProg Position */
  614. #define TPI_FFSR_FlInProg_Msk (0x1UL /*<< TPI_FFSR_FlInProg_Pos*/) /*!< TPI FFSR: FlInProg Mask */
  615. /* TPI Formatter and Flush Control Register Definitions */
  616. #define TPI_FFCR_TrigIn_Pos 8U /*!< TPI FFCR: TrigIn Position */
  617. #define TPI_FFCR_TrigIn_Msk (0x1UL << TPI_FFCR_TrigIn_Pos) /*!< TPI FFCR: TrigIn Mask */
  618. #define TPI_FFCR_FOnMan_Pos 6U /*!< TPI FFCR: FOnMan Position */
  619. #define TPI_FFCR_FOnMan_Msk (0x1UL << TPI_FFCR_FOnMan_Pos) /*!< TPI FFCR: FOnMan Mask */
  620. #define TPI_FFCR_EnFCont_Pos 1U /*!< TPI FFCR: EnFCont Position */
  621. #define TPI_FFCR_EnFCont_Msk (0x1UL << TPI_FFCR_EnFCont_Pos) /*!< TPI FFCR: EnFCont Mask */
  622. /* TPI TRIGGER Register Definitions */
  623. #define TPI_TRIGGER_TRIGGER_Pos 0U /*!< TPI TRIGGER: TRIGGER Position */
  624. #define TPI_TRIGGER_TRIGGER_Msk (0x1UL /*<< TPI_TRIGGER_TRIGGER_Pos*/) /*!< TPI TRIGGER: TRIGGER Mask */
  625. /* TPI Integration Test FIFO Test Data 0 Register Definitions */
  626. #define TPI_ITFTTD0_ATB_IF2_ATVALID_Pos 29U /*!< TPI ITFTTD0: ATB Interface 2 ATVALIDPosition */
  627. #define TPI_ITFTTD0_ATB_IF2_ATVALID_Msk (0x3UL << TPI_ITFTTD0_ATB_IF2_ATVALID_Pos) /*!< TPI ITFTTD0: ATB Interface 2 ATVALID Mask */
  628. #define TPI_ITFTTD0_ATB_IF2_bytecount_Pos 27U /*!< TPI ITFTTD0: ATB Interface 2 byte count Position */
  629. #define TPI_ITFTTD0_ATB_IF2_bytecount_Msk (0x3UL << TPI_ITFTTD0_ATB_IF2_bytecount_Pos) /*!< TPI ITFTTD0: ATB Interface 2 byte count Mask */
  630. #define TPI_ITFTTD0_ATB_IF1_ATVALID_Pos 26U /*!< TPI ITFTTD0: ATB Interface 1 ATVALID Position */
  631. #define TPI_ITFTTD0_ATB_IF1_ATVALID_Msk (0x3UL << TPI_ITFTTD0_ATB_IF1_ATVALID_Pos) /*!< TPI ITFTTD0: ATB Interface 1 ATVALID Mask */
  632. #define TPI_ITFTTD0_ATB_IF1_bytecount_Pos 24U /*!< TPI ITFTTD0: ATB Interface 1 byte count Position */
  633. #define TPI_ITFTTD0_ATB_IF1_bytecount_Msk (0x3UL << TPI_ITFTTD0_ATB_IF1_bytecount_Pos) /*!< TPI ITFTTD0: ATB Interface 1 byte countt Mask */
  634. #define TPI_ITFTTD0_ATB_IF1_data2_Pos 16U /*!< TPI ITFTTD0: ATB Interface 1 data2 Position */
  635. #define TPI_ITFTTD0_ATB_IF1_data2_Msk (0xFFUL << TPI_ITFTTD0_ATB_IF1_data1_Pos) /*!< TPI ITFTTD0: ATB Interface 1 data2 Mask */
  636. #define TPI_ITFTTD0_ATB_IF1_data1_Pos 8U /*!< TPI ITFTTD0: ATB Interface 1 data1 Position */
  637. #define TPI_ITFTTD0_ATB_IF1_data1_Msk (0xFFUL << TPI_ITFTTD0_ATB_IF1_data1_Pos) /*!< TPI ITFTTD0: ATB Interface 1 data1 Mask */
  638. #define TPI_ITFTTD0_ATB_IF1_data0_Pos 0U /*!< TPI ITFTTD0: ATB Interface 1 data0 Position */
  639. #define TPI_ITFTTD0_ATB_IF1_data0_Msk (0xFFUL /*<< TPI_ITFTTD0_ATB_IF1_data0_Pos*/) /*!< TPI ITFTTD0: ATB Interface 1 data0 Mask */
  640. /* TPI Integration Test ATB Control Register 2 Register Definitions */
  641. #define TPI_ITATBCTR2_AFVALID2S_Pos 1U /*!< TPI ITATBCTR2: AFVALID2S Position */
  642. #define TPI_ITATBCTR2_AFVALID2S_Msk (0x1UL << TPI_ITATBCTR2_AFVALID2S_Pos) /*!< TPI ITATBCTR2: AFVALID2SS Mask */
  643. #define TPI_ITATBCTR2_AFVALID1S_Pos 1U /*!< TPI ITATBCTR2: AFVALID1S Position */
  644. #define TPI_ITATBCTR2_AFVALID1S_Msk (0x1UL << TPI_ITATBCTR2_AFVALID1S_Pos) /*!< TPI ITATBCTR2: AFVALID1SS Mask */
  645. #define TPI_ITATBCTR2_ATREADY2S_Pos 0U /*!< TPI ITATBCTR2: ATREADY2S Position */
  646. #define TPI_ITATBCTR2_ATREADY2S_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY2S_Pos*/) /*!< TPI ITATBCTR2: ATREADY2S Mask */
  647. #define TPI_ITATBCTR2_ATREADY1S_Pos 0U /*!< TPI ITATBCTR2: ATREADY1S Position */
  648. #define TPI_ITATBCTR2_ATREADY1S_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY1S_Pos*/) /*!< TPI ITATBCTR2: ATREADY1S Mask */
  649. /* TPI Integration Test FIFO Test Data 1 Register Definitions */
  650. #define TPI_ITFTTD1_ATB_IF2_ATVALID_Pos 29U /*!< TPI ITFTTD1: ATB Interface 2 ATVALID Position */
  651. #define TPI_ITFTTD1_ATB_IF2_ATVALID_Msk (0x3UL << TPI_ITFTTD1_ATB_IF2_ATVALID_Pos) /*!< TPI ITFTTD1: ATB Interface 2 ATVALID Mask */
  652. #define TPI_ITFTTD1_ATB_IF2_bytecount_Pos 27U /*!< TPI ITFTTD1: ATB Interface 2 byte count Position */
  653. #define TPI_ITFTTD1_ATB_IF2_bytecount_Msk (0x3UL << TPI_ITFTTD1_ATB_IF2_bytecount_Pos) /*!< TPI ITFTTD1: ATB Interface 2 byte count Mask */
  654. #define TPI_ITFTTD1_ATB_IF1_ATVALID_Pos 26U /*!< TPI ITFTTD1: ATB Interface 1 ATVALID Position */
  655. #define TPI_ITFTTD1_ATB_IF1_ATVALID_Msk (0x3UL << TPI_ITFTTD1_ATB_IF1_ATVALID_Pos) /*!< TPI ITFTTD1: ATB Interface 1 ATVALID Mask */
  656. #define TPI_ITFTTD1_ATB_IF1_bytecount_Pos 24U /*!< TPI ITFTTD1: ATB Interface 1 byte count Position */
  657. #define TPI_ITFTTD1_ATB_IF1_bytecount_Msk (0x3UL << TPI_ITFTTD1_ATB_IF1_bytecount_Pos) /*!< TPI ITFTTD1: ATB Interface 1 byte countt Mask */
  658. #define TPI_ITFTTD1_ATB_IF2_data2_Pos 16U /*!< TPI ITFTTD1: ATB Interface 2 data2 Position */
  659. #define TPI_ITFTTD1_ATB_IF2_data2_Msk (0xFFUL << TPI_ITFTTD1_ATB_IF2_data1_Pos) /*!< TPI ITFTTD1: ATB Interface 2 data2 Mask */
  660. #define TPI_ITFTTD1_ATB_IF2_data1_Pos 8U /*!< TPI ITFTTD1: ATB Interface 2 data1 Position */
  661. #define TPI_ITFTTD1_ATB_IF2_data1_Msk (0xFFUL << TPI_ITFTTD1_ATB_IF2_data1_Pos) /*!< TPI ITFTTD1: ATB Interface 2 data1 Mask */
  662. #define TPI_ITFTTD1_ATB_IF2_data0_Pos 0U /*!< TPI ITFTTD1: ATB Interface 2 data0 Position */
  663. #define TPI_ITFTTD1_ATB_IF2_data0_Msk (0xFFUL /*<< TPI_ITFTTD1_ATB_IF2_data0_Pos*/) /*!< TPI ITFTTD1: ATB Interface 2 data0 Mask */
  664. /* TPI Integration Test ATB Control Register 0 Definitions */
  665. #define TPI_ITATBCTR0_AFVALID2S_Pos 1U /*!< TPI ITATBCTR0: AFVALID2S Position */
  666. #define TPI_ITATBCTR0_AFVALID2S_Msk (0x1UL << TPI_ITATBCTR0_AFVALID2S_Pos) /*!< TPI ITATBCTR0: AFVALID2SS Mask */
  667. #define TPI_ITATBCTR0_AFVALID1S_Pos 1U /*!< TPI ITATBCTR0: AFVALID1S Position */
  668. #define TPI_ITATBCTR0_AFVALID1S_Msk (0x1UL << TPI_ITATBCTR0_AFVALID1S_Pos) /*!< TPI ITATBCTR0: AFVALID1SS Mask */
  669. #define TPI_ITATBCTR0_ATREADY2S_Pos 0U /*!< TPI ITATBCTR0: ATREADY2S Position */
  670. #define TPI_ITATBCTR0_ATREADY2S_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY2S_Pos*/) /*!< TPI ITATBCTR0: ATREADY2S Mask */
  671. #define TPI_ITATBCTR0_ATREADY1S_Pos 0U /*!< TPI ITATBCTR0: ATREADY1S Position */
  672. #define TPI_ITATBCTR0_ATREADY1S_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY1S_Pos*/) /*!< TPI ITATBCTR0: ATREADY1S Mask */
  673. /* TPI Integration Mode Control Register Definitions */
  674. #define TPI_ITCTRL_Mode_Pos 0U /*!< TPI ITCTRL: Mode Position */
  675. #define TPI_ITCTRL_Mode_Msk (0x3UL /*<< TPI_ITCTRL_Mode_Pos*/) /*!< TPI ITCTRL: Mode Mask */
  676. /* TPI DEVID Register Definitions */
  677. #define TPI_DEVID_NRZVALID_Pos 11U /*!< TPI DEVID: NRZVALID Position */
  678. #define TPI_DEVID_NRZVALID_Msk (0x1UL << TPI_DEVID_NRZVALID_Pos) /*!< TPI DEVID: NRZVALID Mask */
  679. #define TPI_DEVID_MANCVALID_Pos 10U /*!< TPI DEVID: MANCVALID Position */
  680. #define TPI_DEVID_MANCVALID_Msk (0x1UL << TPI_DEVID_MANCVALID_Pos) /*!< TPI DEVID: MANCVALID Mask */
  681. #define TPI_DEVID_PTINVALID_Pos 9U /*!< TPI DEVID: PTINVALID Position */
  682. #define TPI_DEVID_PTINVALID_Msk (0x1UL << TPI_DEVID_PTINVALID_Pos) /*!< TPI DEVID: PTINVALID Mask */
  683. #define TPI_DEVID_FIFOSZ_Pos 6U /*!< TPI DEVID: FIFOSZ Position */
  684. #define TPI_DEVID_FIFOSZ_Msk (0x7UL << TPI_DEVID_FIFOSZ_Pos) /*!< TPI DEVID: FIFOSZ Mask */
  685. #define TPI_DEVID_NrTraceInput_Pos 0U /*!< TPI DEVID: NrTraceInput Position */
  686. #define TPI_DEVID_NrTraceInput_Msk (0x3FUL /*<< TPI_DEVID_NrTraceInput_Pos*/) /*!< TPI DEVID: NrTraceInput Mask */
  687. /* TPI DEVTYPE Register Definitions */
  688. #define TPI_DEVTYPE_SubType_Pos 4U /*!< TPI DEVTYPE: SubType Position */
  689. #define TPI_DEVTYPE_SubType_Msk (0xFUL /*<< TPI_DEVTYPE_SubType_Pos*/) /*!< TPI DEVTYPE: SubType Mask */
  690. #define TPI_DEVTYPE_MajorType_Pos 0U /*!< TPI DEVTYPE: MajorType Position */
  691. #define TPI_DEVTYPE_MajorType_Msk (0xFUL << TPI_DEVTYPE_MajorType_Pos) /*!< TPI DEVTYPE: MajorType Mask */
  692. /*@}*/ /* end of group CMSIS_TPI */
  693. #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U)
  694. /**
  695. \ingroup CMSIS_core_register
  696. \defgroup CMSIS_MPU Memory Protection Unit (MPU)
  697. \brief Type definitions for the Memory Protection Unit (MPU)
  698. @{
  699. */
  700. /**
  701. \brief Structure type to access the Memory Protection Unit (MPU).
  702. */
  703. typedef struct
  704. {
  705. __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */
  706. __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */
  707. __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region Number Register */
  708. __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */
  709. __IOM uint32_t RLAR; /*!< Offset: 0x010 (R/W) MPU Region Limit Address Register */
  710. uint32_t RESERVED0[7U];
  711. union {
  712. __IOM uint32_t MAIR[2];
  713. struct {
  714. __IOM uint32_t MAIR0; /*!< Offset: 0x030 (R/W) MPU Memory Attribute Indirection Register 0 */
  715. __IOM uint32_t MAIR1; /*!< Offset: 0x034 (R/W) MPU Memory Attribute Indirection Register 1 */
  716. };
  717. };
  718. } MPU_Type;
  719. #define MPU_TYPE_RALIASES 1U
  720. /* MPU Type Register Definitions */
  721. #define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */
  722. #define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */
  723. #define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */
  724. #define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */
  725. #define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */
  726. #define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */
  727. /* MPU Control Register Definitions */
  728. #define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */
  729. #define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */
  730. #define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */
  731. #define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */
  732. #define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */
  733. #define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */
  734. /* MPU Region Number Register Definitions */
  735. #define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */
  736. #define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */
  737. /* MPU Region Base Address Register Definitions */
  738. #define MPU_RBAR_BASE_Pos 5U /*!< MPU RBAR: BASE Position */
  739. #define MPU_RBAR_BASE_Msk (0x7FFFFFFUL << MPU_RBAR_BASE_Pos) /*!< MPU RBAR: BASE Mask */
  740. #define MPU_RBAR_SH_Pos 3U /*!< MPU RBAR: SH Position */
  741. #define MPU_RBAR_SH_Msk (0x3UL << MPU_RBAR_SH_Pos) /*!< MPU RBAR: SH Mask */
  742. #define MPU_RBAR_AP_Pos 1U /*!< MPU RBAR: AP Position */
  743. #define MPU_RBAR_AP_Msk (0x3UL << MPU_RBAR_AP_Pos) /*!< MPU RBAR: AP Mask */
  744. #define MPU_RBAR_XN_Pos 0U /*!< MPU RBAR: XN Position */
  745. #define MPU_RBAR_XN_Msk (01UL /*<< MPU_RBAR_XN_Pos*/) /*!< MPU RBAR: XN Mask */
  746. /* MPU Region Limit Address Register Definitions */
  747. #define MPU_RLAR_LIMIT_Pos 5U /*!< MPU RLAR: LIMIT Position */
  748. #define MPU_RLAR_LIMIT_Msk (0x7FFFFFFUL << MPU_RLAR_LIMIT_Pos) /*!< MPU RLAR: LIMIT Mask */
  749. #define MPU_RLAR_AttrIndx_Pos 1U /*!< MPU RLAR: AttrIndx Position */
  750. #define MPU_RLAR_AttrIndx_Msk (0x7UL << MPU_RLAR_AttrIndx_Pos) /*!< MPU RLAR: AttrIndx Mask */
  751. #define MPU_RLAR_EN_Pos 0U /*!< MPU RLAR: EN Position */
  752. #define MPU_RLAR_EN_Msk (1UL /*<< MPU_RLAR_EN_Pos*/) /*!< MPU RLAR: EN Mask */
  753. /* MPU Memory Attribute Indirection Register 0 Definitions */
  754. #define MPU_MAIR0_Attr3_Pos 24U /*!< MPU MAIR0: Attr3 Position */
  755. #define MPU_MAIR0_Attr3_Msk (0xFFUL << MPU_MAIR0_Attr3_Pos) /*!< MPU MAIR0: Attr3 Mask */
  756. #define MPU_MAIR0_Attr2_Pos 16U /*!< MPU MAIR0: Attr2 Position */
  757. #define MPU_MAIR0_Attr2_Msk (0xFFUL << MPU_MAIR0_Attr2_Pos) /*!< MPU MAIR0: Attr2 Mask */
  758. #define MPU_MAIR0_Attr1_Pos 8U /*!< MPU MAIR0: Attr1 Position */
  759. #define MPU_MAIR0_Attr1_Msk (0xFFUL << MPU_MAIR0_Attr1_Pos) /*!< MPU MAIR0: Attr1 Mask */
  760. #define MPU_MAIR0_Attr0_Pos 0U /*!< MPU MAIR0: Attr0 Position */
  761. #define MPU_MAIR0_Attr0_Msk (0xFFUL /*<< MPU_MAIR0_Attr0_Pos*/) /*!< MPU MAIR0: Attr0 Mask */
  762. /* MPU Memory Attribute Indirection Register 1 Definitions */
  763. #define MPU_MAIR1_Attr7_Pos 24U /*!< MPU MAIR1: Attr7 Position */
  764. #define MPU_MAIR1_Attr7_Msk (0xFFUL << MPU_MAIR1_Attr7_Pos) /*!< MPU MAIR1: Attr7 Mask */
  765. #define MPU_MAIR1_Attr6_Pos 16U /*!< MPU MAIR1: Attr6 Position */
  766. #define MPU_MAIR1_Attr6_Msk (0xFFUL << MPU_MAIR1_Attr6_Pos) /*!< MPU MAIR1: Attr6 Mask */
  767. #define MPU_MAIR1_Attr5_Pos 8U /*!< MPU MAIR1: Attr5 Position */
  768. #define MPU_MAIR1_Attr5_Msk (0xFFUL << MPU_MAIR1_Attr5_Pos) /*!< MPU MAIR1: Attr5 Mask */
  769. #define MPU_MAIR1_Attr4_Pos 0U /*!< MPU MAIR1: Attr4 Position */
  770. #define MPU_MAIR1_Attr4_Msk (0xFFUL /*<< MPU_MAIR1_Attr4_Pos*/) /*!< MPU MAIR1: Attr4 Mask */
  771. /*@} end of group CMSIS_MPU */
  772. #endif
  773. #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
  774. /**
  775. \ingroup CMSIS_core_register
  776. \defgroup CMSIS_SAU Security Attribution Unit (SAU)
  777. \brief Type definitions for the Security Attribution Unit (SAU)
  778. @{
  779. */
  780. /**
  781. \brief Structure type to access the Security Attribution Unit (SAU).
  782. */
  783. typedef struct
  784. {
  785. __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SAU Control Register */
  786. __IM uint32_t TYPE; /*!< Offset: 0x004 (R/ ) SAU Type Register */
  787. #if defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U)
  788. __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) SAU Region Number Register */
  789. __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) SAU Region Base Address Register */
  790. __IOM uint32_t RLAR; /*!< Offset: 0x010 (R/W) SAU Region Limit Address Register */
  791. #endif
  792. } SAU_Type;
  793. /* SAU Control Register Definitions */
  794. #define SAU_CTRL_ALLNS_Pos 1U /*!< SAU CTRL: ALLNS Position */
  795. #define SAU_CTRL_ALLNS_Msk (1UL << SAU_CTRL_ALLNS_Pos) /*!< SAU CTRL: ALLNS Mask */
  796. #define SAU_CTRL_ENABLE_Pos 0U /*!< SAU CTRL: ENABLE Position */
  797. #define SAU_CTRL_ENABLE_Msk (1UL /*<< SAU_CTRL_ENABLE_Pos*/) /*!< SAU CTRL: ENABLE Mask */
  798. /* SAU Type Register Definitions */
  799. #define SAU_TYPE_SREGION_Pos 0U /*!< SAU TYPE: SREGION Position */
  800. #define SAU_TYPE_SREGION_Msk (0xFFUL /*<< SAU_TYPE_SREGION_Pos*/) /*!< SAU TYPE: SREGION Mask */
  801. #if defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U)
  802. /* SAU Region Number Register Definitions */
  803. #define SAU_RNR_REGION_Pos 0U /*!< SAU RNR: REGION Position */
  804. #define SAU_RNR_REGION_Msk (0xFFUL /*<< SAU_RNR_REGION_Pos*/) /*!< SAU RNR: REGION Mask */
  805. /* SAU Region Base Address Register Definitions */
  806. #define SAU_RBAR_BADDR_Pos 5U /*!< SAU RBAR: BADDR Position */
  807. #define SAU_RBAR_BADDR_Msk (0x7FFFFFFUL << SAU_RBAR_BADDR_Pos) /*!< SAU RBAR: BADDR Mask */
  808. /* SAU Region Limit Address Register Definitions */
  809. #define SAU_RLAR_LADDR_Pos 5U /*!< SAU RLAR: LADDR Position */
  810. #define SAU_RLAR_LADDR_Msk (0x7FFFFFFUL << SAU_RLAR_LADDR_Pos) /*!< SAU RLAR: LADDR Mask */
  811. #define SAU_RLAR_NSC_Pos 1U /*!< SAU RLAR: NSC Position */
  812. #define SAU_RLAR_NSC_Msk (1UL << SAU_RLAR_NSC_Pos) /*!< SAU RLAR: NSC Mask */
  813. #define SAU_RLAR_ENABLE_Pos 0U /*!< SAU RLAR: ENABLE Position */
  814. #define SAU_RLAR_ENABLE_Msk (1UL /*<< SAU_RLAR_ENABLE_Pos*/) /*!< SAU RLAR: ENABLE Mask */
  815. #endif /* defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) */
  816. /*@} end of group CMSIS_SAU */
  817. #endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */
  818. /**
  819. \ingroup CMSIS_core_register
  820. \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug)
  821. \brief Type definitions for the Core Debug Registers
  822. @{
  823. */
  824. /**
  825. \brief Structure type to access the Core Debug Register (CoreDebug).
  826. */
  827. typedef struct
  828. {
  829. __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */
  830. __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */
  831. __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */
  832. __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */
  833. uint32_t RESERVED4[1U];
  834. __IOM uint32_t DAUTHCTRL; /*!< Offset: 0x014 (R/W) Debug Authentication Control Register */
  835. __IOM uint32_t DSCSR; /*!< Offset: 0x018 (R/W) Debug Security Control and Status Register */
  836. } CoreDebug_Type;
  837. /* Debug Halting Control and Status Register Definitions */
  838. #define CoreDebug_DHCSR_DBGKEY_Pos 16U /*!< CoreDebug DHCSR: DBGKEY Position */
  839. #define CoreDebug_DHCSR_DBGKEY_Msk (0xFFFFUL << CoreDebug_DHCSR_DBGKEY_Pos) /*!< CoreDebug DHCSR: DBGKEY Mask */
  840. #define CoreDebug_DHCSR_S_RESTART_ST_Pos 26U /*!< CoreDebug DHCSR: S_RESTART_ST Position */
  841. #define CoreDebug_DHCSR_S_RESTART_ST_Msk (1UL << CoreDebug_DHCSR_S_RESTART_ST_Pos) /*!< CoreDebug DHCSR: S_RESTART_ST Mask */
  842. #define CoreDebug_DHCSR_S_RESET_ST_Pos 25U /*!< CoreDebug DHCSR: S_RESET_ST Position */
  843. #define CoreDebug_DHCSR_S_RESET_ST_Msk (1UL << CoreDebug_DHCSR_S_RESET_ST_Pos) /*!< CoreDebug DHCSR: S_RESET_ST Mask */
  844. #define CoreDebug_DHCSR_S_RETIRE_ST_Pos 24U /*!< CoreDebug DHCSR: S_RETIRE_ST Position */
  845. #define CoreDebug_DHCSR_S_RETIRE_ST_Msk (1UL << CoreDebug_DHCSR_S_RETIRE_ST_Pos) /*!< CoreDebug DHCSR: S_RETIRE_ST Mask */
  846. #define CoreDebug_DHCSR_S_LOCKUP_Pos 19U /*!< CoreDebug DHCSR: S_LOCKUP Position */
  847. #define CoreDebug_DHCSR_S_LOCKUP_Msk (1UL << CoreDebug_DHCSR_S_LOCKUP_Pos) /*!< CoreDebug DHCSR: S_LOCKUP Mask */
  848. #define CoreDebug_DHCSR_S_SLEEP_Pos 18U /*!< CoreDebug DHCSR: S_SLEEP Position */
  849. #define CoreDebug_DHCSR_S_SLEEP_Msk (1UL << CoreDebug_DHCSR_S_SLEEP_Pos) /*!< CoreDebug DHCSR: S_SLEEP Mask */
  850. #define CoreDebug_DHCSR_S_HALT_Pos 17U /*!< CoreDebug DHCSR: S_HALT Position */
  851. #define CoreDebug_DHCSR_S_HALT_Msk (1UL << CoreDebug_DHCSR_S_HALT_Pos) /*!< CoreDebug DHCSR: S_HALT Mask */
  852. #define CoreDebug_DHCSR_S_REGRDY_Pos 16U /*!< CoreDebug DHCSR: S_REGRDY Position */
  853. #define CoreDebug_DHCSR_S_REGRDY_Msk (1UL << CoreDebug_DHCSR_S_REGRDY_Pos) /*!< CoreDebug DHCSR: S_REGRDY Mask */
  854. #define CoreDebug_DHCSR_C_MASKINTS_Pos 3U /*!< CoreDebug DHCSR: C_MASKINTS Position */
  855. #define CoreDebug_DHCSR_C_MASKINTS_Msk (1UL << CoreDebug_DHCSR_C_MASKINTS_Pos) /*!< CoreDebug DHCSR: C_MASKINTS Mask */
  856. #define CoreDebug_DHCSR_C_STEP_Pos 2U /*!< CoreDebug DHCSR: C_STEP Position */
  857. #define CoreDebug_DHCSR_C_STEP_Msk (1UL << CoreDebug_DHCSR_C_STEP_Pos) /*!< CoreDebug DHCSR: C_STEP Mask */
  858. #define CoreDebug_DHCSR_C_HALT_Pos 1U /*!< CoreDebug DHCSR: C_HALT Position */
  859. #define CoreDebug_DHCSR_C_HALT_Msk (1UL << CoreDebug_DHCSR_C_HALT_Pos) /*!< CoreDebug DHCSR: C_HALT Mask */
  860. #define CoreDebug_DHCSR_C_DEBUGEN_Pos 0U /*!< CoreDebug DHCSR: C_DEBUGEN Position */
  861. #define CoreDebug_DHCSR_C_DEBUGEN_Msk (1UL /*<< CoreDebug_DHCSR_C_DEBUGEN_Pos*/) /*!< CoreDebug DHCSR: C_DEBUGEN Mask */
  862. /* Debug Core Register Selector Register Definitions */
  863. #define CoreDebug_DCRSR_REGWnR_Pos 16U /*!< CoreDebug DCRSR: REGWnR Position */
  864. #define CoreDebug_DCRSR_REGWnR_Msk (1UL << CoreDebug_DCRSR_REGWnR_Pos) /*!< CoreDebug DCRSR: REGWnR Mask */
  865. #define CoreDebug_DCRSR_REGSEL_Pos 0U /*!< CoreDebug DCRSR: REGSEL Position */
  866. #define CoreDebug_DCRSR_REGSEL_Msk (0x1FUL /*<< CoreDebug_DCRSR_REGSEL_Pos*/) /*!< CoreDebug DCRSR: REGSEL Mask */
  867. /* Debug Exception and Monitor Control Register */
  868. #define CoreDebug_DEMCR_DWTENA_Pos 24U /*!< CoreDebug DEMCR: DWTENA Position */
  869. #define CoreDebug_DEMCR_DWTENA_Msk (1UL << CoreDebug_DEMCR_DWTENA_Pos) /*!< CoreDebug DEMCR: DWTENA Mask */
  870. #define CoreDebug_DEMCR_VC_HARDERR_Pos 10U /*!< CoreDebug DEMCR: VC_HARDERR Position */
  871. #define CoreDebug_DEMCR_VC_HARDERR_Msk (1UL << CoreDebug_DEMCR_VC_HARDERR_Pos) /*!< CoreDebug DEMCR: VC_HARDERR Mask */
  872. #define CoreDebug_DEMCR_VC_CORERESET_Pos 0U /*!< CoreDebug DEMCR: VC_CORERESET Position */
  873. #define CoreDebug_DEMCR_VC_CORERESET_Msk (1UL /*<< CoreDebug_DEMCR_VC_CORERESET_Pos*/) /*!< CoreDebug DEMCR: VC_CORERESET Mask */
  874. /* Debug Authentication Control Register Definitions */
  875. #define CoreDebug_DAUTHCTRL_INTSPNIDEN_Pos 3U /*!< CoreDebug DAUTHCTRL: INTSPNIDEN, Position */
  876. #define CoreDebug_DAUTHCTRL_INTSPNIDEN_Msk (1UL << CoreDebug_DAUTHCTRL_INTSPNIDEN_Pos) /*!< CoreDebug DAUTHCTRL: INTSPNIDEN, Mask */
  877. #define CoreDebug_DAUTHCTRL_SPNIDENSEL_Pos 2U /*!< CoreDebug DAUTHCTRL: SPNIDENSEL Position */
  878. #define CoreDebug_DAUTHCTRL_SPNIDENSEL_Msk (1UL << CoreDebug_DAUTHCTRL_SPNIDENSEL_Pos) /*!< CoreDebug DAUTHCTRL: SPNIDENSEL Mask */
  879. #define CoreDebug_DAUTHCTRL_INTSPIDEN_Pos 1U /*!< CoreDebug DAUTHCTRL: INTSPIDEN Position */
  880. #define CoreDebug_DAUTHCTRL_INTSPIDEN_Msk (1UL << CoreDebug_DAUTHCTRL_INTSPIDEN_Pos) /*!< CoreDebug DAUTHCTRL: INTSPIDEN Mask */
  881. #define CoreDebug_DAUTHCTRL_SPIDENSEL_Pos 0U /*!< CoreDebug DAUTHCTRL: SPIDENSEL Position */
  882. #define CoreDebug_DAUTHCTRL_SPIDENSEL_Msk (1UL /*<< CoreDebug_DAUTHCTRL_SPIDENSEL_Pos*/) /*!< CoreDebug DAUTHCTRL: SPIDENSEL Mask */
  883. /* Debug Security Control and Status Register Definitions */
  884. #define CoreDebug_DSCSR_CDS_Pos 16U /*!< CoreDebug DSCSR: CDS Position */
  885. #define CoreDebug_DSCSR_CDS_Msk (1UL << CoreDebug_DSCSR_CDS_Pos) /*!< CoreDebug DSCSR: CDS Mask */
  886. #define CoreDebug_DSCSR_SBRSEL_Pos 1U /*!< CoreDebug DSCSR: SBRSEL Position */
  887. #define CoreDebug_DSCSR_SBRSEL_Msk (1UL << CoreDebug_DSCSR_SBRSEL_Pos) /*!< CoreDebug DSCSR: SBRSEL Mask */
  888. #define CoreDebug_DSCSR_SBRSELEN_Pos 0U /*!< CoreDebug DSCSR: SBRSELEN Position */
  889. #define CoreDebug_DSCSR_SBRSELEN_Msk (1UL /*<< CoreDebug_DSCSR_SBRSELEN_Pos*/) /*!< CoreDebug DSCSR: SBRSELEN Mask */
  890. /*@} end of group CMSIS_CoreDebug */
  891. /**
  892. \ingroup CMSIS_core_register
  893. \defgroup CMSIS_core_bitfield Core register bit field macros
  894. \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk).
  895. @{
  896. */
  897. /**
  898. \brief Mask and shift a bit field value for use in a register bit range.
  899. \param[in] field Name of the register bit field.
  900. \param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type.
  901. \return Masked and shifted value.
  902. */
  903. #define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk)
  904. /**
  905. \brief Mask and shift a register value to extract a bit filed value.
  906. \param[in] field Name of the register bit field.
  907. \param[in] value Value of register. This parameter is interpreted as an uint32_t type.
  908. \return Masked and shifted bit field value.
  909. */
  910. #define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos)
  911. /*@} end of group CMSIS_core_bitfield */
  912. /**
  913. \ingroup CMSIS_core_register
  914. \defgroup CMSIS_core_base Core Definitions
  915. \brief Definitions for base addresses, unions, and structures.
  916. @{
  917. */
  918. /* Memory mapping of Core Hardware */
  919. #define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */
  920. #define DWT_BASE (0xE0001000UL) /*!< DWT Base Address */
  921. #define TPI_BASE (0xE0040000UL) /*!< TPI Base Address */
  922. #define CoreDebug_BASE (0xE000EDF0UL) /*!< Core Debug Base Address */
  923. #define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */
  924. #define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */
  925. #define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */
  926. #define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */
  927. #define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */
  928. #define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */
  929. #define DWT ((DWT_Type *) DWT_BASE ) /*!< DWT configuration struct */
  930. #define TPI ((TPI_Type *) TPI_BASE ) /*!< TPI configuration struct */
  931. #define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE ) /*!< Core Debug configuration struct */
  932. #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U)
  933. #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */
  934. #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */
  935. #endif
  936. #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
  937. #define SAU_BASE (SCS_BASE + 0x0DD0UL) /*!< Security Attribution Unit */
  938. #define SAU ((SAU_Type *) SAU_BASE ) /*!< Security Attribution Unit */
  939. #endif
  940. #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
  941. #define SCS_BASE_NS (0xE002E000UL) /*!< System Control Space Base Address (non-secure address space) */
  942. #define CoreDebug_BASE_NS (0xE002EDF0UL) /*!< Core Debug Base Address (non-secure address space) */
  943. #define SysTick_BASE_NS (SCS_BASE_NS + 0x0010UL) /*!< SysTick Base Address (non-secure address space) */
  944. #define NVIC_BASE_NS (SCS_BASE_NS + 0x0100UL) /*!< NVIC Base Address (non-secure address space) */
  945. #define SCB_BASE_NS (SCS_BASE_NS + 0x0D00UL) /*!< System Control Block Base Address (non-secure address space) */
  946. #define SCB_NS ((SCB_Type *) SCB_BASE_NS ) /*!< SCB configuration struct (non-secure address space) */
  947. #define SysTick_NS ((SysTick_Type *) SysTick_BASE_NS ) /*!< SysTick configuration struct (non-secure address space) */
  948. #define NVIC_NS ((NVIC_Type *) NVIC_BASE_NS ) /*!< NVIC configuration struct (non-secure address space) */
  949. #define CoreDebug_NS ((CoreDebug_Type *) CoreDebug_BASE_NS) /*!< Core Debug configuration struct (non-secure address space) */
  950. #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U)
  951. #define MPU_BASE_NS (SCS_BASE_NS + 0x0D90UL) /*!< Memory Protection Unit (non-secure address space) */
  952. #define MPU_NS ((MPU_Type *) MPU_BASE_NS ) /*!< Memory Protection Unit (non-secure address space) */
  953. #endif
  954. #endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */
  955. /*@} */
  956. /*******************************************************************************
  957. * Hardware Abstraction Layer
  958. Core Function Interface contains:
  959. - Core NVIC Functions
  960. - Core SysTick Functions
  961. - Core Register Access Functions
  962. ******************************************************************************/
  963. /**
  964. \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference
  965. */
  966. /* ########################## NVIC functions #################################### */
  967. /**
  968. \ingroup CMSIS_Core_FunctionInterface
  969. \defgroup CMSIS_Core_NVICFunctions NVIC Functions
  970. \brief Functions that manage interrupts and exceptions via the NVIC.
  971. @{
  972. */
  973. #ifdef CMSIS_NVIC_VIRTUAL
  974. #ifndef CMSIS_NVIC_VIRTUAL_HEADER_FILE
  975. #define CMSIS_NVIC_VIRTUAL_HEADER_FILE "cmsis_nvic_virtual.h"
  976. #endif
  977. #include CMSIS_NVIC_VIRTUAL_HEADER_FILE
  978. #else
  979. /*#define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping not available for Cortex-M23 */
  980. /*#define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping not available for Cortex-M23 */
  981. #define NVIC_EnableIRQ __NVIC_EnableIRQ
  982. #define NVIC_GetEnableIRQ __NVIC_GetEnableIRQ
  983. #define NVIC_DisableIRQ __NVIC_DisableIRQ
  984. #define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ
  985. #define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ
  986. #define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ
  987. #define NVIC_GetActive __NVIC_GetActive
  988. #define NVIC_SetPriority __NVIC_SetPriority
  989. #define NVIC_GetPriority __NVIC_GetPriority
  990. #define NVIC_SystemReset __NVIC_SystemReset
  991. #endif /* CMSIS_NVIC_VIRTUAL */
  992. #ifdef CMSIS_VECTAB_VIRTUAL
  993. #ifndef CMSIS_VECTAB_VIRTUAL_HEADER_FILE
  994. #define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "cmsis_vectab_virtual.h"
  995. #endif
  996. #include CMSIS_VECTAB_VIRTUAL_HEADER_FILE
  997. #else
  998. #define NVIC_SetVector __NVIC_SetVector
  999. #define NVIC_GetVector __NVIC_GetVector
  1000. #endif /* (CMSIS_VECTAB_VIRTUAL) */
  1001. #define NVIC_USER_IRQ_OFFSET 16
  1002. /* Special LR values for Secure/Non-Secure call handling and exception handling */
  1003. /* Function Return Payload (from ARMv8-M Architecture Reference Manual) LR value on entry from Secure BLXNS */
  1004. #define FNC_RETURN (0xFEFFFFFFUL) /* bit [0] ignored when processing a branch */
  1005. /* The following EXC_RETURN mask values are used to evaluate the LR on exception entry */
  1006. #define EXC_RETURN_PREFIX (0xFF000000UL) /* bits [31:24] set to indicate an EXC_RETURN value */
  1007. #define EXC_RETURN_S (0x00000040UL) /* bit [6] stack used to push registers: 0=Non-secure 1=Secure */
  1008. #define EXC_RETURN_DCRS (0x00000020UL) /* bit [5] stacking rules for called registers: 0=skipped 1=saved */
  1009. #define EXC_RETURN_FTYPE (0x00000010UL) /* bit [4] allocate stack for floating-point context: 0=done 1=skipped */
  1010. #define EXC_RETURN_MODE (0x00000008UL) /* bit [3] processor mode for return: 0=Handler mode 1=Thread mode */
  1011. #define EXC_RETURN_SPSEL (0x00000002UL) /* bit [1] stack pointer used to restore context: 0=MSP 1=PSP */
  1012. #define EXC_RETURN_ES (0x00000001UL) /* bit [0] security state exception was taken to: 0=Non-secure 1=Secure */
  1013. /* Integrity Signature (from ARMv8-M Architecture Reference Manual) for exception context stacking */
  1014. #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) /* Value for processors with floating-point extension: */
  1015. #define EXC_INTEGRITY_SIGNATURE (0xFEFA125AUL) /* bit [0] SFTC must match LR bit[4] EXC_RETURN_FTYPE */
  1016. #else
  1017. #define EXC_INTEGRITY_SIGNATURE (0xFEFA125BUL) /* Value for processors without floating-point extension */
  1018. #endif
  1019. /* Interrupt Priorities are WORD accessible only under Armv6-M */
  1020. /* The following MACROS handle generation of the register offset and byte masks */
  1021. #define _BIT_SHIFT(IRQn) ( ((((uint32_t)(int32_t)(IRQn)) ) & 0x03UL) * 8UL)
  1022. #define _SHP_IDX(IRQn) ( (((((uint32_t)(int32_t)(IRQn)) & 0x0FUL)-8UL) >> 2UL) )
  1023. #define _IP_IDX(IRQn) ( (((uint32_t)(int32_t)(IRQn)) >> 2UL) )
  1024. #define __NVIC_SetPriorityGrouping(X) (void)(X)
  1025. #define __NVIC_GetPriorityGrouping() (0U)
  1026. /**
  1027. \brief Enable Interrupt
  1028. \details Enables a device specific interrupt in the NVIC interrupt controller.
  1029. \param [in] IRQn Device specific interrupt number.
  1030. \note IRQn must not be negative.
  1031. */
  1032. __STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn)
  1033. {
  1034. if ((int32_t)(IRQn) >= 0)
  1035. {
  1036. NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL));
  1037. }
  1038. }
  1039. /**
  1040. \brief Get Interrupt Enable status
  1041. \details Returns a device specific interrupt enable status from the NVIC interrupt controller.
  1042. \param [in] IRQn Device specific interrupt number.
  1043. \return 0 Interrupt is not enabled.
  1044. \return 1 Interrupt is enabled.
  1045. \note IRQn must not be negative.
  1046. */
  1047. __STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn)
  1048. {
  1049. if ((int32_t)(IRQn) >= 0)
  1050. {
  1051. return((uint32_t)(((NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL));
  1052. }
  1053. else
  1054. {
  1055. return(0U);
  1056. }
  1057. }
  1058. /**
  1059. \brief Disable Interrupt
  1060. \details Disables a device specific interrupt in the NVIC interrupt controller.
  1061. \param [in] IRQn Device specific interrupt number.
  1062. \note IRQn must not be negative.
  1063. */
  1064. __STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn)
  1065. {
  1066. if ((int32_t)(IRQn) >= 0)
  1067. {
  1068. NVIC->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL));
  1069. __DSB();
  1070. __ISB();
  1071. }
  1072. }
  1073. /**
  1074. \brief Get Pending Interrupt
  1075. \details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt.
  1076. \param [in] IRQn Device specific interrupt number.
  1077. \return 0 Interrupt status is not pending.
  1078. \return 1 Interrupt status is pending.
  1079. \note IRQn must not be negative.
  1080. */
  1081. __STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn)
  1082. {
  1083. if ((int32_t)(IRQn) >= 0)
  1084. {
  1085. return((uint32_t)(((NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL));
  1086. }
  1087. else
  1088. {
  1089. return(0U);
  1090. }
  1091. }
  1092. /**
  1093. \brief Set Pending Interrupt
  1094. \details Sets the pending bit of a device specific interrupt in the NVIC pending register.
  1095. \param [in] IRQn Device specific interrupt number.
  1096. \note IRQn must not be negative.
  1097. */
  1098. __STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn)
  1099. {
  1100. if ((int32_t)(IRQn) >= 0)
  1101. {
  1102. NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL));
  1103. }
  1104. }
  1105. /**
  1106. \brief Clear Pending Interrupt
  1107. \details Clears the pending bit of a device specific interrupt in the NVIC pending register.
  1108. \param [in] IRQn Device specific interrupt number.
  1109. \note IRQn must not be negative.
  1110. */
  1111. __STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn)
  1112. {
  1113. if ((int32_t)(IRQn) >= 0)
  1114. {
  1115. NVIC->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL));
  1116. }
  1117. }
  1118. /**
  1119. \brief Get Active Interrupt
  1120. \details Reads the active register in the NVIC and returns the active bit for the device specific interrupt.
  1121. \param [in] IRQn Device specific interrupt number.
  1122. \return 0 Interrupt status is not active.
  1123. \return 1 Interrupt status is active.
  1124. \note IRQn must not be negative.
  1125. */
  1126. __STATIC_INLINE uint32_t __NVIC_GetActive(IRQn_Type IRQn)
  1127. {
  1128. if ((int32_t)(IRQn) >= 0)
  1129. {
  1130. return((uint32_t)(((NVIC->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL));
  1131. }
  1132. else
  1133. {
  1134. return(0U);
  1135. }
  1136. }
  1137. #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
  1138. /**
  1139. \brief Get Interrupt Target State
  1140. \details Reads the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt.
  1141. \param [in] IRQn Device specific interrupt number.
  1142. \return 0 if interrupt is assigned to Secure
  1143. \return 1 if interrupt is assigned to Non Secure
  1144. \note IRQn must not be negative.
  1145. */
  1146. __STATIC_INLINE uint32_t NVIC_GetTargetState(IRQn_Type IRQn)
  1147. {
  1148. if ((int32_t)(IRQn) >= 0)
  1149. {
  1150. return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL));
  1151. }
  1152. else
  1153. {
  1154. return(0U);
  1155. }
  1156. }
  1157. /**
  1158. \brief Set Interrupt Target State
  1159. \details Sets the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt.
  1160. \param [in] IRQn Device specific interrupt number.
  1161. \return 0 if interrupt is assigned to Secure
  1162. 1 if interrupt is assigned to Non Secure
  1163. \note IRQn must not be negative.
  1164. */
  1165. __STATIC_INLINE uint32_t NVIC_SetTargetState(IRQn_Type IRQn)
  1166. {
  1167. if ((int32_t)(IRQn) >= 0)
  1168. {
  1169. NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] |= ((uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)));
  1170. return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL));
  1171. }
  1172. else
  1173. {
  1174. return(0U);
  1175. }
  1176. }
  1177. /**
  1178. \brief Clear Interrupt Target State
  1179. \details Clears the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt.
  1180. \param [in] IRQn Device specific interrupt number.
  1181. \return 0 if interrupt is assigned to Secure
  1182. 1 if interrupt is assigned to Non Secure
  1183. \note IRQn must not be negative.
  1184. */
  1185. __STATIC_INLINE uint32_t NVIC_ClearTargetState(IRQn_Type IRQn)
  1186. {
  1187. if ((int32_t)(IRQn) >= 0)
  1188. {
  1189. NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] &= ~((uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)));
  1190. return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL));
  1191. }
  1192. else
  1193. {
  1194. return(0U);
  1195. }
  1196. }
  1197. #endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */
  1198. /**
  1199. \brief Set Interrupt Priority
  1200. \details Sets the priority of a device specific interrupt or a processor exception.
  1201. The interrupt number can be positive to specify a device specific interrupt,
  1202. or negative to specify a processor exception.
  1203. \param [in] IRQn Interrupt number.
  1204. \param [in] priority Priority to set.
  1205. \note The priority cannot be set for every processor exception.
  1206. */
  1207. __STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority)
  1208. {
  1209. if ((int32_t)(IRQn) >= 0)
  1210. {
  1211. NVIC->IPR[_IP_IDX(IRQn)] = ((uint32_t)(NVIC->IPR[_IP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) |
  1212. (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn)));
  1213. }
  1214. else
  1215. {
  1216. SCB->SHPR[_SHP_IDX(IRQn)] = ((uint32_t)(SCB->SHPR[_SHP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) |
  1217. (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn)));
  1218. }
  1219. }
  1220. /**
  1221. \brief Get Interrupt Priority
  1222. \details Reads the priority of a device specific interrupt or a processor exception.
  1223. The interrupt number can be positive to specify a device specific interrupt,
  1224. or negative to specify a processor exception.
  1225. \param [in] IRQn Interrupt number.
  1226. \return Interrupt Priority.
  1227. Value is aligned automatically to the implemented priority bits of the microcontroller.
  1228. */
  1229. __STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn)
  1230. {
  1231. if ((int32_t)(IRQn) >= 0)
  1232. {
  1233. return((uint32_t)(((NVIC->IPR[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS)));
  1234. }
  1235. else
  1236. {
  1237. return((uint32_t)(((SCB->SHPR[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS)));
  1238. }
  1239. }
  1240. /**
  1241. \brief Encode Priority
  1242. \details Encodes the priority for an interrupt with the given priority group,
  1243. preemptive priority value, and subpriority value.
  1244. In case of a conflict between priority grouping and available
  1245. priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set.
  1246. \param [in] PriorityGroup Used priority group.
  1247. \param [in] PreemptPriority Preemptive priority value (starting from 0).
  1248. \param [in] SubPriority Subpriority value (starting from 0).
  1249. \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority().
  1250. */
  1251. __STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority)
  1252. {
  1253. uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */
  1254. uint32_t PreemptPriorityBits;
  1255. uint32_t SubPriorityBits;
  1256. PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp);
  1257. SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS));
  1258. return (
  1259. ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) |
  1260. ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL)))
  1261. );
  1262. }
  1263. /**
  1264. \brief Decode Priority
  1265. \details Decodes an interrupt priority value with a given priority group to
  1266. preemptive priority value and subpriority value.
  1267. In case of a conflict between priority grouping and available
  1268. priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set.
  1269. \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority().
  1270. \param [in] PriorityGroup Used priority group.
  1271. \param [out] pPreemptPriority Preemptive priority value (starting from 0).
  1272. \param [out] pSubPriority Subpriority value (starting from 0).
  1273. */
  1274. __STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority)
  1275. {
  1276. uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */
  1277. uint32_t PreemptPriorityBits;
  1278. uint32_t SubPriorityBits;
  1279. PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp);
  1280. SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS));
  1281. *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL);
  1282. *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL);
  1283. }
  1284. /**
  1285. \brief Set Interrupt Vector
  1286. \details Sets an interrupt vector in SRAM based interrupt vector table.
  1287. The interrupt number can be positive to specify a device specific interrupt,
  1288. or negative to specify a processor exception.
  1289. VTOR must been relocated to SRAM before.
  1290. If VTOR is not present address 0 must be mapped to SRAM.
  1291. \param [in] IRQn Interrupt number
  1292. \param [in] vector Address of interrupt handler function
  1293. */
  1294. __STATIC_INLINE void __NVIC_SetVector(IRQn_Type IRQn, uint32_t vector)
  1295. {
  1296. #if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1U)
  1297. uint32_t *vectors = (uint32_t *)SCB->VTOR;
  1298. #else
  1299. uint32_t *vectors = (uint32_t *)0x0U;
  1300. #endif
  1301. vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET] = vector;
  1302. }
  1303. /**
  1304. \brief Get Interrupt Vector
  1305. \details Reads an interrupt vector from interrupt vector table.
  1306. The interrupt number can be positive to specify a device specific interrupt,
  1307. or negative to specify a processor exception.
  1308. \param [in] IRQn Interrupt number.
  1309. \return Address of interrupt handler function
  1310. */
  1311. __STATIC_INLINE uint32_t __NVIC_GetVector(IRQn_Type IRQn)
  1312. {
  1313. #if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1U)
  1314. uint32_t *vectors = (uint32_t *)SCB->VTOR;
  1315. #else
  1316. uint32_t *vectors = (uint32_t *)0x0U;
  1317. #endif
  1318. return vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET];
  1319. }
  1320. /**
  1321. \brief System Reset
  1322. \details Initiates a system reset request to reset the MCU.
  1323. */
  1324. __NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void)
  1325. {
  1326. __DSB(); /* Ensure all outstanding memory accesses included
  1327. buffered write are completed before reset */
  1328. SCB->AIRCR = ((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) |
  1329. SCB_AIRCR_SYSRESETREQ_Msk);
  1330. __DSB(); /* Ensure completion of memory access */
  1331. for(;;) /* wait until reset */
  1332. {
  1333. __NOP();
  1334. }
  1335. }
  1336. #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
  1337. /**
  1338. \brief Enable Interrupt (non-secure)
  1339. \details Enables a device specific interrupt in the non-secure NVIC interrupt controller when in secure state.
  1340. \param [in] IRQn Device specific interrupt number.
  1341. \note IRQn must not be negative.
  1342. */
  1343. __STATIC_INLINE void TZ_NVIC_EnableIRQ_NS(IRQn_Type IRQn)
  1344. {
  1345. if ((int32_t)(IRQn) >= 0)
  1346. {
  1347. NVIC_NS->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL));
  1348. }
  1349. }
  1350. /**
  1351. \brief Get Interrupt Enable status (non-secure)
  1352. \details Returns a device specific interrupt enable status from the non-secure NVIC interrupt controller when in secure state.
  1353. \param [in] IRQn Device specific interrupt number.
  1354. \return 0 Interrupt is not enabled.
  1355. \return 1 Interrupt is enabled.
  1356. \note IRQn must not be negative.
  1357. */
  1358. __STATIC_INLINE uint32_t TZ_NVIC_GetEnableIRQ_NS(IRQn_Type IRQn)
  1359. {
  1360. if ((int32_t)(IRQn) >= 0)
  1361. {
  1362. return((uint32_t)(((NVIC_NS->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL));
  1363. }
  1364. else
  1365. {
  1366. return(0U);
  1367. }
  1368. }
  1369. /**
  1370. \brief Disable Interrupt (non-secure)
  1371. \details Disables a device specific interrupt in the non-secure NVIC interrupt controller when in secure state.
  1372. \param [in] IRQn Device specific interrupt number.
  1373. \note IRQn must not be negative.
  1374. */
  1375. __STATIC_INLINE void TZ_NVIC_DisableIRQ_NS(IRQn_Type IRQn)
  1376. {
  1377. if ((int32_t)(IRQn) >= 0)
  1378. {
  1379. NVIC_NS->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL));
  1380. }
  1381. }
  1382. /**
  1383. \brief Get Pending Interrupt (non-secure)
  1384. \details Reads the NVIC pending register in the non-secure NVIC when in secure state and returns the pending bit for the specified device specific interrupt.
  1385. \param [in] IRQn Device specific interrupt number.
  1386. \return 0 Interrupt status is not pending.
  1387. \return 1 Interrupt status is pending.
  1388. \note IRQn must not be negative.
  1389. */
  1390. __STATIC_INLINE uint32_t TZ_NVIC_GetPendingIRQ_NS(IRQn_Type IRQn)
  1391. {
  1392. if ((int32_t)(IRQn) >= 0)
  1393. {
  1394. return((uint32_t)(((NVIC_NS->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL));
  1395. }
  1396. else
  1397. {
  1398. return(0U);
  1399. }
  1400. }
  1401. /**
  1402. \brief Set Pending Interrupt (non-secure)
  1403. \details Sets the pending bit of a device specific interrupt in the non-secure NVIC pending register when in secure state.
  1404. \param [in] IRQn Device specific interrupt number.
  1405. \note IRQn must not be negative.
  1406. */
  1407. __STATIC_INLINE void TZ_NVIC_SetPendingIRQ_NS(IRQn_Type IRQn)
  1408. {
  1409. if ((int32_t)(IRQn) >= 0)
  1410. {
  1411. NVIC_NS->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL));
  1412. }
  1413. }
  1414. /**
  1415. \brief Clear Pending Interrupt (non-secure)
  1416. \details Clears the pending bit of a device specific interrupt in the non-secure NVIC pending register when in secure state.
  1417. \param [in] IRQn Device specific interrupt number.
  1418. \note IRQn must not be negative.
  1419. */
  1420. __STATIC_INLINE void TZ_NVIC_ClearPendingIRQ_NS(IRQn_Type IRQn)
  1421. {
  1422. if ((int32_t)(IRQn) >= 0)
  1423. {
  1424. NVIC_NS->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL));
  1425. }
  1426. }
  1427. /**
  1428. \brief Get Active Interrupt (non-secure)
  1429. \details Reads the active register in non-secure NVIC when in secure state and returns the active bit for the device specific interrupt.
  1430. \param [in] IRQn Device specific interrupt number.
  1431. \return 0 Interrupt status is not active.
  1432. \return 1 Interrupt status is active.
  1433. \note IRQn must not be negative.
  1434. */
  1435. __STATIC_INLINE uint32_t TZ_NVIC_GetActive_NS(IRQn_Type IRQn)
  1436. {
  1437. if ((int32_t)(IRQn) >= 0)
  1438. {
  1439. return((uint32_t)(((NVIC_NS->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL));
  1440. }
  1441. else
  1442. {
  1443. return(0U);
  1444. }
  1445. }
  1446. /**
  1447. \brief Set Interrupt Priority (non-secure)
  1448. \details Sets the priority of a non-secure device specific interrupt or a non-secure processor exception when in secure state.
  1449. The interrupt number can be positive to specify a device specific interrupt,
  1450. or negative to specify a processor exception.
  1451. \param [in] IRQn Interrupt number.
  1452. \param [in] priority Priority to set.
  1453. \note The priority cannot be set for every non-secure processor exception.
  1454. */
  1455. __STATIC_INLINE void TZ_NVIC_SetPriority_NS(IRQn_Type IRQn, uint32_t priority)
  1456. {
  1457. if ((int32_t)(IRQn) >= 0)
  1458. {
  1459. NVIC_NS->IPR[_IP_IDX(IRQn)] = ((uint32_t)(NVIC_NS->IPR[_IP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) |
  1460. (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn)));
  1461. }
  1462. else
  1463. {
  1464. SCB_NS->SHPR[_SHP_IDX(IRQn)] = ((uint32_t)(SCB_NS->SHPR[_SHP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) |
  1465. (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn)));
  1466. }
  1467. }
  1468. /**
  1469. \brief Get Interrupt Priority (non-secure)
  1470. \details Reads the priority of a non-secure device specific interrupt or a non-secure processor exception when in secure state.
  1471. The interrupt number can be positive to specify a device specific interrupt,
  1472. or negative to specify a processor exception.
  1473. \param [in] IRQn Interrupt number.
  1474. \return Interrupt Priority. Value is aligned automatically to the implemented priority bits of the microcontroller.
  1475. */
  1476. __STATIC_INLINE uint32_t TZ_NVIC_GetPriority_NS(IRQn_Type IRQn)
  1477. {
  1478. if ((int32_t)(IRQn) >= 0)
  1479. {
  1480. return((uint32_t)(((NVIC_NS->IPR[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS)));
  1481. }
  1482. else
  1483. {
  1484. return((uint32_t)(((SCB_NS->SHPR[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS)));
  1485. }
  1486. }
  1487. #endif /* defined (__ARM_FEATURE_CMSE) &&(__ARM_FEATURE_CMSE == 3U) */
  1488. /*@} end of CMSIS_Core_NVICFunctions */
  1489. /* ########################## MPU functions #################################### */
  1490. #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U)
  1491. #include "mpu_armv8.h"
  1492. #endif
  1493. /* ########################## FPU functions #################################### */
  1494. /**
  1495. \ingroup CMSIS_Core_FunctionInterface
  1496. \defgroup CMSIS_Core_FpuFunctions FPU Functions
  1497. \brief Function that provides FPU type.
  1498. @{
  1499. */
  1500. /**
  1501. \brief get FPU type
  1502. \details returns the FPU type
  1503. \returns
  1504. - \b 0: No FPU
  1505. - \b 1: Single precision FPU
  1506. - \b 2: Double + Single precision FPU
  1507. */
  1508. __STATIC_INLINE uint32_t SCB_GetFPUType(void)
  1509. {
  1510. return 0U; /* No FPU */
  1511. }
  1512. /*@} end of CMSIS_Core_FpuFunctions */
  1513. /* ########################## SAU functions #################################### */
  1514. /**
  1515. \ingroup CMSIS_Core_FunctionInterface
  1516. \defgroup CMSIS_Core_SAUFunctions SAU Functions
  1517. \brief Functions that configure the SAU.
  1518. @{
  1519. */
  1520. #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
  1521. /**
  1522. \brief Enable SAU
  1523. \details Enables the Security Attribution Unit (SAU).
  1524. */
  1525. __STATIC_INLINE void TZ_SAU_Enable(void)
  1526. {
  1527. SAU->CTRL |= (SAU_CTRL_ENABLE_Msk);
  1528. }
  1529. /**
  1530. \brief Disable SAU
  1531. \details Disables the Security Attribution Unit (SAU).
  1532. */
  1533. __STATIC_INLINE void TZ_SAU_Disable(void)
  1534. {
  1535. SAU->CTRL &= ~(SAU_CTRL_ENABLE_Msk);
  1536. }
  1537. #endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */
  1538. /*@} end of CMSIS_Core_SAUFunctions */
  1539. /* ################################## SysTick function ############################################ */
  1540. /**
  1541. \ingroup CMSIS_Core_FunctionInterface
  1542. \defgroup CMSIS_Core_SysTickFunctions SysTick Functions
  1543. \brief Functions that configure the System.
  1544. @{
  1545. */
  1546. #if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U)
  1547. /**
  1548. \brief System Tick Configuration
  1549. \details Initializes the System Timer and its interrupt, and starts the System Tick Timer.
  1550. Counter is in free running mode to generate periodic interrupts.
  1551. \param [in] ticks Number of ticks between two interrupts.
  1552. \return 0 Function succeeded.
  1553. \return 1 Function failed.
  1554. \note When the variable <b>__Vendor_SysTickConfig</b> is set to 1, then the
  1555. function <b>SysTick_Config</b> is not included. In this case, the file <b><i>device</i>.h</b>
  1556. must contain a vendor-specific implementation of this function.
  1557. */
  1558. __STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks)
  1559. {
  1560. if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk)
  1561. {
  1562. return (1UL); /* Reload value impossible */
  1563. }
  1564. SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */
  1565. NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */
  1566. SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
  1567. SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk |
  1568. SysTick_CTRL_TICKINT_Msk |
  1569. SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */
  1570. return (0UL); /* Function successful */
  1571. }
  1572. #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
  1573. /**
  1574. \brief System Tick Configuration (non-secure)
  1575. \details Initializes the non-secure System Timer and its interrupt when in secure state, and starts the System Tick Timer.
  1576. Counter is in free running mode to generate periodic interrupts.
  1577. \param [in] ticks Number of ticks between two interrupts.
  1578. \return 0 Function succeeded.
  1579. \return 1 Function failed.
  1580. \note When the variable <b>__Vendor_SysTickConfig</b> is set to 1, then the
  1581. function <b>TZ_SysTick_Config_NS</b> is not included. In this case, the file <b><i>device</i>.h</b>
  1582. must contain a vendor-specific implementation of this function.
  1583. */
  1584. __STATIC_INLINE uint32_t TZ_SysTick_Config_NS(uint32_t ticks)
  1585. {
  1586. if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk)
  1587. {
  1588. return (1UL); /* Reload value impossible */
  1589. }
  1590. SysTick_NS->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */
  1591. TZ_NVIC_SetPriority_NS (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */
  1592. SysTick_NS->VAL = 0UL; /* Load the SysTick Counter Value */
  1593. SysTick_NS->CTRL = SysTick_CTRL_CLKSOURCE_Msk |
  1594. SysTick_CTRL_TICKINT_Msk |
  1595. SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */
  1596. return (0UL); /* Function successful */
  1597. }
  1598. #endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */
  1599. #endif
  1600. /*@} end of CMSIS_Core_SysTickFunctions */
  1601. #ifdef __cplusplus
  1602. }
  1603. #endif
  1604. #endif /* __CORE_CM23_H_DEPENDANT */
  1605. #endif /* __CMSIS_GENERIC */