stm32: common: Extract MCO source setting
This adds MCO source selection to some targets, and removes and standardizes the mask/shift usage for all targets. For devices that support MCO2, this supports only MCO1. No attempt has been made to extract MCO prescaler, which is not available on all F1 and F3.
This commit is contained in:
@@ -182,6 +182,21 @@ void rcc_periph_reset_release(enum rcc_periph_rst rst)
|
||||
{
|
||||
_RCC_REG(rst) &= ~_RCC_BIT(rst);
|
||||
}
|
||||
|
||||
/** @brief Select the source of Microcontroller Clock Output
|
||||
*
|
||||
* Exact sources available depend on your target. On devices with multiple
|
||||
* MCO pins, this function controls MCO1
|
||||
*
|
||||
* @parame[in] mcosrc the unshifted source bits
|
||||
*/
|
||||
|
||||
void rcc_set_mco(uint32_t mcosrc)
|
||||
{
|
||||
RCC_CFGR = (RCC_CFGR & ~(RCC_CFGR_MCO_MASK << RCC_CFGR_MCO_SHIFT)) |
|
||||
(mcosrc << RCC_CFGR_MCO_SHIFT);
|
||||
}
|
||||
|
||||
/**@}*/
|
||||
|
||||
#undef _RCC_REG
|
||||
|
||||
@@ -488,11 +488,6 @@ void rcc_set_prediv(uint32_t prediv)
|
||||
}
|
||||
|
||||
|
||||
void rcc_set_mco(uint32_t mcosrc)
|
||||
{
|
||||
RCC_CFGR = (RCC_CFGR & ~RCC_CFGR_MCO) | mcosrc;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @brief RCC Get the System Clock Source.
|
||||
*
|
||||
|
||||
@@ -594,13 +594,6 @@ void rcc_set_prediv1_source(uint32_t rccsrc)
|
||||
RCC_CFGR2 &= ~RCC_CFGR2_PREDIV1SRC;
|
||||
}
|
||||
|
||||
void rcc_set_mco(uint32_t mcosrc)
|
||||
{
|
||||
RCC_CFGR = (RCC_CFGR & ~RCC_CFGR_MCO) |
|
||||
(mcosrc << RCC_CFGR_MCO_SHIFT);
|
||||
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @brief RCC Get the System Clock Source.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user