f7_regs.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566
  1. /*
  2. * stm32/f7_regs.h
  3. *
  4. * Core and peripheral register definitions.
  5. *
  6. * Written & released by Keir Fraser <keir.xen@gmail.com>
  7. *
  8. * This is free and unencumbered software released into the public domain.
  9. * See the file COPYING for more details, or visit <http://unlicense.org>.
  10. */
  11. struct dbg {
  12. uint32_t mcu_idcode; /* 00: MCU ID code */
  13. uint32_t mcu_cr; /* 04: Debug MCU configuration */
  14. uint32_t mcu_apb1_fz;/* 08: Debug MCU APB1 freeze */
  15. uint32_t mcu_apb2_fz;/* 0C: Debug MCU APB2 freeze */
  16. };
  17. #define DBG_BASE 0xe0042000
  18. /* Flash memory interface */
  19. struct flash {
  20. uint32_t acr; /* 00: Flash access control */
  21. uint32_t keyr; /* 04: Flash key */
  22. uint32_t optkeyr; /* 08: Flash option key */
  23. uint32_t sr; /* 0C: Flash status */
  24. uint32_t cr; /* 10: Flash control */
  25. uint32_t optcr; /* 14: Flash option control */
  26. uint32_t optcr1; /* 18: Flash option control */
  27. uint32_t optcr2; /* 1C: Flash option control */
  28. };
  29. #define FLASH_ACR_ARTRST (1u<<11)
  30. #define FLASH_ACR_ARTEN (1u<< 9)
  31. #define FLASH_ACR_PRFTEN (1u<< 8)
  32. #define FLASH_ACR_LATENCY(w) ((w)<<0) /* wait states */
  33. #define FLASH_SR_BSY (1u<<16)
  34. #define FLASH_SR_RDERR (1u<< 8)
  35. #define FLASH_SR_ERRSERR (1u<< 7)
  36. #define FLASH_SR_PGPERR (1u<< 6)
  37. #define FLASH_SR_PGAERR (1u<< 5)
  38. #define FLASH_SR_WRPERR (1u<< 4)
  39. #define FLASH_SR_OPERR (1u<< 1)
  40. #define FLASH_SR_EOP (1u<< 0)
  41. #define FLASH_CR_LOCK (1u<<31)
  42. #define FLASH_CR_RDERRIE (1u<<26)
  43. #define FLASH_CR_ERRIE (1u<<25)
  44. #define FLASH_CR_EOPIE (1u<<24)
  45. #define FLASH_CR_STRT (1u<<16)
  46. #define FLASH_CR_PSIZE(x) ((x)<<8)
  47. #define FLASH_CR_SNB(x) ((x)<<3)
  48. #define FLASH_CR_MER (1u<< 2)
  49. #define FLASH_CR_SER (1u<< 1)
  50. #define FLASH_CR_PG (1u<< 0)
  51. #define FLASH_BASE 0x40023c00
  52. /* Power control */
  53. struct pwr {
  54. uint32_t cr1; /* 00: Power control #1 */
  55. uint32_t csr1; /* 04: Power control/status #1 */
  56. uint32_t cr2; /* 08: Power control #2 */
  57. uint32_t csr2; /* 0C: Power control/status #2 */
  58. };
  59. #define PWR_CR1_DBP (1u<< 8)
  60. #define PWR_BASE 0x40007000
  61. /* Reset and clock control */
  62. struct rcc {
  63. uint32_t cr; /* 00: Clock control */
  64. uint32_t pllcfgr; /* 04: PLL configuration */
  65. uint32_t cfgr; /* 08: Clock configuration */
  66. uint32_t cir; /* 0C: Clock interrupt */
  67. uint32_t ahb1rstr; /* 10: AHB1 peripheral reset */
  68. uint32_t ahb2rstr; /* 14: AHB2 peripheral reset */
  69. uint32_t ahb3rstr; /* 18: AHB3 peripheral reset */
  70. uint32_t _unused0; /* 1C: - */
  71. uint32_t apb1rstr; /* 20: APB1 peripheral reset */
  72. uint32_t apb2rstr; /* 24: APB2 peripheral reset */
  73. uint32_t _unused1; /* 28: - */
  74. uint32_t _unused2; /* 2C: - */
  75. uint32_t ahb1enr; /* 30: AHB1 peripheral clock enable */
  76. uint32_t ahb2enr; /* 34: AHB2 peripheral clock enable */
  77. uint32_t ahb3enr; /* 38: AHB3 peripheral clock enable */
  78. uint32_t _unused3; /* 3C: - */
  79. uint32_t apb1enr; /* 40: APB1 peripheral clock enable */
  80. uint32_t apb2enr; /* 44: APB1 peripheral clock enable */
  81. uint32_t _unused4; /* 48: - */
  82. uint32_t _unused5; /* 4C: - */
  83. uint32_t ahb1lpenr;/* 50: AHB1 peripheral clock enable (low-power mode) */
  84. uint32_t ahb2lpenr;/* 54: AHB2 peripheral clock enable (low-power mode) */
  85. uint32_t ahb3lpenr;/* 58: AHB3 peripheral clock enable (low-power mode) */
  86. uint32_t _unused6; /* 5C: - */
  87. uint32_t apb1lpenr;/* 60: APB1 peripheral clock enable (low-power mode) */
  88. uint32_t apb2lpenr;/* 64: APB2 peripheral clock enable (low-power mode) */
  89. uint32_t _unused7; /* 68: - */
  90. uint32_t _unused8; /* 6C: - */
  91. uint32_t bdcr; /* 70: Backup domain control */
  92. uint32_t csr; /* 74: Clock control & status */
  93. uint32_t _unused9; /* 78: - */
  94. uint32_t _unusedA; /* 7C: - */
  95. uint32_t sscgr; /* 80: Spread spectrum clock generation */
  96. uint32_t plli2scfgr; /* 84: PLLI2S configuration */
  97. uint32_t pllsaicfgr; /* 88: PLLSAI configuration */
  98. uint32_t dckcfgr1; /* 8C: Dedicated clocks configuration #1 */
  99. uint32_t dckcfgr2; /* 90: Dedicated clocks configuration #2 */
  100. };
  101. #define RCC_CR_SAIRDY (1u<<29)
  102. #define RCC_CR_SAION (1u<<28)
  103. #define RCC_CR_PLLIS2RDY (1u<<27)
  104. #define RCC_CR_PLLI2SON (1u<<26)
  105. #define RCC_CR_PLLRDY (1u<<25)
  106. #define RCC_CR_PLLON (1u<<24)
  107. #define RCC_CR_CSSON (1u<<19)
  108. #define RCC_CR_HSEBYP (1u<<18)
  109. #define RCC_CR_HSERDY (1u<<17)
  110. #define RCC_CR_HSEON (1u<<16)
  111. #define RCC_CR_HSIRDY (1u<<1)
  112. #define RCC_CR_HSION (1u<<0)
  113. #define RCC_PLLCFGR_PLLQ(x) ((x)<<24)
  114. #define RCC_PLLCFGR_PLLSRC_HSE (1<<22)
  115. #define RCC_PLLCFGR_PLLP(x) ((x)<<16)
  116. #define RCC_PLLCFGR_PLLN(x) ((x)<< 6)
  117. #define RCC_PLLCFGR_PLLM(x) ((x)<< 0)
  118. #define RCC_CFGR_MCO2(x) ((x)<<30)
  119. #define RCC_CFGR_MCO2PRE(x) ((x)<<27)
  120. #define RCC_CFGR_MCO1PRE(x) ((x)<<24)
  121. #define RCC_CFGR_I2SSCR (1 <<23)
  122. #define RCC_CFGR_MCO1(x) ((x)<<21)
  123. #define RCC_CFGR_RTCPRE(x) ((x)<<16)
  124. #define RCC_CFGR_PPRE2(x) ((x)<<13)
  125. #define RCC_CFGR_PPRE1(x) ((x)<<10)
  126. #define RCC_CFGR_HPRE(x) ((x)<< 4)
  127. #define RCC_CFGR_SWS(x) ((x)<< 2)
  128. #define RCC_CFGR_SW(x) ((x)<< 0)
  129. #define RCC_AHB1ENR_OTGHSULPIEN (1u<<30)
  130. #define RCC_AHB1ENR_OTGHSEN (1u<<29)
  131. #define RCC_AHB1ENR_DMA2EN (1u<<22)
  132. #define RCC_AHB1ENR_DMA1EN (1u<<21)
  133. #define RCC_AHB1ENR_DTCMRAMEN (1u<<20)
  134. #define RCC_AHB1ENR_BKPSRAMEN (1u<<18)
  135. #define RCC_AHB1ENR_CRCEN (1u<<12)
  136. #define RCC_AHB1ENR_GPIOIEN (1u<< 8)
  137. #define RCC_AHB1ENR_GPIOHEN (1u<< 7)
  138. #define RCC_AHB1ENR_GPIOGEN (1u<< 6)
  139. #define RCC_AHB1ENR_GPIOFEN (1u<< 5)
  140. #define RCC_AHB1ENR_GPIOEEN (1u<< 4)
  141. #define RCC_AHB1ENR_GPIODEN (1u<< 3)
  142. #define RCC_AHB1ENR_GPIOCEN (1u<< 2)
  143. #define RCC_AHB1ENR_GPIOBEN (1u<< 1)
  144. #define RCC_AHB1ENR_GPIOAEN (1u<< 0)
  145. #define RCC_AHB2ENR_OTGFSEN (1u<< 7)
  146. #define RCC_AHB2ENR_RNGEN (1u<< 6)
  147. #define RCC_AHB2ENR_AESEN (1u<< 4)
  148. #define RCC_AHB3ENR_QSPIEN (1u<< 1)
  149. #define RCC_AHB3ENR_FMCEN (1u<< 0)
  150. #define RCC_APB1ENR_USART8EN (1u<<31)
  151. #define RCC_APB1ENR_USART7EN (1u<<30)
  152. #define RCC_APB1ENR_DACEN (1u<<29)
  153. #define RCC_APB1ENR_PWREN (1u<<28)
  154. #define RCC_APB1ENR_CAN1EN (1u<<25)
  155. #define RCC_APB1ENR_I2C3EN (1u<<23)
  156. #define RCC_APB1ENR_I2C2EN (1u<<22)
  157. #define RCC_APB1ENR_I2C1EN (1u<<21)
  158. #define RCC_APB1ENR_USART5EN (1u<<20)
  159. #define RCC_APB1ENR_USART4EN (1u<<19)
  160. #define RCC_APB1ENR_USART3EN (1u<<18)
  161. #define RCC_APB1ENR_USART2EN (1u<<17)
  162. #define RCC_APB1ENR_SPI3EN (1u<<15)
  163. #define RCC_APB1ENR_SPI2EN (1u<<14)
  164. #define RCC_APB1ENR_WWDGEN (1u<<11)
  165. #define RCC_APB1ENR_RTCAPBEN (1u<<10)
  166. #define RCC_APB1ENR_LPTIM1EN (1u<< 9)
  167. #define RCC_APB1ENR_TIM14EN (1u<< 8)
  168. #define RCC_APB1ENR_TIM13EN (1u<< 7)
  169. #define RCC_APB1ENR_TIM12EN (1u<< 6)
  170. #define RCC_APB1ENR_TIM7EN (1u<< 5)
  171. #define RCC_APB1ENR_TIM6EN (1u<< 4)
  172. #define RCC_APB1ENR_TIM5EN (1u<< 3)
  173. #define RCC_APB1ENR_TIM4EN (1u<< 2)
  174. #define RCC_APB1ENR_TIM3EN (1u<< 1)
  175. #define RCC_APB1ENR_TIM2EN (1u<< 0)
  176. #define RCC_APB2ENR_OTGPHYCEN (1u<<31)
  177. #define RCC_APB2ENR_SAI2EN (1u<<23)
  178. #define RCC_APB2ENR_SAI1EN (1u<<22)
  179. #define RCC_APB2ENR_SPI5EN (1u<<20)
  180. #define RCC_APB2ENR_TIM11EN (1u<<18)
  181. #define RCC_APB2ENR_TIM10EN (1u<<17)
  182. #define RCC_APB2ENR_TIM9EN (1u<<16)
  183. #define RCC_APB2ENR_SYSCFGEN (1u<<14)
  184. #define RCC_APB2ENR_SPI4EN (1u<<13)
  185. #define RCC_APB2ENR_SPI1EN (1u<<12)
  186. #define RCC_APB2ENR_SDMMC1EN (1u<<11)
  187. #define RCC_APB2ENR_ADC3EN (1u<<10)
  188. #define RCC_APB2ENR_ADC2EN (1u<< 9)
  189. #define RCC_APB2ENR_ADC1EN (1u<< 8)
  190. #define RCC_APB2ENR_SDMMC2EN (1u<< 7)
  191. #define RCC_APB2ENR_USART6EN (1u<< 5)
  192. #define RCC_APB2ENR_USART1EN (1u<< 4)
  193. #define RCC_APB2ENR_TIM8EN (1u<< 1)
  194. #define RCC_APB2ENR_TIM1EN (1u<< 0)
  195. #define RCC_BDCR_BDRST (1u<<16)
  196. #define RCC_BDCR_RTCEN (1u<<15)
  197. #define RCC_BDCR_RTCSEL(x) ((x)<<8)
  198. #define RCC_BDCR_LSEDRV(x) ((x)<<3)
  199. #define RCC_BDCR_LSEBYP (1u<< 2)
  200. #define RCC_BDCR_LSERDY (1u<< 1)
  201. #define RCC_BDCR_LSEON (1u<< 0)
  202. #define RCC_CSR_LPWRRSTF (1u<<31)
  203. #define RCC_CSR_WWDGRSTF (1u<<30)
  204. #define RCC_CSR_IWDGRSTF (1u<<29)
  205. #define RCC_CSR_SFTRSTF (1u<<28)
  206. #define RCC_CSR_PORRSTF (1u<<27)
  207. #define RCC_CSR_PINRSTF (1u<<26)
  208. #define RCC_CSR_BORRSTF (1u<<25)
  209. #define RCC_CSR_RMVF (1u<<24)
  210. #define RCC_CSR_LSIRDY (1u<< 1)
  211. #define RCC_CSR_LSION (1u<< 0)
  212. #define RCC_DCKCFGR1_TIMPRE (1u<<24)
  213. #define RCC_DCKCFGR1_SAI2SEL(x) ((x)<<22)
  214. #define RCC_DCKCFGR1_SAI1SEL(x) ((x)<<20)
  215. #define RCC_DCKCFGR1_PLLSAIDIVQ(x) ((x)<< 8)
  216. #define RCC_DCKCFGR1_PLLI2SDIVQ(x) ((x)<< 0)
  217. #define RCC_BASE 0x40023800
  218. /* General-purpose I/O */
  219. struct gpio {
  220. uint32_t moder; /* 00: Port mode */
  221. uint32_t otyper; /* 04: Port output type */
  222. uint32_t ospeedr; /* 08: Port output speed */
  223. uint32_t pupdr; /* 0C: Port pull-up/pull-down */
  224. uint32_t idr; /* 10: Port input data */
  225. uint32_t odr; /* 14: Port output data */
  226. uint32_t bsrr; /* 18: Port bit set/reset */
  227. uint32_t lckr; /* 1C: Port configuration lock */
  228. uint32_t afrl; /* 20: Alternate function low */
  229. uint32_t afrh; /* 24: Alternate function high */
  230. };
  231. /* 0-1: MODE, 2: OTYPE, 3-4:OSPEED, 5-6:PUPD, 7:OUTPUT_LEVEL */
  232. #define GPI_analog 0x3u
  233. #define GPI_floating 0x0u
  234. #define _GPI_pulled(level) (0x0u|(((level)?1:2)<<5))
  235. #define GPI_pull_down _GPI_pulled(LOW)
  236. #define GPI_pull_up _GPI_pulled(HIGH)
  237. #define GPO_pushpull(speed,level) (0x1u|((speed)<<3)|((level)<<7))
  238. #define GPO_opendrain(speed,level) (0x5u|((speed)<<3)|((level)<<7))
  239. #define AFO_pushpull(speed) (0x2u|((speed)<<3))
  240. #define AFO_opendrain(speed) (0x6u|((speed)<<3))
  241. #define _4MHz 0 /* CL=50pF */
  242. #define _25MHz 1 /* CL=50pF */
  243. #define _50MHz 2 /* CL=40pF */
  244. #define _100MHz 3 /* CL=30pF */
  245. /* Compat defines */
  246. #define _2MHz _4MHz
  247. #define _10MHz _25MHz
  248. #define LOW 0
  249. #define HIGH 1
  250. #define GPIOA_BASE 0x40020000
  251. #define GPIOB_BASE 0x40020400
  252. #define GPIOC_BASE 0x40020800
  253. #define GPIOD_BASE 0x40020C00
  254. #define GPIOE_BASE 0x40021000
  255. #define GPIOF_BASE 0x40021400
  256. #define GPIOG_BASE 0x40021800
  257. #define GPIOH_BASE 0x40021C00
  258. #define GPIOI_BASE 0x40022000
  259. /* System configuration controller */
  260. struct syscfg {
  261. uint32_t memrmp; /* 00: Memory remap */
  262. uint32_t pmc; /* 04: Peripheral mode configuration */
  263. uint32_t exticr1; /* 08: External interrupt configuration #1 */
  264. uint32_t exticr2; /* 0C: External interrupt configuration #2 */
  265. uint32_t exticr3; /* 10: External interrupt configuration #3 */
  266. uint32_t exticr4; /* 14: External interrupt configuration #4 */
  267. uint32_t _pad[2];
  268. uint32_t cmpcr; /* 20: Compensation cell configuration */
  269. };
  270. #define SYSCFG_BASE 0x40013800
  271. #define EXTI_BASE 0x40013c00
  272. /* DMA */
  273. struct dma_str {
  274. uint32_t cr; /* +00: Configuration */
  275. uint32_t ndtr; /* +04: Number of data */
  276. uint32_t par; /* +08: Peripheral address */
  277. uint32_t m0ar; /* +0C: Memory 0 address */
  278. uint32_t m1ar; /* +10: Memory 1 address */
  279. uint32_t fcr; /* +14: FIFO control */
  280. };
  281. struct dma {
  282. uint32_t lisr; /* 00: Low interrupt status */
  283. uint32_t hisr; /* 00: High interrupt status */
  284. uint32_t lifcr; /* 00: Low interrupt flag clear */
  285. uint32_t hifcr; /* 00: High interrupt flag clear */
  286. struct dma_str str[8]; /* 0x10,0x28,..,0xB8: Stream 0,1,..,7 */
  287. };
  288. #define DMA_ISR_TCIF (1u<<5)
  289. #define DMA_ISR_HTIF (1u<<4)
  290. #define DMA_ISR_TEIF (1u<<3)
  291. #define DMA_ISR_DMEIF (1u<<2)
  292. #define DMA_ISR_FEIF (1u<<0)
  293. #define DMA_IFCR_CTCIF (1u<<5)
  294. #define DMA_IFCR_CHTIF (1u<<4)
  295. #define DMA_IFCR_CTEIF (1u<<3)
  296. #define DMA_IFCR_CDMEIF (1u<<2)
  297. #define DMA_IFCR_CFEIF (1u<<0)
  298. #define DMA_CR_CHSEL(x) ((x)<<25)
  299. #define DMA_CR_CT (1u<<19)
  300. #define DMA_CR_DBM (1u<<18)
  301. #define DMA_CR_PL_LOW (0u<<16)
  302. #define DMA_CR_PL_MEDIUM (1u<<16)
  303. #define DMA_CR_PL_HIGH (2u<<16)
  304. #define DMA_CR_PL_V_HIGH (3u<<16)
  305. #define DMA_CR_PINCOS (1u<<15)
  306. #define DMA_CR_MSIZE_8BIT (0u<<13)
  307. #define DMA_CR_MSIZE_16BIT (1u<<13)
  308. #define DMA_CR_MSIZE_32BIT (2u<<13)
  309. #define DMA_CR_PSIZE_8BIT (0u<<11)
  310. #define DMA_CR_PSIZE_16BIT (1u<<11)
  311. #define DMA_CR_PSIZE_32BIT (2u<<11)
  312. #define DMA_CR_MINC (1u<<10)
  313. #define DMA_CR_PINC (1u<< 9)
  314. #define DMA_CR_CIRC (1u<< 8)
  315. #define DMA_CR_DIR_M2M (2u<< 6)
  316. #define DMA_CR_DIR_M2P (1u<< 6)
  317. #define DMA_CR_DIR_P2M (0u<< 6)
  318. #define DMA_CR_PFCTRL (1u<< 5)
  319. #define DMA_CR_TCIE (1u<< 4)
  320. #define DMA_CR_HTIE (1u<< 3)
  321. #define DMA_CR_TEIE (1u<< 2)
  322. #define DMA_CR_DMEIE (1u<< 1)
  323. #define DMA_CR_EN (1u<< 0)
  324. #define DMA_FCR_DMDIS (1u<< 2)
  325. #define DMA1_BASE 0x40026000
  326. #define DMA2_BASE 0x40026400
  327. #define TIM1_BASE 0x40010000
  328. #define TIM2_BASE 0x40000000
  329. #define TIM3_BASE 0x40000400
  330. #define TIM4_BASE 0x40000800
  331. #define TIM5_BASE 0x40000c00
  332. #define TIM6_BASE 0x40001000
  333. #define TIM7_BASE 0x40001400
  334. #define TIM8_BASE 0x40010400
  335. #define TIM9_BASE 0x40014000
  336. #define TIM10_BASE 0x40014400
  337. #define TIM11_BASE 0x40014800
  338. #define TIM12_BASE 0x40001800
  339. #define TIM13_BASE 0x40001c00
  340. #define TIM14_BASE 0x40002000
  341. #define SPI4_BASE 0x40013400
  342. #define SPI5_BASE 0x40015000
  343. /* I2C */
  344. struct i2c {
  345. uint32_t cr1; /* 00: Control 1 */
  346. uint32_t cr2; /* 04: Control 2 */
  347. uint32_t oar1; /* 08: Own address 1 */
  348. uint32_t oar2; /* 0C: Own address 2 */
  349. uint32_t timingr; /* 10: Timing */
  350. uint32_t timeoutr; /* 14: Timeout */
  351. uint32_t isr; /* 18: Interrupt & status */
  352. uint32_t icr; /* 1C: Interrupt clear */
  353. uint32_t pecr; /* 20: PEC */
  354. uint32_t rxdr; /* 24: Receive data */
  355. uint32_t txdr; /* 28: Transmit data */
  356. };
  357. #define I2C_CR1_PECEN (1u<<23)
  358. #define I2C_CR1_ALERTEN (1u<<22)
  359. #define I2C_CR1_SMBDEN (1u<<21)
  360. #define I2C_CR1_SMBHEN (1u<<20)
  361. #define I2C_CR1_GCEN (1u<<19)
  362. #define I2C_CR1_NOSTRETCH (1u<<17)
  363. #define I2C_CR1_SBC (1u<<16)
  364. #define I2C_CR1_RXDMAEN (1u<<15)
  365. #define I2C_CR1_TXDMAEN (1u<<14)
  366. #define I2C_CR1_ANFOFF (1u<<12)
  367. #define I2C_CR1_DNF(x) ((x)<<8)
  368. #define I2C_CR1_ERRIE (1u<< 7)
  369. #define I2C_CR1_TCIE (1u<< 6)
  370. #define I2C_CR1_STOPIE (1u<< 5)
  371. #define I2C_CR1_NACKIE (1u<< 4)
  372. #define I2C_CR1_ADDRIE (1u<< 3)
  373. #define I2C_CR1_RXIE (1u<< 2)
  374. #define I2C_CR1_TXIE (1u<< 1)
  375. #define I2C_CR1_PE (1u<< 0)
  376. #define I2C_CR2_PECBYTE (1u<<26)
  377. #define I2C_CR2_AUTOEND (1u<<25)
  378. #define I2C_CR2_RELOAD (1u<<24)
  379. #define I2C_CR2_NBYTES(x) ((x)<<16)
  380. #define I2C_CR2_NACK (1u<<15)
  381. #define I2C_CR2_STOP (1u<<14)
  382. #define I2C_CR2_START (1u<<13)
  383. #define I2C_CR2_HEAD10R (1u<<12)
  384. #define I2C_CR2_ADD10 (1u<<11)
  385. #define I2C_CR2_RD_WRN (1u<<10)
  386. #define I2C_CR2_SADD(x) ((x)<<0)
  387. #define I2C_OA1_EN (1u<<15)
  388. #define I2C_OA1_MODE (1u<<10)
  389. #define I2C_ISR_DIR (1<<16)
  390. #define I2C_ISR_BUSY (1<<15)
  391. #define I2C_ISR_ALERT (1<<13)
  392. #define I2C_ISR_TIMEOUT (1<<12)
  393. #define I2C_ISR_PECERR (1<<11)
  394. #define I2C_ISR_OVR (1<<10)
  395. #define I2C_ISR_ARLO (1<< 9)
  396. #define I2C_ISR_BERR (1<< 8)
  397. #define I2C_ISR_TCR (1<< 7)
  398. #define I2C_ISR_TC (1<< 6)
  399. #define I2C_ISR_STOPF (1<< 5)
  400. #define I2C_ISR_NACKF (1<< 4)
  401. #define I2C_ISR_ADDR (1<< 3)
  402. #define I2C_ISR_RXNE (1<< 2)
  403. #define I2C_ISR_TXIS (1<< 1)
  404. #define I2C_ISR_TXE (1<< 0)
  405. #define I2C_ICR_ALERTCF (1<<13)
  406. #define I2C_ICR_TIMOUTCF (1<<12)
  407. #define I2C_ICR_PECCF (1<<11)
  408. #define I2C_ICR_OVRCF (1<<10)
  409. #define I2C_ICR_ARLOCF (1<< 9)
  410. #define I2C_ICR_BERRCF (1<< 8)
  411. #define I2C_ICR_STOPCF (1<< 5)
  412. #define I2C_ICR_NACKCF (1<< 4)
  413. #define I2C_ICR_ADDRCF (1<< 3)
  414. #define I2C1_BASE 0x40005400
  415. #define I2C2_BASE 0x40005800
  416. #define I2C3_BASE 0x40005C00
  417. /* USART */
  418. struct usart {
  419. uint32_t cr1; /* 00: Control #1 */
  420. uint32_t cr2; /* 00: Control #2 */
  421. uint32_t cr3; /* 00: Control #3 */
  422. uint32_t brr; /* 00: Baud rate */
  423. uint32_t gtpr; /* 00: Guard time & prescaler */
  424. uint32_t rtor; /* 00: Receive timeout */
  425. uint32_t rqr; /* 00: Request */
  426. uint32_t isr; /* 00: Interrupt & status */
  427. uint32_t icr; /* 00: Interrupt flag clear */
  428. uint32_t rdr; /* 00: Receive data */
  429. uint32_t tdr; /* 00: Transmit data */
  430. };
  431. #define USART_CR1_M1 (1u<<28)
  432. #define USART_CR1_OVER8 (1u<<15)
  433. #define USART_CR1_CMIE (1u<<14)
  434. #define USART_CR1_MME (1u<<13)
  435. #define USART_CR1_M0 (1u<<12)
  436. #define USART_CR1_WAKE (1u<<11)
  437. #define USART_CR1_PCE (1u<<10)
  438. #define USART_CR1_PS (1u<< 9)
  439. #define USART_CR1_PEIE (1u<< 8)
  440. #define USART_CR1_TXEIE (1u<< 7)
  441. #define USART_CR1_TCIE (1u<< 6)
  442. #define USART_CR1_RXNEIE (1u<< 5)
  443. #define USART_CR1_IDLEIE (1u<< 4)
  444. #define USART_CR1_TE (1u<< 3)
  445. #define USART_CR1_RE (1u<< 2)
  446. #define USART_CR1_UE (1u<< 0)
  447. #define USART_CR3_CTSIE (1u<<10)
  448. #define USART_CR3_CTSE (1u<< 9)
  449. #define USART_CR3_RTSE (1u<< 8)
  450. #define USART_CR3_DMAT (1u<< 7)
  451. #define USART_CR3_DMAR (1u<< 6)
  452. #define USART_CR3_SCEN (1u<< 5)
  453. #define USART_CR3_NACK (1u<< 4)
  454. #define USART_CR3_HDSEL (1u<< 3)
  455. #define USART_CR3_IRLP (1u<< 2)
  456. #define USART_CR3_IREN (1u<< 1)
  457. #define USART_CR3_EIE (1u<< 0)
  458. #define USART_RQR_TXFRQ (1u<< 4)
  459. #define USART_RQR_RXFRQ (1u<< 3)
  460. #define USART_RQR_MMRQ (1u<< 2)
  461. #define USART_RQR_SBKRQ (1u<< 1)
  462. #define USART_RQR_ABRRQ (1u<< 0)
  463. #define USART_ISR_TCBGT (1u<<25)
  464. #define USART_ISR_TEACK (1u<<21)
  465. #define USART_ISR_RWU (1u<<19)
  466. #define USART_ISR_SBKF (1u<<18)
  467. #define USART_ISR_CMF (1u<<17)
  468. #define USART_ISR_BUSY (1u<<16)
  469. #define USART_ISR_ABRF (1u<<15)
  470. #define USART_ISR_ABRE (1u<<14)
  471. #define USART_ISR_EOBF (1u<<12)
  472. #define USART_ISR_RTOF (1u<<11)
  473. #define USART_ISR_CTS (1u<<10)
  474. #define USART_ISR_CTSIF (1u<< 9)
  475. #define USART_ISR_LBDF (1u<< 8)
  476. #define USART_ISR_TXE (1u<< 7)
  477. #define USART_ISR_TC (1u<< 6)
  478. #define USART_ISR_RXNE (1u<< 5)
  479. #define USART_ISR_IDLE (1u<< 4)
  480. #define USART_ISR_ORE (1u<< 3)
  481. #define USART_ISR_NF (1u<< 2)
  482. #define USART_ISR_FE (1u<< 1)
  483. #define USART_ISR_PE (1u<< 0)
  484. #define USART_ICR_CMCF (1u<<17)
  485. #define USART_ICR_EOBCF (1u<<12)
  486. #define USART_ICR_RTOCF (1u<<11)
  487. #define USART_ICR_CTSCF (1u<< 9)
  488. #define USART_ICR_LBDCF (1u<< 8)
  489. #define USART_ICR_TCBGTCF (1u<< 7)
  490. #define USART_ICR_TCCF (1u<< 6)
  491. #define USART_ICR_IDLECF (1u<< 4)
  492. #define USART_ICR_ORECF (1u<< 3)
  493. #define USART_ICR_NCF (1u<< 2)
  494. #define USART_ICR_FECF (1u<< 1)
  495. #define USART_ICR_PECF (1u<< 0)
  496. #define USART1_BASE 0x40011000
  497. #define USART2_BASE 0x40004400
  498. #define USART3_BASE 0x40004800
  499. #define USART4_BASE 0x40004C00
  500. #define USART5_BASE 0x40005000
  501. #define USART6_BASE 0x40011400
  502. #define USB_OTG_FS_BASE 0x50000000
  503. #define USB_OTG_HS_BASE 0x40040000
  504. /*
  505. * Local variables:
  506. * mode: C
  507. * c-file-style: "Linux"
  508. * c-basic-offset: 4
  509. * tab-width: 4
  510. * indent-tabs-mode: nil
  511. * End:
  512. */