⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stm32f10x_rcc.lst

📁 完成数据的采集
💻 LST
📖 第 1 页 / 共 5 页
字号:
    444            /* Store the new value */
    445            RCC->CFGR = tmpreg;
    446          }
    447          
    448          /*******************************************************************************
    449          * Function Name  : RCC_PCLK2Config
    450          * Description    : Configures the High Speed APB clock (PCLK2).
    451          * Input          : - RCC_PCLK2: defines the APB2 clock. This clock is derived
    452          *                    from the AHB clock (HCLK).
    453          *                    This parameter can be one of the following values:
    454          *                       - RCC_HCLK_Div1: APB2 clock = HCLK
    455          *                       - RCC_HCLK_Div2: APB2 clock = HCLK/2
    456          *                       - RCC_HCLK_Div4: APB2 clock = HCLK/4
    457          *                       - RCC_HCLK_Div8: APB2 clock = HCLK/8
    458          *                       - RCC_HCLK_Div16: APB2 clock = HCLK/16
    459          * Output         : None
    460          * Return         : None
    461          *******************************************************************************/
    462          void RCC_PCLK2Config(u32 RCC_PCLK2)
    463          {
    464            u32 tmpreg = 0;
    465          
    466            /* Check the parameters */
    467            assert_param(IS_RCC_PCLK(RCC_PCLK2));
    468          
    469            tmpreg = RCC->CFGR;
    470          
    471            /* Clear PPRE2[13:11] bits */
    472            tmpreg &= CFGR_PPRE2_Reset_Mask;
    473          
    474            /* Set PPRE2[13:11] bits according to RCC_PCLK2 value */
    475            tmpreg |= RCC_PCLK2 << 3;
    476          
    477            /* Store the new value */
    478            RCC->CFGR = tmpreg;
    479          }
    480          
    481          /*******************************************************************************
    482          * Function Name  : RCC_ITConfig
    483          * Description    : Enables or disables the specified RCC interrupts.
    484          * Input          : - RCC_IT: specifies the RCC interrupt sources to be enabled
    485          *                    or disabled.
    486          *                    This parameter can be any combination of the following values:
    487          *                       - RCC_IT_LSIRDY: LSI ready interrupt
    488          *                       - RCC_IT_LSERDY: LSE ready interrupt
    489          *                       - RCC_IT_HSIRDY: HSI ready interrupt
    490          *                       - RCC_IT_HSERDY: HSE ready interrupt
    491          *                       - RCC_IT_PLLRDY: PLL ready interrupt
    492          *                  - NewState: new state of the specified RCC interrupts.
    493          *                    This parameter can be: ENABLE or DISABLE.
    494          * Output         : None
    495          * Return         : None
    496          *******************************************************************************/
    497          void RCC_ITConfig(u8 RCC_IT, FunctionalState NewState)
    498          {
    499            /* Check the parameters */
    500            assert_param(IS_RCC_IT(RCC_IT));
    501            assert_param(IS_FUNCTIONAL_STATE(NewState));
    502          
    503            if (NewState != DISABLE)
    504            {
    505              /* Perform Byte access to RCC_CIR[12:8] bits to enable the selected interrupts */
    506              *(vu8 *) 0x40021009 |= RCC_IT;
    507            }
    508            else
    509            {
    510              /* Perform Byte access to RCC_CIR[12:8] bits to disable the selected interrupts */
    511              *(vu8 *) 0x40021009 &= ~(u32)RCC_IT;
    512            }
    513          }
    514          
    515          /*******************************************************************************
    516          * Function Name  : RCC_USBCLKConfig
    517          * Description    : Configures the USB clock (USBCLK).
    518          * Input          : - RCC_USBCLKSource: specifies the USB clock source. This clock
    519          *                    is derived from the PLL output.
    520          *                    This parameter can be one of the following values:
    521          *                       - RCC_USBCLKSource_PLLCLK_1Div5: PLL clock divided by 1,5
    522          *                         selected as USB clock source
    523          *                       - RCC_USBCLKSource_PLLCLK_Div1: PLL clock selected as USB
    524          *                         clock source
    525          * Output         : None
    526          * Return         : None
    527          *******************************************************************************/
    528          void RCC_USBCLKConfig(u32 RCC_USBCLKSource)
    529          {
    530            /* Check the parameters */
    531            assert_param(IS_RCC_USBCLK_SOURCE(RCC_USBCLKSource));
    532          
    533            *(vu32 *) CFGR_USBPRE_BB = RCC_USBCLKSource;
    534          }
    535          
    536          /*******************************************************************************
    537          * Function Name  : RCC_ADCCLKConfig
    538          * Description    : Configures the ADC clock (ADCCLK).
    539          * Input          : - RCC_ADCCLK: defines the ADC clock. This clock is derived
    540          *                    from the APB2 clock (PCLK2).
    541          *                    This parameter can be one of the following values:
    542          *                       - RCC_PCLK2_Div2: ADC clock = PCLK2/2
    543          *                       - RCC_PCLK2_Div4: ADC clock = PCLK2/4
    544          *                       - RCC_PCLK2_Div6: ADC clock = PCLK2/6
    545          *                       - RCC_PCLK2_Div8: ADC clock = PCLK2/8
    546          * Output         : None
    547          * Return         : None
    548          *******************************************************************************/
    549          void RCC_ADCCLKConfig(u32 RCC_ADCCLK)
    550          {
    551            u32 tmpreg = 0;
    552          
    553            /* Check the parameters */
    554            assert_param(IS_RCC_ADCCLK(RCC_ADCCLK));
    555          
    556            tmpreg = RCC->CFGR;
    557          
    558            /* Clear ADCPRE[15:14] bits */
    559            tmpreg &= CFGR_ADCPRE_Reset_Mask;
    560          
    561            /* Set ADCPRE[15:14] bits according to RCC_ADCCLK value */
    562            tmpreg |= RCC_ADCCLK;
    563          
    564            /* Store the new value */
    565            RCC->CFGR = tmpreg;
    566          }
    567          
    568          /*******************************************************************************
    569          * Function Name  : RCC_LSEConfig
    570          * Description    : Configures the External Low Speed oscillator (LSE).
    571          * Input          : - RCC_LSE: specifies the new state of the LSE.
    572          *                    This parameter can be one of the following values:
    573          *                       - RCC_LSE_OFF: LSE oscillator OFF
    574          *                       - RCC_LSE_ON: LSE oscillator ON
    575          *                       - RCC_LSE_Bypass: LSE oscillator bypassed with external
    576          *                         clock
    577          * Output         : None
    578          * Return         : None
    579          *******************************************************************************/
    580          void RCC_LSEConfig(u32 RCC_LSE)
    581          {
    582            /* Check the parameters */
    583            assert_param(IS_RCC_LSE(RCC_LSE));
    584          
    585            /* Reset LSEON and LSEBYP bits before configuring the LSE ------------------*/
    586            /* Reset LSEON bit */
    587            *(vu8 *) BDCR_BASE = RCC_LSE_OFF;
    588          
    589            /* Reset LSEBYP bit */
    590            *(vu8 *) BDCR_BASE = RCC_LSE_OFF;
    591          
    592            /* Configure LSE (RCC_LSE_OFF is already covered by the code section above) */
    593            switch(RCC_LSE)
    594            {
    595              case RCC_LSE_ON:
    596                /* Set LSEON bit */
    597                *(vu8 *) BDCR_BASE = RCC_LSE_ON;
    598                break;
    599          
    600              case RCC_LSE_Bypass:
    601                /* Set LSEBYP and LSEON bits */
    602                *(vu8 *) BDCR_BASE = RCC_LSE_Bypass | RCC_LSE_ON;
    603                break;
    604          
    605              default:
    606                break;
    607            }
    608          }
    609          
    610          /*******************************************************************************
    611          * Function Name  : RCC_LSICmd
    612          * Description    : Enables or disables the Internal Low Speed oscillator (LSI).
    613          *                  LSI can not be disabled if the IWDG is running.
    614          * Input          : - NewState: new state of the LSI.
    615          *                    This parameter can be: ENABLE or DISABLE.
    616          * Output         : None
    617          * Return         : None
    618          *******************************************************************************/
    619          void RCC_LSICmd(FunctionalState NewState)
    620          {
    621            /* Check the parameters */
    622            assert_param(IS_FUNCTIONAL_STATE(NewState));
    623          
    624            *(vu32 *) CSR_LSION_BB = (u32)NewState;
    625          }
    626          
    627          /*******************************************************************************
    628          * Function Name  : RCC_RTCCLKConfig
    629          * Description    : Configures the RTC clock (RTCCLK).
    630          *                  Once the RTC clock is selected it can抰 be changed unless the
    631          *                  Backup domain is reset.
    632          * Input          : - RCC_RTCCLKSource: specifies the RTC clock source.
    633          *                    This parameter can be one of the following values:
    634          *                       - RCC_RTCCLKSource_LSE: LSE selected as RTC clock
    635          *                       - RCC_RTCCLKSource_LSI: LSI selected as RTC clock
    636          *                       - RCC_RTCCLKSource_HSE_Div128: HSE clock divided by 128
    637          *                         selected as RTC clock
    638          * Output         : None
    639          * Return         : None
    640          *******************************************************************************/
    641          void RCC_RTCCLKConfig(u32 RCC_RTCCLKSource)
    642          {
    643            /* Check the parameters */
    644            assert_param(IS_RCC_RTCCLK_SOURCE(RCC_RTCCLKSource));
    645          
    646            /* Select the RTC clock source */
    647            RCC->BDCR |= RCC_RTCCLKSource;
    648          }
    649          
    650          /*******************************************************************************
    651          * Function Name  : RCC_RTCCLKCmd
    652          * Description    : Enables or disables the RTC clock.
    653          *                  This function must be used only after the RTC clock was
    654          *                  selected using the RCC_RTCCLKConfig function.
    655          * Input          : - NewState: new state of the RTC clock.
    656          *                    This parameter can be: ENABLE or DISABLE.
    657          * Output         : None
    658          * Return         : None
    659          *******************************************************************************/
    660          void RCC_RTCCLKCmd(FunctionalState NewState)
    661          {
    662            /* Check the parameters */
    663            assert_param(IS_FUNCTIONAL_STATE(NewState));
    664          
    665            *(vu32 *) BDCR_RTCEN_BB = (u32)NewState;
    666          }
    667          
    668          /*******************************************************************************
    669          * Function Name  : RCC_GetClocksFreq
    670          * Description    : Returns the frequencies of different on chip clocks.
    671          * Input          : - RCC_Clocks: pointer to a RCC_ClocksTypeDef structure which
    672          *                    will hold the clocks frequencies.
    673          * Output         : None
    674          * Return         : None
    675          *******************************************************************************/
    676          void RCC_GetClocksFreq(RCC_ClocksTypeDef* RCC_Clocks)
    677          {
    678            u32 tmp = 0, pllmull = 0, pllsource = 0, presc = 0;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -