KugleFirmware/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_rcc.c
/**
  * @brief  Selects the clock source to output on MCO1 pin(PA8) or on MCO2 pin(PC9).
  * @note   PA8/PC9 should be configured in alternate function mode.
  * @param  RCC_MCOx: specifies the output direction for the clock source.
  *          This parameter can be one of the following values:
  *            @arg RCC_MCO1: Clock source to output on MCO1 pin(PA8).
  *            @arg RCC_MCO2: Clock source to output on MCO2 pin(PC9).
  * @param  RCC_MCOSource: specifies the clock source to output.
  *          This parameter can be one of the following values:
  *            @arg RCC_MCO1SOURCE_HSI: HSI clock selected as MCO1 source
  *            @arg RCC_MCO1SOURCE_LSE: LSE clock selected as MCO1 source
  *            @arg RCC_MCO1SOURCE_HSE: HSE clock selected as MCO1 source
  *            @arg RCC_MCO1SOURCE_PLL1QCLK:  PLL1Q clock selected as MCO1 source
  *            @arg RCC_MCO1SOURCE_HSI48: HSI48 (48MHZ) selected as MCO1 source
  *            @arg RCC_MCO2SOURCE_SYSCLK: System clock (SYSCLK) selected as MCO2 source
  *            @arg RCC_MCO2SOURCE_PLL2PCLK: PLL2P clock selected as MCO2 source
  *            @arg RCC_MCO2SOURCE_HSE: HSE clock selected as MCO2 source
  *            @arg RCC_MCO2SOURCE_PLLCLK:  PLL1P clock selected as MCO2 source
  *            @arg RCC_MCO2SOURCE_CSICLK:  CSI clock selected as MCO2 source
  *            @arg RCC_MCO2SOURCE_LSICLK:  LSI clock selected as MCO2 source
  * @param  RCC_MCODiv: specifies the MCOx pre-scaler.
  *          This parameter can be one of the following values:
  *            @arg RCC_MCODIV_1 up to RCC_MCODIV_15  : divider applied to MCOx clock
  * @retval None
  */
@brief  Selects the clock source to output on MCO1 pin(PA8) or on MCO2 pin(PC9).
@note   PA8/PC9 should be configured in alternate function mode.
@param  RCC_MCOx: specifies the output direction for the clock source.
This parameter can be one of the following values:
@arg RCC_MCO1: Clock source to output on MCO1 pin(PA8).
@arg RCC_MCO2: Clock source to output on MCO2 pin(PC9).
@param  RCC_MCOSource: specifies the clock source to output.
@brief Selects the clock source to output on MCO1 pin ( PA8 ) or on MCO2 pin ( PC9 ) . @note PA8 / PC9 should be configured in alternate function mode . @param RCC_MCOx : specifies the output direction for the clock source . This parameter can be one of the following values : @arg RCC_MCO1 : Clock source to output on MCO1 pin ( PA8 ) . @arg RCC_MCO2 : Clock source to output on MCO2 pin ( PC9 ) . @param RCC_MCOSource : specifies the clock source to output .
void HAL_RCC_MCOConfig(uint32_t RCC_MCOx, uint32_t RCC_MCOSource, uint32_t RCC_MCODiv)
{
  GPIO_InitTypeDef GPIO_InitStruct;
  assert_param(IS_RCC_MCO(RCC_MCOx));
  assert_param(IS_RCC_MCODIV(RCC_MCODiv));
  if(RCC_MCOx == RCC_MCO1)
  {
    assert_param(IS_RCC_MCO1SOURCE(RCC_MCOSource));
    __MCO1_CLK_ENABLE();
    GPIO_InitStruct.Pin = MCO1_PIN;
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    GPIO_InitStruct.Alternate = GPIO_AF0_MCO;
    HAL_GPIO_Init(MCO1_GPIO_PORT, &GPIO_InitStruct);
    MODIFY_REG(RCC->CFGR, (RCC_CFGR_MCO1 | RCC_CFGR_MCO1PRE), (RCC_MCOSource | RCC_MCODiv));
  }
  else
  {
    assert_param(IS_RCC_MCO2SOURCE(RCC_MCOSource));
    __MCO2_CLK_ENABLE();
    GPIO_InitStruct.Pin = MCO2_PIN;
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    GPIO_InitStruct.Alternate = GPIO_AF0_MCO;
    HAL_GPIO_Init(MCO2_GPIO_PORT, &GPIO_InitStruct);
    MODIFY_REG(RCC->CFGR, (RCC_CFGR_MCO2 | RCC_CFGR_MCO2PRE), (RCC_MCOSource | (RCC_MCODiv << 7)));
  }
}
void HAL_RCC_MCOConfig ( uint32_t RCC_MCOx , uint32_t RCC_MCOSource , uint32_t RCC_MCODiv ) { GPIO_InitTypeDef GPIO_InitStruct ; assert_param ( IS_RCC_MCO ( RCC_MCOx ) ) ; assert_param ( IS_RCC_MCODIV ( RCC_MCODiv ) ) ; if ( RCC_MCOx == RCC_MCO1 ) { assert_param ( IS_RCC_MCO1SOURCE ( RCC_MCOSource ) ) ; __MCO1_CLK_ENABLE ( ) ; GPIO_InitStruct . Pin = MCO1_PIN ; GPIO_InitStruct . Mode = GPIO_MODE_AF_PP ; GPIO_InitStruct . Speed = GPIO_SPEED_FREQ_VERY_HIGH ; GPIO_InitStruct . Pull = GPIO_NOPULL ; GPIO_InitStruct . Alternate = GPIO_AF0_MCO ; HAL_GPIO_Init ( MCO1_GPIO_PORT , & GPIO_InitStruct ) ; MODIFY_REG ( RCC -> CFGR , ( RCC_CFGR_MCO1 | RCC_CFGR_MCO1PRE ) , ( RCC_MCOSource | RCC_MCODiv ) ) ; } else { assert_param ( IS_RCC_MCO2SOURCE ( RCC_MCOSource ) ) ; __MCO2_CLK_ENABLE ( ) ; GPIO_InitStruct . Pin = MCO2_PIN ; GPIO_InitStruct . Mode = GPIO_MODE_AF_PP ; GPIO_InitStruct . Speed = GPIO_SPEED_FREQ_VERY_HIGH ; GPIO_InitStruct . Pull = GPIO_NOPULL ; GPIO_InitStruct . Alternate = GPIO_AF0_MCO ; HAL_GPIO_Init ( MCO2_GPIO_PORT , & GPIO_InitStruct ) ; MODIFY_REG ( RCC -> CFGR , ( RCC_CFGR_MCO2 | RCC_CFGR_MCO2PRE ) , ( RCC_MCOSource | ( RCC_MCODiv << 7 ) ) ) ; } }
@brief  Selects the clock source to output on MCO1 pin(PA8) or on MCO2 pin(PC9).
@brief Selects the clock source to output on MCO1 pin ( PA8 ) or on MCO2 pin ( PC9 ) .
/* Check the parameters */ /* RCC_MCO1 */ /* MCO1 Clock Enable */ /* Configure the MCO1 pin in alternate function mode */ /* Mask MCO1 and MCO1PRE[3:0] bits then Select MCO1 clock source and pre-scaler */ /* MCO2 Clock Enable */ /* Configure the MCO2 pin in alternate function mode */ /* Mask MCO2 and MCO2PRE[3:0] bits then Select MCO2 clock source and pre-scaler */