|
|
|
|
@@ -6,7 +6,8 @@
|
|
|
|
|
|
|
|
|
|
@version 1.0.0
|
|
|
|
|
|
|
|
|
|
@author @htmlonly © @endhtmlonly 2009 Federico Ruiz-Ugalde \<memeruiz at gmail dot com\>
|
|
|
|
|
@author @htmlonly © @endhtmlonly 2009
|
|
|
|
|
Federico Ruiz-Ugalde \<memeruiz at gmail dot com\>
|
|
|
|
|
@author @htmlonly © @endhtmlonly 2009 Uwe Hermann <uwe@hermann-uwe.de>
|
|
|
|
|
@author @htmlonly © @endhtmlonly 2010 Thomas Otto <tommi@viadmin.org>
|
|
|
|
|
|
|
|
|
|
@@ -17,8 +18,8 @@ series of ARM Cortex Microcontrollers by ST Microelectronics.
|
|
|
|
|
|
|
|
|
|
@note Full support for connection line devices is not yet provided.
|
|
|
|
|
|
|
|
|
|
Clock settings and resets for many peripherals are given here rather than in the
|
|
|
|
|
corresponding peripheral library.
|
|
|
|
|
Clock settings and resets for many peripherals are given here rather than in
|
|
|
|
|
the corresponding peripheral library.
|
|
|
|
|
|
|
|
|
|
The library also provides a number of common configurations for the processor
|
|
|
|
|
system clock. Not all possible configurations are included.
|
|
|
|
|
@@ -57,10 +58,11 @@ u32 rcc_ppre1_frequency = 8000000;
|
|
|
|
|
/** Default ppre2 peripheral clock frequency after reset. */
|
|
|
|
|
u32 rcc_ppre2_frequency = 8000000;
|
|
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------------*/
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
|
/** @brief RCC Clear the Oscillator Ready Interrupt Flag
|
|
|
|
|
|
|
|
|
|
Clear the interrupt flag that was set when a clock oscillator became ready to use.
|
|
|
|
|
Clear the interrupt flag that was set when a clock oscillator became ready to
|
|
|
|
|
use.
|
|
|
|
|
|
|
|
|
|
@param[in] osc enum ::osc_t. Oscillator ID
|
|
|
|
|
*/
|
|
|
|
|
@@ -92,7 +94,7 @@ void rcc_osc_ready_int_clear(osc_t osc)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------------*/
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
|
/** @brief RCC Enable the Oscillator Ready Interrupt
|
|
|
|
|
|
|
|
|
|
@param[in] osc enum ::osc_t. Oscillator ID
|
|
|
|
|
@@ -125,7 +127,7 @@ void rcc_osc_ready_int_enable(osc_t osc)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------------*/
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
|
/** @brief RCC Disable the Oscillator Ready Interrupt
|
|
|
|
|
|
|
|
|
|
@param[in] osc enum ::osc_t. Oscillator ID
|
|
|
|
|
@@ -158,7 +160,7 @@ void rcc_osc_ready_int_disable(osc_t osc)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------------*/
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
|
/** @brief RCC Read the Oscillator Ready Interrupt Flag
|
|
|
|
|
|
|
|
|
|
@param[in] osc enum ::osc_t. Oscillator ID
|
|
|
|
|
@@ -194,7 +196,7 @@ int rcc_osc_ready_int_flag(osc_t osc)
|
|
|
|
|
cm3_assert_not_reached();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------------*/
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
|
/** @brief RCC Clear the Clock Security System Interrupt Flag
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
@@ -204,7 +206,7 @@ void rcc_css_int_clear(void)
|
|
|
|
|
RCC_CIR |= RCC_CIR_CSSC;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------------*/
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
|
/** @brief RCC Read the Clock Security System Interrupt Flag
|
|
|
|
|
|
|
|
|
|
@returns int. Boolean value for flag set.
|
|
|
|
|
@@ -215,7 +217,7 @@ int rcc_css_int_flag(void)
|
|
|
|
|
return ((RCC_CIR & RCC_CIR_CSSF) != 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------------*/
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
|
/** @brief RCC Wait for Oscillator Ready.
|
|
|
|
|
|
|
|
|
|
@param[in] osc enum ::osc_t. Oscillator ID
|
|
|
|
|
@@ -248,16 +250,17 @@ void rcc_wait_for_osc_ready(osc_t osc)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------------*/
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
|
/** @brief RCC Turn on an Oscillator.
|
|
|
|
|
|
|
|
|
|
Enable an oscillator and power on. Each oscillator requires an amount of time to
|
|
|
|
|
settle to a usable state. Refer to datasheets for time delay information. A status
|
|
|
|
|
flag is available to indicate when the oscillator becomes ready (see
|
|
|
|
|
Enable an oscillator and power on. Each oscillator requires an amount of time
|
|
|
|
|
to settle to a usable state. Refer to datasheets for time delay information. A
|
|
|
|
|
status flag is available to indicate when the oscillator becomes ready (see
|
|
|
|
|
@ref rcc_osc_ready_int_flag and @ref rcc_wait_for_osc_ready).
|
|
|
|
|
|
|
|
|
|
@note The LSE clock is in the backup domain and cannot be enabled until the
|
|
|
|
|
backup domain write protection has been removed (see @ref pwr_disable_backup_domain_write_protect).
|
|
|
|
|
backup domain write protection has been removed (see @ref
|
|
|
|
|
pwr_disable_backup_domain_write_protect).
|
|
|
|
|
|
|
|
|
|
@param[in] osc enum ::osc_t. Oscillator ID
|
|
|
|
|
*/
|
|
|
|
|
@@ -289,7 +292,7 @@ void rcc_osc_on(osc_t osc)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------------*/
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
|
/** @brief RCC Turn off an Oscillator.
|
|
|
|
|
|
|
|
|
|
Disable an oscillator and power off.
|
|
|
|
|
@@ -330,7 +333,7 @@ void rcc_osc_off(osc_t osc)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------------*/
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
|
/** @brief RCC Enable the Clock Security System.
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
@@ -340,7 +343,7 @@ void rcc_css_enable(void)
|
|
|
|
|
RCC_CR |= RCC_CR_CSSON;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------------*/
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
|
/** @brief RCC Disable the Clock Security System.
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
@@ -350,15 +353,16 @@ void rcc_css_disable(void)
|
|
|
|
|
RCC_CR &= ~RCC_CR_CSSON;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------------*/
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
|
/** @brief RCC Enable Bypass.
|
|
|
|
|
|
|
|
|
|
Enable an external clock to bypass the internal clock (high speed and low speed
|
|
|
|
|
clocks only). The external clock must be enabled (see @ref rcc_osc_on)
|
|
|
|
|
and the internal clock must be disabled (see @ref rcc_osc_off) for this to have effect.
|
|
|
|
|
clocks only). The external clock must be enabled (see @ref rcc_osc_on) and the
|
|
|
|
|
internal clock must be disabled (see @ref rcc_osc_off) for this to have effect.
|
|
|
|
|
|
|
|
|
|
@note The LSE clock is in the backup domain and cannot be bypassed until the
|
|
|
|
|
backup domain write protection has been removed (see @ref pwr_disable_backup_domain_write_protect).
|
|
|
|
|
backup domain write protection has been removed (see @ref
|
|
|
|
|
pwr_disable_backup_domain_write_protect).
|
|
|
|
|
|
|
|
|
|
@param[in] osc enum ::osc_t. Oscillator ID. Only HSE and LSE have effect.
|
|
|
|
|
*/
|
|
|
|
|
@@ -382,15 +386,16 @@ void rcc_osc_bypass_enable(osc_t osc)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------------*/
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
|
/** @brief RCC Disable Bypass.
|
|
|
|
|
|
|
|
|
|
Re-enable the internal clock (high speed and low speed clocks only). The internal
|
|
|
|
|
clock must be disabled (see @ref rcc_osc_off) for this to have effect.
|
|
|
|
|
Re-enable the internal clock (high speed and low speed clocks only). The
|
|
|
|
|
internal clock must be disabled (see @ref rcc_osc_off) for this to have effect.
|
|
|
|
|
|
|
|
|
|
@note The LSE clock is in the backup domain and cannot have bypass removed until the
|
|
|
|
|
backup domain write protection has been removed (see @ref pwr_disable_backup_domain_write_protect)
|
|
|
|
|
or the backup domain has been reset (see @ref rcc_backupdomain_reset).
|
|
|
|
|
@note The LSE clock is in the backup domain and cannot have bypass removed
|
|
|
|
|
until the backup domain write protection has been removed (see @ref
|
|
|
|
|
pwr_disable_backup_domain_write_protect) or the backup domain has been reset
|
|
|
|
|
(see @ref rcc_backupdomain_reset).
|
|
|
|
|
|
|
|
|
|
@param[in] osc enum ::osc_t. Oscillator ID. Only HSE and LSE have effect.
|
|
|
|
|
*/
|
|
|
|
|
@@ -414,13 +419,13 @@ void rcc_osc_bypass_disable(osc_t osc)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------------*/
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
|
/** @brief RCC Enable Peripheral Clocks.
|
|
|
|
|
|
|
|
|
|
Enable the clock on particular peripherals. There are three registers
|
|
|
|
|
involved, each one controlling the enabling of clocks associated with the AHB,
|
|
|
|
|
APB1 and APB2 respectively. Several peripherals could be
|
|
|
|
|
enabled simultaneously <em>only if they are controlled by the same register</em>.
|
|
|
|
|
Enable the clock on particular peripherals. There are three registers involved,
|
|
|
|
|
each one controlling the enabling of clocks associated with the AHB, APB1 and
|
|
|
|
|
APB2 respectively. Several peripherals could be enabled simultaneously <em>only
|
|
|
|
|
if they are controlled by the same register</em>.
|
|
|
|
|
|
|
|
|
|
@param[in] *reg Unsigned int32. Pointer to a Clock Enable Register
|
|
|
|
|
(either RCC_AHBENR, RCC_APB1ENR or RCC_APB2ENR)
|
|
|
|
|
@@ -435,17 +440,18 @@ void rcc_peripheral_enable_clock(volatile u32 *reg, u32 en)
|
|
|
|
|
*reg |= en;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------------*/
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
|
/** @brief RCC Disable Peripheral Clocks.
|
|
|
|
|
|
|
|
|
|
Enable the clock on particular peripherals. There are three registers
|
|
|
|
|
involved, each one controlling the enabling of clocks associated with the AHB,
|
|
|
|
|
APB1 and APB2 respectively. Several peripherals could be
|
|
|
|
|
disabled simultaneously <em>only if they are controlled by the same register</em>.
|
|
|
|
|
Enable the clock on particular peripherals. There are three registers involved,
|
|
|
|
|
each one controlling the enabling of clocks associated with the AHB, APB1 and
|
|
|
|
|
APB2 respectively. Several peripherals could be disabled simultaneously
|
|
|
|
|
<em>only if they are controlled by the same register</em>.
|
|
|
|
|
|
|
|
|
|
@param[in] *reg Unsigned int32. Pointer to a Clock Enable Register
|
|
|
|
|
(either RCC_AHBENR, RCC_APB1ENR or RCC_APB2ENR)
|
|
|
|
|
@param[in] en Unsigned int32. Logical OR of all enables to be used for disabling.
|
|
|
|
|
@param[in] en Unsigned int32. Logical OR of all enables to be used for
|
|
|
|
|
disabling.
|
|
|
|
|
@li If register is RCC_AHBER, from @ref rcc_ahbenr_en
|
|
|
|
|
@li If register is RCC_APB1ENR, from @ref rcc_apb1enr_en
|
|
|
|
|
@li If register is RCC_APB2ENR, from @ref rcc_apb2enr_en
|
|
|
|
|
@@ -456,13 +462,13 @@ void rcc_peripheral_disable_clock(volatile u32 *reg, u32 en)
|
|
|
|
|
*reg &= ~en;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------------*/
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
|
/** @brief RCC Reset Peripherals.
|
|
|
|
|
|
|
|
|
|
Reset particular peripherals. There are three registers
|
|
|
|
|
involved, each one controlling reset of peripherals associated with the AHB,
|
|
|
|
|
APB1 and APB2 respectively. Several peripherals could be reset simultaneously
|
|
|
|
|
<em>only if they are controlled by the same register</em>.
|
|
|
|
|
Reset particular peripherals. There are three registers involved, each one
|
|
|
|
|
controlling reset of peripherals associated with the AHB, APB1 and APB2
|
|
|
|
|
respectively. Several peripherals could be reset simultaneously <em>only if
|
|
|
|
|
they are controlled by the same register</em>.
|
|
|
|
|
|
|
|
|
|
@param[in] *reg Unsigned int32. Pointer to a Reset Register
|
|
|
|
|
(either RCC_AHBENR, RCC_APB1ENR or RCC_APB2ENR)
|
|
|
|
|
@@ -477,7 +483,7 @@ void rcc_peripheral_reset(volatile u32 *reg, u32 reset)
|
|
|
|
|
*reg |= reset;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------------*/
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
|
/** @brief RCC Remove Reset on Peripherals.
|
|
|
|
|
|
|
|
|
|
Remove the reset on particular peripherals. There are three registers
|
|
|
|
|
@@ -498,7 +504,7 @@ void rcc_peripheral_clear_reset(volatile u32 *reg, u32 clear_reset)
|
|
|
|
|
*reg &= ~clear_reset;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------------*/
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
|
/** @brief RCC Set the Source for the System Clock.
|
|
|
|
|
|
|
|
|
|
@param[in] clk Unsigned int32. System Clock Selection @ref rcc_cfgr_scs
|
|
|
|
|
@@ -513,7 +519,7 @@ void rcc_set_sysclk_source(u32 clk)
|
|
|
|
|
RCC_CFGR = (reg32 | clk);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------------*/
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
|
/** @brief RCC Set the PLL Multiplication Factor.
|
|
|
|
|
|
|
|
|
|
@note This only has effect when the PLL is disabled.
|
|
|
|
|
@@ -530,7 +536,7 @@ void rcc_set_pll_multiplication_factor(u32 mul)
|
|
|
|
|
RCC_CFGR = (reg32 | (mul << 18));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------------*/
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
|
/** @brief RCC Set the PLL2 Multiplication Factor.
|
|
|
|
|
|
|
|
|
|
@note This only has effect when the PLL is disabled.
|
|
|
|
|
@@ -547,7 +553,7 @@ void rcc_set_pll2_multiplication_factor(u32 mul)
|
|
|
|
|
RCC_CFGR2 = (reg32 | (mul << 8));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------------*/
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
|
/** @brief RCC Set the PLL3 Multiplication Factor.
|
|
|
|
|
|
|
|
|
|
@note This only has effect when the PLL is disabled.
|
|
|
|
|
@@ -564,7 +570,7 @@ void rcc_set_pll3_multiplication_factor(u32 mul)
|
|
|
|
|
RCC_CFGR2 = (reg32 | (mul << 12));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------------*/
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
|
/** @brief RCC Set the PLL Clock Source.
|
|
|
|
|
|
|
|
|
|
@note This only has effect when the PLL is disabled.
|
|
|
|
|
@@ -581,7 +587,7 @@ void rcc_set_pll_source(u32 pllsrc)
|
|
|
|
|
RCC_CFGR = (reg32 | (pllsrc << 16));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------------*/
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
|
/** @brief RCC Set the HSE Frequency Divider used as PLL Clock Source.
|
|
|
|
|
|
|
|
|
|
@note This only has effect when the PLL is disabled.
|
|
|
|
|
@@ -598,7 +604,7 @@ void rcc_set_pllxtpre(u32 pllxtpre)
|
|
|
|
|
RCC_CFGR = (reg32 | (pllxtpre << 17));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------------*/
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
|
/** @brief ADC Setup the A/D Clock
|
|
|
|
|
|
|
|
|
|
The ADC's have a common clock prescale setting.
|
|
|
|
|
@@ -615,7 +621,7 @@ void rcc_set_adcpre(u32 adcpre)
|
|
|
|
|
RCC_CFGR = (reg32 | (adcpre << 14));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------------*/
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
|
/** @brief RCC Set the APB2 Prescale Factor.
|
|
|
|
|
|
|
|
|
|
@param[in] ppre2 Unsigned int32. APB2 prescale factor @ref rcc_cfgr_apb2pre
|
|
|
|
|
@@ -630,7 +636,7 @@ void rcc_set_ppre2(u32 ppre2)
|
|
|
|
|
RCC_CFGR = (reg32 | (ppre2 << 11));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------------*/
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
|
/** @brief RCC Set the APB1 Prescale Factor.
|
|
|
|
|
|
|
|
|
|
@note The APB1 clock frequency must not exceed 36MHz.
|
|
|
|
|
@@ -647,7 +653,7 @@ void rcc_set_ppre1(u32 ppre1)
|
|
|
|
|
RCC_CFGR = (reg32 | (ppre1 << 8));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------------*/
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
|
/** @brief RCC Set the AHB Prescale Factor.
|
|
|
|
|
|
|
|
|
|
@param[in] hpre Unsigned int32. AHB prescale factor @ref rcc_cfgr_ahbpre
|
|
|
|
|
@@ -662,7 +668,7 @@ void rcc_set_hpre(u32 hpre)
|
|
|
|
|
RCC_CFGR = (reg32 | (hpre << 4));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------------*/
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
|
/** @brief RCC Set the USB Prescale Factor.
|
|
|
|
|
|
|
|
|
|
The prescale factor can be set to 1 (no prescale) for use when the PLL clock is
|
|
|
|
|
@@ -712,7 +718,7 @@ void rcc_set_mco(u32 mcosrc)
|
|
|
|
|
RCC_CFGR |= (reg32 | (mcosrc << 24));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------------*/
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
|
/** @brief RCC Get the System Clock Source.
|
|
|
|
|
|
|
|
|
|
@returns Unsigned int32. System clock source:
|
|
|
|
|
@@ -724,15 +730,15 @@ void rcc_set_mco(u32 mcosrc)
|
|
|
|
|
u32 rcc_system_clock_source(void)
|
|
|
|
|
{
|
|
|
|
|
/* Return the clock source which is used as system clock. */
|
|
|
|
|
return ((RCC_CFGR & 0x000c) >> 2);
|
|
|
|
|
return (RCC_CFGR & 0x000c) >> 2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------------*/
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
|
/*
|
|
|
|
|
* These functions are setting up the whole clock system for the most common
|
|
|
|
|
* input clock and output clock configurations.
|
|
|
|
|
*/
|
|
|
|
|
/*-----------------------------------------------------------------------------*/
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
|
/** @brief RCC Set System Clock PLL at 64MHz from HSI
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
@@ -750,10 +756,10 @@ void rcc_clock_setup_in_hsi_out_64mhz(void)
|
|
|
|
|
* Set prescalers for AHB, ADC, ABP1, ABP2.
|
|
|
|
|
* Do this before touching the PLL (TODO: why?).
|
|
|
|
|
*/
|
|
|
|
|
rcc_set_hpre(RCC_CFGR_HPRE_SYSCLK_NODIV); /* Set. 64MHz Max. 72MHz */
|
|
|
|
|
rcc_set_adcpre(RCC_CFGR_ADCPRE_PCLK2_DIV8); /* Set. 8MHz Max. 14MHz */
|
|
|
|
|
rcc_set_ppre1(RCC_CFGR_PPRE1_HCLK_DIV2); /* Set. 32MHz Max. 36MHz */
|
|
|
|
|
rcc_set_ppre2(RCC_CFGR_PPRE2_HCLK_NODIV); /* Set. 64MHz Max. 72MHz */
|
|
|
|
|
rcc_set_hpre(RCC_CFGR_HPRE_SYSCLK_NODIV); /* Set. 64MHz Max. 72MHz */
|
|
|
|
|
rcc_set_adcpre(RCC_CFGR_ADCPRE_PCLK2_DIV8); /* Set. 8MHz Max. 14MHz */
|
|
|
|
|
rcc_set_ppre1(RCC_CFGR_PPRE1_HCLK_DIV2); /* Set. 32MHz Max. 36MHz */
|
|
|
|
|
rcc_set_ppre2(RCC_CFGR_PPRE2_HCLK_NODIV); /* Set. 64MHz Max. 72MHz */
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Sysclk is running with 64MHz -> 2 waitstates.
|
|
|
|
|
@@ -784,7 +790,7 @@ void rcc_clock_setup_in_hsi_out_64mhz(void)
|
|
|
|
|
rcc_ppre2_frequency = 64000000;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------------*/
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
|
/** @brief RCC Set System Clock PLL at 48MHz from HSI
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
@@ -802,11 +808,11 @@ void rcc_clock_setup_in_hsi_out_48mhz(void)
|
|
|
|
|
* Set prescalers for AHB, ADC, ABP1, ABP2.
|
|
|
|
|
* Do this before touching the PLL (TODO: why?).
|
|
|
|
|
*/
|
|
|
|
|
rcc_set_hpre(RCC_CFGR_HPRE_SYSCLK_NODIV); /* Set. 48MHz Max. 72MHz */
|
|
|
|
|
rcc_set_adcpre(RCC_CFGR_ADCPRE_PCLK2_DIV8); /* Set. 6MHz Max. 14MHz */
|
|
|
|
|
rcc_set_ppre1(RCC_CFGR_PPRE1_HCLK_DIV2); /* Set. 24MHz Max. 36MHz */
|
|
|
|
|
rcc_set_ppre2(RCC_CFGR_PPRE2_HCLK_NODIV); /* Set. 48MHz Max. 72MHz */
|
|
|
|
|
rcc_set_usbpre(RCC_CFGR_USBPRE_PLL_CLK_NODIV); /* Set. 48MHz Max. 48MHz */
|
|
|
|
|
rcc_set_hpre(RCC_CFGR_HPRE_SYSCLK_NODIV); /*Set.48MHz Max.72MHz */
|
|
|
|
|
rcc_set_adcpre(RCC_CFGR_ADCPRE_PCLK2_DIV8); /*Set. 6MHz Max.14MHz */
|
|
|
|
|
rcc_set_ppre1(RCC_CFGR_PPRE1_HCLK_DIV2); /*Set.24MHz Max.36MHz */
|
|
|
|
|
rcc_set_ppre2(RCC_CFGR_PPRE2_HCLK_NODIV); /*Set.48MHz Max.72MHz */
|
|
|
|
|
rcc_set_usbpre(RCC_CFGR_USBPRE_PLL_CLK_NODIV); /*Set.48MHz Max.48MHz */
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Sysclk runs with 48MHz -> 1 waitstates.
|
|
|
|
|
@@ -837,12 +843,13 @@ void rcc_clock_setup_in_hsi_out_48mhz(void)
|
|
|
|
|
rcc_ppre2_frequency = 48000000;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------------*/
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
|
/** @brief RCC Set System Clock PLL at 24MHz from HSI
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
void rcc_clock_setup_in_hsi_out_24mhz(void) {
|
|
|
|
|
void rcc_clock_setup_in_hsi_out_24mhz(void)
|
|
|
|
|
{
|
|
|
|
|
/* Enable internal high-speed oscillator. */
|
|
|
|
|
rcc_osc_on(HSI);
|
|
|
|
|
rcc_wait_for_osc_ready(HSI);
|
|
|
|
|
@@ -888,7 +895,7 @@ void rcc_clock_setup_in_hsi_out_24mhz(void) {
|
|
|
|
|
rcc_ppre2_frequency = 24000000;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------------*/
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
|
/** @brief RCC Set System Clock PLL at 24MHz from HSE at 8MHz
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
@@ -911,10 +918,10 @@ void rcc_clock_setup_in_hse_8mhz_out_24mhz(void)
|
|
|
|
|
* Set prescalers for AHB, ADC, ABP1, ABP2.
|
|
|
|
|
* Do this before touching the PLL (TODO: why?).
|
|
|
|
|
*/
|
|
|
|
|
rcc_set_hpre(RCC_CFGR_HPRE_SYSCLK_NODIV); /* Set. 24MHz Max. 72MHz */
|
|
|
|
|
rcc_set_adcpre(RCC_CFGR_ADCPRE_PCLK2_DIV2); /* Set. 12MHz Max. 14MHz */
|
|
|
|
|
rcc_set_ppre1(RCC_CFGR_PPRE1_HCLK_NODIV); /* Set. 24MHz Max. 36MHz */
|
|
|
|
|
rcc_set_ppre2(RCC_CFGR_PPRE2_HCLK_NODIV); /* Set. 24MHz Max. 72MHz */
|
|
|
|
|
rcc_set_hpre(RCC_CFGR_HPRE_SYSCLK_NODIV); /* Set. 24MHz Max. 72MHz */
|
|
|
|
|
rcc_set_adcpre(RCC_CFGR_ADCPRE_PCLK2_DIV2); /* Set. 12MHz Max. 14MHz */
|
|
|
|
|
rcc_set_ppre1(RCC_CFGR_PPRE1_HCLK_NODIV); /* Set. 24MHz Max. 36MHz */
|
|
|
|
|
rcc_set_ppre2(RCC_CFGR_PPRE2_HCLK_NODIV); /* Set. 24MHz Max. 72MHz */
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Sysclk runs with 24MHz -> 0 waitstates.
|
|
|
|
|
@@ -951,7 +958,7 @@ void rcc_clock_setup_in_hse_8mhz_out_24mhz(void)
|
|
|
|
|
rcc_ppre2_frequency = 24000000;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------------*/
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
|
/** @brief RCC Set System Clock PLL at 72MHz from HSE at 8MHz
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
@@ -974,10 +981,10 @@ void rcc_clock_setup_in_hse_8mhz_out_72mhz(void)
|
|
|
|
|
* Set prescalers for AHB, ADC, ABP1, ABP2.
|
|
|
|
|
* Do this before touching the PLL (TODO: why?).
|
|
|
|
|
*/
|
|
|
|
|
rcc_set_hpre(RCC_CFGR_HPRE_SYSCLK_NODIV); /* Set. 72MHz Max. 72MHz */
|
|
|
|
|
rcc_set_adcpre(RCC_CFGR_ADCPRE_PCLK2_DIV8); /* Set. 9MHz Max. 14MHz */
|
|
|
|
|
rcc_set_ppre1(RCC_CFGR_PPRE1_HCLK_DIV2); /* Set. 36MHz Max. 36MHz */
|
|
|
|
|
rcc_set_ppre2(RCC_CFGR_PPRE2_HCLK_NODIV); /* Set. 72MHz Max. 72MHz */
|
|
|
|
|
rcc_set_hpre(RCC_CFGR_HPRE_SYSCLK_NODIV); /* Set. 72MHz Max. 72MHz */
|
|
|
|
|
rcc_set_adcpre(RCC_CFGR_ADCPRE_PCLK2_DIV8); /* Set. 9MHz Max. 14MHz */
|
|
|
|
|
rcc_set_ppre1(RCC_CFGR_PPRE1_HCLK_DIV2); /* Set. 36MHz Max. 36MHz */
|
|
|
|
|
rcc_set_ppre2(RCC_CFGR_PPRE2_HCLK_NODIV); /* Set. 72MHz Max. 72MHz */
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Sysclk runs with 72MHz -> 2 waitstates.
|
|
|
|
|
@@ -1014,7 +1021,7 @@ void rcc_clock_setup_in_hse_8mhz_out_72mhz(void)
|
|
|
|
|
rcc_ppre2_frequency = 72000000;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------------*/
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
|
/** @brief RCC Set System Clock PLL at 24MHz from HSE at 12MHz
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
@@ -1037,10 +1044,10 @@ void rcc_clock_setup_in_hse_12mhz_out_72mhz(void)
|
|
|
|
|
* Set prescalers for AHB, ADC, ABP1, ABP2.
|
|
|
|
|
* Do this before touching the PLL (TODO: why?).
|
|
|
|
|
*/
|
|
|
|
|
rcc_set_hpre(RCC_CFGR_HPRE_SYSCLK_NODIV); /* Set. 72MHz Max. 72MHz */
|
|
|
|
|
rcc_set_adcpre(RCC_CFGR_ADCPRE_PCLK2_DIV6); /* Set. 12MHz Max. 14MHz */
|
|
|
|
|
rcc_set_ppre1(RCC_CFGR_PPRE1_HCLK_DIV2); /* Set. 36MHz Max. 36MHz */
|
|
|
|
|
rcc_set_ppre2(RCC_CFGR_PPRE2_HCLK_NODIV); /* Set. 72MHz Max. 72MHz */
|
|
|
|
|
rcc_set_hpre(RCC_CFGR_HPRE_SYSCLK_NODIV); /* Set. 72MHz Max. 72MHz */
|
|
|
|
|
rcc_set_adcpre(RCC_CFGR_ADCPRE_PCLK2_DIV6); /* Set. 12MHz Max. 14MHz */
|
|
|
|
|
rcc_set_ppre1(RCC_CFGR_PPRE1_HCLK_DIV2); /* Set. 36MHz Max. 36MHz */
|
|
|
|
|
rcc_set_ppre2(RCC_CFGR_PPRE2_HCLK_NODIV); /* Set. 72MHz Max. 72MHz */
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Sysclk runs with 72MHz -> 2 waitstates.
|
|
|
|
|
@@ -1077,7 +1084,7 @@ void rcc_clock_setup_in_hse_12mhz_out_72mhz(void)
|
|
|
|
|
rcc_ppre2_frequency = 72000000;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------------*/
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
|
/** @brief RCC Set System Clock PLL at 24MHz from HSE at 16MHz
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
@@ -1100,10 +1107,10 @@ void rcc_clock_setup_in_hse_16mhz_out_72mhz(void)
|
|
|
|
|
* Set prescalers for AHB, ADC, ABP1, ABP2.
|
|
|
|
|
* Do this before touching the PLL (TODO: why?).
|
|
|
|
|
*/
|
|
|
|
|
rcc_set_hpre(RCC_CFGR_HPRE_SYSCLK_NODIV); /* Set. 72MHz Max. 72MHz */
|
|
|
|
|
rcc_set_adcpre(RCC_CFGR_ADCPRE_PCLK2_DIV6); /* Set. 12MHz Max. 14MHz */
|
|
|
|
|
rcc_set_ppre1(RCC_CFGR_PPRE1_HCLK_DIV2); /* Set. 36MHz Max. 36MHz */
|
|
|
|
|
rcc_set_ppre2(RCC_CFGR_PPRE2_HCLK_NODIV); /* Set. 72MHz Max. 72MHz */
|
|
|
|
|
rcc_set_hpre(RCC_CFGR_HPRE_SYSCLK_NODIV); /* Set. 72MHz Max. 72MHz */
|
|
|
|
|
rcc_set_adcpre(RCC_CFGR_ADCPRE_PCLK2_DIV6); /* Set. 12MHz Max. 14MHz */
|
|
|
|
|
rcc_set_ppre1(RCC_CFGR_PPRE1_HCLK_DIV2); /* Set. 36MHz Max. 36MHz */
|
|
|
|
|
rcc_set_ppre2(RCC_CFGR_PPRE2_HCLK_NODIV); /* Set. 72MHz Max. 72MHz */
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Sysclk runs with 72MHz -> 2 waitstates.
|
|
|
|
|
@@ -1140,7 +1147,7 @@ void rcc_clock_setup_in_hse_16mhz_out_72mhz(void)
|
|
|
|
|
rcc_ppre2_frequency = 72000000;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------------*/
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
|
/** @brief RCC Set System Clock PLL at 72MHz from HSE at 25MHz
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
@@ -1164,10 +1171,10 @@ void rcc_clock_setup_in_hse_25mhz_out_72mhz(void)
|
|
|
|
|
* Set prescalers for AHB, ADC, ABP1, ABP2.
|
|
|
|
|
* Do this before touching the PLL (TODO: why?).
|
|
|
|
|
*/
|
|
|
|
|
rcc_set_hpre(RCC_CFGR_HPRE_SYSCLK_NODIV); /* Set. 72MHz Max. 72MHz */
|
|
|
|
|
rcc_set_adcpre(RCC_CFGR_ADCPRE_PCLK2_DIV6); /* Set. 12MHz Max. 14MHz */
|
|
|
|
|
rcc_set_ppre1(RCC_CFGR_PPRE1_HCLK_DIV2); /* Set. 36MHz Max. 36MHz */
|
|
|
|
|
rcc_set_ppre2(RCC_CFGR_PPRE2_HCLK_NODIV); /* Set. 72MHz Max. 72MHz */
|
|
|
|
|
rcc_set_hpre(RCC_CFGR_HPRE_SYSCLK_NODIV); /* Set. 72MHz Max. 72MHz */
|
|
|
|
|
rcc_set_adcpre(RCC_CFGR_ADCPRE_PCLK2_DIV6); /* Set. 12MHz Max. 14MHz */
|
|
|
|
|
rcc_set_ppre1(RCC_CFGR_PPRE1_HCLK_DIV2); /* Set. 36MHz Max. 36MHz */
|
|
|
|
|
rcc_set_ppre2(RCC_CFGR_PPRE2_HCLK_NODIV); /* Set. 72MHz Max. 72MHz */
|
|
|
|
|
|
|
|
|
|
/* Set pll2 prediv and multiplier */
|
|
|
|
|
rcc_set_prediv2(RCC_CFGR2_PREDIV2_DIV5);
|
|
|
|
|
@@ -1197,7 +1204,7 @@ void rcc_clock_setup_in_hse_25mhz_out_72mhz(void)
|
|
|
|
|
rcc_ppre2_frequency = 72000000;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------------*/
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
|
/** @brief RCC Reset the backup domain
|
|
|
|
|
|
|
|
|
|
The backup domain register is reset to disable all controls.
|
|
|
|
|
|