18#ifndef __HAL_DRIVER_GIGADEVICE_GD32H7XX_COMMON_H__
19#define __HAL_DRIVER_GIGADEVICE_GD32H7XX_COMMON_H__
32#define VSF_HW_CLKRST_REGION(__WORD_OFFSET, __BIT_OFFSET, __BIT_LENGTH) \
33 (((__WORD_OFFSET) << 16) | ((__BIT_LENGTH) << 8) | ((__BIT_OFFSET) << 0))
37#define VSF_HW_PLL_IN_RANGE_1M_2M 0
38#define VSF_HW_PLL_IN_RANGE_2M_4M 1
39#define VSF_HW_PLL_IN_RANGE_4M_8M 2
40#define VSF_HW_PLL_IN_RANGE_8M_16M 3
41#define VSF_HW_PLL_OUT_RANGE_192M_836M 0
42#define VSF_HW_PLL_OUT_RANGE_150M_420M 1
44#define vsf_hw_peripheral_clk_set vsf_hw_clkrst_region_set
45#define vsf_hw_peripheral_clk_get vsf_hw_clkrst_region_get
47#define vsf_hw_peripheral_rst_set vsf_hw_clkrst_region_set_bit
48#define vsf_hw_peripheral_rst_clear vsf_hw_clkrst_region_clear_bit
49#define vsf_hw_peripheral_rst_get vsf_hw_clkrst_region_get_bit
51#define vsf_hw_peripheral_enable vsf_hw_clkrst_region_set_bit
52#define vsf_hw_peripheral_disable vsf_hw_clkrst_region_clear_bit
54#define VSF_SYSTIMER_FREQ vsf_hw_clk_get_freq_hz(&VSF_HW_CLK_SYS)
328#define VSF_HW_CLK_APB1 VSF_HW_CLK_PCLK1
330#define VSF_HW_CLK_APB2 VSF_HW_CLK_PCLK2
332#define VSF_HW_CLK_APB3 VSF_HW_CLK_PCLK3
334#define VSF_HW_CLK_APB4 VSF_HW_CLK_PCLK4
336#if VSF_HAL_USE_USART == ENABLED
340#define VSF_HW_CLK_UART3 VSF_HW_CLK_APB1
341#define VSF_HW_CLK_UART4 VSF_HW_CLK_APB1
343#define VSF_HW_CLK_UART6 VSF_HW_CLK_APB1
344#define VSF_HW_CLK_UART7 VSF_HW_CLK_APB1
347#if VSF_HAL_USE_SDIO == ENABLED
vsf_err_t
Definition __type.h:42
vsf_hw_peripheral_rst_t
Definition common.h:58
@ VSF_HW_RST_SPI5
Definition common.h:144
@ VSF_HW_RST_RSPDIF
Definition common.h:119
@ VSF_HW_RST_DAC
Definition common.h:105
@ VSF_HW_RST_TIMER31
Definition common.h:122
@ VSF_HW_RST_TIMER23
Definition common.h:124
@ VSF_HW_RST_OSPI0
Definition common.h:81
@ VSF_HW_RST_DMA1
Definition common.h:63
@ VSF_HW_RST_SPI4
Definition common.h:145
@ VSF_HW_RST_TIMER2
Definition common.h:130
@ VSF_HW_RST_TIMER41
Definition common.h:139
@ VSF_HW_RST_EXMC
Definition common.h:86
@ VSF_HW_RST_CMP
Definition common.h:168
@ VSF_HW_RST_ENET0
Definition common.h:61
@ VSF_HW_RST_FAC
Definition common.h:74
@ VSF_HW_RST_SPI2
Definition common.h:117
@ VSF_HW_RST_GPIOJ
Definition common.h:92
@ VSF_HW_RST_ENET1
Definition common.h:66
@ VSF_HW_RST_TLI
Definition common.h:162
@ VSF_HW_RST_DMA0
Definition common.h:64
@ VSF_HW_RST_VREF
Definition common.h:167
@ VSF_HW_RST_USART0
Definition common.h:156
@ VSF_HW_RST_TIMER42
Definition common.h:138
@ VSF_HW_RST_SDIO0
Definition common.h:84
@ VSF_HW_RST_OSPI1
Definition common.h:80
@ VSF_HW_RST_I2C2
Definition common.h:109
@ VSF_HW_RST_MDMA
Definition common.h:83
@ VSF_HW_RST_RTDEC0
Definition common.h:79
@ VSF_HW_RST_TIMER22
Definition common.h:125
@ VSF_HW_RST_DCI
Definition common.h:75
@ VSF_HW_RST_CAU
Definition common.h:72
@ VSF_HW_RST_PMU
Definition common.h:165
@ VSF_HW_RST_EDOUT
Definition common.h:135
@ VSF_HW_RST_SPI1
Definition common.h:118
@ VSF_HW_RST_TIMER44
Definition common.h:136
@ VSF_HW_RST_TIMER6
Definition common.h:126
@ VSF_HW_RST_UART3
Definition common.h:113
@ VSF_HW_RST_SAI0
Definition common.h:143
@ VSF_HW_RST_TIMER40
Definition common.h:140
@ VSF_HW_RST_GPIOK
Definition common.h:91
@ VSF_HW_RST_IPA
Definition common.h:85
@ VSF_HW_RST_WWDGT
Definition common.h:161
@ VSF_HW_RST_I2C0
Definition common.h:111
@ VSF_HW_RST_I2C1
Definition common.h:110
@ VSF_HW_RST_RTDEC1
Definition common.h:78
@ VSF_HW_RST_TIMER16
Definition common.h:147
@ VSF_HW_RST_TIMER51
Definition common.h:120
@ VSF_HW_RST_TIMER7
Definition common.h:157
@ VSF_HW_RST_TIMER30
Definition common.h:123
@ VSF_HW_RST_TRNG
Definition common.h:70
@ VSF_HW_RST_DMAMUX
Definition common.h:62
@ VSF_HW_RST_UART6
Definition common.h:104
@ VSF_HW_RST_HWSEM
Definition common.h:89
@ VSF_HW_RST_TIMER15
Definition common.h:148
@ VSF_HW_RST_HPDF
Definition common.h:146
@ VSF_HW_RST_HAU
Definition common.h:71
@ VSF_HW_RST_SAI2
Definition common.h:141
@ VSF_HW_RST_LPDTS
Definition common.h:166
@ VSF_HW_RST_TRIGSEL
Definition common.h:134
@ VSF_HW_RST_SDIO1
Definition common.h:73
@ VSF_HW_RST_CTC
Definition common.h:107
@ VSF_HW_RST_TIMER43
Definition common.h:137
@ VSF_HW_RST_SYSCFG
Definition common.h:169
@ VSF_HW_RST_USART5
Definition common.h:155
@ VSF_HW_RST_TIMER5
Definition common.h:127
@ VSF_HW_RST_TMU
Definition common.h:69
@ VSF_HW_RST_ADC2
Definition common.h:152
@ VSF_HW_RST_TIMER14
Definition common.h:149
@ VSF_HW_RST_TIMER1
Definition common.h:131
@ VSF_HW_RST_DACHOLD
Definition common.h:106
@ VSF_HW_RST_TIMER4
Definition common.h:128
@ VSF_HW_RST_OSPIM
Definition common.h:82
@ VSF_HW_RST_I2C3
Definition common.h:108
@ VSF_HW_RST_MDIO
Definition common.h:116
@ VSF_HW_RST_TIMER3
Definition common.h:129
@ VSF_HW_RST_SPI0
Definition common.h:151
@ VSF_HW_RST_USBHS0
Definition common.h:65
@ VSF_HW_RST_SAI1
Definition common.h:142
@ VSF_HW_RST_USBHS1
Definition common.h:60
@ VSF_HW_RST_ADC1
Definition common.h:153
@ VSF_HW_RST_TIMER50
Definition common.h:121
@ VSF_HW_RST_TIMER0
Definition common.h:158
@ VSF_HW_RST_ADC0
Definition common.h:154
vsf_err_t vsf_hw_pll_vco_config(const vsf_hw_clk_t *clk, uint_fast8_t src_prescaler, uint32_t vco_freq_hz)
configure frequency range of pll input/output clocks
Definition driver.c:745
const vsf_hw_clk_t VSF_HW_CLK_HXTAL
Definition driver.c:109
const vsf_hw_clk_t VSF_HW_CLK_PLL0R
Definition driver.c:226
const vsf_hw_clk_t VSF_HW_CLK_PLL0Q
Definition driver.c:215
const vsf_hw_clk_t VSF_HW_CLK_LXTAL
Definition driver.c:117
const vsf_hw_clk_t VSF_HW_CLK_PLL2P
Definition driver.c:270
#define VSF_HW_CLKRST_REGION(__WORD_OFFSET, __BIT_OFFSET, __BIT_LENGTH)
Definition common.h:32
const vsf_hw_clk_t VSF_HW_CLK_PLL1R
Definition driver.c:259
const vsf_hw_clk_t VSF_HW_CLK_PLL1P
Definition driver.c:237
const vsf_hw_clk_t VSF_HW_CLK_IRC32K
Definition driver.c:145
const vsf_hw_clk_t VSF_HW_CLK_PLL2R
Definition driver.c:292
const vsf_hw_clk_t VSF_HW_CLK_AHB
Definition driver.c:343
bool vsf_hw_clk_is_ready(const vsf_hw_clk_t *clk)
Definition driver.c:667
const vsf_hw_clk_t VSF_HW_CLK_RTC
Definition driver.c:316
const vsf_hw_clk_t VSF_HW_CLK_IRC64MDIV
Definition driver.c:125
vsf_err_t vsf_hw_clk_config(const vsf_hw_clk_t *clk, const vsf_hw_clk_t *clksrc, uint16_t prescaler, uint32_t freq_hz)
Definition driver.c:675
const vsf_hw_clk_t VSF_HW_CLK_PLL2Q
Definition driver.c:281
const vsf_hw_clk_t VSF_HW_CLK_SDIO0
Definition driver.c:443
const vsf_hw_clk_t VSF_HW_CLK_PLL1Q
Definition driver.c:248
void vsf_hw_clk_disable(const vsf_hw_clk_t *clk)
Definition driver.c:651
vsf_hw_peripheral_en_t
Definition common.h:172
@ VSF_HW_EN_TIMER30
Definition common.h:249
@ VSF_HW_EN_LPDTS
Definition common.h:292
@ VSF_HW_EN_ADC1
Definition common.h:279
@ VSF_HW_EN_TRIGSEL
Definition common.h:260
@ VSF_HW_EN_WWDGT
Definition common.h:287
@ VSF_HW_EN_TMU
Definition common.h:192
@ VSF_HW_EN_SDIO1
Definition common.h:196
@ VSF_HW_EN_USART0
Definition common.h:282
@ VSF_HW_EN_MDMA
Definition common.h:208
@ VSF_HW_EN_TIMER43
Definition common.h:263
@ VSF_HW_EN_ADC2
Definition common.h:278
@ VSF_HW_EN_TIMER16
Definition common.h:273
@ VSF_HW_EN_HWSEM
Definition common.h:214
@ VSF_HW_EN_USBHS1
Definition common.h:175
@ VSF_HW_EN_EXMC
Definition common.h:211
@ VSF_HW_EN_TIMER31
Definition common.h:248
@ VSF_HW_EN_SPI2
Definition common.h:243
@ VSF_HW_EN_HPDF
Definition common.h:272
@ VSF_HW_EN_MDIO
Definition common.h:242
@ VSF_HW_EN_TIMER4
Definition common.h:254
@ VSF_HW_EN_TIMER6
Definition common.h:252
@ VSF_HW_EN_TIMER5
Definition common.h:253
@ VSF_HW_EN_DMAMUX
Definition common.h:180
@ VSF_HW_EN_SPI1
Definition common.h:244
@ VSF_HW_EN_TIMER22
Definition common.h:251
@ VSF_HW_EN_BKPSRAM
Definition common.h:216
@ VSF_HW_EN_USBHS0ULPI
Definition common.h:183
@ VSF_HW_EN_TIMER15
Definition common.h:274
@ VSF_HW_EN_TIMER42
Definition common.h:264
@ VSF_HW_EN_TIMER23
Definition common.h:250
@ VSF_HW_EN_TLI
Definition common.h:288
@ VSF_HW_EN_TIMER41
Definition common.h:265
@ VSF_HW_EN_TIMER2
Definition common.h:256
@ VSF_HW_EN_CPU
Definition common.h:201
@ VSF_HW_EN_TIMER50
Definition common.h:247
@ VSF_HW_EN_ENET0PTP
Definition common.h:176
@ VSF_HW_EN_CMP
Definition common.h:294
@ VSF_HW_EN_OSPIM
Definition common.h:207
@ VSF_HW_EN_ENET1TX
Definition common.h:187
@ VSF_HW_EN_ENET0
Definition common.h:179
@ VSF_HW_EN_SPI4
Definition common.h:271
@ VSF_HW_EN_USBHS1ULPI
Definition common.h:174
@ VSF_HW_EN_I2C1
Definition common.h:236
@ VSF_HW_EN_RAMECCMU1
Definition common.h:191
@ VSF_HW_EN_RTDEC1
Definition common.h:203
@ VSF_HW_EN_DACHOLD
Definition common.h:232
@ VSF_HW_EN_CRC
Definition common.h:215
@ VSF_HW_EN_TIMER1
Definition common.h:257
@ VSF_HW_EN_TIMER0
Definition common.h:284
@ VSF_HW_EN_TIMER44
Definition common.h:262
@ VSF_HW_EN_RAMECCMU0
Definition common.h:202
@ VSF_HW_EN_CTC
Definition common.h:233
@ VSF_HW_EN_IPA
Definition common.h:210
@ VSF_HW_EN_SAI0
Definition common.h:269
@ VSF_HW_EN_SPI3
Definition common.h:276
@ VSF_HW_EN_CAU
Definition common.h:195
@ VSF_HW_EN_DCI
Definition common.h:198
@ VSF_HW_EN_ENET0TX
Definition common.h:178
@ VSF_HW_EN_SAI2
Definition common.h:267
@ VSF_HW_EN_SDIO0
Definition common.h:209
@ VSF_HW_EN_ADC0
Definition common.h:280
@ VSF_HW_EN_DMA0
Definition common.h:182
@ VSF_HW_EN_DMA1
Definition common.h:181
@ VSF_HW_EN_ENET1RX
Definition common.h:186
@ VSF_HW_EN_ENET0RX
Definition common.h:177
@ VSF_HW_EN_TIMER7
Definition common.h:283
@ VSF_HW_EN_USART5
Definition common.h:281
@ VSF_HW_EN_RSPDIF
Definition common.h:245
@ VSF_HW_EN_DAC
Definition common.h:231
@ VSF_HW_EN_HAU
Definition common.h:194
@ VSF_HW_EN_I2C0
Definition common.h:237
@ VSF_HW_EN_OSPI0
Definition common.h:206
@ VSF_HW_EN_UART6
Definition common.h:230
@ VSF_HW_EN_PMU
Definition common.h:291
@ VSF_HW_EN_TIMER40
Definition common.h:266
@ VSF_HW_EN_I2C2
Definition common.h:235
@ VSF_HW_EN_TIMER51
Definition common.h:246
@ VSF_HW_EN_ENET1PTP
Definition common.h:185
@ VSF_HW_EN_USBHS0
Definition common.h:184
@ VSF_HW_EN_TIMER3
Definition common.h:255
@ VSF_HW_EN_SYSCFG
Definition common.h:295
@ VSF_HW_EN_OSPI1
Definition common.h:205
@ VSF_HW_EN_FAC
Definition common.h:197
@ VSF_HW_EN_SPI0
Definition common.h:277
@ VSF_HW_EN_I2C3
Definition common.h:234
@ VSF_HW_EN_SAI1
Definition common.h:268
@ VSF_HW_EN_UART3
Definition common.h:239
@ VSF_HW_EN_RTDEC0
Definition common.h:204
@ VSF_HW_EN_TIMER14
Definition common.h:275
@ VSF_HW_EN_VREF
Definition common.h:293
@ VSF_HW_EN_TRNG
Definition common.h:193
@ VSF_HW_EN_ENET1
Definition common.h:188
@ VSF_HW_EN_EDOUT
Definition common.h:261
@ VSF_HW_EN_SPI5
Definition common.h:270
const vsf_hw_clk_t VSF_HW_CLK_TLI
Definition driver.c:457
const vsf_hw_clk_t VSF_HW_CLK_USART0
Definition driver.c:415
const vsf_hw_clk_t VSF_HW_CLK_SDIO1
Definition driver.c:448
bool vsf_hw_clk_is_enabled(const vsf_hw_clk_t *clk)
Definition driver.c:659
const vsf_hw_clk_t VSF_HW_CLK_LPIRC4M
Definition driver.c:137
const vsf_hw_clk_t VSF_HW_CLK_PLL2_VCO
Definition driver.c:190
const vsf_hw_clk_t VSF_HW_CLK_USART1
Definition driver.c:420
void vsf_hw_clk_enable(const vsf_hw_clk_t *clk)
Definition driver.c:640
const vsf_hw_clk_t VSF_HW_CLK_EXMC
Definition driver.c:474
const vsf_hw_clk_t VSF_HW_CLK_PLL1_VCO
Definition driver.c:176
const vsf_hw_clk_t VSF_HW_CLK_PLL0_VCO
Definition driver.c:162
const vsf_hw_clk_t VSF_HW_CLK_USART2
Definition driver.c:425
const vsf_hw_clk_t VSF_HW_CLK_USART5
Definition driver.c:430
const vsf_hw_clk_t VSF_HW_CLK_PLL0P
Definition driver.c:204
@ VSF_HW_RST_GPIOA
Definition common.h:89
@ VSF_HW_RST_GPIOG
Definition common.h:83
@ VSF_HW_RST_GPIOH
Definition common.h:82
@ VSF_HW_RST_GPIOE
Definition common.h:85
@ VSF_HW_RST_GPIOF
Definition common.h:84
@ VSF_HW_RST_GPIOC
Definition common.h:87
@ VSF_HW_RST_GPIOB
Definition common.h:88
@ VSF_HW_RST_CRC
Definition common.h:77
@ VSF_HW_RST_GPIOD
Definition common.h:86
@ VSF_HW_RST_SPI3
Definition common.h:116
const vsf_hw_clk_t VSF_HW_CLK_SYS
Definition driver.c:326
vsf_hw_peripheral_rst_t
Definition common.h:49
@ VSF_HW_RST_UART7
Definition common.h:56
@ VSF_HW_RST_USART2
Definition common.h:51
@ VSF_HW_RST_USART1
Definition common.h:50
@ VSF_HW_RST_UART4
Definition common.h:53
void vsf_hw_clkrst_region_clear_bit(uint32_t region)
Definition driver.c:518
const vsf_hw_clk_t VSF_HW_CLK_PCLK4
Definition driver.c:393
void vsf_hw_clkrst_region_set_bit(uint32_t region)
Definition driver.c:506
const vsf_hw_clk_t VSF_HW_CLK_PCLK3
Definition driver.c:381
const vsf_hw_clk_t VSF_HW_CLK_PCLK2
Definition driver.c:369
uint32_t vsf_hw_clk_get_freq_hz(const vsf_hw_clk_t *clk)
Definition driver.c:594
vsf_hw_peripheral_en_t
Definition common.h:63
@ VSF_HW_EN_GPIOH
Definition common.h:71
@ VSF_HW_EN_GPIOE
Definition common.h:68
@ VSF_HW_EN_UART7
Definition common.h:82
@ VSF_HW_EN_USART2
Definition common.h:77
@ VSF_HW_EN_GPIOB
Definition common.h:65
@ VSF_HW_EN_GPIOC
Definition common.h:66
@ VSF_HW_EN_GPIOD
Definition common.h:67
@ VSF_HW_EN_UART4
Definition common.h:79
@ VSF_HW_EN_GPIOA
Definition common.h:64
@ VSF_HW_EN_GPIOG
Definition common.h:70
@ VSF_HW_EN_USART1
Definition common.h:76
@ VSF_HW_EN_GPIOJ
Definition common.h:73
@ VSF_HW_EN_GPIOK
Definition common.h:74
@ VSF_HW_EN_GPIOF
Definition common.h:69
uint_fast8_t vsf_hw_clkrst_region_get_bit(uint32_t region)
Definition driver.c:530
uint_fast8_t vsf_hw_clkrst_region_get(uint32_t region)
Definition driver.c:498
void vsf_hw_clkrst_region_set(uint32_t region, uint_fast8_t value)
Definition driver.c:485
const vsf_hw_clk_t VSF_HW_CLK_PCLK1
Definition driver.c:357
const vsf_hw_clk_t VSF_HW_CLK_PER
Definition driver.c:333
const vsf_hw_clk_t * vsf_hw_clk_get_src(const vsf_hw_clk_t *clk)
Definition driver.c:556
unsigned short uint16_t
Definition lvgl.h:41
unsigned int uint32_t
Definition lvgl.h:43
unsigned char uint_fast8_t
Definition stdint.h:23
uint32_t prescaler
Definition driver.c:93
const vsf_hw_clk_t * clksrc
Definition driver.c:89
vk_av_control_value_t value
Definition vsf_audio.h:171