core_cm3.h 84 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819
  1. /**************************************************************************//**
  2. * @file core_cm3.h
  3. * @brief CMSIS Cortex-M3 Core Peripheral Access Layer Header File
  4. * @version V1.30
  5. * @date 30. October 2009
  6. *
  7. * @note
  8. * Copyright (C) 2009 ARM Limited. All rights reserved.
  9. *
  10. * @par
  11. * ARM Limited (ARM) is supplying this software for use with Cortex-M
  12. * processor based microcontrollers. This file can be freely distributed
  13. * within development tools that are supporting such ARM based processors.
  14. *
  15. * @par
  16. * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
  17. * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
  18. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
  19. * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
  20. * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
  21. *
  22. ******************************************************************************/
  23. #ifndef __CM3_CORE_H__
  24. #define __CM3_CORE_H__
  25. /** @addtogroup CMSIS_CM3_core_LintCinfiguration CMSIS CM3 Core Lint Configuration
  26. *
  27. * List of Lint messages which will be suppressed and not shown:
  28. * - Error 10: \n
  29. * register uint32_t __regBasePri __asm("basepri"); \n
  30. * Error 10: Expecting ';'
  31. * .
  32. * - Error 530: \n
  33. * return(__regBasePri); \n
  34. * Warning 530: Symbol '__regBasePri' (line 264) not initialized
  35. * .
  36. * - Error 550: \n
  37. * __regBasePri = (basePri & 0x1ff); \n
  38. * Warning 550: Symbol '__regBasePri' (line 271) not accessed
  39. * .
  40. * - Error 754: \n
  41. * uint32_t RESERVED0[24]; \n
  42. * Info 754: local structure member '<some, not used in the HAL>' (line 109, file ./cm3_core.h) not referenced
  43. * .
  44. * - Error 750: \n
  45. * #define __CM3_CORE_H__ \n
  46. * Info 750: local macro '__CM3_CORE_H__' (line 43, file./cm3_core.h) not referenced
  47. * .
  48. * - Error 528: \n
  49. * static __INLINE void NVIC_DisableIRQ(uint32_t IRQn) \n
  50. * Warning 528: Symbol 'NVIC_DisableIRQ(unsigned int)' (line 419, file ./cm3_core.h) not referenced
  51. * .
  52. * - Error 751: \n
  53. * } InterruptType_Type; \n
  54. * Info 751: local typedef 'InterruptType_Type' (line 170, file ./cm3_core.h) not referenced
  55. * .
  56. * Note: To re-enable a Message, insert a space before 'lint' *
  57. *
  58. */
  59. /*lint -save */
  60. /*lint -e10 */
  61. /*lint -e530 */
  62. /*lint -e550 */
  63. /*lint -e754 */
  64. /*lint -e750 */
  65. /*lint -e528 */
  66. /*lint -e751 */
  67. /** @addtogroup CMSIS_CM3_core_definitions CM3 Core Definitions
  68. This file defines all structures and symbols for CMSIS core:
  69. - CMSIS version number
  70. - Cortex-M core registers and bitfields
  71. - Cortex-M core peripheral base address
  72. @{
  73. */
  74. #ifdef __cplusplus
  75. extern "C" {
  76. #endif
  77. #define __CM3_CMSIS_VERSION_MAIN (0x01) /*!< [31:16] CMSIS HAL main version */
  78. #define __CM3_CMSIS_VERSION_SUB (0x30) /*!< [15:0] CMSIS HAL sub version */
  79. #define __CM3_CMSIS_VERSION ((__CM3_CMSIS_VERSION_MAIN << 16) | __CM3_CMSIS_VERSION_SUB) /*!< CMSIS HAL version number */
  80. #define __CORTEX_M (0x03) /*!< Cortex core */
  81. #include <stdint.h> /* Include standard types */
  82. #if defined (__ICCARM__)
  83. #include <intrinsics.h> /* IAR Intrinsics */
  84. #endif
  85. #ifndef __NVIC_PRIO_BITS
  86. #define __NVIC_PRIO_BITS 4 /*!< standard definition for NVIC Priority Bits */
  87. #endif
  88. /**
  89. * IO definitions
  90. *
  91. * define access restrictions to peripheral registers
  92. */
  93. #ifdef __cplusplus
  94. #define __I volatile /*!< defines 'read only' permissions */
  95. #else
  96. #define __I volatile const /*!< defines 'read only' permissions */
  97. #endif
  98. #define __O volatile /*!< defines 'write only' permissions */
  99. #define __IO volatile /*!< defines 'read / write' permissions */
  100. /*******************************************************************************
  101. * Register Abstraction
  102. ******************************************************************************/
  103. /** @addtogroup CMSIS_CM3_core_register CMSIS CM3 Core Register
  104. @{
  105. */
  106. /** @addtogroup CMSIS_CM3_NVIC CMSIS CM3 NVIC
  107. memory mapped structure for Nested Vectored Interrupt Controller (NVIC)
  108. @{
  109. */
  110. typedef struct
  111. {
  112. __IO uint32_t ISER[8]; /*!< Offset: 0x000 Interrupt Set Enable Register */
  113. uint32_t RESERVED0[24];
  114. __IO uint32_t ICER[8]; /*!< Offset: 0x080 Interrupt Clear Enable Register */
  115. uint32_t RSERVED1[24];
  116. __IO uint32_t ISPR[8]; /*!< Offset: 0x100 Interrupt Set Pending Register */
  117. uint32_t RESERVED2[24];
  118. __IO uint32_t ICPR[8]; /*!< Offset: 0x180 Interrupt Clear Pending Register */
  119. uint32_t RESERVED3[24];
  120. __IO uint32_t IABR[8]; /*!< Offset: 0x200 Interrupt Active bit Register */
  121. uint32_t RESERVED4[56];
  122. __IO uint8_t IP[240]; /*!< Offset: 0x300 Interrupt Priority Register (8Bit wide) */
  123. uint32_t RESERVED5[644];
  124. __O uint32_t STIR; /*!< Offset: 0xE00 Software Trigger Interrupt Register */
  125. } NVIC_Type;
  126. /*@}*/ /* end of group CMSIS_CM3_NVIC */
  127. /** @addtogroup CMSIS_CM3_SCB CMSIS CM3 SCB
  128. memory mapped structure for System Control Block (SCB)
  129. @{
  130. */
  131. typedef struct
  132. {
  133. __I uint32_t CPUID; /*!< Offset: 0x00 CPU ID Base Register */
  134. __IO uint32_t ICSR; /*!< Offset: 0x04 Interrupt Control State Register */
  135. __IO uint32_t VTOR; /*!< Offset: 0x08 Vector Table Offset Register */
  136. __IO uint32_t AIRCR; /*!< Offset: 0x0C Application Interrupt / Reset Control Register */
  137. __IO uint32_t SCR; /*!< Offset: 0x10 System Control Register */
  138. __IO uint32_t CCR; /*!< Offset: 0x14 Configuration Control Register */
  139. __IO uint8_t SHP[12]; /*!< Offset: 0x18 System Handlers Priority Registers (4-7, 8-11, 12-15) */
  140. __IO uint32_t SHCSR; /*!< Offset: 0x24 System Handler Control and State Register */
  141. __IO uint32_t CFSR; /*!< Offset: 0x28 Configurable Fault Status Register */
  142. __IO uint32_t HFSR; /*!< Offset: 0x2C Hard Fault Status Register */
  143. __IO uint32_t DFSR; /*!< Offset: 0x30 Debug Fault Status Register */
  144. __IO uint32_t MMFAR; /*!< Offset: 0x34 Mem Manage Address Register */
  145. __IO uint32_t BFAR; /*!< Offset: 0x38 Bus Fault Address Register */
  146. __IO uint32_t AFSR; /*!< Offset: 0x3C Auxiliary Fault Status Register */
  147. __I uint32_t PFR[2]; /*!< Offset: 0x40 Processor Feature Register */
  148. __I uint32_t DFR; /*!< Offset: 0x48 Debug Feature Register */
  149. __I uint32_t ADR; /*!< Offset: 0x4C Auxiliary Feature Register */
  150. __I uint32_t MMFR[4]; /*!< Offset: 0x50 Memory Model Feature Register */
  151. __I uint32_t ISAR[5]; /*!< Offset: 0x60 ISA Feature Register */
  152. } SCB_Type;
  153. /* SCB CPUID Register Definitions */
  154. #define SCB_CPUID_IMPLEMENTER_Pos 24 /*!< SCB CPUID: IMPLEMENTER Position */
  155. #define SCB_CPUID_IMPLEMENTER_Msk (0xFFul << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */
  156. #define SCB_CPUID_VARIANT_Pos 20 /*!< SCB CPUID: VARIANT Position */
  157. #define SCB_CPUID_VARIANT_Msk (0xFul << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */
  158. #define SCB_CPUID_PARTNO_Pos 4 /*!< SCB CPUID: PARTNO Position */
  159. #define SCB_CPUID_PARTNO_Msk (0xFFFul << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */
  160. #define SCB_CPUID_REVISION_Pos 0 /*!< SCB CPUID: REVISION Position */
  161. #define SCB_CPUID_REVISION_Msk (0xFul << SCB_CPUID_REVISION_Pos) /*!< SCB CPUID: REVISION Mask */
  162. /* SCB Interrupt Control State Register Definitions */
  163. #define SCB_ICSR_NMIPENDSET_Pos 31 /*!< SCB ICSR: NMIPENDSET Position */
  164. #define SCB_ICSR_NMIPENDSET_Msk (1ul << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */
  165. #define SCB_ICSR_PENDSVSET_Pos 28 /*!< SCB ICSR: PENDSVSET Position */
  166. #define SCB_ICSR_PENDSVSET_Msk (1ul << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */
  167. #define SCB_ICSR_PENDSVCLR_Pos 27 /*!< SCB ICSR: PENDSVCLR Position */
  168. #define SCB_ICSR_PENDSVCLR_Msk (1ul << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */
  169. #define SCB_ICSR_PENDSTSET_Pos 26 /*!< SCB ICSR: PENDSTSET Position */
  170. #define SCB_ICSR_PENDSTSET_Msk (1ul << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */
  171. #define SCB_ICSR_PENDSTCLR_Pos 25 /*!< SCB ICSR: PENDSTCLR Position */
  172. #define SCB_ICSR_PENDSTCLR_Msk (1ul << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */
  173. #define SCB_ICSR_ISRPREEMPT_Pos 23 /*!< SCB ICSR: ISRPREEMPT Position */
  174. #define SCB_ICSR_ISRPREEMPT_Msk (1ul << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */
  175. #define SCB_ICSR_ISRPENDING_Pos 22 /*!< SCB ICSR: ISRPENDING Position */
  176. #define SCB_ICSR_ISRPENDING_Msk (1ul << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */
  177. #define SCB_ICSR_VECTPENDING_Pos 12 /*!< SCB ICSR: VECTPENDING Position */
  178. #define SCB_ICSR_VECTPENDING_Msk (0x1FFul << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */
  179. #define SCB_ICSR_RETTOBASE_Pos 11 /*!< SCB ICSR: RETTOBASE Position */
  180. #define SCB_ICSR_RETTOBASE_Msk (1ul << SCB_ICSR_RETTOBASE_Pos) /*!< SCB ICSR: RETTOBASE Mask */
  181. #define SCB_ICSR_VECTACTIVE_Pos 0 /*!< SCB ICSR: VECTACTIVE Position */
  182. #define SCB_ICSR_VECTACTIVE_Msk (0x1FFul << SCB_ICSR_VECTACTIVE_Pos) /*!< SCB ICSR: VECTACTIVE Mask */
  183. /* SCB Interrupt Control State Register Definitions */
  184. #define SCB_VTOR_TBLBASE_Pos 29 /*!< SCB VTOR: TBLBASE Position */
  185. #define SCB_VTOR_TBLBASE_Msk (0x1FFul << SCB_VTOR_TBLBASE_Pos) /*!< SCB VTOR: TBLBASE Mask */
  186. #define SCB_VTOR_TBLOFF_Pos 7 /*!< SCB VTOR: TBLOFF Position */
  187. #define SCB_VTOR_TBLOFF_Msk (0x3FFFFFul << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */
  188. /* SCB Application Interrupt and Reset Control Register Definitions */
  189. #define SCB_AIRCR_VECTKEY_Pos 16 /*!< SCB AIRCR: VECTKEY Position */
  190. #define SCB_AIRCR_VECTKEY_Msk (0xFFFFul << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */
  191. #define SCB_AIRCR_VECTKEYSTAT_Pos 16 /*!< SCB AIRCR: VECTKEYSTAT Position */
  192. #define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFul << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */
  193. #define SCB_AIRCR_ENDIANESS_Pos 15 /*!< SCB AIRCR: ENDIANESS Position */
  194. #define SCB_AIRCR_ENDIANESS_Msk (1ul << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */
  195. #define SCB_AIRCR_PRIGROUP_Pos 8 /*!< SCB AIRCR: PRIGROUP Position */
  196. #define SCB_AIRCR_PRIGROUP_Msk (7ul << SCB_AIRCR_PRIGROUP_Pos) /*!< SCB AIRCR: PRIGROUP Mask */
  197. #define SCB_AIRCR_SYSRESETREQ_Pos 2 /*!< SCB AIRCR: SYSRESETREQ Position */
  198. #define SCB_AIRCR_SYSRESETREQ_Msk (1ul << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */
  199. #define SCB_AIRCR_VECTCLRACTIVE_Pos 1 /*!< SCB AIRCR: VECTCLRACTIVE Position */
  200. #define SCB_AIRCR_VECTCLRACTIVE_Msk (1ul << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */
  201. #define SCB_AIRCR_VECTRESET_Pos 0 /*!< SCB AIRCR: VECTRESET Position */
  202. #define SCB_AIRCR_VECTRESET_Msk (1ul << SCB_AIRCR_VECTRESET_Pos) /*!< SCB AIRCR: VECTRESET Mask */
  203. /* SCB System Control Register Definitions */
  204. #define SCB_SCR_SEVONPEND_Pos 4 /*!< SCB SCR: SEVONPEND Position */
  205. #define SCB_SCR_SEVONPEND_Msk (1ul << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */
  206. #define SCB_SCR_SLEEPDEEP_Pos 2 /*!< SCB SCR: SLEEPDEEP Position */
  207. #define SCB_SCR_SLEEPDEEP_Msk (1ul << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */
  208. #define SCB_SCR_SLEEPONEXIT_Pos 1 /*!< SCB SCR: SLEEPONEXIT Position */
  209. #define SCB_SCR_SLEEPONEXIT_Msk (1ul << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */
  210. /* SCB Configuration Control Register Definitions */
  211. #define SCB_CCR_STKALIGN_Pos 9 /*!< SCB CCR: STKALIGN Position */
  212. #define SCB_CCR_STKALIGN_Msk (1ul << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */
  213. #define SCB_CCR_BFHFNMIGN_Pos 8 /*!< SCB CCR: BFHFNMIGN Position */
  214. #define SCB_CCR_BFHFNMIGN_Msk (1ul << SCB_CCR_BFHFNMIGN_Pos) /*!< SCB CCR: BFHFNMIGN Mask */
  215. #define SCB_CCR_DIV_0_TRP_Pos 4 /*!< SCB CCR: DIV_0_TRP Position */
  216. #define SCB_CCR_DIV_0_TRP_Msk (1ul << SCB_CCR_DIV_0_TRP_Pos) /*!< SCB CCR: DIV_0_TRP Mask */
  217. #define SCB_CCR_UNALIGN_TRP_Pos 3 /*!< SCB CCR: UNALIGN_TRP Position */
  218. #define SCB_CCR_UNALIGN_TRP_Msk (1ul << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */
  219. #define SCB_CCR_USERSETMPEND_Pos 1 /*!< SCB CCR: USERSETMPEND Position */
  220. #define SCB_CCR_USERSETMPEND_Msk (1ul << SCB_CCR_USERSETMPEND_Pos) /*!< SCB CCR: USERSETMPEND Mask */
  221. #define SCB_CCR_NONBASETHRDENA_Pos 0 /*!< SCB CCR: NONBASETHRDENA Position */
  222. #define SCB_CCR_NONBASETHRDENA_Msk (1ul << SCB_CCR_NONBASETHRDENA_Pos) /*!< SCB CCR: NONBASETHRDENA Mask */
  223. /* SCB System Handler Control and State Register Definitions */
  224. #define SCB_SHCSR_USGFAULTENA_Pos 18 /*!< SCB SHCSR: USGFAULTENA Position */
  225. #define SCB_SHCSR_USGFAULTENA_Msk (1ul << SCB_SHCSR_USGFAULTENA_Pos) /*!< SCB SHCSR: USGFAULTENA Mask */
  226. #define SCB_SHCSR_BUSFAULTENA_Pos 17 /*!< SCB SHCSR: BUSFAULTENA Position */
  227. #define SCB_SHCSR_BUSFAULTENA_Msk (1ul << SCB_SHCSR_BUSFAULTENA_Pos) /*!< SCB SHCSR: BUSFAULTENA Mask */
  228. #define SCB_SHCSR_MEMFAULTENA_Pos 16 /*!< SCB SHCSR: MEMFAULTENA Position */
  229. #define SCB_SHCSR_MEMFAULTENA_Msk (1ul << SCB_SHCSR_MEMFAULTENA_Pos) /*!< SCB SHCSR: MEMFAULTENA Mask */
  230. #define SCB_SHCSR_SVCALLPENDED_Pos 15 /*!< SCB SHCSR: SVCALLPENDED Position */
  231. #define SCB_SHCSR_SVCALLPENDED_Msk (1ul << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */
  232. #define SCB_SHCSR_BUSFAULTPENDED_Pos 14 /*!< SCB SHCSR: BUSFAULTPENDED Position */
  233. #define SCB_SHCSR_BUSFAULTPENDED_Msk (1ul << SCB_SHCSR_BUSFAULTPENDED_Pos) /*!< SCB SHCSR: BUSFAULTPENDED Mask */
  234. #define SCB_SHCSR_MEMFAULTPENDED_Pos 13 /*!< SCB SHCSR: MEMFAULTPENDED Position */
  235. #define SCB_SHCSR_MEMFAULTPENDED_Msk (1ul << SCB_SHCSR_MEMFAULTPENDED_Pos) /*!< SCB SHCSR: MEMFAULTPENDED Mask */
  236. #define SCB_SHCSR_USGFAULTPENDED_Pos 12 /*!< SCB SHCSR: USGFAULTPENDED Position */
  237. #define SCB_SHCSR_USGFAULTPENDED_Msk (1ul << SCB_SHCSR_USGFAULTPENDED_Pos) /*!< SCB SHCSR: USGFAULTPENDED Mask */
  238. #define SCB_SHCSR_SYSTICKACT_Pos 11 /*!< SCB SHCSR: SYSTICKACT Position */
  239. #define SCB_SHCSR_SYSTICKACT_Msk (1ul << SCB_SHCSR_SYSTICKACT_Pos) /*!< SCB SHCSR: SYSTICKACT Mask */
  240. #define SCB_SHCSR_PENDSVACT_Pos 10 /*!< SCB SHCSR: PENDSVACT Position */
  241. #define SCB_SHCSR_PENDSVACT_Msk (1ul << SCB_SHCSR_PENDSVACT_Pos) /*!< SCB SHCSR: PENDSVACT Mask */
  242. #define SCB_SHCSR_MONITORACT_Pos 8 /*!< SCB SHCSR: MONITORACT Position */
  243. #define SCB_SHCSR_MONITORACT_Msk (1ul << SCB_SHCSR_MONITORACT_Pos) /*!< SCB SHCSR: MONITORACT Mask */
  244. #define SCB_SHCSR_SVCALLACT_Pos 7 /*!< SCB SHCSR: SVCALLACT Position */
  245. #define SCB_SHCSR_SVCALLACT_Msk (1ul << SCB_SHCSR_SVCALLACT_Pos) /*!< SCB SHCSR: SVCALLACT Mask */
  246. #define SCB_SHCSR_USGFAULTACT_Pos 3 /*!< SCB SHCSR: USGFAULTACT Position */
  247. #define SCB_SHCSR_USGFAULTACT_Msk (1ul << SCB_SHCSR_USGFAULTACT_Pos) /*!< SCB SHCSR: USGFAULTACT Mask */
  248. #define SCB_SHCSR_BUSFAULTACT_Pos 1 /*!< SCB SHCSR: BUSFAULTACT Position */
  249. #define SCB_SHCSR_BUSFAULTACT_Msk (1ul << SCB_SHCSR_BUSFAULTACT_Pos) /*!< SCB SHCSR: BUSFAULTACT Mask */
  250. #define SCB_SHCSR_MEMFAULTACT_Pos 0 /*!< SCB SHCSR: MEMFAULTACT Position */
  251. #define SCB_SHCSR_MEMFAULTACT_Msk (1ul << SCB_SHCSR_MEMFAULTACT_Pos) /*!< SCB SHCSR: MEMFAULTACT Mask */
  252. /* SCB Configurable Fault Status Registers Definitions */
  253. #define SCB_CFSR_USGFAULTSR_Pos 16 /*!< SCB CFSR: Usage Fault Status Register Position */
  254. #define SCB_CFSR_USGFAULTSR_Msk (0xFFFFul << SCB_CFSR_USGFAULTSR_Pos) /*!< SCB CFSR: Usage Fault Status Register Mask */
  255. #define SCB_CFSR_BUSFAULTSR_Pos 8 /*!< SCB CFSR: Bus Fault Status Register Position */
  256. #define SCB_CFSR_BUSFAULTSR_Msk (0xFFul << SCB_CFSR_BUSFAULTSR_Pos) /*!< SCB CFSR: Bus Fault Status Register Mask */
  257. #define SCB_CFSR_MEMFAULTSR_Pos 0 /*!< SCB CFSR: Memory Manage Fault Status Register Position */
  258. #define SCB_CFSR_MEMFAULTSR_Msk (0xFFul << SCB_CFSR_MEMFAULTSR_Pos) /*!< SCB CFSR: Memory Manage Fault Status Register Mask */
  259. /* SCB Hard Fault Status Registers Definitions */
  260. #define SCB_HFSR_DEBUGEVT_Pos 31 /*!< SCB HFSR: DEBUGEVT Position */
  261. #define SCB_HFSR_DEBUGEVT_Msk (1ul << SCB_HFSR_DEBUGEVT_Pos) /*!< SCB HFSR: DEBUGEVT Mask */
  262. #define SCB_HFSR_FORCED_Pos 30 /*!< SCB HFSR: FORCED Position */
  263. #define SCB_HFSR_FORCED_Msk (1ul << SCB_HFSR_FORCED_Pos) /*!< SCB HFSR: FORCED Mask */
  264. #define SCB_HFSR_VECTTBL_Pos 1 /*!< SCB HFSR: VECTTBL Position */
  265. #define SCB_HFSR_VECTTBL_Msk (1ul << SCB_HFSR_VECTTBL_Pos) /*!< SCB HFSR: VECTTBL Mask */
  266. /* SCB Debug Fault Status Register Definitions */
  267. #define SCB_DFSR_EXTERNAL_Pos 4 /*!< SCB DFSR: EXTERNAL Position */
  268. #define SCB_DFSR_EXTERNAL_Msk (1ul << SCB_DFSR_EXTERNAL_Pos) /*!< SCB DFSR: EXTERNAL Mask */
  269. #define SCB_DFSR_VCATCH_Pos 3 /*!< SCB DFSR: VCATCH Position */
  270. #define SCB_DFSR_VCATCH_Msk (1ul << SCB_DFSR_VCATCH_Pos) /*!< SCB DFSR: VCATCH Mask */
  271. #define SCB_DFSR_DWTTRAP_Pos 2 /*!< SCB DFSR: DWTTRAP Position */
  272. #define SCB_DFSR_DWTTRAP_Msk (1ul << SCB_DFSR_DWTTRAP_Pos) /*!< SCB DFSR: DWTTRAP Mask */
  273. #define SCB_DFSR_BKPT_Pos 1 /*!< SCB DFSR: BKPT Position */
  274. #define SCB_DFSR_BKPT_Msk (1ul << SCB_DFSR_BKPT_Pos) /*!< SCB DFSR: BKPT Mask */
  275. #define SCB_DFSR_HALTED_Pos 0 /*!< SCB DFSR: HALTED Position */
  276. #define SCB_DFSR_HALTED_Msk (1ul << SCB_DFSR_HALTED_Pos) /*!< SCB DFSR: HALTED Mask */
  277. /*@}*/ /* end of group CMSIS_CM3_SCB */
  278. /** @addtogroup CMSIS_CM3_SysTick CMSIS CM3 SysTick
  279. memory mapped structure for SysTick
  280. @{
  281. */
  282. typedef struct
  283. {
  284. __IO uint32_t CTRL; /*!< Offset: 0x00 SysTick Control and Status Register */
  285. __IO uint32_t LOAD; /*!< Offset: 0x04 SysTick Reload Value Register */
  286. __IO uint32_t VAL; /*!< Offset: 0x08 SysTick Current Value Register */
  287. __I uint32_t CALIB; /*!< Offset: 0x0C SysTick Calibration Register */
  288. } SysTick_Type;
  289. /* SysTick Control / Status Register Definitions */
  290. #define SysTick_CTRL_COUNTFLAG_Pos 16 /*!< SysTick CTRL: COUNTFLAG Position */
  291. #define SysTick_CTRL_COUNTFLAG_Msk (1ul << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */
  292. #define SysTick_CTRL_CLKSOURCE_Pos 2 /*!< SysTick CTRL: CLKSOURCE Position */
  293. #define SysTick_CTRL_CLKSOURCE_Msk (1ul << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */
  294. #define SysTick_CTRL_TICKINT_Pos 1 /*!< SysTick CTRL: TICKINT Position */
  295. #define SysTick_CTRL_TICKINT_Msk (1ul << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */
  296. #define SysTick_CTRL_ENABLE_Pos 0 /*!< SysTick CTRL: ENABLE Position */
  297. #define SysTick_CTRL_ENABLE_Msk (1ul << SysTick_CTRL_ENABLE_Pos) /*!< SysTick CTRL: ENABLE Mask */
  298. /* SysTick Reload Register Definitions */
  299. #define SysTick_LOAD_RELOAD_Pos 0 /*!< SysTick LOAD: RELOAD Position */
  300. #define SysTick_LOAD_RELOAD_Msk (0xFFFFFFul << SysTick_LOAD_RELOAD_Pos) /*!< SysTick LOAD: RELOAD Mask */
  301. /* SysTick Current Register Definitions */
  302. #define SysTick_VAL_CURRENT_Pos 0 /*!< SysTick VAL: CURRENT Position */
  303. #define SysTick_VAL_CURRENT_Msk (0xFFFFFFul << SysTick_VAL_CURRENT_Pos) /*!< SysTick VAL: CURRENT Mask */
  304. /* SysTick Calibration Register Definitions */
  305. #define SysTick_CALIB_NOREF_Pos 31 /*!< SysTick CALIB: NOREF Position */
  306. #define SysTick_CALIB_NOREF_Msk (1ul << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */
  307. #define SysTick_CALIB_SKEW_Pos 30 /*!< SysTick CALIB: SKEW Position */
  308. #define SysTick_CALIB_SKEW_Msk (1ul << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */
  309. #define SysTick_CALIB_TENMS_Pos 0 /*!< SysTick CALIB: TENMS Position */
  310. #define SysTick_CALIB_TENMS_Msk (0xFFFFFFul << SysTick_VAL_CURRENT_Pos) /*!< SysTick CALIB: TENMS Mask */
  311. /*@}*/ /* end of group CMSIS_CM3_SysTick */
  312. /** @addtogroup CMSIS_CM3_ITM CMSIS CM3 ITM
  313. memory mapped structure for Instrumentation Trace Macrocell (ITM)
  314. @{
  315. */
  316. typedef struct
  317. {
  318. __O union
  319. {
  320. __O uint8_t u8; /*!< Offset: ITM Stimulus Port 8-bit */
  321. __O uint16_t u16; /*!< Offset: ITM Stimulus Port 16-bit */
  322. __O uint32_t u32; /*!< Offset: ITM Stimulus Port 32-bit */
  323. } PORT [32]; /*!< Offset: 0x00 ITM Stimulus Port Registers */
  324. uint32_t RESERVED0[864];
  325. __IO uint32_t TER; /*!< Offset: ITM Trace Enable Register */
  326. uint32_t RESERVED1[15];
  327. __IO uint32_t TPR; /*!< Offset: ITM Trace Privilege Register */
  328. uint32_t RESERVED2[15];
  329. __IO uint32_t TCR; /*!< Offset: ITM Trace Control Register */
  330. uint32_t RESERVED3[29];
  331. __IO uint32_t IWR; /*!< Offset: ITM Integration Write Register */
  332. __IO uint32_t IRR; /*!< Offset: ITM Integration Read Register */
  333. __IO uint32_t IMCR; /*!< Offset: ITM Integration Mode Control Register */
  334. uint32_t RESERVED4[43];
  335. __IO uint32_t LAR; /*!< Offset: ITM Lock Access Register */
  336. __IO uint32_t LSR; /*!< Offset: ITM Lock Status Register */
  337. uint32_t RESERVED5[6];
  338. __I uint32_t PID4; /*!< Offset: ITM Peripheral Identification Register #4 */
  339. __I uint32_t PID5; /*!< Offset: ITM Peripheral Identification Register #5 */
  340. __I uint32_t PID6; /*!< Offset: ITM Peripheral Identification Register #6 */
  341. __I uint32_t PID7; /*!< Offset: ITM Peripheral Identification Register #7 */
  342. __I uint32_t PID0; /*!< Offset: ITM Peripheral Identification Register #0 */
  343. __I uint32_t PID1; /*!< Offset: ITM Peripheral Identification Register #1 */
  344. __I uint32_t PID2; /*!< Offset: ITM Peripheral Identification Register #2 */
  345. __I uint32_t PID3; /*!< Offset: ITM Peripheral Identification Register #3 */
  346. __I uint32_t CID0; /*!< Offset: ITM Component Identification Register #0 */
  347. __I uint32_t CID1; /*!< Offset: ITM Component Identification Register #1 */
  348. __I uint32_t CID2; /*!< Offset: ITM Component Identification Register #2 */
  349. __I uint32_t CID3; /*!< Offset: ITM Component Identification Register #3 */
  350. } ITM_Type;
  351. /* ITM Trace Privilege Register Definitions */
  352. #define ITM_TPR_PRIVMASK_Pos 0 /*!< ITM TPR: PRIVMASK Position */
  353. #define ITM_TPR_PRIVMASK_Msk (0xFul << ITM_TPR_PRIVMASK_Pos) /*!< ITM TPR: PRIVMASK Mask */
  354. /* ITM Trace Control Register Definitions */
  355. #define ITM_TCR_BUSY_Pos 23 /*!< ITM TCR: BUSY Position */
  356. #define ITM_TCR_BUSY_Msk (1ul << ITM_TCR_BUSY_Pos) /*!< ITM TCR: BUSY Mask */
  357. #define ITM_TCR_ATBID_Pos 16 /*!< ITM TCR: ATBID Position */
  358. #define ITM_TCR_ATBID_Msk (0x7Ful << ITM_TCR_ATBID_Pos) /*!< ITM TCR: ATBID Mask */
  359. #define ITM_TCR_TSPrescale_Pos 8 /*!< ITM TCR: TSPrescale Position */
  360. #define ITM_TCR_TSPrescale_Msk (3ul << ITM_TCR_TSPrescale_Pos) /*!< ITM TCR: TSPrescale Mask */
  361. #define ITM_TCR_SWOENA_Pos 4 /*!< ITM TCR: SWOENA Position */
  362. #define ITM_TCR_SWOENA_Msk (1ul << ITM_TCR_SWOENA_Pos) /*!< ITM TCR: SWOENA Mask */
  363. #define ITM_TCR_DWTENA_Pos 3 /*!< ITM TCR: DWTENA Position */
  364. #define ITM_TCR_DWTENA_Msk (1ul << ITM_TCR_DWTENA_Pos) /*!< ITM TCR: DWTENA Mask */
  365. #define ITM_TCR_SYNCENA_Pos 2 /*!< ITM TCR: SYNCENA Position */
  366. #define ITM_TCR_SYNCENA_Msk (1ul << ITM_TCR_SYNCENA_Pos) /*!< ITM TCR: SYNCENA Mask */
  367. #define ITM_TCR_TSENA_Pos 1 /*!< ITM TCR: TSENA Position */
  368. #define ITM_TCR_TSENA_Msk (1ul << ITM_TCR_TSENA_Pos) /*!< ITM TCR: TSENA Mask */
  369. #define ITM_TCR_ITMENA_Pos 0 /*!< ITM TCR: ITM Enable bit Position */
  370. #define ITM_TCR_ITMENA_Msk (1ul << ITM_TCR_ITMENA_Pos) /*!< ITM TCR: ITM Enable bit Mask */
  371. /* ITM Integration Write Register Definitions */
  372. #define ITM_IWR_ATVALIDM_Pos 0 /*!< ITM IWR: ATVALIDM Position */
  373. #define ITM_IWR_ATVALIDM_Msk (1ul << ITM_IWR_ATVALIDM_Pos) /*!< ITM IWR: ATVALIDM Mask */
  374. /* ITM Integration Read Register Definitions */
  375. #define ITM_IRR_ATREADYM_Pos 0 /*!< ITM IRR: ATREADYM Position */
  376. #define ITM_IRR_ATREADYM_Msk (1ul << ITM_IRR_ATREADYM_Pos) /*!< ITM IRR: ATREADYM Mask */
  377. /* ITM Integration Mode Control Register Definitions */
  378. #define ITM_IMCR_INTEGRATION_Pos 0 /*!< ITM IMCR: INTEGRATION Position */
  379. #define ITM_IMCR_INTEGRATION_Msk (1ul << ITM_IMCR_INTEGRATION_Pos) /*!< ITM IMCR: INTEGRATION Mask */
  380. /* ITM Lock Status Register Definitions */
  381. #define ITM_LSR_ByteAcc_Pos 2 /*!< ITM LSR: ByteAcc Position */
  382. #define ITM_LSR_ByteAcc_Msk (1ul << ITM_LSR_ByteAcc_Pos) /*!< ITM LSR: ByteAcc Mask */
  383. #define ITM_LSR_Access_Pos 1 /*!< ITM LSR: Access Position */
  384. #define ITM_LSR_Access_Msk (1ul << ITM_LSR_Access_Pos) /*!< ITM LSR: Access Mask */
  385. #define ITM_LSR_Present_Pos 0 /*!< ITM LSR: Present Position */
  386. #define ITM_LSR_Present_Msk (1ul << ITM_LSR_Present_Pos) /*!< ITM LSR: Present Mask */
  387. /*@}*/ /* end of group CMSIS_CM3_ITM */
  388. /** @addtogroup CMSIS_CM3_InterruptType CMSIS CM3 Interrupt Type
  389. memory mapped structure for Interrupt Type
  390. @{
  391. */
  392. typedef struct
  393. {
  394. uint32_t RESERVED0;
  395. __I uint32_t ICTR; /*!< Offset: 0x04 Interrupt Control Type Register */
  396. #if ((defined __CM3_REV) && (__CM3_REV >= 0x200))
  397. __IO uint32_t ACTLR; /*!< Offset: 0x08 Auxiliary Control Register */
  398. #else
  399. uint32_t RESERVED1;
  400. #endif
  401. } InterruptType_Type;
  402. /* Interrupt Controller Type Register Definitions */
  403. #define InterruptType_ICTR_INTLINESNUM_Pos 0 /*!< InterruptType ICTR: INTLINESNUM Position */
  404. #define InterruptType_ICTR_INTLINESNUM_Msk (0x1Ful << InterruptType_ICTR_INTLINESNUM_Pos) /*!< InterruptType ICTR: INTLINESNUM Mask */
  405. /* Auxiliary Control Register Definitions */
  406. #define InterruptType_ACTLR_DISFOLD_Pos 2 /*!< InterruptType ACTLR: DISFOLD Position */
  407. #define InterruptType_ACTLR_DISFOLD_Msk (1ul << InterruptType_ACTLR_DISFOLD_Pos) /*!< InterruptType ACTLR: DISFOLD Mask */
  408. #define InterruptType_ACTLR_DISDEFWBUF_Pos 1 /*!< InterruptType ACTLR: DISDEFWBUF Position */
  409. #define InterruptType_ACTLR_DISDEFWBUF_Msk (1ul << InterruptType_ACTLR_DISDEFWBUF_Pos) /*!< InterruptType ACTLR: DISDEFWBUF Mask */
  410. #define InterruptType_ACTLR_DISMCYCINT_Pos 0 /*!< InterruptType ACTLR: DISMCYCINT Position */
  411. #define InterruptType_ACTLR_DISMCYCINT_Msk (1ul << InterruptType_ACTLR_DISMCYCINT_Pos) /*!< InterruptType ACTLR: DISMCYCINT Mask */
  412. /*@}*/ /* end of group CMSIS_CM3_InterruptType */
  413. #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1)
  414. /** @addtogroup CMSIS_CM3_MPU CMSIS CM3 MPU
  415. memory mapped structure for Memory Protection Unit (MPU)
  416. @{
  417. */
  418. typedef struct
  419. {
  420. __I uint32_t TYPE; /*!< Offset: 0x00 MPU Type Register */
  421. __IO uint32_t CTRL; /*!< Offset: 0x04 MPU Control Register */
  422. __IO uint32_t RNR; /*!< Offset: 0x08 MPU Region RNRber Register */
  423. __IO uint32_t RBAR; /*!< Offset: 0x0C MPU Region Base Address Register */
  424. __IO uint32_t RASR; /*!< Offset: 0x10 MPU Region Attribute and Size Register */
  425. __IO uint32_t RBAR_A1; /*!< Offset: 0x14 MPU Alias 1 Region Base Address Register */
  426. __IO uint32_t RASR_A1; /*!< Offset: 0x18 MPU Alias 1 Region Attribute and Size Register */
  427. __IO uint32_t RBAR_A2; /*!< Offset: 0x1C MPU Alias 2 Region Base Address Register */
  428. __IO uint32_t RASR_A2; /*!< Offset: 0x20 MPU Alias 2 Region Attribute and Size Register */
  429. __IO uint32_t RBAR_A3; /*!< Offset: 0x24 MPU Alias 3 Region Base Address Register */
  430. __IO uint32_t RASR_A3; /*!< Offset: 0x28 MPU Alias 3 Region Attribute and Size Register */
  431. } MPU_Type;
  432. /* MPU Type Register */
  433. #define MPU_TYPE_IREGION_Pos 16 /*!< MPU TYPE: IREGION Position */
  434. #define MPU_TYPE_IREGION_Msk (0xFFul << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */
  435. #define MPU_TYPE_DREGION_Pos 8 /*!< MPU TYPE: DREGION Position */
  436. #define MPU_TYPE_DREGION_Msk (0xFFul << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */
  437. #define MPU_TYPE_SEPARATE_Pos 0 /*!< MPU TYPE: SEPARATE Position */
  438. #define MPU_TYPE_SEPARATE_Msk (1ul << MPU_TYPE_SEPARATE_Pos) /*!< MPU TYPE: SEPARATE Mask */
  439. /* MPU Control Register */
  440. #define MPU_CTRL_PRIVDEFENA_Pos 2 /*!< MPU CTRL: PRIVDEFENA Position */
  441. #define MPU_CTRL_PRIVDEFENA_Msk (1ul << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */
  442. #define MPU_CTRL_HFNMIENA_Pos 1 /*!< MPU CTRL: HFNMIENA Position */
  443. #define MPU_CTRL_HFNMIENA_Msk (1ul << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */
  444. #define MPU_CTRL_ENABLE_Pos 0 /*!< MPU CTRL: ENABLE Position */
  445. #define MPU_CTRL_ENABLE_Msk (1ul << MPU_CTRL_ENABLE_Pos) /*!< MPU CTRL: ENABLE Mask */
  446. /* MPU Region Number Register */
  447. #define MPU_RNR_REGION_Pos 0 /*!< MPU RNR: REGION Position */
  448. #define MPU_RNR_REGION_Msk (0xFFul << MPU_RNR_REGION_Pos) /*!< MPU RNR: REGION Mask */
  449. /* MPU Region Base Address Register */
  450. #define MPU_RBAR_ADDR_Pos 5 /*!< MPU RBAR: ADDR Position */
  451. #define MPU_RBAR_ADDR_Msk (0x7FFFFFFul << MPU_RBAR_ADDR_Pos) /*!< MPU RBAR: ADDR Mask */
  452. #define MPU_RBAR_VALID_Pos 4 /*!< MPU RBAR: VALID Position */
  453. #define MPU_RBAR_VALID_Msk (1ul << MPU_RBAR_VALID_Pos) /*!< MPU RBAR: VALID Mask */
  454. #define MPU_RBAR_REGION_Pos 0 /*!< MPU RBAR: REGION Position */
  455. #define MPU_RBAR_REGION_Msk (0xFul << MPU_RBAR_REGION_Pos) /*!< MPU RBAR: REGION Mask */
  456. /* MPU Region Attribute and Size Register */
  457. #define MPU_RASR_XN_Pos 28 /*!< MPU RASR: XN Position */
  458. #define MPU_RASR_XN_Msk (1ul << MPU_RASR_XN_Pos) /*!< MPU RASR: XN Mask */
  459. #define MPU_RASR_AP_Pos 24 /*!< MPU RASR: AP Position */
  460. #define MPU_RASR_AP_Msk (7ul << MPU_RASR_AP_Pos) /*!< MPU RASR: AP Mask */
  461. #define MPU_RASR_TEX_Pos 19 /*!< MPU RASR: TEX Position */
  462. #define MPU_RASR_TEX_Msk (7ul << MPU_RASR_TEX_Pos) /*!< MPU RASR: TEX Mask */
  463. #define MPU_RASR_S_Pos 18 /*!< MPU RASR: Shareable bit Position */
  464. #define MPU_RASR_S_Msk (1ul << MPU_RASR_S_Pos) /*!< MPU RASR: Shareable bit Mask */
  465. #define MPU_RASR_C_Pos 17 /*!< MPU RASR: Cacheable bit Position */
  466. #define MPU_RASR_C_Msk (1ul << MPU_RASR_C_Pos) /*!< MPU RASR: Cacheable bit Mask */
  467. #define MPU_RASR_B_Pos 16 /*!< MPU RASR: Bufferable bit Position */
  468. #define MPU_RASR_B_Msk (1ul << MPU_RASR_B_Pos) /*!< MPU RASR: Bufferable bit Mask */
  469. #define MPU_RASR_SRD_Pos 8 /*!< MPU RASR: Sub-Region Disable Position */
  470. #define MPU_RASR_SRD_Msk (0xFFul << MPU_RASR_SRD_Pos) /*!< MPU RASR: Sub-Region Disable Mask */
  471. #define MPU_RASR_SIZE_Pos 1 /*!< MPU RASR: Region Size Field Position */
  472. #define MPU_RASR_SIZE_Msk (0x1Ful << MPU_RASR_SIZE_Pos) /*!< MPU RASR: Region Size Field Mask */
  473. #define MPU_RASR_ENA_Pos 0 /*!< MPU RASR: Region enable bit Position */
  474. #define MPU_RASR_ENA_Msk (0x1Ful << MPU_RASR_ENA_Pos) /*!< MPU RASR: Region enable bit Disable Mask */
  475. /*@}*/ /* end of group CMSIS_CM3_MPU */
  476. #endif
  477. /** @addtogroup CMSIS_CM3_CoreDebug CMSIS CM3 Core Debug
  478. memory mapped structure for Core Debug Register
  479. @{
  480. */
  481. typedef struct
  482. {
  483. __IO uint32_t DHCSR; /*!< Offset: 0x00 Debug Halting Control and Status Register */
  484. __O uint32_t DCRSR; /*!< Offset: 0x04 Debug Core Register Selector Register */
  485. __IO uint32_t DCRDR; /*!< Offset: 0x08 Debug Core Register Data Register */
  486. __IO uint32_t DEMCR; /*!< Offset: 0x0C Debug Exception and Monitor Control Register */
  487. } CoreDebug_Type;
  488. /* Debug Halting Control and Status Register */
  489. #define CoreDebug_DHCSR_DBGKEY_Pos 16 /*!< CoreDebug DHCSR: DBGKEY Position */
  490. #define CoreDebug_DHCSR_DBGKEY_Msk (0xFFFFul << CoreDebug_DHCSR_DBGKEY_Pos) /*!< CoreDebug DHCSR: DBGKEY Mask */
  491. #define CoreDebug_DHCSR_S_RESET_ST_Pos 25 /*!< CoreDebug DHCSR: S_RESET_ST Position */
  492. #define CoreDebug_DHCSR_S_RESET_ST_Msk (1ul << CoreDebug_DHCSR_S_RESET_ST_Pos) /*!< CoreDebug DHCSR: S_RESET_ST Mask */
  493. #define CoreDebug_DHCSR_S_RETIRE_ST_Pos 24 /*!< CoreDebug DHCSR: S_RETIRE_ST Position */
  494. #define CoreDebug_DHCSR_S_RETIRE_ST_Msk (1ul << CoreDebug_DHCSR_S_RETIRE_ST_Pos) /*!< CoreDebug DHCSR: S_RETIRE_ST Mask */
  495. #define CoreDebug_DHCSR_S_LOCKUP_Pos 19 /*!< CoreDebug DHCSR: S_LOCKUP Position */
  496. #define CoreDebug_DHCSR_S_LOCKUP_Msk (1ul << CoreDebug_DHCSR_S_LOCKUP_Pos) /*!< CoreDebug DHCSR: S_LOCKUP Mask */
  497. #define CoreDebug_DHCSR_S_SLEEP_Pos 18 /*!< CoreDebug DHCSR: S_SLEEP Position */
  498. #define CoreDebug_DHCSR_S_SLEEP_Msk (1ul << CoreDebug_DHCSR_S_SLEEP_Pos) /*!< CoreDebug DHCSR: S_SLEEP Mask */
  499. #define CoreDebug_DHCSR_S_HALT_Pos 17 /*!< CoreDebug DHCSR: S_HALT Position */
  500. #define CoreDebug_DHCSR_S_HALT_Msk (1ul << CoreDebug_DHCSR_S_HALT_Pos) /*!< CoreDebug DHCSR: S_HALT Mask */
  501. #define CoreDebug_DHCSR_S_REGRDY_Pos 16 /*!< CoreDebug DHCSR: S_REGRDY Position */
  502. #define CoreDebug_DHCSR_S_REGRDY_Msk (1ul << CoreDebug_DHCSR_S_REGRDY_Pos) /*!< CoreDebug DHCSR: S_REGRDY Mask */
  503. #define CoreDebug_DHCSR_C_SNAPSTALL_Pos 5 /*!< CoreDebug DHCSR: C_SNAPSTALL Position */
  504. #define CoreDebug_DHCSR_C_SNAPSTALL_Msk (1ul << CoreDebug_DHCSR_C_SNAPSTALL_Pos) /*!< CoreDebug DHCSR: C_SNAPSTALL Mask */
  505. #define CoreDebug_DHCSR_C_MASKINTS_Pos 3 /*!< CoreDebug DHCSR: C_MASKINTS Position */
  506. #define CoreDebug_DHCSR_C_MASKINTS_Msk (1ul << CoreDebug_DHCSR_C_MASKINTS_Pos) /*!< CoreDebug DHCSR: C_MASKINTS Mask */
  507. #define CoreDebug_DHCSR_C_STEP_Pos 2 /*!< CoreDebug DHCSR: C_STEP Position */
  508. #define CoreDebug_DHCSR_C_STEP_Msk (1ul << CoreDebug_DHCSR_C_STEP_Pos) /*!< CoreDebug DHCSR: C_STEP Mask */
  509. #define CoreDebug_DHCSR_C_HALT_Pos 1 /*!< CoreDebug DHCSR: C_HALT Position */
  510. #define CoreDebug_DHCSR_C_HALT_Msk (1ul << CoreDebug_DHCSR_C_HALT_Pos) /*!< CoreDebug DHCSR: C_HALT Mask */
  511. #define CoreDebug_DHCSR_C_DEBUGEN_Pos 0 /*!< CoreDebug DHCSR: C_DEBUGEN Position */
  512. #define CoreDebug_DHCSR_C_DEBUGEN_Msk (1ul << CoreDebug_DHCSR_C_DEBUGEN_Pos) /*!< CoreDebug DHCSR: C_DEBUGEN Mask */
  513. /* Debug Core Register Selector Register */
  514. #define CoreDebug_DCRSR_REGWnR_Pos 16 /*!< CoreDebug DCRSR: REGWnR Position */
  515. #define CoreDebug_DCRSR_REGWnR_Msk (1ul << CoreDebug_DCRSR_REGWnR_Pos) /*!< CoreDebug DCRSR: REGWnR Mask */
  516. #define CoreDebug_DCRSR_REGSEL_Pos 0 /*!< CoreDebug DCRSR: REGSEL Position */
  517. #define CoreDebug_DCRSR_REGSEL_Msk (0x1Ful << CoreDebug_DCRSR_REGSEL_Pos) /*!< CoreDebug DCRSR: REGSEL Mask */
  518. /* Debug Exception and Monitor Control Register */
  519. #define CoreDebug_DEMCR_TRCENA_Pos 24 /*!< CoreDebug DEMCR: TRCENA Position */
  520. #define CoreDebug_DEMCR_TRCENA_Msk (1ul << CoreDebug_DEMCR_TRCENA_Pos) /*!< CoreDebug DEMCR: TRCENA Mask */
  521. #define CoreDebug_DEMCR_MON_REQ_Pos 19 /*!< CoreDebug DEMCR: MON_REQ Position */
  522. #define CoreDebug_DEMCR_MON_REQ_Msk (1ul << CoreDebug_DEMCR_MON_REQ_Pos) /*!< CoreDebug DEMCR: MON_REQ Mask */
  523. #define CoreDebug_DEMCR_MON_STEP_Pos 18 /*!< CoreDebug DEMCR: MON_STEP Position */
  524. #define CoreDebug_DEMCR_MON_STEP_Msk (1ul << CoreDebug_DEMCR_MON_STEP_Pos) /*!< CoreDebug DEMCR: MON_STEP Mask */
  525. #define CoreDebug_DEMCR_MON_PEND_Pos 17 /*!< CoreDebug DEMCR: MON_PEND Position */
  526. #define CoreDebug_DEMCR_MON_PEND_Msk (1ul << CoreDebug_DEMCR_MON_PEND_Pos) /*!< CoreDebug DEMCR: MON_PEND Mask */
  527. #define CoreDebug_DEMCR_MON_EN_Pos 16 /*!< CoreDebug DEMCR: MON_EN Position */
  528. #define CoreDebug_DEMCR_MON_EN_Msk (1ul << CoreDebug_DEMCR_MON_EN_Pos) /*!< CoreDebug DEMCR: MON_EN Mask */
  529. #define CoreDebug_DEMCR_VC_HARDERR_Pos 10 /*!< CoreDebug DEMCR: VC_HARDERR Position */
  530. #define CoreDebug_DEMCR_VC_HARDERR_Msk (1ul << CoreDebug_DEMCR_VC_HARDERR_Pos) /*!< CoreDebug DEMCR: VC_HARDERR Mask */
  531. #define CoreDebug_DEMCR_VC_INTERR_Pos 9 /*!< CoreDebug DEMCR: VC_INTERR Position */
  532. #define CoreDebug_DEMCR_VC_INTERR_Msk (1ul << CoreDebug_DEMCR_VC_INTERR_Pos) /*!< CoreDebug DEMCR: VC_INTERR Mask */
  533. #define CoreDebug_DEMCR_VC_BUSERR_Pos 8 /*!< CoreDebug DEMCR: VC_BUSERR Position */
  534. #define CoreDebug_DEMCR_VC_BUSERR_Msk (1ul << CoreDebug_DEMCR_VC_BUSERR_Pos) /*!< CoreDebug DEMCR: VC_BUSERR Mask */
  535. #define CoreDebug_DEMCR_VC_STATERR_Pos 7 /*!< CoreDebug DEMCR: VC_STATERR Position */
  536. #define CoreDebug_DEMCR_VC_STATERR_Msk (1ul << CoreDebug_DEMCR_VC_STATERR_Pos) /*!< CoreDebug DEMCR: VC_STATERR Mask */
  537. #define CoreDebug_DEMCR_VC_CHKERR_Pos 6 /*!< CoreDebug DEMCR: VC_CHKERR Position */
  538. #define CoreDebug_DEMCR_VC_CHKERR_Msk (1ul << CoreDebug_DEMCR_VC_CHKERR_Pos) /*!< CoreDebug DEMCR: VC_CHKERR Mask */
  539. #define CoreDebug_DEMCR_VC_NOCPERR_Pos 5 /*!< CoreDebug DEMCR: VC_NOCPERR Position */
  540. #define CoreDebug_DEMCR_VC_NOCPERR_Msk (1ul << CoreDebug_DEMCR_VC_NOCPERR_Pos) /*!< CoreDebug DEMCR: VC_NOCPERR Mask */
  541. #define CoreDebug_DEMCR_VC_MMERR_Pos 4 /*!< CoreDebug DEMCR: VC_MMERR Position */
  542. #define CoreDebug_DEMCR_VC_MMERR_Msk (1ul << CoreDebug_DEMCR_VC_MMERR_Pos) /*!< CoreDebug DEMCR: VC_MMERR Mask */
  543. #define CoreDebug_DEMCR_VC_CORERESET_Pos 0 /*!< CoreDebug DEMCR: VC_CORERESET Position */
  544. #define CoreDebug_DEMCR_VC_CORERESET_Msk (1ul << CoreDebug_DEMCR_VC_CORERESET_Pos) /*!< CoreDebug DEMCR: VC_CORERESET Mask */
  545. /*@}*/ /* end of group CMSIS_CM3_CoreDebug */
  546. /* Memory mapping of Cortex-M3 Hardware */
  547. #define SCS_BASE (0xE000E000) /*!< System Control Space Base Address */
  548. #define ITM_BASE (0xE0000000) /*!< ITM Base Address */
  549. #define CoreDebug_BASE (0xE000EDF0) /*!< Core Debug Base Address */
  550. #define SysTick_BASE (SCS_BASE + 0x0010) /*!< SysTick Base Address */
  551. #define NVIC_BASE (SCS_BASE + 0x0100) /*!< NVIC Base Address */
  552. #define SCB_BASE (SCS_BASE + 0x0D00) /*!< System Control Block Base Address */
  553. #define InterruptType ((InterruptType_Type *) SCS_BASE) /*!< Interrupt Type Register */
  554. #define SCB ((SCB_Type *) SCB_BASE) /*!< SCB configuration struct */
  555. #define SysTick ((SysTick_Type *) SysTick_BASE) /*!< SysTick configuration struct */
  556. #define NVIC ((NVIC_Type *) NVIC_BASE) /*!< NVIC configuration struct */
  557. #define ITM ((ITM_Type *) ITM_BASE) /*!< ITM configuration struct */
  558. #define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE) /*!< Core Debug configuration struct */
  559. #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1)
  560. #define MPU_BASE (SCS_BASE + 0x0D90) /*!< Memory Protection Unit */
  561. #define MPU ((MPU_Type*) MPU_BASE) /*!< Memory Protection Unit */
  562. #endif
  563. /*@}*/ /* end of group CMSIS_CM3_core_register */
  564. /*******************************************************************************
  565. * Hardware Abstraction Layer
  566. ******************************************************************************/
  567. #if defined ( __CC_ARM )
  568. #define __ASM __asm /*!< asm keyword for ARM Compiler */
  569. #define __INLINE __inline /*!< inline keyword for ARM Compiler */
  570. #elif defined ( __ICCARM__ )
  571. #define __ASM __asm /*!< asm keyword for IAR Compiler */
  572. #define __INLINE inline /*!< inline keyword for IAR Compiler. Only avaiable in High optimization mode! */
  573. #elif defined ( __GNUC__ )
  574. #define __ASM __asm /*!< asm keyword for GNU Compiler */
  575. #define __INLINE inline /*!< inline keyword for GNU Compiler */
  576. #elif defined ( __TASKING__ )
  577. #define __ASM __asm /*!< asm keyword for TASKING Compiler */
  578. #define __INLINE inline /*!< inline keyword for TASKING Compiler */
  579. #endif
  580. /* ################### Compiler specific Intrinsics ########################### */
  581. #if defined ( __CC_ARM ) /*------------------RealView Compiler -----------------*/
  582. /* ARM armcc specific functions */
  583. #define __enable_fault_irq __enable_fiq
  584. #define __disable_fault_irq __disable_fiq
  585. #define __NOP __nop
  586. #define __WFI __wfi
  587. #define __WFE __wfe
  588. #define __SEV __sev
  589. #define __ISB() __isb(0)
  590. #define __DSB() __dsb(0)
  591. #define __DMB() __dmb(0)
  592. #define __REV __rev
  593. #define __RBIT __rbit
  594. #define __LDREXB(ptr) ((unsigned char ) __ldrex(ptr))
  595. #define __LDREXH(ptr) ((unsigned short) __ldrex(ptr))
  596. #define __LDREXW(ptr) ((unsigned int ) __ldrex(ptr))
  597. #define __STREXB(value, ptr) __strex(value, ptr)
  598. #define __STREXH(value, ptr) __strex(value, ptr)
  599. #define __STREXW(value, ptr) __strex(value, ptr)
  600. /* intrinsic unsigned long long __ldrexd(volatile void *ptr) */
  601. /* intrinsic int __strexd(unsigned long long val, volatile void *ptr) */
  602. /* intrinsic void __enable_irq(); */
  603. /* intrinsic void __disable_irq(); */
  604. /**
  605. * @brief Return the Process Stack Pointer
  606. *
  607. * @return ProcessStackPointer
  608. *
  609. * Return the actual process stack pointer
  610. */
  611. extern uint32_t __get_PSP(void);
  612. /**
  613. * @brief Set the Process Stack Pointer
  614. *
  615. * @param topOfProcStack Process Stack Pointer
  616. *
  617. * Assign the value ProcessStackPointer to the MSP
  618. * (process stack pointer) Cortex processor register
  619. */
  620. extern void __set_PSP(uint32_t topOfProcStack);
  621. /**
  622. * @brief Return the Main Stack Pointer
  623. *
  624. * @return Main Stack Pointer
  625. *
  626. * Return the current value of the MSP (main stack pointer)
  627. * Cortex processor register
  628. */
  629. extern uint32_t __get_MSP(void);
  630. /**
  631. * @brief Set the Main Stack Pointer
  632. *
  633. * @param topOfMainStack Main Stack Pointer
  634. *
  635. * Assign the value mainStackPointer to the MSP
  636. * (main stack pointer) Cortex processor register
  637. */
  638. extern void __set_MSP(uint32_t topOfMainStack);
  639. /**
  640. * @brief Reverse byte order in unsigned short value
  641. *
  642. * @param value value to reverse
  643. * @return reversed value
  644. *
  645. * Reverse byte order in unsigned short value
  646. */
  647. extern uint32_t __REV16(uint16_t value);
  648. /**
  649. * @brief Reverse byte order in signed short value with sign extension to integer
  650. *
  651. * @param value value to reverse
  652. * @return reversed value
  653. *
  654. * Reverse byte order in signed short value with sign extension to integer
  655. */
  656. extern int32_t __REVSH(int16_t value);
  657. #if (__ARMCC_VERSION < 400000)
  658. /**
  659. * @brief Remove the exclusive lock created by ldrex
  660. *
  661. * Removes the exclusive lock which is created by ldrex.
  662. */
  663. extern void __CLREX(void);
  664. /**
  665. * @brief Return the Base Priority value
  666. *
  667. * @return BasePriority
  668. *
  669. * Return the content of the base priority register
  670. */
  671. extern uint32_t __get_BASEPRI(void);
  672. /**
  673. * @brief Set the Base Priority value
  674. *
  675. * @param basePri BasePriority
  676. *
  677. * Set the base priority register
  678. */
  679. extern void __set_BASEPRI(uint32_t basePri);
  680. /**
  681. * @brief Return the Priority Mask value
  682. *
  683. * @return PriMask
  684. *
  685. * Return state of the priority mask bit from the priority mask register
  686. */
  687. extern uint32_t __get_PRIMASK(void);
  688. /**
  689. * @brief Set the Priority Mask value
  690. *
  691. * @param priMask PriMask
  692. *
  693. * Set the priority mask bit in the priority mask register
  694. */
  695. extern void __set_PRIMASK(uint32_t priMask);
  696. /**
  697. * @brief Return the Fault Mask value
  698. *
  699. * @return FaultMask
  700. *
  701. * Return the content of the fault mask register
  702. */
  703. extern uint32_t __get_FAULTMASK(void);
  704. /**
  705. * @brief Set the Fault Mask value
  706. *
  707. * @param faultMask faultMask value
  708. *
  709. * Set the fault mask register
  710. */
  711. extern void __set_FAULTMASK(uint32_t faultMask);
  712. /**
  713. * @brief Return the Control Register value
  714. *
  715. * @return Control value
  716. *
  717. * Return the content of the control register
  718. */
  719. extern uint32_t __get_CONTROL(void);
  720. /**
  721. * @brief Set the Control Register value
  722. *
  723. * @param control Control value
  724. *
  725. * Set the control register
  726. */
  727. extern void __set_CONTROL(uint32_t control);
  728. #else /* (__ARMCC_VERSION >= 400000) */
  729. /**
  730. * @brief Remove the exclusive lock created by ldrex
  731. *
  732. * Removes the exclusive lock which is created by ldrex.
  733. */
  734. #define __CLREX __clrex
  735. /**
  736. * @brief Return the Base Priority value
  737. *
  738. * @return BasePriority
  739. *
  740. * Return the content of the base priority register
  741. */
  742. static __INLINE uint32_t __get_BASEPRI(void)
  743. {
  744. register uint32_t __regBasePri __ASM("basepri");
  745. return(__regBasePri);
  746. }
  747. /**
  748. * @brief Set the Base Priority value
  749. *
  750. * @param basePri BasePriority
  751. *
  752. * Set the base priority register
  753. */
  754. static __INLINE void __set_BASEPRI(uint32_t basePri)
  755. {
  756. register uint32_t __regBasePri __ASM("basepri");
  757. __regBasePri = (basePri & 0xff);
  758. }
  759. /**
  760. * @brief Return the Priority Mask value
  761. *
  762. * @return PriMask
  763. *
  764. * Return state of the priority mask bit from the priority mask register
  765. */
  766. static __INLINE uint32_t __get_PRIMASK(void)
  767. {
  768. register uint32_t __regPriMask __ASM("primask");
  769. return(__regPriMask);
  770. }
  771. /**
  772. * @brief Set the Priority Mask value
  773. *
  774. * @param priMask PriMask
  775. *
  776. * Set the priority mask bit in the priority mask register
  777. */
  778. static __INLINE void __set_PRIMASK(uint32_t priMask)
  779. {
  780. register uint32_t __regPriMask __ASM("primask");
  781. __regPriMask = (priMask);
  782. }
  783. /**
  784. * @brief Return the Fault Mask value
  785. *
  786. * @return FaultMask
  787. *
  788. * Return the content of the fault mask register
  789. */
  790. static __INLINE uint32_t __get_FAULTMASK(void)
  791. {
  792. register uint32_t __regFaultMask __ASM("faultmask");
  793. return(__regFaultMask);
  794. }
  795. /**
  796. * @brief Set the Fault Mask value
  797. *
  798. * @param faultMask faultMask value
  799. *
  800. * Set the fault mask register
  801. */
  802. static __INLINE void __set_FAULTMASK(uint32_t faultMask)
  803. {
  804. register uint32_t __regFaultMask __ASM("faultmask");
  805. __regFaultMask = (faultMask & 1);
  806. }
  807. /**
  808. * @brief Return the Control Register value
  809. *
  810. * @return Control value
  811. *
  812. * Return the content of the control register
  813. */
  814. static __INLINE uint32_t __get_CONTROL(void)
  815. {
  816. register uint32_t __regControl __ASM("control");
  817. return(__regControl);
  818. }
  819. /**
  820. * @brief Set the Control Register value
  821. *
  822. * @param control Control value
  823. *
  824. * Set the control register
  825. */
  826. static __INLINE void __set_CONTROL(uint32_t control)
  827. {
  828. register uint32_t __regControl __ASM("control");
  829. __regControl = control;
  830. }
  831. #endif /* __ARMCC_VERSION */
  832. #elif (defined (__ICCARM__)) /*------------------ ICC Compiler -------------------*/
  833. /* IAR iccarm specific functions */
  834. #define __enable_irq __enable_interrupt /*!< global Interrupt enable */
  835. #define __disable_irq __disable_interrupt /*!< global Interrupt disable */
  836. static __INLINE void __enable_fault_irq() { __ASM ("cpsie f"); }
  837. static __INLINE void __disable_fault_irq() { __ASM ("cpsid f"); }
  838. #define __NOP __no_operation /*!< no operation intrinsic in IAR Compiler */
  839. static __INLINE void __WFI() { __ASM ("wfi"); }
  840. static __INLINE void __WFE() { __ASM ("wfe"); }
  841. static __INLINE void __SEV() { __ASM ("sev"); }
  842. static __INLINE void __CLREX() { __ASM ("clrex"); }
  843. /* intrinsic void __ISB(void) */
  844. /* intrinsic void __DSB(void) */
  845. /* intrinsic void __DMB(void) */
  846. /* intrinsic void __set_PRIMASK(); */
  847. /* intrinsic void __get_PRIMASK(); */
  848. /* intrinsic void __set_FAULTMASK(); */
  849. /* intrinsic void __get_FAULTMASK(); */
  850. /* intrinsic uint32_t __REV(uint32_t value); */
  851. /* intrinsic uint32_t __REVSH(uint32_t value); */
  852. /* intrinsic unsigned long __STREX(unsigned long, unsigned long); */
  853. /* intrinsic unsigned long __LDREX(unsigned long *); */
  854. /**
  855. * @brief Return the Process Stack Pointer
  856. *
  857. * @return ProcessStackPointer
  858. *
  859. * Return the actual process stack pointer
  860. */
  861. extern uint32_t __get_PSP(void);
  862. /**
  863. * @brief Set the Process Stack Pointer
  864. *
  865. * @param topOfProcStack Process Stack Pointer
  866. *
  867. * Assign the value ProcessStackPointer to the MSP
  868. * (process stack pointer) Cortex processor register
  869. */
  870. extern void __set_PSP(uint32_t topOfProcStack);
  871. /**
  872. * @brief Return the Main Stack Pointer
  873. *
  874. * @return Main Stack Pointer
  875. *
  876. * Return the current value of the MSP (main stack pointer)
  877. * Cortex processor register
  878. */
  879. extern uint32_t __get_MSP(void);
  880. /**
  881. * @brief Set the Main Stack Pointer
  882. *
  883. * @param topOfMainStack Main Stack Pointer
  884. *
  885. * Assign the value mainStackPointer to the MSP
  886. * (main stack pointer) Cortex processor register
  887. */
  888. extern void __set_MSP(uint32_t topOfMainStack);
  889. /**
  890. * @brief Reverse byte order in unsigned short value
  891. *
  892. * @param value value to reverse
  893. * @return reversed value
  894. *
  895. * Reverse byte order in unsigned short value
  896. */
  897. extern uint32_t __REV16(uint16_t value);
  898. /**
  899. * @brief Reverse bit order of value
  900. *
  901. * @param value value to reverse
  902. * @return reversed value
  903. *
  904. * Reverse bit order of value
  905. */
  906. extern uint32_t __RBIT(uint32_t value);
  907. /**
  908. * @brief LDR Exclusive (8 bit)
  909. *
  910. * @param *addr address pointer
  911. * @return value of (*address)
  912. *
  913. * Exclusive LDR command for 8 bit values)
  914. */
  915. extern uint8_t __LDREXB(uint8_t *addr);
  916. /**
  917. * @brief LDR Exclusive (16 bit)
  918. *
  919. * @param *addr address pointer
  920. * @return value of (*address)
  921. *
  922. * Exclusive LDR command for 16 bit values
  923. */
  924. extern uint16_t __LDREXH(uint16_t *addr);
  925. /**
  926. * @brief LDR Exclusive (32 bit)
  927. *
  928. * @param *addr address pointer
  929. * @return value of (*address)
  930. *
  931. * Exclusive LDR command for 32 bit values
  932. */
  933. extern uint32_t __LDREXW(uint32_t *addr);
  934. /**
  935. * @brief STR Exclusive (8 bit)
  936. *
  937. * @param value value to store
  938. * @param *addr address pointer
  939. * @return successful / failed
  940. *
  941. * Exclusive STR command for 8 bit values
  942. */
  943. extern uint32_t __STREXB(uint8_t value, uint8_t *addr);
  944. /**
  945. * @brief STR Exclusive (16 bit)
  946. *
  947. * @param value value to store
  948. * @param *addr address pointer
  949. * @return successful / failed
  950. *
  951. * Exclusive STR command for 16 bit values
  952. */
  953. extern uint32_t __STREXH(uint16_t value, uint16_t *addr);
  954. /**
  955. * @brief STR Exclusive (32 bit)
  956. *
  957. * @param value value to store
  958. * @param *addr address pointer
  959. * @return successful / failed
  960. *
  961. * Exclusive STR command for 32 bit values
  962. */
  963. extern uint32_t __STREXW(uint32_t value, uint32_t *addr);
  964. #elif (defined (__GNUC__)) /*------------------ GNU Compiler ---------------------*/
  965. /* GNU gcc specific functions */
  966. static __INLINE void __enable_irq() { __ASM volatile ("cpsie i"); }
  967. static __INLINE void __disable_irq() { __ASM volatile ("cpsid i"); }
  968. static __INLINE void __enable_fault_irq() { __ASM volatile ("cpsie f"); }
  969. static __INLINE void __disable_fault_irq() { __ASM volatile ("cpsid f"); }
  970. static __INLINE void __NOP() { __ASM volatile ("nop"); }
  971. static __INLINE void __WFI() { __ASM volatile ("wfi"); }
  972. static __INLINE void __WFE() { __ASM volatile ("wfe"); }
  973. static __INLINE void __SEV() { __ASM volatile ("sev"); }
  974. static __INLINE void __ISB() { __ASM volatile ("isb"); }
  975. static __INLINE void __DSB() { __ASM volatile ("dsb"); }
  976. static __INLINE void __DMB() { __ASM volatile ("dmb"); }
  977. static __INLINE void __CLREX() { __ASM volatile ("clrex"); }
  978. /**
  979. * @brief Return the Process Stack Pointer
  980. *
  981. * @return ProcessStackPointer
  982. *
  983. * Return the actual process stack pointer
  984. */
  985. extern uint32_t __get_PSP(void);
  986. /**
  987. * @brief Set the Process Stack Pointer
  988. *
  989. * @param topOfProcStack Process Stack Pointer
  990. *
  991. * Assign the value ProcessStackPointer to the MSP
  992. * (process stack pointer) Cortex processor register
  993. */
  994. extern void __set_PSP(uint32_t topOfProcStack);
  995. /**
  996. * @brief Return the Main Stack Pointer
  997. *
  998. * @return Main Stack Pointer
  999. *
  1000. * Return the current value of the MSP (main stack pointer)
  1001. * Cortex processor register
  1002. */
  1003. extern uint32_t __get_MSP(void);
  1004. /**
  1005. * @brief Set the Main Stack Pointer
  1006. *
  1007. * @param topOfMainStack Main Stack Pointer
  1008. *
  1009. * Assign the value mainStackPointer to the MSP
  1010. * (main stack pointer) Cortex processor register
  1011. */
  1012. extern void __set_MSP(uint32_t topOfMainStack);
  1013. /**
  1014. * @brief Return the Base Priority value
  1015. *
  1016. * @return BasePriority
  1017. *
  1018. * Return the content of the base priority register
  1019. */
  1020. extern uint32_t __get_BASEPRI(void);
  1021. /**
  1022. * @brief Set the Base Priority value
  1023. *
  1024. * @param basePri BasePriority
  1025. *
  1026. * Set the base priority register
  1027. */
  1028. extern void __set_BASEPRI(uint32_t basePri);
  1029. /**
  1030. * @brief Return the Priority Mask value
  1031. *
  1032. * @return PriMask
  1033. *
  1034. * Return state of the priority mask bit from the priority mask register
  1035. */
  1036. extern uint32_t __get_PRIMASK(void);
  1037. /**
  1038. * @brief Set the Priority Mask value
  1039. *
  1040. * @param priMask PriMask
  1041. *
  1042. * Set the priority mask bit in the priority mask register
  1043. */
  1044. extern void __set_PRIMASK(uint32_t priMask);
  1045. /**
  1046. * @brief Return the Fault Mask value
  1047. *
  1048. * @return FaultMask
  1049. *
  1050. * Return the content of the fault mask register
  1051. */
  1052. extern uint32_t __get_FAULTMASK(void);
  1053. /**
  1054. * @brief Set the Fault Mask value
  1055. *
  1056. * @param faultMask faultMask value
  1057. *
  1058. * Set the fault mask register
  1059. */
  1060. extern void __set_FAULTMASK(uint32_t faultMask);
  1061. /**
  1062. * @brief Return the Control Register value
  1063. *
  1064. * @return Control value
  1065. *
  1066. * Return the content of the control register
  1067. */
  1068. extern uint32_t __get_CONTROL(void);
  1069. /**
  1070. * @brief Set the Control Register value
  1071. *
  1072. * @param control Control value
  1073. *
  1074. * Set the control register
  1075. */
  1076. extern void __set_CONTROL(uint32_t control);
  1077. /**
  1078. * @brief Reverse byte order in integer value
  1079. *
  1080. * @param value value to reverse
  1081. * @return reversed value
  1082. *
  1083. * Reverse byte order in integer value
  1084. */
  1085. extern uint32_t __REV(uint32_t value);
  1086. /**
  1087. * @brief Reverse byte order in unsigned short value
  1088. *
  1089. * @param value value to reverse
  1090. * @return reversed value
  1091. *
  1092. * Reverse byte order in unsigned short value
  1093. */
  1094. extern uint32_t __REV16(uint16_t value);
  1095. /**
  1096. * @brief Reverse byte order in signed short value with sign extension to integer
  1097. *
  1098. * @param value value to reverse
  1099. * @return reversed value
  1100. *
  1101. * Reverse byte order in signed short value with sign extension to integer
  1102. */
  1103. extern int32_t __REVSH(int16_t value);
  1104. /**
  1105. * @brief Reverse bit order of value
  1106. *
  1107. * @param value value to reverse
  1108. * @return reversed value
  1109. *
  1110. * Reverse bit order of value
  1111. */
  1112. extern uint32_t __RBIT(uint32_t value);
  1113. /**
  1114. * @brief LDR Exclusive (8 bit)
  1115. *
  1116. * @param *addr address pointer
  1117. * @return value of (*address)
  1118. *
  1119. * Exclusive LDR command for 8 bit value
  1120. */
  1121. extern uint8_t __LDREXB(uint8_t *addr);
  1122. /**
  1123. * @brief LDR Exclusive (16 bit)
  1124. *
  1125. * @param *addr address pointer
  1126. * @return value of (*address)
  1127. *
  1128. * Exclusive LDR command for 16 bit values
  1129. */
  1130. extern uint16_t __LDREXH(uint16_t *addr);
  1131. /**
  1132. * @brief LDR Exclusive (32 bit)
  1133. *
  1134. * @param *addr address pointer
  1135. * @return value of (*address)
  1136. *
  1137. * Exclusive LDR command for 32 bit values
  1138. */
  1139. extern uint32_t __LDREXW(uint32_t *addr);
  1140. /**
  1141. * @brief STR Exclusive (8 bit)
  1142. *
  1143. * @param value value to store
  1144. * @param *addr address pointer
  1145. * @return successful / failed
  1146. *
  1147. * Exclusive STR command for 8 bit values
  1148. */
  1149. extern uint32_t __STREXB(uint8_t value, uint8_t *addr);
  1150. /**
  1151. * @brief STR Exclusive (16 bit)
  1152. *
  1153. * @param value value to store
  1154. * @param *addr address pointer
  1155. * @return successful / failed
  1156. *
  1157. * Exclusive STR command for 16 bit values
  1158. */
  1159. extern uint32_t __STREXH(uint16_t value, uint16_t *addr);
  1160. /**
  1161. * @brief STR Exclusive (32 bit)
  1162. *
  1163. * @param value value to store
  1164. * @param *addr address pointer
  1165. * @return successful / failed
  1166. *
  1167. * Exclusive STR command for 32 bit values
  1168. */
  1169. extern uint32_t __STREXW(uint32_t value, uint32_t *addr);
  1170. #elif (defined (__TASKING__)) /*------------------ TASKING Compiler ---------------------*/
  1171. /* TASKING carm specific functions */
  1172. /*
  1173. * The CMSIS functions have been implemented as intrinsics in the compiler.
  1174. * Please use "carm -?i" to get an up to date list of all instrinsics,
  1175. * Including the CMSIS ones.
  1176. */
  1177. #endif
  1178. /** @addtogroup CMSIS_CM3_Core_FunctionInterface CMSIS CM3 Core Function Interface
  1179. Core Function Interface containing:
  1180. - Core NVIC Functions
  1181. - Core SysTick Functions
  1182. - Core Reset Functions
  1183. */
  1184. /*@{*/
  1185. /* ########################## NVIC functions #################################### */
  1186. /**
  1187. * @brief Set the Priority Grouping in NVIC Interrupt Controller
  1188. *
  1189. * @param PriorityGroup is priority grouping field
  1190. *
  1191. * Set the priority grouping field using the required unlock sequence.
  1192. * The parameter priority_grouping is assigned to the field
  1193. * SCB->AIRCR [10:8] PRIGROUP field. Only values from 0..7 are used.
  1194. * In case of a conflict between priority grouping and available
  1195. * priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set.
  1196. */
  1197. static __INLINE void NVIC_SetPriorityGrouping(uint32_t PriorityGroup)
  1198. {
  1199. uint32_t reg_value;
  1200. uint32_t PriorityGroupTmp = (PriorityGroup & 0x07); /* only values 0..7 are used */
  1201. reg_value = SCB->AIRCR; /* read old register configuration */
  1202. reg_value &= ~(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk); /* clear bits to change */
  1203. reg_value = (reg_value |
  1204. (0x5FA << SCB_AIRCR_VECTKEY_Pos) |
  1205. (PriorityGroupTmp << 8)); /* Insert write key and priorty group */
  1206. SCB->AIRCR = reg_value;
  1207. }
  1208. /**
  1209. * @brief Get the Priority Grouping from NVIC Interrupt Controller
  1210. *
  1211. * @return priority grouping field
  1212. *
  1213. * Get the priority grouping from NVIC Interrupt Controller.
  1214. * priority grouping is SCB->AIRCR [10:8] PRIGROUP field.
  1215. */
  1216. static __INLINE uint32_t NVIC_GetPriorityGrouping(void)
  1217. {
  1218. return ((SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos); /* read priority grouping field */
  1219. }
  1220. /**
  1221. * @brief Enable Interrupt in NVIC Interrupt Controller
  1222. *
  1223. * @param IRQn The positive number of the external interrupt to enable
  1224. *
  1225. * Enable a device specific interupt in the NVIC interrupt controller.
  1226. * The interrupt number cannot be a negative value.
  1227. */
  1228. static __INLINE void NVIC_EnableIRQ(IRQn_Type IRQn)
  1229. {
  1230. NVIC->ISER[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F)); /* enable interrupt */
  1231. }
  1232. /**
  1233. * @brief Disable the interrupt line for external interrupt specified
  1234. *
  1235. * @param IRQn The positive number of the external interrupt to disable
  1236. *
  1237. * Disable a device specific interupt in the NVIC interrupt controller.
  1238. * The interrupt number cannot be a negative value.
  1239. */
  1240. static __INLINE void NVIC_DisableIRQ(IRQn_Type IRQn)
  1241. {
  1242. NVIC->ICER[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F)); /* disable interrupt */
  1243. }
  1244. /**
  1245. * @brief Read the interrupt pending bit for a device specific interrupt source
  1246. *
  1247. * @param IRQn The number of the device specifc interrupt
  1248. * @return 1 = interrupt pending, 0 = interrupt not pending
  1249. *
  1250. * Read the pending register in NVIC and return 1 if its status is pending,
  1251. * otherwise it returns 0
  1252. */
  1253. static __INLINE uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn)
  1254. {
  1255. return((uint32_t) ((NVIC->ISPR[(uint32_t)(IRQn) >> 5] & (1 << ((uint32_t)(IRQn) & 0x1F)))?1:0)); /* Return 1 if pending else 0 */
  1256. }
  1257. /**
  1258. * @brief Set the pending bit for an external interrupt
  1259. *
  1260. * @param IRQn The number of the interrupt for set pending
  1261. *
  1262. * Set the pending bit for the specified interrupt.
  1263. * The interrupt number cannot be a negative value.
  1264. */
  1265. static __INLINE void NVIC_SetPendingIRQ(IRQn_Type IRQn)
  1266. {
  1267. NVIC->ISPR[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F)); /* set interrupt pending */
  1268. }
  1269. /**
  1270. * @brief Clear the pending bit for an external interrupt
  1271. *
  1272. * @param IRQn The number of the interrupt for clear pending
  1273. *
  1274. * Clear the pending bit for the specified interrupt.
  1275. * The interrupt number cannot be a negative value.
  1276. */
  1277. static __INLINE void NVIC_ClearPendingIRQ(IRQn_Type IRQn)
  1278. {
  1279. NVIC->ICPR[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F)); /* Clear pending interrupt */
  1280. }
  1281. /**
  1282. * @brief Read the active bit for an external interrupt
  1283. *
  1284. * @param IRQn The number of the interrupt for read active bit
  1285. * @return 1 = interrupt active, 0 = interrupt not active
  1286. *
  1287. * Read the active register in NVIC and returns 1 if its status is active,
  1288. * otherwise it returns 0.
  1289. */
  1290. static __INLINE uint32_t NVIC_GetActive(IRQn_Type IRQn)
  1291. {
  1292. return((uint32_t)((NVIC->IABR[(uint32_t)(IRQn) >> 5] & (1 << ((uint32_t)(IRQn) & 0x1F)))?1:0)); /* Return 1 if active else 0 */
  1293. }
  1294. /**
  1295. * @brief Set the priority for an interrupt
  1296. *
  1297. * @param IRQn The number of the interrupt for set priority
  1298. * @param priority The priority to set
  1299. *
  1300. * Set the priority for the specified interrupt. The interrupt
  1301. * number can be positive to specify an external (device specific)
  1302. * interrupt, or negative to specify an internal (core) interrupt.
  1303. *
  1304. * Note: The priority cannot be set for every core interrupt.
  1305. */
  1306. static __INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority)
  1307. {
  1308. if(IRQn < 0) {
  1309. SCB->SHP[((uint32_t)(IRQn) & 0xF)-4] = ((priority << (8 - __NVIC_PRIO_BITS)) & 0xff); } /* set Priority for Cortex-M3 System Interrupts */
  1310. else {
  1311. NVIC->IP[(uint32_t)(IRQn)] = ((priority << (8 - __NVIC_PRIO_BITS)) & 0xff); } /* set Priority for device specific Interrupts */
  1312. }
  1313. /**
  1314. * @brief Read the priority for an interrupt
  1315. *
  1316. * @param IRQn The number of the interrupt for get priority
  1317. * @return The priority for the interrupt
  1318. *
  1319. * Read the priority for the specified interrupt. The interrupt
  1320. * number can be positive to specify an external (device specific)
  1321. * interrupt, or negative to specify an internal (core) interrupt.
  1322. *
  1323. * The returned priority value is automatically aligned to the implemented
  1324. * priority bits of the microcontroller.
  1325. *
  1326. * Note: The priority cannot be set for every core interrupt.
  1327. */
  1328. static __INLINE uint32_t NVIC_GetPriority(IRQn_Type IRQn)
  1329. {
  1330. if(IRQn < 0) {
  1331. return((uint32_t)(SCB->SHP[((uint32_t)(IRQn) & 0xF)-4] >> (8 - __NVIC_PRIO_BITS))); } /* get priority for Cortex-M3 system interrupts */
  1332. else {
  1333. return((uint32_t)(NVIC->IP[(uint32_t)(IRQn)] >> (8 - __NVIC_PRIO_BITS))); } /* get priority for device specific interrupts */
  1334. }
  1335. /**
  1336. * @brief Encode the priority for an interrupt
  1337. *
  1338. * @param PriorityGroup The used priority group
  1339. * @param PreemptPriority The preemptive priority value (starting from 0)
  1340. * @param SubPriority The sub priority value (starting from 0)
  1341. * @return The encoded priority for the interrupt
  1342. *
  1343. * Encode the priority for an interrupt with the given priority group,
  1344. * preemptive priority value and sub priority value.
  1345. * In case of a conflict between priority grouping and available
  1346. * priority bits (__NVIC_PRIO_BITS) the samllest possible priority group is set.
  1347. *
  1348. * The returned priority value can be used for NVIC_SetPriority(...) function
  1349. */
  1350. static __INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority)
  1351. {
  1352. uint32_t PriorityGroupTmp = (PriorityGroup & 0x07); /* only values 0..7 are used */
  1353. uint32_t PreemptPriorityBits;
  1354. uint32_t SubPriorityBits;
  1355. PreemptPriorityBits = ((7 - PriorityGroupTmp) > __NVIC_PRIO_BITS) ? __NVIC_PRIO_BITS : 7 - PriorityGroupTmp;
  1356. SubPriorityBits = ((PriorityGroupTmp + __NVIC_PRIO_BITS) < 7) ? 0 : PriorityGroupTmp - 7 + __NVIC_PRIO_BITS;
  1357. return (
  1358. ((PreemptPriority & ((1 << (PreemptPriorityBits)) - 1)) << SubPriorityBits) |
  1359. ((SubPriority & ((1 << (SubPriorityBits )) - 1)))
  1360. );
  1361. }
  1362. /**
  1363. * @brief Decode the priority of an interrupt
  1364. *
  1365. * @param Priority The priority for the interrupt
  1366. * @param PriorityGroup The used priority group
  1367. * @param pPreemptPriority The preemptive priority value (starting from 0)
  1368. * @param pSubPriority The sub priority value (starting from 0)
  1369. *
  1370. * Decode an interrupt priority value with the given priority group to
  1371. * preemptive priority value and sub priority value.
  1372. * In case of a conflict between priority grouping and available
  1373. * priority bits (__NVIC_PRIO_BITS) the samllest possible priority group is set.
  1374. *
  1375. * The priority value can be retrieved with NVIC_GetPriority(...) function
  1376. */
  1377. static __INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* pPreemptPriority, uint32_t* pSubPriority)
  1378. {
  1379. uint32_t PriorityGroupTmp = (PriorityGroup & 0x07); /* only values 0..7 are used */
  1380. uint32_t PreemptPriorityBits;
  1381. uint32_t SubPriorityBits;
  1382. PreemptPriorityBits = ((7 - PriorityGroupTmp) > __NVIC_PRIO_BITS) ? __NVIC_PRIO_BITS : 7 - PriorityGroupTmp;
  1383. SubPriorityBits = ((PriorityGroupTmp + __NVIC_PRIO_BITS) < 7) ? 0 : PriorityGroupTmp - 7 + __NVIC_PRIO_BITS;
  1384. *pPreemptPriority = (Priority >> SubPriorityBits) & ((1 << (PreemptPriorityBits)) - 1);
  1385. *pSubPriority = (Priority ) & ((1 << (SubPriorityBits )) - 1);
  1386. }
  1387. /* ################################## SysTick function ############################################ */
  1388. #if (!defined (__Vendor_SysTickConfig)) || (__Vendor_SysTickConfig == 0)
  1389. /**
  1390. * @brief Initialize and start the SysTick counter and its interrupt.
  1391. *
  1392. * @param ticks number of ticks between two interrupts
  1393. * @return 1 = failed, 0 = successful
  1394. *
  1395. * Initialise the system tick timer and its interrupt and start the
  1396. * system tick timer / counter in free running mode to generate
  1397. * periodical interrupts.
  1398. */
  1399. static __INLINE uint32_t SysTick_Config(uint32_t ticks)
  1400. {
  1401. if (ticks > SysTick_LOAD_RELOAD_Msk) return (1); /* Reload value impossible */
  1402. SysTick->LOAD = (ticks & SysTick_LOAD_RELOAD_Msk) - 1; /* set reload register */
  1403. NVIC_SetPriority (SysTick_IRQn, (1<<__NVIC_PRIO_BITS) - 1); /* set Priority for Cortex-M0 System Interrupts */
  1404. SysTick->VAL = 0; /* Load the SysTick Counter Value */
  1405. SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk |
  1406. SysTick_CTRL_TICKINT_Msk |
  1407. SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */
  1408. return (0); /* Function successful */
  1409. }
  1410. #endif
  1411. /* ################################## Reset function ############################################ */
  1412. /**
  1413. * @brief Initiate a system reset request.
  1414. *
  1415. * Initiate a system reset request to reset the MCU
  1416. */
  1417. static __INLINE void NVIC_SystemReset(void)
  1418. {
  1419. SCB->AIRCR = ((0x5FA << SCB_AIRCR_VECTKEY_Pos) |
  1420. (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) |
  1421. SCB_AIRCR_SYSRESETREQ_Msk); /* Keep priority group unchanged */
  1422. __DSB(); /* Ensure completion of memory access */
  1423. while(1); /* wait until reset */
  1424. }
  1425. /*@}*/ /* end of group CMSIS_CM3_Core_FunctionInterface */
  1426. /* ##################################### Debug In/Output function ########################################### */
  1427. /** @addtogroup CMSIS_CM3_CoreDebugInterface CMSIS CM3 Core Debug Interface
  1428. Core Debug Interface containing:
  1429. - Core Debug Receive / Transmit Functions
  1430. - Core Debug Defines
  1431. - Core Debug Variables
  1432. */
  1433. /*@{*/
  1434. extern volatile int ITM_RxBuffer; /*!< variable to receive characters */
  1435. #define ITM_RXBUFFER_EMPTY 0x5AA55AA5 /*!< value identifying ITM_RxBuffer is ready for next character */
  1436. /**
  1437. * @brief Outputs a character via the ITM channel 0
  1438. *
  1439. * @param ch character to output
  1440. * @return character to output
  1441. *
  1442. * The function outputs a character via the ITM channel 0.
  1443. * The function returns when no debugger is connected that has booked the output.
  1444. * It is blocking when a debugger is connected, but the previous character send is not transmitted.
  1445. */
  1446. static __INLINE uint32_t ITM_SendChar (uint32_t ch)
  1447. {
  1448. if ((CoreDebug->DEMCR & CoreDebug_DEMCR_TRCENA_Msk) && /* Trace enabled */
  1449. (ITM->TCR & ITM_TCR_ITMENA_Msk) && /* ITM enabled */
  1450. (ITM->TER & (1ul << 0) ) ) /* ITM Port #0 enabled */
  1451. {
  1452. while (ITM->PORT[0].u32 == 0);
  1453. ITM->PORT[0].u8 = (uint8_t) ch;
  1454. }
  1455. return (ch);
  1456. }
  1457. /**
  1458. * @brief Inputs a character via variable ITM_RxBuffer
  1459. *
  1460. * @return received character, -1 = no character received
  1461. *
  1462. * The function inputs a character via variable ITM_RxBuffer.
  1463. * The function returns when no debugger is connected that has booked the output.
  1464. * It is blocking when a debugger is connected, but the previous character send is not transmitted.
  1465. */
  1466. static __INLINE int ITM_ReceiveChar (void) {
  1467. int ch = -1; /* no character available */
  1468. if (ITM_RxBuffer != ITM_RXBUFFER_EMPTY) {
  1469. ch = ITM_RxBuffer;
  1470. ITM_RxBuffer = ITM_RXBUFFER_EMPTY; /* ready for next character */
  1471. }
  1472. return (ch);
  1473. }
  1474. /**
  1475. * @brief Check if a character via variable ITM_RxBuffer is available
  1476. *
  1477. * @return 1 = character available, 0 = no character available
  1478. *
  1479. * The function checks variable ITM_RxBuffer whether a character is available or not.
  1480. * The function returns '1' if a character is available and '0' if no character is available.
  1481. */
  1482. static __INLINE int ITM_CheckChar (void) {
  1483. if (ITM_RxBuffer == ITM_RXBUFFER_EMPTY) {
  1484. return (0); /* no character available */
  1485. } else {
  1486. return (1); /* character available */
  1487. }
  1488. }
  1489. /*@}*/ /* end of group CMSIS_CM3_core_DebugInterface */
  1490. #ifdef __cplusplus
  1491. }
  1492. #endif
  1493. /*@}*/ /* end of group CMSIS_CM3_core_definitions */
  1494. #endif /* __CM3_CORE_H__ */
  1495. /*lint -restore */