Better method of reset and clock handling with RCC, support L1, F1, F2, F3, F4
This commit is contained in:
committed by
Piotr Esden-Tempski
parent
33f75a529d
commit
723e1a69bd
@@ -40,7 +40,7 @@ OBJS += crc_common_all.o dac_common_all.o dma_common_l1f013.o \
|
||||
gpio_common_all.o i2c_common_all.o iwdg_common_all.o \
|
||||
pwr_common_all.o spi_common_all.o spi_common_l1f124.o \
|
||||
timer_common_all.o usart_common_all.o usart_common_f124.o \
|
||||
exti_common_all.o
|
||||
rcc_common_all.o exti_common_all.o
|
||||
|
||||
OBJS += usb.o usb_control.o usb_standard.o usb_f103.o usb_f107.o \
|
||||
usb_fx07_common.o
|
||||
|
||||
@@ -67,7 +67,7 @@ use.
|
||||
@param[in] osc enum ::osc_t. Oscillator ID
|
||||
*/
|
||||
|
||||
void rcc_osc_ready_int_clear(osc_t osc)
|
||||
void rcc_osc_ready_int_clear(enum rcc_osc osc)
|
||||
{
|
||||
switch (osc) {
|
||||
case PLL:
|
||||
@@ -100,7 +100,7 @@ void rcc_osc_ready_int_clear(osc_t osc)
|
||||
@param[in] osc enum ::osc_t. Oscillator ID
|
||||
*/
|
||||
|
||||
void rcc_osc_ready_int_enable(osc_t osc)
|
||||
void rcc_osc_ready_int_enable(enum rcc_osc osc)
|
||||
{
|
||||
switch (osc) {
|
||||
case PLL:
|
||||
@@ -133,7 +133,7 @@ void rcc_osc_ready_int_enable(osc_t osc)
|
||||
@param[in] osc enum ::osc_t. Oscillator ID
|
||||
*/
|
||||
|
||||
void rcc_osc_ready_int_disable(osc_t osc)
|
||||
void rcc_osc_ready_int_disable(enum rcc_osc osc)
|
||||
{
|
||||
switch (osc) {
|
||||
case PLL:
|
||||
@@ -167,7 +167,7 @@ void rcc_osc_ready_int_disable(osc_t osc)
|
||||
@returns int. Boolean value for flag set.
|
||||
*/
|
||||
|
||||
int rcc_osc_ready_int_flag(osc_t osc)
|
||||
int rcc_osc_ready_int_flag(enum rcc_osc osc)
|
||||
{
|
||||
switch (osc) {
|
||||
case PLL:
|
||||
@@ -223,7 +223,7 @@ int rcc_css_int_flag(void)
|
||||
@param[in] osc enum ::osc_t. Oscillator ID
|
||||
*/
|
||||
|
||||
void rcc_wait_for_osc_ready(osc_t osc)
|
||||
void rcc_wait_for_osc_ready(enum rcc_osc osc)
|
||||
{
|
||||
switch (osc) {
|
||||
case PLL:
|
||||
@@ -265,7 +265,7 @@ pwr_disable_backup_domain_write_protect).
|
||||
@param[in] osc enum ::osc_t. Oscillator ID
|
||||
*/
|
||||
|
||||
void rcc_osc_on(osc_t osc)
|
||||
void rcc_osc_on(enum rcc_osc osc)
|
||||
{
|
||||
switch (osc) {
|
||||
case PLL:
|
||||
@@ -306,7 +306,7 @@ backup domain write protection has been removed (see
|
||||
@param[in] osc enum ::osc_t. Oscillator ID
|
||||
*/
|
||||
|
||||
void rcc_osc_off(osc_t osc)
|
||||
void rcc_osc_off(enum rcc_osc osc)
|
||||
{
|
||||
switch (osc) {
|
||||
case PLL:
|
||||
@@ -367,7 +367,7 @@ pwr_disable_backup_domain_write_protect).
|
||||
@param[in] osc enum ::osc_t. Oscillator ID. Only HSE and LSE have effect.
|
||||
*/
|
||||
|
||||
void rcc_osc_bypass_enable(osc_t osc)
|
||||
void rcc_osc_bypass_enable(enum rcc_osc osc)
|
||||
{
|
||||
switch (osc) {
|
||||
case HSE:
|
||||
@@ -400,7 +400,7 @@ pwr_disable_backup_domain_write_protect) or the backup domain has been reset
|
||||
@param[in] osc enum ::osc_t. Oscillator ID. Only HSE and LSE have effect.
|
||||
*/
|
||||
|
||||
void rcc_osc_bypass_disable(osc_t osc)
|
||||
void rcc_osc_bypass_disable(enum rcc_osc osc)
|
||||
{
|
||||
switch (osc) {
|
||||
case HSE:
|
||||
@@ -419,91 +419,6 @@ 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>.
|
||||
|
||||
@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 set
|
||||
@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
|
||||
*/
|
||||
|
||||
void rcc_peripheral_enable_clock(volatile uint32_t *reg, uint32_t 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>.
|
||||
|
||||
@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.
|
||||
@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
|
||||
*/
|
||||
|
||||
void rcc_peripheral_disable_clock(volatile uint32_t *reg, uint32_t 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>.
|
||||
|
||||
@param[in] *reg Unsigned int32. Pointer to a Reset Register
|
||||
(either RCC_AHBENR, RCC_APB1ENR or RCC_APB2ENR)
|
||||
@param[in] reset Unsigned int32. Logical OR of all resets.
|
||||
@li If register is RCC_AHBRSTR, from @ref rcc_ahbrstr_rst
|
||||
@li If register is RCC_APB1RSTR, from @ref rcc_apb1rstr_rst
|
||||
@li If register is RCC_APB2RSTR, from @ref rcc_apb2rstr_rst
|
||||
*/
|
||||
|
||||
void rcc_peripheral_reset(volatile uint32_t *reg, uint32_t reset)
|
||||
{
|
||||
*reg |= reset;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @brief RCC Remove Reset on Peripherals.
|
||||
|
||||
Remove the reset on particular peripherals. There are three registers
|
||||
involved, each one controlling reset of peripherals associated with the AHB,
|
||||
APB1 and APB2 respectively. Several peripherals could have the reset removed
|
||||
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)
|
||||
@param[in] clear_reset Unsigned int32. Logical OR of all resets to be removed:
|
||||
@li If register is RCC_AHBRSTR, from @ref rcc_ahbrstr_rst
|
||||
@li If register is RCC_APB1RSTR, from @ref rcc_apb1rstr_rst
|
||||
@li If register is RCC_APB2RSTR, from @ref rcc_apb2rstr_rst
|
||||
*/
|
||||
|
||||
void rcc_peripheral_clear_reset(volatile uint32_t *reg, uint32_t clear_reset)
|
||||
{
|
||||
*reg &= ~clear_reset;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @brief RCC Set the Source for the System Clock.
|
||||
|
||||
@@ -1218,5 +1133,6 @@ void rcc_backupdomain_reset(void)
|
||||
/* Clear the backup domain software reset. */
|
||||
RCC_BDCR &= ~RCC_BDCR_BDRST;
|
||||
}
|
||||
|
||||
/**@}*/
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ LGPL License Terms @ref lgpl_license
|
||||
#include <libopencm3/stm32/rtc.h>
|
||||
#include <libopencm3/stm32/pwr.h>
|
||||
|
||||
void rtc_awake_from_off(osc_t clock_source)
|
||||
void rtc_awake_from_off(enum rcc_osc clock_source)
|
||||
{
|
||||
uint32_t reg32;
|
||||
|
||||
@@ -279,7 +279,7 @@ void rtc_awake_from_standby(void)
|
||||
while ((reg32 = (RTC_CRL & RTC_CRL_RTOFF)) == 0);
|
||||
}
|
||||
|
||||
void rtc_auto_awake(osc_t clock_source, uint32_t prescale_val)
|
||||
void rtc_auto_awake(enum rcc_osc clock_source, uint32_t prescale_val)
|
||||
{
|
||||
uint32_t reg32;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user