MG32L003 Standard Peripherals Firmware Library
Modules | Data Structures | Macros | Functions

RCC driver modules. More...

Modules

 RCC_Exported_Constants
 
 RCC_Private_Functions
 

Data Structures

struct  RCC_ClocksTypeDef
 

Macros

#define IS_HSI_VALUE(VALUE)
 
#define IS_LSI_VALUE(VALUE)
 
#define IS_RCC_LSI_STARTUP(TIME)
 
#define IS_RCC_HSE(HSE)
 
#define IS_RCC_LSE(LSE)
 
#define IS_RCC_SYSCLK_SOURCE(SOURCE)
 
#define IS_RCC_AHBCLKDiv(DIV)   (((int32_t)(DIV) > 0) && ((DIV) <= 510))
 
#define IS_RCC_APBCLKDiv(DIV)   (((int32_t)(DIV) > 0) && ((DIV) <= 510))
 
#define IS_RCC_MCO_HCLkDiv(DIV)   (((int32_t)(DIV) > 0) && ((DIV) <= 510))
 
#define IS_RCC_MCO_SOURCE(SOURCE)
 
#define IS_RCC_AHB_PERIPH(PERIPH)   ((((PERIPH) & RCC_AHBPeriph_ALL) != 0))
 
#define IS_RCC_APB_PERIPH(PERIPH)   ((((PERIPH) & RCC_APBPeriph_ALL) != 0))
 
#define IS_RCC_RESET_FLAG(FLAG)
 
#define RCC_REGWR_LOCK()   (RCC->UNLOCK = (0x2AD5334C << RCC_UNLOCK_KEY_Pos) & RCC_UNLOCK_KEY)
 
#define RCC_REGWR_UNLOCK()   (RCC->UNLOCK = RCC_UNLOCK_UNLOCK | (0x2AD5334C << RCC_UNLOCK_KEY_Pos))
 
#define RCC_SYSTEMCR_UNLOCK_KEY   ((uint32_t)0x5A69)
 
#define RCC_SYSTEMCR_UNLOCK_Pos   ((uint32_t)16)
 
#define RCC_SET_KEYBIT(REG, BIT)   ((REG) |= (BIT | (RCC_SYSTEMCR_UNLOCK_KEY << RCC_SYSTEMCR_UNLOCK_Pos)))
 
#define RCC_MODIFY_KEYREG(REG, CLEARMASK, SETVALUE)   WRITE_REG((REG), (((READ_REG(REG)) & (~(CLEARMASK))) | (SETVALUE | (RCC_SYSTEMCR_UNLOCK_KEY << RCC_SYSTEMCR_UNLOCK_Pos))))
 
#define RCC_WRITE_KEYREG(REG, VAL)   ((REG) = (VAL | (RCC_SYSTEMCR_UNLOCK_KEY << RCC_SYSTEMCR_UNLOCK_Pos)))
 
#define RCC_CLEAR_KEYBIT(REG, CLEARMASK)   WRITE_REG((REG), (((READ_REG(REG)) & (~(CLEARMASK))) | (RCC_SYSTEMCR_UNLOCK_KEY << RCC_SYSTEMCR_UNLOCK_Pos)))
 

Functions

void RCC_DeInit (void)
 Resets the RCC clock configuration to the default reset state. More...
 
void RCC_HSIConfig (uint32_t HSI_Value, FunctionalState NewState)
 Configures the Internal High Speed oscillator (HSI). More...
 
void RCC_LSIConfig (uint32_t LSI_Value, uint32_t LSI_StartUPTime, FunctionalState NewState)
 Configures the Internal low Speed oscillator (LSI). More...
 
void RCC_HSEConfig (uint32_t RCC_HSE)
 Configures the External High Speed oscillator (HSE). More...
 
void RCC_LSEConfig (uint32_t RCC_LSE)
 Configures the External Low Speed oscillator (LSE). More...
 
void RCC_HSEDriveCurrentConfig (uint32_t Current)
 Configures the drive current of High Speed oscillator (HSE). More...
 
void RCC_HSEStartTimeConfig (uint32_t Time)
 Configures the start time of High Speed oscillator (HSE). More...
 
void RCC_LSEDriveCurrentConfig (uint32_t Current)
 Configures the drive current of Low Speed oscillator (LSE). More...
 
void RCC_LSEStartTimeConfig (uint32_t Time)
 Configures the start time of Low Speed oscillator (LSE). More...
 
void RCC_SYSCLKConfig (uint32_t RCC_SYSCLKSource)
 Configures the SYS Clock (SYSCLK). More...
 
void RCC_AHBCLKConfig (uint32_t RCC_AHBCLKDiv)
 Configures the AHB clock (AHBCLK). More...
 
void RCC_APBCLKConfig (uint32_t RCC_APBCLKDiv)
 Configures the APB clock (APBCLK). More...
 
void RCC_MCOConfig (uint32_t RCC_MCOSource, uint32_t RCC_MCOHCLKDiv)
 Selects the clock source to output on MCO pin. More...
 
void RCC_MCOCmd (FunctionalState NewState)
 Enable or Disable the MCO Clock output. More...
 
void RCC_GetClocksFreq (RCC_ClocksTypeDef *RCC_Clocks)
 Returns the frequencies of different on chip clocks. More...
 
void RCC_AHBPeriphClockCmd (uint32_t RCC_AHBPeriph, FunctionalState NewState)
 Enables or disables the AHB peripheral clock. More...
 
void RCC_APBPeriphClockCmd (uint32_t RCC_APBPeriph, FunctionalState NewState)
 Enables or disables the APB peripheral clock. More...
 
void RCC_AHBPeriphResetCmd (uint32_t RCC_AHBPeriph, FunctionalState NewState)
 Forces or releases AHB peripheral reset. More...
 
void RCC_APBPeriphResetCmd (uint32_t RCC_APBPeriph, FunctionalState NewState)
 Forces or releases APB peripheral reset. More...
 
void RCC_RTCPeriphResetCmd (FunctionalState NewState)
 Forces or releases RTC peripheral reset. More...
 
FlagStatus RCC_GetResetFlagStatus (uint32_t RCC_RSTFLAG)
 Checks whether the specified RCC reset flag is set or not. More...
 
void RCC_ClearResetFlags (uint32_t RCC_RSTFLAG)
 Clear the specified RCC reset flag. More...
 

Detailed Description

RCC driver modules.

Macro Definition Documentation

◆ IS_HSI_VALUE

#define IS_HSI_VALUE (   VALUE)
Value:
(((VALUE) == HSI_VALUE_24M) || \
((VALUE) == HSI_VALUE_22M) || \
((VALUE) == HSI_VALUE_16M) || \
((VALUE) == HSI_VALUE_8M) || \
((VALUE) == HSI_VALUE_4M))
#define HSI_VALUE_16M
Definition: mg32l003_rcc.h:48
#define HSI_VALUE_4M
Definition: mg32l003_rcc.h:50
#define HSI_VALUE_22M
Definition: mg32l003_rcc.h:47
#define HSI_VALUE_8M
Definition: mg32l003_rcc.h:49
#define HSI_VALUE_24M
Definition: mg32l003_rcc.h:46

◆ IS_LSI_VALUE

#define IS_LSI_VALUE (   VALUE)
Value:
(((VALUE) == LSI_VALUE_38K) || \
((VALUE) == LSI_VALUE_32K))
#define LSI_VALUE_32K
Definition: mg32l003_rcc.h:60
#define LSI_VALUE_38K
Definition: mg32l003_rcc.h:59

◆ IS_RCC_HSE

#define IS_RCC_HSE (   HSE)
Value:
(((HSE) == RCC_HSE_OFF) || \
((HSE) == RCC_HSE_ON) || \
((HSE) == RCC_HSE_BYPASS) || \
((HSE) == RCC_HSE_DEFAULT))
#define RCC_HSE_BYPASS
Definition: mg32l003_rcc.h:82
#define RCC_HSE_OFF
Definition: mg32l003_rcc.h:80
#define RCC_HSE_ON
Definition: mg32l003_rcc.h:81

◆ IS_RCC_LSE

#define IS_RCC_LSE (   LSE)
Value:
(((LSE) == RCC_LSE_OFF) || \
((LSE) == RCC_LSE_ON) || \
((LSE) == RCC_LSE_BYPASS) || \
((LSE) == RCC_LSE_DEFAULT))
#define RCC_LSE_OFF
Definition: mg32l003_rcc.h:92
#define RCC_LSE_ON
Definition: mg32l003_rcc.h:93
#define RCC_LSE_BYPASS
Definition: mg32l003_rcc.h:94

◆ IS_RCC_LSI_STARTUP

#define IS_RCC_LSI_STARTUP (   TIME)
Value:
(((TIME) == RCC_LSI_STARTUP_4CYCLE) || \
((TIME) == RCC_LSI_STARTUP_16CYCLE) || \
((TIME) == RCC_LSI_STARTUP_64CYCLE) || \
#define RCC_LSI_STARTUP_16CYCLE
Definition: mg32l003_rcc.h:70
#define RCC_LSI_STARTUP_4CYCLE
Definition: mg32l003_rcc.h:69
#define RCC_LSI_STARTUP_256CYCLE
Definition: mg32l003_rcc.h:72
#define RCC_LSI_STARTUP_64CYCLE
Definition: mg32l003_rcc.h:71

◆ IS_RCC_MCO_SOURCE

#define IS_RCC_MCO_SOURCE (   SOURCE)
Value:
(((SOURCE) == RCC_MCOSOURCE_HSI) || \
((SOURCE) == RCC_MCOSOURCE_HSE) || \
((SOURCE) == RCC_MCOSOURCE_LSI) || \
((SOURCE) == RCC_MCOSOURCE_LSE) || \
((SOURCE) == RCC_MCOSOURCE_SYSCLK) || \
((SOURCE) == RCC_MCOSOURCE_HCLK))

◆ IS_RCC_RESET_FLAG

#define IS_RCC_RESET_FLAG (   FLAG)
Value:
(((FLAG) == RCC_RSTFLAG_MCURST) || \
((FLAG) == RCC_RSTFLAG_CPURST) || \
((FLAG) == RCC_RSTFLAG_WWDGRST) || \
((FLAG) == RCC_RSTFLAG_IWDGRST) || \
((FLAG) == RCC_RSTFLAG_LVDRST) || \
((FLAG) == RCC_RSTFLAG_PORRST) || \
((FLAG) == RCC_RSTFLAG_LOCKUPRST) || \
((FLAG) == RCC_RSTFLAG_PADRST) || \
((FLAG) == RCC_RSTFLAG_SFTRST))

◆ IS_RCC_SYSCLK_SOURCE

#define IS_RCC_SYSCLK_SOURCE (   SOURCE)
Value:
(((SOURCE) == RCC_SYSCLKSource_HSI) || \
((SOURCE) == RCC_SYSCLKSource_HSE) || \
((SOURCE) == RCC_SYSCLKSource_LSI) || \
((SOURCE) == RCC_SYSCLKSource_LSE))

Function Documentation

◆ RCC_AHBCLKConfig()

void RCC_AHBCLKConfig ( uint32_t  RCC_AHBCLKDiv)

Configures the AHB clock (AHBCLK).

Parameters
RCC_AHBCLKDivdefines the AHB clock divider. This clock is derived from the system clock (SYSCLK). This parameter can be a value of 1-510, The allowed values are an even number from 2 to 510 and 1.
Return values
None

◆ RCC_AHBPeriphClockCmd()

void RCC_AHBPeriphClockCmd ( uint32_t  RCC_AHBPeriph,
FunctionalState  NewState 
)

Enables or disables the AHB peripheral clock.

Parameters
RCC_AHBPeriphspecifies the AHB peripheral to gates its clock. This parameter can be any combination of the following values:
  • RCC_AHBPeriph_GPIOA
  • RCC_AHBPeriph_GPIOB
  • RCC_AHBPeriph_GPIOC
  • RCC_AHBPeriph_GPIOD
  • RCC_AHBPeriph_CRC
  • RCC_AHBPeriph_FLASH
NewStatenew state of the specified peripheral clock. This parameter can be: ENABLE or DISABLE.
Return values
None

◆ RCC_AHBPeriphResetCmd()

void RCC_AHBPeriphResetCmd ( uint32_t  RCC_AHBPeriph,
FunctionalState  NewState 
)

Forces or releases AHB peripheral reset.

Parameters
RCC_AHBPeriphspecifies the AHB peripheral to reset. This parameter can be any combination of the following values:
  • RCC_AHBPeriph_GPIOA
  • RCC_AHBPeriph_GPIOB
  • RCC_AHBPeriph_GPIOC
  • RCC_AHBPeriph_GPIOD
  • RCC_AHBPeriph_CRC
NewStatenew state of the specified peripheral reset. This parameter can be: ENABLE or DISABLE.
Return values
None

◆ RCC_APBCLKConfig()

void RCC_APBCLKConfig ( uint32_t  RCC_APBCLKDiv)

Configures the APB clock (APBCLK).

Parameters
RCC_APBCLKDivdefines the APB clock divider. This clock is derived from the AHB clock (HCLK). This parameter can be a value of 1-510, The allowed values are an even number from 2 to 510 and 1.
Return values
None

◆ RCC_APBPeriphClockCmd()

void RCC_APBPeriphClockCmd ( uint32_t  RCC_APBPeriph,
FunctionalState  NewState 
)

Enables or disables the APB peripheral clock.

Parameters
RCC_APBPeriphspecifies the APB peripheral to gates its clock. This parameter can be any combination of the following values:
  • RCC_APBPeriph_UART1
  • RCC_APBPeriph_UART2
  • RCC_APBPeriph_I2C
  • RCC_APBPeriph_LPUART
  • RCC_APBPeriph_SPI
  • RCC_APBPeriph_LPTIM
  • RCC_APBPeriph_BASETIM
  • RCC_APBPeriph_SYSCON
  • RCC_APBPeriph_PCA
  • RCC_APBPeriph_OWIRE
  • RCC_APBPeriph_TIM1
  • RCC_APBPeriph_TIM2
  • RCC_APBPeriph_WWDG
  • RCC_APBPeriph_ADC
  • RCC_APBPeriph_AWK
  • RCC_APBPeriph_RTC
  • RCC_APBPeriph_CLKTRIM
  • RCC_APBPeriph_IWDG
  • RCC_APBPeriph_LVDVC
  • RCC_APBPeriph_BEEP
  • RCC_APBPeriph_DBG
NewStatenew state of the specified peripheral clock. This parameter can be: ENABLE or DISABLE.
Return values
None

◆ RCC_APBPeriphResetCmd()

void RCC_APBPeriphResetCmd ( uint32_t  RCC_APBPeriph,
FunctionalState  NewState 
)

Forces or releases APB peripheral reset.

Parameters
RCC_APBPeriphspecifies the APB peripheral to reset. This parameter can be any combination of the following values:
  • RCC_APBPeriph_UART1
  • RCC_APBPeriph_UART2
  • RCC_APBPeriph_I2C
  • RCC_APBPeriph_LPUART
  • RCC_APBPeriph_SPI
  • RCC_APBPeriph_LPTIM
  • RCC_APBPeriph_BASETIM
  • RCC_APBPeriph_SYSCON
  • RCC_APBPeriph_PCA
  • RCC_APBPeriph_OWIRE
  • RCC_APBPeriph_TIM1
  • RCC_APBPeriph_TIM2
  • RCC_APBPeriph_WWDG
  • RCC_APBPeriph_ADC
  • RCC_APBPeriph_AWK
  • RCC_APBPeriph_CLKTRIM
  • RCC_APBPeriph_LVDVC
  • RCC_APBPeriph_BEEP
  • RCC_APBPeriph_DBG
NewStatenew state of the specified peripheral reset. This parameter can be: ENABLE or DISABLE.
Return values
None

◆ RCC_ClearResetFlags()

void RCC_ClearResetFlags ( uint32_t  RCC_RSTFLAG)

Clear the specified RCC reset flag.

Parameters
RCC_RSTFLAGspecifies the flag to check. This parameter can be one of the following values:
  • RCC_RSTFLAG_MCURST: MCU reset-option byte reload.
  • RCC_RSTFLAG_CPURST: CPU reset-no option byte reload.
  • RCC_RSTFLAG_WWDGRST: Window Watchdog reset.
  • RCC_RSTFLAG_IWDGRST: Independent Watchdog reset.
  • RCC_RSTFLAG_LVDRST: Low Voltage Detect reset.
  • RCC_RSTFLAG_PORRST: PowerON reset.
  • RCC_RSTFLAG_LOCKUPRST: CPU Lockup reset.
  • RCC_RSTFLAG_PADRST: Pad reset.
  • RCC_RSTFLAG_SFTRST: Software reset.
Return values
None.

◆ RCC_DeInit()

void RCC_DeInit ( void  )

Resets the RCC clock configuration to the default reset state.

Note
The default reset state of the clock configuration is given below:
  • HSI ON and used as system clock source
  • HSE are OFF
  • AHB, APB prescaler set to 1.
  • MCO OFF
This function does not modify the configuration of the
  • Peripheral clocks
  • LSI, LSE clocks
Return values
None

◆ RCC_GetClocksFreq()

void RCC_GetClocksFreq ( RCC_ClocksTypeDef RCC_Clocks)

Returns the frequencies of different on chip clocks.

Parameters
RCC_Clockspointer to a RCC_ClocksTypeDef structure which will hold the clocks frequencies.
Return values
None

◆ RCC_GetResetFlagStatus()

FlagStatus RCC_GetResetFlagStatus ( uint32_t  RCC_RSTFLAG)

Checks whether the specified RCC reset flag is set or not.

Parameters
RCC_RSTFLAGspecifies the flag to check. This parameter can be one of the following values:
  • RCC_RSTFLAG_MCURST: MCU reset-option byte reload.
  • RCC_RSTFLAG_CPURST: CPU reset-no option byte reload.
  • RCC_RSTFLAG_WWDGRST: Window Watchdog reset.
  • RCC_RSTFLAG_IWDGRST: Independent Watchdog reset.
  • RCC_RSTFLAG_LVDRST: Low Voltage Detect reset.
  • RCC_RSTFLAG_PORRST: PowerON reset.
  • RCC_RSTFLAG_LOCKUPRST: CPU Lockup reset.
  • RCC_RSTFLAG_PADRST: Pad reset.
  • RCC_RSTFLAG_SFTRST: Software reset.
Return values
Thenew state of RCC_RSTFLAG (SET or RESET).

◆ RCC_HSEConfig()

void RCC_HSEConfig ( uint32_t  RCC_HSE)

Configures the External High Speed oscillator (HSE).

Parameters
RCC_HSESpecifies the new state of the HSE. This parameter can be one of the following values:
Note
The SYSTEM register write-protection function should be disabled before using this function.
Return values
None

◆ RCC_HSEDriveCurrentConfig()

void RCC_HSEDriveCurrentConfig ( uint32_t  Current)

Configures the drive current of High Speed oscillator (HSE).

Parameters
Currentspecifies the drive current.
Note
The SYSTEM register write-protection function should be disabled before using this function. This parameter can be a value of 0-7.
Return values
None

◆ RCC_HSEStartTimeConfig()

void RCC_HSEStartTimeConfig ( uint32_t  Time)

Configures the start time of High Speed oscillator (HSE).

Parameters
Timespecifies the start time.
Note
The SYSTEM register write-protection function should be disabled before using this function. This parameter can be a value of 0-3.
Return values
None

◆ RCC_HSIConfig()

void RCC_HSIConfig ( const uint32_t  HSI_Value,
FunctionalState  NewState 
)

Configures the Internal High Speed oscillator (HSI).

Parameters
HSI_ValueThe HSI frequency value. This parameter can be one of the following values:
NewStatenew state of the HSI. This parameter can be: ENABLE or DISABLE.
Note
The SYSTEM register write-protection function should be disabled before using this function.
Return values
None

◆ RCC_LSEConfig()

void RCC_LSEConfig ( uint32_t  RCC_LSE)

Configures the External Low Speed oscillator (LSE).

Parameters
RCC_LSESpecifies the new state of the LSE. This parameter can be one of the following values:
Note
The SYSTEM register write-protection function should be disabled before using this function.
Return values
None

◆ RCC_LSEDriveCurrentConfig()

void RCC_LSEDriveCurrentConfig ( uint32_t  Current)

Configures the drive current of Low Speed oscillator (LSE).

Parameters
Currentspecifies the drive current.
Note
The SYSTEM register write-protection function should be disabled before using this function. This parameter can be a value of 0-15.
Return values
None

◆ RCC_LSEStartTimeConfig()

void RCC_LSEStartTimeConfig ( uint32_t  Time)

Configures the start time of Low Speed oscillator (LSE).

Parameters
Timespecifies the start time.
Note
The SYSTEM register write-protection function should be disabled before using this function. This parameter can be a value of 0-3.
Return values
None

◆ RCC_LSIConfig()

void RCC_LSIConfig ( uint32_t  LSI_Value,
uint32_t  LSI_StartUPTime,
FunctionalState  NewState 
)

Configures the Internal low Speed oscillator (LSI).

Parameters
LSI_ValueThe LSI frequency value. This parameter can be one of the following values:
LSI_StartUPTimeThe LSI startup time. This parameter can be one of the following values:
NewStatenew state of the LSI. This parameter can be: ENABLE or DISABLE.
Note
The SYSTEM register write-protection function should be disabled before using this function.
Return values
None

◆ RCC_MCOCmd()

void RCC_MCOCmd ( FunctionalState  NewState)

Enable or Disable the MCO Clock output.

Parameters
NewStatenew state of the MCO. This parameter can be: ENABLE or DISABLE.
Return values
None

◆ RCC_MCOConfig()

void RCC_MCOConfig ( uint32_t  RCC_MCOSource,
uint32_t  RCC_MCOHCLKDiv 
)

Selects the clock source to output on MCO pin.

Parameters
RCC_MCOSourcespecifies the clock source to output. This parameter can be one of the following values:
  • RCC_MCOSOURCE_HSI: HSI selected as MCO clock
  • RCC_MCOSOURCE_HSE: HSE selected as MCO clock
  • RCC_MCOSOURCE_LSI: LSI selected as MCO clock
  • RCC_MCOSOURCE_LSE: LSE selected as MCO clock
  • RCC_MCOSOURCE_SYSCLK: SYSCLK selected as MCO clock
  • RCC_MCOSOURCE_HCLK: HCLK selected as MCO clock
RCC_MCOHCLKDivspecifies the MCO DIV. This parameter can be a value of 1-510, The allowed values are an even number from 2 to 510 and 1.
Note
MCO pin should be configured in alternate function mode.
Return values
None

◆ RCC_RTCPeriphResetCmd()

void RCC_RTCPeriphResetCmd ( FunctionalState  NewState)

Forces or releases RTC peripheral reset.

Parameters
NewStatenew state of the RTC peripheral reset. This parameter can be: ENABLE or DISABLE.
Return values
None

◆ RCC_SYSCLKConfig()

void RCC_SYSCLKConfig ( uint32_t  RCC_SYSCLKSource)

Configures the SYS Clock (SYSCLK).

Parameters
RCC_SYSCLKSourcespecifies the clock source used as system clock. This parameter can be one of the following values:
  • RCC_SYSCLKSource_HSI: HSI selected as system clock.
  • RCC_SYSCLKSource_HSE: HSE selected as system clock.
  • RCC_SYSCLKSource_LSI: LSI selected as system clock.
  • RCC_SYSCLKSource_LSE: LSE selected as system clock.
Return values
None