STM8S/A Standard Peripherals Firmware Library: CLK_Public_Functions

STM8S/A

STM8S/A Standard Peripherals Firmware Library
CLK_Public_Functions

Functions

void CLK_AdjustHSICalibrationValue (CLK_HSITrimValue_TypeDef CLK_HSICalibrationValue)
 Adjusts the Internal High Speed oscillator (HSI) calibration value.
void CLK_CCOCmd (FunctionalState NewState)
 Enables or disablle the Configurable Clock Output (CCO).
void CLK_CCOConfig (CLK_Output_TypeDef CLK_CCO)
 Output the selected clock on a dedicated I/O pin.
void CLK_ClearITPendingBit (CLK_IT_TypeDef CLK_IT)
 Clears the CLK�s interrupt pending bits.
void CLK_ClockSecuritySystemEnable (void)
 Enables the Clock Security System.
void CLK_ClockSwitchCmd (FunctionalState NewState)
 Starts or Stops manually the clock switch execution.
ErrorStatus CLK_ClockSwitchConfig (CLK_SwitchMode_TypeDef CLK_SwitchMode, CLK_Source_TypeDef CLK_NewClock, FunctionalState ITState, CLK_CurrentClockState_TypeDef CLK_CurrentClockState)
 configures the Switch from one clock to another
void CLK_DeInit (void)
 Deinitializes the CLK peripheral registers to their default reset values.
void CLK_FastHaltWakeUpCmd (FunctionalState NewState)
 Configures the High Speed Internal oscillator (HSI).
uint32_t CLK_GetClockFreq (void)
 This function returns the frequencies of different on chip clocks.
FlagStatus CLK_GetFlagStatus (CLK_Flag_TypeDef CLK_FLAG)
 Checks whether the specified CLK flag is set or not.
ITStatus CLK_GetITStatus (CLK_IT_TypeDef CLK_IT)
 Checks whether the specified CLK interrupt has is enabled or not.
CLK_Source_TypeDef CLK_GetSYSCLKSource (void)
 Returns the clock source used as system clock.
void CLK_HSECmd (FunctionalState NewState)
 Enable or Disable the External High Speed oscillator (HSE).
void CLK_HSICmd (FunctionalState NewState)
 Enables or disables the Internal High Speed oscillator (HSI).
void CLK_HSIPrescalerConfig (CLK_Prescaler_TypeDef HSIPrescaler)
 Configures the HSI clock dividers.
void CLK_ITConfig (CLK_IT_TypeDef CLK_IT, FunctionalState NewState)
 Enables or disables the specified CLK interrupts.
void CLK_LSICmd (FunctionalState NewState)
 Enables or disables the Internal Low Speed oscillator (LSI).
void CLK_PeripheralClockConfig (CLK_Peripheral_TypeDef CLK_Peripheral, FunctionalState NewState)
 Enables or disables the specified peripheral CLK.
void CLK_SlowActiveHaltWakeUpCmd (FunctionalState NewState)
 Configures the slow active halt wake up.
void CLK_SWIMConfig (CLK_SWIMDivider_TypeDef CLK_SWIMDivider)
 Configures the SWIM clock frequency on the fly.
void CLK_SYSCLKConfig (CLK_Prescaler_TypeDef CLK_Prescaler)
 Configures the HSI and CPU clock dividers.
void CLK_SYSCLKEmergencyClear (void)
 Reset the SWBSY flag (SWICR Reister)

Function Documentation

void CLK_AdjustHSICalibrationValue ( CLK_HSITrimValue_TypeDef  CLK_HSICalibrationValue)

Adjusts the Internal High Speed oscillator (HSI) calibration value.

Full description:
Parameters:
CLK_HSICalibrationValuecalibration trimming value. can be one of the values of CLK_HSITrimValue_TypeDef
Return values:
None

Definition at line 604 of file stm8s_clk.c.

References assert_param, CLK, CLK_HSITRIMR_HSITRIM, and IS_CLK_HSITRIMVALUE_OK.

void CLK_CCOCmd ( FunctionalState  NewState)

Enables or disablle the Configurable Clock Output (CCO).

Parameters:
NewState: New state of CCEN bit (CCO register). This parameter can be any of the FunctionalState enumeration.
Return values:
None

Definition at line 189 of file stm8s_clk.c.

References assert_param, CLK, CLK_CCOR_CCOEN, DISABLE, and IS_FUNCTIONALSTATE_OK.

Referenced by main().

void CLK_CCOConfig ( CLK_Output_TypeDef  CLK_CCO)

Output the selected clock on a dedicated I/O pin.

Parameters:
CLK_CCO: Specifies the clock source. This parameter can be any of the CLK_Output_TypeDef enumeration.
Return values:
None
Required preconditions:
The dedicated I/O pin must be set at 1 in the corresponding Px_CR1 register
to be set as input with pull-up or push-pull output.

Definition at line 436 of file stm8s_clk.c.

References assert_param, CLK, CLK_CCOR_CCOEN, CLK_CCOR_CCOSEL, and IS_CLK_OUTPUT_OK.

Referenced by main().

void CLK_ClearITPendingBit ( CLK_IT_TypeDef  CLK_IT)

Clears the CLK�s interrupt pending bits.

Parameters:
CLK_ITspecifies the interrupt pending bits. can be one of the values of CLK_IT_TypeDef
Return values:
None

Definition at line 729 of file stm8s_clk.c.

References assert_param, CLK, CLK_CSSR_CSSD, CLK_IT_CSSD, CLK_SWCR_SWIF, and IS_CLK_IT_OK.

void CLK_ClockSecuritySystemEnable ( void  )

Enables the Clock Security System.

Full description:
once CSS is enabled it cannot be disabled until the next reset.
Parameters:
None
Return values:
None

Definition at line 547 of file stm8s_clk.c.

References CLK, and CLK_CSSR_CSSEN.

void CLK_ClockSwitchCmd ( FunctionalState  NewState)

Starts or Stops manually the clock switch execution.

Full description:
NewState parameter set the SWEN.
Parameters:
NewStatenew state of SWEN, value accepted ENABLE, DISABLE.
Return values:
None

Definition at line 213 of file stm8s_clk.c.

References assert_param, CLK, CLK_SWCR_SWEN, DISABLE, and IS_FUNCTIONALSTATE_OK.

ErrorStatus CLK_ClockSwitchConfig ( CLK_SwitchMode_TypeDef  CLK_SwitchMode,
CLK_Source_TypeDef  CLK_NewClock,
FunctionalState  ITState,
CLK_CurrentClockState_TypeDef  CLK_CurrentClockState 
)

configures the Switch from one clock to another

Parameters:
CLK_SwitchModeselect the clock switch mode. It can be set of the values of CLK_SwitchMode_TypeDef
CLK_NewClockchoice of the future clock. It can be set of the values of CLK_Source_TypeDef
NewStateEnable or Disable the Clock Switch interrupt.
CLK_CurrentClockStatecurrent clock to switch OFF or to keep ON. It can be set of the values of CLK_CurrentClockState_TypeDef
Note:
LSI selected as master clock source only if LSI_EN option bit is set.
Return values:
ErrorStatusthis shows the clock switch status (ERROR/SUCCESS).

Definition at line 309 of file stm8s_clk.c.

References assert_param, CLK, CLK_CURRENTCLOCKSTATE_DISABLE, CLK_ECKR_HSEEN, CLK_ICKR_HSIEN, CLK_ICKR_LSIEN, CLK_SOURCE_HSE, CLK_SOURCE_HSI, CLK_SOURCE_LSI, CLK_SWCR_SWBSY, CLK_SWCR_SWEN, CLK_SWCR_SWIEN, CLK_SWCR_SWIF, CLK_SWITCHMODE_AUTO, CLK_TIMEOUT, DISABLE, ERROR, IS_CLK_CURRENTCLOCKSTATE_OK, IS_CLK_SOURCE_OK, IS_CLK_SWITCHMODE_OK, IS_FUNCTIONALSTATE_OK, and SUCCESS.

Referenced by main().

void CLK_DeInit ( void  )

Deinitializes the CLK peripheral registers to their default reset values.

Parameters:
None
Return values:
None
Warning:
Resetting the CCOR register:
When the CCOEN bit is set, the reset of the CCOR register require two consecutive write instructions in order to reset first the CCOEN bit and the second one is to reset the CCOSEL bits.

Definition at line 72 of file stm8s_clk.c.

References CLK, CLK_CCOR_CCOEN, CLK_CCOR_RESET_VALUE, CLK_CKDIVR_RESET_VALUE, CLK_CSSR_RESET_VALUE, CLK_ECKR_RESET_VALUE, CLK_HSITRIMR_RESET_VALUE, CLK_ICKR_RESET_VALUE, CLK_PCKENR1_RESET_VALUE, CLK_PCKENR2_RESET_VALUE, CLK_SWCR_RESET_VALUE, CLK_SWIMCCR_RESET_VALUE, and CLK_SWR_RESET_VALUE.

void CLK_FastHaltWakeUpCmd ( FunctionalState  NewState)

Configures the High Speed Internal oscillator (HSI).

Full description:
If CLK_FastHaltWakeup is enabled, HSI oscillator is automatically switched-on (HSIEN=1) and selected as next clock master (CKM=SWI=HSI) when resuming from HALT/ActiveHalt modes.
Parameters:
NewStatethis parameter is the Wake-up Mode state.
Return values:
None

Definition at line 99 of file stm8s_clk.c.

References assert_param, CLK, CLK_ICKR_FHWU, DISABLE, and IS_FUNCTIONALSTATE_OK.

uint32_t CLK_GetClockFreq ( void  )

This function returns the frequencies of different on chip clocks.

Parameters:
None
Return values:
themaster clock frequency

Definition at line 569 of file stm8s_clk.c.

References CLK, CLK_CKDIVR_HSIDIV, CLK_SOURCE_HSI, CLK_SOURCE_LSI, HSE_VALUE, HSI_VALUE, HSIDivFactor, and LSI_VALUE.

Referenced by LSIMeasurment(), UART1_Init(), UART2_Init(), UART3_Init(), and UART4_Init().

FlagStatus CLK_GetFlagStatus ( CLK_Flag_TypeDef  CLK_FLAG)

Checks whether the specified CLK flag is set or not.

Full description:
Parameters:
CLK_FLAGFlag to check. can be one of the values of CLK_Flag_TypeDef
Return values:
FlagStatus,statusof the checked flag

Definition at line 634 of file stm8s_clk.c.

References assert_param, CLK, IS_CLK_FLAG_OK, RESET, and SET.

ITStatus CLK_GetITStatus ( CLK_IT_TypeDef  CLK_IT)

Checks whether the specified CLK interrupt has is enabled or not.

Parameters:
CLK_ITspecifies the CLK interrupt. can be one of the values of CLK_IT_TypeDef
Return values:
ITStatus,newstate of CLK_IT (SET or RESET).

Definition at line 687 of file stm8s_clk.c.

References assert_param, CLK, CLK_IT_SWIF, IS_CLK_IT_OK, RESET, and SET.

CLK_Source_TypeDef CLK_GetSYSCLKSource ( void  )

Returns the clock source used as system clock.

Parameters:
None
Return values:
Clocksource used. can be one of the values of CLK_Source_TypeDef

Definition at line 559 of file stm8s_clk.c.

References CLK.

void CLK_HSECmd ( FunctionalState  NewState)

Enable or Disable the External High Speed oscillator (HSE).

Parameters:
NewStatenew state of HSEEN, value accepted ENABLE, DISABLE.
Return values:
None

Definition at line 121 of file stm8s_clk.c.

References assert_param, CLK, CLK_ECKR_HSEEN, DISABLE, and IS_FUNCTIONALSTATE_OK.

void CLK_HSICmd ( FunctionalState  NewState)

Enables or disables the Internal High Speed oscillator (HSI).

Parameters:
NewStatenew state of HSIEN, value accepted ENABLE, DISABLE.
Return values:
None

Definition at line 143 of file stm8s_clk.c.

References assert_param, CLK, CLK_ICKR_HSIEN, DISABLE, and IS_FUNCTIONALSTATE_OK.

Referenced by main().

void CLK_HSIPrescalerConfig ( CLK_Prescaler_TypeDef  HSIPrescaler)

Configures the HSI clock dividers.

Parameters:
HSIPrescaler: Specifies the HSI clock divider to apply. This parameter can be any of the CLK_Prescaler_TypeDef enumeration.
Return values:
None

Definition at line 415 of file stm8s_clk.c.

References assert_param, CLK, CLK_CKDIVR_HSIDIV, and IS_CLK_HSIPRESCALER_OK.

Referenced by CLK_Config(), and main().

void CLK_ITConfig ( CLK_IT_TypeDef  CLK_IT,
FunctionalState  NewState 
)

Enables or disables the specified CLK interrupts.

Parameters:
CLK_ITThis parameter specifies the interrupt sources. It can be one of the values of CLK_IT_TypeDef.
NewStateNew state of the Interrupt. Value accepted ENABLE, DISABLE.
Return values:
None

Definition at line 459 of file stm8s_clk.c.

References assert_param, CLK, CLK_CSSR_CSSDIE, CLK_IT_CSSD, CLK_IT_SWIF, CLK_SWCR_SWIEN, DISABLE, IS_CLK_IT_OK, and IS_FUNCTIONALSTATE_OK.

void CLK_LSICmd ( FunctionalState  NewState)

Enables or disables the Internal Low Speed oscillator (LSI).

Parameters:
NewStatenew state of LSIEN, value accepted ENABLE, DISABLE.
Note:
Before using the LSI clock you have to enable the option bytes (LSI_EN option bit is set).
Return values:
None

Definition at line 166 of file stm8s_clk.c.

References assert_param, CLK, CLK_ICKR_LSIEN, DISABLE, and IS_FUNCTIONALSTATE_OK.

void CLK_PeripheralClockConfig ( CLK_Peripheral_TypeDef  CLK_Peripheral,
FunctionalState  NewState 
)

Enables or disables the specified peripheral CLK.

Parameters:
CLK_Peripheral: This parameter specifies the peripheral clock to gate. This parameter can be any of the CLK_Peripheral_TypeDef enumeration.
NewState: New state of specified peripheral clock. This parameter can be any of the FunctionalState enumeration.
Return values:
None

Definition at line 263 of file stm8s_clk.c.

References assert_param, CLK, DISABLE, IS_CLK_PERIPHERAL_OK, and IS_FUNCTIONALSTATE_OK.

Referenced by SD_LowLevel_DeInit(), SD_LowLevel_Init(), sEE_LowLevel_DeInit(), sEE_LowLevel_Init(), and STM8S_EVAL_LCD_Init().

void CLK_SlowActiveHaltWakeUpCmd ( FunctionalState  NewState)

Configures the slow active halt wake up.

Parameters:
NewState,:specifies the Slow Active Halt wake up state. can be set of the following values:
  • DISABLE: Slow Active Halt mode disabled;
  • ENABLE: Slow Active Halt mode enabled.
Return values:
None

Definition at line 238 of file stm8s_clk.c.

References assert_param, CLK, CLK_ICKR_SWUAH, DISABLE, and IS_FUNCTIONALSTATE_OK.

void CLK_SWIMConfig ( CLK_SWIMDivider_TypeDef  CLK_SWIMDivider)

Configures the SWIM clock frequency on the fly.

Parameters:
CLK_SWIMDividerSpecifies the SWIM clock divider to apply. can be one of the value of CLK_SWIMDivider_TypeDef
Return values:
None

Definition at line 523 of file stm8s_clk.c.

References assert_param, CLK, CLK_SWIMCCR_SWIMDIV, CLK_SWIMDIVIDER_2, and IS_CLK_SWIMDIVIDER_OK.

void CLK_SYSCLKConfig ( CLK_Prescaler_TypeDef  CLK_Prescaler)

Configures the HSI and CPU clock dividers.

Parameters:
ClockPrescalerSpecifies the HSI or CPU clock divider to apply.
Return values:
None

Definition at line 500 of file stm8s_clk.c.

References assert_param, CLK, CLK_CKDIVR_CPUDIV, CLK_CKDIVR_HSIDIV, and IS_CLK_PRESCALER_OK.

Referenced by main().

void CLK_SYSCLKEmergencyClear ( void  )

Reset the SWBSY flag (SWICR Reister)

Full description:
This function reset SWBSY flag in order to reset clock switch operations (target oscillator is broken, stabilization is longing too much, etc.). If at the same time
software attempts to set SWEN and clear SWBSY, SWBSY action takes precedence.
Parameters:
None
Return values:
None

Definition at line 622 of file stm8s_clk.c.

References CLK, and CLK_SWCR_SWBSY.

STM8 Standard Peripherals Library: Footer

 

 

 

      For complete documentation on STM8 8-bit Microcontrollers platform visit www.st.com