core_cm3-.h 82 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818
  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 */