stm8l15x.h 128 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027
  1. /**
  2. ******************************************************************************
  3. * @file stm8l15x.h
  4. * @author MCD Application Team
  5. * @version V1.6.1
  6. * @date 30-September-2014
  7. * @brief This file contains all the peripheral register's definitions, bits
  8. * definitions and memory mapping for STM8L15x devices.
  9. ******************************************************************************
  10. * @attention
  11. *
  12. * <h2><center>&copy; COPYRIGHT 2014 STMicroelectronics</center></h2>
  13. *
  14. * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
  15. * You may not use this file except in compliance with the License.
  16. * You may obtain a copy of the License at:
  17. *
  18. * http://www.st.com/software_license_agreement_liberty_v2
  19. *
  20. * Unless required by applicable law or agreed to in writing, software
  21. * distributed under the License is distributed on an "AS IS" BASIS,
  22. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  23. * See the License for the specific language governing permissions and
  24. * limitations under the License.
  25. *
  26. ******************************************************************************
  27. */
  28. /* Define to prevent recursive inclusion -------------------------------------*/
  29. #ifndef __STM8L15x_H
  30. #define __STM8L15x_H
  31. /** @addtogroup STM8L15x_StdPeriph_Driver
  32. * @{
  33. */
  34. /* Uncomment the line below according to the target STM8L15x device used in your
  35. application
  36. */
  37. /* #define STM8L15X_LD */ /*!< STM8L15X_LD: STM8L15x Low density devices */
  38. /* #define STM8L15X_MD */ /*!< STM8L15X_MD: STM8L15x Medium density devices */
  39. /* #define STM8L15X_MDP */ /*!< STM8L15X_MDP: STM8L15x Medium density plus devices */
  40. /* #define STM8L15X_HD */ /*!< STM8L15X_HD: STM8L15x/16x High density devices */
  41. /* #define STM8L05X_LD_VL */ /*!< STM8L05X_LD_VL: STM8L051xx3 Low density value line devices */
  42. /* #define STM8L05X_MD_VL */ /*!< STM8L05X_MD_VL: STM8L052xx6 Medium density value line devices */
  43. /* #define STM8L05X_HD_VL */ /*!< STM8L05X_HD_VL: STM8L052xx8 High density value line devices */
  44. /* #define STM8AL31_L_MD */ /*!< STM8AL31_L_MD: STM8AL3x Medium density devices */
  45. /* Tip: To avoid modifying this file each time you need to switch between these
  46. devices, you can define the device in your toolchain compiler preprocessor.
  47. - Low density STM8L15x devices are STM8L151C3, STM8L151K3, STM8L151G3, STM8L151F3,
  48. STM8L151C2, STM8L151K2, STM8L151G2 and STM8L151F2 microcontrollers where the
  49. Flash memory density ranges between 4 and 8 Kbytes.
  50. - Medium density STM8L15x devices are STM8L151C4, STM8L151C6, STM8L152C4,
  51. STM8L152C6, STM8L151K4, STM8L151K6, STM8L152K4, STM8L152K6, STM8L151G4,
  52. STM8L151G6, STM8L152G4 and STM8L152G6 microcontrollers where the Flash memory
  53. density ranges between 16 and 32 Kbytes.
  54. - Medium density Plus devices are STM8L151R6, STM8L152R6 microcontrollers where
  55. the Flash memory density is fixed and equal to 32 Kbytes and a wider range of
  56. peripheral than the medium density devices.
  57. - High density STM8L15x devices are STM8L151x8, STM8L152x8, STM8L162R8 and STM8L162M8
  58. microcontrollers where the Flash memory density is fixed and equal to 64 Kbytes with
  59. the same peripheral set than Medium Density Plus devices.
  60. - Value line low density STM8L05xx devices are STM8L051x3 microcontrollers
  61. with 8-KB Flash
  62. - Value line medium density STM8L05xx devices are STM8L052x6 microcontrollers
  63. with 32-KB Flash
  64. - Value line high density STM8L05xx devices: STM8L052x8 microcontrollers
  65. with 64-KB Flash
  66. - Medium density STM8AL31xx/STM8AL3Lxx devices: STM8AL3168, STM8AL3166,
  67. STM8AL3148,STM8AL3146, STM8AL3138, STM8AL3136, STM8AL3L68, STM8AL3L66,
  68. STM8AL3L48, STM8AL3L46 microcontrollers with 8-KB, 16-KB or 32-KB Flash
  69. */
  70. #if !defined (STM8L15X_MD) && !defined (STM8L15X_MDP) && !defined (STM8L15X_HD) && !defined (STM8L15X_LD) \
  71. && !defined (STM8L05X_LD_VL) && !defined (STM8L05X_MD_VL) && !defined (STM8L05X_HD_VL) && !defined (STM8AL31_L_MD)
  72. #error "Please select first the target STM8L device used in your application (in stm8l15x.h file)"
  73. #endif
  74. /******************************************************************************/
  75. /* Library configuration section */
  76. /******************************************************************************/
  77. /* Check the used compiler */
  78. #if defined(__CSMC__)
  79. #define _COSMIC_
  80. #elif defined(__RCSTM8__)
  81. #define _RAISONANCE_
  82. #elif defined(__ICCSTM8__)
  83. #define _IAR_
  84. #else
  85. #error "Unsupported Compiler!" /* Compiler defines not found */
  86. #endif
  87. #if !defined USE_STDPERIPH_DRIVER
  88. /* Comment the line below if you will not use the peripherals drivers.
  89. In this case, these drivers will not be included and the application code will be
  90. based on direct access to peripherals registers */
  91. #define USE_STDPERIPH_DRIVER
  92. #endif
  93. /**
  94. * @brief In the following line adjust the value of External High Speed oscillator (HSE)
  95. used in your application
  96. Tip: To avoid modifying this file each time you need to use different HSE, you
  97. can define the HSE value in your toolchain compiler preprocessor.
  98. */
  99. #if !defined HSE_VALUE
  100. #define HSE_VALUE ((uint32_t)16000000) /*!< Typical Value of the HSE in Hz */
  101. #endif /* HSE_VALUE */
  102. /**
  103. * @brief Definition of External Low Speed oscillator (LSE) frequency
  104. */
  105. #if !defined LSE_VALUE
  106. #define LSE_VALUE ((uint32_t)32768) /*!< Typical Value of the LSE in Hz */
  107. #endif /* LSE_VALUE */
  108. /**
  109. * @brief Definition of Device on-chip RC oscillator frequencies
  110. */
  111. #if !defined HSI_VALUE
  112. #define HSI_VALUE ((uint32_t)16000000) /*!< Typical Value of the HSI in Hz */
  113. #endif /* HSI_VALUE */
  114. #if !defined LSI_VALUE
  115. #define LSI_VALUE ((uint32_t)38000) /*!< Typical Value of the LSI in Hz */
  116. #endif /* LSI_VALUE */
  117. #ifdef _COSMIC_
  118. #define FAR @far
  119. #define NEAR @near
  120. #define TINY @tiny
  121. #define EEPROM @eeprom
  122. #define CONST const
  123. #elif defined (_RAISONANCE_) /* __RCSTM8__ */
  124. #define FAR far
  125. #define NEAR data
  126. #define TINY page0
  127. #define EEPROM eeprom
  128. #define CONST code
  129. #if defined (STM8L15X_MD) || defined (STM8L15X_MDP) || defined (STM8L05X_MD_VL) || \
  130. defined (STM8AL31_L_MD)
  131. /*!< Used with memory Models for code less than 64K */
  132. #define MEMCPY memcpy
  133. #elif defined (STM8L15X_HD) || defined (STM8L05X_HD_VL)
  134. /*!< Used with memory Models for code higher than 64K */
  135. #define MEMCPY fmemcpy
  136. #endif /* STM8L15X_MD or STM8L15X_MDP or STM8L05X_MD_VL or STM8AL31_L_MD*/
  137. #else /*_IAR_*/
  138. #define FAR __far
  139. #define NEAR __near
  140. #define TINY __tiny
  141. #define EEPROM __eeprom
  142. #define CONST const
  143. #endif /* __CSMC__ */
  144. /**
  145. * @brief Legacy definition
  146. */
  147. #define __CONST CONST
  148. #if defined (STM8L15X_MD) || defined (STM8L15X_MDP) || defined (STM8L15X_LD) || \
  149. defined (STM8L05X_LD_VL) || defined (STM8L05X_MD_VL) || defined (STM8AL31_L_MD)
  150. /*!< Used with memory Models for code smaller than 64K */
  151. #define PointerAttr NEAR
  152. #define MemoryAddressCast uint16_t
  153. #elif defined (STM8L15X_HD) || defined (STM8L05X_HD_VL)
  154. /*!< Used with memory Models for code higher than 64K */
  155. #define PointerAttr FAR
  156. #define MemoryAddressCast uint32_t
  157. #endif /* STM8L15X_MD or STM8L15X_MDP or STM8L15X_LD or STM8L05X_LD_VL or STM8L05X_MD_VL
  158. or STM8AL31_L_MD */
  159. /* Uncomment the line below to enable the FLASH functions execution from RAM */
  160. #if !defined (RAM_EXECUTION)
  161. /* #define RAM_EXECUTION (1) */
  162. #endif /* RAM_EXECUTION */
  163. #ifdef RAM_EXECUTION
  164. #ifdef _COSMIC_
  165. #define IN_RAM(a) a
  166. #elif defined (_RAISONANCE_) /* __RCSTM8__ */
  167. #define IN_RAM(a) a inram
  168. #else /*_IAR_*/
  169. #define IN_RAM(a) __ramfunc a
  170. #endif /* _COSMIC_ */
  171. #else
  172. #define IN_RAM(a) a
  173. #endif /* RAM_EXECUTION */
  174. /*!< [31:16] STM8L15X Standard Peripheral Library main version */
  175. #define __STM8L15X_STDPERIPH_VERSION_MAIN ((uint8_t)0x01) /*!< [31:24] main version */
  176. #define __STM8L15X_STDPERIPH_VERSION_SUB1 ((uint8_t)0x06) /*!< [23:16] sub1 version */
  177. #define __STM8L15X_STDPERIPH_VERSION_SUB2 ((uint8_t)0x01) /*!< [15:8] sub2 version */
  178. #define __STM8L15X_STDPERIPH_VERSION_RC ((uint8_t)0x00) /*!< [7:0] release candidate */
  179. #define __STM8L15X_STDPERIPH_VERSION ( (__STM8L15X_STDPERIPH_VERSION_MAIN << 24)\
  180. |(__STM8L15X_STDPERIPH_VERSION_SUB1 << 16)\
  181. |(__STM8L15X_STDPERIPH_VERSION_SUB2 << 8)\
  182. |(__STM8L15X_STDPERIPH_VERSION_RC))
  183. /******************************************************************************/
  184. /* Includes ------------------------------------------------------------------*/
  185. /* Exported types and constants ----------------------------------------------*/
  186. /** @addtogroup Exported_types
  187. * @{
  188. */
  189. /**
  190. * IO definitions
  191. *
  192. * define access restrictions to peripheral registers
  193. */
  194. #define __I volatile const /*!< defines 'read only' permissions */
  195. #define __O volatile /*!< defines 'write only' permissions */
  196. #define __IO volatile /*!< defines 'read / write' permissions */
  197. /*!< Signed integer types */
  198. typedef signed char int8_t;
  199. typedef signed short int16_t;
  200. typedef signed long int32_t;
  201. /*!< Unsigned integer types */
  202. typedef unsigned char uint8_t;
  203. typedef unsigned short uint16_t;
  204. typedef unsigned long uint32_t;
  205. /*!< STM8Lx Standard Peripheral Library old types (maintained for legacy purpose) */
  206. typedef int32_t s32;
  207. typedef int16_t s16;
  208. typedef int8_t s8;
  209. typedef uint32_t u32;
  210. typedef uint16_t u16;
  211. typedef uint8_t u8;
  212. typedef enum {FALSE = 0, TRUE = !FALSE} bool;
  213. typedef enum {RESET = 0, SET = !RESET} FlagStatus, ITStatus, BitStatus, BitAction;
  214. typedef enum {DISABLE = 0, ENABLE = !DISABLE} FunctionalState;
  215. #define IS_FUNCTIONAL_STATE(STATE) (((STATE) == DISABLE) || ((STATE) == ENABLE))
  216. typedef enum {ERROR = 0, SUCCESS = !ERROR} ErrorStatus;
  217. #define U8_MAX (255)
  218. #define S8_MAX (127)
  219. #define S8_MIN (-128)
  220. #define U16_MAX (65535u)
  221. #define S16_MAX (32767)
  222. #define S16_MIN (-32768)
  223. #define U32_MAX (4294967295uL)
  224. #define S32_MAX (2147483647)
  225. #define S32_MIN (-2147483648uL)
  226. /**
  227. * @}
  228. */
  229. /** @addtogroup MAP_FILE_Exported_Types_and_Constants
  230. * @{
  231. */
  232. /******************************************************************************/
  233. /* IP registers structures */
  234. /******************************************************************************/
  235. /*----------------------------------------------------------------------------*/
  236. /**
  237. * @brief General Purpose I/Os (GPIO)
  238. */
  239. typedef struct GPIO_struct
  240. {
  241. __IO uint8_t ODR; /*!< Output Data Register */
  242. __IO uint8_t IDR; /*!< Input Data Register */
  243. __IO uint8_t DDR; /*!< Data Direction Register */
  244. __IO uint8_t CR1; /*!< Configuration Register 1 */
  245. __IO uint8_t CR2; /*!< Configuration Register 2 */
  246. }
  247. GPIO_TypeDef;
  248. /** @addtogroup GPIO_Registers_Reset_Value
  249. * @{
  250. */
  251. #define GPIO_ODR_RESET_VALUE ((uint8_t)0x00)
  252. #define GPIO_DDR_RESET_VALUE ((uint8_t)0x00)
  253. #define GPIO_CR1_RESET_VALUE ((uint8_t)0x00)
  254. #define GPIO_CR2_RESET_VALUE ((uint8_t)0x00)
  255. /**
  256. * @}
  257. */
  258. /*----------------------------------------------------------------------------*/
  259. /**
  260. * @brief Real-Time Clock (RTC) peripheral registers.
  261. */
  262. typedef struct RTC_struct
  263. {
  264. __IO uint8_t TR1; /*!< Time Register 1*/
  265. __IO uint8_t TR2; /*!< Time Register 2*/
  266. __IO uint8_t TR3; /*!< Time Register 3*/
  267. uint8_t RESERVED0;
  268. __IO uint8_t DR1; /*!< Date Register 1*/
  269. __IO uint8_t DR2; /*!< Date Register 2*/
  270. __IO uint8_t DR3; /*!< Date Register 3*/
  271. uint8_t RESERVED1;
  272. __IO uint8_t CR1; /*!< Control Register 1*/
  273. __IO uint8_t CR2; /*!< Control Register 2*/
  274. __IO uint8_t CR3; /*!< Control Register 3*/
  275. uint8_t RESERVED2;
  276. __IO uint8_t ISR1; /*!< Initialisation and Status Register 1 */
  277. __IO uint8_t ISR2; /*!< Initialisation and Status Register 2 */
  278. uint8_t RESERVED3;
  279. uint8_t RESERVED4;
  280. __IO uint8_t SPRERH; /*!< Synchronous Prediv high Register */
  281. __IO uint8_t SPRERL; /*!< Synchronous Prediv Low Register */
  282. __IO uint8_t APRER; /*!< Asynchronous Prediv Register */
  283. uint8_t RESERVED5;
  284. __IO uint8_t WUTRH; /*!< Wake-Up Timer High Register */
  285. __IO uint8_t WUTRL; /*!< Wake-Up Timer Low Register */
  286. uint8_t RESERVED6;
  287. __IO uint8_t SSRH; /*!< Sub Second High Register */
  288. __IO uint8_t SSRL; /*!< Sub Second Low Register */
  289. __IO uint8_t WPR; /*!< Write Protection Register */
  290. __IO uint8_t SHIFTRH; /*!< Shift control High Register */
  291. __IO uint8_t SHIFTRL; /*!< Shift control Low Register */
  292. __IO uint8_t ALRMAR1; /*!< ALARM A Register 1 */
  293. __IO uint8_t ALRMAR2; /*!< ALARM A Register 2 */
  294. __IO uint8_t ALRMAR3; /*!< ALARM A Register 3 */
  295. __IO uint8_t ALRMAR4; /*!< ALARM A Register 4 */
  296. uint8_t RESERVED7[4];
  297. __IO uint8_t ALRMASSRH; /*!< ALARM A Subsecond Register High */
  298. __IO uint8_t ALRMASSRL; /*!< ALARM A Subsecond Register Low */
  299. __IO uint8_t ALRMASSMSKR; /*!< ALARM A Subsecond Mask Register */
  300. uint8_t RESERVED8[3];
  301. __IO uint8_t CALRH; /*!< Calibration register high */
  302. __IO uint8_t CALRL; /*!< Calibration register low */
  303. __IO uint8_t TCR1; /*!< Tamper control register 1 */
  304. __IO uint8_t TCR2; /*!< Tamper control register 2 */
  305. }
  306. RTC_TypeDef;
  307. /** @addtogroup RTC_Registers_Reset_Value
  308. * @{
  309. */
  310. #define RTC_TR1_RESET_VALUE ((uint8_t)0x00)
  311. #define RTC_TR2_RESET_VALUE ((uint8_t)0x00)
  312. #define RTC_TR3_RESET_VALUE ((uint8_t)0x00)
  313. #define RTC_DR1_RESET_VALUE ((uint8_t)0x01)
  314. #define RTC_DR2_RESET_VALUE ((uint8_t)0x21)
  315. #define RTC_DR3_RESET_VALUE ((uint8_t)0x00)
  316. #define RTC_CR1_RESET_VALUE ((uint8_t)0x00)
  317. #define RTC_CR2_RESET_VALUE ((uint8_t)0x00)
  318. #define RTC_CR3_RESET_VALUE ((uint8_t)0x00)
  319. #define RTC_ISR1_RESET_VALUE ((uint8_t)0x07)
  320. #define RTC_ISR2_RESET_VALUE ((uint8_t)0x00)
  321. #define RTC_SPRERH_RESET_VALUE ((uint8_t)0x00)
  322. #define RTC_SPRERL_RESET_VALUE ((uint8_t)0xFF)
  323. #define RTC_APRER_RESET_VALUE ((uint8_t)0x7F)
  324. #define RTC_WUTRH_RESET_VALUE ((uint8_t)0xFF)
  325. #define RTC_WUTRL_RESET_VALUE ((uint8_t)0xFF)
  326. #define RTC_WPR_RESET_VALUE ((uint8_t)0x00)
  327. #define RTC_ALRMAR1_RESET_VALUE ((uint8_t)0x00)
  328. #define RTC_ALRMAR2_RESET_VALUE ((uint8_t)0x00)
  329. #define RTC_ALRMAR3_RESET_VALUE ((uint8_t)0x00)
  330. #define RTC_ALRMAR4_RESET_VALUE ((uint8_t)0x00)
  331. #define RTC_SHIFTRH_RESET_VALUE ((uint8_t)0x00)
  332. #define RTC_SHIFTRL_RESET_VALUE ((uint8_t)0x00)
  333. #define RTC_ALRMASSRH_RESET_VALUE ((uint8_t)0x00)
  334. #define RTC_ALRMASSRL_RESET_VALUE ((uint8_t)0x00)
  335. #define RTC_ALRMASSMSKR_RESET_VALUE ((uint8_t)0x00)
  336. #define RTC_CALRH_RESET_VALUE ((uint8_t)0x00)
  337. #define RTC_CALRL_RESET_VALUE ((uint8_t)0x00)
  338. #define RTC_TCR1_RESET_VALUE ((uint8_t)0x00)
  339. #define RTC_TCR2_RESET_VALUE ((uint8_t)0x00)
  340. /**
  341. * @}
  342. */
  343. /** @addtogroup RTC_Registers_Bits_Definition
  344. * @{
  345. */
  346. /* Bits definition for RTC_TR1 register*/
  347. #define RTC_TR1_ST ((uint8_t)0x70)
  348. #define RTC_TR1_SU ((uint8_t)0x0F)
  349. /* Bits definition for RTC_TR2 register*/
  350. #define RTC_TR2_MNT ((uint8_t)0x70)
  351. #define RTC_TR2_MNU ((uint8_t)0x0F)
  352. /* Bits definition for RTC_TR3 register*/
  353. #define RTC_TR3_PM ((uint8_t)0x40)
  354. #define RTC_TR3_HT ((uint8_t)0x30)
  355. #define RTC_TR3_HU ((uint8_t)0x0F)
  356. /* Bits definition for RTC_DR1 register*/
  357. #define RTC_DR1_DT ((uint8_t)0x30)
  358. #define RTC_DR1_DU ((uint8_t)0x0F)
  359. /* Bits definition for RTC_DR2 register*/
  360. #define RTC_DR2_WDU ((uint8_t)0xE0)
  361. #define RTC_DR2_MT ((uint8_t)0x10)
  362. #define RTC_DR2_MU ((uint8_t)0x0F)
  363. /* Bits definition for RTC_DR3 register*/
  364. #define RTC_DR3_YT ((uint8_t)0xF0)
  365. #define RTC_DR3_YU ((uint8_t)0x0F)
  366. /* Bits definition for RTC_CR1 register*/
  367. #define RTC_CR1_FMT ((uint8_t)0x40)
  368. #define RTC_CR1_RATIO ((uint8_t)0x20)
  369. #define RTC_CR1_WUCKSEL ((uint8_t)0x07)
  370. #define RTC_CR1_BYPSHAD ((uint8_t)0x10)
  371. /* Bits definition for RTC_CR2 register*/
  372. #define RTC_CR2_WUTIE ((uint8_t)0x40)
  373. #define RTC_CR2_ALRAIE ((uint8_t)0x10)
  374. #define RTC_CR2_WUTE ((uint8_t)0x04)
  375. #define RTC_CR2_ALRAE ((uint8_t)0x01)
  376. #define RTC_CR2_ALRIE ((uint8_t)0x20)
  377. /* Bits definition for RTC_CR3 register*/
  378. #define RTC_CR3_COE ((uint8_t)0x80)
  379. #define RTC_CR3_OSEL ((uint8_t)0x60)
  380. #define RTC_CR3_POL ((uint8_t)0x10)
  381. #define RTC_CR3_COSEL ((uint8_t)0x08)
  382. #define RTC_CR3_BCK ((uint8_t)0x04)
  383. #define RTC_CR3_SUB1H ((uint8_t)0x02)
  384. #define RTC_CR3_ADD1H ((uint8_t)0x01)
  385. /* Bits definition for RTC_ISR1 register*/
  386. #define RTC_ISR1_INIT ((uint8_t)0x80)
  387. #define RTC_ISR1_INITF ((uint8_t)0x40)
  388. #define RTC_ISR1_RSF ((uint8_t)0x20)
  389. #define RTC_ISR1_INITS ((uint8_t)0x10)
  390. #define RTC_ISR1_SHPF ((uint8_t)0x08)
  391. #define RTC_ISR1_WUTWF ((uint8_t)0x04)
  392. #define RTC_ISR1_RECALPF ((uint8_t)0x02)
  393. #define RTC_ISR1_ALRAWF ((uint8_t)0x01)
  394. /* Bits definition for RTC_ISR2 register*/
  395. #define RTC_ISR2_WUTF ((uint8_t)0x04)
  396. #define RTC_ISR2_ALRAF ((uint8_t)0x01)
  397. #define RTC_ISR2_TAMP3F ((uint8_t)0x80)
  398. #define RTC_ISR2_TAMP2F ((uint8_t)0x40)
  399. #define RTC_ISR2_TAMP1F ((uint8_t)0x20)
  400. /* Bits definition for RTC_SHIFTRH register*/
  401. #define RTC_SHIFTRH_ADD1S ((uint8_t)0x80)
  402. #define RTC_SHIFTRH_SUBFS ((uint8_t)0x7F)
  403. /* Bits definition for RTC_SHIFTRL register*/
  404. #define RTC_SHIFTRL_SUBFS ((uint8_t)0xFF)
  405. /* Bits definition for RTC_ALRMAR1 register*/
  406. #define RTC_ALRMAR1_MSK1 ((uint8_t)0x80)
  407. #define RTC_ALRMAR1_ST ((uint8_t)0x70)
  408. #define RTC_ALRMAR1_SU ((uint8_t)0x0F)
  409. /* Bits definition for RTC_ALRMAR2 register*/
  410. #define RTC_ALRMAR2_MSK2 ((uint8_t)0x80)
  411. #define RTC_ALRMAR2_MNT ((uint8_t)0x70)
  412. #define RTC_ALRMAR2_MNU ((uint8_t)0x0F)
  413. /* Bits definition for RTC_ALRMAR3 register*/
  414. #define RTC_ALRMAR3_MSK3 ((uint8_t)0x80)
  415. #define RTC_ALRMAR3_PM ((uint8_t)0x40)
  416. #define RTC_ALRMAR3_HT ((uint8_t)0x30)
  417. #define RTC_ALRMAR3_HU ((uint8_t)0x0F)
  418. /* Bits definition for RTC_ALRMAR4 register*/
  419. #define RTC_ALRMAR4_MSK4 ((uint8_t)0x80)
  420. #define RTC_ALRMAR4_WDSEL ((uint8_t)0x40)
  421. #define RTC_ALRMAR4_DT ((uint8_t)0x30)
  422. #define RTC_ALRMAR4_DU ((uint8_t)0x0F)
  423. /* Bits definition for RTC_ALRMASSRH register*/
  424. #define RTC_ALRMASSRH_ALSS ((uint8_t)0x7F)
  425. /* Bits definition for RTC_ALRMASSRL register*/
  426. #define RTC_ALRMASSRL_ALSS ((uint8_t)0xFF)
  427. /* Bits definition for RTC_ALRMASSMSKR register*/
  428. #define RTC_ALRMASSMSKR_MASKSS ((uint8_t)0x1F)
  429. /* Bits definition for RTC_CALRH register*/
  430. #define RTC_CALRH_CALP ((uint8_t)0x80)
  431. #define RTC_CALRH_CALW8 ((uint8_t)0x40)
  432. #define RTC_CALRH_CALW16 ((uint8_t)0x20)
  433. #define RTC_CALRH_CALWx ((uint8_t)0x60)
  434. #define RTC_CALRH_CALM ((uint8_t)0x01)
  435. /* Bits definition for RTC_CALRL register*/
  436. #define RTC_CALRL_CALM ((uint8_t)0xFF)
  437. /* Bits definition for RTC_TCR1 register*/
  438. #define RTC_TCR1_TAMP3LEVEL ((uint8_t)0x40)
  439. #define RTC_TCR1_TAMP3E ((uint8_t)0x20)
  440. #define RTC_TCR1_TAMP2LEVEL ((uint8_t)0x10)
  441. #define RTC_TCR1_TAMP2E ((uint8_t)0x08)
  442. #define RTC_TCR1_TAMP1LEVEL ((uint8_t)0x04)
  443. #define RTC_TCR1_TAMP1E ((uint8_t)0x02)
  444. #define RTC_TCR1_TAMPIE ((uint8_t)0x01)
  445. /* Bits definition for RTC_TCR2 register*/
  446. #define RTC_TCR2_TAMPPUDIS ((uint8_t)0x80)
  447. #define RTC_TCR2_TAMPPRCH ((uint8_t)0x60)
  448. #define RTC_TCR2_TAMPFLT ((uint8_t)0x18)
  449. #define RTC_TCR2_TAMPFREQ ((uint8_t)0x07)
  450. /*RTC special defines */
  451. #define RTC_WPR_EnableKey ((uint8_t)0xFF)
  452. #define RTC_WPR_DisableKey1 ((uint8_t)0xCA)
  453. #define RTC_WPR_DisableKey2 ((uint8_t)0x53)
  454. /**
  455. * @}
  456. */
  457. /**
  458. * @brief CSS on LSE registers.
  459. */
  460. typedef struct CSSLSE_struct
  461. {
  462. __IO uint8_t CSR; /*!< Control and Status Register*/
  463. }
  464. CSSLSE_TypeDef;
  465. /** @addtogroup CSSLSE_Registers_Reset_Value
  466. * @{
  467. */
  468. #define CSSLSE_CSR_RESET_VALUE ((uint8_t)0x00)
  469. /**
  470. * @}
  471. */
  472. /** @addtogroup CSSLSE_Registers_Bits_Definition
  473. * @{
  474. */
  475. /* Bits definition for CSSLSE_CSR register*/
  476. #define CSSLSE_CSR_SWITCHF ((uint8_t)0x10)
  477. #define CSSLSE_CSR_CSSF ((uint8_t)0x08)
  478. #define CSSLSE_CSR_CSSIE ((uint8_t)0x04)
  479. #define CSSLSE_CSR_SWITCHEN ((uint8_t)0x02)
  480. #define CSSLSE_CSR_CSSEN ((uint8_t)0x01)
  481. /**
  482. * @}
  483. */
  484. /*----------------------------------------------------------------------------*/
  485. /**
  486. * @brief Beeper (BEEP) peripheral registers.
  487. */
  488. typedef struct BEEP_struct
  489. {
  490. __IO uint8_t CSR1; /*!< BEEP Control status register1 */
  491. uint8_t RSERVED1;
  492. uint8_t RESERVED2;
  493. __IO uint8_t CSR2; /*!< BEEP Control status register2 */
  494. }
  495. BEEP_TypeDef;
  496. /** @addtogroup BEEP_Registers_Reset_Value
  497. * @{
  498. */
  499. #define BEEP_CSR1_RESET_VALUE ((uint8_t)0x00)
  500. #define BEEP_CSR2_RESET_VALUE ((uint8_t)0x1F)
  501. /**
  502. * @}
  503. */
  504. /** @addtogroup BEEP_Registers_Bits_Definition
  505. * @{
  506. */
  507. #define BEEP_CSR1_MSR ((uint8_t)0x01) /*!< Measurement enable mask */
  508. #define BEEP_CSR2_BEEPSEL ((uint8_t)0xC0) /*!< Beeper frequency selection mask */
  509. #define BEEP_CSR2_BEEPEN ((uint8_t)0x20) /*!< Beeper enable mask */
  510. #define BEEP_CSR2_BEEPDIV ((uint8_t)0x1F) /*!< Beeper Divider prescalar mask */
  511. /**
  512. * @}
  513. */
  514. /*----------------------------------------------------------------------------ok*/
  515. /**
  516. * @brief Configuration Registers (CFG)
  517. */
  518. typedef struct CFG_struct
  519. {
  520. __IO uint8_t GCR; /*!< Global Configuration register */
  521. }
  522. CFG_TypeDef;
  523. /** @addtogroup CFG_Registers_Reset_Value
  524. * @{
  525. */
  526. #define CFG_GCR_RESET_VALUE ((uint8_t)0x00)
  527. /**
  528. * @}
  529. */
  530. /** @addtogroup CFG_Registers_Bits_Definition
  531. * @{
  532. */
  533. #define CFG_GCR_SWD ((uint8_t)0x01) /*!< Swim disable bit mask */
  534. #define CFG_GCR_AL ((uint8_t)0x02) /*!< Activation Level bit mask */
  535. /**
  536. * @}
  537. */
  538. /*----------------------------------------------------------------------------ok*/
  539. /**
  540. * @brief SYSCFG
  541. */
  542. typedef struct SYSCFG_struct
  543. {
  544. __IO uint8_t RMPCR3; /*!< Remap control register 3 */
  545. __IO uint8_t RMPCR1; /*!< Remap control register 1 */
  546. __IO uint8_t RMPCR2; /*!< Remap control register 2 */
  547. }
  548. SYSCFG_TypeDef;
  549. /** @addtogroup SYSCFG_Registers_Reset_Value
  550. * @{
  551. */
  552. #define SYSCFG_RMPCR1_RESET_VALUE ((uint8_t)0x0C)
  553. #define SYSCFG_RMPCR2_RESET_VALUE ((uint8_t)0x00)
  554. #define SYSCFG_RMPCR3_RESET_VALUE ((uint8_t)0x00)
  555. /**
  556. * @}
  557. */
  558. /** @addtogroup SYSCFG_Registers_Bits_Definition
  559. * @{
  560. */
  561. /* For DMA Channel Mapping*/
  562. #define SYSCFG_RMPCR1_ADC1DMA_REMAP ((uint8_t)0x03) /*!< ADC1 DMA channel remapping */
  563. #define SYSCFG_RMPCR1_TIM4DMA_REMAP ((uint8_t)0x0C) /*!< TIM4 DMA channel remapping */
  564. /* For GPIO Reapping*/
  565. #define SYSCFG_RMPCR1_USART1TR_REMAP ((uint8_t)0x30) /*!< USART1_TX and USART1_RX remapping */
  566. #define SYSCFG_RMPCR1_USART1CK_REMAP ((uint8_t)0x40) /*!< USART1_CK remapping */
  567. #define SYSCFG_RMPCR1_SPI1_REMAP ((uint8_t)0x80) /*!< SPI1 remapping */
  568. #define SYSCFG_RMPCR2_ADC1TRIG_REMAP ((uint8_t)0x01) /*!< ADC1 External Trigger remap */
  569. #define SYSCFG_RMPCR2_TIM2TRIG_REMAP ((uint8_t)0x02) /*!< TIM2 Trigger remap */
  570. #define SYSCFG_RMPCR2_TIM3TRIG_REMAP1 ((uint8_t)0x04) /*!< TIM3 Trigger remap 1 */
  571. #define SYSCFG_RMPCR2_TIM2TRIG_LSE ((uint8_t)0x08) /*!< TIM2 Trigger remap to LSE */
  572. #define SYSCFG_RMPCR2_TIM3TRIG_LSE ((uint8_t)0x10) /*!< TIM3 Trigger remap to LSE */
  573. #define SYSCFG_RMPCR2_SPI2_REMAP ((uint8_t)0x20) /*!< SPI2 remapping */
  574. #define SYSCFG_RMPCR2_TIM3TRIG_REMAP2 ((uint8_t)0x40) /*!< TIM3 Trigger remap 2 */
  575. #define SYSCFG_RMPCR2_TIM23BKIN_REMAP ((uint8_t)0x80) /*!< TIM2 & TIM3 Break input remap */
  576. #define SYSCFG_RMPCR3_SPI1_REMAP ((uint8_t)0x01) /*!< SPI1 remapping */
  577. #define SYSCFG_RMPCR3_USART3TR_REMAP ((uint8_t)0x02) /*!< USART3_TX and USART3_RX remapping */
  578. #define SYSCFG_RMPCR3_USART3CK_REMAP ((uint8_t)0x04) /*!< USART3_CK remapping */
  579. #define SYSCFG_RMPCR3_TIM3CH1_REMAP ((uint8_t)0x08) /*!< TIM3 channel 1 remapping */
  580. #define SYSCFG_RMPCR3_TIM3CH2_REMAP ((uint8_t)0x10) /*!< TIM3 channel 2 remapping */
  581. #define SYSCFG_RMPCR3_CCO_REMAP ((uint8_t)0x20) /*!< CCO remapping */
  582. /**
  583. * @}
  584. */
  585. /*----------------------------------------------------------------------------ok*/
  586. /**
  587. * @brief Clock Controller (CLK)
  588. */
  589. typedef struct CLK_struct
  590. {
  591. __IO uint8_t CKDIVR; /*!< Clock Master Divider Register */
  592. __IO uint8_t CRTCR; /*!< RTC Clock selection Register */
  593. __IO uint8_t ICKCR; /*!< Internal Clocks Control Register */
  594. __IO uint8_t PCKENR1; /*!< Peripheral Clock Gating Register 1 */
  595. __IO uint8_t PCKENR2; /*!< Peripheral Clock Gating Register 2 */
  596. __IO uint8_t CCOR; /*!< Configurable Clock Output Register */
  597. __IO uint8_t ECKCR; /*!< External Clocks Control Register */
  598. __IO uint8_t SCSR; /*!< System clock status Register */
  599. __IO uint8_t SWR; /*!< System clock Switch Register */
  600. __IO uint8_t SWCR; /*!< Switch Control Register */
  601. __IO uint8_t CSSR; /*!< Clock Security Sytem Register */
  602. __IO uint8_t CBEEPR; /*!< Clock BEEP Register */
  603. __IO uint8_t HSICALR; /*!< HSI Calibration Register */
  604. __IO uint8_t HSITRIMR; /*!< HSI clock Calibration Trimmer Register */
  605. __IO uint8_t HSIUNLCKR; /*!< HSI Unlock Register */
  606. __IO uint8_t REGCSR; /*!< Main regulator control status register */
  607. __IO uint8_t PCKENR3; /*!< Peripheral Clock Gating Register 3 */
  608. }
  609. CLK_TypeDef;
  610. /** @addtogroup CLK_Registers_Reset_Value
  611. * @{
  612. */
  613. #define CLK_CKDIVR_RESET_VALUE ((uint8_t)0x03)
  614. #define CLK_CRTCR_RESET_VALUE ((uint8_t)0x00)
  615. #define CLK_ICKCR_RESET_VALUE ((uint8_t)0x11)
  616. #define CLK_PCKENR1_RESET_VALUE ((uint8_t)0x00)
  617. #define CLK_PCKENR2_RESET_VALUE ((uint8_t)0x80)
  618. #define CLK_PCKENR3_RESET_VALUE ((uint8_t)0x00)
  619. #define CLK_CCOR_RESET_VALUE ((uint8_t)0x00)
  620. #define CLK_ECKCR_RESET_VALUE ((uint8_t)0x00)
  621. #define CLK_SCSR_RESET_VALUE ((uint8_t)0x01)
  622. #define CLK_SWR_RESET_VALUE ((uint8_t)0x01)
  623. #define CLK_SWCR_RESET_VALUE ((uint8_t)0x00)
  624. #define CLK_CSSR_RESET_VALUE ((uint8_t)0x00)
  625. #define CLK_CBEEPR_RESET_VALUE ((uint8_t)0x00)
  626. #define CLK_HSICALR_RESET_VALUE ((uint8_t)0x00)
  627. #define CLK_HSITRIMR_RESET_VALUE ((uint8_t)0x00)
  628. #define CLK_HSIUNLCKR_RESET_VALUE ((uint8_t)0x00)
  629. #define CLK_REGCSR_RESET_VALUE ((uint8_t)0xB9)
  630. /**
  631. * @}
  632. */
  633. /** @addtogroup CLK_Registers_Bits_Definition
  634. * @{
  635. */
  636. #define CLK_CKDIVR_CKM ((uint8_t)0x07) /*!< System clock prescaler mask */
  637. #define CLK_CRTCR_RTCDIV ((uint8_t)0xE0) /*!< RTC clock prescaler mask*/
  638. #define CLK_CRTCR_RTCSEL ((uint8_t)0x1E) /*!< RTC clock output selection mask */
  639. #define CLK_CRTCR_RTCSWBSY ((uint8_t)0x01) /*!< RTC clock switch busy */
  640. #define CLK_ICKCR_BEEPAHALT ((uint8_t)0x40) /*!< BEEP clock Active Halt/Halt mode */
  641. #define CLK_ICKCR_FHWU ((uint8_t)0x20) /*!< Fast Wake-up from Active Halt/Halt mode */
  642. #define CLK_ICKCR_SAHALT ((uint8_t)0x10) /*!< Slow Active-halt mode */
  643. #define CLK_ICKCR_LSIRDY ((uint8_t)0x08) /*!< Low speed internal RC oscillator ready */
  644. #define CLK_ICKCR_LSION ((uint8_t)0x04) /*!< Low speed internal RC oscillator enable */
  645. #define CLK_ICKCR_HSIRDY ((uint8_t)0x02) /*!< High speed internal RC oscillator ready */
  646. #define CLK_ICKCR_HSION ((uint8_t)0x01) /*!< High speed internal RC oscillator enable */
  647. #define CLK_PCKENR1_TIM2 ((uint8_t)0x01) /*!< Timer 2 clock enable */
  648. #define CLK_PCKENR1_TIM3 ((uint8_t)0x02) /*!< Timer 3 clock enable */
  649. #define CLK_PCKENR1_TIM4 ((uint8_t)0x04) /*!< Timer 4 clock enable */
  650. #define CLK_PCKENR1_I2C1 ((uint8_t)0x08) /*!< I2C1 clock enable */
  651. #define CLK_PCKENR1_SPI1 ((uint8_t)0x10) /*!< SPI1 clock enable */
  652. #define CLK_PCKENR1_USART1 ((uint8_t)0x20) /*!< USART1 clock enable */
  653. #define CLK_PCKENR1_BEEP ((uint8_t)0x40) /*!< BEEP clock enable */
  654. #define CLK_PCKENR1_DAC ((uint8_t)0x80) /*!< DAC clock enable */
  655. #define CLK_PCKENR2_ADC1 ((uint8_t)0x01) /*!< ADC1 clock enable */
  656. #define CLK_PCKENR2_TIM1 ((uint8_t)0x02) /*!< TIM1 clock enable */
  657. #define CLK_PCKENR2_RTC ((uint8_t)0x04) /*!< RTC clock enable */
  658. #define CLK_PCKENR2_LCD ((uint8_t)0x08) /*!< LCD clock enable */
  659. #define CLK_PCKENR2_DMA1 ((uint8_t)0x10) /*!< DMA1 clock enable */
  660. #define CLK_PCKENR2_COMP ((uint8_t)0x20) /*!< Comparator clock enable */
  661. #define CLK_PCKENR2_BOOTROM ((uint8_t)0x80) /*!< Boot ROM clock enable */
  662. #define CLK_PCKENR3_AES ((uint8_t)0x01) /*!< AES clock enable */
  663. #define CLK_PCKENR3_TIM5 ((uint8_t)0x02) /*!< Timer 5 clock enable */
  664. #define CLK_PCKENR3_SPI2 ((uint8_t)0x04) /*!< SPI2 clock enable */
  665. #define CLK_PCKENR3_UASRT2 ((uint8_t)0x08) /*!< USART2 clock enable */
  666. #define CLK_PCKENR3_USART3 ((uint8_t)0x10) /*!< USART3 clock enable */
  667. #define CLK_CCOR_CCODIV ((uint8_t)0xE0) /*!< Configurable Clock output prescaler */
  668. #define CLK_CCOR_CCOSEL ((uint8_t)0x1E) /*!< Configurable clock output selection */
  669. #define CLK_CCOR_CCOSWBSY ((uint8_t)0x01) /*!< Configurable clock output switch busy flag */
  670. #define CLK_ECKCR_LSEBYP ((uint8_t)0x20) /*!< Low speed external clock bypass */
  671. #define CLK_ECKCR_HSEBYP ((uint8_t)0x10) /*!< High speed external clock bypass */
  672. #define CLK_ECKCR_LSERDY ((uint8_t)0x08) /*!< Low speed external crystal oscillator ready */
  673. #define CLK_ECKCR_LSEON ((uint8_t)0x04) /*!< Low speed external crystal oscillator enable */
  674. #define CLK_ECKCR_HSERDY ((uint8_t)0x02) /*!< High speed external crystal oscillator ready */
  675. #define CLK_ECKCR_HSEON ((uint8_t)0x01) /*!< High speed external crystal oscillator enable */
  676. #define CLK_SCSR_CKM ((uint8_t)0x0F) /*!< System clock status bits */
  677. #define CLK_SWR_SWI ((uint8_t)0x0F) /*!< System clock selection bits */
  678. #define CLK_SWCR_SWIF ((uint8_t)0x08) /*!< Clock switch interrupt flag */
  679. #define CLK_SWCR_SWIEN ((uint8_t)0x04) /*!< Clock switch interrupt enable */
  680. #define CLK_SWCR_SWEN ((uint8_t)0x02) /*!< Switch start/stop */
  681. #define CLK_SWCR_SWBSY ((uint8_t)0x01) /*!< Switch busy */
  682. #define CLK_CSSR_CSSDGON ((uint8_t)0x10) /*!< Clock security sytem deglitcher system */
  683. #define CLK_CSSR_CSSD ((uint8_t)0x08) /*!< Clock security sytem detection */
  684. #define CLK_CSSR_CSSDIE ((uint8_t)0x04) /*!< Clock security system detection interrupt enable */
  685. #define CLK_CSSR_AUX ((uint8_t)0x02) /*!< Auxiliary oscillator connected to master clock */
  686. #define CLK_CSSR_CSSEN ((uint8_t)0x01) /*!< Clock security system enable */
  687. #define CLK_CBEEPR_CLKBEEPSEL ((uint8_t)0x06) /*!< Configurable BEEP clock source selection */
  688. #define CLK_CBEEPR_BEEPSWBSY ((uint8_t)0x01) /*!< BEEP clock busy in switch */
  689. #define CLK_HSICALR_HSICAL ((uint8_t)0xFF) /*!< Copy of otpion byte trimming HSI oscillator */
  690. #define CLK_HSITRIMR_HSITRIM ((uint8_t)0xFF) /*!< High speed internal oscillator trimmer */
  691. #define CLK_HSIUNLCKR_HSIUNLCK ((uint8_t)0xFF) /*!< High speed internal oscillator trimmer unlock */
  692. #define CLK_REGCSR_EEREADY ((uint8_t)0x80) /*!< Flash program memory and Data EEPROM ready */
  693. #define CLK_REGCSR_EEBUSY ((uint8_t)0x40) /*!< Flash program memory and Data EEPROM busy */
  694. #define CLK_REGCSR_LSEPD ((uint8_t)0x20) /*!< LSE power-down */
  695. #define CLK_REGCSR_HSEPD ((uint8_t)0x10) /*!< HSE power-down */
  696. #define CLK_REGCSR_LSIPD ((uint8_t)0x08) /*!< LSI power-down */
  697. #define CLK_REGCSR_HSIPD ((uint8_t)0x04) /*!< HSI power-down */
  698. #define CLK_REGCSR_REGOFF ((uint8_t)0x02) /*!< Main regulator OFF */
  699. #define CLK_REGCSR_REGREADY ((uint8_t)0x01) /*!< Main regulator ready */
  700. /**
  701. * @}
  702. */
  703. /*----------------------------------------------------------------------------ok*/
  704. /**
  705. * @brief Comparator interface (COMP)
  706. */
  707. typedef struct COMP_struct
  708. {
  709. __IO uint8_t CSR1; /*!< Control status register 1 */
  710. __IO uint8_t CSR2; /*!< Control status register 2 */
  711. __IO uint8_t CSR3; /*!< Control status register 3 */
  712. __IO uint8_t CSR4; /*!< Control status register 4 */
  713. __IO uint8_t CSR5; /*!< Control status register 5 */
  714. }
  715. COMP_TypeDef;
  716. /** @addtogroup COMP_Registers_Reset_Value
  717. * @{
  718. */
  719. #define COMP_CSR1_RESET_VALUE ((uint8_t)0x00)
  720. #define COMP_CSR2_RESET_VALUE ((uint8_t)0x00)
  721. #define COMP_CSR3_RESET_VALUE ((uint8_t)0xC0)
  722. #define COMP_CSR4_RESET_VALUE ((uint8_t)0x00)
  723. #define COMP_CSR5_RESET_VALUE ((uint8_t)0x00)
  724. /**
  725. * @}
  726. */
  727. /** @addtogroup COMP_Registers_Bits_Definition
  728. * @{
  729. */
  730. /* CSR1 */
  731. #define COMP_CSR1_IE1 ((uint8_t)0x20) /*!< Comparator 1 Interrupt Enable Mask. */
  732. #define COMP_CSR1_EF1 ((uint8_t)0x10) /*!< Comparator 1 Event Flag Mask. */
  733. #define COMP_CSR1_CMP1OUT ((uint8_t)0x08) /*!< Comparator 1 Ouptput Mask. */
  734. #define COMP_CSR1_STE ((uint8_t)0x04) /*!< Schmitt trigger enable Mask. */
  735. #define COMP_CSR1_CMP1 ((uint8_t)0x03) /*!< Comparator 1 Configuration Mask. */
  736. /* CSR2 */
  737. #define COMP_CSR2_IE2 ((uint8_t)0x20) /*!< Comparator 2 Interrupt Enable Mask. */
  738. #define COMP_CSR2_EF2 ((uint8_t)0x10) /*!< Comparator 2 Event Flag Mask. */
  739. #define COMP_CSR2_CMP2OUT ((uint8_t)0x08) /*!< Comparator 2 Ouptput Mask. */
  740. #define COMP_CSR2_SPEED ((uint8_t)0x04) /*!< Comparator 2 speed modeMask. */
  741. #define COMP_CSR2_CMP2 ((uint8_t)0x03) /*!< Comparator 2 Configuration Mask. */
  742. /* CSR3 */
  743. #define COMP_CSR3_OUTSEL ((uint8_t)0xC0) /*!< Comparator 2 output selection Mask. */
  744. #define COMP_CSR3_INSEL ((uint8_t)0x38) /*!< Inversion input selection Mask. */
  745. #define COMP_CSR3_VREFEN ((uint8_t)0x04) /*!< Internal reference voltage Enable Mask. */
  746. #define COMP_CSR3_WNDWE ((uint8_t)0x02) /*!< Window Mode Enable Mask. */
  747. #define COMP_CSR3_VREFOUTEN ((uint8_t)0x01) /*!< VREF Output Enable Mask. */
  748. /* CSR4 */
  749. #define COMP_CSR4_NINVTRIG ((uint8_t)0x38) /*!< COMP2 non-inverting input Mask. */
  750. #define COMP_CSR4_INVTRIG ((uint8_t)0x07) /*!< COMP2 inverting input Mask. */
  751. /* CSR5 */
  752. #define COMP_CSR5_DACTRIG ((uint8_t)0x38) /*!< DAC outputs Mask. */
  753. #define COMP_CSR5_VREFTRIG ((uint8_t)0x07) /*!< VREF outputs Mask. */
  754. /**
  755. * @}
  756. */
  757. /*----------------------------------------------------------------------------ok*/
  758. /**
  759. * @brief External Interrupt Controller (EXTI)
  760. */
  761. typedef struct EXTI_struct
  762. {
  763. __IO uint8_t CR1; /*!< The four LSB EXTI pin sensitivity */
  764. __IO uint8_t CR2; /*!< The four MSB EXTI pin sensitivity */
  765. __IO uint8_t CR3; /*!< EXTI port B & port D sensitivity */
  766. __IO uint8_t SR1; /*!< Pins Status flag register 1 */
  767. __IO uint8_t SR2; /*!< Ports Status flage register 2 */
  768. __IO uint8_t CONF1; /*!< Port interrupt selector */
  769. uint8_t RESERVED[4]; /*!< reserved area */
  770. __IO uint8_t CR4; /*!< EXTI port G & port H sensitivity */
  771. __IO uint8_t CONF2; /*!< Port interrupt selector */
  772. }
  773. EXTI_TypeDef;
  774. /** @addtogroup EXTI_Registers_Reset_Value
  775. * @{
  776. */
  777. #define EXTI_CR1_RESET_VALUE ((uint8_t)0x00)
  778. #define EXTI_CR2_RESET_VALUE ((uint8_t)0x00)
  779. #define EXTI_CR3_RESET_VALUE ((uint8_t)0x00)
  780. #define EXTI_CONF1_RESET_VALUE ((uint8_t)0x00)
  781. #define EXTI_SR1_RESET_VALUE ((uint8_t)0x00)
  782. #define EXTI_SR2_RESET_VALUE ((uint8_t)0x00)
  783. #define EXTI_CR4_RESET_VALUE ((uint8_t)0x00)
  784. #define EXTI_CONF2_RESET_VALUE ((uint8_t)0x00)
  785. /**
  786. * @}
  787. */
  788. /** @addtogroup EXTI_Registers_Bits_Definition
  789. * @{
  790. */
  791. /* CR1 */
  792. #define EXTI_CR1_P3IS ((uint8_t)0xC0) /*!< EXTI Pin 3 external interrupt sensitivity bit Mask */
  793. #define EXTI_CR1_P2IS ((uint8_t)0x30) /*!< EXTI Pin 2 external interrupt sensitivity bit Mask */
  794. #define EXTI_CR1_P1IS ((uint8_t)0x0C) /*!< EXTI Pin 1 external interrupt sensitivity bit Mask */
  795. #define EXTI_CR1_P0IS ((uint8_t)0x03) /*!< EXTI Pin 0 external interrupt sensitivity bit Mask */
  796. /* CR2 */
  797. #define EXTI_CR2_P7IS ((uint8_t)0xC0) /*!< EXTI Pin 7 external interrupt sensitivity bit Mask */
  798. #define EXTI_CR2_P6IS ((uint8_t)0x30) /*!< EXTI Pin 6 external interrupt sensitivity bit Mask */
  799. #define EXTI_CR2_P5IS ((uint8_t)0x0C) /*!< EXTI Pin 5 external interrupt sensitivity bit Mask */
  800. #define EXTI_CR2_P4IS ((uint8_t)0x03) /*!< EXTI Pin 4 external interrupt sensitivity bit Mask */
  801. /* CR3 */
  802. #define EXTI_CR3_PBIS ((uint8_t)0x03) /*!< EXTI PORTB external interrupt sensitivity bits Mask */
  803. #define EXTI_CR3_PDIS ((uint8_t)0x0C) /*!< EXTI PORTD external interrupt sensitivity bits Mask */
  804. #define EXTI_CR3_PEIS ((uint8_t)0x30) /*!< EXTI PORTE external interrupt sensitivity bits Mask */
  805. #define EXTI_CR3_PFIS ((uint8_t)0xC0) /*!< EXTI PORTF external interrupt sensitivity bits Mask */
  806. /* CONF1 */
  807. #define EXTI_CONF1_PBLIS ((uint8_t)0x01) /*!< EXTI PORTB low interrupt selector bit Mask */
  808. #define EXTI_CONF1_PBHIS ((uint8_t)0x02) /*!< EXTI PORTB high interrupt selector bit Mask */
  809. #define EXTI_CONF1_PDLIS ((uint8_t)0x04) /*!< EXTI PORTD low interrupt selector bit Mask */
  810. #define EXTI_CONF1_PDHIS ((uint8_t)0x08) /*!< EXTI PORTD high interrupt selector bit Mask */
  811. #define EXTI_CONF1_PELIS ((uint8_t)0x10) /*!< EXTI PORTE low interrupt selector bit Mask */
  812. #define EXTI_CONF1_PEHIS ((uint8_t)0x20) /*!< EXTI PORTE high interrupt selector bit Mask */
  813. #define EXTI_CONF1_PFLIS ((uint8_t)0x40) /*!< EXTI PORTF low interrupt selector bit Mask */
  814. #define EXTI_CONF1_PFES ((uint8_t)0x80) /*!< EXTI PORTF or PORTE interrupt selector bit Mask */
  815. /* CR4 */
  816. #define EXTI_CR4_PGIS ((uint8_t)0x03) /*!< EXTI PORTG external interrupt sensitivity bits Mask */
  817. #define EXTI_CR4_PHIS ((uint8_t)0x0C) /*!< EXTI PORTH external interrupt sensitivity bits Mask */
  818. /* CONF2 */
  819. #define EXTI_CONF2_PFHIS ((uint8_t)0x01) /*!< EXTI PORTF high interrupt selector bit Mask */
  820. #define EXTI_CONF2_PGLIS ((uint8_t)0x02) /*!< EXTI PORTG low interrupt selector bit Mask */
  821. #define EXTI_CONF2_PGHIS ((uint8_t)0x04) /*!< EXTI PORTG high interrupt selector bit Mask */
  822. #define EXTI_CONF2_PHLIS ((uint8_t)0x08) /*!< EXTI PORTH low interrupt selector bit Mask */
  823. #define EXTI_CONF2_PHHIS ((uint8_t)0x10) /*!< EXTI PORTH high interrupt selector bit Mask */
  824. #define EXTI_CONF2_PGBS ((uint8_t)0x20) /*!< EXTI PORTB or PORTG interrupt selector bit Mask */
  825. #define EXTI_CONF2_PHDS ((uint8_t)0x40) /*!< EXTI PORTD or PORTH interrupt selector bit Mask */
  826. /**
  827. * @}
  828. */
  829. /*----------------------------------------------------------------------------ok*/
  830. /**
  831. * @brief FLASH and Data EEPROM
  832. */
  833. typedef struct FLASH_struct
  834. {
  835. __IO uint8_t CR1; /*!< Flash control register 1 */
  836. __IO uint8_t CR2; /*!< Flash control register 2 */
  837. __IO uint8_t PUKR; /*!< Flash program memory unprotection register */
  838. __IO uint8_t DUKR; /*!< Data EEPROM unprotection register */
  839. __IO uint8_t IAPSR; /*!< Flash in-application programming status register */
  840. }
  841. FLASH_TypeDef;
  842. /** @addtogroup FLASH_Registers_Reset_Value
  843. * @{
  844. */
  845. #define FLASH_CR1_RESET_VALUE ((uint8_t)0x00)
  846. #define FLASH_CR2_RESET_VALUE ((uint8_t)0x00)
  847. #define FLASH_PUKR_RESET_VALUE ((uint8_t)0xAE)
  848. #define FLASH_DUKR_RESET_VALUE ((uint8_t)0x56)
  849. #define FLASH_IAPSR_RESET_VALUE ((uint8_t)0x40)
  850. /**
  851. * @}
  852. */
  853. /** @addtogroup FLASH_Registers_Bits_Definition
  854. * @{
  855. */
  856. #define FLASH_CR1_EEPM ((uint8_t)0x08) /*!< Flash low power selection during Run and Low power run mode Mask */
  857. #define FLASH_CR1_WAITM ((uint8_t)0x04) /*!< Flash low power selection during Wait and Low power wait mode Mask */
  858. #define FLASH_CR1_IE ((uint8_t)0x02) /*!< Flash Interrupt enable Mask */
  859. #define FLASH_CR1_FIX ((uint8_t)0x01) /*!< Fix programming time Mask */
  860. #define FLASH_CR2_OPT ((uint8_t)0x80) /*!< Enable write access to option bytes*/
  861. #define FLASH_CR2_WPRG ((uint8_t)0x40) /*!< Word write once Mask */
  862. #define FLASH_CR2_ERASE ((uint8_t)0x20) /*!< Erase block Mask */
  863. #define FLASH_CR2_FPRG ((uint8_t)0x10) /*!< Fast programming mode Mask */
  864. #define FLASH_CR2_PRG ((uint8_t)0x01) /*!< Program block Mask */
  865. #define FLASH_IAPSR_HVOFF ((uint8_t)0x40) /*!< End of high voltage flag Mask */
  866. #define FLASH_IAPSR_DUL ((uint8_t)0x08) /*!< Data EEPROM unlocked flag Mask */
  867. #define FLASH_IAPSR_EOP ((uint8_t)0x04) /*!< End of operation flag Mask */
  868. #define FLASH_IAPSR_PUL ((uint8_t)0x02) /*!< Program memory unlocked flag Mask */
  869. #define FLASH_IAPSR_WR_PG_DIS ((uint8_t)0x01) /*!< Write attempted to protected page Mask */
  870. #define FLASH_PUKR_PUK ((uint8_t)0xFF) /*!< Flash Program memory unprotection mask */
  871. #define FLASH_DUKR_DUK ((uint8_t)0xFF) /*!< Data EEPROM unprotection mask */
  872. /**
  873. * @}
  874. */
  875. /*----------------------------------------------------------------------------*/
  876. /**
  877. * @brief Inter-Integrated Circuit (I2C)
  878. */
  879. typedef struct I2C_struct
  880. {
  881. __IO uint8_t CR1; /*!< I2C control register 1 */
  882. __IO uint8_t CR2; /*!< I2C control register 2 */
  883. __IO uint8_t FREQR; /*!< I2C frequency register */
  884. __IO uint8_t OARL; /*!< I2C own address register 1 LSB */
  885. __IO uint8_t OARH; /*!< I2C own address register 1 MSB */
  886. __IO uint8_t OAR2; /*!< I2C own address register 2 */
  887. __IO uint8_t DR; /*!< I2C data register */
  888. __IO uint8_t SR1; /*!< I2C status register 1 */
  889. __IO uint8_t SR2; /*!< I2C status register 2 */
  890. __IO uint8_t SR3; /*!< I2C status register 3 */
  891. __IO uint8_t ITR; /*!< I2C interrupt & DMA register */
  892. __IO uint8_t CCRL; /*!< I2C clock control register low */
  893. __IO uint8_t CCRH; /*!< I2C clock control register high */
  894. __IO uint8_t TRISER; /*!< I2C maximum rise time register */
  895. __IO uint8_t PECR; /*!< I2CPacket Error Checking register */
  896. }
  897. I2C_TypeDef;
  898. /** @addtogroup I2C_Registers_Reset_Value
  899. * @{
  900. */
  901. #define I2C_CR1_RESET_VALUE ((uint8_t)0x00)
  902. #define I2C_CR2_RESET_VALUE ((uint8_t)0x00)
  903. #define I2C_FREQR_RESET_VALUE ((uint8_t)0x00)
  904. #define I2C_OARL_RESET_VALUE ((uint8_t)0x00)
  905. #define I2C_OARH_RESET_VALUE ((uint8_t)0x00)
  906. #define I2C_OAR2_RESET_VALUE ((uint8_t)0x00)
  907. #define I2C_DR_RESET_VALUE ((uint8_t)0x00)
  908. #define I2C_SR1_RESET_VALUE ((uint8_t)0x00)
  909. #define I2C_SR2_RESET_VALUE ((uint8_t)0x00)
  910. #define I2C_SR3_RESET_VALUE ((uint8_t)0x00)
  911. #define I2C_ITR_RESET_VALUE ((uint8_t)0x00)
  912. #define I2C_CCRL_RESET_VALUE ((uint8_t)0x00)
  913. #define I2C_CCRH_RESET_VALUE ((uint8_t)0x00)
  914. #define I2C_TRISER_RESET_VALUE ((uint8_t)0x02)
  915. #define I2C_PECR_RESET_VALUE ((uint8_t)0x00)
  916. /**
  917. * @}
  918. */
  919. /** @addtogroup I2C_Registers_Bits_Definition
  920. * @{
  921. */
  922. #define I2C_CR1_NOSTRETCH ((uint8_t)0x80) /*!< Clock Stretching Disable (Slave mode) */
  923. #define I2C_CR1_ENGC ((uint8_t)0x40) /*!< General Call Enable */
  924. #define I2C_CR1_ENPEC ((uint8_t)0x20) /*!< PEC Enable */
  925. #define I2C_CR1_ARP ((uint8_t)0x10) /*!< ARP Enable */
  926. #define I2C_CR1_SMBTYPE ((uint8_t)0x08) /*!< SMBus type */
  927. #define I2C_CR1_SMBUS ((uint8_t)0x02) /*!< SMBus mode */
  928. #define I2C_CR1_PE ((uint8_t)0x01) /*!< Peripheral Enable */
  929. #define I2C_CR2_SWRST ((uint8_t)0x80) /*!< Software Reset */
  930. #define I2C_CR2_ALERT ((uint8_t)0x20) /*!< SMBus Alert*/
  931. #define I2C_CR2_PEC ((uint8_t)0x10) /*!< Packet Error Checking */
  932. #define I2C_CR2_POS ((uint8_t)0x08) /*!< Acknowledge */
  933. #define I2C_CR2_ACK ((uint8_t)0x04) /*!< Acknowledge Enable */
  934. #define I2C_CR2_STOP ((uint8_t)0x02) /*!< Stop Generation */
  935. #define I2C_CR2_START ((uint8_t)0x01) /*!< Start Generation */
  936. #define I2C_FREQR_FREQ ((uint8_t)0x3F) /*!< Peripheral Clock Frequency */
  937. #define I2C_OARL_ADD ((uint8_t)0xFE) /*!< Interface Address bits [7..1] */
  938. #define I2C_OARL_ADD0 ((uint8_t)0x01) /*!< Interface Address bit0 */
  939. #define I2C_OARH_ADDMODE ((uint8_t)0x80) /*!< Addressing Mode (Slave mode) */
  940. #define I2C_OARH_ADDCONF ((uint8_t)0x40) /*!< Address mode configuration */
  941. #define I2C_OARH_ADD ((uint8_t)0x06) /*!< Interface Address bits [9..8] */
  942. #define I2C_OAR2_ADD2 ((uint8_t)0xFE) /*!< Interface Address bits [7..1] */
  943. #define I2C_OAR2_ENDUAL ((uint8_t)0x01) /*!< Dual addressing mode enable */
  944. #define I2C_DR_DR ((uint8_t)0xFF) /*!< Data Register */
  945. #define I2C_SR1_TXE ((uint8_t)0x80) /*!< Data Register Empty (transmitters) */
  946. #define I2C_SR1_RXNE ((uint8_t)0x40) /*!< Data Register not Empty (receivers) */
  947. #define I2C_SR1_STOPF ((uint8_t)0x10) /*!< Stop detection (Slave mode) */
  948. #define I2C_SR1_ADD10 ((uint8_t)0x08) /*!< 10-bit header sent (Master mode) */
  949. #define I2C_SR1_BTF ((uint8_t)0x04) /*!< Byte Transfer Finished */
  950. #define I2C_SR1_ADDR ((uint8_t)0x02) /*!< Address sent (master mode)/matched (slave mode) */
  951. #define I2C_SR1_SB ((uint8_t)0x01) /*!< Start Bit (Master mode) */
  952. #define I2C_SR2_SMBALERT ((uint8_t)0x80) /*!< SMBus Alert */
  953. #define I2C_SR2_TIMEOUT ((uint8_t)0x40) /*!< Time out or TLow error */
  954. #define I2C_SR2_WUFH ((uint8_t)0x20) /*!< Wake-up from Halt */
  955. #define I2C_SR2_PECERR ((uint8_t)0x10) /*!< PEC error in reception */
  956. #define I2C_SR2_OVR ((uint8_t)0x08) /*!< Overrun/Underrun */
  957. #define I2C_SR2_AF ((uint8_t)0x04) /*!< Acknowledge Failure */
  958. #define I2C_SR2_ARLO ((uint8_t)0x02) /*!< Arbitration Lost (master mode) */
  959. #define I2C_SR2_BERR ((uint8_t)0x01) /*!< Bus Error */
  960. #define I2C_SR3_DUALF ((uint8_t)0x80) /*!< Dual flag (Slave mode) */
  961. #define I2C_SR3_SMBHOST ((uint8_t)0x40) /*!< SMBus Host Header (Slave mode) */
  962. #define I2C_SR3_SMBDEFAULT ((uint8_t)0x20) /*!< SMBus Default Header (Slave mode) */
  963. #define I2C_SR3_GENCALL ((uint8_t)0x10) /*!< General Call Header (Slave mode) */
  964. #define I2C_SR3_TRA ((uint8_t)0x04) /*!< Transmitter/Receiver */
  965. #define I2C_SR3_BUSY ((uint8_t)0x02) /*!< Bus Busy */
  966. #define I2C_SR3_MSL ((uint8_t)0x01) /*!< Master/Slave */
  967. #define I2C_ITR_LAST ((uint8_t)0x10) /*!< DMA Last transfer */
  968. #define I2C_ITR_DMAEN ((uint8_t)0x08) /*!< DMA request Enable */
  969. #define I2C_ITR_ITBUFEN ((uint8_t)0x04) /*!< Buffer Interrupt Enable */
  970. #define I2C_ITR_ITEVTEN ((uint8_t)0x02) /*!< Event Interrupt Enable */
  971. #define I2C_ITR_ITERREN ((uint8_t)0x01) /*!< Error Interrupt Enable */
  972. #define I2C_CCRL_CCR ((uint8_t)0xFF) /*!< Clock Control Register (Master mode) */
  973. #define I2C_CCRH_FS ((uint8_t)0x80) /*!< Master Mode Selection */
  974. #define I2C_CCRH_DUTY ((uint8_t)0x40) /*!< Fast Mode Duty Cycle */
  975. #define I2C_CCRH_CCR ((uint8_t)0x0F) /*!< Clock Control Register in Fast/Standard mode (Master mode) bits [11..8] */
  976. #define I2C_TRISER_TRISE ((uint8_t)0x3F) /*!< Maximum Rise Time in Fast/Standard mode (Master mode) */
  977. #define I2C_PECR_PEC ((uint8_t)0xFF) /*!< Packet error checking */
  978. /**
  979. * @}
  980. */
  981. /*----------------------------------------------------------------------------*/
  982. /**
  983. * @brief IR digital interface (IRTIM)
  984. */
  985. typedef struct IRTIM_struct
  986. {
  987. __IO uint8_t CR; /*!< control register */
  988. }
  989. IRTIM_TypeDef;
  990. /** @addtogroup IRTIM_Registers_Reset_Value
  991. * @{
  992. */
  993. #define IRTIM_CR_RESET_VALUE ((uint8_t)0x00)
  994. /**
  995. * @}
  996. */
  997. /** @addtogroup IRTIM_Registers_Bits_Definition
  998. * @{
  999. */
  1000. /* CR*/
  1001. #define IRTIM_CR_EN ((uint8_t)0x01) /*!< IRTIM_OUT enable Mask. */
  1002. #define IRTIM_CR_HSEN ((uint8_t)0x02) /*!< High sink open drain buffer enable Mask */
  1003. /**
  1004. * @}
  1005. */
  1006. /*----------------------------------------------------------------------------*/
  1007. /**
  1008. * @brief Interrupt Controller (ITC)
  1009. */
  1010. typedef struct ITC_struct
  1011. {
  1012. __IO uint8_t ISPR1; /*!< Interrupt Software Priority register 1 */
  1013. __IO uint8_t ISPR2; /*!< Interrupt Software Priority register 2 */
  1014. __IO uint8_t ISPR3; /*!< Interrupt Software Priority register 3 */
  1015. __IO uint8_t ISPR4; /*!< Interrupt Software Priority register 4 */
  1016. __IO uint8_t ISPR5; /*!< Interrupt Software Priority register 5 */
  1017. __IO uint8_t ISPR6; /*!< Interrupt Software Priority register 6 */
  1018. __IO uint8_t ISPR7; /*!< Interrupt Software Priority register 7 */
  1019. __IO uint8_t ISPR8; /*!< Interrupt Software Priority register 8 */
  1020. }
  1021. ITC_TypeDef;
  1022. /** @addtogroup ITC_Registers_Reset_Value
  1023. * @{
  1024. */
  1025. #define ITC_SPRX_RESET_VALUE ((uint8_t)0xFF) /*!< Reset value of Software Priority registers 0 to 7 */
  1026. /**
  1027. * @}
  1028. */
  1029. /*----------------------------------------------------------------------------*/
  1030. /**
  1031. * @brief Internal Low Speed Watchdog (IWDG)
  1032. */
  1033. typedef struct IWDG_struct
  1034. {
  1035. __IO uint8_t KR; /*!< Low Speed Watchdog Key Register */
  1036. __IO uint8_t PR; /*!< Low Speed Watchdog Prescaler Register */
  1037. __IO uint8_t RLR; /*!< Low Speed Watchdog Reload Register */
  1038. }
  1039. IWDG_TypeDef;
  1040. /** @addtogroup IWDG_Registers_Reset_Value
  1041. * @{
  1042. */
  1043. #define IWDG_RLR_RESET_VALUE ((uint8_t)0xFF) /*! <Reload Register Default Value */
  1044. #define IWDG_PR_RESET_VALUE ((uint8_t)0x00) /*! <Prescaler Register Default Value */
  1045. /**
  1046. * @}
  1047. */
  1048. /*----------------------------------------------------------------------------*/
  1049. /**
  1050. * @brief Wait For Event (WFE) peripheral registers.
  1051. */
  1052. /** @addtogroup WFE_Registers
  1053. * @{
  1054. */
  1055. typedef struct WFE_struct
  1056. {
  1057. __IO uint8_t CR1; /*!< Wait for event control register 1 */
  1058. __IO uint8_t CR2; /*!< Wait for event control register 2 */
  1059. __IO uint8_t CR3; /*!< Wait for event control register 3 */
  1060. __IO uint8_t CR4; /*!< Wait for event control register 4 */
  1061. }
  1062. WFE_TypeDef;
  1063. /**
  1064. * @}
  1065. */
  1066. /** @addtogroup WFE_Registers_Reset_Value
  1067. * @{
  1068. */
  1069. #define WFE_CRX_RESET_VALUE ((uint8_t)0x00) /*!< Reset value wait for event control register */
  1070. /**
  1071. * @}
  1072. */
  1073. /** @addtogroup WFE_Registers_Bits_Definition
  1074. * @{
  1075. */
  1076. #define WFE_CR1_EXTI_EV3 ((uint8_t)0x80) /*!< External interrupt event 3 Mask */
  1077. #define WFE_CR1_EXTI_EV2 ((uint8_t)0x40) /*!< External interrupt event 2 Mask */
  1078. #define WFE_CR1_EXTI_EV1 ((uint8_t)0x20) /*!< External interrupt event 1 Mask */
  1079. #define WFE_CR1_EXTI_EV0 ((uint8_t)0x10) /*!< External interrupt event 0 Mask */
  1080. #define WFE_CR1_TIM1_EV1 ((uint8_t)0x08) /*!< TIM1 event 1 Mask */
  1081. #define WFE_CR1_TIM1_EV0 ((uint8_t)0x04) /*!< TIM1 event 0 Mask */
  1082. #define WFE_CR1_TIM2_EV1 ((uint8_t)0x02) /*!< TIM2 event 1 Mask */
  1083. #define WFE_CR1_TIM2_EV0 ((uint8_t)0x01) /*!< TIM2 event 0 Mask */
  1084. #define WFE_CR2_ADC1_COMP_EV ((uint8_t)0x80) /*!< ADC / COMP event Mask*/
  1085. #define WFE_CR2_EXTI_EVEF ((uint8_t)0x40) /*!< External interrupt event on Port E or Port F Mask */
  1086. #define WFE_CR2_EXTI_EVDH ((uint8_t)0x20) /*!< External interrupt event on Port D or Port H Mask */
  1087. #define WFE_CR2_EXTI_EVBG ((uint8_t)0x10) /*!< External interrupt event on Port B or Port G Mask */
  1088. #define WFE_CR2_EXTI_EV7 ((uint8_t)0x08) /*!< External interrupt event 7 Mask */
  1089. #define WFE_CR2_EXTI_EV6 ((uint8_t)0x04) /*!< External interrupt event 6 Mask */
  1090. #define WFE_CR2_EXTI_EV5 ((uint8_t)0x02) /*!< External interrupt event 5 Mask */
  1091. #define WFE_CR2_EXTI_EV4 ((uint8_t)0x01) /*!< External interrupt event 4 Mask */
  1092. #define WFE_CR3_DMA1CH23_EV ((uint8_t)0x80) /*!< DMA1 channel 2 and 3 interrupt event Mask */
  1093. #define WFE_CR3_DMA1CH01_EV ((uint8_t)0x40) /*!< DMA1 channel 0 and 1 interrupt event Mask */
  1094. #define WFE_CR3_USART1_EV ((uint8_t)0x20) /*!< USART1 Rx and Tx interrupt event Mask */
  1095. #define WFE_CR3_I2C1_EV ((uint8_t)0x10) /*!< I2C1 Rx and Tx interrupt event Mask */
  1096. #define WFE_CR3_SPI1_EV ((uint8_t)0x08) /*!< SPI1 Rx and Tx interrupt event Mask */
  1097. #define WFE_CR3_TIM4_EV ((uint8_t)0x04) /*!< TIM4 event Mask */
  1098. #define WFE_CR3_TIM3_EV1 ((uint8_t)0x02) /*!< TIM3 event 1 Mask */
  1099. #define WFE_CR3_TIM3_EV0 ((uint8_t)0x01) /*!< TIM3 event 0 Mask */
  1100. #define WFE_CR4_AES_EV ((uint8_t)0x40) /*!< AES event Mask */
  1101. #define WFE_CR4_TIM5_EV1 ((uint8_t)0x20) /*!< TIM5 event 1 Mask */
  1102. #define WFE_CR4_TIM5_EV0 ((uint8_t)0x10) /*!< TIM5 event 0 Mask */
  1103. #define WFE_CR4_USART3_EV ((uint8_t)0x08) /*!< USART3 Rx and Tx interrupt event Mask */
  1104. #define WFE_CR4_USART2_EV ((uint8_t)0x04) /*!< USART2 Rx and Tx interrupt event Mask */
  1105. #define WFE_CR4_SPI2_EV ((uint8_t)0x02) /*!< SPI2 Rx and Tx interrupt event Mask */
  1106. #define WFE_CR4_RTC_CSS_EV ((uint8_t)0x01) /*!< RTC or CSS on LSE interrupt event Mask */
  1107. /**
  1108. * @}
  1109. */
  1110. /*----------------------------------------------------------------------------*/
  1111. /**
  1112. * @brief Option Bytes (OPT)
  1113. */
  1114. typedef struct OPT_struct
  1115. {
  1116. __IO uint8_t ROP; /*!< Read-out protection*/
  1117. uint8_t RESERVED1;
  1118. __IO uint8_t UBC; /*!< User Boot code size*/
  1119. uint8_t RESERVED2;
  1120. uint8_t RESERVED3;
  1121. uint8_t RESERVED4;
  1122. uint8_t RESERVED5;
  1123. __IO uint8_t PCODESIZE;
  1124. __IO uint8_t WDG; /*!< Independent and Window watchdog option */
  1125. __IO uint8_t XTSTARTUP; /*!< HSE and LSE option */
  1126. __IO uint8_t BOR; /*!< Brownout option */
  1127. }
  1128. OPT_TypeDef;
  1129. /**
  1130. * @}
  1131. */
  1132. /*----------------------------------------------------------------------------*/
  1133. /**
  1134. * @brief Reset Controller (RST)
  1135. */
  1136. typedef struct RST_struct
  1137. {
  1138. __IO uint8_t CR; /*!< Multiplex Reset Pad */
  1139. __IO uint8_t SR; /*!< Reset status register */
  1140. }
  1141. RST_TypeDef;
  1142. /**
  1143. * @}
  1144. */
  1145. /** @addtogroup RST_Registers_Reset_Value
  1146. * @{
  1147. */
  1148. #define RST_CR_RESET_VALUE ((uint8_t)0x00) /*!< Reset pin configuration register 1 reset value */
  1149. #define RST_SR_RESET_VALUE ((uint8_t)0x01) /*!< Reset status register 2 reset value */
  1150. /**
  1151. * @}
  1152. */
  1153. /** @addtogroup RST_Registers_Bits_Definition
  1154. * @{
  1155. */
  1156. #define RST_SR_BORF ((uint8_t)0x20) /*!< Brownout reset flag mask */
  1157. #define RST_SR_WWDGF ((uint8_t)0x10) /*!< Window Watchdog reset flag mask */
  1158. #define RST_SR_SWIMF ((uint8_t)0x08) /*!< SWIM reset flag mask */
  1159. #define RST_SR_ILLOPF ((uint8_t)0x04) /*!< Illegal opcode reset flag mask */
  1160. #define RST_SR_IWDGF ((uint8_t)0x02) /*!< Independent Watchdog reset flag mask */
  1161. #define RST_SR_PORF ((uint8_t)0x01) /*!< Power On Reset (POR) flag mask */
  1162. /**
  1163. * @}
  1164. */
  1165. /*----------------------------------------------------------------------------*/
  1166. /**
  1167. * @brief Power Control (PWR)
  1168. */
  1169. typedef struct PWR_struct
  1170. {
  1171. __IO uint8_t CSR1; /*!< PWR control status register 1 */
  1172. __IO uint8_t CSR2; /*!< PWR control status register 2 */
  1173. }
  1174. PWR_TypeDef;
  1175. /**
  1176. * @}
  1177. */
  1178. /** @addtogroup PWR_Registers_Reset_Value
  1179. * @{
  1180. */
  1181. #define PWR_CSR1_RESET_VALUE ((uint8_t)0x00) /*!< Control Status Register 1 reset value */
  1182. #define PWR_CSR2_RESET_VALUE ((uint8_t)0x00) /*!< Control Status Register 2 reset value */
  1183. /**
  1184. * @}
  1185. */
  1186. /** @addtogroup PWR_Registers_Bits_Definition
  1187. * @{
  1188. */
  1189. #define PWR_CSR1_PVDOF ((uint8_t)0x40) /*!< PVD output flag mask */
  1190. #define PWR_CSR1_PVDIF ((uint8_t)0x20) /*!< PVD interrupt flag mask */
  1191. #define PWR_CSR1_PVDIEN ((uint8_t)0x10) /*!< PVD interrupt enable mask */
  1192. #define PWR_CSR1_PLS ((uint8_t)0x0E) /*!< PVD Level thresholds selector mask */
  1193. #define PWR_CSR1_PVDE ((uint8_t)0x01) /*!< Power Voltage Detector (PVD) enable mask */
  1194. #define PWR_CSR2_FWU ((uint8_t)0x04) /*!< Fast wake up configuration mask */
  1195. #define PWR_CSR2_ULP ((uint8_t)0x02) /*!< Ultra Low power configuration mask */
  1196. #define PWR_CR2_VREFINTF ((uint8_t)0x01) /*!< Internal reference voltage status flag mask */
  1197. /**
  1198. * @}
  1199. */
  1200. /*----------------------------------------------------------------------------*/
  1201. /**
  1202. * @brief Routing Interface (RI)
  1203. */
  1204. typedef struct RI_struct
  1205. {
  1206. uint8_t RESERVED;
  1207. __IO uint8_t ICR1; /*!< Timer input capture routing register 1 */
  1208. __IO uint8_t ICR2; /*!< Timer input capture routing register 2 */
  1209. __IO uint8_t IOIR1; /*!< I/O input register 1 */
  1210. __IO uint8_t IOIR2; /*!< I/O input register 2 */
  1211. __IO uint8_t IOIR3; /*!< I/O input register 3 */
  1212. __IO uint8_t IOCMR1; /*!< I/O control mode register 1 */
  1213. __IO uint8_t IOCMR2; /*!< I/O control mode register 2 */
  1214. __IO uint8_t IOCMR3; /*!< I/O control mode register 3 */
  1215. __IO uint8_t IOSR1; /*!< I/O switch register 1*/
  1216. __IO uint8_t IOSR2; /*!< I/O switch register 2*/
  1217. __IO uint8_t IOSR3; /*!< I/O switch register 3*/
  1218. __IO uint8_t IOGCR; /*!< I/O group control register */
  1219. __IO uint8_t ASCR1; /*!< Analog Switch Control register 1 */
  1220. __IO uint8_t ASCR2; /*!< Analog Switch Control register 2 */
  1221. __IO uint8_t RCR; /*!< Resistor control register */
  1222. uint8_t RESERVED1[16];
  1223. __IO uint8_t CR; /*!< Control Register */
  1224. __IO uint8_t IOMR1; /*!< IO Mask Register 1 */
  1225. __IO uint8_t IOMR2; /*!< IO Mask Register 2 */
  1226. __IO uint8_t IOMR3; /*!< IO Mask Register 3 */
  1227. __IO uint8_t IOMR4; /*!< IO Mask Register 4*/
  1228. __IO uint8_t IOIR4; /*!< I/O input register 4 */
  1229. __IO uint8_t IOCMR4; /*!< I/O control mode register 4 */
  1230. __IO uint8_t IOSR4; /*!< I/O switch register 4 */
  1231. }RI_TypeDef;
  1232. /**
  1233. * @}
  1234. */
  1235. /** @addtogroup RI_Registers_Reset_Value
  1236. * @{
  1237. */
  1238. #define RI_ICR1_RESET_VALUE ((uint8_t)0x00) /*!< Timer input capture routing register 1 reset value */
  1239. #define RI_ICR2_RESET_VALUE ((uint8_t)0x00) /*!< Timer input capture routing register 2 reset value */
  1240. #define RI_IOCMR1_RESET_VALUE ((uint8_t)0x00) /*!< I/O control mode register 1 reset value */
  1241. #define RI_IOCMR2_RESET_VALUE ((uint8_t)0x00) /*!< I/O control mode register 2 reset value */
  1242. #define RI_IOCMR3_RESET_VALUE ((uint8_t)0x00) /*!< I/O control mode register 3 reset value */
  1243. #define RI_IOSR1_RESET_VALUE ((uint8_t)0x00) /*!< I/O switch register 1 reset value */
  1244. #define RI_IOSR2_RESET_VALUE ((uint8_t)0x00) /*!< I/O switch register 2 reset value */
  1245. #define RI_IOSR3_RESET_VALUE ((uint8_t)0x00) /*!< I/O switch register 3 reset value */
  1246. #define RI_IOGCR_RESET_VALUE ((uint8_t)0xFF) /*!< IO group control register reset value */
  1247. #define RI_ASCR1_RESET_VALUE ((uint8_t)0x00) /*!< Analog switch register 1 reset value */
  1248. #define RI_ASCR2_RESET_VALUE ((uint8_t)0x00) /*!< Analog switch register 2 reset value */
  1249. #define RI_RCR_RESET_VALUE ((uint8_t)0x00) /*!< Resistor control register reset value */
  1250. #define RI_IOCMR4_RESET_VALUE ((uint8_t)0x00) /*!< I/O control mode register 4 reset value */
  1251. #define RI_IOSR4_RESET_VALUE ((uint8_t)0x00) /*!< I/O switch register 4 reset value */
  1252. /**
  1253. * @}
  1254. */
  1255. /** @addtogroup RI_Registers_Bits_Definition
  1256. * @{
  1257. */
  1258. #define RI_ICR1_IC2CS ((uint8_t)0x1F) /*!< TIM1 Input Capture 2 I/O selection mask */
  1259. #define RI_ICR2_IC3CS ((uint8_t)0x1F) /*!< TIM1 Input Capture 3 I/O selection mask */
  1260. #define RI_IOIR1_CH1I ((uint8_t)0x01) /*!< Channel 1 I/O pin input value */
  1261. #define RI_IOIR1_CH4I ((uint8_t)0x02) /*!< Channel 4 I/O pin input value */
  1262. #define RI_IOIR1_CH7I ((uint8_t)0x04) /*!< Channel 7 I/O pin input value */
  1263. #define RI_IOIR1_CH10I ((uint8_t)0x08) /*!< Channel 10 I/O pin input value */
  1264. #define RI_IOIR1_CH13I ((uint8_t)0x10) /*!< Channel 13 I/O pin input value */
  1265. #define RI_IOIR1_CH16I ((uint8_t)0x20) /*!< Channel 16 I/O pin input value */
  1266. #define RI_IOIR1_CH19I ((uint8_t)0x40) /*!< Channel 19 I/O pin input value */
  1267. #define RI_IOIR1_CH22I ((uint8_t)0x80) /*!< Channel 22 I/O pin input value */
  1268. #define RI_IOIR2_CH2I ((uint8_t)0x01) /*!< Channel 2 I/O pin input value */
  1269. #define RI_IOIR2_CH5I ((uint8_t)0x02) /*!< Channel 5 I/O pin input value */
  1270. #define RI_IOIR2_CH8I ((uint8_t)0x04) /*!< Channel 8 I/O pin input value */
  1271. #define RI_IOIR2_CH11I ((uint8_t)0x08) /*!< Channel 11 I/O pin input value */
  1272. #define RI_IOIR2_CH14I ((uint8_t)0x10) /*!< Channel 14 I/O pin input value */
  1273. #define RI_IOIR2_CH17I ((uint8_t)0x20) /*!< Channel 17 I/O pin input value */
  1274. #define RI_IOIR2_CH20I ((uint8_t)0x40) /*!< Channel 20 I/O pin input value */
  1275. #define RI_IOIR2_CH23I ((uint8_t)0x80) /*!< Channel 23 I/O pin input value */
  1276. #define RI_IOIR3_CH3I ((uint8_t)0x01) /*!< Channel 3 I/O pin input value */
  1277. #define RI_IOIR3_CH6I ((uint8_t)0x02) /*!< Channel 6 I/O pin input value */
  1278. #define RI_IOIR3_CH9I ((uint8_t)0x04) /*!< Channel 9 I/O pin input value */
  1279. #define RI_IOIR3_CH12I ((uint8_t)0x08) /*!< Channel 12 I/O pin input value */
  1280. #define RI_IOIR3_CH15I ((uint8_t)0x10) /*!< Channel 15 I/O pin input value */
  1281. #define RI_IOIR3_CH18I ((uint8_t)0x20) /*!< Channel 18 I/O pin input value */
  1282. #define RI_IOIR3_CH21I ((uint8_t)0x40) /*!< Channel 21 I/O pin input value */
  1283. #define RI_IOIR3_CH24I ((uint8_t)0x80) /*!< Channel 24 I/O pin input value */
  1284. #define RI_IOCMR1_CH1M ((uint8_t)0x01) /*!< Channel 1 I/O control mode */
  1285. #define RI_IOCMR1_CH4M ((uint8_t)0x02) /*!< Channel 4 I/O control mode */
  1286. #define RI_IOCMR1_CH7M ((uint8_t)0x04) /*!< Channel 7 I/O control mode */
  1287. #define RI_IOCMR1_CH10M ((uint8_t)0x08) /*!< Channel 10 I/O control mode */
  1288. #define RI_IOCMR1_CH13M ((uint8_t)0x10) /*!< Channel 13 I/O control mode */
  1289. #define RI_IOCMR1_CH16M ((uint8_t)0x20) /*!< Channel 16 I/O control mode */
  1290. #define RI_IOCMR1_CH19M ((uint8_t)0x40) /*!< Channel 19 I/O control mode */
  1291. #define RI_IOCMR1_CH22M ((uint8_t)0x80) /*!< Channel 22 I/O control mode */
  1292. #define RI_IOCMR2_CH2M ((uint8_t)0x01) /*!< Channel 2 I/O control mode */
  1293. #define RI_IOCMR2_CH5M ((uint8_t)0x02) /*!< Channel 5 I/O control mode */
  1294. #define RI_IOCMR2_CH8M ((uint8_t)0x04) /*!< Channel 8 I/O control mode */
  1295. #define RI_IOCMR2_CH11M ((uint8_t)0x08) /*!< Channel 11 I/O control mode */
  1296. #define RI_IOCMR2_CH14M ((uint8_t)0x10) /*!< Channel 14 I/O control mode */
  1297. #define RI_IOCMR2_CH17M ((uint8_t)0x20) /*!< Channel 17 I/O control mode */
  1298. #define RI_IOCMR2_CH20M ((uint8_t)0x40) /*!< Channel 20 I/O control mode */
  1299. #define RI_IOCMR2_CH23M ((uint8_t)0x80) /*!< Channel 23 I/O control mode */
  1300. #define RI_IOCMR3_CH3M ((uint8_t)0x01) /*!< Channel 3 I/O control mode */
  1301. #define RI_IOCMR3_CH6M ((uint8_t)0x02) /*!< Channel 6 I/O control mode */
  1302. #define RI_IOCMR3_CH9M ((uint8_t)0x04) /*!< Channel 9 I/O control mode */
  1303. #define RI_IOCMR3_CH12M ((uint8_t)0x08) /*!< Channel 12 I/O control mode */
  1304. #define RI_IOCMR3_CH15M ((uint8_t)0x10) /*!< Channel 15 I/O control mode */
  1305. #define RI_IOCMR3_CH18M ((uint8_t)0x20) /*!< Channel 18 I/O control mode */
  1306. #define RI_IOCMR3_CH21M ((uint8_t)0x40) /*!< Channel 21 I/O control mode */
  1307. #define RI_IOCMR3_CH24M ((uint8_t)0x80) /*!< Channel 24 I/O control mode */
  1308. #define RI_IOSR1_CH1E ((uint8_t)0x01) /*!< Channel 1 I/O switch control */
  1309. #define RI_IOSR1_CH4E ((uint8_t)0x02) /*!< Channel 4 I/O switch control */
  1310. #define RI_IOSR1_CH7E ((uint8_t)0x04) /*!< Channel 7 I/O switch control */
  1311. #define RI_IOSR1_CH10E ((uint8_t)0x08) /*!< Channel 10 I/O switch control */
  1312. #define RI_IOSR1_CH13E ((uint8_t)0x10) /*!< Channel 13 I/O switch control */
  1313. #define RI_IOSR1_CH16E ((uint8_t)0x20) /*!< Channel 16 I/O switch control */
  1314. #define RI_IOSR1_CH19E ((uint8_t)0x40) /*!< Channel 19 I/O switch control */
  1315. #define RI_IOSR1_CH22E ((uint8_t)0x80) /*!< Channel 22 I/O switch control */
  1316. #define RI_IOSR2_CH2E ((uint8_t)0x01) /*!< Channel 2 I/O switch control */
  1317. #define RI_IOSR2_CH5E ((uint8_t)0x02) /*!< Channel 5 I/O switch control */
  1318. #define RI_IOSR2_CH8E ((uint8_t)0x04) /*!< Channel 8 I/O switch control */
  1319. #define RI_IOSR2_CH11E ((uint8_t)0x08) /*!< Channel 11 I/O switch control */
  1320. #define RI_IOSR2_CH14E ((uint8_t)0x10) /*!< Channel 14 I/O switch control */
  1321. #define RI_IOSR2_CH17E ((uint8_t)0x20) /*!< Channel 17 I/O switch control */
  1322. #define RI_IOSR2_CH20E ((uint8_t)0x40) /*!< Channel 20 I/O switch control */
  1323. #define RI_IOSR2_CH23E ((uint8_t)0x80) /*!< Channel 23 I/O switch control */
  1324. #define RI_IOSR3_CH3E ((uint8_t)0x01) /*!< Channel 3 I/O switch control */
  1325. #define RI_IOSR3_CH6E ((uint8_t)0x02) /*!< Channel 6 I/O switch control */
  1326. #define RI_IOSR3_CH9E ((uint8_t)0x04) /*!< Channel 9 I/O switch control */
  1327. #define RI_IOSR3_CH12E ((uint8_t)0x08) /*!< Channel 12 I/O switch control */
  1328. #define RI_IOSR3_CH15E ((uint8_t)0x10) /*!< Channel 15 I/O switch control */
  1329. #define RI_IOSR3_CH18E ((uint8_t)0x20) /*!< Channel 18 I/O switch control */
  1330. #define RI_IOSR3_CH21E ((uint8_t)0x40) /*!< Channel 21 I/O switch control */
  1331. #define RI_IOSR3_CH24E ((uint8_t)0x80) /*!< Channel 24 I/O switch control */
  1332. #define RI_IOGCR_IOM1 ((uint8_t)0x03) /*!< I/O mode 1 */
  1333. #define RI_IOGCR_IOM2 ((uint8_t)0x0C) /*!< I/O mode 2 */
  1334. #define RI_IOGCR_IOM3 ((uint8_t)0x30) /*!< I/O mode 3 */
  1335. #define RI_IOGCR_IOM4 ((uint8_t)0xC0) /*!< I/O mode 4 */
  1336. #define RI_ASCR1_AS0 ((uint8_t)0x01) /*!< Analog switch AS0 control */
  1337. #define RI_ASCR1_AS1 ((uint8_t)0x02) /*!< Analog switch AS1 control */
  1338. #define RI_ASCR1_AS2 ((uint8_t)0x04) /*!< Analog switch AS2 control */
  1339. #define RI_ASCR1_AS3 ((uint8_t)0x08) /*!< Analog switch AS3 control */
  1340. #define RI_ASCR1_AS4 ((uint8_t)0x10) /*!< Analog switch AS4 control */
  1341. #define RI_ASCR1_AS5 ((uint8_t)0x20) /*!< Analog switch AS5 control */
  1342. #define RI_ASCR1_AS6 ((uint8_t)0x40) /*!< Analog switch AS6 control */
  1343. #define RI_ASCR1_AS7 ((uint8_t)0x80) /*!< Analog switch AS7 control */
  1344. #define RI_ASCR2_AS8 ((uint8_t)0x01) /*!< Analog switch AS8 control */
  1345. #define RI_ASCR2_AS9 ((uint8_t)0x02) /*!< Analog switch AS9 control */
  1346. #define RI_ASCR2_AS10 ((uint8_t)0x04) /*!< Analog switch AS10 control */
  1347. #define RI_ASCR2_AS11 ((uint8_t)0x08) /*!< Analog switch AS11 control */
  1348. #define RI_ASCR2_AS14 ((uint8_t)0x40) /*!< Analog switch AS14 control */
  1349. #define RI_RCR_400KPD ((uint8_t)0x08) /*!< 400K pull-down resistor Mask. */
  1350. #define RI_RCR_10KPD ((uint8_t)0x04) /*!< 10K pull-down resistor Mask. */
  1351. #define RI_RCR_400KPU ((uint8_t)0x02) /*!< 400K pull-up resistor Mask. */
  1352. #define RI_RCR_10KPU ((uint8_t)0x01) /*!< 10K pull-up resistor Mask. */
  1353. #define RI_IOSR4_CH29E ((uint8_t)0x01) /*!< Channel 29 I/O switch control */
  1354. #define RI_IOSR4_CH26E ((uint8_t)0x02) /*!< Channel 26 I/O switch control */
  1355. #define RI_IOSR4_CH27E ((uint8_t)0x40) /*!< Channel 27 I/O switch control */
  1356. #define RI_IOSR4_CH28E ((uint8_t)0x80) /*!< Channel 28 I/O switch control */
  1357. /**
  1358. * @}
  1359. */
  1360. /*----------------------------------------------------------------------------ok*/
  1361. /**
  1362. * @brief Serial Peripheral Interface (SPI)
  1363. */
  1364. typedef struct SPI_struct
  1365. {
  1366. __IO uint8_t CR1; /*!< SPI control register 1 */
  1367. __IO uint8_t CR2; /*!< SPI control register 2 */
  1368. __IO uint8_t CR3; /*!< SPI DMA and interrupt control register */
  1369. __IO uint8_t SR; /*!< SPI status register */
  1370. __IO uint8_t DR; /*!< SPI data I/O register */
  1371. __IO uint8_t CRCPR; /*!< SPI CRC polynomial register */
  1372. __IO uint8_t RXCRCR; /*!< SPI Rx CRC register */
  1373. __IO uint8_t TXCRCR; /*!< SPI Tx CRC register */
  1374. }
  1375. SPI_TypeDef;
  1376. /** @addtogroup SPI_Registers_Reset_Value
  1377. * @{
  1378. */
  1379. #define SPI_CR1_RESET_VALUE ((uint8_t)0x00) /*!< Control Register 1 reset value */
  1380. #define SPI_CR2_RESET_VALUE ((uint8_t)0x00) /*!< Control Register 2 reset value */
  1381. #define SPI_CR3_RESET_VALUE ((uint8_t)0x00) /*!< DMA and Interrupt Control Register reset value */
  1382. #define SPI_SR_RESET_VALUE ((uint8_t)0x02) /*!< Status Register reset value */
  1383. #define SPI_DR_RESET_VALUE ((uint8_t)0x00) /*!< Data Register reset value */
  1384. #define SPI_CRCPR_RESET_VALUE ((uint8_t)0x07) /*!< Polynomial Register reset value */
  1385. #define SPI_RXCRCR_RESET_VALUE ((uint8_t)0x00) /*!< RX CRC Register reset value */
  1386. #define SPI_TXCRCR_RESET_VALUE ((uint8_t)0x00) /*!< TX CRC Register reset value */
  1387. /**
  1388. * @}
  1389. */
  1390. /** @addtogroup SPI_Registers_Bits_Definition
  1391. * @{
  1392. */
  1393. #define SPI_CR1_LSBFIRST ((uint8_t)0x80) /*!< Frame format mask */
  1394. #define SPI_CR1_SPE ((uint8_t)0x40) /*!< Enable bits mask */
  1395. #define SPI_CR1_BR ((uint8_t)0x38) /*!< Baud rate control mask */
  1396. #define SPI_CR1_MSTR ((uint8_t)0x04) /*!< Master Selection mask */
  1397. #define SPI_CR1_CPOL ((uint8_t)0x02) /*!< Clock Polarity mask */
  1398. #define SPI_CR1_CPHA ((uint8_t)0x01) /*!< Clock Phase mask */
  1399. #define SPI_CR2_BDM ((uint8_t)0x80) /*!< Bi-directional data mode enable mask */
  1400. #define SPI_CR2_BDOE ((uint8_t)0x40) /*!< Output enable in bi-directional mode mask */
  1401. #define SPI_CR2_CRCEN ((uint8_t)0x20) /*!< Hardware CRC calculation enable mask */
  1402. #define SPI_CR2_CRCNEXT ((uint8_t)0x10) /*!< Transmit CRC next mask */
  1403. #define SPI_CR2_RXONLY ((uint8_t)0x04) /*!< Receive only mask */
  1404. #define SPI_CR2_SSM ((uint8_t)0x02) /*!< Software slave management mask */
  1405. #define SPI_CR2_SSI ((uint8_t)0x01) /*!< Internal slave select mask */
  1406. #define SPI_CR3_TXIE ((uint8_t)0x80) /*!< Tx buffer empty interrupt enable mask */
  1407. #define SPI_CR3_RXIE ((uint8_t)0x40) /*!< Rx buffer empty interrupt enable mask */
  1408. #define SPI_CR3_ERRIE ((uint8_t)0x20) /*!< Error interrupt enable mask */
  1409. #define SPI_CR3_WKIE ((uint8_t)0x10) /*!< Wake-up interrupt enable mask */
  1410. #define SPI_CR3_TXDMAEN ((uint8_t)0x02) /*!< Tx Buffer DMA enable mask */
  1411. #define SPI_CR3_RXDMAEN ((uint8_t)0x01) /*!< Rx Buffer DMA enable mask */
  1412. #define SPI_SR_BSY ((uint8_t)0x80) /*!< Busy flag */
  1413. #define SPI_SR_OVR ((uint8_t)0x40) /*!< Overrun flag */
  1414. #define SPI_SR_MODF ((uint8_t)0x20) /*!< Mode fault */
  1415. #define SPI_SR_CRCERR ((uint8_t)0x10) /*!< CRC error flag */
  1416. #define SPI_SR_WKUP ((uint8_t)0x08) /*!< Wake-Up flag */
  1417. #define SPI_SR_TXE ((uint8_t)0x02) /*!< Transmit buffer empty */
  1418. #define SPI_SR_RXNE ((uint8_t)0x01) /*!< Receive buffer not empty */
  1419. /**
  1420. * @}
  1421. */
  1422. /*----------------------------------------------------------------------------ok*/
  1423. /**
  1424. * @brief Advanced 16 bit timer with complementary PWM outputs (TIM1)
  1425. */
  1426. typedef struct TIM1_struct
  1427. {
  1428. __IO uint8_t CR1; /*!< control register 1 */
  1429. __IO uint8_t CR2; /*!< control register 2 */
  1430. __IO uint8_t SMCR; /*!< Synchro mode control register */
  1431. __IO uint8_t ETR; /*!< external trigger register */
  1432. __IO uint8_t DER; /*!< DMA requests enable register */
  1433. __IO uint8_t IER; /*!< interrupt enable register*/
  1434. __IO uint8_t SR1; /*!< status register 1 */
  1435. __IO uint8_t SR2; /*!< status register 2 */
  1436. __IO uint8_t EGR; /*!< event generation register */
  1437. __IO uint8_t CCMR1; /*!< CC mode register 1 */
  1438. __IO uint8_t CCMR2; /*!< CC mode register 2 */
  1439. __IO uint8_t CCMR3; /*!< CC mode register 3 */
  1440. __IO uint8_t CCMR4; /*!< CC mode register 4 */
  1441. __IO uint8_t CCER1; /*!< CC enable register 1 */
  1442. __IO uint8_t CCER2; /*!< CC enable register 2 */
  1443. __IO uint8_t CNTRH; /*!< counter high */
  1444. __IO uint8_t CNTRL; /*!< counter low */
  1445. __IO uint8_t PSCRH; /*!< prescaler high */
  1446. __IO uint8_t PSCRL; /*!< prescaler low */
  1447. __IO uint8_t ARRH; /*!< auto-reload register high */
  1448. __IO uint8_t ARRL; /*!< auto-reload register low */
  1449. __IO uint8_t RCR; /*!< Repetition Counter register */
  1450. __IO uint8_t CCR1H; /*!< capture/compare register 1 high */
  1451. __IO uint8_t CCR1L; /*!< capture/compare register 1 low */
  1452. __IO uint8_t CCR2H; /*!< capture/compare register 2 high */
  1453. __IO uint8_t CCR2L; /*!< capture/compare register 2 low */
  1454. __IO uint8_t CCR3H; /*!< capture/compare register 3 high */
  1455. __IO uint8_t CCR3L; /*!< capture/compare register 3 low */
  1456. __IO uint8_t CCR4H; /*!< capture/compare register 3 high */
  1457. __IO uint8_t CCR4L; /*!< capture/compare register 3 low */
  1458. __IO uint8_t BKR; /*!< Break Register */
  1459. __IO uint8_t DTR; /*!< dead-time register */
  1460. __IO uint8_t OISR; /*!< Output idle register */
  1461. __IO uint8_t DCR1; /*!< DMA control register 1 */
  1462. __IO uint8_t DCR2; /*!< DMA control register 2 */
  1463. __IO uint8_t DMAR; /*!< DMA Address for brust mode */
  1464. }
  1465. TIM1_TypeDef;
  1466. /** @addtogroup TIM1_Registers_Reset_Value
  1467. * @{
  1468. */
  1469. #define TIM1_CR1_RESET_VALUE ((uint8_t)0x00)
  1470. #define TIM1_CR2_RESET_VALUE ((uint8_t)0x00)
  1471. #define TIM1_SMCR_RESET_VALUE ((uint8_t)0x00)
  1472. #define TIM1_ETR_RESET_VALUE ((uint8_t)0x00)
  1473. #define TIM1_DER_RESET_VALUE ((uint8_t)0x00)
  1474. #define TIM1_IER_RESET_VALUE ((uint8_t)0x00)
  1475. #define TIM1_SR1_RESET_VALUE ((uint8_t)0x00)
  1476. #define TIM1_SR2_RESET_VALUE ((uint8_t)0x00)
  1477. #define TIM1_EGR_RESET_VALUE ((uint8_t)0x00)
  1478. #define TIM1_CCMR1_RESET_VALUE ((uint8_t)0x00)
  1479. #define TIM1_CCMR2_RESET_VALUE ((uint8_t)0x00)
  1480. #define TIM1_CCMR3_RESET_VALUE ((uint8_t)0x00)
  1481. #define TIM1_CCMR4_RESET_VALUE ((uint8_t)0x00)
  1482. #define TIM1_CCER1_RESET_VALUE ((uint8_t)0x00)
  1483. #define TIM1_CCER2_RESET_VALUE ((uint8_t)0x00)
  1484. #define TIM1_CNTRH_RESET_VALUE ((uint8_t)0x00)
  1485. #define TIM1_CNTRL_RESET_VALUE ((uint8_t)0x00)
  1486. #define TIM1_PSCRH_RESET_VALUE ((uint8_t)0x00)
  1487. #define TIM1_PSCRL_RESET_VALUE ((uint8_t)0x00)
  1488. #define TIM1_ARRH_RESET_VALUE ((uint8_t)0xFF)
  1489. #define TIM1_ARRL_RESET_VALUE ((uint8_t)0xFF)
  1490. #define TIM1_RCR_RESET_VALUE ((uint8_t)0x00)
  1491. #define TIM1_CCR1H_RESET_VALUE ((uint8_t)0x00)
  1492. #define TIM1_CCR1L_RESET_VALUE ((uint8_t)0x00)
  1493. #define TIM1_CCR2H_RESET_VALUE ((uint8_t)0x00)
  1494. #define TIM1_CCR2L_RESET_VALUE ((uint8_t)0x00)
  1495. #define TIM1_CCR3H_RESET_VALUE ((uint8_t)0x00)
  1496. #define TIM1_CCR3L_RESET_VALUE ((uint8_t)0x00)
  1497. #define TIM1_CCR4H_RESET_VALUE ((uint8_t)0x00)
  1498. #define TIM1_CCR4L_RESET_VALUE ((uint8_t)0x00)
  1499. #define TIM1_BKR_RESET_VALUE ((uint8_t)0x00)
  1500. #define TIM1_DTR_RESET_VALUE ((uint8_t)0x00)
  1501. #define TIM1_OISR_RESET_VALUE ((uint8_t)0x00)
  1502. #define TIM1_DCR1_RESET_VALUE ((uint8_t)0x00)
  1503. #define TIM1_DCR2_RESET_VALUE ((uint8_t)0x00)
  1504. #define TIM1_DMAR_RESET_VALUE ((uint8_t)0x00)
  1505. /**
  1506. * @}
  1507. */
  1508. /** @addtogroup TIM1_Registers_Bits_Definition
  1509. * @{
  1510. */
  1511. /* CR1*/
  1512. #define TIM1_CR1_ARPE ((uint8_t)0x80) /*!< Auto-Reload Preload Enable mask. */
  1513. #define TIM1_CR1_CMS ((uint8_t)0x60) /*!< Center-aligned Mode Selection mask. */
  1514. #define TIM1_CR1_DIR ((uint8_t)0x10) /*!< Direction mask. */
  1515. #define TIM1_CR1_OPM ((uint8_t)0x08) /*!< One Pulse Mode mask. */
  1516. #define TIM1_CR1_URS ((uint8_t)0x04) /*!< Update Request Source mask. */
  1517. #define TIM1_CR1_UDIS ((uint8_t)0x02) /*!< Update DIsable mask. */
  1518. #define TIM1_CR1_CEN ((uint8_t)0x01) /*!< Counter Enable mask. */
  1519. /* CR2*/
  1520. #define TIM1_CR2_TI1S ((uint8_t)0x80) /*!< TI1 selection */
  1521. #define TIM1_CR2_MMS ((uint8_t)0x70) /*!< MMS Selection mask. */
  1522. #define TIM1_CR2_CCDS ((uint8_t)0x08) /*!< Capture/Compare DMA Selection */
  1523. #define TIM1_CR2_CCUS ((uint8_t)0x04) /*!< Capture/Compare Control Update Selection mask. */
  1524. #define TIM1_CR2_CCPC ((uint8_t)0x01) /*!< Capture/Compare Preloaded Control mask. */
  1525. /* SMCR*/
  1526. #define TIM1_SMCR_MSM ((uint8_t)0x80) /*!< Master/Slave Mode mask. */
  1527. #define TIM1_SMCR_TS ((uint8_t)0x70) /*!< Trigger Selection mask. */
  1528. #define TIM1_SMCR_OCCS ((uint8_t)0x08) /*!< OCREFCLR Selection mask. */
  1529. #define TIM1_SMCR_SMS ((uint8_t)0x07) /*!< Slave Mode Selection mask. */
  1530. /* ETR*/
  1531. #define TIM1_ETR_ETP ((uint8_t)0x80) /*!< External Trigger Polarity mask. */
  1532. #define TIM1_ETR_ECE ((uint8_t)0x40) /*!< External Clock mask. */
  1533. #define TIM1_ETR_ETPS ((uint8_t)0x30) /*!< External Trigger Prescaler mask. */
  1534. #define TIM1_ETR_ETF ((uint8_t)0x0F) /*!< External Trigger Filter mask. */
  1535. /* DER*/
  1536. #define TIM1_DER_COMDE ((uint8_t)0x20) /*!< Commutation DMA request Enable mask.*/
  1537. #define TIM1_DER_CC4DE ((uint8_t)0x10) /*!< Capture/Compare 4 DMA request Enable mask.*/
  1538. #define TIM1_DER_CC3DE ((uint8_t)0x08) /*!< Capture/Compare 3 DMA request Enable mask.*/
  1539. #define TIM1_DER_CC2DE ((uint8_t)0x04) /*!< Capture/Compare 2 DMA request Enable mask.*/
  1540. #define TIM1_DER_CC1DE ((uint8_t)0x02) /*!< Capture/Compare 1 DMA request Enable mask.*/
  1541. #define TIM1_DER_UDE ((uint8_t)0x01) /*!< Update DMA request Enable mask. */
  1542. /* IER*/
  1543. #define TIM1_IER_BIE ((uint8_t)0x80) /*!< Break Interrupt Enable mask. */
  1544. #define TIM1_IER_TIE ((uint8_t)0x40) /*!< Trigger Interrupt Enable mask. */
  1545. #define TIM1_IER_COMIE ((uint8_t)0x20) /*!< Commutation Interrupt Enable mask.*/
  1546. #define TIM1_IER_CC4IE ((uint8_t)0x10) /*!< Capture/Compare 4 Interrupt Enable mask. */
  1547. #define TIM1_IER_CC3IE ((uint8_t)0x08) /*!< Capture/Compare 3 Interrupt Enable mask. */
  1548. #define TIM1_IER_CC2IE ((uint8_t)0x04) /*!< Capture/Compare 2 Interrupt Enable mask. */
  1549. #define TIM1_IER_CC1IE ((uint8_t)0x02) /*!< Capture/Compare 1 Interrupt Enable mask. */
  1550. #define TIM1_IER_UIE ((uint8_t)0x01) /*!< Update Interrupt Enable mask. */
  1551. /* SR1*/
  1552. #define TIM1_SR1_BIF ((uint8_t)0x80) /*!< Break Interrupt Flag mask. */
  1553. #define TIM1_SR1_TIF ((uint8_t)0x40) /*!< Trigger Interrupt Flag mask. */
  1554. #define TIM1_SR1_COMIF ((uint8_t)0x20) /*!< Commutation Interrupt Flag mask. */
  1555. #define TIM1_SR1_CC4IF ((uint8_t)0x10) /*!< Capture/Compare 4 Interrupt Flag mask. */
  1556. #define TIM1_SR1_CC3IF ((uint8_t)0x08) /*!< Capture/Compare 3 Interrupt Flag mask. */
  1557. #define TIM1_SR1_CC2IF ((uint8_t)0x04) /*!< Capture/Compare 2 Interrupt Flag mask. */
  1558. #define TIM1_SR1_CC1IF ((uint8_t)0x02) /*!< Capture/Compare 1 Interrupt Flag mask. */
  1559. #define TIM1_SR1_UIF ((uint8_t)0x01) /*!< Update Interrupt Flag mask. */
  1560. /* SR2*/
  1561. #define TIM1_SR2_CC4OF ((uint8_t)0x10) /*!< Capture/Compare 4 Overcapture Flag mask. */
  1562. #define TIM1_SR2_CC3OF ((uint8_t)0x08) /*!< Capture/Compare 3 Overcapture Flag mask. */
  1563. #define TIM1_SR2_CC2OF ((uint8_t)0x04) /*!< Capture/Compare 2 Overcapture Flag mask. */
  1564. #define TIM1_SR2_CC1OF ((uint8_t)0x02) /*!< Capture/Compare 1 Overcapture Flag mask. */
  1565. /*EGR*/
  1566. #define TIM1_EGR_BG ((uint8_t)0x80) /*!< Break Generation mask. */
  1567. #define TIM1_EGR_TG ((uint8_t)0x40) /*!< Trigger Generation mask. */
  1568. #define TIM1_EGR_COMG ((uint8_t)0x20) /*!< Capture/Compare Control Update Generation mask. */
  1569. #define TIM1_EGR_CC4G ((uint8_t)0x10) /*!< Capture/Compare 4 Generation mask. */
  1570. #define TIM1_EGR_CC3G ((uint8_t)0x08) /*!< Capture/Compare 3 Generation mask. */
  1571. #define TIM1_EGR_CC2G ((uint8_t)0x04) /*!< Capture/Compare 2 Generation mask. */
  1572. #define TIM1_EGR_CC1G ((uint8_t)0x02) /*!< Capture/Compare 1 Generation mask. */
  1573. #define TIM1_EGR_UG ((uint8_t)0x01) /*!< Update Generation mask. */
  1574. /*CCMR*/
  1575. #define TIM1_CCMR_ICxPSC ((uint8_t)0x0C) /*!< Input Capture x Prescaler mask. */
  1576. #define TIM1_CCMR_ICxF ((uint8_t)0xF0) /*!< Input Capture x Filter mask. */
  1577. #define TIM1_CCMR_OCM ((uint8_t)0x70) /*!< Output Compare x Mode mask. */
  1578. #define TIM1_CCMR_OCxPE ((uint8_t)0x08) /*!< Output Compare x Preload Enable mask. */
  1579. #define TIM1_CCMR_OCxFE ((uint8_t)0x04) /*!< Output Compare x Fast Enable mask. */
  1580. #define TIM1_CCMR_CCxS ((uint8_t)0x03) /*!< Capture/Compare x Selection mask. */
  1581. #define TIM1_CCMR_OCxCE ((uint8_t)0x80) /*!< Output Compare x Clear Enable mask. */
  1582. #define CCMR_TIxDirect_Set ((uint8_t)0x01)
  1583. /*CCER1*/
  1584. #define TIM1_CCER1_CC2NP ((uint8_t)0x80) /*!< Capture/Compare 2 Complementary output Polarity mask. */
  1585. #define TIM1_CCER1_CC2NE ((uint8_t)0x40) /*!< Capture/Compare 2 Complementary output enable mask. */
  1586. #define TIM1_CCER1_CC2P ((uint8_t)0x20) /*!< Capture/Compare 2 output Polarity mask. */
  1587. #define TIM1_CCER1_CC2E ((uint8_t)0x10) /*!< Capture/Compare 2 output enable mask. */
  1588. #define TIM1_CCER1_CC1NP ((uint8_t)0x08) /*!< Capture/Compare 1 Complementary output Polarity mask. */
  1589. #define TIM1_CCER1_CC1NE ((uint8_t)0x04) /*!< Capture/Compare 1 Complementary output enable mask. */
  1590. #define TIM1_CCER1_CC1P ((uint8_t)0x02) /*!< Capture/Compare 1 output Polarity mask. */
  1591. #define TIM1_CCER1_CC1E ((uint8_t)0x01) /*!< Capture/Compare 1 output enable mask. */
  1592. /*CCER2*/
  1593. #define TIM1_CCER2_CC4P ((uint8_t)0x20) /*!< Capture/Compare 4 Polarity mask. */
  1594. #define TIM1_CCER2_CC4E ((uint8_t)0x10) /*!< Capture/Compare 4 Enable mask. */
  1595. #define TIM1_CCER2_CC3NP ((uint8_t)0x08) /*!< Capture/Compare 3 Complementary output Polarity mask. */
  1596. #define TIM1_CCER2_CC3NE ((uint8_t)0x04) /*!< Capture/Compare 3 Complementary output enable mask. */
  1597. #define TIM1_CCER2_CC3P ((uint8_t)0x02) /*!< Capture/Compare 3 output Polarity mask. */
  1598. #define TIM1_CCER2_CC3E ((uint8_t)0x01) /*!< Capture/Compare 3 output enable mask. */
  1599. /*CNTR*/
  1600. #define TIM1_CNTRH_CNT ((uint8_t)0xFF) /*!< Counter Value (MSB) mask. */
  1601. #define TIM1_CNTRL_CNT ((uint8_t)0xFF) /*!< Counter Value (LSB) mask. */
  1602. /*PSCR*/
  1603. #define TIM1_PSCH_PSC ((uint8_t)0xFF) /*!< Prescaler Value (MSB) mask. */
  1604. #define TIM1_PSCL_PSC ((uint8_t)0xFF) /*!< Prescaler Value (LSB) mask. */
  1605. /*ARR*/
  1606. #define TIM1_ARRH_ARR ((uint8_t)0xFF) /*!< Autoreload Value (MSB) mask. */
  1607. #define TIM1_ARRL_ARR ((uint8_t)0xFF) /*!< Autoreload Value (LSB) mask. */
  1608. /*RCR*/
  1609. #define TIM1_RCR_REP ((uint8_t)0xFF) /*!< Repetition Counter Value mask. */
  1610. /*CCR1*/
  1611. #define TIM1_CCR1H_CCR1 ((uint8_t)0xFF) /*!< Capture/Compare 1 Value (MSB) mask. */
  1612. #define TIM1_CCR1L_CCR1 ((uint8_t)0xFF) /*!< Capture/Compare 1 Value (LSB) mask. */
  1613. /*CCR2*/
  1614. #define TIM1_CCR2H_CCR2 ((uint8_t)0xFF) /*!< Capture/Compare 2 Value (MSB) mask. */
  1615. #define TIM1_CCR2L_CCR2 ((uint8_t)0xFF) /*!< Capture/Compare 2 Value (LSB) mask. */
  1616. /*CCR3*/
  1617. #define TIM1_CCR3H_CCR3 ((uint8_t)0xFF) /*!< Capture/Compare 3 Value (MSB) mask. */
  1618. #define TIM1_CCR3L_CCR3 ((uint8_t)0xFF) /*!< Capture/Compare 3 Value (LSB) mask. */
  1619. /*CCR4*/
  1620. #define TIM1_CCR4H_CCR4 ((uint8_t)0xFF) /*!< Capture/Compare 4 Value (MSB) mask. */
  1621. #define TIM1_CCR4L_CCR4 ((uint8_t)0xFF) /*!< Capture/Compare 4 Value (LSB) mask. */
  1622. /*BKR*/
  1623. #define TIM1_BKR_MOE ((uint8_t)0x80) /*!< Main Output Enable mask. */
  1624. #define TIM1_BKR_AOE ((uint8_t)0x40) /*!< Automatic Output Enable mask. */
  1625. #define TIM1_BKR_BKP ((uint8_t)0x20) /*!< Break Polarity mask. */
  1626. #define TIM1_BKR_BKE ((uint8_t)0x10) /*!< Break Enable mask. */
  1627. #define TIM1_BKR_OSSR ((uint8_t)0x08) /*!< Off-State Selection for Run mode mask. */
  1628. #define TIM1_BKR_OSSI ((uint8_t)0x04) /*!< Off-State Selection for Idle mode mask. */
  1629. #define TIM1_BKR_LOCK ((uint8_t)0x03) /*!< Lock Configuration mask. */
  1630. /*DTR*/
  1631. #define TIM1_DTR_DTG ((uint8_t)0xFF) /*!< Dead-Time Generator set-up mask. */
  1632. /*OISR*/
  1633. #define TIM1_OISR_OIS3N ((uint8_t)0x20) /*!< Output Idle state 3 (OC3N output) mask. */
  1634. #define TIM1_OISR_OIS3 ((uint8_t)0x10) /*!< Output Idle state 3 (OC3 output) mask. */
  1635. #define TIM1_OISR_OIS2N ((uint8_t)0x08) /*!< Output Idle state 2 (OC2N output) mask. */
  1636. #define TIM1_OISR_OIS2 ((uint8_t)0x04) /*!< Output Idle state 2 (OC2 output) mask. */
  1637. #define TIM1_OISR_OIS1N ((uint8_t)0x02) /*!< Output Idle state 1 (OC1N output) mask. */
  1638. #define TIM1_OISR_OIS1 ((uint8_t)0x01) /*!< Output Idle state 1 (OC1 output) mask. */
  1639. /*DCR1*/
  1640. #define TIM1_DCR1_DBA ((uint8_t)0x1F) /*!< DMA Base Address mask. */
  1641. /*DCR2*/
  1642. #define TIM1_DCR2_DBL ((uint8_t)0x1F) /*!< DMA Burst Length mask. */
  1643. /*DMAR*/
  1644. #define TIM1_DMAR_VR ((uint8_t)0xFF) /*!< Virtual register mask. */
  1645. /**
  1646. * @}
  1647. */
  1648. /*----------------------------------------------------------------------------*/
  1649. /**
  1650. * @brief 16 bit timer :TIM2, TIM3 & TIM5
  1651. */
  1652. typedef struct TIM_struct
  1653. {
  1654. __IO uint8_t CR1; /*!< control register 1 */
  1655. __IO uint8_t CR2; /*!< control register 2 */
  1656. __IO uint8_t SMCR; /*!< Synchro mode control register */
  1657. __IO uint8_t ETR; /*!< external trigger register */
  1658. __IO uint8_t DER; /*!< DMA requests enable register */
  1659. __IO uint8_t IER; /*!< interrupt enable register*/
  1660. __IO uint8_t SR1; /*!< status register 1 */
  1661. __IO uint8_t SR2; /*!< status register 2 */
  1662. __IO uint8_t EGR; /*!< event generation register */
  1663. __IO uint8_t CCMR1; /*!< CC mode register 1 */
  1664. __IO uint8_t CCMR2; /*!< CC mode register 2 */
  1665. __IO uint8_t CCER1; /*!< CC enable register 1 */
  1666. __IO uint8_t CNTRH; /*!< counterregister high */
  1667. __IO uint8_t CNTRL; /*!< counterregister low */
  1668. __IO uint8_t PSCR; /*!< prescaler register */
  1669. __IO uint8_t ARRH; /*!< auto-reload register high */
  1670. __IO uint8_t ARRL; /*!< auto-reload register low */
  1671. __IO uint8_t CCR1H; /*!< capture/compare register 1 high */
  1672. __IO uint8_t CCR1L; /*!< capture/compare register 1 low */
  1673. __IO uint8_t CCR2H; /*!< capture/compare register 2 high */
  1674. __IO uint8_t CCR2L; /*!< capture/compare register 2 low */
  1675. __IO uint8_t BKR; /*!< Break Register */
  1676. __IO uint8_t OISR; /*!< Output idle register */
  1677. }
  1678. TIM_TypeDef;
  1679. /** @addtogroup TIM2_TIM3_Registers_Reset_Value
  1680. * @{
  1681. */
  1682. #define TIM_CR1_RESET_VALUE ((uint8_t)0x00)
  1683. #define TIM_CR2_RESET_VALUE ((uint8_t)0x00)
  1684. #define TIM_SMCR_RESET_VALUE ((uint8_t)0x00)
  1685. #define TIM_ETR_RESET_VALUE ((uint8_t)0x00)
  1686. #define TIM_DER_RESET_VALUE ((uint8_t)0x00)
  1687. #define TIM_IER_RESET_VALUE ((uint8_t)0x00)
  1688. #define TIM_SR1_RESET_VALUE ((uint8_t)0x00)
  1689. #define TIM_SR2_RESET_VALUE ((uint8_t)0x00)
  1690. #define TIM_EGR_RESET_VALUE ((uint8_t)0x00)
  1691. #define TIM_CCMR1_RESET_VALUE ((uint8_t)0x00)
  1692. #define TIM_CCMR2_RESET_VALUE ((uint8_t)0x00)
  1693. #define TIM_CCER1_RESET_VALUE ((uint8_t)0x00)
  1694. #define TIM_CNTRH_RESET_VALUE ((uint8_t)0x00)
  1695. #define TIM_CNTRL_RESET_VALUE ((uint8_t)0x00)
  1696. #define TIM_PSCR_RESET_VALUE ((uint8_t)0x00)
  1697. #define TIM_ARRH_RESET_VALUE ((uint8_t)0xFF)
  1698. #define TIM_ARRL_RESET_VALUE ((uint8_t)0xFF)
  1699. #define TIM_CCR1H_RESET_VALUE ((uint8_t)0x00)
  1700. #define TIM_CCR1L_RESET_VALUE ((uint8_t)0x00)
  1701. #define TIM_CCR2H_RESET_VALUE ((uint8_t)0x00)
  1702. #define TIM_CCR2L_RESET_VALUE ((uint8_t)0x00)
  1703. #define TIM_BKR_RESET_VALUE ((uint8_t)0x00)
  1704. #define TIM_OISR_RESET_VALUE ((uint8_t)0x00)
  1705. /**
  1706. * @}
  1707. */
  1708. /** @addtogroup TIM2_TIM3_TIM5_Registers_Bits_Definition
  1709. * @{
  1710. */
  1711. /* CR1*/
  1712. #define TIM_CR1_ARPE ((uint8_t)0x80) /*!< Auto-Reload Preload Enable Mask. */
  1713. #define TIM_CR1_CMS ((uint8_t)0x60) /*!< Center-aligned Mode Selection Mask. */
  1714. #define TIM_CR1_DIR ((uint8_t)0x10) /*!< Direction Mask. */
  1715. #define TIM_CR1_OPM ((uint8_t)0x08) /*!< One Pulse Mode Mask. */
  1716. #define TIM_CR1_URS ((uint8_t)0x04) /*!< Update Request Source Mask. */
  1717. #define TIM_CR1_UDIS ((uint8_t)0x02) /*!< Update DIsable Mask. */
  1718. #define TIM_CR1_CEN ((uint8_t)0x01) /*!< Counter Enable Mask. */
  1719. /* CR2*/
  1720. #define TIM_CR2_TI1S ((uint8_t)0x80) /*!< TI1 selection */
  1721. #define TIM_CR2_MMS ((uint8_t)0x70) /*!< MMS Selection Mask. */
  1722. #define TIM_CR2_CCDS ((uint8_t)0x08) /*!< Capture/Compare DMA Selection */
  1723. /* SMCR*/
  1724. #define TIM_SMCR_MSM ((uint8_t)0x80) /*!< Master/Slave Mode Mask. */
  1725. #define TIM_SMCR_TS ((uint8_t)0x70) /*!< Trigger Selection Mask. */
  1726. #define TIM_SMCR_SMS ((uint8_t)0x07) /*!< Slave Mode Selection Mask. */
  1727. /* ETR*/
  1728. #define TIM_ETR_ETP ((uint8_t)0x80) /*!< External Trigger Polarity Mask. */
  1729. #define TIM_ETR_ECE ((uint8_t)0x40)/*!< External Clock Mask. */
  1730. #define TIM_ETR_ETPS ((uint8_t)0x30) /*!< External Trigger Prescaler Mask. */
  1731. #define TIM_ETR_ETF ((uint8_t)0x0F) /*!< External Trigger Filter Mask. */
  1732. /* DER*/
  1733. #define TIM_DER_CC2DE ((uint8_t)0x04) /*!< Capture/Compare 2 DMA request Enable mask.*/
  1734. #define TIM_DER_CC1DE ((uint8_t)0x02) /*!< Capture/Compare 1 DMA request Enable mask.*/
  1735. #define TIM_DER_UDE ((uint8_t)0x01) /*!< Update DMA request Enable mask. */
  1736. /* IER*/
  1737. #define TIM_IER_BIE ((uint8_t)0x80) /*!< Break Interrupt Enable Mask. */
  1738. #define TIM_IER_TIE ((uint8_t)0x40) /*!< Trigger Interrupt Enable Mask. */
  1739. #define TIM_IER_CC2IE ((uint8_t)0x04) /*!< Capture/Compare 2 Interrupt Enable Mask. */
  1740. #define TIM_IER_CC1IE ((uint8_t)0x02) /*!< Capture/Compare 1 Interrupt Enable Mask. */
  1741. #define TIM_IER_UIE ((uint8_t)0x01) /*!< Update Interrupt Enable Mask. */
  1742. /* SR1*/
  1743. #define TIM_SR1_BIF ((uint8_t)0x80) /*!< Break Interrupt Flag Mask. */
  1744. #define TIM_SR1_TIF ((uint8_t)0x40) /*!< Trigger Interrupt Flag Mask. */
  1745. #define TIM_SR1_CC2IF ((uint8_t)0x04) /*!< Capture/Compare 2 Interrupt Flag Mask. */
  1746. #define TIM_SR1_CC1IF ((uint8_t)0x02) /*!< Capture/Compare 1 Interrupt Flag Mask. */
  1747. #define TIM_SR1_UIF ((uint8_t)0x01) /*!< Update Interrupt Flag Mask. */
  1748. /* SR2*/
  1749. #define TIM_SR2_CC2OF ((uint8_t)0x04) /*!< Capture/Compare 2 Overcapture Flag Mask. */
  1750. #define TIM_SR2_CC1OF ((uint8_t)0x02) /*!< Capture/Compare 1 Overcapture Flag Mask. */
  1751. /*EGR*/
  1752. #define TIM_EGR_BG ((uint8_t)0x80) /*!< Break Generation Mask. */
  1753. #define TIM_EGR_TG ((uint8_t)0x40) /*!< Trigger Generation Mask. */
  1754. #define TIM_EGR_CC2G ((uint8_t)0x04) /*!< Capture/Compare 2 Generation Mask. */
  1755. #define TIM_EGR_CC1G ((uint8_t)0x02) /*!< Capture/Compare 1 Generation Mask. */
  1756. #define TIM_EGR_UG ((uint8_t)0x01) /*!< Update Generation Mask. */
  1757. /*CCMR*/
  1758. #define TIM_CCMR_ICxF ((uint8_t)0xF0) /*!< Input Capture x Filter Mask. */
  1759. #define TIM_CCMR_ICxPSC ((uint8_t)0x0C) /*!< Input Capture x Prescaler Mask. */
  1760. #define TIM_CCMR_CCxS ((uint8_t)0x03) /*!< Capture/Compare x Selection Mask. */
  1761. #define TIM_CCMR_OCM ((uint8_t)0x70) /*!< Output Compare x Mode Mask. */
  1762. #define TIM_CCMR_OCxPE ((uint8_t)0x08) /*!< Output Compare x Preload Enable Mask. */
  1763. #define TIM_CCMR_OCxFE ((uint8_t)0x04) /*!< Output Compare x Fast Enable Mask. */
  1764. #define TIM_CCMR_TIxDirect_Set ((uint8_t)0x01)
  1765. /*CCER1*/
  1766. #define TIM_CCER1_CC2P ((uint8_t)0x20) /*!< Capture/Compare 2 output Polarity Mask. */
  1767. #define TIM_CCER1_CC2E ((uint8_t)0x10) /*!< Capture/Compare 2 output enable Mask. */
  1768. #define TIM_CCER1_CC1P ((uint8_t)0x02) /*!< Capture/Compare 1 output Polarity Mask. */
  1769. #define TIM_CCER1_CC1E ((uint8_t)0x01) /*!< Capture/Compare 1 output enable Mask. */
  1770. /*CNTR*/
  1771. #define TIM_CNTRH_CNT ((uint8_t)0xFF) /*!< Counter Value (MSB) Mask. */
  1772. #define TIM_CNTRL_CNT ((uint8_t)0xFF) /*!< Counter Value (LSB) Mask. */
  1773. /*PSCR*/
  1774. #define TIM_PSCR_PSC ((uint8_t)0x07) /*!< Prescaler Value Mask. */
  1775. /*ARR*/
  1776. #define TIM_ARRH_ARR ((uint8_t)0xFF) /*!< Autoreload Value (MSB) Mask. */
  1777. #define TIM_ARRL_ARR ((uint8_t)0xFF) /*!< Autoreload Value (LSB) Mask. */
  1778. /*CCR1*/
  1779. #define TIM_CCR1H_CCR1 ((uint8_t)0xFF) /*!< Capture/Compare 1 Value (MSB) Mask. */
  1780. #define TIM_CCR1L_CCR1 ((uint8_t)0xFF) /*!< Capture/Compare 1 Value (LSB) Mask. */
  1781. /*CCR2*/
  1782. #define TIM_CCR2H_CCR2 ((uint8_t)0xFF) /*!< Capture/Compare 2 Value (MSB) Mask. */
  1783. #define TIM_CCR2L_CCR2 ((uint8_t)0xFF) /*!< Capture/Compare 2 Value (LSB) Mask. */
  1784. /*BKR*/
  1785. #define TIM_BKR_MOE ((uint8_t)0x80) /*!< Main Output Enable Mask. */
  1786. #define TIM_BKR_AOE ((uint8_t)0x40) /*!< Automatic Output Enable Mask. */
  1787. #define TIM_BKR_BKP ((uint8_t)0x20) /*!< Break Polarity Mask. */
  1788. #define TIM_BKR_BKE ((uint8_t)0x10) /*!< Break Enable Mask. */
  1789. #define TIM_BKR_OSSI ((uint8_t)0x04) /*!< Off-State Selection for Idle mode Mask. */
  1790. #define TIM_BKR_LOCK ((uint8_t)0x03) /*!<Lock Configuration Mask. */
  1791. /*OISR*/
  1792. #define TIM_OISR_OIS2 ((uint8_t)0x04) /*!< Output Idle state 2 (OC2 output) Mask. */
  1793. #define TIM_OISR_OIS1 ((uint8_t)0x01) /*!< Output Idle state 1 (OC1 output) Mask. */
  1794. /**
  1795. * @}
  1796. */
  1797. /*----------------------------------------------------------------------------*/
  1798. /**
  1799. * @brief 8-bit system or Low End Small Timer (TIM4)
  1800. */
  1801. typedef struct TIM4_struct
  1802. {
  1803. __IO uint8_t CR1; /*!< control register 1 */
  1804. __IO uint8_t CR2; /*!< control register 2 */
  1805. __IO uint8_t SMCR; /*!< Synchro mode control register */
  1806. __IO uint8_t DER; /*!< DMA requests enable register */
  1807. __IO uint8_t IER; /*!< interrupt enable register */
  1808. __IO uint8_t SR1; /*!< status register 1 */
  1809. __IO uint8_t EGR; /*!< event generation register */
  1810. __IO uint8_t CNTR; /*!< counter register */
  1811. __IO uint8_t PSCR; /*!< prescaler register */
  1812. __IO uint8_t ARR; /*!< auto-reload register */
  1813. }
  1814. TIM4_TypeDef;
  1815. /** @addtogroup TIM4_Registers_Reset_Value
  1816. * @{
  1817. */
  1818. #define TIM4_CR1_RESET_VALUE ((uint8_t)0x00)
  1819. #define TIM4_CR2_RESET_VALUE ((uint8_t)0x00)
  1820. #define TIM4_SMCR_RESET_VALUE ((uint8_t)0x00)
  1821. #define TIM4_DER_RESET_VALUE ((uint8_t)0x00)
  1822. #define TIM4_IER_RESET_VALUE ((uint8_t)0x00)
  1823. #define TIM4_SR1_RESET_VALUE ((uint8_t)0x00)
  1824. #define TIM4_EGR_RESET_VALUE ((uint8_t)0x00)
  1825. #define TIM4_CNTR_RESET_VALUE ((uint8_t)0x00)
  1826. #define TIM4_PSCR_RESET_VALUE ((uint8_t)0x00)
  1827. #define TIM4_ARR_RESET_VALUE ((uint8_t)0xFF)
  1828. /**
  1829. * @}
  1830. */
  1831. /** @addtogroup TIM4_Registers_Bits_Definition
  1832. * @{
  1833. */
  1834. /* CR1*/
  1835. #define TIM4_CR1_ARPE ((uint8_t)0x80) /*!< Auto-Reload Preload Enable Mask. */
  1836. #define TIM4_CR1_OPM ((uint8_t)0x08) /*!< One Pulse Mode Mask. */
  1837. #define TIM4_CR1_URS ((uint8_t)0x04) /*!< Update Request Source Mask. */
  1838. #define TIM4_CR1_UDIS ((uint8_t)0x02) /*!< Update DIsable Mask. */
  1839. #define TIM4_CR1_CEN ((uint8_t)0x01) /*!< Counter Enable Mask. */
  1840. /* CR2*/
  1841. #define TIM4_CR2_MMS ((uint8_t)0x70) /*!< MMS Selection Mask. */
  1842. /* SMCR*/
  1843. #define TIM4_SMCR_MSM ((uint8_t)0x80) /*!< Master/Slave Mode Mask. */
  1844. #define TIM4_SMCR_TS ((uint8_t)0x70) /*!< Trigger Selection Mask. */
  1845. #define TIM4_SMCR_SMS ((uint8_t)0x07) /*!< Slave Mode Selection Mask. */
  1846. /* DER*/
  1847. #define TIM4_DER_UDE ((uint8_t)0x01) /*!< Update DMA request Enable mask. */
  1848. /* IER*/
  1849. #define TIM4_IER_TIE ((uint8_t)0x40) /*!< Trigger Interrupt Enable Mask. */
  1850. #define TIM4_IER_UIE ((uint8_t)0x01) /*!< Update Interrupt Enable Mask. */
  1851. /* SR1*/
  1852. #define TIM4_SR1_UIF ((uint8_t)0x01) /*!< Update Interrupt Flag Mask. */
  1853. #define TIM4_SR1_TIF ((uint8_t)0x40) /*!< Trigger Interrupt Flag Mask. */
  1854. /* EGR*/
  1855. #define TIM4_EGR_UG ((uint8_t)0x01) /*!< Update Generation Mask. */
  1856. #define TIM4_EGR_TG ((uint8_t)0x40) /*!< Trigger Generation Mask. */
  1857. /* CNTR*/
  1858. #define TIM4_CNTR_CNT ((uint8_t)0xFF) /*!<Counter Value (LSB) Mask. */
  1859. /* PSCR*/
  1860. #define TIM4_PSCR_PSC ((uint8_t)0x0F) /*!<Prescaler Value Mask. */
  1861. /* ARR*/
  1862. #define TIM4_ARR_ARR ((uint8_t)0xFF) /*!<Autoreload Value Mask. */
  1863. /**
  1864. * @}
  1865. */
  1866. /*----------------------------------------------------------------------------*/
  1867. /**
  1868. * @brief USART
  1869. */
  1870. typedef struct USART_struct
  1871. {
  1872. __IO uint8_t SR; /*!< USART status register */
  1873. __IO uint8_t DR; /*!< USART data register */
  1874. __IO uint8_t BRR1; /*!< USART baud rate register */
  1875. __IO uint8_t BRR2; /*!< USART DIV mantissa[11:8] SCIDIV fraction */
  1876. __IO uint8_t CR1; /*!< USART control register 1 */
  1877. __IO uint8_t CR2; /*!< USART control register 2 */
  1878. __IO uint8_t CR3; /*!< USART control register 3 */
  1879. __IO uint8_t CR4; /*!< USART control register 4 */
  1880. __IO uint8_t CR5; /*!< USART control register 5 */
  1881. __IO uint8_t GTR; /*!< USART guard time register */
  1882. __IO uint8_t PSCR; /*!< USART prescaler register */
  1883. }
  1884. USART_TypeDef;
  1885. /** @addtogroup USART_Registers_Reset_Value
  1886. * @{
  1887. */
  1888. #define USART_SR_RESET_VALUE ((uint8_t)0xC0)
  1889. #define USART_BRR1_RESET_VALUE ((uint8_t)0x00)
  1890. #define USART_BRR2_RESET_VALUE ((uint8_t)0x00)
  1891. #define USART_CR1_RESET_VALUE ((uint8_t)0x00)
  1892. #define USART_CR2_RESET_VALUE ((uint8_t)0x00)
  1893. #define USART_CR3_RESET_VALUE ((uint8_t)0x00)
  1894. #define USART_CR4_RESET_VALUE ((uint8_t)0x00)
  1895. /**
  1896. * @}
  1897. */
  1898. /** @addtogroup USART_Registers_Bits_Definition
  1899. * @{
  1900. */
  1901. #define USART_SR_TXE ((uint8_t)0x80) /*!< Transmit Data Register Empty mask */
  1902. #define USART_SR_TC ((uint8_t)0x40) /*!< Transmission Complete mask */
  1903. #define USART_SR_RXNE ((uint8_t)0x20) /*!< Read Data Register Not Empty mask */
  1904. #define USART_SR_IDLE ((uint8_t)0x10) /*!< IDLE line detected mask */
  1905. #define USART_SR_OR ((uint8_t)0x08) /*!< OverRun error mask */
  1906. #define USART_SR_NF ((uint8_t)0x04) /*!< Noise Flag mask */
  1907. #define USART_SR_FE ((uint8_t)0x02) /*!< Framing Error mask */
  1908. #define USART_SR_PE ((uint8_t)0x01) /*!< Parity Error mask */
  1909. #define USART_BRR1_DIVM ((uint8_t)0xFF) /*!< LSB mantissa of USARTDIV [7:0] mask */
  1910. #define USART_BRR2_DIVM ((uint8_t)0xF0) /*!< MSB mantissa of USARTDIV [11:8] mask */
  1911. #define USART_BRR2_DIVF ((uint8_t)0x0F) /*!< Fraction bits of USARTDIV [3:0] mask */
  1912. #define USART_CR1_R8 ((uint8_t)0x80) /*!< Receive Data bit 8 */
  1913. #define USART_CR1_T8 ((uint8_t)0x40) /*!< Transmit data bit 8 */
  1914. #define USART_CR1_USARTD ((uint8_t)0x20) /*!< USART Disable (for low power consumption) */
  1915. #define USART_CR1_M ((uint8_t)0x10) /*!< Word length mask */
  1916. #define USART_CR1_WAKE ((uint8_t)0x08) /*!< Wake-up method mask */
  1917. #define USART_CR1_PCEN ((uint8_t)0x04) /*!< Parity Control Enable mask */
  1918. #define USART_CR1_PS ((uint8_t)0x02) /*!< USART Parity Selection */
  1919. #define USART_CR1_PIEN ((uint8_t)0x01) /*!< USART Parity Interrupt Enable mask */
  1920. #define USART_CR2_TIEN ((uint8_t)0x80) /*!< Transmitter Interrupt Enable mask */
  1921. #define USART_CR2_TCIEN ((uint8_t)0x40) /*!< TransmissionComplete Interrupt Enable mask */
  1922. #define USART_CR2_RIEN ((uint8_t)0x20) /*!< Receiver Interrupt Enable mask */
  1923. #define USART_CR2_ILIEN ((uint8_t)0x10) /*!< IDLE Line Interrupt Enable mask */
  1924. #define USART_CR2_TEN ((uint8_t)0x08) /*!< Transmitter Enable mask */
  1925. #define USART_CR2_REN ((uint8_t)0x04) /*!< Receiver Enable mask */
  1926. #define USART_CR2_RWU ((uint8_t)0x02) /*!< Receiver Wake-Up mask */
  1927. #define USART_CR2_SBK ((uint8_t)0x01) /*!< Send Break mask */
  1928. #define USART_CR3_STOP ((uint8_t)0x30) /*!< STOP bits [1:0] mask */
  1929. #define USART_CR3_CLKEN ((uint8_t)0x08) /*!< Clock Enable mask */
  1930. #define USART_CR3_CPOL ((uint8_t)0x04) /*!< Clock Polarity mask */
  1931. #define USART_CR3_CPHA ((uint8_t)0x02) /*!< Clock Phase mask */
  1932. #define USART_CR3_LBCL ((uint8_t)0x01) /*!< Last Bit Clock pulse mask */
  1933. #define USART_CR4_ADD ((uint8_t)0x0F) /*!< Address of the USART node mask */
  1934. #define USART_CR5_DMAT ((uint8_t)0x80) /*!< DMA Enable transmitter mask */
  1935. #define USART_CR5_DMAR ((uint8_t)0x40) /*!< DMA Enable receiver mask */
  1936. #define USART_CR5_SCEN ((uint8_t)0x20) /*!< Smart Card Enable mask */
  1937. #define USART_CR5_NACK ((uint8_t)0x10) /*!< Smart Card Nack Enable mask */
  1938. #define USART_CR5_HDSEL ((uint8_t)0x08) /*!< Half-Duplex Selection mask */
  1939. #define USART_CR5_IRLP ((uint8_t)0x04) /*!< Irda Low Power Selection mask */
  1940. #define USART_CR5_IREN ((uint8_t)0x02) /*!< Irda Enable mask */
  1941. #define USART_CR5_EIE ((uint8_t)0x01) /*!< Error Interrupt mask */
  1942. /**
  1943. * @}
  1944. */
  1945. /*----------------------------------------------------------------------------*/
  1946. /**
  1947. * @brief Analog to Digital Converter (ADC) peripheral
  1948. */
  1949. typedef struct ADC_struct
  1950. {
  1951. __IO uint8_t CR1; /*!< Control register 1 */
  1952. __IO uint8_t CR2; /*!< Control register 2 */
  1953. __IO uint8_t CR3; /*!< Control register 3 */
  1954. __IO uint8_t SR; /*!< Status register */
  1955. __IO uint8_t DRH; /*!< Data register MSB */
  1956. __IO uint8_t DRL; /*!< Data register LSB */
  1957. __IO uint8_t HTRH; /*!< High voltage reference register MSB */
  1958. __IO uint8_t HTRL; /*!< High voltage reference register LSB */
  1959. __IO uint8_t LTRH; /*!< Low voltage reference register MSB */
  1960. __IO uint8_t LTRL; /*!< Low voltage reference register LSB */
  1961. __IO uint8_t SQR[4]; /*!< Channel select scan registers */
  1962. __IO uint8_t TRIGR[4]; /*!< Trigger disable registers */
  1963. }
  1964. ADC_TypeDef;
  1965. /** @addtogroup ADC_Registers_Reset_Value
  1966. * @{
  1967. */
  1968. #define ADC_CR1_RESET_VALUE ((uint8_t) 0x00)
  1969. #define ADC_CR2_RESET_VALUE ((uint8_t) 0x00)
  1970. #define ADC_CR3_RESET_VALUE ((uint8_t) 0x1F)
  1971. #define ADC_SR_RESET_VALUE ((uint8_t) 0x00)
  1972. #define ADC_DRH_RESET_VALUE ((uint8_t) 0x00)
  1973. #define ADC_DRL_RESET_VALUE ((uint8_t) 0x00)
  1974. #define ADC_HTRH_RESET_VALUE ((uint8_t) 0x0F)
  1975. #define ADC_HTRL_RESET_VALUE ((uint8_t) 0xFF)
  1976. #define ADC_LTRH_RESET_VALUE ((uint8_t) 0x00)
  1977. #define ADC_LTRL_RESET_VALUE ((uint8_t) 0x00)
  1978. #define ADC_SQR1_RESET_VALUE ((uint8_t) 0x00)
  1979. #define ADC_SQR2_RESET_VALUE ((uint8_t) 0x00)
  1980. #define ADC_SQR3_RESET_VALUE ((uint8_t) 0x00)
  1981. #define ADC_SQR4_RESET_VALUE ((uint8_t) 0x00)
  1982. #define ADC_TRIGR1_RESET_VALUE ((uint8_t) 0x00)
  1983. #define ADC_TRIGR2_RESET_VALUE ((uint8_t) 0x00)
  1984. #define ADC_TRIGR3_RESET_VALUE ((uint8_t) 0x00)
  1985. #define ADC_TRIGR4_RESET_VALUE ((uint8_t) 0x00)
  1986. /**
  1987. * @}
  1988. */
  1989. /** @addtogroup ADC_Registers_Bits_Definition
  1990. * @{
  1991. */
  1992. #define ADC_CR1_ADON ((uint8_t)0x01)
  1993. #define ADC_CR1_START ((uint8_t)0x02)
  1994. #define ADC_CR1_CONT ((uint8_t)0x04)
  1995. #define ADC_CR1_EOCIE ((uint8_t)0x08)
  1996. #define ADC_CR1_AWDIE ((uint8_t)0x10)
  1997. #define ADC_CR1_RES ((uint8_t)0x60)
  1998. #define ADC_CR1_OVERIE ((uint8_t)0x80)
  1999. #define ADC_CR2_SMPT1 ((uint8_t)0x07)
  2000. #define ADC_CR2_EXTSEL ((uint8_t)0x18)
  2001. #define ADC_CR2_TRIGEDGE ((uint8_t)0x60)
  2002. #define ADC_CR2_PRESC ((uint8_t)0x80)
  2003. #define ADC_CR3_CHSEL ((uint8_t)0x1F)
  2004. #define ADC_CR3_SMPT2 ((uint8_t)0xE0)
  2005. #define ADC_SR_EOC ((uint8_t)0x01)
  2006. #define ADC_SR_AWD ((uint8_t)0x02)
  2007. #define ADC_SR_OVER ((uint8_t)0x04)
  2008. #define ADC_DRH_CONVDATA ((uint8_t)0x0F)
  2009. #define ADC_DRL_CONVDATA ((uint8_t)0xFF)
  2010. #define ADC_HTRH_HT ((uint8_t)0x0F)
  2011. #define ADC_HTRL_HT ((uint8_t)0xFF)
  2012. #define ADC_LTRH_LT ((uint8_t)0x0F)
  2013. #define ADC_LTRL_LT ((uint8_t)0xFF)
  2014. #define ADC_SQR1_CHSELS ((uint8_t)0x3F)
  2015. #define ADC_SQR1_DMAOFF ((uint8_t)0x80)
  2016. #define ADC_SQR2_CHSELS ((uint8_t)0xFF)
  2017. #define ADC_SQR3_CHSELS ((uint8_t)0xFF)
  2018. #define ADC_SQR4_CHSELS ((uint8_t)0xFF)
  2019. #define ADC_TRIGR1_TRIG ((uint8_t)0x0F)
  2020. #define ADC_TRIGR1_VREFINTON ((uint8_t)0x10)
  2021. #define ADC_TRIGR1_TSON ((uint8_t)0x20)
  2022. #define ADC_TRIGR2_TRIG ((uint8_t)0xFF)
  2023. #define ADC_TRIGR3_TRIG ((uint8_t)0xFF)
  2024. #define ADC_TRIGR4_TRIG ((uint8_t)0xFF)
  2025. /**
  2026. * @}
  2027. */
  2028. /*----------------------------------------------------------------------------*/
  2029. /*----------------------------------------------------------------------------*/
  2030. /**
  2031. * @brief Digital to Analog Converter (DAC) peripheral
  2032. */
  2033. typedef struct DAC_struct
  2034. {
  2035. __IO uint8_t CH1CR1; /*!< DAC control register 1 */
  2036. __IO uint8_t CH1CR2; /*!< DAC control register 2 */
  2037. __IO uint8_t CH2CR1; /*!< DAC channel 2 control register 1 */
  2038. __IO uint8_t CH2CR2; /*!< DAC channel 2 control register 2 */
  2039. __IO uint8_t SWTRIGR; /*!< DAC software trigger register */
  2040. __IO uint8_t SR; /*!< DAC status register */
  2041. /*Channel 1 registers*/
  2042. __IO uint8_t RESERVED0[2];
  2043. __IO uint8_t CH1RDHRH; /*!< DAC Channel 1 right aligned data holding register MSB */
  2044. __IO uint8_t CH1RDHRL; /*!< DAC Channel 1 right aligned data holding register LSB */
  2045. __IO uint8_t RESERVED1[2];
  2046. __IO uint8_t CH1LDHRH; /*!< DAC Channel 1 left aligned data holding register MSB */
  2047. __IO uint8_t CH1LDHRL; /*!< DAC Channel 1 left aligned data holding register LSB */
  2048. __IO uint8_t RESERVED2[2];
  2049. __IO uint8_t CH1DHR8; /*!< DAC Channel 1 8-bit data holding register */
  2050. /*Channel 2 registers*/
  2051. __IO uint8_t RESERVED3[3];
  2052. __IO uint8_t CH2RDHRH; /*!< DAC Channel 2 right aligned data holding register MSB */
  2053. __IO uint8_t CH2RDHRL; /*!< DAC Channel 2 right aligned data holding register LSB */
  2054. __IO uint8_t RESERVED4[2];
  2055. __IO uint8_t CH2LDHRH; /*!< DAC Channel 2 left aligned data holding register MSB */
  2056. __IO uint8_t CH2LDHRL; /*!< DAC Channel 2 left aligned data holding register LSB */
  2057. __IO uint8_t RESERVED5[2];
  2058. __IO uint8_t CH2DHR8; /*!< DAC Channel 2 8-bit data holding register */
  2059. /* Dual mode registers */
  2060. __IO uint8_t RESERVED6[3];
  2061. __IO uint8_t DCH1RDHRH; /*!< DAC Dual mode Channel 1 right aligned data holding register MSB */
  2062. __IO uint8_t DCH1RDHRL; /*!< DAC Dual mode Channel 1 right aligned data holding register LSB */
  2063. __IO uint8_t DCH2RDHRH; /*!< DAC Dual mode Channel 2 right aligned data holding register MSB */
  2064. __IO uint8_t DCH2RDHRL; /*!< DAC Dual mode Channel 2 right aligned data holding register LSB */
  2065. __IO uint8_t DCH1LDHRH; /*!< DAC Dual mode Channel 1 left aligned data holding register MSB */
  2066. __IO uint8_t DCH1LDHRL; /*!< DAC Dual mode Channel 1 left aligned data holding register LSB */
  2067. __IO uint8_t DCH2LDHRH; /*!< DAC Dual mode Channel 2 left aligned data holding register MSB */
  2068. __IO uint8_t DCH2LDHRL; /*!< DAC Dual mode Channel 2 left aligned data holding register LSB */
  2069. __IO uint8_t DCH1DHR8; /*!< DAC Dual mode Channel 1 8-bit data holding register */
  2070. __IO uint8_t DCH2DHR8; /*!< DAC Dual mode Channel 2 8-bit data holding register */
  2071. /* DOR registers*/
  2072. __IO uint8_t RESERVED7[2];
  2073. __IO uint8_t CH1DORH; /*!< DAC Channel 1 data output register MSB */
  2074. __IO uint8_t CH1DORL; /*!< DAC Channel 1 data output register LSB */
  2075. __IO uint8_t RESERVED8[2];
  2076. __IO uint8_t CH2DORH; /*!< DAC Channel 2 data output register MSB */
  2077. __IO uint8_t CH2DORL; /*!< DAC Channel 2 data output register LSB */
  2078. }
  2079. DAC_TypeDef;
  2080. /** @addtogroup DAC_Registers_Reset_Value
  2081. * @{
  2082. */
  2083. #define DAC_CR1_RESET_VALUE ((uint8_t)0x00)
  2084. #define DAC_CR2_RESET_VALUE ((uint8_t)0x00)
  2085. #define DAC_SWTRIGR_RESET_VALUE ((uint8_t)0x00)
  2086. #define DAC_SR_RESET_VALUE ((uint8_t)0x00)
  2087. #define DAC_RDHRH_RESET_VALUE ((uint8_t)0x00)
  2088. #define DAC_RDHRL_RESET_VALUE ((uint8_t)0x00)
  2089. #define DAC_LDHRH_RESET_VALUE ((uint8_t)0x00)
  2090. #define DAC_LDHRL_RESET_VALUE ((uint8_t)0x00)
  2091. #define DAC_DHR8_RESET_VALUE ((uint8_t)0x00)
  2092. #define DAC_DORH_RESET_VALUE ((uint8_t)0x00)
  2093. #define DAC_DORL_RESET_VALUE ((uint8_t)0x00)
  2094. /**
  2095. * @}
  2096. */
  2097. /** @addtogroup DAC_Registers_Bits_Definition
  2098. * @{
  2099. */
  2100. /* CR1*/
  2101. #define DAC_CR1_TSEL ((uint8_t)0x38) /*!< DAC channel trigger selection. */
  2102. #define DAC_CR1_TEN ((uint8_t)0x04) /*!< DAC channel trigger enable. */
  2103. #define DAC_CR1_BOFF ((uint8_t)0x02) /*!< DAC channel output buffer disable. */
  2104. #define DAC_CR1_EN ((uint8_t)0x01) /*!< DAC channel enable. */
  2105. #define DAC_CR1_WAVEN ((uint8_t)0xC0) /*!< DAC channel wave generation enable. */
  2106. /* CR2*/
  2107. #define DAC_CR2_DMAUDRIE ((uint8_t)0x20) /*!< DAC channel DMA underrun interrupt enable. */
  2108. #define DAC_CR2_DMAEN ((uint8_t)0x10) /*!< DAC DMA enable. */
  2109. #define DAC_CR2_MAMPx ((uint8_t)0x0F) /*!< DAC Dchannel wave generation config. */
  2110. /* SWTRIGR*/
  2111. #define DAC_SWTRIGR_SWTRIG1 ((uint8_t)0x01) /*!< DAC channel 1 software trigger. */
  2112. #define DAC_SWTRIGR_SWTRIG2 ((uint8_t)0x02) /*!< DAC channel 2 software trigger. */
  2113. /* SR*/
  2114. #define DAC_SR_DMAUDR1 ((uint8_t)0x01) /*!< DAC channel 1 DMA underrun flag. */
  2115. #define DAC_SR_DMAUDR2 ((uint8_t)0x02) /*!< DAC channel 2 DMA underrun flag. */
  2116. /* RDHRH*/
  2117. #define DAC_RDHRH_RDHRH ((uint8_t)0x0F) /*!< DAC right aligned data holding register most significant bits. */
  2118. /* RDHRL*/
  2119. #define DAC_RDHRL_RDHRL ((uint8_t)0xFF) /*!< DAC right aligned data holding register least significant bits. */
  2120. /* LDHRL*/
  2121. #define DAC_LDHRH_LDHRH ((uint8_t)0xFF) /*!< DAC left aligned data holding register most significant bits. */
  2122. /* LDHRL*/
  2123. #define DAC_LDHRL_LDHRL ((uint8_t)0xF0) /*!< DAC left aligned data holding register least significant bits. */
  2124. /* DHR8*/
  2125. #define DAC_DHR8_8DHR ((uint8_t)0xFF) /*!< DAC 8bit data holding bits */
  2126. /* DORH*/
  2127. #define DAC_DORH_DORH ((uint8_t)0x0F) /*!< DAC data output register most significant bit */
  2128. /* DORL*/
  2129. #define DAC_DORL_DORL ((uint8_t)0xFF) /*!< DAC data output register least significant bit */
  2130. /**
  2131. * @}
  2132. */
  2133. /*----------------------------------------------------------------------------*/
  2134. /**
  2135. * @brief Direct-Memory Access (DMA)
  2136. */
  2137. typedef struct DMA_struct
  2138. {
  2139. __IO uint8_t GCSR; /*!< Global configuration and status register */
  2140. __IO uint8_t GIR1; /*!< Global interrupt register 1 */
  2141. }
  2142. DMA_TypeDef;
  2143. /**
  2144. * @}
  2145. */
  2146. typedef struct DMA_Channel_struct
  2147. {
  2148. __IO uint8_t CCR; /*!< CHx Control register */
  2149. __IO uint8_t CSPR; /*!< CHx Status & Priority register */
  2150. __IO uint8_t CNBTR; /*!< CHx Number of Bytes to Tranfer register */
  2151. __IO uint8_t CPARH; /*!< Peripheral Address High register */
  2152. __IO uint8_t CPARL; /*!< Peripheral Address Low register */
  2153. __IO uint8_t CM0EAR; /*!< Memory 0 Extended Address register (for channel3)*/
  2154. __IO uint8_t CM0ARH; /*!< Memory 0 Address High register */
  2155. __IO uint8_t CM0ARL; /*!< Memory 0 Address Low register */
  2156. }
  2157. DMA_Channel_TypeDef;
  2158. /**
  2159. * @}
  2160. */
  2161. /** @addtogroup DMA_Registers_Reset_Value
  2162. * @{
  2163. */
  2164. #define DMA_GCSR_RESET_VALUE ((uint8_t)0xFC)
  2165. #define DMA_GIR1_RESET_VALUE ((uint8_t)0x00)
  2166. /**
  2167. * @}
  2168. */
  2169. /** @addtogroup DMA_Channels_Registers_Reset_Value
  2170. * @{
  2171. */
  2172. #define DMA_CCR_RESET_VALUE ((uint8_t)0x00)
  2173. #define DMA_CSPR_RESET_VALUE ((uint8_t)0x00)
  2174. #define DMA_CNBTR_RESET_VALUE ((uint8_t)0x00)
  2175. #define DMA_CPARH_RESET_VALUE ((uint8_t)0x52)
  2176. #define DMA_C3PARH_RESET_VALUE ((uint8_t)0x40)
  2177. #define DMA_CPARL_RESET_VALUE ((uint8_t)0x00)
  2178. #define DMA_C3M0EAR_RESET_VALUE ((uint8_t)0x00)
  2179. #define DMA_CM0ARH_RESET_VALUE ((uint8_t)0x00)
  2180. #define DMA_CM0ARL_RESET_VALUE ((uint8_t)0x00)
  2181. /** @addtogroup DMA_Registers_Bits_Definition
  2182. * @{
  2183. */
  2184. /* Bit definition for DMA_GCSR register */
  2185. #define DMA_GCSR_GE ((uint8_t)0x01) /*!<Global Enable */
  2186. #define DMA_GCSR_GB ((uint8_t)0x02) /*!<Global Busy */
  2187. #define DMA_GCSR_TO ((uint8_t)0xFC) /*!<Time Out */
  2188. /* Bit definition for DMA_GIR1 register */
  2189. #define DMA_GIR1_IFC0 ((uint8_t)0x01) /*!< Interrupt Flag Channel 0 */
  2190. #define DMA_GIR1_IFC1 ((uint8_t)0x02) /*!< Interrupt Flag Channel 1 */
  2191. #define DMA_GIR1_IFC2 ((uint8_t)0x04) /*!< Interrupt Flag Channel 2 */
  2192. #define DMA_GIR1_IFC3 ((uint8_t)0x08) /*!< Interrupt Flag Channel 3 */
  2193. /* Bit definition for DMA_CCR registers */
  2194. #define DMA_CCR_CE ((uint8_t)0x01) /*!<Channel enable*/
  2195. #define DMA_CCR_TCIE ((uint8_t)0x02) /*!<Transfer complete interrupt enable */
  2196. #define DMA_CCR_HTIE ((uint8_t)0x04) /*!<Half Transfer interrupt enable */
  2197. #define DMA_CCR_DTD ((uint8_t)0x08) /*!<Data transfer direction */
  2198. #define DMA_CCR_ARM ((uint8_t)0x10) /*!<Autorelaod mode Circular buffer mode */
  2199. #define DMA_CCR_IDM ((uint8_t)0x20) /*!<Inc/Dec mode */
  2200. #define DMA_CCR_MEM ((uint8_t)0x40) /*!<Memory Transfer Enable */
  2201. /* Bit definition for DMA_CSPR registers */
  2202. #define DMA_CSPR_TCIF ((uint8_t)0x02) /*!<Transaction Complete Interrupt Flag*/
  2203. #define DMA_CSPR_HTIF ((uint8_t)0x04) /*!<Half Transaction Interrupt Flag*/
  2204. #define DMA_CSPR_16BM ((uint8_t)0x08) /*!<16 bit mode*/
  2205. #define DMA_CSPR_PL ((uint8_t)0x30) /*!<Channel priority level*/
  2206. #define DMA_CSPR_PEND ((uint8_t)0x40) /*!<Channel pending*/
  2207. #define DMA_CSPR_BUSY ((uint8_t)0x80) /*!<Channel Busy */
  2208. /* Bit definition for DMA_CNBTR register */
  2209. #define DMA_CNBTR_NDT ((uint8_t)0xFF) /*!<Number of data to Transfer */
  2210. /* Bit definition for DMA_CPARH register */
  2211. #define DMA_CPARH_PA ((uint8_t)0xFF) /*!<Peripheral MSB Address Pointer */
  2212. /* Bit definition for DMA_CPARL register */
  2213. #define DMA_CPARL_PA ((uint8_t)0xFF) /*!<Peripheral LSB Address Pointer */
  2214. /* Bit definition for DMA_CMAR registers */
  2215. #define DMA_CM0EAR_MA ((uint8_t)0x01) /* Memory Extended Address Pointer only for channel 3 in Memory to memory transfer*/
  2216. #define DMA_CM0ARH_MA ((uint8_t)0xFF) /*!<Memory MSB Address Pointer*/
  2217. #define DMA_CM0ARL_MA ((uint8_t)0xFF) /*!<Memory LSB Address Pointer */
  2218. /**
  2219. * @}
  2220. */
  2221. /*----------------------------------------------------------------------------*/
  2222. /**
  2223. * @brief Window Watchdog (WWDG)
  2224. */
  2225. typedef struct WWDG_struct
  2226. {
  2227. __IO uint8_t CR; /*!< Control Register */
  2228. __IO uint8_t WR; /*!< Window Register */
  2229. }
  2230. WWDG_TypeDef;
  2231. /** @addtogroup WWDG_Registers_Reset_Value
  2232. * @{
  2233. */
  2234. #define WWDG_CR_RESET_VALUE ((uint8_t)0x7F)
  2235. #define WWDG_WR_RESET_VALUE ((uint8_t)0x7F)
  2236. /**
  2237. * @}
  2238. */
  2239. /** @addtogroup WWDG_Registers_Bits_Definition
  2240. * @{
  2241. */
  2242. #define WWDG_CR_WDGA ((uint8_t)0x80) /*!< WDGA bit mask */
  2243. #define WWDG_CR_T6 ((uint8_t)0x40) /*!< T6 bit mask */
  2244. #define WWDG_CR_T ((uint8_t)0x7F) /*!< T bits mask */
  2245. #define WWDG_WR_MSB ((uint8_t)0x80) /*!< MSB bit mask */
  2246. #define WWDG_WR_W ((uint8_t)0x7F) /*!< W bits mask */
  2247. /**
  2248. * @}
  2249. */
  2250. /*----------------------------------------------------------------------------*/
  2251. /**
  2252. * @brief LCD Controller (LCD)
  2253. */
  2254. typedef struct LCD_struct
  2255. {
  2256. __IO uint8_t CR1; /*!< LCD control register 1 */
  2257. __IO uint8_t CR2; /*!< LCD control register 2 */
  2258. __IO uint8_t CR3; /*!< LCD control register 3 */
  2259. __IO uint8_t FRQ; /*!< LCD frequency register */
  2260. __IO uint8_t PM[6]; /*!< LCD portmask registers*/
  2261. uint8_t RESERVED1[2]; /*!< Reserved */
  2262. __IO uint8_t RAM[22]; /*!< LCD RAM registers*/
  2263. uint8_t RESERVED2[13]; /*!< Reserved */
  2264. __IO uint8_t CR4; /*!< LCD control register 4 */
  2265. }
  2266. LCD_TypeDef;
  2267. /** @addtogroup LCD_Registers_Reset_Value
  2268. * @{
  2269. */
  2270. #define LCD_CR1_RESET_VALUE ((uint8_t)0x00) /*!< Control Register 1 reset value */
  2271. #define LCD_CR2_RESET_VALUE ((uint8_t)0x00) /*!< Control Register 2 reset value */
  2272. #define LCD_CR3_RESET_VALUE ((uint8_t)0x00) /*!< Control Register 3 reset value */
  2273. #define LCD_FRQ_RESET_VALUE ((uint8_t)0x00) /*!< Register Frequency reset value */
  2274. #define LCD_PM_RESET_VALUE ((uint8_t)0x00) /*!< Port mask Register reset value */
  2275. #define LCD_RAM_RESET_VALUE ((uint8_t)0x00) /*!< RAM Register reset value */
  2276. #define LCD_CR4_RESET_VALUE ((uint8_t)0x00) /*!< Control Register 4 reset value */
  2277. /**
  2278. * @}
  2279. */
  2280. /** @addtogroup LCD_Registers_Bits_Definition
  2281. * @{
  2282. */
  2283. #define LCD_CR1_BLINK ((uint8_t)0xC0) /*!< Blink bits mask */
  2284. #define LCD_CR1_BLINKF ((uint8_t)0x38) /*!< Blink frequency bits mask */
  2285. #define LCD_CR1_DUTY ((uint8_t)0x06) /*!< Duty bits mask */
  2286. #define LCD_CR1_B2 ((uint8_t)0x01) /*!< Bias selector bit mask */
  2287. #define LCD_CR2_PON ((uint8_t)0xE0) /*!< Pulse on duration bits mask */
  2288. #define LCD_CR2_HD ((uint8_t)0x10) /*!< High drive enable bit mask */
  2289. #define LCD_CR2_CC ((uint8_t)0x0E) /*!< Contrast control bits mask */
  2290. #define LCD_CR2_VSEL ((uint8_t)0x01) /*!< Voltage source bit mask */
  2291. #define LCD_CR3_LCDEN ((uint8_t)0x40) /*!< Enable bit mask */
  2292. #define LCD_CR3_SOFIE ((uint8_t)0x20) /*!< Start of frame interrupt enable mask */
  2293. #define LCD_CR3_SOF ((uint8_t)0x10) /*!< Start of frame bit mask */
  2294. #define LCD_CR3_SOFC ((uint8_t)0x08) /*!< Clear start of frame bit mask */
  2295. #define LCD_CR3_DEAD ((uint8_t)0x07) /*!< DEAD time bits mask */
  2296. #define LCD_FRQ_DIV ((uint8_t)0x0F) /*!< Divider bits mask */
  2297. #define LCD_FRQ_PS ((uint8_t)0xF0) /*!< 16 bits prescaler bits mask */
  2298. #define LCD_CR4_MAPCOM ((uint8_t)0x08) /*!< Select the mapping scheme for the COM[7:4] */
  2299. #define LCD_CR4_PAGECOM ((uint8_t)0x04) /*!< Select the LCD RAM page sector */
  2300. #define LCD_CR4_DUTY8 ((uint8_t)0x02) /*!< Enable the 1/8 duty */
  2301. #define LCD_CR4_B4 ((uint8_t)0x01) /*!< Enable the 1/4 bias */
  2302. /**
  2303. * @}
  2304. */
  2305. /*----------------------------------------------------------------------------*/
  2306. /* This peripheral is avilable in STM8L16x devices only*/
  2307. /**
  2308. * @brief AES tiny (AES)
  2309. */
  2310. typedef struct AES_struct
  2311. {
  2312. __IO uint8_t CR; /*!< AES control register */
  2313. __IO uint8_t SR; /*!< AES status register */
  2314. __IO uint8_t DINR; /*!< AES Data input register */
  2315. __IO uint8_t DOUTR; /*!< AES Data output register */
  2316. }
  2317. AES_TypeDef;
  2318. /** @addtogroup AES_Registers_Reset_Value
  2319. * @{
  2320. */
  2321. #define AES_CR_RESET_VALUE ((uint8_t)0x00) /*!< Control Register reset value */
  2322. #define AES_SR_RESET_VALUE ((uint8_t)0x00) /*!< Status Register reset value */
  2323. #define AES_DINR_RESET_VALUE ((uint8_t)0x00) /*!< Data input register reset value */
  2324. #define AES_DOUTR_RESET_VALUE ((uint8_t)0x00) /*!< Data output register reset value */
  2325. /**
  2326. * @}
  2327. */
  2328. /** @addtogroup AES_Registers_Bits_Definition
  2329. * @{
  2330. */
  2331. #define AES_CR_DMAEN ((uint8_t)0x80) /*!< DMA Enable bit mask */
  2332. #define AES_CR_ERRIE ((uint8_t)0x40) /*!< Error Interrupt Enable bit mask */
  2333. #define AES_CR_CCIE ((uint8_t)0x20) /*!< Computation Complete Interrupt Enable bit mask */
  2334. #define AES_CR_ERRC ((uint8_t)0x10) /*!< Error Clear bit mask */
  2335. #define AES_CR_CCFC ((uint8_t)0x08) /*!< Computation Complete Flag Clear bit mask */
  2336. #define AES_CR_MODE ((uint8_t)0x06) /*!< AES Modes of Operation bits mask */
  2337. #define AES_CR_EN ((uint8_t)0x01) /*!< AES Enable bit mask */
  2338. #define AES_SR_WRERR ((uint8_t)0x04) /*!< Write Error Flag bit mask */
  2339. #define AES_SR_RDERR ((uint8_t)0x02) /*!< Read Error Flag bit mask */
  2340. #define AES_SR_CCF ((uint8_t)0x01) /*!< Computation Complete Flag bit mask */
  2341. #define AES_DINR ((uint8_t)0xFF) /*!< Data Input bits mask */
  2342. #define AES_DOUTR ((uint8_t)0xFF) /*!< Data Output bits mask */
  2343. /**
  2344. * @}
  2345. */
  2346. /******************************************************************************/
  2347. /* Peripherals Base Address */
  2348. /******************************************************************************/
  2349. #define OPT_BASE (uint16_t)0x4800
  2350. #define GPIOA_BASE (uint16_t)0x5000
  2351. #define GPIOB_BASE (uint16_t)0x5005
  2352. #define GPIOC_BASE (uint16_t)0x500A
  2353. #define GPIOD_BASE (uint16_t)0x500F
  2354. #define GPIOE_BASE (uint16_t)0x5014
  2355. #define GPIOF_BASE (uint16_t)0x5019
  2356. #define GPIOG_BASE (uint16_t)0x501E
  2357. #define GPIOH_BASE (uint16_t)0x5023
  2358. #define GPIOI_BASE (uint16_t)0x5028
  2359. #define FLASH_BASE (uint16_t)0x5050
  2360. #define DMA1_BASE (uint16_t)0x5070
  2361. #define DMA1_Channel0_BASE (uint16_t)0x5075
  2362. #define DMA1_Channel1_BASE (uint16_t)0x507F
  2363. #define DMA1_Channel2_BASE (uint16_t)0x5089
  2364. #define DMA1_Channel3_BASE (uint16_t)0x5093
  2365. #define SYSCFG_BASE (uint16_t)0x509D
  2366. #define EXTI_BASE (uint16_t)0x50A0
  2367. #define WFE_BASE (uint16_t)0x50A6
  2368. #define RST_BASE (uint16_t)0x50B0
  2369. #define PWR_BASE (uint16_t)0x50B2
  2370. #define CLK_BASE (uint16_t)0x50C0
  2371. #define WWDG_BASE (uint16_t)0x50D3
  2372. #define IWDG_BASE (uint16_t)0x50E0
  2373. #define BEEP_BASE (uint16_t)0x50F0
  2374. #define RTC_BASE (uint16_t)0x5140
  2375. #define CSSLSE_BASE (uint16_t)0x5190
  2376. #define SPI1_BASE (uint16_t)0x5200
  2377. #define SPI2_BASE (uint16_t)0x53C0
  2378. #define I2C1_BASE (uint16_t)0x5210
  2379. #define USART1_BASE (uint16_t)0x5230
  2380. #define USART2_BASE (uint16_t)0x53E0
  2381. #define USART3_BASE (uint16_t)0x53F0
  2382. #define TIM2_BASE (uint16_t)0x5250
  2383. #define TIM3_BASE (uint16_t)0x5280
  2384. #define TIM1_BASE (uint16_t)0x52B0
  2385. #define TIM4_BASE (uint16_t)0x52E0
  2386. #define IRTIM_BASE (uint16_t)0x52FF
  2387. #define TIM5_BASE (uint16_t)0x5300
  2388. #define ADC1_BASE (uint16_t)0x5340
  2389. #define DAC_BASE (uint16_t)0x5380
  2390. #define AES_BASE (uint16_t)0x53D0
  2391. #define LCD_BASE (uint16_t)0x5400
  2392. #define RI_BASE (uint16_t)0x5430
  2393. #define COMP_BASE (uint16_t)0x5440
  2394. #define CFG_BASE (uint16_t)0x7F60
  2395. #define ITC_BASE (uint16_t)0x7F70
  2396. #define DM_BASE (uint16_t)0x7F90
  2397. /******************************************************************************/
  2398. /* Peripherals declarations */
  2399. /******************************************************************************/
  2400. #define SYSCFG ((SYSCFG_TypeDef *) SYSCFG_BASE)
  2401. #define GPIOA ((GPIO_TypeDef *) GPIOA_BASE)
  2402. #define GPIOB ((GPIO_TypeDef *) GPIOB_BASE)
  2403. #define GPIOC ((GPIO_TypeDef *) GPIOC_BASE)
  2404. #define GPIOD ((GPIO_TypeDef *) GPIOD_BASE)
  2405. #define GPIOE ((GPIO_TypeDef *) GPIOE_BASE)
  2406. #define GPIOF ((GPIO_TypeDef *) GPIOF_BASE)
  2407. #define GPIOG ((GPIO_TypeDef *) GPIOG_BASE)
  2408. #define GPIOH ((GPIO_TypeDef *) GPIOH_BASE)
  2409. #define GPIOI ((GPIO_TypeDef *) GPIOI_BASE)
  2410. #define RTC ((RTC_TypeDef *) RTC_BASE)
  2411. #define FLASH ((FLASH_TypeDef *) FLASH_BASE)
  2412. #define EXTI ((EXTI_TypeDef *) EXTI_BASE)
  2413. #define RST ((RST_TypeDef *) RST_BASE)
  2414. #define PWR ((PWR_TypeDef *) PWR_BASE)
  2415. #define CLK ((CLK_TypeDef *) CLK_BASE)
  2416. #define CSSLSE ((CSSLSE_TypeDef *) CSSLSE_BASE)
  2417. #define WWDG ((WWDG_TypeDef *) WWDG_BASE)
  2418. #define IWDG ((IWDG_TypeDef *) IWDG_BASE)
  2419. #define WFE ((WFE_TypeDef *) WFE_BASE)
  2420. #define BEEP ((BEEP_TypeDef *) BEEP_BASE)
  2421. #define SPI1 ((SPI_TypeDef *) SPI1_BASE)
  2422. #define SPI2 ((SPI_TypeDef *) SPI2_BASE)
  2423. #define I2C1 ((I2C_TypeDef *) I2C1_BASE)
  2424. #define USART1 ((USART_TypeDef *) USART1_BASE)
  2425. #define USART2 ((USART_TypeDef *) USART2_BASE)
  2426. #define USART3 ((USART_TypeDef *) USART3_BASE)
  2427. #define LCD ((LCD_TypeDef *) LCD_BASE)
  2428. #define TIM1 ((TIM1_TypeDef *) TIM1_BASE)
  2429. #define TIM2 ((TIM_TypeDef *) TIM2_BASE)
  2430. #define TIM3 ((TIM_TypeDef *) TIM3_BASE)
  2431. #define TIM4 ((TIM4_TypeDef *) TIM4_BASE)
  2432. #define TIM5 ((TIM_TypeDef *) TIM5_BASE)
  2433. #define IRTIM ((IRTIM_TypeDef *) IRTIM_BASE)
  2434. #define ITC ((ITC_TypeDef *) ITC_BASE)
  2435. #define DAC ((DAC_TypeDef *) DAC_BASE)
  2436. #define DMA1 ((DMA_TypeDef *) DMA1_BASE)
  2437. #define DMA1_Channel0 ((DMA_Channel_TypeDef *) DMA1_Channel0_BASE)
  2438. #define DMA1_Channel1 ((DMA_Channel_TypeDef *) DMA1_Channel1_BASE)
  2439. #define DMA1_Channel2 ((DMA_Channel_TypeDef *) DMA1_Channel2_BASE)
  2440. #define DMA1_Channel3 ((DMA_Channel_TypeDef *) DMA1_Channel3_BASE)
  2441. #define DM ((DM_TypeDef *) DM_BASE)
  2442. #define RI ((RI_TypeDef *) RI_BASE)
  2443. #define COMP ((COMP_TypeDef *) COMP_BASE)
  2444. #define AES ((AES_TypeDef *) AES_BASE)
  2445. #define ADC1 ((ADC_TypeDef *) ADC1_BASE)
  2446. #define CFG ((CFG_TypeDef *) CFG_BASE)
  2447. #define OPT ((OPT_TypeDef *) OPT_BASE)
  2448. #ifdef USE_STDPERIPH_DRIVER
  2449. #include "stm8l15x_conf.h"
  2450. #endif
  2451. /* Exported macro --------------------------------------------------------------*/
  2452. /*============================== Interrupts ====================================*/
  2453. #ifdef _RAISONANCE_
  2454. #include <intrist7.h>
  2455. #define enableInterrupts() _rim_() /*!<enable interrupts */
  2456. #define disableInterrupts() _sim_() /*!<disable interrupts */
  2457. #define rim() _rim_() /*!<enable interrupts */
  2458. #define sim() _sim_() /*!<disable interrupts */
  2459. #define nop() _nop_() /*!<No Operation */
  2460. #define trap() _trap_() /*!<Trap (soft IT) */
  2461. #define wfi() _wfi_() /*!<Wait For Interrupt */
  2462. #define wfe() _wfe_() /*!<Wait For Interrupt */
  2463. #define halt() _halt_() /*!<Halt */
  2464. #elif defined(_COSMIC_)
  2465. #define enableInterrupts() {_asm("rim\n");} /*!<enable interrupts */
  2466. #define disableInterrupts() {_asm("sim\n");} /*!<disable interrupts */
  2467. #define rim() {_asm("rim\n");} /*!<enable interrupts */
  2468. #define sim() {_asm("sim\n");} /*!<disable interrupts */
  2469. #define nop() {_asm("nop\n");} /*!<No Operation */
  2470. #define trap() {_asm("trap\n");} /*!<Trap (soft IT) */
  2471. #define wfi() {_asm("wfi\n");} /*!<Wait For Interrupt */
  2472. #define wfe() {_asm("wfe\n");} /*!<Wait for event */
  2473. #define halt() {_asm("halt\n");} /*!<Halt */
  2474. #else /*_IAR*/
  2475. #include <intrinsics.h>
  2476. #define enableInterrupts() __enable_interrupt() /* enable interrupts */
  2477. #define disableInterrupts() __disable_interrupt() /* disable interrupts */
  2478. #define rim() __enable_interrupt() /* enable interrupts */
  2479. #define sim() __disable_interrupt() /* disable interrupts */
  2480. #define nop() __no_operation() /* No Operation */
  2481. #define trap() __trap() /* Trap (soft IT) */
  2482. #define wfi() __wait_for_interrupt() /* Wait For Interrupt */
  2483. #define wfe() __wait_for_event(); /* Wait for event */
  2484. #define halt() __halt() /* Halt */
  2485. #endif /* _RAISONANCE_ */
  2486. /*============================== Interrupt vector Handling ========================*/
  2487. #ifdef _COSMIC_
  2488. #define INTERRUPT_HANDLER(a,b) @far @interrupt void a(void)
  2489. #define INTERRUPT_HANDLER_TRAP(a) void @far @interrupt a(void)
  2490. #endif /* _COSMIC_ */
  2491. #ifdef _RAISONANCE_
  2492. #define INTERRUPT_HANDLER(a,b) void a(void) interrupt b
  2493. #define INTERRUPT_HANDLER_TRAP(a) void a(void) trap
  2494. #endif /* _RAISONANCE_ */
  2495. #ifdef _IAR_
  2496. #define STRINGVECTOR(x) #x
  2497. #define VECTOR_ID(x) STRINGVECTOR( vector = (x) )
  2498. #define INTERRUPT_HANDLER( a, b ) \
  2499. _Pragma( VECTOR_ID( (b)+2 ) ) \
  2500. __interrupt void (a)( void )
  2501. #define INTERRUPT_HANDLER_TRAP(a) \
  2502. _Pragma( VECTOR_ID( 1 ) ) \
  2503. __interrupt void (a) (void)
  2504. #endif /* _IAR_ */
  2505. /*============================== Interrupt Handler declaration ========================*/
  2506. #ifdef _COSMIC_
  2507. #define INTERRUPT @far @interrupt
  2508. #elif defined(_IAR_)
  2509. #define INTERRUPT __interrupt
  2510. #endif /* _COSMIC_ */
  2511. /*============================== Handling bits ====================================*/
  2512. /*-----------------------------------------------------------------------------
  2513. Method : I
  2514. Description : Handle the bit from the character variables.
  2515. Comments : The different parameters of commands are
  2516. - VAR : Name of the character variable where the bit is located.
  2517. - Place : Bit position in the variable (7 6 5 4 3 2 1 0)
  2518. - Value : Can be 0 (reset bit) or not 0 (set bit)
  2519. The "MskBit" command allows to select some bits in a source
  2520. variables and copy it in a destination var (return the value).
  2521. The "ValBit" command returns the value of a bit in a char
  2522. variable: the bit is reset if it returns 0 else the bit is set.
  2523. This method generates not an optimised code yet.
  2524. -----------------------------------------------------------------------------*/
  2525. #define SetBit(VAR,Place) ( (VAR) |= (uint8_t)((uint8_t)1<<(uint8_t)(Place)) )
  2526. #define ClrBit(VAR,Place) ( (VAR) &= (uint8_t)((uint8_t)((uint8_t)1<<(uint8_t)(Place))^(uint8_t)255) )
  2527. #define ChgBit(VAR,Place) ( (VAR) ^= (uint8_t)((uint8_t)1<<(uint8_t)(Place)) )
  2528. #define AffBit(VAR,Place,Value) ((Value) ? \
  2529. ((VAR) |= ((uint8_t)1<<(Place))) : \
  2530. ((VAR) &= (((uint8_t)1<<(Place))^(uint8_t)255)))
  2531. #define MskBit(Dest,Msk,Src) ( (Dest) = ((Msk) & (Src)) | ((~(Msk)) & (Dest)) )
  2532. #define ValBit(VAR,Place) ((uint8_t)(VAR) & (uint8_t)((uint8_t)1<<(uint8_t)(Place)))
  2533. #define BYTE_0(n) ((uint8_t)((n) & (uint8_t)0xFF)) /*!< Returns the low byte of the 32-bit value */
  2534. #define BYTE_1(n) ((uint8_t)(BYTE_0((n) >> (uint8_t)8))) /*!< Returns the second byte of the 32-bit value */
  2535. #define BYTE_2(n) ((uint8_t)(BYTE_0((n) >> (uint8_t)16))) /*!< Returns the third byte of the 32-bit value */
  2536. #define BYTE_3(n) ((uint8_t)(BYTE_0((n) >> (uint8_t)24))) /*!< Returns the high byte of the 32-bit value */
  2537. /*============================== Assert Macros ====================================*/
  2538. #define IS_STATE_VALUE(STATE) \
  2539. (((STATE) == SET) || \
  2540. ((STATE) == RESET))
  2541. /*-----------------------------------------------------------------------------
  2542. Method : II
  2543. Description : Handle directly the bit.
  2544. Comments : The idea is to handle directly with the bit name. For that, it is
  2545. necessary to have RAM area descriptions (example: HW register...)
  2546. and the following command line for each area.
  2547. This method generates the most optimized code.
  2548. -----------------------------------------------------------------------------*/
  2549. #define AREA 0x00 /* The area of bits begins at address 0x10. */
  2550. #define BitClr(BIT) ( *((unsigned char *) (AREA+(BIT)/8)) &= (~(1<<(7-(BIT)%8))) )
  2551. #define BitSet(BIT) ( *((unsigned char *) (AREA+(BIT)/8)) |= (1<<(7-(BIT)%8)) )
  2552. #define BitVal(BIT) ( *((unsigned char *) (AREA+(BIT)/8)) & (1<<(7-(BIT)%8)) )
  2553. #endif /* __STM8L15x_H */
  2554. /**
  2555. * @}
  2556. */
  2557. /**
  2558. * @}
  2559. */
  2560. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/