Nut/OS  5.0.5
API Reference
stm32_clk.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define SYSCLK_HSI   0
#define SYSCLK_PLL   1
#define SYSCLK_HSE   2
#define PLLCLK_HSI   3
#define PLLCLK_HSE   4

Functions

int CtlHseClock (uint8_t ena)
 Control HSE clock.
int CtlHsiClock (uint8_t ena)
 Control HSI clock.
int CtlPllClock (uint8_t ena)
 Control PLL clock.
int SetPllClock (int src)
int SetPllClockSource (int src)
 Configures the System clock source: HSE or HSI.
int SetSysClock (void)
 Update SystemCoreClock according to Clock Register Values.
uint32_t SysCtlClockGet (void)
 requests System clock frequency

Variables

uint32_t SystemCoreClock

Define Documentation

#define SYSCLK_HSI   0

Referenced by SetSysClockSource().

#define SYSCLK_PLL   1

Referenced by SetSysClockSource().

#define SYSCLK_HSE   2

Referenced by SetSysClockSource().

#define PLLCLK_HSI   3

Referenced by SetPllClockSource().

#define PLLCLK_HSE   4

Referenced by SetPllClockSource().


Function Documentation

int CtlHseClock ( uint8_t  ena)

Control HSE clock.

Parameters:
ena0 disable clock, any other value enable it.
Returns:
0 on success, -1 on HSE start failed.

References HSE_STARTUP_TIMEOUT, rc, RCC, RCC_CR_HSEON, RCC_CR_HSERDY, RCC_CR_HSION, and RESET.

Referenced by SetPllClockSource(), and SetSysClockSource().

int CtlHsiClock ( uint8_t  ena)

Control HSI clock.

Parameters:
ena0 disable clock, any other value enable it.
Returns:
0 on success, -1 on HSI start failed.

References HSE_STARTUP_TIMEOUT, rc, RCC, RCC_CR_HSION, RCC_CR_HSIRDY, and RESET.

Referenced by SetPllClockSource(), and SetSysClockSource().

int CtlPllClock ( uint8_t  ena)

Control PLL clock.

Parameters:
ena0 disable clock, any other value enable it.
Returns:
0 on success, -1 on PLL start failed.

References HSE_STARTUP_TIMEOUT, rc, RCC, RCC_CR_PLLON, RCC_CR_PLLRDY, and RESET.

Referenced by SetSysClockSource().

int SetPllClock ( int  src)
int SetPllClockSource ( int  src)

Configures the System clock source: HSE or HSI.

Note:
This function should be used only after reset.
Parameters:
srcis one of PLLCLK_HSE, PLLCLK_HSI.
Returns:
0 if clock is running ale -1.
Note:
This function should be used with PLL disables
Parameters:
srcis one of PLLCLK_HSE, PLLCLK_HSI.
Returns:
0 if clock is running ale -1.

References _BI32, CM3BBREG, CtlHseClock(), CtlHsiClock(), ENABLE, PLLCLK_HSE, PLLCLK_HSI, rc, RCC, RCC_BASE, RCC_CFGR_PLLSRC, RCC_CFGR_PLLXTPRE, and RCC_PLLCFGR_PLLSRC.

Here is the call graph for this function:

int SetSysClock ( void  )

Update SystemCoreClock according to Clock Register Values.

This function reads out the CPUs clock and PLL registers and assembles the actual clock speed values into the SystemCoreClock global variable. Sets System clock frequency to the configured defaults.

Note:
This function should be used only after reset.
Parameters:
None
Return values:
NoneUpdate SystemCoreClock according to Clock Register Values.
Note:
This function should be used only after reset.
Parameters:
None
Return values:
NoneUpdate SystemCoreClock according to Clock Register Values.

Enable HSI/HSE clock and setup HCLK, PCLK2 and PCLK1 prescalers.

Parameters:
None.
Returns:
0 on success, -1 on fault of HSE.

References CCLKCFG_Val, CCLKSEL_Val, CLKOUTCFG_Val, CLKSRCSEL_Val, EMCCLKSEL_Val, FLASH, FLASH_ACR_LATENCY, FLASH_ACR_LATENCY_1, FLASH_ACR_PRFTBE, FLASHCFG_Val, HSE_VALUE, LPC_SC, PCLKSEL0_Val, PCLKSEL1_Val, PCLKSEL_Val, PCONP_Val, PLL0CFG_Val, PLL1CFG_Val, rc, RCC, RCC_CFGR_HPRE, RCC_CFGR_HPRE_DIV1, RCC_CFGR_PPRE1, RCC_CFGR_PPRE1_DIV1, RCC_CFGR_PPRE2, RCC_CFGR_PPRE2_DIV1, SCS_Val, SetSysClockSource(), SYSCLK_SOURCE, SystemCoreClockUpdate(), USBCLKCFG_Val, and USBCLKSEL_Val.

Here is the call graph for this function:

uint32_t SysCtlClockGet ( void  )

requests System clock frequency

Note:
This function should be used only after reset.
Parameters:
None
Return values:
None

References SystemCoreClock, and SystemCoreClockUpdate().

Here is the call graph for this function: