STM32 RTOS 0.2.3
Bare-metal preemptive RTOS for STM32F446RE
Loading...
Searching...
No Matches

Regulator voltage scaling and over-drive. More...

Collaboration diagram for PWR:

Macros

#define PWR_READY_TIMEOUT_ITERATIONS   (100000U)
 Polls allowed for each CSR ready-flag wait (see Poll-count timeouts).

Functions

DRIVER_MUST_CHECK DriverStatus_e pwrSetVoltageScale (PwrRegisters_t *pwr, uint32_t vos)
 Select the regulator voltage scale for the coming PLL frequency.
DRIVER_MUST_CHECK DriverStatus_e pwrWaitVoltageScaleReady (const PwrRegisters_t *pwr)
 Wait until the regulator reaches the selected scale (CSR.VOSRDY).
DRIVER_MUST_CHECK DriverStatus_e pwrEnableOverdrive (PwrRegisters_t *pwr)
 Enable over-drive, to run above the scale's normal maximum.
static DriverStatus_e pwrWaitCsrFlag (const PwrRegisters_t *pwr, uint32_t flag)
 Poll a CSR flag until it sets or PWR_READY_TIMEOUT_ITERATIONS polls pass.

Detailed Description

Regulator voltage scaling and over-drive.

Macro Definition Documentation

◆ PWR_READY_TIMEOUT_ITERATIONS

#define PWR_READY_TIMEOUT_ITERATIONS   (100000U)

Polls allowed for each CSR ready-flag wait (see Poll-count timeouts).

Definition at line 14 of file pwr.c.

Referenced by pwrWaitCsrFlag().

Function Documentation

◆ pwrSetVoltageScale()

DriverStatus_e pwrSetVoltageScale ( PwrRegisters_t * pwr,
uint32_t vos )

Select the regulator voltage scale for the coming PLL frequency.

Takes effect when the PLL is turned on, so there is nothing to wait for here.

Parameters
pwrPWR block (e.g. PWR).
vosPWR_CR_VOS_SCALE1, PWR_CR_VOS_SCALE2 or PWR_CR_VOS_SCALE3.
Precondition
The PWR clock is on (rccPwrClockEnable()).
The PLL is off. This is not checked: PLLON is in RCC.
Return values
DRIVER_STATUS_OKCR.VOS written.
DRIVER_STATUS_ERR_INVALID_PARAMvos is not a scale value.

Definition at line 42 of file pwr.c.

References PwrRegisters_t::CR, DRIVER_STATUS_ERR_INVALID_PARAM, DRIVER_STATUS_OK, PWR_CR_VOS_Msk, PWR_CR_VOS_Pos, PWR_CR_VOS_SCALE1, PWR_CR_VOS_SCALE2, PWR_CR_VOS_SCALE3, and pwrSetVoltageScale().

Referenced by bspClockInit(), and pwrSetVoltageScale().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pwrWaitVoltageScaleReady()

DriverStatus_e pwrWaitVoltageScaleReady ( const PwrRegisters_t * pwr)

Wait until the regulator reaches the selected scale (CSR.VOSRDY).

Parameters
pwrPWR block (e.g. PWR); only CSR is read.
Precondition
pwrSetVoltageScale() has run and the PLL has since been turned on. With the PLL off this can only time out.
Return values
DRIVER_STATUS_OKVOSRDY is set.
DRIVER_STATUS_ERR_TIMEOUTVOSRDY did not set within the poll budget.

Definition at line 58 of file pwr.c.

References PWR_CSR_VOSRDY, pwrWaitCsrFlag(), and pwrWaitVoltageScaleReady().

Referenced by bspClockInit(), and pwrWaitVoltageScaleReady().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pwrEnableOverdrive()

DriverStatus_e pwrEnableOverdrive ( PwrRegisters_t * pwr)

Enable over-drive, to run above the scale's normal maximum.

Sets ODEN and waits for ODRDY, then sets ODSWEN and waits for ODSWRDY, as ST's HAL does. CR.VOS is preserved.

Parameters
pwrPWR block (e.g. PWR).
Precondition
The scale is selected and ready (pwrWaitVoltageScaleReady()).
SYSCLK is still HSI or HSE, not the PLL.
No peripheral clock other than PWR is on (RM0390 section 5.1.3).
Return values
DRIVER_STATUS_OKODSWRDY is set.
DRIVER_STATUS_ERR_TIMEOUTODRDY did not set (ODSWEN is then not written), or ODSWRDY did not.

Definition at line 63 of file pwr.c.

References PwrRegisters_t::CR, DRIVER_STATUS_OK, PWR_CR_ODEN, PWR_CR_ODSWEN, PWR_CSR_ODRDY, PWR_CSR_ODSWRDY, pwrEnableOverdrive(), and pwrWaitCsrFlag().

Referenced by bspClockInit(), and pwrEnableOverdrive().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pwrWaitCsrFlag()

DriverStatus_e pwrWaitCsrFlag ( const PwrRegisters_t * pwr,
uint32_t flag )
static

Poll a CSR flag until it sets or PWR_READY_TIMEOUT_ITERATIONS polls pass.

Parameters
pwrPWR block; only CSR is read.
flagPWR_CSR_VOSRDY, PWR_CSR_ODRDY or PWR_CSR_ODSWRDY.
Return values
DRIVER_STATUS_OKThe flag is set.
DRIVER_STATUS_ERR_TIMEOUTIt did not set in time.

Definition at line 23 of file pwr.c.

References PwrRegisters_t::CSR, DRIVER_STATUS_ERR_TIMEOUT, DRIVER_STATUS_OK, PWR_READY_TIMEOUT_ITERATIONS, and pwrWaitCsrFlag().

Referenced by pwrEnableOverdrive(), pwrWaitCsrFlag(), and pwrWaitVoltageScaleReady().

Here is the call graph for this function:
Here is the caller graph for this function: