KugleFirmware/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_rcc.c
/**
  * @brief  Configures the RCC_OscInitStruct according to the internal
  * RCC configuration registers.
  * @param  RCC_OscInitStruct: pointer to an RCC_OscInitTypeDef structure that
  * will be configured.
  * @retval None
  */
@brief  Configures the RCC_OscInitStruct according to the internal
RCC configuration registers.
@param  RCC_OscInitStruct: pointer to an RCC_OscInitTypeDef structure that
will be configured.
@retval None
@brief Configures the RCC_OscInitStruct according to the internal RCC configuration registers . @param RCC_OscInitStruct : pointer to an RCC_OscInitTypeDef structure that will be configured . @retval None
void HAL_RCC_GetOscConfig(RCC_OscInitTypeDef  *RCC_OscInitStruct)
{
  RCC_OscInitStruct->OscillatorType = RCC_OSCILLATORTYPE_HSE | RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_CSI | \
                                      RCC_OSCILLATORTYPE_LSE | RCC_OSCILLATORTYPE_LSI| RCC_OSCILLATORTYPE_HSI48;
  if((RCC->CR &RCC_CR_HSEBYP) == RCC_CR_HSEBYP)
  {
    RCC_OscInitStruct->HSEState = RCC_HSE_BYPASS;
  }
  else if((RCC->CR &RCC_CR_HSEON) == RCC_CR_HSEON)
  {
    RCC_OscInitStruct->HSEState = RCC_HSE_ON;
  }
  else
  {
    RCC_OscInitStruct->HSEState = RCC_HSE_OFF;
  }
  if((RCC->CR &RCC_CR_CSION) == RCC_CR_CSION)
  {
    RCC_OscInitStruct->CSIState = RCC_CSI_ON;
  }
  else
  {
    RCC_OscInitStruct->CSIState = RCC_CSI_OFF;
  }
  RCC_OscInitStruct->CSICalibrationValue = (uint32_t)((RCC->ICSCR &RCC_ICSCR_CSITRIM) >> POSITION_VAL(RCC_ICSCR_CSITRIM));
  if((RCC->CR &RCC_CR_HSION) == RCC_CR_HSION)
  {
    RCC_OscInitStruct->HSIState = RCC_HSI_ON;
  }
  else
  {
    RCC_OscInitStruct->HSIState = RCC_HSI_OFF;
  }
  RCC_OscInitStruct->HSICalibrationValue = (uint32_t)((RCC->ICSCR &RCC_ICSCR_HSITRIM) >> POSITION_VAL(RCC_ICSCR_HSITRIM));
  if((RCC->BDCR &RCC_BDCR_LSEBYP) == RCC_BDCR_LSEBYP)
  {
    RCC_OscInitStruct->LSEState = RCC_LSE_BYPASS;
  }
  else if((RCC->BDCR &RCC_BDCR_LSEON) == RCC_BDCR_LSEON)
  {
    RCC_OscInitStruct->LSEState = RCC_LSE_ON;
  }
  else
  {
    RCC_OscInitStruct->LSEState = RCC_LSE_OFF;
  }
  if((RCC->CSR &RCC_CSR_LSION) == RCC_CSR_LSION)
  {
    RCC_OscInitStruct->LSIState = RCC_LSI_ON;
  }
  else
  {
    RCC_OscInitStruct->LSIState = RCC_LSI_OFF;
  }
  if((RCC->CR & RCC_CR_HSI48ON) == RCC_CR_HSI48ON)
  {
    RCC_OscInitStruct->HSI48State = RCC_HSI48_ON;
  }
  else
  {
    RCC_OscInitStruct->HSI48State = RCC_HSI48_OFF;
  }
  if((RCC->CR &RCC_CR_PLLON) == RCC_CR_PLLON)
  {
    RCC_OscInitStruct->PLL.PLLState = RCC_PLL_ON;
  }
  else
  {
    RCC_OscInitStruct->PLL.PLLState = RCC_PLL_OFF;
  }
  RCC_OscInitStruct->PLL.PLLSource = (uint32_t)(RCC->PLLCKSELR & RCC_PLLCKSELR_PLLSRC);
  RCC_OscInitStruct->PLL.PLLM = (uint32_t)((RCC->PLLCKSELR & RCC_PLLCKSELR_DIVM1)>> POSITION_VAL(RCC_PLLCKSELR_DIVM1));
  RCC_OscInitStruct->PLL.PLLN = (uint32_t)((RCC->PLL1DIVR & RCC_PLL1DIVR_N1) >> POSITION_VAL(RCC_PLL1DIVR_N1))+ 1;
  RCC_OscInitStruct->PLL.PLLR = (uint32_t)((RCC->PLL1DIVR & RCC_PLL1DIVR_R1) >> POSITION_VAL(RCC_PLL1DIVR_R1))+ 1;
  RCC_OscInitStruct->PLL.PLLP = (uint32_t)((RCC->PLL1DIVR & RCC_PLL1DIVR_P1) >> POSITION_VAL(RCC_PLL1DIVR_P1))+ 1;
  RCC_OscInitStruct->PLL.PLLQ = (uint32_t)((RCC->PLL1DIVR & RCC_PLL1DIVR_Q1) >> POSITION_VAL(RCC_PLL1DIVR_Q1))+ 1;
  RCC_OscInitStruct->PLL.PLLRGE = (uint32_t)((RCC->PLLCFGR & RCC_PLLCFGR_PLL1RGE) >> POSITION_VAL(RCC_PLLCFGR_PLL1RGE_1));
  RCC_OscInitStruct->PLL.PLLVCOSEL = (uint32_t)((RCC->PLLCFGR & RCC_PLLCFGR_PLL1VCOSEL) >> POSITION_VAL(RCC_PLLCFGR_PLL1VCOSEL));
}
void HAL_RCC_GetOscConfig ( RCC_OscInitTypeDef * RCC_OscInitStruct ) { RCC_OscInitStruct -> OscillatorType = RCC_OSCILLATORTYPE_HSE | RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_CSI | RCC_OSCILLATORTYPE_LSE | RCC_OSCILLATORTYPE_LSI | RCC_OSCILLATORTYPE_HSI48 ; if ( ( RCC -> CR & RCC_CR_HSEBYP ) == RCC_CR_HSEBYP ) { RCC_OscInitStruct -> HSEState = RCC_HSE_BYPASS ; } else if ( ( RCC -> CR & RCC_CR_HSEON ) == RCC_CR_HSEON ) { RCC_OscInitStruct -> HSEState = RCC_HSE_ON ; } else { RCC_OscInitStruct -> HSEState = RCC_HSE_OFF ; } if ( ( RCC -> CR & RCC_CR_CSION ) == RCC_CR_CSION ) { RCC_OscInitStruct -> CSIState = RCC_CSI_ON ; } else { RCC_OscInitStruct -> CSIState = RCC_CSI_OFF ; } RCC_OscInitStruct -> CSICalibrationValue = ( uint32_t ) ( ( RCC -> ICSCR & RCC_ICSCR_CSITRIM ) >> POSITION_VAL ( RCC_ICSCR_CSITRIM ) ) ; if ( ( RCC -> CR & RCC_CR_HSION ) == RCC_CR_HSION ) { RCC_OscInitStruct -> HSIState = RCC_HSI_ON ; } else { RCC_OscInitStruct -> HSIState = RCC_HSI_OFF ; } RCC_OscInitStruct -> HSICalibrationValue = ( uint32_t ) ( ( RCC -> ICSCR & RCC_ICSCR_HSITRIM ) >> POSITION_VAL ( RCC_ICSCR_HSITRIM ) ) ; if ( ( RCC -> BDCR & RCC_BDCR_LSEBYP ) == RCC_BDCR_LSEBYP ) { RCC_OscInitStruct -> LSEState = RCC_LSE_BYPASS ; } else if ( ( RCC -> BDCR & RCC_BDCR_LSEON ) == RCC_BDCR_LSEON ) { RCC_OscInitStruct -> LSEState = RCC_LSE_ON ; } else { RCC_OscInitStruct -> LSEState = RCC_LSE_OFF ; } if ( ( RCC -> CSR & RCC_CSR_LSION ) == RCC_CSR_LSION ) { RCC_OscInitStruct -> LSIState = RCC_LSI_ON ; } else { RCC_OscInitStruct -> LSIState = RCC_LSI_OFF ; } if ( ( RCC -> CR & RCC_CR_HSI48ON ) == RCC_CR_HSI48ON ) { RCC_OscInitStruct -> HSI48State = RCC_HSI48_ON ; } else { RCC_OscInitStruct -> HSI48State = RCC_HSI48_OFF ; } if ( ( RCC -> CR & RCC_CR_PLLON ) == RCC_CR_PLLON ) { RCC_OscInitStruct -> PLL . PLLState = RCC_PLL_ON ; } else { RCC_OscInitStruct -> PLL . PLLState = RCC_PLL_OFF ; } RCC_OscInitStruct -> PLL . PLLSource = ( uint32_t ) ( RCC -> PLLCKSELR & RCC_PLLCKSELR_PLLSRC ) ; RCC_OscInitStruct -> PLL . PLLM = ( uint32_t ) ( ( RCC -> PLLCKSELR & RCC_PLLCKSELR_DIVM1 ) >> POSITION_VAL ( RCC_PLLCKSELR_DIVM1 ) ) ; RCC_OscInitStruct -> PLL . PLLN = ( uint32_t ) ( ( RCC -> PLL1DIVR & RCC_PLL1DIVR_N1 ) >> POSITION_VAL ( RCC_PLL1DIVR_N1 ) ) + 1 ; RCC_OscInitStruct -> PLL . PLLR = ( uint32_t ) ( ( RCC -> PLL1DIVR & RCC_PLL1DIVR_R1 ) >> POSITION_VAL ( RCC_PLL1DIVR_R1 ) ) + 1 ; RCC_OscInitStruct -> PLL . PLLP = ( uint32_t ) ( ( RCC -> PLL1DIVR & RCC_PLL1DIVR_P1 ) >> POSITION_VAL ( RCC_PLL1DIVR_P1 ) ) + 1 ; RCC_OscInitStruct -> PLL . PLLQ = ( uint32_t ) ( ( RCC -> PLL1DIVR & RCC_PLL1DIVR_Q1 ) >> POSITION_VAL ( RCC_PLL1DIVR_Q1 ) ) + 1 ; RCC_OscInitStruct -> PLL . PLLRGE = ( uint32_t ) ( ( RCC -> PLLCFGR & RCC_PLLCFGR_PLL1RGE ) >> POSITION_VAL ( RCC_PLLCFGR_PLL1RGE_1 ) ) ; RCC_OscInitStruct -> PLL . PLLVCOSEL = ( uint32_t ) ( ( RCC -> PLLCFGR & RCC_PLLCFGR_PLL1VCOSEL ) >> POSITION_VAL ( RCC_PLLCFGR_PLL1VCOSEL ) ) ; }
@brief  Configures the RCC_OscInitStruct according to the internal
 RCC configuration registers.
@brief Configures the RCC_OscInitStruct according to the internal RCC configuration registers .
/* Set all possible values for the Oscillator type parameter ---------------*/ /* Get the HSE configuration -----------------------------------------------*/ /* Get the CSI configuration -----------------------------------------------*/ /* Get the HSI configuration -----------------------------------------------*/ /* Get the LSE configuration -----------------------------------------------*/ /* Get the LSI configuration -----------------------------------------------*/ /* Get the HSI48 configuration ---------------------------------------------*/ /* Get the PLL configuration -----------------------------------------------*/