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
185
lib/stm32/common/rcc_common_all.c
Normal file
185
lib/stm32/common/rcc_common_all.c
Normal file
@@ -0,0 +1,185 @@
|
||||
/*
|
||||
* This file is part of the libopencm3 project.
|
||||
*
|
||||
* Copyright (C) 2013 Frantisek Burian <bufran@seznam.cz>
|
||||
* .. file is merged from many other copyrighted files of stm32 family
|
||||
*
|
||||
* This library is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <libopencm3/stm32/rcc.h>
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @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;
|
||||
}
|
||||
|
||||
#define _RCC_REG(i) MMIO32(RCC_BASE + ((i) >> 5))
|
||||
#define _RCC_BIT(i) (1 << ((i) & 0x1f))
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @brief Enable Peripheral Clock in running mode.
|
||||
*
|
||||
* Enable the clock on particular peripheral.
|
||||
*
|
||||
* @param[in] periph periph_t Peripheral Name
|
||||
*
|
||||
* For available constants, see #periph_t (RCC_UART1 for example)
|
||||
*/
|
||||
|
||||
void rcc_periph_clock_enable(enum rcc_periph_clken clken)
|
||||
{
|
||||
_RCC_REG(clken) |= _RCC_BIT(clken);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @brief Disable Peripheral Clock in running mode.
|
||||
* Disable the clock on particular peripheral.
|
||||
*
|
||||
* @param[in] periph periph_t Peripheral Name
|
||||
*
|
||||
* For available constants, see #periph_t (RCC_UART1 for example)
|
||||
*/
|
||||
|
||||
void rcc_periph_clock_disable(enum rcc_periph_clken clken)
|
||||
{
|
||||
_RCC_REG(clken) &= ~_RCC_BIT(clken);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @brief Reset Peripheral, pulsed
|
||||
*
|
||||
* Reset particular peripheral, and restore to working state.
|
||||
*
|
||||
* @param[in] periph periph_t Peripheral name
|
||||
*
|
||||
* For available constants, see #periph_t (RCC_UART1 for example)
|
||||
*/
|
||||
|
||||
void rcc_periph_reset_pulse(enum rcc_periph_rst rst)
|
||||
{
|
||||
_RCC_REG(rst) |= _RCC_BIT(rst);
|
||||
_RCC_REG(rst) &= ~_RCC_BIT(rst);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @brief Reset Peripheral, hold
|
||||
*
|
||||
* Reset particular peripheral, and hold in reset state.
|
||||
*
|
||||
* @param[in] periph periph_t Peripheral name
|
||||
*
|
||||
* For available constants, see #periph_t (RCC_UART1 for example)
|
||||
*/
|
||||
|
||||
void rcc_periph_reset_hold(enum rcc_periph_rst rst)
|
||||
{
|
||||
_RCC_REG(rst) |= _RCC_BIT(rst);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @brief Reset Peripheral, release
|
||||
*
|
||||
* Restore peripheral from reset state to working state.
|
||||
*
|
||||
* @param[in] periph periph_t Peripheral name
|
||||
*
|
||||
* For available constants, see #periph_t (RCC_UART1 for example)
|
||||
*/
|
||||
|
||||
void rcc_periph_reset_release(enum rcc_periph_rst rst)
|
||||
{
|
||||
_RCC_REG(rst) &= ~_RCC_BIT(rst);
|
||||
}
|
||||
|
||||
#undef _RCC_REG
|
||||
#undef _RCC_BIT
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ OBJS += crc_common_all.o dac_common_all.o dma_common_f24.o \
|
||||
spi_common_l1f124.o timer_common_all.o timer_common_f234.o \
|
||||
timer_common_f24.o usart_common_all.o usart_common_f124.o \
|
||||
flash_common_f234.o flash_common_f24.o hash_common_f24.o \
|
||||
crypto_common_f24.o exti_common_all.o
|
||||
crypto_common_f24.o exti_common_all.o rcc_common_all.o
|
||||
|
||||
OBJS += usb.o usb_standard.o usb_control.o usb_fx07_common.o \
|
||||
usb_f107.o usb_f207.o
|
||||
|
||||
@@ -1,3 +1,21 @@
|
||||
/** @defgroup rcc_file RCC
|
||||
*
|
||||
* @ingroup STM32F2xx
|
||||
*
|
||||
* @section rcc_f2_api_ex Reset and Clock Control API.
|
||||
*
|
||||
* @brief <b>libopencm3 STM32F4xx Reset and Clock Control</b>
|
||||
*
|
||||
* @author @htmlonly © @endhtmlonly 2013 Frantisek Burian <BuFran at seznam.cz>
|
||||
*
|
||||
* @date 18 Jun 2013
|
||||
*
|
||||
* This library supports the Reset and Clock Control System in the STM32 series
|
||||
* of ARM Cortex Microcontrollers by ST Microelectronics.
|
||||
*
|
||||
* LGPL License Terms @ref lgpl_license
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file is part of the libopencm3 project.
|
||||
*
|
||||
@@ -23,6 +41,8 @@
|
||||
#include <libopencm3/stm32/f2/rcc.h>
|
||||
#include <libopencm3/stm32/f2/flash.h>
|
||||
|
||||
/**@{*/
|
||||
|
||||
/* Set the default ppre1 and ppre2 peripheral clock frequencies after reset. */
|
||||
uint32_t rcc_ppre1_frequency = 16000000;
|
||||
uint32_t rcc_ppre2_frequency = 16000000;
|
||||
@@ -264,26 +284,6 @@ void rcc_osc_bypass_disable(osc_t osc)
|
||||
}
|
||||
}
|
||||
|
||||
void rcc_peripheral_enable_clock(volatile uint32_t *reg, uint32_t en)
|
||||
{
|
||||
*reg |= en;
|
||||
}
|
||||
|
||||
void rcc_peripheral_disable_clock(volatile uint32_t *reg, uint32_t en)
|
||||
{
|
||||
*reg &= ~en;
|
||||
}
|
||||
|
||||
void rcc_peripheral_reset(volatile uint32_t *reg, uint32_t reset)
|
||||
{
|
||||
*reg |= reset;
|
||||
}
|
||||
|
||||
void rcc_peripheral_clear_reset(volatile uint32_t *reg, uint32_t clear_reset)
|
||||
{
|
||||
*reg &= ~clear_reset;
|
||||
}
|
||||
|
||||
void rcc_set_sysclk_source(uint32_t clk)
|
||||
{
|
||||
uint32_t reg32;
|
||||
@@ -413,3 +413,5 @@ void rcc_backupdomain_reset(void)
|
||||
/* Clear the backup domain software reset. */
|
||||
RCC_BDCR &= ~RCC_BDCR_BDRST;
|
||||
}
|
||||
|
||||
/**@}*/
|
||||
|
||||
@@ -34,13 +34,13 @@ CFLAGS = -Os -g \
|
||||
|
||||
ARFLAGS = rcs
|
||||
|
||||
OBJS = rcc.o gpio.o adc.o i2c.o spi.o usart.o dma.o
|
||||
OBJS = rcc.o gpio.o adc.o i2c.o spi.o usart.o dma.o flash.o
|
||||
|
||||
OBJS += gpio_common_all.o gpio_common_f0234.o \
|
||||
dac_common_all.o usart_common_all.o crc_common_all.o\
|
||||
iwdg_common_all.o spi_common_all.o dma_common_l1f013.o\
|
||||
timer_common_all.o timer_common_f234.o flash_common_f234.o \
|
||||
flash.o exti_common_all.o
|
||||
flash.o exti_common_all.o rcc_common_all.o
|
||||
|
||||
OBJS += usb.o usb_control.o usb_standard.o usb_f103.o
|
||||
|
||||
|
||||
@@ -321,26 +321,6 @@ void rcc_osc_bypass_disable(enum osc osc)
|
||||
}
|
||||
}
|
||||
|
||||
void rcc_peripheral_enable_clock(volatile uint32_t *reg, uint32_t en)
|
||||
{
|
||||
*reg |= en;
|
||||
}
|
||||
|
||||
void rcc_peripheral_disable_clock(volatile uint32_t *reg, uint32_t en)
|
||||
{
|
||||
*reg &= ~en;
|
||||
}
|
||||
|
||||
void rcc_peripheral_reset(volatile uint32_t *reg, uint32_t reset)
|
||||
{
|
||||
*reg |= reset;
|
||||
}
|
||||
|
||||
void rcc_peripheral_clear_reset(volatile uint32_t *reg, uint32_t clear_reset)
|
||||
{
|
||||
*reg &= ~clear_reset;
|
||||
}
|
||||
|
||||
void rcc_set_sysclk_source(uint32_t clk)
|
||||
{
|
||||
uint32_t reg32;
|
||||
|
||||
@@ -44,7 +44,8 @@ OBJS += crc_common_all.o dac_common_all.o dma_common_f24.o \
|
||||
spi_common_all.o spi_common_l1f124.o timer_common_all.o \
|
||||
timer_common_f234.o timer_common_f24.o usart_common_all.o \
|
||||
usart_common_f124.o flash_common_f234.o flash_common_f24.o \
|
||||
hash_common_f24.o crypto_common_f24.o exti_common_all.o
|
||||
hash_common_f24.o crypto_common_f24.o exti_common_all.o \
|
||||
rcc_common_all.o
|
||||
|
||||
OBJS += usb.o usb_standard.o usb_control.o usb_fx07_common.o \
|
||||
usb_f107.o usb_f207.o
|
||||
|
||||
@@ -1,3 +1,21 @@
|
||||
/** @defgroup rcc_file RCC
|
||||
*
|
||||
* @ingroup STM32F4xx
|
||||
*
|
||||
* @section rcc_f4_api_ex Reset and Clock Control API.
|
||||
*
|
||||
* @brief <b>libopencm3 STM32F4xx Reset and Clock Control</b>
|
||||
*
|
||||
* @author @htmlonly © @endhtmlonly 2013 Frantisek Burian <BuFran at seznam.cz>
|
||||
*
|
||||
* @date 18 Jun 2013
|
||||
*
|
||||
* This library supports the Reset and Clock Control System in the STM32 series
|
||||
* of ARM Cortex Microcontrollers by ST Microelectronics.
|
||||
*
|
||||
* LGPL License Terms @ref lgpl_license
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file is part of the libopencm3 project.
|
||||
*
|
||||
@@ -24,6 +42,8 @@
|
||||
#include <libopencm3/stm32/f4/pwr.h>
|
||||
#include <libopencm3/stm32/f4/flash.h>
|
||||
|
||||
/**@{*/
|
||||
|
||||
/* Set the default ppre1 and ppre2 peripheral clock frequencies after reset. */
|
||||
uint32_t rcc_ppre1_frequency = 16000000;
|
||||
uint32_t rcc_ppre2_frequency = 16000000;
|
||||
@@ -160,7 +180,7 @@ const clock_scale_t hse_16mhz_3v3[CLOCK_3V3_END] = {
|
||||
},
|
||||
};
|
||||
|
||||
void rcc_osc_ready_int_clear(osc_t osc)
|
||||
void rcc_osc_ready_int_clear(enum rcc_osc osc)
|
||||
{
|
||||
switch (osc) {
|
||||
case PLL:
|
||||
@@ -181,7 +201,7 @@ void rcc_osc_ready_int_clear(osc_t osc)
|
||||
}
|
||||
}
|
||||
|
||||
void rcc_osc_ready_int_enable(osc_t osc)
|
||||
void rcc_osc_ready_int_enable(enum rcc_osc osc)
|
||||
{
|
||||
switch (osc) {
|
||||
case PLL:
|
||||
@@ -202,7 +222,7 @@ void rcc_osc_ready_int_enable(osc_t osc)
|
||||
}
|
||||
}
|
||||
|
||||
void rcc_osc_ready_int_disable(osc_t osc)
|
||||
void rcc_osc_ready_int_disable(enum rcc_osc osc)
|
||||
{
|
||||
switch (osc) {
|
||||
case PLL:
|
||||
@@ -223,7 +243,7 @@ void rcc_osc_ready_int_disable(osc_t osc)
|
||||
}
|
||||
}
|
||||
|
||||
int rcc_osc_ready_int_flag(osc_t osc)
|
||||
int rcc_osc_ready_int_flag(enum rcc_osc osc)
|
||||
{
|
||||
switch (osc) {
|
||||
case PLL:
|
||||
@@ -256,7 +276,7 @@ int rcc_css_int_flag(void)
|
||||
return ((RCC_CIR & RCC_CIR_CSSF) != 0);
|
||||
}
|
||||
|
||||
void rcc_wait_for_osc_ready(osc_t osc)
|
||||
void rcc_wait_for_osc_ready(enum rcc_osc osc)
|
||||
{
|
||||
switch (osc) {
|
||||
case PLL:
|
||||
@@ -277,7 +297,7 @@ void rcc_wait_for_osc_ready(osc_t osc)
|
||||
}
|
||||
}
|
||||
|
||||
void rcc_wait_for_sysclk_status(osc_t osc)
|
||||
void rcc_wait_for_sysclk_status(enum rcc_osc osc)
|
||||
{
|
||||
switch (osc) {
|
||||
case PLL:
|
||||
@@ -295,7 +315,7 @@ void rcc_wait_for_sysclk_status(osc_t osc)
|
||||
}
|
||||
}
|
||||
|
||||
void rcc_osc_on(osc_t osc)
|
||||
void rcc_osc_on(enum rcc_osc osc)
|
||||
{
|
||||
switch (osc) {
|
||||
case PLL:
|
||||
@@ -316,7 +336,7 @@ void rcc_osc_on(osc_t osc)
|
||||
}
|
||||
}
|
||||
|
||||
void rcc_osc_off(osc_t osc)
|
||||
void rcc_osc_off(enum rcc_osc osc)
|
||||
{
|
||||
switch (osc) {
|
||||
case PLL:
|
||||
@@ -347,7 +367,7 @@ void rcc_css_disable(void)
|
||||
RCC_CR &= ~RCC_CR_CSSON;
|
||||
}
|
||||
|
||||
void rcc_osc_bypass_enable(osc_t osc)
|
||||
void rcc_osc_bypass_enable(enum rcc_osc osc)
|
||||
{
|
||||
switch (osc) {
|
||||
case HSE:
|
||||
@@ -364,7 +384,7 @@ void rcc_osc_bypass_enable(osc_t osc)
|
||||
}
|
||||
}
|
||||
|
||||
void rcc_osc_bypass_disable(osc_t osc)
|
||||
void rcc_osc_bypass_disable(enum rcc_osc osc)
|
||||
{
|
||||
switch (osc) {
|
||||
case HSE:
|
||||
@@ -381,25 +401,7 @@ void rcc_osc_bypass_disable(osc_t osc)
|
||||
}
|
||||
}
|
||||
|
||||
void rcc_peripheral_enable_clock(volatile uint32_t *reg, uint32_t en)
|
||||
{
|
||||
*reg |= en;
|
||||
}
|
||||
|
||||
void rcc_peripheral_disable_clock(volatile uint32_t *reg, uint32_t en)
|
||||
{
|
||||
*reg &= ~en;
|
||||
}
|
||||
|
||||
void rcc_peripheral_reset(volatile uint32_t *reg, uint32_t reset)
|
||||
{
|
||||
*reg |= reset;
|
||||
}
|
||||
|
||||
void rcc_peripheral_clear_reset(volatile uint32_t *reg, uint32_t clear_reset)
|
||||
{
|
||||
*reg &= ~clear_reset;
|
||||
}
|
||||
|
||||
void rcc_set_sysclk_source(uint32_t clk)
|
||||
{
|
||||
@@ -532,11 +534,6 @@ void rcc_clock_setup_hse_3v3(const clock_scale_t *clock)
|
||||
rcc_osc_off(HSI);
|
||||
}
|
||||
|
||||
void rcc_backupdomain_reset(void)
|
||||
{
|
||||
/* Set the backup domain software reset. */
|
||||
RCC_BDCR |= RCC_BDCR_BDRST;
|
||||
|
||||
/* Clear the backup domain software reset. */
|
||||
RCC_BDCR &= ~RCC_BDCR_BDRST;
|
||||
}
|
||||
|
||||
/**@}*/
|
||||
|
||||
@@ -41,6 +41,7 @@ OBJS += pwr_common_all.o pwr.o rtc_common_l1f024.o
|
||||
OBJS += spi_common_all.o spi_common_l1f124.o timer_common_all.o
|
||||
OBJS += usart_common_all.o usart_common_f124.o
|
||||
OBJS += exti_common_all.o
|
||||
OBJS += rcc_common_all.o
|
||||
OBJS += usb.o usb_control.o usb_standard.o usb_f103.o
|
||||
|
||||
VPATH += ../../usb:../:../../cm3:../common
|
||||
|
||||
@@ -346,26 +346,6 @@ void rcc_osc_bypass_disable(osc_t osc)
|
||||
}
|
||||
}
|
||||
|
||||
void rcc_peripheral_enable_clock(volatile uint32_t *reg, uint32_t en)
|
||||
{
|
||||
*reg |= en;
|
||||
}
|
||||
|
||||
void rcc_peripheral_disable_clock(volatile uint32_t *reg, uint32_t en)
|
||||
{
|
||||
*reg &= ~en;
|
||||
}
|
||||
|
||||
void rcc_peripheral_reset(volatile uint32_t *reg, uint32_t reset)
|
||||
{
|
||||
*reg |= reset;
|
||||
}
|
||||
|
||||
void rcc_peripheral_clear_reset(volatile uint32_t *reg, uint32_t clear_reset)
|
||||
{
|
||||
*reg &= ~clear_reset;
|
||||
}
|
||||
|
||||
void rcc_set_sysclk_source(uint32_t clk)
|
||||
{
|
||||
uint32_t reg32;
|
||||
|
||||
Reference in New Issue
Block a user