driver_com.h 69 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287
  1. /*
  2. * @File name : driver_com.h
  3. * @Author : Bluetrum IOT Team
  4. * @Date : 2023-02-10
  5. * @Description : AB202X Device Peripheral Access Layer Header File.
  6. * This file contains all the peripheral register's definitions, bits
  7. * definitions and memory mapping for AB202X devices.
  8. *
  9. * Copyright (c) by Bluetrum, All Rights Reserved.
  10. */
  11. #ifndef _DRIVER_COM_H
  12. #define _DRIVER_COM_H
  13. #include "global.h"
  14. #include "api.h"
  15. #include "driver_clk.h"
  16. typedef enum {DISABLE = 0, ENABLE = !DISABLE} FUNCTIONAL_STATE;
  17. typedef enum {RESET = 0, SET = !RESET} FLAG_STATE, IT_STATE;
  18. typedef enum {FAILED = 0, SUCCESS = !FAILED} STATUS_STATE;
  19. //--------------------------- SFR BASE DECLARATION ---------------------------//
  20. #define SFR0_BASE (SFR_BASE + 0x000)
  21. #define SFR1_BASE (SFR_BASE + 0x100)
  22. #define SFR2_BASE (SFR_BASE + 0x200)
  23. #define SFR3_BASE (SFR_BASE + 0x300)
  24. #define SFR4_BASE (SFR_BASE + 0x400)
  25. #define SFR5_BASE (SFR_BASE + 0x500)
  26. #define SFR6_BASE (SFR_BASE + 0x600)
  27. #define SFR7_BASE (SFR_BASE + 0x700)
  28. #define SFR8_BASE (SFR_BASE + 0x800)
  29. #define SFR9_BASE (SFR_BASE + 0x900)
  30. #define SFR10_BASE (SFR_BASE + 0xa00)
  31. #define SFR11_BASE (SFR_BASE + 0xb00)
  32. #define SFR12_BASE (SFR_BASE + 0xc00)
  33. #define SFR13_BASE (SFR_BASE + 0xd00)
  34. #define SFR14_BASE (SFR_BASE + 0xe00)
  35. #define SFR15_BASE (SFR_BASE + 0xf00)
  36. //-------------------------------- SFR Group0 --------------------------------//
  37. #define TICK0_BASE (SFR0_BASE + 0x01*4)
  38. #define TICK1_BASE (SFR0_BASE + 0x05*4)
  39. #define UART0_BASE (SFR0_BASE + 0x10*4)
  40. #define TMR0_BASE (SFR0_BASE + 0x14*4)
  41. #define WDT_BASE (SFR0_BASE + 0x1a*4)
  42. #define SD0_BASE (SFR0_BASE + 0x20*4)
  43. #define SPI0_BASE (SFR0_BASE + 0x2a*4)
  44. #define UART1_BASE (SFR0_BASE + 0x30*4)
  45. #define TMR1_BASE (SFR0_BASE + 0x35*4)
  46. #define TMR2_BASE (SFR0_BASE + 0x3a*4)
  47. //---------------------------------- SFR Group1 -----------------------------------//
  48. //---------------------------------- SFR Group3 -----------------------------------//
  49. #define HSUART_BASE (SFR3_BASE + 0x30*4)
  50. //---------------------------------- SFR Group4 -----------------------------------//
  51. //---------------------------------- SFR Group5 -----------------------------------//
  52. #define IIC_BASE (SFR5_BASE + 0x07*4)
  53. #define SARADC_BASE (SFR5_BASE + 0x20*4)
  54. //---------------------------------- SFR Group6 -----------------------------------//
  55. #define GPIOA_BASE (SFR6_BASE + 0x00*4)
  56. #define GPIOB_BASE (SFR6_BASE + 0x10*4)
  57. #define FUNCMCON_BASE (SFR6_BASE + 0x30*4)
  58. //---------------------------------- SFR Group7 -----------------------------------//
  59. #define GPIOG_BASE (SFR7_BASE + 0x00*4)
  60. #define IRTX_BASE (SFR7_BASE + 0x20*4)
  61. #define IRRX_BASE (SFR7_BASE + 0x2f*4)
  62. //---------------------------------- SFR Group8 -----------------------------------//
  63. #define KEYSCAN_BASE (SFR8_BASE + 0x00*4)
  64. //---------------------------------- SFR Group9 -----------------------------------//
  65. #define TMR3_BASE (SFR9_BASE + 0x00*4)
  66. #define UDET_BASE (SFR9_BASE + 0x18*4)
  67. #define SPI1_BASE (SFR9_BASE + 0x20*4)
  68. //---------------------------------- SFR Group10 -----------------------------------//
  69. #define TOUCH_KEY_BASE (SFR10_BASE + 0x02*4)
  70. //---------------------------------- SFR Group12 -----------------------------------//
  71. #define TIM_BASE (SFR12_BASE + 0x00*4)
  72. #define LEDC_BASE (SFR12_BASE + 0x30*4)
  73. //---------------------------------- SFR Group13 -----------------------------------//
  74. #define SDADC_BASE (SFR13_BASE + 0x09*4)
  75. #define SDDAC_BASE (SFR13_BASE + 0x13*4)
  76. #define LPWM_BASE (SFR13_BASE + 0x20*4)
  77. /**
  78. * @brief PERIPHERAL DECLARATION
  79. */
  80. #define GPIOA_REG ((gpio_typedef *) GPIOA_BASE)
  81. #define GPIOB_REG ((gpio_typedef *) GPIOB_BASE)
  82. #define FUNCMAP ((func_map_typedef *) FUNCMCON_BASE)
  83. #define TMR0 ((tmr_typedef *) TMR0_BASE)
  84. #define TMR1 ((tmr_typedef *) TMR1_BASE)
  85. #define TMR2 ((tmr_typedef *) TMR2_BASE)
  86. #define TMR3 ((tmr_typedef *) TMR3_BASE)
  87. #define TIM1 ((tim_typedef *) TIM_BASE)
  88. #define UART ((uart_typedef *) UART0_BASE)
  89. #define UDET ((uart_typedef *) UDET_BASE)
  90. #define HSUART ((hsuart_typedef *) HSUART_BASE)
  91. #define IIC ((iic_typedef *) IIC_BASE)
  92. #define SPI0 ((spi_typedef *) SPI0_BASE)
  93. #define SPI1 ((spi_typedef *) SPI1_BASE)
  94. #define WDT ((wdt_typedef *) WDT_BASE)
  95. #define SARADC ((sadc_typedef *) SARADC_BASE)
  96. #define LPWM ((lpwm_typedef *) LPWM_BASE)
  97. #define KEYSCAN ((keyscan_typedef *) KEYSCAN_BASE)
  98. #define IRTX ((irtx_typedef *) IRTX_BASE)
  99. #define IRRX ((irrx_typedef *) IRRX_BASE)
  100. #define TOUCH_KEY ((touch_key_typedef *) TOUCH_KEY_BASE)
  101. #define SDADC ((sdadc_typedef *) SDADC_BASE)
  102. #define SDDAC ((sddac_typedef *) SDDAC_BASE)
  103. #define LEDC ((ledc_typedef *) LEDC_BASE)
  104. #define TICK ((tick_typedef *) TICK0_BASE)
  105. /*---------------------------------------------------------------------------------*/
  106. /* TMR */
  107. /*---------------------------------------------------------------------------------*/
  108. /******************** Bit definition for TMR[0.1.2]CON register ********************/
  109. #define TMRxCON_TMREN ((uint32_t)0x00000001)
  110. #define TMRxCON_INCSEL ((uint32_t)0x0000000c)
  111. #define TMRxCON_INCSEL_0 ((uint32_t)0x00000004)
  112. #define TMRxCON_INCSEL_1 ((uint32_t)0x00000008)
  113. #define TMRxCON_INCSRC ((uint32_t)0x00000040)
  114. #define TMRxCON_TIE ((uint32_t)0x00000080)
  115. #define TMRxCON_TPND ((uint32_t)0x00000200)
  116. /*********************** Bit definition for TMR3CON register ***********************/
  117. #define TMR3CON_TMREN ((uint32_t)0x00000001)
  118. #define TMR3CON_CPTEN ((uint32_t)0x00000002)
  119. #define TMR3CON_INCSEL ((uint32_t)0x0000000c)
  120. #define TMR3CON_INCSEL_0 ((uint32_t)0x00000004)
  121. #define TMR3CON_INCSEL_1 ((uint32_t)0x00000008)
  122. #define TMR3CON_CPTEDSEL ((uint32_t)0x00000030)
  123. #define TMR3CON_CPTEDSEL_0 ((uint32_t)0x00000010)
  124. #define TMR3CON_CPTEDSEL_1 ((uint32_t)0x00000020)
  125. #define TMR3CON_INCSRC ((uint32_t)0x00000040)
  126. #define TMR3CON_TIE ((uint32_t)0x00000080)
  127. #define TMR3CON_CIE ((uint32_t)0x00000100)
  128. #define TMR3CON_PWM0EN ((uint32_t)0x00000200)
  129. #define TMR3CON_PWM1EN ((uint32_t)0x00000400)
  130. #define TMR3CON_PWM2EN ((uint32_t)0x00000800)
  131. #define TMR3CON_TIMS ((uint32_t)0x00001000)
  132. #define TMR3CON_TIS ((uint32_t)0x00002000)
  133. #define TMR3CON_CPT_CLREN ((uint32_t)0x00004000)
  134. #define TMR3CON_CPT_FLTEN ((uint32_t)0x00008000)
  135. #define TMR3CON_TPND ((uint32_t)0x00010000)
  136. #define TMR3CON_CPND ((uint32_t)0x00020000)
  137. /******************** Bit definition for TMR[0.1.2]CPND register *******************/
  138. #define TMRxCPND_TPCLR ((uint32_t)0x00000200)
  139. /*********************** Bit definition for TMR3CPND register **********************/
  140. #define TMR3CPND_TPCLR ((uint32_t)0x00010000)
  141. #define TMR3CPND_CPCLR ((uint32_t)0x00020000)
  142. /*---------------------------------------------------------------------------------*/
  143. /* UART */
  144. /*---------------------------------------------------------------------------------*/
  145. /*********************** Bit definition for UARTxCON register **********************/
  146. #define UARTxCON_UTEN ((uint32_t)0x00000001)
  147. #define UARTxCON_BIT9EN ((uint32_t)0x00000002)
  148. #define UARTxCON_RXIE ((uint32_t)0x00000004)
  149. #define UARTxCON_TXIE ((uint32_t)0x00000008)
  150. #define UARTxCON_SB2EN ((uint32_t)0x00000010)
  151. #define UARTxCON_CLKSRC ((uint32_t)0x00000020)
  152. /* UDETCON Register */
  153. #define UARTxCON_FIXBAUD ((uint32_t)0x00000020)
  154. #define UARTxCON_ONELINE ((uint32_t)0x00000040)
  155. #define UARTxCON_RXEN ((uint32_t)0x00000080)
  156. #define UARTxCON_TXPND ((uint32_t)0x00000100)
  157. #define UARTxCON_RXPND ((uint32_t)0x00000200)
  158. #define UARTxCON_RX4BUFEN ((uint32_t)0x00000400)
  159. /* UDETCON Register */
  160. #define UARTxCON_KEYMAT ((uint32_t)0x00000400)
  161. #define UARTxCON_RXBCNT ((uint32_t)0x00003800)
  162. #define UARTxCON_RXBCNT_0 ((uint32_t)0x00000800)
  163. #define UARTxCON_RXBCNT_1 ((uint32_t)0x00001000)
  164. #define UARTxCON_RXBCNT_2 ((uint32_t)0x00002000)
  165. #define UARTxCON_RX4BUFPND ((uint32_t)0x00004000)
  166. #define UARTxCON_RX4BUFERROR ((uint32_t)0x00008000)
  167. /*********************** Bit definition for UARTxCPND register *********************/
  168. #define UARTxCPND_ALL ((uint32_t)0x00038300)
  169. #define UARTxCPND_CTXPND ((uint32_t)0x00000100)
  170. #define UARTxCPND_CRXPND ((uint32_t)0x00000200)
  171. /* UDETCPND Register */
  172. #define UARTxCPND_CKEYMAT ((uint32_t)0x00000400)
  173. #define UARTxCPND_RX4BUF_ERR_CLR ((uint32_t)0x00008000)
  174. #define UARTxCPND_CKEYPND ((uint32_t)0x00010000)
  175. #define UARTxCPND_CRSTKEYPND ((uint32_t)0x00020000)
  176. /* UDETCPND Register */
  177. #define UARTxCPND_CBDCFM ((uint32_t)0x00040000)
  178. /*---------------------------------------------------------------------------------*/
  179. /* HUART */
  180. /*---------------------------------------------------------------------------------*/
  181. /*********************** Bit definition for HSUT0CON register **********************/
  182. #define HSUT0CON_URXEN ((uint32_t)0x00000001)
  183. #define HSUT0CON_UTXEN ((uint32_t)0x00000002)
  184. #define HSUT0CON_RXIE ((uint32_t)0x00000004)
  185. #define HSUT0CON_TXIE ((uint32_t)0x00000008)
  186. #define HSUT0CON_RXTRSMODE ((uint32_t)0x00000010)
  187. #define HSUT0CON_RXBITSEL ((uint32_t)0x00000020)
  188. #define HSUT0CON_RXLPBUFEN ((uint32_t)0x00000040)
  189. #define HSUT0CON_TXTRSMODE ((uint32_t)0x00000080)
  190. #define HSUT0CON_TXBITSEL ((uint32_t)0x00000100)
  191. #define HSUT0CON_SPBITSEL ((uint32_t)0x00000200)
  192. #define HSUT0CON_HSUTTMREN ((uint32_t)0x00000400)
  193. #define HSUT0CON_RXHF_PND ((uint32_t)0x00000800)
  194. #define HSUT0CON_RXPND ((uint32_t)0x00001000)
  195. #define HSUT0CON_TXPND ((uint32_t)0x00002000)
  196. #define HSUT0CON_RXFAIL ((uint32_t)0x00004000)
  197. #define HSUT0CON_TMROV ((uint32_t)0x00008000)
  198. #define HSUT0CON_RXOVE_PND ((uint32_t)0x00010000)
  199. #define HSUT0CON_RXHF_IE ((uint32_t)0x00020000)
  200. #define HSUT0CON_ONELINE ((uint32_t)0x00040000)
  201. /*********************** Bit definition for HSUT0CPND register *********************/
  202. #define HSUT0CPND_CUTRX ((uint32_t)0x00000001)
  203. #define HSUT0CPND_CUTTX ((uint32_t)0x00000002)
  204. #define HSUT0CPND_CCTSPND ((uint32_t)0x00000400)
  205. #define HSUT0CPND_CRXHFPND ((uint32_t)0x00000800)
  206. #define HSUT0CPND_CRXPND ((uint32_t)0x00001000)
  207. #define HSUT0CPND_CTXPND ((uint32_t)0x00002000)
  208. #define HSUT0CPND_CRXFAIL ((uint32_t)0x00004000)
  209. #define HSUT0CPND_CTMROV ((uint32_t)0x00008000)
  210. #define HSUT0CPND_CRXOVEPND ((uint32_t)0x00010000)
  211. #define HSUT0CPND_CRXLBBUF ((uint32_t)0x00020000)
  212. /*********************** Bit definition for HSUT0FCCON register ********************/
  213. #define HSUT0CCON_UCTS_EN ((uint32_t)0x00000001)
  214. #define HSUT0CCON_URTS_EN ((uint32_t)0x00000002)
  215. #define HSUT0CCON_CTSIE ((uint32_t)0x00000004)
  216. #define HSUT0CCON_RTS_MODE ((uint32_t)0x00000008)
  217. #define HSUT0CCON_CTSPND ((uint32_t)0x00000010)
  218. #define HSUT0CCON_CTSS ((uint32_t)0x00000020)
  219. #define HSUT0CCON_RTSS ((uint32_t)0x00000040)
  220. #define HSUT0CCON_RTS_SW ((uint32_t)0x00000080)
  221. /*---------------------------------------------------------------------------------*/
  222. /* IIC */
  223. /*---------------------------------------------------------------------------------*/
  224. /************************ Bit definition for IICCON0 register **********************/
  225. #define IICCON0_DONE ((uint32_t)0x80000000)
  226. #define IICCON0_ACKSTATUS ((uint32_t)0x40000000)
  227. #define IICCON0_CLR_DONE ((uint32_t)0x20000000)
  228. #define IICCON0_KS ((uint32_t)0x10000000)
  229. #define IICCON0_CLR_ALL ((uint32_t)0x08000000)
  230. #define IICCON0_RX_NACK_EN ((uint32_t)0x00004000)
  231. #define IICCON0_SMP_SEL ((uint32_t)0x00002000)
  232. #define IICCON0_MODE ((uint32_t)0x00001000)
  233. #define IICCON0_POSDIV ((uint32_t)0x000003f0)
  234. #define IICCON0_HOLDCNT ((uint32_t)0x0000000c)
  235. #define IICCON0_INTEN ((uint32_t)0x00000002)
  236. #define IICCON0_IICEN ((uint32_t)0x00000001)
  237. /************************ Bit definition for IICCON1 register **********************/
  238. #define IICCON1_DATA_CNT ((uint32_t)0x00000007)
  239. #define IICCON1_START0_EN ((uint32_t)0x00000008)
  240. #define IICCON1_CTL0_EN ((uint32_t)0x00000010)
  241. #define IICCON1_ADR0_EN ((uint32_t)0x00000020)
  242. #define IICCON1_ADR1_EN ((uint32_t)0x00000040)
  243. #define IICCON1_START1_EN ((uint32_t)0x00000080)
  244. #define IICCON1_CTL1_EN ((uint32_t)0x00000100)
  245. #define IICCON1_RDAT_EN ((uint32_t)0x00000200)
  246. #define IICCON1_WDAT_EN ((uint32_t)0x00000400)
  247. #define IICCON1_STOP_EN ((uint32_t)0x00000800)
  248. #define IICCON1_TXNAK_EN ((uint32_t)0x00001000)
  249. /************************ Bit definition for IICSSTS register **********************/
  250. #define IICSSTS_RXVLD ((uint32_t)0x00000001)
  251. #define IICSSTS_TXVLD ((uint32_t)0x00000002)
  252. #define IICSSTS_START ((uint32_t)0x00000004)
  253. #define IICSSTS_RESTART ((uint32_t)0x00000008)
  254. #define IICSSTS_STOP ((uint32_t)0x00000010)
  255. #define IICSSTS_SRX ((uint32_t)0x00000020)
  256. #define IICSSTS_STX ((uint32_t)0x00000040)
  257. #define IICSSTS_DATA_CNT ((uint32_t)0x00000700)
  258. #define IICSSTS_RXVLD_SET ((uint32_t)0x00010000)
  259. #define IICSSTS_TXVLD_SET ((uint32_t)0x00020000)
  260. #define IICSSTS_START_CLR ((uint32_t)0x00040000)
  261. #define IICSSTS_RESTART_CLR ((uint32_t)0x00080000)
  262. #define IICSSTS_STOP_CLR ((uint32_t)0x00100000)
  263. /*---------------------------------------------------------------------------------*/
  264. /* RTC */
  265. /*---------------------------------------------------------------------------------*/
  266. /************************ Bit definition for RTCCON register ***********************/
  267. #define RTCCON_VRTCVSEL ((uint32_t)0x00000001)
  268. #define RTCCON_BAUDSEL ((uint32_t)0x00000006)
  269. #define RTCCON_RTC1SIE ((uint32_t)0x00000008)
  270. #define RTCCON_ALMIE ((uint32_t)0x00000010)
  271. #define RTCCON_WKUPRSTEN ((uint32_t)0x00000020)
  272. #define RTCCON_VUSBRSTEN ((uint32_t)0x00000040)
  273. #define RTCCON_RTC_WKSLPEN ((uint32_t)0x00000080)
  274. #define RTCCON_ALM_WKEN ((uint32_t)0x00000100)
  275. #define RTCCON_VUSBON_WKSLPEN ((uint32_t)0x00000200)
  276. #define RTCCON_INBOX_WKSLPEN ((uint32_t)0x00000400)
  277. #define RTCCON_VUSBONIE ((uint32_t)0x00000800)
  278. #define RTCCON_INBOXIE ((uint32_t)0x00001000)
  279. #define RTCCON_RTC_ON ((uint32_t)0x00010000)
  280. #define RTCCON_ALMPND ((uint32_t)0x00020000)
  281. #define RTCCON_RTCWKSLPPND ((uint32_t)0x00040000)
  282. #define RTCCON_RTCWKP ((uint32_t)0x00080000)
  283. #define RTCCON_VUSBONLINE ((uint32_t)0x00100000)
  284. #define RTCCON_VUSBOFF ((uint32_t)0x00200000)
  285. #define RTCCON_INBOX ((uint32_t)0x00400000)
  286. /************************ Bit definition for RTCCPND register **********************/
  287. #define RTCCPND_TKTSOE ((uint32_t)0x00000003)
  288. #define RTCCPND_CALMPND ((uint32_t)0x00020000)
  289. #define RTCCPND_CWKSLPPND ((uint32_t)0x00040000)
  290. #define RTCCPND_VBCNTDIS ((uint32_t)0x30000000)
  291. #define RTCCPND_VBCNTKST ((uint32_t)0x40000000)
  292. #define RTCCPND_VBCNTCLR ((uint32_t)0x80000000)
  293. /************************ Bit definition for RTCCON11 register *********************/
  294. #define RTCCON11_RTCWKSLPEN ((uint32_t)0x00000400)
  295. /*---------------------------------------------------------------------------------*/
  296. /* SPI */
  297. /*---------------------------------------------------------------------------------*/
  298. /************************ Bit definition for SPIxCON register **********************/
  299. #define SPIxCON_SPIEN ((uint32_t)0x00000001)
  300. #define SPIxCON_SPISM ((uint32_t)0x00000002)
  301. #define SPIxCON_BUSMODE ((uint32_t)0x0000000c)
  302. #define SPIxCON_BUSMODE_0 ((uint32_t)0x00000004)
  303. #define SPIxCON_BUSMODE_1 ((uint32_t)0x00000008)
  304. #define SPIxCON_SPISEL ((uint32_t)0x00000010)
  305. #define SPIxCON_CLKIDS ((uint32_t)0x00000020)
  306. #define SPIxCON_SMPS ((uint32_t)0x00000040)
  307. #define SPIxCON_SPIIE ((uint32_t)0x00000080)
  308. #define SPIxCON_SPILF_EN ((uint32_t)0x00000100)
  309. #define SPIxCON_SPIMBEN ((uint32_t)0x00000200)
  310. #define SPIxCON_SPIOSS ((uint32_t)0x00000400)
  311. #define SPIxCON_HOLDENRX ((uint32_t)0x00000800)
  312. #define SPIxCON_HOLDENTX ((uint32_t)0x00001000)
  313. #define SPIxCON_HOLDENSW ((uint32_t)0x00002000)
  314. #define SPIxCON_SPIPND ((uint32_t)0x00010000)
  315. /*---------------------------------------------------------------------------------*/
  316. /* WDT */
  317. /*---------------------------------------------------------------------------------*/
  318. /************************ Bit definition for WDTCON register ***********************/
  319. #define WDTCON_WDTCLR ((uint32_t)0x0000000f)
  320. #define WDTCON_WDTCLR_0 ((uint32_t)0x00000001)
  321. #define WDTCON_WDTCLR_1 ((uint32_t)0x00000002)
  322. #define WDTCON_WDTCLR_2 ((uint32_t)0x00000004)
  323. #define WDTCON_WDTCLR_3 ((uint32_t)0x00000008)
  324. #define WDTCON_WDTEN_WR ((uint32_t)0x000000f0)
  325. #define WDTCON_WDTEN_WR_0 ((uint32_t)0x00000010)
  326. #define WDTCON_WDTEN_WR_1 ((uint32_t)0x00000020)
  327. #define WDTCON_WDTEN_WR_2 ((uint32_t)0x00000040)
  328. #define WDTCON_WDTEN_WR_3 ((uint32_t)0x00000080)
  329. #define WDTCON_RSTEN_WR ((uint32_t)0x00000f00)
  330. #define WDTCON_RSTEN_WR_0 ((uint32_t)0x00000100)
  331. #define WDTCON_RSTEN_WR_1 ((uint32_t)0x00000200)
  332. #define WDTCON_RSTEN_WR_2 ((uint32_t)0x00000400)
  333. #define WDTCON_RSTEN_WR_3 ((uint32_t)0x00000800)
  334. #define WDTCON_WDTIE_WR ((uint32_t)0x0000f000)
  335. #define WDTCON_WDTIE_WR_0 ((uint32_t)0x00001000)
  336. #define WDTCON_WDTIE_WR_1 ((uint32_t)0x00002000)
  337. #define WDTCON_WDTIE_WR_2 ((uint32_t)0x00004000)
  338. #define WDTCON_WDTIE_WR_3 ((uint32_t)0x00008000)
  339. #define WDTCON_WDTCSEL_WR ((uint32_t)0x000f0000)
  340. #define WDTCON_WDTCSEL_WR_0 ((uint32_t)0x00010000)
  341. #define WDTCON_WDTCSEL_WR_1 ((uint32_t)0x00020000)
  342. #define WDTCON_WDTCSEL_WR_2 ((uint32_t)0x00040000)
  343. #define WDTCON_WDTCSEL_WR_3 ((uint32_t)0x00080000)
  344. #define WDTCON_TMRSEL ((uint32_t)0x00700000)
  345. #define WDTCON_TMRSEL_0 ((uint32_t)0x00100000)
  346. #define WDTCON_TMRSEL_1 ((uint32_t)0x00200000)
  347. #define WDTCON_TMRSEL_2 ((uint32_t)0x00400000)
  348. #define WDTCON_TMRSEL_WR ((uint32_t)0x0f000000)
  349. #define WDTCON_TMRSEL_WR_0 ((uint32_t)0x01000000)
  350. #define WDTCON_TMRSEL_WR_1 ((uint32_t)0x02000000)
  351. #define WDTCON_TMRSEL_WR_2 ((uint32_t)0x04000000)
  352. #define WDTCON_TMRSEL_WR_3 ((uint32_t)0x08000000)
  353. #define WDTCON_WDTPND ((uint32_t)0x80000000)
  354. /*---------------------------------------------------------------------------------*/
  355. /* SARADC */
  356. /*---------------------------------------------------------------------------------*/
  357. /************************ Bit definition for SADCCON register **********************/
  358. #define SADCCON_CH0PUEN ((uint32_t)0x00000001)
  359. #define SADCCON_CH1PUEN ((uint32_t)0x00000002)
  360. #define SADCCON_CH2PUEN ((uint32_t)0x00000004)
  361. #define SADCCON_CH3PUEN ((uint32_t)0x00000008)
  362. #define SADCCON_CH4PUEN ((uint32_t)0x00000010)
  363. #define SADCCON_CH5PUEN ((uint32_t)0x00000020)
  364. #define SADCCON_CH6PUEN ((uint32_t)0x00000040)
  365. #define SADCCON_CH7PUEN ((uint32_t)0x00000080)
  366. #define SADCCON_CH8PUEN ((uint32_t)0x00000100)
  367. #define SADCCON_CH9PUEN ((uint32_t)0x00000200)
  368. #define SADCCON_CH10PUEN ((uint32_t)0x00000400)
  369. #define SADCCON_CH11PUEN ((uint32_t)0x00000800)
  370. #define SADCCON_CH12PUEN ((uint32_t)0x00001000)
  371. #define SADCCON_CH13PUEN ((uint32_t)0x00002000)
  372. #define SADCCON_CH14PUEN ((uint32_t)0x00004000)
  373. #define SADCCON_CH15PUEN ((uint32_t)0x00008000)
  374. #define SADCCON_ADCEN ((uint32_t)0x00010000)
  375. #define SADCCON_ADCIE ((uint32_t)0x00020000)
  376. #define SADCCON_ADCANGIOEN ((uint32_t)0x00040000)
  377. #define SADCCON_ADCAEN ((uint32_t)0x00080000)
  378. #define SADCCON_ADCMODE ((uint32_t)0x00100000)
  379. /*---------------------------------------------------------------------------------*/
  380. /* LPWM */
  381. /*---------------------------------------------------------------------------------*/
  382. /********************** Bit definition for LPWMSTCON register **********************/
  383. #define LPWMSTCON_LPWM_DIR ((uint32_t)0x00000800)
  384. #define LPWMSTCON_ST_DUTY ((uint32_t)0x000007fc)
  385. #define LPWMSTCON_ST_DUTY_0 ((uint32_t)0x00000004)
  386. #define LPWMSTCON_BREATH_MODE ((uint32_t)0x00000002)
  387. #define LPWMSTCON_LPWM_EN ((uint32_t)0x00000001)
  388. /********************** Bit definition for LPWMSWCON register **********************/
  389. #define LPWMSWCON_DUTY_ON ((uint32_t)0x000000ff)
  390. #define LPWMSWCON_DUTY_ON_0 ((uint32_t)0x00000001)
  391. /********************** Bit definition for LPWMCMCON register **********************/
  392. #define LPWMCMCON_SWT_CNTMAX ((uint32_t)0x00ff0000)
  393. #define LPWMCMCON_SWT_CNTMAX_0 ((uint32_t)0x00010000)
  394. #define LPWMCMCON_BRT_CNTMAX ((uint32_t)0x000001ff)
  395. #define LPWMCMCON_BRT_CNTMAX_0 ((uint32_t)0x00000001)
  396. /********************** Bit definition for LPWMxCON register ***********************/
  397. #define LPWMxCON_EN ((uint32_t)0x02000000)
  398. #define LPWMxCON_REPEAT ((uint32_t)0x01fe0000)
  399. #define LPWMxCON_REPEAT_0 ((uint32_t)0x00020000)
  400. #define LPWMxCON_STEP ((uint32_t)0x0001fe00)
  401. #define LPWMxCON_STEP_0 ((uint32_t)0x00000200)
  402. #define LPWMxCON_ST_DUTY ((uint32_t)0x000001ff)
  403. #define LPWMxCON_ST_DUTY_0 ((uint32_t)0x00000001)
  404. /********************** Bit definition for LPWMHLCON register **********************/
  405. #define LPWMHLCON_H_EN ((uint32_t)0x00200000)
  406. #define LPWMHLCON_L_EN ((uint32_t)0x00100000)
  407. #define LPWMHLCON_H_REPEAT ((uint32_t)0x000ffc00)
  408. #define LPWMHLCON_H_REPEAT_0 ((uint32_t)0x00000400)
  409. #define LPWMHLCON_L_REPEAT ((uint32_t)0x000003ff)
  410. #define LPWMHLCON_L_REPEAT_0 ((uint32_t)0x00000001)
  411. /*********************** Bit definition for LPWMPND register ***********************/
  412. #define LPWMPND_LPWM_PND ((uint32_t)0x00000001)
  413. /*---------------------------------------------------------------------------------*/
  414. /* KEYSCAN */
  415. /*---------------------------------------------------------------------------------*/
  416. /********************* Bit definition for KEYSCAN_CON0 register ********************/
  417. #define KEYSCAN_CON0_KEYVALID_PND ((uint32_t)0x80000000)
  418. #define KEYSCAN_CON0_KEYINVALID_PND ((uint32_t)0x40000000)
  419. #define KEYSCAN_CON0_KEYPORT_EN ((uint32_t)0x0000ff00)
  420. #define KEYSCAN_CON0_KEYPORT_EN_0 ((uint32_t)0x00000100)
  421. #define KEYSCAN_CON0_KEYSCAN_SWRSTN ((uint32_t)0x00000080)
  422. #define KEYSCAN_CON0_KEYINVALID_INT_EN ((uint32_t)0x00000020)
  423. #define KEYSCAN_CON0_KEYVALID_INT_EN ((uint32_t)0x00000010)
  424. #define KEYSCAN_CON0_KEYVALID_WKUP_EN ((uint32_t)0x00000008)
  425. #define KEYSCAN_CON0_KEYSCAN_LP ((uint32_t)0x00000004)
  426. #define KEYSCAN_CON0_KEYSCAN_MODE ((uint32_t)0x00000002)
  427. #define KEYSCAN_CON0_KEYSCAN_EN ((uint32_t)0x00000001)
  428. /********************* Bit definition for KEYSCAN_CON1 register ********************/
  429. #define KEYSCAN_CON1_KEYPORT_STAB_TIME ((uint32_t)0x00ff0000)
  430. #define KEYSCAN_CON1_KEYPORT_STAB_TIME_0 ((uint32_t)0x00010000)
  431. #define KEYSCAN_CON1_KEY_DEBO_TIMES ((uint32_t)0x0000ff00)
  432. #define KEYSCAN_CON1_KEY_DEBO_TIMES_0 ((uint32_t)0x00000100)
  433. #define KEYSCAN_CON1_KEY_WAIT_TIMES ((uint32_t)0x000000ff)
  434. #define KEYSCAN_CON1_KEY_WAIT_TIMES_0 ((uint32_t)0x00000001)
  435. /********************* Bit definition for KEYSCAN_CLR register *********************/
  436. #define KEYSCAN_CLR_KEYVALID_PND_CLR ((uint32_t)0x80000000)
  437. #define KEYSCAN_CLR_KEYINVALID_PND_CLR ((uint32_t)0x40000000)
  438. /********************* Bit definition for KEYSCAN_INFO0 register *******************/
  439. #define KEYSCAN_INFO0_KD7_KD0 ((uint32_t)0xff000000)
  440. #define KEYSCAN_INFO0_KD7_KD0_0 ((uint32_t)0x01000000)
  441. #define KEYSCAN_INFO0_KC7_KC0 ((uint32_t)0x00ff0000)
  442. #define KEYSCAN_INFO0_KC7_KC0_0 ((uint32_t)0x00010000)
  443. #define KEYSCAN_INFO0_KB7_KB0 ((uint32_t)0x0000ff00)
  444. #define KEYSCAN_INFO0_KB7_KB0_0 ((uint32_t)0x00000100)
  445. #define KEYSCAN_INFO0_KA7_KA0 ((uint32_t)0x000000ff)
  446. #define KEYSCAN_INFO0_KA7_KA0_0 ((uint32_t)0x00000001)
  447. /********************* Bit definition for KEYSCAN_INFO1 register *******************/
  448. #define KEYSCAN_INFO1_KH7_KH0 ((uint32_t)0xff000000)
  449. #define KEYSCAN_INFO1_KH7_KH0_0 ((uint32_t)0x01000000)
  450. #define KEYSCAN_INFO1_KG7_KG0 ((uint32_t)0x00ff0000)
  451. #define KEYSCAN_INFO1_KG7_KG0_0 ((uint32_t)0x00010000)
  452. #define KEYSCAN_INFO1_KF7_KF0 ((uint32_t)0x0000ff00)
  453. #define KEYSCAN_INFO1_KF7_KF0_0 ((uint32_t)0x00000100)
  454. #define KEYSCAN_INFO1_KE7_KE0 ((uint32_t)0x000000ff)
  455. #define KEYSCAN_INFO1_KE7_KE0_0 ((uint32_t)0x00000001)
  456. /********************* Bit definition for KEYSCAN_INFO2 register *******************/
  457. #define KEYSCAN_INFO2_KI7_KI0 ((uint32_t)0x0000ff00)
  458. #define KEYSCAN_INFO2_KI7_KI0_0 ((uint32_t)0x00000100)
  459. #define KEYSCAN_INFO2_KJ7_KJ0 ((uint32_t)0x000000ff)
  460. #define KEYSCAN_INFO2_KJ7_KJ0_0 ((uint32_t)0x00000001)
  461. /*---------------------------------------------------------------------------------*/
  462. /* SDADC */
  463. /*---------------------------------------------------------------------------------*/
  464. /*********************** Bit definition for SDADC_CON register *********************/
  465. #define SDADC_CON_GET_DC_FLAG ((uint32_t)0x80000000)
  466. #define SDADC_CON_PHT_SP_SEL ((uint32_t)0x00008000)
  467. #define SDADC_CON_ADC_SP_SEL ((uint32_t)0x00004000)
  468. #define SDADC_CON_RMDC_FILTER_SEL ((uint32_t)0x00001000)
  469. #define SDADC_CON_GETDC_SEL ((uint32_t)0x00000c00)
  470. #define SDADC_CON_GETDC_SEL_0 ((uint32_t)0x00000400)
  471. #define SDADC_CON_GETDC_SEL_1 ((uint32_t)0x00000800)
  472. #define SDADC_CON_RMDC_SEL ((uint32_t)0x00000300)
  473. #define SDADC_CON_RMDC_SEL_0 ((uint32_t)0x00000100)
  474. #define SDADC_CON_RMDC_SEL_1 ((uint32_t)0x00000200)
  475. #define SDADC_CON_SW_DC_EN ((uint32_t)0x00000080)
  476. #define SDADC_CON_GETDC_EN ((uint32_t)0x00000040)
  477. #define SDADC_CON_RMDC_EN ((uint32_t)0x00000020)
  478. #define SDADC_CON_GAIN_EN ((uint32_t)0x00000010)
  479. #define SDADC_CON_FSOUT_SEL ((uint32_t)0x0000000e)
  480. #define SDADC_CON_FSOUT_SEL_0 ((uint32_t)0x00000002)
  481. #define SDADC_CON_FSOUT_SEL_1 ((uint32_t)0x00000004)
  482. #define SDADC_CON_FSOUT_SEL_2 ((uint32_t)0x00000008)
  483. #define SDADC_CON_ADC_EN ((uint32_t)0x00000001)
  484. /********************* Bit definition for SDADC_GETDCCON register ******************/
  485. #define SDADC_GETDCCON_GETDC_SIZE ((uint32_t)0xffff0000)
  486. #define SDADC_GETDCCON_SW_DC ((uint32_t)0x0000ffff)
  487. /********************* Bit definition for SDADC_GAINCON register *******************/
  488. #define SDADC_GAINCON_GAIN ((uint32_t)0x0000ffff)
  489. /********************* Bit definition for SDADC_DMACON register ********************/
  490. #define SDADC_DMACON_SAMPLES_IE ((uint32_t)0x00000400)
  491. #define SDADC_DMACON_DMA_ALLDONE_IE ((uint32_t)0x00000200)
  492. #define SDADC_DMACON_DMA_HALFDONE_IE ((uint32_t)0x00000100)
  493. #define SDADC_DMACON_DMA_EN ((uint32_t)0x00000001)
  494. /********************* Bit definition for SDADC_DMAPND register ********************/
  495. #define SDADC_DMAPND_SAMPLEDONE ((uint32_t)0x00000004)
  496. #define SDADC_DMAPND_ALLDONE ((uint32_t)0x00000002)
  497. #define SDADC_DMAPND_HALFDONE ((uint32_t)0x00000001)
  498. /********************* Bit definition for SDADC_DMACPND register *******************/
  499. #define SDADC_DMACPND_SAMPLEDONE_CLR ((uint32_t)0x00000004)
  500. #define SDADC_DMACPND_ALLDONE_CLR ((uint32_t)0x00000002)
  501. #define SDADC_DMACPND_HALFDONE_CLR ((uint32_t)0x00000001)
  502. /*---------------------------------------------------------------------------------*/
  503. /* SDDAC */
  504. /*---------------------------------------------------------------------------------*/
  505. /*********************** Bit definition for SDDACCON register **********************/
  506. #define SDDAC_DAC_EN ((uint32_t)0x00000001)
  507. #define SDDAC_FSIN_SEL ((uint32_t)0x0000000e)
  508. #define SDDAC_FSIN_SEL_0 ((uint32_t)0x00000002)
  509. #define SDDAC_OSR_MODE ((uint32_t)0x00000010)
  510. /********************* Bit definition for DACDMAINCON register ********************/
  511. #define SDDAC_DMA_EN ((uint32_t)0x00000001)
  512. #define SDDAC_DMA_MODE ((uint32_t)0x00000002)
  513. #define SDDAC_DMA_HPEND_IE ((uint32_t)0x00000004)
  514. #define SDDAC_DMA_APEND_IE ((uint32_t)0x00000008)
  515. /********************* Bit definition for DACDMAINPEND register ********************/
  516. #define SDDAC_DMA_HALFPEND ((uint32_t)0x00000001)
  517. #define SDDAC_DMA_ALLPEND ((uint32_t)0x00000002)
  518. /********************* Bit definition for DACDMAINCPND register ********************/
  519. #define SDDAC_DMA_HALFPEND_CLR ((uint32_t)0x00000001)
  520. #define SDDAC_DMA_ALLPEND_CLR ((uint32_t)0x00000002)
  521. /*---------------------------------------------------------------------------------*/
  522. /* LEDC */
  523. /*---------------------------------------------------------------------------------*/
  524. /*********************** Bit definition for LEDCCON register ***********************/
  525. #define LEDC_CON_DMA_INT_EN ((uint32_t)0x04000000)
  526. #define LEDC_CON_OUT_INV ((uint32_t)0x02000000)
  527. #define LEDC_CON_RST_INT_EN ((uint32_t)0x01000000)
  528. #define LEDC_CON_BAUD ((uint32_t)0x00ff0000)
  529. #define LEDC_CON_DELAY ((uint32_t)0x0000ff00)
  530. #define LEDC_CON_IN_FORMAT ((uint32_t)0x00000080)
  531. #define LEDC_CON_INT_EN ((uint32_t)0x00000040)
  532. #define LEDC_CON_IDLE_LEVEL ((uint32_t)0x00000020)
  533. #define LEDC_CON_VLD_INV ((uint32_t)0x00000010)
  534. #define LEDC_CON_BYTE_INV ((uint32_t)0x0000000c)
  535. #define LEDC_CON_BYTE_INV_0 ((uint32_t)0x00000004)
  536. #define LEDC_CON_BYTE_INV_1 ((uint32_t)0x00000008)
  537. #define LEDC_CON_LEDC_KICK ((uint32_t)0x00000002)
  538. #define LEDC_CON_EN ((uint32_t)0x00000001)
  539. /*********************** Bit definition for LEDCPEND register **********************/
  540. #define LEDC_PEND_DMA_PND ((uint32_t)0x00000004)
  541. #define LEDC_PEND_RST_PND ((uint32_t)0x00000002)
  542. #define LEDC_PEND_LEDC_PND ((uint32_t)0x00000001)
  543. /*---------------------------------------------------------------------------------*/
  544. /* TICK */
  545. /*---------------------------------------------------------------------------------*/
  546. /*********************** Bit definition for TICK0CON register **********************/
  547. #define TICK_CON_TPND ((uint32_t)0x00000200)
  548. #define TICK_CON_TIE ((uint32_t)0x00000080)
  549. #define TICK_CON_INCSRC ((uint32_t)0x00000040)
  550. #define TICK_CON_INCSEL ((uint32_t)0x0000000c)
  551. #define TICK_CON_INCSEL_0 ((uint32_t)0x00000004)
  552. #define TICK_CON_INCSEL_1 ((uint32_t)0x00000008)
  553. #define TICK_CON_EN ((uint32_t)0x00000001)
  554. /*********************** Bit definition for TICK0CPND register *********************/
  555. #define TICK_CPND_TPCLR ((uint32_t)0x00000200)
  556. /*---------------------------------------------------------------------------------*/
  557. /* TIM */
  558. /*---------------------------------------------------------------------------------*/
  559. /******************* Bit definition for TIM_CR1 register ********************/
  560. #define TIM_CR1_CEN ((uint16_t)0x0001) /*!< Counter enable */
  561. #define TIM_CR1_UDIS ((uint16_t)0x0002) /*!< Update disable */
  562. #define TIM_CR1_URS ((uint16_t)0x0004) /*!< Update request source */
  563. #define TIM_CR1_OPM ((uint16_t)0x0008) /*!< One pulse mode */
  564. #define TIM_CR1_DIR ((uint16_t)0x0010) /*!< Direction */
  565. #define TIM_CR1_CMS ((uint16_t)0x0060) /*!< CMS[1:0] bits (Center-aligned mode selection) */
  566. #define TIM_CR1_CMS_0 ((uint16_t)0x0020) /*!< Bit 0 */
  567. #define TIM_CR1_CMS_1 ((uint16_t)0x0040) /*!< Bit 1 */
  568. #define TIM_CR1_ARPE ((uint16_t)0x0080) /*!< Auto-reload preload enable */
  569. #define TIM_CR1_CKD ((uint16_t)0x0300) /*!< CKD[1:0] bits (clock division) */
  570. #define TIM_CR1_CKD_0 ((uint16_t)0x0100) /*!< Bit 0 */
  571. #define TIM_CR1_CKD_1 ((uint16_t)0x0200) /*!< Bit 1 */
  572. /******************* Bit definition for TIM_CR2 register ********************/
  573. #define TIM_CR2_CCPC ((uint16_t)0x0001) /*!< Capture/Compare Preloaded Control */
  574. #define TIM_CR2_CCUS ((uint16_t)0x0004) /*!< Capture/Compare Control Update Selection */
  575. #define TIM_CR2_CCDS ((uint16_t)0x0008) /*!< Capture/Compare DMA Selection */
  576. #define TIM_CR2_MMS ((uint16_t)0x0070) /*!< MMS[2:0] bits (Master Mode Selection) */
  577. #define TIM_CR2_MMS_0 ((uint16_t)0x0010) /*!< Bit 0 */
  578. #define TIM_CR2_MMS_1 ((uint16_t)0x0020) /*!< Bit 1 */
  579. #define TIM_CR2_MMS_2 ((uint16_t)0x0040) /*!< Bit 2 */
  580. #define TIM_CR2_TI1S ((uint16_t)0x0080) /*!< TI1 Selection */
  581. #define TIM_CR2_OIS1 ((uint16_t)0x0100) /*!< Output Idle state 1 (OC1 output) */
  582. #define TIM_CR2_OIS1N ((uint16_t)0x0200) /*!< Output Idle state 1 (OC1N output) */
  583. #define TIM_CR2_OIS2 ((uint16_t)0x0400) /*!< Output Idle state 2 (OC2 output) */
  584. #define TIM_CR2_OIS2N ((uint16_t)0x0800) /*!< Output Idle state 2 (OC2N output) */
  585. #define TIM_CR2_OIS3 ((uint16_t)0x1000) /*!< Output Idle state 3 (OC3 output) */
  586. #define TIM_CR2_OIS3N ((uint16_t)0x2000) /*!< Output Idle state 3 (OC3N output) */
  587. #define TIM_CR2_OIS4 ((uint16_t)0x4000) /*!< Output Idle state 4 (OC4 output) */
  588. /******************* Bit definition for TIM_SMCR register *******************/
  589. #define TIM_SMCR_SMS ((uint16_t)0x0007) /*!< SMS[2:0] bits (Slave mode selection) */
  590. #define TIM_SMCR_SMS_0 ((uint16_t)0x0001) /*!< Bit 0 */
  591. #define TIM_SMCR_SMS_1 ((uint16_t)0x0002) /*!< Bit 1 */
  592. #define TIM_SMCR_SMS_2 ((uint16_t)0x0004) /*!< Bit 2 */
  593. #define TIM_SMCR_TS ((uint16_t)0x0070) /*!< TS[2:0] bits (Trigger selection) */
  594. #define TIM_SMCR_TS_0 ((uint16_t)0x0010) /*!< Bit 0 */
  595. #define TIM_SMCR_TS_1 ((uint16_t)0x0020) /*!< Bit 1 */
  596. #define TIM_SMCR_TS_2 ((uint16_t)0x0040) /*!< Bit 2 */
  597. #define TIM_SMCR_MSM ((uint16_t)0x0080) /*!< Master/slave mode */
  598. #define TIM_SMCR_ETF ((uint16_t)0x0F00) /*!< ETF[3:0] bits (External trigger filter) */
  599. #define TIM_SMCR_ETF_0 ((uint16_t)0x0100) /*!< Bit 0 */
  600. #define TIM_SMCR_ETF_1 ((uint16_t)0x0200) /*!< Bit 1 */
  601. #define TIM_SMCR_ETF_2 ((uint16_t)0x0400) /*!< Bit 2 */
  602. #define TIM_SMCR_ETF_3 ((uint16_t)0x0800) /*!< Bit 3 */
  603. #define TIM_SMCR_ETPS ((uint16_t)0x3000) /*!< ETPS[1:0] bits (External trigger prescaler) */
  604. #define TIM_SMCR_ETPS_0 ((uint16_t)0x1000) /*!< Bit 0 */
  605. #define TIM_SMCR_ETPS_1 ((uint16_t)0x2000) /*!< Bit 1 */
  606. #define TIM_SMCR_ECE ((uint16_t)0x4000) /*!< External clock enable */
  607. #define TIM_SMCR_ETP ((uint16_t)0x8000) /*!< External trigger polarity */
  608. /******************* Bit definition for TIM_DIER register *******************/
  609. #define TIM_DIER_UIE ((uint16_t)0x0001) /*!< Update interrupt enable */
  610. #define TIM_DIER_CC1IE ((uint16_t)0x0002) /*!< Capture/Compare 1 interrupt enable */
  611. #define TIM_DIER_CC2IE ((uint16_t)0x0004) /*!< Capture/Compare 2 interrupt enable */
  612. #define TIM_DIER_CC3IE ((uint16_t)0x0008) /*!< Capture/Compare 3 interrupt enable */
  613. #define TIM_DIER_CC4IE ((uint16_t)0x0010) /*!< Capture/Compare 4 interrupt enable */
  614. #define TIM_DIER_COMIE ((uint16_t)0x0020) /*!< COM interrupt enable */
  615. #define TIM_DIER_TIE ((uint16_t)0x0040) /*!< Trigger interrupt enable */
  616. #define TIM_DIER_BIE ((uint16_t)0x0080) /*!< Break interrupt enable */
  617. #define TIM_DIER_UDE ((uint16_t)0x0100) /*!< Update DMA request enable */
  618. #define TIM_DIER_CC1DE ((uint16_t)0x0200) /*!< Capture/Compare 1 DMA request enable */
  619. #define TIM_DIER_CC2DE ((uint16_t)0x0400) /*!< Capture/Compare 2 DMA request enable */
  620. #define TIM_DIER_CC3DE ((uint16_t)0x0800) /*!< Capture/Compare 3 DMA request enable */
  621. #define TIM_DIER_CC4DE ((uint16_t)0x1000) /*!< Capture/Compare 4 DMA request enable */
  622. #define TIM_DIER_COMDE ((uint16_t)0x2000) /*!< COM DMA request enable */
  623. #define TIM_DIER_TDE ((uint16_t)0x4000) /*!< Trigger DMA request enable */
  624. /******************** Bit definition for TIM_SR register ********************/
  625. #define TIM_SR_UIF ((uint16_t)0x0001) /*!< Update interrupt Flag */
  626. #define TIM_SR_CC1IF ((uint16_t)0x0002) /*!< Capture/Compare 1 interrupt Flag */
  627. #define TIM_SR_CC2IF ((uint16_t)0x0004) /*!< Capture/Compare 2 interrupt Flag */
  628. #define TIM_SR_CC3IF ((uint16_t)0x0008) /*!< Capture/Compare 3 interrupt Flag */
  629. #define TIM_SR_CC4IF ((uint16_t)0x0010) /*!< Capture/Compare 4 interrupt Flag */
  630. #define TIM_SR_COMIF ((uint16_t)0x0020) /*!< COM interrupt Flag */
  631. #define TIM_SR_TIF ((uint16_t)0x0040) /*!< Trigger interrupt Flag */
  632. #define TIM_SR_BIF ((uint16_t)0x0080) /*!< Break interrupt Flag */
  633. #define TIM_SR_CC1OF ((uint16_t)0x0200) /*!< Capture/Compare 1 Overcapture Flag */
  634. #define TIM_SR_CC2OF ((uint16_t)0x0400) /*!< Capture/Compare 2 Overcapture Flag */
  635. #define TIM_SR_CC3OF ((uint16_t)0x0800) /*!< Capture/Compare 3 Overcapture Flag */
  636. #define TIM_SR_CC4OF ((uint16_t)0x1000) /*!< Capture/Compare 4 Overcapture Flag */
  637. /******************* Bit definition for TIM_EGR register ********************/
  638. #define TIM_EGR_UG ((uint8_t)0x01) /*!< Update Generation */
  639. #define TIM_EGR_CC1G ((uint8_t)0x02) /*!< Capture/Compare 1 Generation */
  640. #define TIM_EGR_CC2G ((uint8_t)0x04) /*!< Capture/Compare 2 Generation */
  641. #define TIM_EGR_CC3G ((uint8_t)0x08) /*!< Capture/Compare 3 Generation */
  642. #define TIM_EGR_CC4G ((uint8_t)0x10) /*!< Capture/Compare 4 Generation */
  643. #define TIM_EGR_COMG ((uint8_t)0x20) /*!< Capture/Compare Control Update Generation */
  644. #define TIM_EGR_TG ((uint8_t)0x40) /*!< Trigger Generation */
  645. #define TIM_EGR_BG ((uint8_t)0x80) /*!< Break Generation */
  646. /****************** Bit definition for TIM_CCMR1 register *******************/
  647. #define TIM_CCMR1_CC1S ((uint16_t)0x0003) /*!< CC1S[1:0] bits (Capture/Compare 1 Selection) */
  648. #define TIM_CCMR1_CC1S_0 ((uint16_t)0x0001) /*!< Bit 0 */
  649. #define TIM_CCMR1_CC1S_1 ((uint16_t)0x0002) /*!< Bit 1 */
  650. #define TIM_CCMR1_OC1FE ((uint16_t)0x0004) /*!< Output Compare 1 Fast enable */
  651. #define TIM_CCMR1_OC1PE ((uint16_t)0x0008) /*!< Output Compare 1 Preload enable */
  652. #define TIM_CCMR1_OC1M ((uint16_t)0x0070) /*!< OC1M[2:0] bits (Output Compare 1 Mode) */
  653. #define TIM_CCMR1_OC1M_0 ((uint16_t)0x0010) /*!< Bit 0 */
  654. #define TIM_CCMR1_OC1M_1 ((uint16_t)0x0020) /*!< Bit 1 */
  655. #define TIM_CCMR1_OC1M_2 ((uint16_t)0x0040) /*!< Bit 2 */
  656. #define TIM_CCMR1_OC1CE ((uint16_t)0x0080) /*!< Output Compare 1Clear Enable */
  657. #define TIM_CCMR1_CC2S ((uint16_t)0x0300) /*!< CC2S[1:0] bits (Capture/Compare 2 Selection) */
  658. #define TIM_CCMR1_CC2S_0 ((uint16_t)0x0100) /*!< Bit 0 */
  659. #define TIM_CCMR1_CC2S_1 ((uint16_t)0x0200) /*!< Bit 1 */
  660. #define TIM_CCMR1_OC2FE ((uint16_t)0x0400) /*!< Output Compare 2 Fast enable */
  661. #define TIM_CCMR1_OC2PE ((uint16_t)0x0800) /*!< Output Compare 2 Preload enable */
  662. #define TIM_CCMR1_OC2M ((uint16_t)0x7000) /*!< OC2M[2:0] bits (Output Compare 2 Mode) */
  663. #define TIM_CCMR1_OC2M_0 ((uint16_t)0x1000) /*!< Bit 0 */
  664. #define TIM_CCMR1_OC2M_1 ((uint16_t)0x2000) /*!< Bit 1 */
  665. #define TIM_CCMR1_OC2M_2 ((uint16_t)0x4000) /*!< Bit 2 */
  666. #define TIM_CCMR1_OC2CE ((uint16_t)0x8000) /*!< Output Compare 2 Clear Enable */
  667. /*----------------------------------------------------------------------------*/
  668. #define TIM_CCMR1_IC1PSC ((uint16_t)0x000C) /*!< IC1PSC[1:0] bits (Input Capture 1 Prescaler) */
  669. #define TIM_CCMR1_IC1PSC_0 ((uint16_t)0x0004) /*!< Bit 0 */
  670. #define TIM_CCMR1_IC1PSC_1 ((uint16_t)0x0008) /*!< Bit 1 */
  671. #define TIM_CCMR1_IC1F ((uint16_t)0x00F0) /*!< IC1F[3:0] bits (Input Capture 1 Filter) */
  672. #define TIM_CCMR1_IC1F_0 ((uint16_t)0x0010) /*!< Bit 0 */
  673. #define TIM_CCMR1_IC1F_1 ((uint16_t)0x0020) /*!< Bit 1 */
  674. #define TIM_CCMR1_IC1F_2 ((uint16_t)0x0040) /*!< Bit 2 */
  675. #define TIM_CCMR1_IC1F_3 ((uint16_t)0x0080) /*!< Bit 3 */
  676. #define TIM_CCMR1_IC2PSC ((uint16_t)0x0C00) /*!< IC2PSC[1:0] bits (Input Capture 2 Prescaler) */
  677. #define TIM_CCMR1_IC2PSC_0 ((uint16_t)0x0400) /*!< Bit 0 */
  678. #define TIM_CCMR1_IC2PSC_1 ((uint16_t)0x0800) /*!< Bit 1 */
  679. #define TIM_CCMR1_IC2F ((uint16_t)0xF000) /*!< IC2F[3:0] bits (Input Capture 2 Filter) */
  680. #define TIM_CCMR1_IC2F_0 ((uint16_t)0x1000) /*!< Bit 0 */
  681. #define TIM_CCMR1_IC2F_1 ((uint16_t)0x2000) /*!< Bit 1 */
  682. #define TIM_CCMR1_IC2F_2 ((uint16_t)0x4000) /*!< Bit 2 */
  683. #define TIM_CCMR1_IC2F_3 ((uint16_t)0x8000) /*!< Bit 3 */
  684. /****************** Bit definition for TIM_CCMR2 register *******************/
  685. #define TIM_CCMR2_CC3S ((uint16_t)0x0003) /*!< CC3S[1:0] bits (Capture/Compare 3 Selection) */
  686. #define TIM_CCMR2_CC3S_0 ((uint16_t)0x0001) /*!< Bit 0 */
  687. #define TIM_CCMR2_CC3S_1 ((uint16_t)0x0002) /*!< Bit 1 */
  688. #define TIM_CCMR2_OC3FE ((uint16_t)0x0004) /*!< Output Compare 3 Fast enable */
  689. #define TIM_CCMR2_OC3PE ((uint16_t)0x0008) /*!< Output Compare 3 Preload enable */
  690. #define TIM_CCMR2_OC3M ((uint16_t)0x0070) /*!< OC3M[2:0] bits (Output Compare 3 Mode) */
  691. #define TIM_CCMR2_OC3M_0 ((uint16_t)0x0010) /*!< Bit 0 */
  692. #define TIM_CCMR2_OC3M_1 ((uint16_t)0x0020) /*!< Bit 1 */
  693. #define TIM_CCMR2_OC3M_2 ((uint16_t)0x0040) /*!< Bit 2 */
  694. #define TIM_CCMR2_OC3CE ((uint16_t)0x0080) /*!< Output Compare 3 Clear Enable */
  695. #define TIM_CCMR2_CC4S ((uint16_t)0x0300) /*!< CC4S[1:0] bits (Capture/Compare 4 Selection) */
  696. #define TIM_CCMR2_CC4S_0 ((uint16_t)0x0100) /*!< Bit 0 */
  697. #define TIM_CCMR2_CC4S_1 ((uint16_t)0x0200) /*!< Bit 1 */
  698. #define TIM_CCMR2_OC4FE ((uint16_t)0x0400) /*!< Output Compare 4 Fast enable */
  699. #define TIM_CCMR2_OC4PE ((uint16_t)0x0800) /*!< Output Compare 4 Preload enable */
  700. #define TIM_CCMR2_OC4M ((uint16_t)0x7000) /*!< OC4M[2:0] bits (Output Compare 4 Mode) */
  701. #define TIM_CCMR2_OC4M_0 ((uint16_t)0x1000) /*!< Bit 0 */
  702. #define TIM_CCMR2_OC4M_1 ((uint16_t)0x2000) /*!< Bit 1 */
  703. #define TIM_CCMR2_OC4M_2 ((uint16_t)0x4000) /*!< Bit 2 */
  704. #define TIM_CCMR2_OC4CE ((uint16_t)0x8000) /*!< Output Compare 4 Clear Enable */
  705. /*----------------------------------------------------------------------------*/
  706. #define TIM_CCMR2_IC3PSC ((uint16_t)0x000C) /*!< IC3PSC[1:0] bits (Input Capture 3 Prescaler) */
  707. #define TIM_CCMR2_IC3PSC_0 ((uint16_t)0x0004) /*!< Bit 0 */
  708. #define TIM_CCMR2_IC3PSC_1 ((uint16_t)0x0008) /*!< Bit 1 */
  709. #define TIM_CCMR2_IC3F ((uint16_t)0x00F0) /*!< IC3F[3:0] bits (Input Capture 3 Filter) */
  710. #define TIM_CCMR2_IC3F_0 ((uint16_t)0x0010) /*!< Bit 0 */
  711. #define TIM_CCMR2_IC3F_1 ((uint16_t)0x0020) /*!< Bit 1 */
  712. #define TIM_CCMR2_IC3F_2 ((uint16_t)0x0040) /*!< Bit 2 */
  713. #define TIM_CCMR2_IC3F_3 ((uint16_t)0x0080) /*!< Bit 3 */
  714. #define TIM_CCMR2_IC4PSC ((uint16_t)0x0C00) /*!< IC4PSC[1:0] bits (Input Capture 4 Prescaler) */
  715. #define TIM_CCMR2_IC4PSC_0 ((uint16_t)0x0400) /*!< Bit 0 */
  716. #define TIM_CCMR2_IC4PSC_1 ((uint16_t)0x0800) /*!< Bit 1 */
  717. #define TIM_CCMR2_IC4F ((uint16_t)0xF000) /*!< IC4F[3:0] bits (Input Capture 4 Filter) */
  718. #define TIM_CCMR2_IC4F_0 ((uint16_t)0x1000) /*!< Bit 0 */
  719. #define TIM_CCMR2_IC4F_1 ((uint16_t)0x2000) /*!< Bit 1 */
  720. #define TIM_CCMR2_IC4F_2 ((uint16_t)0x4000) /*!< Bit 2 */
  721. #define TIM_CCMR2_IC4F_3 ((uint16_t)0x8000) /*!< Bit 3 */
  722. /******************* Bit definition for TIM_CCER register *******************/
  723. #define TIM_CCER_CC1E ((uint16_t)0x0001) /*!< Capture/Compare 1 output enable */
  724. #define TIM_CCER_CC1P ((uint16_t)0x0002) /*!< Capture/Compare 1 output Polarity */
  725. #define TIM_CCER_CC1NE ((uint16_t)0x0004) /*!< Capture/Compare 1 Complementary output enable */
  726. #define TIM_CCER_CC1NP ((uint16_t)0x0008) /*!< Capture/Compare 1 Complementary output Polarity */
  727. #define TIM_CCER_CC2E ((uint16_t)0x0010) /*!< Capture/Compare 2 output enable */
  728. #define TIM_CCER_CC2P ((uint16_t)0x0020) /*!< Capture/Compare 2 output Polarity */
  729. #define TIM_CCER_CC2NE ((uint16_t)0x0040) /*!< Capture/Compare 2 Complementary output enable */
  730. #define TIM_CCER_CC2NP ((uint16_t)0x0080) /*!< Capture/Compare 2 Complementary output Polarity */
  731. #define TIM_CCER_CC3E ((uint16_t)0x0100) /*!< Capture/Compare 3 output enable */
  732. #define TIM_CCER_CC3P ((uint16_t)0x0200) /*!< Capture/Compare 3 output Polarity */
  733. #define TIM_CCER_CC3NE ((uint16_t)0x0400) /*!< Capture/Compare 3 Complementary output enable */
  734. #define TIM_CCER_CC3NP ((uint16_t)0x0800) /*!< Capture/Compare 3 Complementary output Polarity */
  735. #define TIM_CCER_CC4E ((uint16_t)0x1000) /*!< Capture/Compare 4 output enable */
  736. #define TIM_CCER_CC4P ((uint16_t)0x2000) /*!< Capture/Compare 4 output Polarity */
  737. #define TIM_CCER_CC4NP ((uint16_t)0x8000) /*!< Capture/Compare 4 Complementary output Polarity */
  738. /******************* Bit definition for TIM_CNT register ********************/
  739. #define TIM_CNT_CNT ((uint16_t)0xFFFF) /*!< Counter Value */
  740. /******************* Bit definition for TIM_PSC register ********************/
  741. #define TIM_PSC_PSC ((uint16_t)0xFFFF) /*!< Prescaler Value */
  742. /******************* Bit definition for TIM_ARR register ********************/
  743. #define TIM_ARR_ARR ((uint16_t)0xFFFF) /*!< actual auto-reload Value */
  744. /******************* Bit definition for TIM_RCR register ********************/
  745. #define TIM_RCR_REP ((uint8_t)0xFF) /*!< Repetition Counter Value */
  746. /******************* Bit definition for TIM_CCR1 register *******************/
  747. #define TIM_CCR1_CCR1 ((uint16_t)0xFFFF) /*!< Capture/Compare 1 Value */
  748. /******************* Bit definition for TIM_CCR2 register *******************/
  749. #define TIM_CCR2_CCR2 ((uint16_t)0xFFFF) /*!< Capture/Compare 2 Value */
  750. /******************* Bit definition for TIM_CCR3 register *******************/
  751. #define TIM_CCR3_CCR3 ((uint16_t)0xFFFF) /*!< Capture/Compare 3 Value */
  752. /******************* Bit definition for TIM_CCR4 register *******************/
  753. #define TIM_CCR4_CCR4 ((uint16_t)0xFFFF) /*!< Capture/Compare 4 Value */
  754. /******************* Bit definition for TIM_BDTR register *******************/
  755. #define TIM_BDTR_DTG ((uint16_t)0x00FF) /*!< DTG[0:7] bits (Dead-Time Generator set-up) */
  756. #define TIM_BDTR_DTG_0 ((uint16_t)0x0001) /*!< Bit 0 */
  757. #define TIM_BDTR_DTG_1 ((uint16_t)0x0002) /*!< Bit 1 */
  758. #define TIM_BDTR_DTG_2 ((uint16_t)0x0004) /*!< Bit 2 */
  759. #define TIM_BDTR_DTG_3 ((uint16_t)0x0008) /*!< Bit 3 */
  760. #define TIM_BDTR_DTG_4 ((uint16_t)0x0010) /*!< Bit 4 */
  761. #define TIM_BDTR_DTG_5 ((uint16_t)0x0020) /*!< Bit 5 */
  762. #define TIM_BDTR_DTG_6 ((uint16_t)0x0040) /*!< Bit 6 */
  763. #define TIM_BDTR_DTG_7 ((uint16_t)0x0080) /*!< Bit 7 */
  764. #define TIM_BDTR_LOCK ((uint16_t)0x0300) /*!< LOCK[1:0] bits (Lock Configuration) */
  765. #define TIM_BDTR_LOCK_0 ((uint16_t)0x0100) /*!< Bit 0 */
  766. #define TIM_BDTR_LOCK_1 ((uint16_t)0x0200) /*!< Bit 1 */
  767. #define TIM_BDTR_OSSI ((uint16_t)0x0400) /*!< Off-State Selection for Idle mode */
  768. #define TIM_BDTR_OSSR ((uint16_t)0x0800) /*!< Off-State Selection for Run mode */
  769. #define TIM_BDTR_BKE ((uint16_t)0x1000) /*!< Break enable */
  770. #define TIM_BDTR_BKP ((uint16_t)0x2000) /*!< Break Polarity */
  771. #define TIM_BDTR_AOE ((uint16_t)0x4000) /*!< Automatic Output enable */
  772. #define TIM_BDTR_MOE ((uint16_t)0x8000) /*!< Main Output enable */
  773. /******************* Bit definition for TIM_DCR register ********************/
  774. #define TIM_DCR_DBA ((uint16_t)0x001F) /*!< DBA[4:0] bits (DMA Base Address) */
  775. #define TIM_DCR_DBA_0 ((uint16_t)0x0001) /*!< Bit 0 */
  776. #define TIM_DCR_DBA_1 ((uint16_t)0x0002) /*!< Bit 1 */
  777. #define TIM_DCR_DBA_2 ((uint16_t)0x0004) /*!< Bit 2 */
  778. #define TIM_DCR_DBA_3 ((uint16_t)0x0008) /*!< Bit 3 */
  779. #define TIM_DCR_DBA_4 ((uint16_t)0x0010) /*!< Bit 4 */
  780. #define TIM_DCR_DBL ((uint16_t)0x1F00) /*!< DBL[4:0] bits (DMA Burst Length) */
  781. #define TIM_DCR_DBL_0 ((uint16_t)0x0100) /*!< Bit 0 */
  782. #define TIM_DCR_DBL_1 ((uint16_t)0x0200) /*!< Bit 1 */
  783. #define TIM_DCR_DBL_2 ((uint16_t)0x0400) /*!< Bit 2 */
  784. #define TIM_DCR_DBL_3 ((uint16_t)0x0800) /*!< Bit 3 */
  785. #define TIM_DCR_DBL_4 ((uint16_t)0x1000) /*!< Bit 4 */
  786. /******************* Bit definition for TIM_DMAR register *******************/
  787. #define TIM_DMAR_DMAB ((uint16_t)0xFFFF) /*!< DMA register for burst accesses */
  788. /******************* Bit definition for TIM_SARAD register *******************/
  789. #define TIM_SARAD_MASK ((uint16_t)0xFFFF) /*!< TIM_SARAD register for burst accesses */
  790. #define TIM_SARAD_CH0 ((uint16_t)0x0001) /*!< Bit 0 */
  791. #define TIM_SARAD_CH1 ((uint16_t)0x0002) /*!< Bit 1 */
  792. #define TIM_SARAD_CH2 ((uint16_t)0x0004) /*!< Bit 2 */
  793. #define TIM_SARAD_CH3 ((uint16_t)0x0008) /*!< Bit 3 */
  794. #define TIM_SARAD_CH4 ((uint16_t)0x0010) /*!< Bit 4 */
  795. #define TIM_SARAD_CH5 ((uint16_t)0x0020) /*!< Bit 5 */
  796. #define TIM_SARAD_CH6 ((uint16_t)0x0040) /*!< Bit 6 */
  797. #define TIM_SARAD_CH7 ((uint16_t)0x0080) /*!< Bit 7 */
  798. #define TIM_SARAD_CH8 ((uint16_t)0x0100) /*!< Bit 8 */
  799. #define TIM_SARAD_CH9 ((uint16_t)0x0200) /*!< Bit 9 */
  800. #define TIM_SARAD_CH10 ((uint16_t)0x0400) /*!< Bit 10 */
  801. #define TIM_SARAD_CH11 ((uint16_t)0x0800) /*!< Bit 11 */
  802. #define TIM_SARAD_CH12 ((uint16_t)0x1000) /*!< Bit 12 */
  803. #define TIM_SARAD_CH13 ((uint16_t)0x2000) /*!< Bit 13 */
  804. #define TIM_SARAD_CH14 ((uint16_t)0x4000) /*!< Bit 14 */
  805. #define TIM_SARAD_CH15 ((uint16_t)0x8000) /*!< Bit 15 */
  806. #define TIM_SARAD_TRGOEN ((uint32_t)0x10000) /*!< Bit 16 */
  807. /**
  808. * @brief GPIO Register Structure
  809. */
  810. typedef struct {
  811. volatile u32 io_set;
  812. volatile u32 io_clr;
  813. volatile u32 data;
  814. volatile u32 dir;
  815. volatile u32 de;
  816. volatile u32 fen;
  817. volatile u32 fdir;
  818. volatile u32 drv;
  819. volatile u32 pupd[6];
  820. } gpio_typedef;
  821. /**
  822. * @brief Function and IO Mapping Register Structure
  823. */
  824. typedef struct {
  825. volatile u32 func_output_map[8];
  826. volatile u32 func_input_map[7];
  827. } func_map_typedef;
  828. /**
  829. * @brief Timer Register Structure
  830. */
  831. typedef struct {
  832. volatile u32 con;
  833. volatile u32 cpnd;
  834. volatile u32 cnt;
  835. volatile u32 period;
  836. volatile u32 capture_val;
  837. volatile u32 duty0;
  838. volatile u32 duty1;
  839. volatile u32 duty2;
  840. volatile u32 psc;
  841. } tmr_typedef;
  842. /**
  843. * @brief Uart Register Structure
  844. */
  845. typedef struct {
  846. volatile u32 con;
  847. volatile u32 cpnd;
  848. volatile u32 baud;
  849. volatile u32 data;
  850. } uart_typedef;
  851. /**
  852. * @brief High Speed UART Register Structure
  853. */
  854. typedef struct {
  855. volatile u32 con;
  856. volatile u32 cpnd;
  857. volatile u32 baud;
  858. volatile u32 data;
  859. volatile u32 tx_cnt;
  860. volatile u32 tx_adr;
  861. volatile u32 rx_cnt;
  862. const u32 reserved0;
  863. const u32 reserved1;
  864. volatile u32 rx_adr;
  865. volatile u32 fifo_cnt;
  866. volatile u32 fifo;
  867. volatile u32 fifo_adr;
  868. volatile u32 tmr_cnt;
  869. volatile u32 flow_ctrl;
  870. } hsuart_typedef;
  871. /**
  872. * @brief IIC Register Structure
  873. */
  874. typedef struct {
  875. volatile u32 con0;
  876. volatile u32 con1;
  877. volatile u32 cmd_addr;
  878. volatile u32 data;
  879. volatile u32 dma_addr;
  880. volatile u32 dma_cnt;
  881. volatile u32 slave_sta;
  882. } iic_typedef;
  883. /**
  884. * @brief SPI Register Structure
  885. */
  886. typedef struct {
  887. volatile u32 con;
  888. volatile u32 buf;
  889. volatile u32 baud;
  890. volatile u32 cpnd;
  891. volatile u32 dma_cnt;
  892. volatile u32 dma_adr;
  893. } spi_typedef;
  894. /**
  895. * @brief WDT Register Structure
  896. */
  897. typedef struct {
  898. volatile u32 con;
  899. } wdt_typedef;
  900. /**
  901. * @brief SARADC Register Structure
  902. */
  903. typedef struct {
  904. volatile u32 dat[16];
  905. volatile u32 con;
  906. volatile u32 ch;
  907. volatile u32 cst;
  908. volatile u32 baud;
  909. const u32 reserved0;
  910. const u32 reserved1;
  911. const u32 reserved2;
  912. const u32 reserved3;
  913. const u32 reserved4;
  914. volatile u32 ch_int;
  915. volatile u32 ch_pnd;
  916. } sadc_typedef;
  917. /**
  918. * @brief LPWM Register Structure
  919. */
  920. typedef struct {
  921. volatile u32 start_con;
  922. volatile u32 switch_con;
  923. volatile u32 cnt_max_con;
  924. volatile u32 stageA_con;
  925. volatile u32 stageB_con;
  926. volatile u32 stageC_con;
  927. volatile u32 stageD_con;
  928. volatile u32 stageE_con;
  929. volatile u32 stageF_con;
  930. volatile u32 stageHL_con;
  931. volatile u32 pend;
  932. } lpwm_typedef;
  933. /**
  934. * @brief KEYSCAN Register Structure
  935. */
  936. typedef struct {
  937. volatile u32 con0;
  938. volatile u32 con1;
  939. volatile u32 clr;
  940. volatile u32 info0;
  941. volatile u32 info1;
  942. volatile u32 info2;
  943. } keyscan_typedef;
  944. /**
  945. * @brief IRRX Register Structure
  946. */
  947. typedef struct {
  948. // IR RX Control Register
  949. volatile u32 con;
  950. // IR RX Data Register
  951. volatile u32 rxdata;
  952. // IR RX Clear Pending Register
  953. volatile u32 cpnd;
  954. // IR RX Error Config Register0
  955. volatile u32 err0;
  956. // IR RX Error Config Register1
  957. volatile u32 err1;
  958. // IR RX Period Config Register0
  959. volatile u32 period0;
  960. // IR RX Period Config Register1
  961. volatile u32 period1;
  962. } irrx_typedef;
  963. /**
  964. * @brief IRTX Register Structure
  965. */
  966. typedef struct {
  967. // IR One Code Time Register
  968. volatile u32 otime;
  969. // IR One Zero Time Register
  970. volatile u32 ztime;
  971. // IR Start Code Time Register
  972. volatile u32 stime;
  973. // IR Repeat Code Time Register
  974. volatile u32 rtime;
  975. // IR Repeat Code Control Register
  976. volatile u32 rctrl;
  977. // IR TX Control Register
  978. volatile u32 con;
  979. // IR TX Data Register
  980. volatile u32 txdata;
  981. // IR TX Data Length Register
  982. volatile u32 txlen;
  983. // IR TX Pending Register
  984. volatile u32 pend;
  985. // IR TX DMA Control Register
  986. volatile u32 dma_con;
  987. // IR TX DMA Input Address Register
  988. volatile u32 dma_iadr;
  989. // IR TX DMA Input Size Register
  990. volatile u32 dma_isize;
  991. // IR TX DMA Output Address Register
  992. volatile u32 dma_oadr;
  993. // IR TX DMA Output Size Register
  994. volatile u32 dma_osize;
  995. // IR TX DMA Pending Register
  996. volatile u32 dma_pend;
  997. } irtx_typedef;
  998. /**
  999. * @brief Touch Key Register Structure
  1000. */
  1001. typedef struct {
  1002. // Touch Key Control Register
  1003. volatile u32 tkcon;
  1004. // Touch Key Control Register 1
  1005. volatile u32 tkcon1;
  1006. // Touch Key Counter Register
  1007. volatile u32 tkcnt;
  1008. // Touch Key Charge And Discharge Period Register 0
  1009. volatile u32 tkcdpr0;
  1010. // Touch Key Charge And Discharge Period Register 1
  1011. volatile u32 tkcdpr1;
  1012. // Touch Key Times Register
  1013. volatile u32 tktmr;
  1014. // Touch Ear Times Register
  1015. volatile u32 tetmr;
  1016. // Touch Key Base Counter Register
  1017. volatile u32 tkbcnt;
  1018. // Touch Key Press Threshold Register
  1019. volatile u32 tkpthd;
  1020. // Touch Key Exception Threshold Register
  1021. volatile u32 tkethd;
  1022. // Touch Ear Base Counter Register
  1023. volatile u32 tebcnt;
  1024. // Touch Ear Press Threshold Register
  1025. volatile u32 tepthd;
  1026. // Touch Ear Exception Threshold Register
  1027. volatile u32 teethd;
  1028. // Touch Key Control Register 2
  1029. volatile u32 tkcon2;
  1030. // Touch Key Variance Register
  1031. volatile u32 tkvari;
  1032. // Touch Key Variance Threshold Register
  1033. volatile u32 tkvarithd;
  1034. // Touch Key Analog Control Register 0
  1035. volatile u32 tkacon0;
  1036. // Touch Key Analog Control Register 1
  1037. volatile u32 tkacon1;
  1038. } touch_key_typedef;
  1039. /**
  1040. * @brief SDADC Register Structure
  1041. */
  1042. typedef struct {
  1043. volatile u32 con;
  1044. volatile u32 gain_con;
  1045. volatile u32 get_dc_con;
  1046. volatile u32 dma_con;
  1047. volatile u32 dma_addr;
  1048. volatile u32 dma_size;
  1049. volatile u32 dma_pend;
  1050. volatile u32 dma_cpnd;
  1051. volatile u32 ram_test_addr;
  1052. volatile u32 ram_test_data;
  1053. } sdadc_typedef;
  1054. /**
  1055. * @brief SDDAC Register Structure
  1056. */
  1057. typedef struct {
  1058. volatile u32 dma_con;
  1059. volatile u32 dma_addr;
  1060. volatile u32 dma_size;
  1061. volatile u32 dma_pend;
  1062. volatile u32 dma_cpnd;
  1063. volatile u32 con;
  1064. } sddac_typedef;
  1065. /**
  1066. * @brief LEDC Register Structure
  1067. */
  1068. typedef struct {
  1069. volatile u32 con;
  1070. volatile u32 fd;
  1071. volatile u32 lp;
  1072. volatile u32 tix;
  1073. volatile u32 rstx;
  1074. volatile u32 addr;
  1075. volatile u32 cnt;
  1076. volatile u32 pend;
  1077. } ledc_typedef;
  1078. /**
  1079. * @brief TICK0 Register Structure
  1080. */
  1081. typedef struct {
  1082. volatile u32 con;
  1083. volatile u32 cpnd;
  1084. volatile u32 cnt;
  1085. volatile u32 pr;
  1086. } tick_typedef;
  1087. #endif // _DRIVER_COM_H