ADuCM4x50 Device Drivers API Reference Manual
Release 4.0.0.0
|
Power Management Driver. More...
Modules | |
Static Configuration | |
Functions | |
ADI_PWR_RESULT | adi_pwr_Init (void) |
ADI_PWR_RESULT | adi_pwr_UpdateCoreClock (void) |
Updates the internal SystemCoreClock variable with current core Clock retrieved from cpu registers. More... | |
ADI_PWR_RESULT | adi_pwr_SetExtClkFreq (const uint32_t ExtClkFreq) |
Sets the system external clock frequency. More... | |
ADI_PWR_RESULT | adi_pwr_SetRootClockMux (const ADI_CLOCK_MUX_ID eClockID) |
Sets the source for the root clock multiplexer. More... | |
ADI_PWR_RESULT | adi_pwr_SetPLLClockMux (const ADI_CLOCK_MUX_ID eClockID) |
Sets the input clock source for PLL multiplexer. More... | |
ADI_PWR_RESULT | adi_pwr_SetLFClockMux (const ADI_CLOCK_MUX_ID eClockID) |
Sets the input clock for low frequency clock multiplexer. More... | |
ADI_PWR_RESULT | adi_pwr_EnableLFXTALFailAutoSwitch (const bool bEnable) |
Enable/Disable the LFXTAL Fail Auto switch. Enables/Disable automatic Switching of the LF Mux to LF OSC on LF XTAL Failure. More... | |
ADI_PWR_RESULT | adi_pwr_EnableRootClockFailAutoSwitch (const bool bEnable) |
To enable/disable auto switching of root clock to HFOSC upon detection of Root clock failure. This feature is valid only when the ROOT clock monitor is enabled. The root clock monitoring can be enabled by using the API adi_pwr_EnableClockInterrupt. More... | |
ADI_PWR_RESULT | adi_pwr_SetHFOscDivFactor (const ADI_PWR_HFOSC_DIV eDivFactor) |
Sets the HF Oscillator divide factor. More... | |
ADI_PWR_RESULT | adi_pwr_EnableHFOscAutoDivBy1 (const bool bEnable) |
Enable or disable the HF oscillator automatic divide by 1 during wakeup from Flexi mode. More... | |
ADI_PWR_RESULT | adi_pwr_SetRefClockMux (const ADI_CLOCK_MUX_ID eClockID) |
Sets clock source for the Reference clock multiplexer. More... | |
ADI_PWR_RESULT | adi_pwr_GetExtClkFreq (uint32_t *pExtClock) |
Gets the system external clock frequency. Gets the clock frequency of the source connected to the external GPIO clock input source. More... | |
ADI_PWR_RESULT | adi_pwr_GetClockFrequency (const ADI_CLOCK_ID eClockId, uint32_t *pClock) |
Get the frequency of the given clock. Obtain individual peripheral clock frequencies. More... | |
ADI_PWR_RESULT | adi_pwr_EnableClock (const ADI_CLOCK_GATE eClockGate, const bool bEnable) |
Enable/disable individual peripheral clocks. More... | |
ADI_PWR_RESULT | adi_pwr_EnableClockSource (const ADI_CLOCK_SOURCE_ID eClockSource, const bool bEnable) |
To Enable/disable clock sources. More... | |
ADI_PWR_RESULT | adi_pwr_SetClockDivider (const ADI_CLOCK_ID eClockId, const uint16_t nDiv) |
Sets the clock divide factor for an individual clock group. More... | |
ADI_PWR_RESULT | adi_pwr_GetClockStatus (const ADI_CLOCK_SOURCE_ID eClockSource, ADI_CLOCK_SOURCE_STATUS *peStatus) |
Return the status of a clock source. More... | |
ADI_PWR_RESULT | adi_pwr_SetPll (uint8_t nDivFactor, const uint8_t nMulFactor, const bool bDiv2, const bool bMul2) |
Program PLL frequency. More... | |
ADI_PWR_RESULT | adi_pwr_EnableClockInterrupt (const ADI_PWR_CLOCK_IRQ eIrq, const bool bEnable) |
Enable/Disable the clock interrupt to monitor status of LFXTAL, HFXTAL and PLL. More... | |
ADI_PWR_RESULT | adi_pwr_EnableLFXTALBypass (const bool bEnable) |
Enable/disable LFXTAL bypass mode. More... | |
ADI_PWR_RESULT | adi_pwr_EnablePMGInterrupt (const ADI_PWR_PMG_IRQ eIrq, const bool bEnable) |
Enable/Disable the power management interrupt. More... | |
ADI_PWR_RESULT | adi_pwr_GetWakeUpStatus (ADI_PWR_WAKEUP_STATUS *peStatus) |
Function to retrieve the wakeup from shut down mode status. More... | |
ADI_PWR_RESULT | adi_pwr_SetVoltageRange (const ADI_PWR_VOLTAGE_RANGE eRange) |
To Monitor voltage range of battery. More... | |
ADI_PWR_RESULT | adi_pwr_EnterLowPowerMode (const ADI_PWR_POWER_MODE PowerMode, uint32_t volatile *pnInterruptOccurred, const uint8_t PriorityMask) |
Puts the processor into given low power mode. More... | |
ADI_PWR_RESULT | adi_pwr_ExitLowPowerMode (uint32_t volatile *pnInterruptOccurred) |
ADI_PWR_RESULT | adi_pwr_EnableHPBuck (const bool bEnable) |
Enables or disables the HP Buck. More... | |
ADI_PWR_RESULT | adi_pwr_SetGPIOClockOutput (const ADI_CLOCK_OUTPUT_ID eClockOutput) |
Set the clock output through the GPIO. More... | |
ADI_PWR_RESULT | adi_pwr_EnableHPBuckLowPowerMode (const bool bEnable) |
Enable or disable the HPBuck Low Power mode. The HPBUCK Low Power mode can be selected, when the Chip is in Flexi Power mode and low power modules such as Timer, Beeper only are enabled. More... | |
ADI_PWR_RESULT | adi_pwr_SetHPBuckLoadMode (const ADI_PWR_HPBUCK_LD_MODE eLoadMode) |
Set the HP Buck load mode. More... | |
ADI_PWR_RESULT | adi_pwr_RegisterCallback (const ADI_CALLBACK pfCallback, void *pcbParam) |
Registers or unregister the callback function. More... | |
Power Management Driver.
enum ADI_CLOCK_ID |
enum ADI_CLOCK_SOURCE_ID |
Enumeration of input clock sources
enum ADI_CLOCK_MUX_ID |
Enumeration of clock sources for each clock multiplexer. The processor has the following clock multiplexers.
Enumeration of clock source status.
enum ADI_CLOCK_OUTPUT_ID |
Clock output options through GPIO pin. The GPIO clock output pin can be driven through one of these clocks.
enum ADI_CLOCK_GATE |
Enumeration of clock gates using which the clocks can be gated.
enum ADI_PWR_HFOSC_DIV |
enum ADI_PWR_RESULT |
Power driver API return codes
enum ADI_PWR_POWER_MODE |
Enumeration of the power modes supported by the processor.
enum ADI_PWR_PMG_IRQ |
Enumeration of power management interrupts.
Enumerator | |
---|---|
ADI_PWR_LOW_BATTERY_VOLTAGE_IEN | Interrupt when battery voltage drops below 1.8V. |
ADI_PWR_UNDER_VOLATAGE_IEN | Interrupt when VREG under-voltage: below 1V. |
ADI_PWR_OVER_VOLATAGE_IEN | Interrupt when VREG over-voltage: over- 1.32V. |
ADI_PWR_BATTERY_VOLTAGE_RANGE_IEN | Interrupt when battery voltage falls to the specified range.Please see adi_pwr_SetVoltageRange. |
enum ADI_PWR_CLOCK_IRQ |
Enumeration of system clock module interrupts.
enum ADI_PWR_EVENT |
Enumeration of the power driver events notified through the callback.
Enumeration of the battery voltage ranges for voltage monitoring interrupt generation.
Enumeration of HP Buck load modes. The modes can be used to choose the loading capability of the HPBUCK. The low load mode and high load mode are based on the loading in the system.
ADI_PWR_RESULT adi_pwr_Init | ( | void | ) |
Initialize the clock configuration register with the default values.
ADI_PWR_RESULT adi_pwr_UpdateCoreClock | ( | void | ) |
Updates the internal SystemCoreClock variable with current core Clock retrieved from cpu registers.
Updates the internal SystemCoreClock variable with current core Clock retrieved from cpu registers.
ADI_PWR_RESULT adi_pwr_SetExtClkFreq | ( | const uint32_t | ExtClkFreq | ) |
Sets the system external clock frequency.
[in] | ExtClkFreq | External clock frequency in Hz |
ADI_PWR_RESULT adi_pwr_SetRootClockMux | ( | const ADI_CLOCK_MUX_ID | eClockID | ) |
Sets the source for the root clock multiplexer.
[in] | eClockID | Clock source to the root clock multiplexer. |
ADI_PWR_RESULT adi_pwr_SetPLLClockMux | ( | const ADI_CLOCK_MUX_ID | eClockID | ) |
Sets the input clock source for PLL multiplexer.
[in] | eClockID | Clock source to the System PLL multiplexer. |
ADI_PWR_RESULT adi_pwr_SetLFClockMux | ( | const ADI_CLOCK_MUX_ID | eClockID | ) |
Sets the input clock for low frequency clock multiplexer.
[in] | eClockID | Clock source to the low frequency clock multiplexer. |
ADI_PWR_RESULT adi_pwr_EnableLFXTALFailAutoSwitch | ( | const bool | bEnable | ) |
Enable/Disable the LFXTAL Fail Auto switch. Enables/Disable automatic Switching of the LF Mux to LF OSC on LF XTAL Failure.
[in] | bEnable | : Flag which indicates whether to enable/disable LFXTAL Auto switch. true - Enable LFXTAL Auto switch. false - Disable LFXTAL Auto switch. |
ADI_PWR_RESULT adi_pwr_EnableRootClockFailAutoSwitch | ( | const bool | bEnable | ) |
To enable/disable auto switching of root clock to HFOSC upon detection of Root clock failure. This feature is valid only when the ROOT clock monitor is enabled. The root clock monitoring can be enabled by using the API adi_pwr_EnableClockInterrupt.
[in] | bEnable | : Flag which indicates whether to enable or disable Root clock auto switch. true - Enable Root clock auto switch. false - Disable Root clock auto switch. |
ADI_PWR_RESULT adi_pwr_SetHFOscDivFactor | ( | const ADI_PWR_HFOSC_DIV | eDivFactor | ) |
Sets the HF Oscillator divide factor.
Sets the divide factor for the clocks derived from the HF oscillator clock.
[in] | eDivFactor | : HF Clock divide factor to be set. |
ADI_PWR_RESULT adi_pwr_EnableHFOscAutoDivBy1 | ( | const bool | bEnable | ) |
Enable or disable the HF oscillator automatic divide by 1 during wakeup from Flexi mode.
This is used to enable/disable the fast wakeup from Flexi power mode. When the fast wakeup from Flexi mode is enabled, the frequency undivided 26MHz HF oscillator clock itself will be used during the wake up. The undivided HFOSC clock is selected automatically by setting the HF oscillator divide factor to 1. This updated divided by 1 clock selection will remain same until the new divider value is set. When disabled the HF Oscillator divide factor will remain unchanged during the wakeup.
[in] | bEnable | : Flag which indicates whether HF oscillator automatic divide by 1 is enabled/disabled. 'true' - To enable automatic divide by 1. 'false' - To disable automatic divide by 1. |
ADI_PWR_RESULT adi_pwr_SetRefClockMux | ( | const ADI_CLOCK_MUX_ID | eClockID | ) |
Sets clock source for the Reference clock multiplexer.
[in] | eClockID | Clock source to the reference clock multiplexer. |
ADI_PWR_RESULT adi_pwr_GetExtClkFreq | ( | uint32_t * | pExtClock | ) |
Gets the system external clock frequency. Gets the clock frequency of the source connected to the external GPIO clock input source.
[in] | pExtClock | : Pointer to write the external clock frequency. |
ADI_PWR_RESULT adi_pwr_GetClockFrequency | ( | const ADI_CLOCK_ID | eClockId, |
uint32_t * | pClock | ||
) |
Get the frequency of the given clock. Obtain individual peripheral clock frequencies.
[in] | eClockId | : Clock identifier |
[out] | pClock | : Pointer to a location to store the clock frequency. |
Definition at line 435 of file adi_pwr.c.
Referenced by adi_adc_GetBatteryVoltage(), adi_adc_GetTemperature(), adi_adc_PowerUp(), adi_i2c_SetBitRate(), adi_spi_GetBitrate(), and adi_spi_SetBitrate().
ADI_PWR_RESULT adi_pwr_EnableClock | ( | const ADI_CLOCK_GATE | eClockGate, |
const bool | bEnable | ||
) |
Enable/disable individual peripheral clocks.
[in] | eClockGate | Clock identifier |
[in] | bEnable | Flag to indicate whether to enable/disable individual clock. true - to enable individual clock. false - to disable individual clock. |
Manage individual peripheral clock gates to enable or disable the clocks to the peripheral.
ADI_PWR_RESULT adi_pwr_EnableClockSource | ( | const ADI_CLOCK_SOURCE_ID | eClockSource, |
const bool | bEnable | ||
) |
To Enable/disable clock sources.
[in] | eClockSource | : Clock source identifier. |
[in] | bEnable | : Enable (true) or disable (false) the clock source. |
Enables or disables clock sources without additional checks, by writing a "1" or "0" to the enable bit.
ADI_PWR_RESULT adi_pwr_SetClockDivider | ( | const ADI_CLOCK_ID | eClockId, |
const uint16_t | nDiv | ||
) |
Sets the clock divide factor for an individual clock group.
[in] | eClockId | Clock domain identifier. |
[in] | nDiv | Clock divide value to be set (right-justified uint16_t). |
Manage individual peripheral clock dividers.
ADI_PWR_RESULT adi_pwr_GetClockStatus | ( | const ADI_CLOCK_SOURCE_ID | eClockSource, |
ADI_CLOCK_SOURCE_STATUS * | peStatus | ||
) |
Return the status of a clock source.
[in] | eClockSource | : Clock source identifier. |
[out] | peStatus | : Pointer to variable of type ADI_CLOCK_SOURCE_STATUS for storing clock source status. |
Return the status of a clock source.
ADI_PWR_RESULT adi_pwr_SetPll | ( | uint8_t | nDivFactor, |
const uint8_t | nMulFactor, | ||
const bool | bDiv2, | ||
const bool | bMul2 | ||
) |
Program PLL frequency.
[in] | nDivFactor | PLL divider(M). |
[in] | nMulFactor | PLL Multiplier(N) |
[in] | bDiv2 | PLL DIV2 parameter. |
[in] | bMul2 | PLL DIV2 parameter. |
Program PLL frequency (parameters M, N, DIV2) forSystem PLL(SPLL).
SPLL = input clock * ["(N * (1+ bMul2 )" / "((1+bDiv2)*M)" ] where input clock can be HFOSC or HFXTAL.
ADI_PWR_RESULT adi_pwr_EnableClockInterrupt | ( | const ADI_PWR_CLOCK_IRQ | eIrq, |
const bool | bEnable | ||
) |
Enable/Disable the clock interrupt to monitor status of LFXTAL, HFXTAL and PLL.
[in] | eIrq | : Specify which interrupt need to be enable/disabled. |
[in] | bEnable | : Specifies to enable/disable the specified interrupt. |
Interrupt for root clock monitor and Clock Fail
Interrupt for LFXTAL clock monitor and Clock Fail
Interrupt when LFXTAL clock becomes stable/unstable
Interrupt when HFXTAL clock becomes stable/unstable
Interrupt when PLL-LOCK/PLL-UNLOCK
ADI_PWR_RESULT adi_pwr_EnableLFXTALBypass | ( | const bool | bEnable | ) |
Enable/disable LFXTAL bypass mode.
[in] | bEnable | : Specifies to enable/disable the LFXTAL bypass mode true: To enable LFXTAL bypass mode. false: To disable LFXTAL bypass mode. |
ADI_PWR_RESULT adi_pwr_EnablePMGInterrupt | ( | const ADI_PWR_PMG_IRQ | eIrq, |
const bool | bEnable | ||
) |
Enable/Disable the power management interrupt.
[in] | eIrq | : Specify which interrupt need to be enable/disabled. |
[in] | bEnable | : Specifies to enable/disable the interrupt. |
ADI_PWR_RESULT adi_pwr_GetWakeUpStatus | ( | ADI_PWR_WAKEUP_STATUS * | peStatus | ) |
Function to retrieve the wakeup from shut down mode status.
[in] | peStatus | : Pointer to ADI_PWR_WAKEUP_STATUS for returning the wakeup status. |
ADI_PWR_RESULT adi_pwr_SetVoltageRange | ( | const ADI_PWR_VOLTAGE_RANGE | eRange | ) |
To Monitor voltage range of battery.
[in] | eRange | : Specify the voltage range for the battery. |
ADI_PWR_RESULT adi_pwr_EnterLowPowerMode | ( | const ADI_PWR_POWER_MODE | PowerMode, |
uint32_t volatile * | pnInterruptOccurred, | ||
const uint8_t | PriorityMask | ||
) |
Puts the processor into given low power mode.
[in] | PowerMode | One of the ADI_PWR_POWER_MODE enum values, defining the specific low-power modes to use. |
[in,out] | pnInterruptOccurred | Control parameter selection low-power operation. Either a NULL pointer for automatic hardware-based sleeping between interrupts, or a pointer to uint32_t for software looping sleep between interrupts. |
If a pointer to uint32_t is passed in, the integer must be 0 on entry, and will be set to 0 on exit.
When a NULL is passed, it means the application wants the low-power implementation to use the automatic "sleep-on-exit" hardware sleep mode in which wakeup interrupts are dispatched and then automatically put the processor back to sleep on exit. All interrupts execute the same WFI instruction (no looping) under hardware control, which results in a faster re-sleep than the software mode.
When a non-NULL value is passed, it is interpreted as a pointer to a shared integer application control variable allowing the wake-up interrupts to control whether/when the control loop should re-sleep the processor as each interrupt exits. Any interrupt that sets the variable will cause the sleep loop to exit. Otherwise, exiting interrupts will cause the core to re-sleep until the variable is set. Each interrupt executes a different WFI instruction inside a software loop (slower re-sleep).
[in] | PriorityMask | A right-justified (un shifted) wakeup interrupt priority mask, corresponding to the programmable interrupt priority encoding scheme defined by the Cortex NVIC controller. The PriorityMask value blocks interrupts with an equal or lower priority than the specified level, such that only higher-priority interrupts (less in numerical value) than the priority mask awake the processor. A zero-valued PriorityMask disables interrupt masking. |
Puts the processor into a low-power mode with interrupt-based wakeup(s). Applications specify the low-power mode, a pointer to an application-defined interrupt variable, and an interrupt priority mask controlling the interrupt priority level that may awake the processor.
When non-Null, a software strategy is used to control sleeping. As awakening interrupts are processed, they can increment the interrupt controlling variable and thereby cause the sleep mode to be exited. Note that all interrupts share a common variable and any interrupt that sets the variable will cause the sleep mode to be exited.
Use of the pnInterruptOccurred parameter provides a mechanism to resolve two potential hibernation trouble spots: 1) the inherent race between the intended wakeup interrupt and the execution of the Wait-For-Interrupt instruction (WFI) used to sleep the processor, and 2) unrelated interrupts (of sufficient priority) that may terminate the wait prematurely.
In the first case of the race condition, the race is avoided by testing the pnInterruptOccurred variable prior to the WFI within a common critical section. This allows the adi_pwr_EnterLowPowerMode() implementation to insure the intended wakeup interrupt has not occurred already and control whether to sleep the processor. This insures the intended wakeup interrupt has not already occurred prior to the wait, thereby eliminating the race condition otherwise present.
In the second case of an unrelated interrupt terminating the sleep prematurely, the problem is solved by requiring the interrupt handler(s) which is(are) intended to awake the sleeping processor to set the application-defined pnInterruptOccurred variable in their respective interrupt handler(s). This insures only those interrupts that explicitly set the variable will break the sleeping processor out of the sleep cycle. Other (incidental) interrupts put the processor back to sleep after the interrupt because the variable would not have been set. This is why there is a loop around the WFI instruction.
The pnInterruptOccurred variable must be initialized to zero before first use, and this should be done prior to enabling any interrupt which may set it (otherwise interrupts may be missed). If this variable is global or static then static initialization to zero or false will be sufficient.
The variable should only be set, from an interrupt handler, by calling adi_pwr_ExitLowPowerMode() and passing the variable by reference. The variable should not be assigned to directly, other than for initialization.
adi_pwr_EnterLowPowerMode() will always clear the variable again before returning, so it does not need to be cleared by user code on each use. Explicitly clearing the variable, outside of adi_pwr_EnterLowPowerMode() runs the risk of missing interrupts.
Each "programmable" peripheral interrupt has an associated priority-level register (which defaults to zero) within the Nested Vectored Interrupt Controller (NVIC). The number of interrupt priority encoding bits is defined by constant __NVIC_PRIO_BITS and is a fixed silicon attribute configured during chip design. The interrupt priority-level registers range in width from 3 to 8 bits.
This processor uses 3-bit priority encoding, allowing priority levels ranging between 0 (the highest, default programmable priority) and 7 (the lowest). For example, if the PriorityMask parameter is set to 3, only interrupts with assigned priority 0, 1, and 2 may awake the processor. Since default priority of all programmable interrupts is 0, setting up maskable interrupts requires that they be demoted in priority (raised numerically) relative to interrupts that are intended to awake the processor.
ADI_PWR_RESULT adi_pwr_ExitLowPowerMode | ( | uint32_t volatile * | pnInterruptOccurred | ) |
Companion function to adi_pwr_EnterLowPowerMode() that allows interrupts to
break out of the "FLEXI" mode in which the processor stays in
sleep while peripherals are active.
[in,out] | pnInterruptOccurred | Control parameter selection low-power operation. Either a NULL pointer for hardware sleep-on-exit feature, or a pointer to uint32_t for software looping sleep between interrupts. |
ADI_PWR_RESULT adi_pwr_EnableHPBuck | ( | const bool | bEnable | ) |
Enables or disables the HP Buck.
[in] | bEnable | : Flag which indicates whether to enable or disable HPBuck 'true' - To enable HPBuck. 'false' - To disable HPBuck. |
ADI_PWR_RESULT adi_pwr_SetGPIOClockOutput | ( | const ADI_CLOCK_OUTPUT_ID | eClockOutput | ) |
Set the clock output through the GPIO.
[in] | eClockOutput | : Clock to be output through the GPIO pin. |
ADI_PWR_RESULT adi_pwr_EnableHPBuckLowPowerMode | ( | const bool | bEnable | ) |
Enable or disable the HPBuck Low Power mode. The HPBUCK Low Power mode can be selected, when the Chip is in Flexi Power mode and low power modules such as Timer, Beeper only are enabled.
[in] | bEnable | : Flag which indicates whether to enable or disable HPBuck low power mode. 'true' - Enable HPBuck low power mode. 'false' - Disable HPBuck low power mode. |
ADI_PWR_RESULT adi_pwr_SetHPBuckLoadMode | ( | const ADI_PWR_HPBUCK_LD_MODE | eLoadMode | ) |
Set the HP Buck load mode.
HP Buck load mode can be set based on the system load. The low load mode can be set when the system is running below 26Mhz. The High load mode can be set when the system is running at greater than 26Mhz.
[in] | eLoadMode | : Load mode to be set. |
ADI_PWR_RESULT adi_pwr_RegisterCallback | ( | const ADI_CALLBACK | pfCallback, |
void * | pcbParam | ||
) |
Registers or unregister the callback function.
Application can register or unregister the callback function which will be called to notify the events from the driver.
[in] | pfCallback | : Callback function pointer. |
[in] | pcbParam | : Callback parameter. |