gd32f30x.h 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  1. /*!
  2. \file gd32f30x.h
  3. \brief general definitions for GD32F30x
  4. \version 2023-12-30, V2.2.0, firmware for GD32F30x
  5. */
  6. /* Copyright (c) 2012 ARM LIMITED
  7. Copyright (c) 2023, GigaDevice Semiconductor Inc.
  8. All rights reserved.
  9. Redistribution and use in source and binary forms, with or without
  10. modification, are permitted provided that the following conditions are met:
  11. - Redistributions of source code must retain the above copyright
  12. notice, this list of conditions and the following disclaimer.
  13. - Redistributions in binary form must reproduce the above copyright
  14. notice, this list of conditions and the following disclaimer in the
  15. documentation and/or other materials provided with the distribution.
  16. - Neither the name of ARM nor the names of its contributors may be used
  17. to endorse or promote products derived from this software without
  18. specific prior written permission.
  19. *
  20. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  21. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  22. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  23. ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
  24. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  25. CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  26. SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  27. INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  28. CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  29. ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  30. POSSIBILITY OF SUCH DAMAGE.
  31. ---------------------------------------------------------------------------*/
  32. /* This file refers the CMSIS standard, some adjustments are made according to GigaDevice chips */
  33. #ifndef GD32F30X_H
  34. #define GD32F30X_H
  35. #ifdef __cplusplus
  36. extern "C" {
  37. #endif
  38. /* define GD32F30x */
  39. #if !defined (GD32F30X_HD) && !defined (GD32F30X_XD) && !defined (GD32F30X_CL)
  40. /* #define GD32F30X_HD */
  41. /* #define GD32F30X_XD */
  42. /* #define GD32F30X_CL */
  43. #endif /* define GD32F30x */
  44. #if !defined (GD32F30X_HD) && !defined (GD32F30X_XD) && !defined (GD32F30X_CL)
  45. #error "Please select the target GD32F30x device in gd32f30x.h file"
  46. #endif /* undefine GD32F30x tip */
  47. /* define value of high speed crystal oscillator (HXTAL) in Hz */
  48. #if !defined HXTAL_VALUE
  49. #ifdef GD32F30X_CL
  50. #define HXTAL_VALUE ((uint32_t)25000000) /*!< value of the external oscillator in Hz */
  51. #else
  52. #define HXTAL_VALUE ((uint32_t)8000000) /* !< from 4M to 32M *!< value of the external oscillator in Hz*/
  53. #endif /* HXTAL_VALUE */
  54. #endif /* high speed crystal oscillator value */
  55. /* define startup timeout value of high speed crystal oscillator (HXTAL) */
  56. #if !defined (HXTAL_STARTUP_TIMEOUT)
  57. #define HXTAL_STARTUP_TIMEOUT ((uint16_t)0xFFFF)
  58. #endif /* high speed crystal oscillator startup timeout */
  59. /* define value of internal 48MHz RC oscillator (IRC48M) in Hz */
  60. #if !defined (IRC48M_VALUE)
  61. #define IRC48M_VALUE ((uint32_t)48000000)
  62. #endif /* internal 48MHz RC oscillator value */
  63. /* define value of internal 8MHz RC oscillator (IRC8M) in Hz */
  64. #if !defined (IRC8M_VALUE)
  65. #define IRC8M_VALUE ((uint32_t)8000000)
  66. #endif /* internal 8MHz RC oscillator value */
  67. /* define startup timeout value of internal 8MHz RC oscillator (IRC8M) */
  68. #if !defined (IRC8M_STARTUP_TIMEOUT)
  69. #define IRC8M_STARTUP_TIMEOUT ((uint16_t)0x0500)
  70. #endif /* internal 8MHz RC oscillator startup timeout */
  71. /* define value of internal 40KHz RC oscillator(IRC40K) in Hz */
  72. #if !defined (IRC40K_VALUE)
  73. #define IRC40K_VALUE ((uint32_t)40000)
  74. #endif /* internal 40KHz RC oscillator value */
  75. /* define value of low speed crystal oscillator (LXTAL)in Hz */
  76. #if !defined (LXTAL_VALUE)
  77. #define LXTAL_VALUE ((uint32_t)32768)
  78. #endif /* low speed crystal oscillator value */
  79. /* GD32F30x firmware library version number V1.0 */
  80. #define __GD32F30x_STDPERIPH_VERSION_MAIN (0x01) /*!< [31:24] main version */
  81. #define __GD32F30x_STDPERIPH_VERSION_SUB1 (0x00) /*!< [23:16] sub1 version */
  82. #define __GD32F30x_STDPERIPH_VERSION_SUB2 (0x00) /*!< [15:8] sub2 version */
  83. #define __GD32F30x_STDPERIPH_VERSION_RC (0x00) /*!< [7:0] release candidate */
  84. #define __GD32F30x_STDPERIPH_VERSION ((__GD32F30x_STDPERIPH_VERSION_MAIN << 24)\
  85. |(__GD32F30x_STDPERIPH_VERSION_SUB1 << 16)\
  86. |(__GD32F30x_STDPERIPH_VERSION_SUB2 << 8)\
  87. |(__GD32F30x_STDPERIPH_VERSION_RC))
  88. /* configuration of the Cortex-M4 processor and core peripherals */
  89. #define __CM4_REV 0x0001 /*!< Core revision r0p1 */
  90. #define __MPU_PRESENT 1 /*!< GD32F30x provide MPU */
  91. #define __NVIC_PRIO_BITS 4 /*!< GD32F30x uses 4 bits for the priority levels */
  92. #define __Vendor_SysTickConfig 0 /*!< set to 1 if different sysTick config is used */
  93. #define __FPU_PRESENT 1 /*!< FPU present */
  94. /* define interrupt number */
  95. typedef enum IRQn
  96. {
  97. /* Cortex-M4 processor exceptions numbers */
  98. NonMaskableInt_IRQn = -14, /*!< 2 non maskable interrupt */
  99. MemoryManagement_IRQn = -12, /*!< 4 Cortex-M4 memory management interrupt */
  100. BusFault_IRQn = -11, /*!< 5 Cortex-M4 bus fault interrupt */
  101. UsageFault_IRQn = -10, /*!< 6 Cortex-M4 usage fault interrupt */
  102. SVCall_IRQn = -5, /*!< 11 Cortex-M4 SV call interrupt */
  103. DebugMonitor_IRQn = -4, /*!< 12 Cortex-M4 debug monitor interrupt */
  104. PendSV_IRQn = -2, /*!< 14 Cortex-M4 pend SV interrupt */
  105. SysTick_IRQn = -1, /*!< 15 Cortex-M4 system tick interrupt */
  106. /* interruput numbers */
  107. WWDGT_IRQn = 0, /*!< window watchDog timer interrupt */
  108. LVD_IRQn = 1, /*!< LVD through EXTI line detect interrupt */
  109. TAMPER_IRQn = 2, /*!< tamper through EXTI line detect */
  110. RTC_IRQn = 3, /*!< RTC through EXTI line interrupt */
  111. FMC_IRQn = 4, /*!< FMC interrupt */
  112. RCU_CTC_IRQn = 5, /*!< RCU and CTC interrupt */
  113. EXTI0_IRQn = 6, /*!< EXTI line 0 interrupt */
  114. EXTI1_IRQn = 7, /*!< EXTI line 1 interrupt */
  115. EXTI2_IRQn = 8, /*!< EXTI line 2 interrupt */
  116. EXTI3_IRQn = 9, /*!< EXTI line 3 interrupt */
  117. EXTI4_IRQn = 10, /*!< EXTI line 4 interrupt */
  118. DMA0_Channel0_IRQn = 11, /*!< DMA0 channel0 interrupt */
  119. DMA0_Channel1_IRQn = 12, /*!< DMA0 channel1 interrupt */
  120. DMA0_Channel2_IRQn = 13, /*!< DMA0 channel2 interrupt */
  121. DMA0_Channel3_IRQn = 14, /*!< DMA0 channel3 interrupt */
  122. DMA0_Channel4_IRQn = 15, /*!< DMA0 channel4 interrupt */
  123. DMA0_Channel5_IRQn = 16, /*!< DMA0 channel5 interrupt */
  124. DMA0_Channel6_IRQn = 17, /*!< DMA0 channel6 interrupt */
  125. ADC0_1_IRQn = 18, /*!< ADC0 and ADC1 interrupt */
  126. #ifdef GD32F30X_HD
  127. USBD_HP_CAN0_TX_IRQn = 19, /*!< CAN0 TX interrupts */
  128. USBD_LP_CAN0_RX0_IRQn = 20, /*!< CAN0 RX0 interrupts */
  129. CAN0_RX1_IRQn = 21, /*!< CAN0 RX1 interrupt */
  130. CAN0_EWMC_IRQn = 22, /*!< CAN0 EWMC interrupt */
  131. EXTI5_9_IRQn = 23, /*!< EXTI[9:5] interrupts */
  132. TIMER0_BRK_IRQn = 24, /*!< TIMER0 break interrupt */
  133. TIMER0_UP_IRQn = 25, /*!< TIMER0 update interrupt */
  134. TIMER0_TRG_CMT_IRQn = 26, /*!< TIMER0 trigger and commutation interrupt */
  135. TIMER0_Channel_IRQn = 27, /*!< TIMER0 channel capture compare interrupt */
  136. TIMER1_IRQn = 28, /*!< TIMER1 interrupt */
  137. TIMER2_IRQn = 29, /*!< TIMER2 interrupt */
  138. TIMER3_IRQn = 30, /*!< TIMER3 interrupt */
  139. I2C0_EV_IRQn = 31, /*!< I2C0 event interrupt */
  140. I2C0_ER_IRQn = 32, /*!< I2C0 error interrupt */
  141. I2C1_EV_IRQn = 33, /*!< I2C1 event interrupt */
  142. I2C1_ER_IRQn = 34, /*!< I2C1 error interrupt */
  143. SPI0_IRQn = 35, /*!< SPI0 interrupt */
  144. SPI1_IRQn = 36, /*!< SPI1 interrupt */
  145. USART0_IRQn = 37, /*!< USART0 interrupt */
  146. USART1_IRQn = 38, /*!< USART1 interrupt */
  147. USART2_IRQn = 39, /*!< USART2 interrupt */
  148. EXTI10_15_IRQn = 40, /*!< EXTI[15:10] interrupts */
  149. RTC_Alarm_IRQn = 41, /*!< RTC alarm interrupt */
  150. USBD_WKUP_IRQn = 42, /*!< USBD Wakeup interrupt */
  151. TIMER7_BRK_IRQn = 43, /*!< TIMER7 break interrupt */
  152. TIMER7_UP_IRQn = 44, /*!< TIMER7 update interrupt */
  153. TIMER7_TRG_CMT_IRQn = 45, /*!< TIMER7 trigger and commutation interrupt */
  154. TIMER7_Channel_IRQn = 46, /*!< TIMER7 channel capture compare interrupt */
  155. ADC2_IRQn = 47, /*!< ADC2 global interrupt */
  156. EXMC_IRQn = 48, /*!< EXMC global interrupt */
  157. SDIO_IRQn = 49, /*!< SDIO global interrupt */
  158. TIMER4_IRQn = 50, /*!< TIMER4 global interrupt */
  159. SPI2_IRQn = 51, /*!< SPI2 global interrupt */
  160. UART3_IRQn = 52, /*!< UART3 global interrupt */
  161. UART4_IRQn = 53, /*!< UART4 global interrupt */
  162. TIMER5_IRQn = 54, /*!< TIMER5 global interrupt */
  163. TIMER6_IRQn = 55, /*!< TIMER6 global interrupt */
  164. DMA1_Channel0_IRQn = 56, /*!< DMA1 channel0 global interrupt */
  165. DMA1_Channel1_IRQn = 57, /*!< DMA1 channel1 global interrupt */
  166. DMA1_Channel2_IRQn = 58, /*!< DMA1 channel2 global interrupt */
  167. DMA1_Channel3_Channel4_IRQn = 59, /*!< DMA1 channel3 and channel4 global Interrupt */
  168. #endif /* GD32F30X_HD */
  169. #ifdef GD32F30X_XD
  170. USBD_HP_CAN0_TX_IRQn = 19, /*!< CAN0 TX interrupts */
  171. USBD_LP_CAN0_RX0_IRQn = 20, /*!< CAN0 RX0 interrupts */
  172. CAN0_RX1_IRQn = 21, /*!< CAN0 RX1 interrupt */
  173. CAN0_EWMC_IRQn = 22, /*!< CAN0 EWMC interrupt */
  174. EXTI5_9_IRQn = 23, /*!< EXTI[9:5] interrupts */
  175. TIMER0_BRK_TIMER8_IRQn = 24, /*!< TIMER0 break and TIMER8 interrupt */
  176. TIMER0_UP_TIMER9_IRQn = 25, /*!< TIMER0 update and TIMER9 interrupt */
  177. TIMER0_TRG_CMT_TIMER10_IRQn = 26, /*!< TIMER0 trigger and commutation and TIMER10 interrupt */
  178. TIMER0_Channel_IRQn = 27, /*!< TIMER0 channel capture compare interrupt */
  179. TIMER1_IRQn = 28, /*!< TIMER1 interrupt */
  180. TIMER2_IRQn = 29, /*!< TIMER2 interrupt */
  181. TIMER3_IRQn = 30, /*!< TIMER3 interrupt */
  182. I2C0_EV_IRQn = 31, /*!< I2C0 event interrupt */
  183. I2C0_ER_IRQn = 32, /*!< I2C0 error interrupt */
  184. I2C1_EV_IRQn = 33, /*!< I2C1 event interrupt */
  185. I2C1_ER_IRQn = 34, /*!< I2C1 error interrupt */
  186. SPI0_IRQn = 35, /*!< SPI0 interrupt */
  187. SPI1_IRQn = 36, /*!< SPI1 interrupt */
  188. USART0_IRQn = 37, /*!< USART0 interrupt */
  189. USART1_IRQn = 38, /*!< USART1 interrupt */
  190. USART2_IRQn = 39, /*!< USART2 interrupt */
  191. EXTI10_15_IRQn = 40, /*!< EXTI[15:10] interrupts */
  192. RTC_Alarm_IRQn = 41, /*!< RTC alarm interrupt */
  193. USBD_WKUP_IRQn = 42, /*!< USBD wakeup interrupt */
  194. TIMER7_BRK_TIMER11_IRQn = 43, /*!< TIMER7 break and TIMER11 interrupt */
  195. TIMER7_UP_TIMER12_IRQn = 44, /*!< TIMER7 update and TIMER12 interrupt */
  196. TIMER7_TRG_CMT_TIMER13_IRQn = 45, /*!< TIMER7 trigger and commutation and TIMER13 interrupt */
  197. TIMER7_Channel_IRQn = 46, /*!< TIMER7 channel capture compare interrupt */
  198. ADC2_IRQn = 47, /*!< ADC2 global interrupt */
  199. EXMC_IRQn = 48, /*!< EXMC global interrupt */
  200. SDIO_IRQn = 49, /*!< SDIO global interrupt */
  201. TIMER4_IRQn = 50, /*!< TIMER4 global interrupt */
  202. SPI2_IRQn = 51, /*!< SPI2 global interrupt */
  203. UART3_IRQn = 52, /*!< UART3 global interrupt */
  204. UART4_IRQn = 53, /*!< UART4 global interrupt */
  205. TIMER5_IRQn = 54, /*!< TIMER5 global interrupt */
  206. TIMER6_IRQn = 55, /*!< TIMER6 global interrupt */
  207. DMA1_Channel0_IRQn = 56, /*!< DMA1 channel0 global interrupt */
  208. DMA1_Channel1_IRQn = 57, /*!< DMA1 channel1 global interrupt */
  209. DMA1_Channel2_IRQn = 58, /*!< DMA1 channel2 global interrupt */
  210. DMA1_Channel3_Channel4_IRQn = 59, /*!< DMA1 channel3 and channel4 global interrupt */
  211. #endif /* GD32F30X_XD */
  212. #ifdef GD32F30X_CL
  213. CAN0_TX_IRQn = 19, /*!< CAN0 TX interrupt */
  214. CAN0_RX0_IRQn = 20, /*!< CAN0 RX0 interrupt */
  215. CAN0_RX1_IRQn = 21, /*!< CAN0 RX1 interrupt */
  216. CAN0_EWMC_IRQn = 22, /*!< CAN0 EWMC interrupt */
  217. EXTI5_9_IRQn = 23, /*!< EXTI[9:5] interrupts */
  218. TIMER0_BRK_TIMER8_IRQn = 24, /*!< TIMER0 break and TIMER8 interrupt */
  219. TIMER0_UP_TIMER9_IRQn = 25, /*!< TIMER0 update and TIMER9 interrupt */
  220. TIMER0_TRG_CMT_TIMER10_IRQn = 26, /*!< TIMER0 trigger and commutation and TIMER10 interrupt */
  221. TIMER0_Channel_IRQn = 27, /*!< TIMER0 channel capture compare interrupt */
  222. TIMER1_IRQn = 28, /*!< TIMER1 interrupt */
  223. TIMER2_IRQn = 29, /*!< TIMER2 interrupt */
  224. TIMER3_IRQn = 30, /*!< TIMER3 interrupt */
  225. I2C0_EV_IRQn = 31, /*!< I2C0 event interrupt */
  226. I2C0_ER_IRQn = 32, /*!< I2C0 error interrupt */
  227. I2C1_EV_IRQn = 33, /*!< I2C1 event interrupt */
  228. I2C1_ER_IRQn = 34, /*!< I2C1 error interrupt */
  229. SPI0_IRQn = 35, /*!< SPI0 interrupt */
  230. SPI1_IRQn = 36, /*!< SPI1 interrupt */
  231. USART0_IRQn = 37, /*!< USART0 interrupt */
  232. USART1_IRQn = 38, /*!< USART1 interrupt */
  233. USART2_IRQn = 39, /*!< USART2 interrupt */
  234. EXTI10_15_IRQn = 40, /*!< EXTI[15:10] interrupts */
  235. RTC_Alarm_IRQn = 41, /*!< RTC alarm interrupt */
  236. USBFS_WKUP_IRQn = 42, /*!< USBFS wakeup interrupt */
  237. TIMER7_BRK_TIMER11_IRQn = 43, /*!< TIMER7 break and TIMER11 interrupt */
  238. TIMER7_UP_TIMER12_IRQn = 44, /*!< TIMER7 update and TIMER12 interrupt */
  239. TIMER7_TRG_CMT_TIMER13_IRQn = 45, /*!< TIMER7 trigger and commutation and TIMER13 interrupt */
  240. TIMER7_Channel_IRQn = 46, /*!< TIMER7 channel capture compare interrupt */
  241. EXMC_IRQn = 48, /*!< EXMC global interrupt */
  242. TIMER4_IRQn = 50, /*!< TIMER4 global interrupt */
  243. SPI2_IRQn = 51, /*!< SPI2 global interrupt */
  244. UART3_IRQn = 52, /*!< UART3 global interrupt */
  245. UART4_IRQn = 53, /*!< UART4 global interrupt */
  246. TIMER5_IRQn = 54, /*!< TIMER5 global interrupt */
  247. TIMER6_IRQn = 55, /*!< TIMER6 global interrupt */
  248. DMA1_Channel0_IRQn = 56, /*!< DMA1 channel0 global interrupt */
  249. DMA1_Channel1_IRQn = 57, /*!< DMA1 channel1 global interrupt */
  250. DMA1_Channel2_IRQn = 58, /*!< DMA1 channel2 global interrupt */
  251. DMA1_Channel3_IRQn = 59, /*!< DMA1 channel3 global interrupt */
  252. DMA1_Channel4_IRQn = 60, /*!< DMA1 channel3 global interrupt */
  253. ENET_IRQn = 61, /*!< ENET global interrupt */
  254. ENET_WKUP_IRQn = 62, /*!< ENET Wakeup interrupt */
  255. CAN1_TX_IRQn = 63, /*!< CAN1 TX interrupt */
  256. CAN1_RX0_IRQn = 64, /*!< CAN1 RX0 interrupt */
  257. CAN1_RX1_IRQn = 65, /*!< CAN1 RX1 interrupt */
  258. CAN1_EWMC_IRQn = 66, /*!< CAN1 EWMC interrupt */
  259. USBFS_IRQn = 67, /*!< USBFS global interrupt */
  260. #endif /* GD32F30X_CL */
  261. } IRQn_Type;
  262. /* includes */
  263. #include "core_cm4.h"
  264. #include "system_gd32f30x.h"
  265. #include <stdint.h>
  266. /* enum definitions */
  267. typedef enum {DISABLE = 0, ENABLE = !DISABLE} EventStatus, ControlStatus;
  268. typedef enum {RESET = 0, SET = !RESET} FlagStatus;
  269. typedef enum {ERROR = 0, SUCCESS = !ERROR} ErrStatus;
  270. /* bit operations */
  271. #define REG32(addr) (*(volatile uint32_t *)(uint32_t)(addr))
  272. #define REG16(addr) (*(volatile uint16_t *)(uint32_t)(addr))
  273. #define REG8(addr) (*(volatile uint8_t *)(uint32_t)(addr))
  274. #define BIT(x) ((uint32_t)((uint32_t)0x01U<<(x)))
  275. #define BITS(start, end) ((0xFFFFFFFFUL << (start)) & (0xFFFFFFFFUL >> (31U - (uint32_t)(end))))
  276. #define GET_BITS(regval, start, end) (((regval) & BITS((start),(end))) >> (start))
  277. /* main flash and SRAM memory map */
  278. #define FLASH_BASE ((uint32_t)0x08000000U) /*!< main FLASH base address */
  279. #define SRAM_BASE ((uint32_t)0x20000000U) /*!< SRAM0 base address */
  280. #define OB_BASE ((uint32_t)0x1FFFF800U) /*!< OB base address */
  281. #define DBG_BASE ((uint32_t)0xE0042000U) /*!< DBG base address */
  282. #define EXMC_BASE ((uint32_t)0xA0000000U) /*!< EXMC register base address */
  283. /* peripheral memory map */
  284. #define APB1_BUS_BASE ((uint32_t)0x40000000U) /*!< apb1 base address */
  285. #define APB2_BUS_BASE ((uint32_t)0x40010000U) /*!< apb2 base address */
  286. #define AHB1_BUS_BASE ((uint32_t)0x40018000U) /*!< ahb1 base address */
  287. #define AHB3_BUS_BASE ((uint32_t)0x60000000U) /*!< ahb3 base address */
  288. /* advanced peripheral bus 1 memory map */
  289. #define TIMER_BASE (APB1_BUS_BASE + 0x00000000U) /*!< TIMER base address */
  290. #define RTC_BASE (APB1_BUS_BASE + 0x00002800U) /*!< RTC base address */
  291. #define WWDGT_BASE (APB1_BUS_BASE + 0x00002C00U) /*!< WWDGT base address */
  292. #define FWDGT_BASE (APB1_BUS_BASE + 0x00003000U) /*!< FWDGT base address */
  293. #define SPI_BASE (APB1_BUS_BASE + 0x00003800U) /*!< SPI base address */
  294. #define USART_BASE (APB1_BUS_BASE + 0x00004400U) /*!< USART base address */
  295. #define I2C_BASE (APB1_BUS_BASE + 0x00005400U) /*!< I2C base address */
  296. #define USBD_BASE (APB1_BUS_BASE + 0x00005C00U) /*!< USBD base address */
  297. #define USBD_RAM_BASE (APB1_BUS_BASE + 0x00006000U) /*!< USBD RAM base address */
  298. #define CAN_BASE (APB1_BUS_BASE + 0x00006400U) /*!< CAN base address */
  299. #define BKP_BASE (APB1_BUS_BASE + 0x00006C00U) /*!< BKP base address */
  300. #define PMU_BASE (APB1_BUS_BASE + 0x00007000U) /*!< PMU base address */
  301. #define DAC_BASE (APB1_BUS_BASE + 0x00007400U) /*!< DAC base address */
  302. #define CTC_BASE (APB1_BUS_BASE + 0x0000C800U) /*!< CTC base address */
  303. /* advanced peripheral bus 2 memory map */
  304. #define AFIO_BASE (APB2_BUS_BASE + 0x00000000U) /*!< AFIO base address */
  305. #define EXTI_BASE (APB2_BUS_BASE + 0x00000400U) /*!< EXTI base address */
  306. #define GPIO_BASE (APB2_BUS_BASE + 0x00000800U) /*!< GPIO base address */
  307. #define ADC_BASE (APB2_BUS_BASE + 0x00002400U) /*!< ADC base address */
  308. /* advanced high performance bus 1 memory map */
  309. #define SDIO_BASE (AHB1_BUS_BASE + 0x00000000U) /*!< SDIO base address */
  310. #define DMA_BASE (AHB1_BUS_BASE + 0x00008000U) /*!< DMA base address */
  311. #define RCU_BASE (AHB1_BUS_BASE + 0x00009000U) /*!< RCU base address */
  312. #define FMC_BASE (AHB1_BUS_BASE + 0x0000A000U) /*!< FMC base address */
  313. #define CRC_BASE (AHB1_BUS_BASE + 0x0000B000U) /*!< CRC base address */
  314. #define ENET_BASE (AHB1_BUS_BASE + 0x00010000U) /*!< ENET base address */
  315. #define USBFS_BASE (AHB1_BUS_BASE + 0x0FFE8000U) /*!< USBFS base address */
  316. /** @addtogroup Exported_types
  317. * @{
  318. */
  319. /*!< STM32F10x Standard Peripheral Library old types (maintained for legacy purpose) */
  320. typedef int32_t s32;
  321. typedef int16_t s16;
  322. typedef int8_t s8;
  323. typedef const int32_t sc32; /*!< Read Only */
  324. typedef const int16_t sc16; /*!< Read Only */
  325. typedef const int8_t sc8; /*!< Read Only */
  326. typedef __IO int32_t vs32;
  327. typedef __IO int16_t vs16;
  328. typedef __IO int8_t vs8;
  329. typedef __I int32_t vsc32; /*!< Read Only */
  330. typedef __I int16_t vsc16; /*!< Read Only */
  331. typedef __I int8_t vsc8; /*!< Read Only */
  332. typedef uint32_t u32;
  333. typedef uint16_t u16;
  334. typedef uint8_t u8;
  335. typedef const uint32_t uc32; /*!< Read Only */
  336. typedef const uint16_t uc16; /*!< Read Only */
  337. typedef const uint8_t uc8; /*!< Read Only */
  338. typedef __IO uint32_t vu32;
  339. typedef __IO uint16_t vu16;
  340. typedef __IO uint8_t vu8;
  341. typedef __I uint32_t vuc32; /*!< Read Only */
  342. typedef __I uint16_t vuc16; /*!< Read Only */
  343. typedef __I uint8_t vuc8; /*!< Read Only */
  344. #define GPIOA_BASE (APB2_BUS_BASE + 0x0800)
  345. #define GPIOB_BASE (APB2_BUS_BASE + 0x0C00)
  346. #define GPIOC_BASE (APB2_BUS_BASE + 0x1000)
  347. #define GPIOD_BASE (APB2_BUS_BASE + 0x1400)
  348. #define GPIOE_BASE (APB2_BUS_BASE + 0x1800)
  349. #define GPIOF_BASE (APB2_BUS_BASE + 0x1C00)
  350. #define GPIOG_BASE (APB2_BUS_BASE + 0x2000)
  351. typedef enum {FALSE = 0, TRUE = !FALSE} bool;
  352. /**
  353. * @brief General Purpose I/O
  354. */
  355. typedef struct
  356. {
  357. __IO uint32_t CRL;
  358. __IO uint32_t CRH;
  359. __IO uint32_t IDR;
  360. __IO uint32_t ODR;
  361. __IO uint32_t BSRR;
  362. __IO uint32_t BRR;
  363. __IO uint32_t LCKR;
  364. } GPIO_TypeDef;
  365. /* define marco USE_STDPERIPH_DRIVER */
  366. #if !defined USE_STDPERIPH_DRIVER
  367. #define USE_STDPERIPH_DRIVER
  368. #endif
  369. #ifdef USE_STDPERIPH_DRIVER
  370. #include "gd32f30x_libopt.h"
  371. #endif /* USE_STDPERIPH_DRIVER */
  372. #ifdef __cplusplus
  373. }
  374. #endif
  375. #endif