21#ifndef __STM32F1xx_HAL_RCC_H
22#define __STM32F1xx_HAL_RCC_H
95#define RCC_PLLSOURCE_HSI_DIV2 0x00000000U
96#define RCC_PLLSOURCE_HSE RCC_CFGR_PLLSRC
105#define RCC_OSCILLATORTYPE_NONE 0x00000000U
106#define RCC_OSCILLATORTYPE_HSE 0x00000001U
107#define RCC_OSCILLATORTYPE_HSI 0x00000002U
108#define RCC_OSCILLATORTYPE_LSE 0x00000004U
109#define RCC_OSCILLATORTYPE_LSI 0x00000008U
117#define RCC_HSE_OFF 0x00000000U
118#define RCC_HSE_ON RCC_CR_HSEON
119#define RCC_HSE_BYPASS ((uint32_t)(RCC_CR_HSEBYP | RCC_CR_HSEON))
127#define RCC_LSE_OFF 0x00000000U
128#define RCC_LSE_ON RCC_BDCR_LSEON
129#define RCC_LSE_BYPASS ((uint32_t)(RCC_BDCR_LSEBYP | RCC_BDCR_LSEON))
138#define RCC_HSI_OFF 0x00000000U
139#define RCC_HSI_ON RCC_CR_HSION
141#define RCC_HSICALIBRATION_DEFAULT 0x10U
150#define RCC_LSI_OFF 0x00000000U
151#define RCC_LSI_ON RCC_CSR_LSION
160#define RCC_PLL_NONE 0x00000000U
161#define RCC_PLL_OFF 0x00000001U
162#define RCC_PLL_ON 0x00000002U
171#define RCC_CLOCKTYPE_SYSCLK 0x00000001U
172#define RCC_CLOCKTYPE_HCLK 0x00000002U
173#define RCC_CLOCKTYPE_PCLK1 0x00000004U
174#define RCC_CLOCKTYPE_PCLK2 0x00000008U
183#define RCC_SYSCLKSOURCE_HSI RCC_CFGR_SW_HSI
184#define RCC_SYSCLKSOURCE_HSE RCC_CFGR_SW_HSE
185#define RCC_SYSCLKSOURCE_PLLCLK RCC_CFGR_SW_PLL
194#define RCC_SYSCLKSOURCE_STATUS_HSI RCC_CFGR_SWS_HSI
195#define RCC_SYSCLKSOURCE_STATUS_HSE RCC_CFGR_SWS_HSE
196#define RCC_SYSCLKSOURCE_STATUS_PLLCLK RCC_CFGR_SWS_PLL
205#define RCC_SYSCLK_DIV1 RCC_CFGR_HPRE_DIV1
206#define RCC_SYSCLK_DIV2 RCC_CFGR_HPRE_DIV2
207#define RCC_SYSCLK_DIV4 RCC_CFGR_HPRE_DIV4
208#define RCC_SYSCLK_DIV8 RCC_CFGR_HPRE_DIV8
209#define RCC_SYSCLK_DIV16 RCC_CFGR_HPRE_DIV16
210#define RCC_SYSCLK_DIV64 RCC_CFGR_HPRE_DIV64
211#define RCC_SYSCLK_DIV128 RCC_CFGR_HPRE_DIV128
212#define RCC_SYSCLK_DIV256 RCC_CFGR_HPRE_DIV256
213#define RCC_SYSCLK_DIV512 RCC_CFGR_HPRE_DIV512
222#define RCC_HCLK_DIV1 RCC_CFGR_PPRE1_DIV1
223#define RCC_HCLK_DIV2 RCC_CFGR_PPRE1_DIV2
224#define RCC_HCLK_DIV4 RCC_CFGR_PPRE1_DIV4
225#define RCC_HCLK_DIV8 RCC_CFGR_PPRE1_DIV8
226#define RCC_HCLK_DIV16 RCC_CFGR_PPRE1_DIV16
235#define RCC_RTCCLKSOURCE_NO_CLK 0x00000000U
236#define RCC_RTCCLKSOURCE_LSE RCC_BDCR_RTCSEL_LSE
237#define RCC_RTCCLKSOURCE_LSI RCC_BDCR_RTCSEL_LSI
238#define RCC_RTCCLKSOURCE_HSE_DIV128 RCC_BDCR_RTCSEL_HSE
247#define RCC_MCO1 0x00000000U
248#define RCC_MCO RCC_MCO1
257#define RCC_MCODIV_1 0x00000000U
266#define RCC_IT_LSIRDY ((uint8_t)RCC_CIR_LSIRDYF)
267#define RCC_IT_LSERDY ((uint8_t)RCC_CIR_LSERDYF)
268#define RCC_IT_HSIRDY ((uint8_t)RCC_CIR_HSIRDYF)
269#define RCC_IT_HSERDY ((uint8_t)RCC_CIR_HSERDYF)
270#define RCC_IT_PLLRDY ((uint8_t)RCC_CIR_PLLRDYF)
271#define RCC_IT_CSS ((uint8_t)RCC_CIR_CSSF)
286#define RCC_FLAG_HSIRDY ((uint8_t)((CR_REG_INDEX << 5U) | RCC_CR_HSIRDY_Pos))
287#define RCC_FLAG_HSERDY ((uint8_t)((CR_REG_INDEX << 5U) | RCC_CR_HSERDY_Pos))
288#define RCC_FLAG_PLLRDY ((uint8_t)((CR_REG_INDEX << 5U) | RCC_CR_PLLRDY_Pos))
291#define RCC_FLAG_LSIRDY ((uint8_t)((CSR_REG_INDEX << 5U) | RCC_CSR_LSIRDY_Pos))
292#define RCC_FLAG_PINRST ((uint8_t)((CSR_REG_INDEX << 5U) | RCC_CSR_PINRSTF_Pos))
293#define RCC_FLAG_PORRST ((uint8_t)((CSR_REG_INDEX << 5U) | RCC_CSR_PORRSTF_Pos))
294#define RCC_FLAG_SFTRST ((uint8_t)((CSR_REG_INDEX << 5U) | RCC_CSR_SFTRSTF_Pos))
295#define RCC_FLAG_IWDGRST ((uint8_t)((CSR_REG_INDEX << 5U) | RCC_CSR_IWDGRSTF_Pos))
296#define RCC_FLAG_WWDGRST ((uint8_t)((CSR_REG_INDEX << 5U) | RCC_CSR_WWDGRSTF_Pos))
297#define RCC_FLAG_LPWRRST ((uint8_t)((CSR_REG_INDEX << 5U) | RCC_CSR_LPWRRSTF_Pos))
300#define RCC_FLAG_LSERDY ((uint8_t)((BDCR_REG_INDEX << 5U) | RCC_BDCR_LSERDY_Pos))
323#define __HAL_RCC_DMA1_CLK_ENABLE() do { \
324 __IO uint32_t tmpreg; \
325 SET_BIT(RCC->AHBENR, RCC_AHBENR_DMA1EN);\
327 tmpreg = READ_BIT(RCC->AHBENR, RCC_AHBENR_DMA1EN);\
331#define __HAL_RCC_SRAM_CLK_ENABLE() do { \
332 __IO uint32_t tmpreg; \
333 SET_BIT(RCC->AHBENR, RCC_AHBENR_SRAMEN);\
335 tmpreg = READ_BIT(RCC->AHBENR, RCC_AHBENR_SRAMEN);\
339#define __HAL_RCC_FLITF_CLK_ENABLE() do { \
340 __IO uint32_t tmpreg; \
341 SET_BIT(RCC->AHBENR, RCC_AHBENR_FLITFEN);\
343 tmpreg = READ_BIT(RCC->AHBENR, RCC_AHBENR_FLITFEN);\
347#define __HAL_RCC_CRC_CLK_ENABLE() do { \
348 __IO uint32_t tmpreg; \
349 SET_BIT(RCC->AHBENR, RCC_AHBENR_CRCEN);\
351 tmpreg = READ_BIT(RCC->AHBENR, RCC_AHBENR_CRCEN);\
355#define __HAL_RCC_DMA1_CLK_DISABLE() (RCC->AHBENR &= ~(RCC_AHBENR_DMA1EN))
356#define __HAL_RCC_SRAM_CLK_DISABLE() (RCC->AHBENR &= ~(RCC_AHBENR_SRAMEN))
357#define __HAL_RCC_FLITF_CLK_DISABLE() (RCC->AHBENR &= ~(RCC_AHBENR_FLITFEN))
358#define __HAL_RCC_CRC_CLK_DISABLE() (RCC->AHBENR &= ~(RCC_AHBENR_CRCEN))
372#define __HAL_RCC_DMA1_IS_CLK_ENABLED() ((RCC->AHBENR & (RCC_AHBENR_DMA1EN)) != RESET)
373#define __HAL_RCC_DMA1_IS_CLK_DISABLED() ((RCC->AHBENR & (RCC_AHBENR_DMA1EN)) == RESET)
374#define __HAL_RCC_SRAM_IS_CLK_ENABLED() ((RCC->AHBENR & (RCC_AHBENR_SRAMEN)) != RESET)
375#define __HAL_RCC_SRAM_IS_CLK_DISABLED() ((RCC->AHBENR & (RCC_AHBENR_SRAMEN)) == RESET)
376#define __HAL_RCC_FLITF_IS_CLK_ENABLED() ((RCC->AHBENR & (RCC_AHBENR_FLITFEN)) != RESET)
377#define __HAL_RCC_FLITF_IS_CLK_DISABLED() ((RCC->AHBENR & (RCC_AHBENR_FLITFEN)) == RESET)
378#define __HAL_RCC_CRC_IS_CLK_ENABLED() ((RCC->AHBENR & (RCC_AHBENR_CRCEN)) != RESET)
379#define __HAL_RCC_CRC_IS_CLK_DISABLED() ((RCC->AHBENR & (RCC_AHBENR_CRCEN)) == RESET)
392#define __HAL_RCC_TIM2_CLK_ENABLE() do { \
393 __IO uint32_t tmpreg; \
394 SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM2EN);\
396 tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM2EN);\
400#define __HAL_RCC_TIM3_CLK_ENABLE() do { \
401 __IO uint32_t tmpreg; \
402 SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM3EN);\
404 tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM3EN);\
408#define __HAL_RCC_WWDG_CLK_ENABLE() do { \
409 __IO uint32_t tmpreg; \
410 SET_BIT(RCC->APB1ENR, RCC_APB1ENR_WWDGEN);\
412 tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_WWDGEN);\
416#define __HAL_RCC_USART2_CLK_ENABLE() do { \
417 __IO uint32_t tmpreg; \
418 SET_BIT(RCC->APB1ENR, RCC_APB1ENR_USART2EN);\
420 tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_USART2EN);\
424#define __HAL_RCC_I2C1_CLK_ENABLE() do { \
425 __IO uint32_t tmpreg; \
426 SET_BIT(RCC->APB1ENR, RCC_APB1ENR_I2C1EN);\
428 tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_I2C1EN);\
432#define __HAL_RCC_BKP_CLK_ENABLE() do { \
433 __IO uint32_t tmpreg; \
434 SET_BIT(RCC->APB1ENR, RCC_APB1ENR_BKPEN);\
436 tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_BKPEN);\
440#define __HAL_RCC_PWR_CLK_ENABLE() do { \
441 __IO uint32_t tmpreg; \
442 SET_BIT(RCC->APB1ENR, RCC_APB1ENR_PWREN);\
444 tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_PWREN);\
448#define __HAL_RCC_TIM2_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM2EN))
449#define __HAL_RCC_TIM3_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM3EN))
450#define __HAL_RCC_WWDG_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_WWDGEN))
451#define __HAL_RCC_USART2_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_USART2EN))
452#define __HAL_RCC_I2C1_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_I2C1EN))
454#define __HAL_RCC_BKP_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_BKPEN))
455#define __HAL_RCC_PWR_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_PWREN))
469#define __HAL_RCC_TIM2_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM2EN)) != RESET)
470#define __HAL_RCC_TIM2_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM2EN)) == RESET)
471#define __HAL_RCC_TIM3_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM3EN)) != RESET)
472#define __HAL_RCC_TIM3_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_TIM3EN)) == RESET)
473#define __HAL_RCC_WWDG_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_WWDGEN)) != RESET)
474#define __HAL_RCC_WWDG_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_WWDGEN)) == RESET)
475#define __HAL_RCC_USART2_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_USART2EN)) != RESET)
476#define __HAL_RCC_USART2_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_USART2EN)) == RESET)
477#define __HAL_RCC_I2C1_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_I2C1EN)) != RESET)
478#define __HAL_RCC_I2C1_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_I2C1EN)) == RESET)
479#define __HAL_RCC_BKP_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_BKPEN)) != RESET)
480#define __HAL_RCC_BKP_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_BKPEN)) == RESET)
481#define __HAL_RCC_PWR_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_PWREN)) != RESET)
482#define __HAL_RCC_PWR_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_PWREN)) == RESET)
495#define __HAL_RCC_AFIO_CLK_ENABLE() do { \
496 __IO uint32_t tmpreg; \
497 SET_BIT(RCC->APB2ENR, RCC_APB2ENR_AFIOEN);\
499 tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_AFIOEN);\
503#define __HAL_RCC_GPIOA_CLK_ENABLE() do { \
504 __IO uint32_t tmpreg; \
505 SET_BIT(RCC->APB2ENR, RCC_APB2ENR_IOPAEN);\
507 tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_IOPAEN);\
511#define __HAL_RCC_GPIOB_CLK_ENABLE() do { \
512 __IO uint32_t tmpreg; \
513 SET_BIT(RCC->APB2ENR, RCC_APB2ENR_IOPBEN);\
515 tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_IOPBEN);\
519#define __HAL_RCC_GPIOC_CLK_ENABLE() do { \
520 __IO uint32_t tmpreg; \
521 SET_BIT(RCC->APB2ENR, RCC_APB2ENR_IOPCEN);\
523 tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_IOPCEN);\
527#define __HAL_RCC_GPIOD_CLK_ENABLE() do { \
528 __IO uint32_t tmpreg; \
529 SET_BIT(RCC->APB2ENR, RCC_APB2ENR_IOPDEN);\
531 tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_IOPDEN);\
535#define __HAL_RCC_ADC1_CLK_ENABLE() do { \
536 __IO uint32_t tmpreg; \
537 SET_BIT(RCC->APB2ENR, RCC_APB2ENR_ADC1EN);\
539 tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_ADC1EN);\
543#define __HAL_RCC_TIM1_CLK_ENABLE() do { \
544 __IO uint32_t tmpreg; \
545 SET_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM1EN);\
547 tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM1EN);\
551#define __HAL_RCC_SPI1_CLK_ENABLE() do { \
552 __IO uint32_t tmpreg; \
553 SET_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI1EN);\
555 tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI1EN);\
559#define __HAL_RCC_USART1_CLK_ENABLE() do { \
560 __IO uint32_t tmpreg; \
561 SET_BIT(RCC->APB2ENR, RCC_APB2ENR_USART1EN);\
563 tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_USART1EN);\
567#define __HAL_RCC_AFIO_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_AFIOEN))
568#define __HAL_RCC_GPIOA_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_IOPAEN))
569#define __HAL_RCC_GPIOB_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_IOPBEN))
570#define __HAL_RCC_GPIOC_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_IOPCEN))
571#define __HAL_RCC_GPIOD_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_IOPDEN))
572#define __HAL_RCC_ADC1_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_ADC1EN))
574#define __HAL_RCC_TIM1_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_TIM1EN))
575#define __HAL_RCC_SPI1_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_SPI1EN))
576#define __HAL_RCC_USART1_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_USART1EN))
590#define __HAL_RCC_AFIO_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_AFIOEN)) != RESET)
591#define __HAL_RCC_AFIO_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_AFIOEN)) == RESET)
592#define __HAL_RCC_GPIOA_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_IOPAEN)) != RESET)
593#define __HAL_RCC_GPIOA_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_IOPAEN)) == RESET)
594#define __HAL_RCC_GPIOB_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_IOPBEN)) != RESET)
595#define __HAL_RCC_GPIOB_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_IOPBEN)) == RESET)
596#define __HAL_RCC_GPIOC_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_IOPCEN)) != RESET)
597#define __HAL_RCC_GPIOC_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_IOPCEN)) == RESET)
598#define __HAL_RCC_GPIOD_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_IOPDEN)) != RESET)
599#define __HAL_RCC_GPIOD_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_IOPDEN)) == RESET)
600#define __HAL_RCC_ADC1_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_ADC1EN)) != RESET)
601#define __HAL_RCC_ADC1_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_ADC1EN)) == RESET)
602#define __HAL_RCC_TIM1_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_TIM1EN)) != RESET)
603#define __HAL_RCC_TIM1_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_TIM1EN)) == RESET)
604#define __HAL_RCC_SPI1_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_SPI1EN)) != RESET)
605#define __HAL_RCC_SPI1_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_SPI1EN)) == RESET)
606#define __HAL_RCC_USART1_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_USART1EN)) != RESET)
607#define __HAL_RCC_USART1_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_USART1EN)) == RESET)
617#define __HAL_RCC_APB1_FORCE_RESET() (RCC->APB2RSTR = 0xFFFFFFFFU)
618#define __HAL_RCC_TIM2_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM2RST))
619#define __HAL_RCC_TIM3_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM3RST))
620#define __HAL_RCC_WWDG_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_WWDGRST))
621#define __HAL_RCC_USART2_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_USART2RST))
622#define __HAL_RCC_I2C1_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_I2C1RST))
624#define __HAL_RCC_BKP_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_BKPRST))
625#define __HAL_RCC_PWR_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_PWRRST))
627#define __HAL_RCC_APB1_RELEASE_RESET() (RCC->APB1RSTR = 0x00)
628#define __HAL_RCC_TIM2_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM2RST))
629#define __HAL_RCC_TIM3_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM3RST))
630#define __HAL_RCC_WWDG_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_WWDGRST))
631#define __HAL_RCC_USART2_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_USART2RST))
632#define __HAL_RCC_I2C1_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_I2C1RST))
634#define __HAL_RCC_BKP_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_BKPRST))
635#define __HAL_RCC_PWR_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_PWRRST))
645#define __HAL_RCC_APB2_FORCE_RESET() (RCC->APB2RSTR = 0xFFFFFFFFU)
646#define __HAL_RCC_AFIO_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_AFIORST))
647#define __HAL_RCC_GPIOA_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_IOPARST))
648#define __HAL_RCC_GPIOB_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_IOPBRST))
649#define __HAL_RCC_GPIOC_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_IOPCRST))
650#define __HAL_RCC_GPIOD_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_IOPDRST))
651#define __HAL_RCC_ADC1_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_ADC1RST))
653#define __HAL_RCC_TIM1_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_TIM1RST))
654#define __HAL_RCC_SPI1_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_SPI1RST))
655#define __HAL_RCC_USART1_FORCE_RESET() (RCC->APB2RSTR |= (RCC_APB2RSTR_USART1RST))
657#define __HAL_RCC_APB2_RELEASE_RESET() (RCC->APB2RSTR = 0x00)
658#define __HAL_RCC_AFIO_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_AFIORST))
659#define __HAL_RCC_GPIOA_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_IOPARST))
660#define __HAL_RCC_GPIOB_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_IOPBRST))
661#define __HAL_RCC_GPIOC_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_IOPCRST))
662#define __HAL_RCC_GPIOD_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_IOPDRST))
663#define __HAL_RCC_ADC1_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_ADC1RST))
665#define __HAL_RCC_TIM1_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_TIM1RST))
666#define __HAL_RCC_SPI1_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_SPI1RST))
667#define __HAL_RCC_USART1_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_USART1RST))
687#define __HAL_RCC_HSI_ENABLE() (*(__IO uint32_t *) RCC_CR_HSION_BB = ENABLE)
688#define __HAL_RCC_HSI_DISABLE() (*(__IO uint32_t *) RCC_CR_HSION_BB = DISABLE)
697#define __HAL_RCC_HSI_CALIBRATIONVALUE_ADJUST(_HSICALIBRATIONVALUE_) \
698 (MODIFY_REG(RCC->CR, RCC_CR_HSITRIM, (uint32_t)(_HSICALIBRATIONVALUE_) << RCC_CR_HSITRIM_Pos))
713#define __HAL_RCC_LSI_ENABLE() (*(__IO uint32_t *) RCC_CSR_LSION_BB = ENABLE)
720#define __HAL_RCC_LSI_DISABLE() (*(__IO uint32_t *) RCC_CSR_LSION_BB = DISABLE)
752#define __HAL_RCC_HSE_CONFIG(__STATE__) \
754 if ((__STATE__) == RCC_HSE_ON) \
756 SET_BIT(RCC->CR, RCC_CR_HSEON); \
758 else if ((__STATE__) == RCC_HSE_OFF) \
760 CLEAR_BIT(RCC->CR, RCC_CR_HSEON); \
761 CLEAR_BIT(RCC->CR, RCC_CR_HSEBYP); \
763 else if ((__STATE__) == RCC_HSE_BYPASS) \
765 SET_BIT(RCC->CR, RCC_CR_HSEBYP); \
766 SET_BIT(RCC->CR, RCC_CR_HSEON); \
770 CLEAR_BIT(RCC->CR, RCC_CR_HSEON); \
771 CLEAR_BIT(RCC->CR, RCC_CR_HSEBYP); \
800#define __HAL_RCC_LSE_CONFIG(__STATE__) \
802 if ((__STATE__) == RCC_LSE_ON) \
804 SET_BIT(RCC->BDCR, RCC_BDCR_LSEON); \
806 else if ((__STATE__) == RCC_LSE_OFF) \
808 CLEAR_BIT(RCC->BDCR, RCC_BDCR_LSEON); \
809 CLEAR_BIT(RCC->BDCR, RCC_BDCR_LSEBYP); \
811 else if ((__STATE__) == RCC_LSE_BYPASS) \
813 SET_BIT(RCC->BDCR, RCC_BDCR_LSEBYP); \
814 SET_BIT(RCC->BDCR, RCC_BDCR_LSEON); \
818 CLEAR_BIT(RCC->BDCR, RCC_BDCR_LSEON); \
819 CLEAR_BIT(RCC->BDCR, RCC_BDCR_LSEBYP); \
837#define __HAL_RCC_PLL_ENABLE() (*(__IO uint32_t *) RCC_CR_PLLON_BB = ENABLE)
842#define __HAL_RCC_PLL_DISABLE() (*(__IO uint32_t *) RCC_CR_PLLON_BB = DISABLE)
874#define __HAL_RCC_PLL_CONFIG(__RCC_PLLSOURCE__, __PLLMUL__)\
875 MODIFY_REG(RCC->CFGR, (RCC_CFGR_PLLSRC | RCC_CFGR_PLLMULL),((__RCC_PLLSOURCE__) | (__PLLMUL__) ))
883#define __HAL_RCC_GET_PLL_OSCSOURCE() ((uint32_t)(READ_BIT(RCC->CFGR, RCC_CFGR_PLLSRC)))
901#define __HAL_RCC_SYSCLK_CONFIG(__SYSCLKSOURCE__) \
902 MODIFY_REG(RCC->CFGR, RCC_CFGR_SW, (__SYSCLKSOURCE__))
911#define __HAL_RCC_GET_SYSCLK_SOURCE() ((uint32_t)(READ_BIT(RCC->CFGR,RCC_CFGR_SWS)))
921#if defined(RCC_CFGR_MCO_3)
953#define __HAL_RCC_MCO1_CONFIG(__MCOCLKSOURCE__, __MCODIV__) \
954 MODIFY_REG(RCC->CFGR, RCC_CFGR_MCO, (__MCOCLKSOURCE__))
987#define __HAL_RCC_RTC_CONFIG(__RTC_CLKSOURCE__) MODIFY_REG(RCC->BDCR, RCC_BDCR_RTCSEL, (__RTC_CLKSOURCE__))
996#define __HAL_RCC_GET_RTC_SOURCE() (READ_BIT(RCC->BDCR, RCC_BDCR_RTCSEL))
1001#define __HAL_RCC_RTC_ENABLE() (*(__IO uint32_t *) RCC_BDCR_RTCEN_BB = ENABLE)
1006#define __HAL_RCC_RTC_DISABLE() (*(__IO uint32_t *) RCC_BDCR_RTCEN_BB = DISABLE)
1012#define __HAL_RCC_BACKUPRESET_FORCE() (*(__IO uint32_t *) RCC_BDCR_BDRST_BB = ENABLE)
1016#define __HAL_RCC_BACKUPRESET_RELEASE() (*(__IO uint32_t *) RCC_BDCR_BDRST_BB = DISABLE)
1043#define __HAL_RCC_ENABLE_IT(__INTERRUPT__) (*(__IO uint8_t *) RCC_CIR_BYTE1_ADDRESS |= (__INTERRUPT__))
1061#define __HAL_RCC_DISABLE_IT(__INTERRUPT__) (*(__IO uint8_t *) RCC_CIR_BYTE1_ADDRESS &= (uint8_t)(~(__INTERRUPT__)))
1080#define __HAL_RCC_CLEAR_IT(__INTERRUPT__) (*(__IO uint8_t *) RCC_CIR_BYTE2_ADDRESS = (__INTERRUPT__))
1100#define __HAL_RCC_GET_IT(__INTERRUPT__) ((RCC->CIR & (__INTERRUPT__)) == (__INTERRUPT__))
1106#define __HAL_RCC_CLEAR_RESET_FLAGS() (*(__IO uint32_t *)RCC_CSR_RMVF_BB = ENABLE)
1131#define __HAL_RCC_GET_FLAG(__FLAG__) (((((__FLAG__) >> 5U) == CR_REG_INDEX)? RCC->CR : \
1132 ((((__FLAG__) >> 5U) == BDCR_REG_INDEX)? RCC->BDCR : \
1133 RCC->CSR)) & (1U << ((__FLAG__) & RCC_FLAG_MASK)))
1169void HAL_RCC_MCOConfig(uint32_t RCC_MCOx, uint32_t RCC_MCOSource, uint32_t RCC_MCODiv);
1170void HAL_RCC_EnableCSS(
void);
1171void HAL_RCC_DisableCSS(
void);
1172uint32_t HAL_RCC_GetSysClockFreq(
void);
1173uint32_t HAL_RCC_GetHCLKFreq(
void);
1174uint32_t HAL_RCC_GetPCLK1Freq(
void);
1175uint32_t HAL_RCC_GetPCLK2Freq(
void);
1177void HAL_RCC_GetClockConfig(
RCC_ClkInitTypeDef *RCC_ClkInitStruct, uint32_t *pFLatency);
1180void HAL_RCC_NMI_IRQHandler(
void);
1183void HAL_RCC_CSSCallback(
void);
1202#define RCC_DBP_TIMEOUT_VALUE 100U
1204#define RCC_LSE_TIMEOUT_VALUE LSE_STARTUP_TIMEOUT
1205#define CLOCKSWITCH_TIMEOUT_VALUE 5000
1206#define HSE_TIMEOUT_VALUE HSE_STARTUP_TIMEOUT
1207#define HSI_TIMEOUT_VALUE 2U
1208#define LSI_TIMEOUT_VALUE 2U
1209#define PLL_TIMEOUT_VALUE 2U
1218#define RCC_OFFSET (RCC_BASE - PERIPH_BASE)
1219#define RCC_CR_OFFSET 0x00U
1220#define RCC_CFGR_OFFSET 0x04U
1221#define RCC_CIR_OFFSET 0x08U
1222#define RCC_BDCR_OFFSET 0x20U
1223#define RCC_CSR_OFFSET 0x24U
1233#define RCC_CR_OFFSET_BB (RCC_OFFSET + RCC_CR_OFFSET)
1234#define RCC_CFGR_OFFSET_BB (RCC_OFFSET + RCC_CFGR_OFFSET)
1235#define RCC_CIR_OFFSET_BB (RCC_OFFSET + RCC_CIR_OFFSET)
1236#define RCC_BDCR_OFFSET_BB (RCC_OFFSET + RCC_BDCR_OFFSET)
1237#define RCC_CSR_OFFSET_BB (RCC_OFFSET + RCC_CSR_OFFSET)
1241#define RCC_HSION_BIT_NUMBER RCC_CR_HSION_Pos
1242#define RCC_CR_HSION_BB ((uint32_t)(PERIPH_BB_BASE + (RCC_CR_OFFSET_BB * 32U) + (RCC_HSION_BIT_NUMBER * 4U)))
1244#define RCC_HSEON_BIT_NUMBER RCC_CR_HSEON_Pos
1245#define RCC_CR_HSEON_BB ((uint32_t)(PERIPH_BB_BASE + (RCC_CR_OFFSET_BB * 32U) + (RCC_HSEON_BIT_NUMBER * 4U)))
1247#define RCC_CSSON_BIT_NUMBER RCC_CR_CSSON_Pos
1248#define RCC_CR_CSSON_BB ((uint32_t)(PERIPH_BB_BASE + (RCC_CR_OFFSET_BB * 32U) + (RCC_CSSON_BIT_NUMBER * 4U)))
1250#define RCC_PLLON_BIT_NUMBER RCC_CR_PLLON_Pos
1251#define RCC_CR_PLLON_BB ((uint32_t)(PERIPH_BB_BASE + (RCC_CR_OFFSET_BB * 32U) + (RCC_PLLON_BIT_NUMBER * 4U)))
1255#define RCC_LSION_BIT_NUMBER RCC_CSR_LSION_Pos
1256#define RCC_CSR_LSION_BB ((uint32_t)(PERIPH_BB_BASE + (RCC_CSR_OFFSET_BB * 32U) + (RCC_LSION_BIT_NUMBER * 4U)))
1259#define RCC_RMVF_BIT_NUMBER RCC_CSR_RMVF_Pos
1260#define RCC_CSR_RMVF_BB ((uint32_t)(PERIPH_BB_BASE + (RCC_CSR_OFFSET_BB * 32U) + (RCC_RMVF_BIT_NUMBER * 4U)))
1264#define RCC_LSEON_BIT_NUMBER RCC_BDCR_LSEON_Pos
1265#define RCC_BDCR_LSEON_BB ((uint32_t)(PERIPH_BB_BASE + (RCC_BDCR_OFFSET_BB * 32U) + (RCC_LSEON_BIT_NUMBER * 4U)))
1268#define RCC_LSEBYP_BIT_NUMBER RCC_BDCR_LSEBYP_Pos
1269#define RCC_BDCR_LSEBYP_BB ((uint32_t)(PERIPH_BB_BASE + (RCC_BDCR_OFFSET_BB * 32U) + (RCC_LSEBYP_BIT_NUMBER * 4U)))
1272#define RCC_RTCEN_BIT_NUMBER RCC_BDCR_RTCEN_Pos
1273#define RCC_BDCR_RTCEN_BB ((uint32_t)(PERIPH_BB_BASE + (RCC_BDCR_OFFSET_BB * 32U) + (RCC_RTCEN_BIT_NUMBER * 4U)))
1276#define RCC_BDRST_BIT_NUMBER RCC_BDCR_BDRST_Pos
1277#define RCC_BDCR_BDRST_BB ((uint32_t)(PERIPH_BB_BASE + (RCC_BDCR_OFFSET_BB * 32U) + (RCC_BDRST_BIT_NUMBER * 4U)))
1284#define RCC_CR_BYTE2_ADDRESS ((uint32_t)(RCC_BASE + RCC_CR_OFFSET + 0x02U))
1287#define RCC_CIR_BYTE1_ADDRESS ((uint32_t)(RCC_BASE + RCC_CIR_OFFSET + 0x01U))
1290#define RCC_CIR_BYTE2_ADDRESS ((uint32_t)(RCC_BASE + RCC_CIR_OFFSET + 0x02U))
1293#define CR_REG_INDEX ((uint8_t)1)
1294#define BDCR_REG_INDEX ((uint8_t)2)
1295#define CSR_REG_INDEX ((uint8_t)3)
1297#define RCC_FLAG_MASK ((uint8_t)0x1F)
1309#define __HAL_RCC_SYSCFG_CLK_DISABLE __HAL_RCC_AFIO_CLK_DISABLE
1310#define __HAL_RCC_SYSCFG_CLK_ENABLE __HAL_RCC_AFIO_CLK_ENABLE
1311#define __HAL_RCC_SYSCFG_FORCE_RESET __HAL_RCC_AFIO_FORCE_RESET
1312#define __HAL_RCC_SYSCFG_RELEASE_RESET __HAL_RCC_AFIO_RELEASE_RESET
1317#define IS_RCC_PLLSOURCE(__SOURCE__) (((__SOURCE__) == RCC_PLLSOURCE_HSI_DIV2) || \
1318 ((__SOURCE__) == RCC_PLLSOURCE_HSE))
1319#define IS_RCC_OSCILLATORTYPE(__OSCILLATOR__) (((__OSCILLATOR__) == RCC_OSCILLATORTYPE_NONE) || \
1320 (((__OSCILLATOR__) & RCC_OSCILLATORTYPE_HSE) == RCC_OSCILLATORTYPE_HSE) || \
1321 (((__OSCILLATOR__) & RCC_OSCILLATORTYPE_HSI) == RCC_OSCILLATORTYPE_HSI) || \
1322 (((__OSCILLATOR__) & RCC_OSCILLATORTYPE_LSI) == RCC_OSCILLATORTYPE_LSI) || \
1323 (((__OSCILLATOR__) & RCC_OSCILLATORTYPE_LSE) == RCC_OSCILLATORTYPE_LSE))
1324#define IS_RCC_HSE(__HSE__) (((__HSE__) == RCC_HSE_OFF) || ((__HSE__) == RCC_HSE_ON) || \
1325 ((__HSE__) == RCC_HSE_BYPASS))
1326#define IS_RCC_LSE(__LSE__) (((__LSE__) == RCC_LSE_OFF) || ((__LSE__) == RCC_LSE_ON) || \
1327 ((__LSE__) == RCC_LSE_BYPASS))
1328#define IS_RCC_HSI(__HSI__) (((__HSI__) == RCC_HSI_OFF) || ((__HSI__) == RCC_HSI_ON))
1329#define IS_RCC_CALIBRATION_VALUE(__VALUE__) ((__VALUE__) <= 0x1FU)
1330#define IS_RCC_LSI(__LSI__) (((__LSI__) == RCC_LSI_OFF) || ((__LSI__) == RCC_LSI_ON))
1331#define IS_RCC_PLL(__PLL__) (((__PLL__) == RCC_PLL_NONE) || ((__PLL__) == RCC_PLL_OFF) || \
1332 ((__PLL__) == RCC_PLL_ON))
1334#define IS_RCC_CLOCKTYPE(CLK) ((((CLK) & RCC_CLOCKTYPE_SYSCLK) == RCC_CLOCKTYPE_SYSCLK) || \
1335 (((CLK) & RCC_CLOCKTYPE_HCLK) == RCC_CLOCKTYPE_HCLK) || \
1336 (((CLK) & RCC_CLOCKTYPE_PCLK1) == RCC_CLOCKTYPE_PCLK1) || \
1337 (((CLK) & RCC_CLOCKTYPE_PCLK2) == RCC_CLOCKTYPE_PCLK2))
1338#define IS_RCC_SYSCLKSOURCE(__SOURCE__) (((__SOURCE__) == RCC_SYSCLKSOURCE_HSI) || \
1339 ((__SOURCE__) == RCC_SYSCLKSOURCE_HSE) || \
1340 ((__SOURCE__) == RCC_SYSCLKSOURCE_PLLCLK))
1341#define IS_RCC_SYSCLKSOURCE_STATUS(__SOURCE__) (((__SOURCE__) == RCC_SYSCLKSOURCE_STATUS_HSI) || \
1342 ((__SOURCE__) == RCC_SYSCLKSOURCE_STATUS_HSE) || \
1343 ((__SOURCE__) == RCC_SYSCLKSOURCE_STATUS_PLLCLK))
1344#define IS_RCC_HCLK(__HCLK__) (((__HCLK__) == RCC_SYSCLK_DIV1) || ((__HCLK__) == RCC_SYSCLK_DIV2) || \
1345 ((__HCLK__) == RCC_SYSCLK_DIV4) || ((__HCLK__) == RCC_SYSCLK_DIV8) || \
1346 ((__HCLK__) == RCC_SYSCLK_DIV16) || ((__HCLK__) == RCC_SYSCLK_DIV64) || \
1347 ((__HCLK__) == RCC_SYSCLK_DIV128) || ((__HCLK__) == RCC_SYSCLK_DIV256) || \
1348 ((__HCLK__) == RCC_SYSCLK_DIV512))
1349#define IS_RCC_PCLK(__PCLK__) (((__PCLK__) == RCC_HCLK_DIV1) || ((__PCLK__) == RCC_HCLK_DIV2) || \
1350 ((__PCLK__) == RCC_HCLK_DIV4) || ((__PCLK__) == RCC_HCLK_DIV8) || \
1351 ((__PCLK__) == RCC_HCLK_DIV16))
1352#define IS_RCC_MCO(__MCO__) ((__MCO__) == RCC_MCO)
1353#define IS_RCC_MCODIV(__DIV__) (((__DIV__) == RCC_MCODIV_1))
1354#define IS_RCC_RTCCLKSOURCE(__SOURCE__) (((__SOURCE__) == RCC_RTCCLKSOURCE_NO_CLK) || \
1355 ((__SOURCE__) == RCC_RTCCLKSOURCE_LSE) || \
1356 ((__SOURCE__) == RCC_RTCCLKSOURCE_LSI) || \
1357 ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV128))
This file contains HAL common defines, enumeration, macros and structures definitions.
HAL_StatusTypeDef
HAL Status structures definition.
Definition stm32f1xx_hal_def.h:40
Header file of RCC HAL Extension module.
RCC System, AHB and APB busses clock configuration structure definition.
Definition stm32f1xx_hal_rcc.h:65
uint32_t APB1CLKDivider
Definition stm32f1xx_hal_rcc.h:75
uint32_t SYSCLKSource
Definition stm32f1xx_hal_rcc.h:69
uint32_t ClockType
Definition stm32f1xx_hal_rcc.h:66
uint32_t APB2CLKDivider
Definition stm32f1xx_hal_rcc.h:78
uint32_t AHBCLKDivider
Definition stm32f1xx_hal_rcc.h:72
RCC Internal/External Oscillator (HSE, HSI, LSE and LSI) configuration structure definition.
Definition stm32f1xx_hal_rcc_ex.h:229
RCC PLL configuration structure definition.
Definition stm32f1xx_hal_rcc.h:50
uint32_t PLLMUL
Definition stm32f1xx_hal_rcc.h:57
uint32_t PLLState
Definition stm32f1xx_hal_rcc.h:51
uint32_t PLLSource
Definition stm32f1xx_hal_rcc.h:54