stm32l0: rcc: add peripherals clock source selection helpers.

This commit is contained in:
Guillaume Revaillot 2019-01-30 14:55:18 +01:00 committed by Karl Palsson
parent 6953138a28
commit 8668f9198b
2 changed files with 49 additions and 0 deletions

View File

@ -695,6 +695,11 @@ void rcc_clock_setup_pll(const struct rcc_clock_scale *clock);
void rcc_set_msi_range(uint32_t msi_range);
void rcc_set_lptim1_sel(uint32_t lptim1_sel);
void rcc_set_lpuart1_sel(uint32_t lpupart1_sel);
void rcc_set_usart1_sel(uint32_t usart1_sel);
void rcc_set_usart2_sel(uint32_t usart2_sel);
END_DECLS
/**@}*/

View File

@ -402,6 +402,50 @@ void rcc_set_msi_range(uint32_t msi_range)
RCC_ICSCR = reg32 | (msi_range << RCC_ICSCR_MSIRANGE_SHIFT);
}
/*---------------------------------------------------------------------------*/
/** @brief Set the LPTIM1 clock source
*
* @param lptim1_sel peripheral clock source @ref rcc_ccpipr_lptim1sel
*/
void rcc_set_lptim1_sel(uint32_t lptim1_sel)
{
RCC_CCIPR &= ~(RCC_CCIPR_LPTIM1SEL_MASK << RCC_CCIPR_LPTIM1SEL_SHIFT);
RCC_CCIPR |= (lptim1_sel << RCC_CCIPR_LPTIM1SEL_SHIFT);
}
/*---------------------------------------------------------------------------*/
/** @brief Set the LPUART1 clock source
*
* @param lpuart1_sel periphral clock source @ref rcc_ccpipr_lpuart1sel
*/
void rcc_set_lpuart1_sel(uint32_t lpuart1_sel)
{
RCC_CCIPR &= ~(RCC_CCIPR_LPUART1SEL_MASK << RCC_CCIPR_LPTIM1SEL_SHIFT);
RCC_CCIPR |= (lpuart1_sel << RCC_CCIPR_LPTIM1SEL_SHIFT);
}
/*---------------------------------------------------------------------------*/
/** @brief Set the USART1 clock source
*
* @param usart1_sel periphral clock source @ref rcc_ccpipr_usart1sel
*/
void rcc_set_usart1_sel(uint32_t usart1_sel)
{
RCC_CCIPR &= ~(RCC_CCIPR_USART1SEL_MASK << RCC_CCIPR_USART1SEL_SHIFT);
RCC_CCIPR |= (usart1_sel << RCC_CCIPR_USART1SEL_SHIFT);
}
/*---------------------------------------------------------------------------*/
/** @brief Set the USART2 clock source
*
* @param usart2_sel periphral clock source @ref rcc_ccpipr_usartxsel
*/
void rcc_set_usart2_sel(uint32_t usart2_sel)
{
RCC_CCIPR &= ~(RCC_CCIPR_USART2SEL_MASK << RCC_CCIPR_USART2SEL_SHIFT);
RCC_CCIPR |= (usart2_sel << RCC_CCIPR_USART2SEL_SHIFT);
}
/**
* Set up sysclock with PLL from HSI16
* @param clock full struct with desired parameters