Nut/OS  5.0.5
API Reference
stm32_clk.c File Reference
#include <cfg/arch.h>
#include <arch/cm3.h>
#include <arch/cm3/stm/stm32_clk.h>
#include <cfg/clock.h>
Include dependency graph for stm32_clk.c:

Defines

#define SYSCLK_SOURCE   SYSCLK_HSI

Functions

void SystemCoreClockUpdate (void)
 Update SystemCoreClock according to Clock Register Values.
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 SetPllClockSource (int src)
 Configures the System clock source: HSE or HSI.
int SetSysClockSource (int src)
 Configures the System clock source: HSI, HS or PLL.
int SetSysClock (void)
 Configures the System clock coming from HSE or HSI oscillator.
uint32_t SysCtlClockGet (void)
 requests System clock frequency

Variables

uint32_t SystemCoreClock

Define Documentation

#define SYSCLK_SOURCE   SYSCLK_HSI

Referenced by SetSysClock().


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.

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.

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.

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.

References CtlHseClock(), CtlHsiClock(), ENABLE, PLLCLK_HSE, PLLCLK_HSI, rc, RCC, RCC_CFGR_PLLSRC, and RCC_CFGR_PLLXTPRE.

Here is the call graph for this function:

int SetSysClockSource ( int  src)

Configures the System clock source: HSI, HS or PLL.

Note:
This function should be used only after reset.
Parameters:
srcis one of SYSCLK_HSE, SYSCLK_HSI or SYSCLK_PLL.
Returns:
0 if selected clock is running else -1.

References CtlHseClock(), CtlHsiClock(), CtlPllClock(), ENABLE, rc, RCC, RCC_CFGR_SW, RCC_CFGR_SW_HSE, RCC_CFGR_SW_HSI, RCC_CFGR_SW_PLL, RCC_CFGR_SWS, RCC_CFGR_SWS_HSE, RCC_CFGR_SWS_HSI, RCC_CFGR_SWS_PLL, SYSCLK_HSE, SYSCLK_HSI, SYSCLK_PLL, and SystemCoreClockUpdate().

Referenced by SetSysClock().

Here is the call graph for this function:

int SetSysClock ( void  )

Configures the System clock coming from HSE or HSI oscillator.

Update 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 FLASH, FLASH_ACR_LATENCY, FLASH_ACR_LATENCY_1, FLASH_ACR_PRFTBE, HSE_VALUE, rc, RCC, RCC_CFGR_HPRE, RCC_CFGR_HPRE_DIV1, RCC_CFGR_PPRE1, RCC_CFGR_PPRE1_DIV1, RCC_CFGR_PPRE2, RCC_CFGR_PPRE2_DIV1, SetSysClockSource(), and SYSCLK_SOURCE.

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: