Tiva Driver Lib
Macros | Functions
Hibernate_api

Macros

#define DELAY_USECS   95
 
#define LOOP_CYCLES   3
 

Functions

void HibernateEnableExpClk (uint32_t ui32HibClk)
 
void HibernateDisable (void)
 
void HibernateClockConfig (uint32_t ui32Config)
 
void HibernateRTCEnable (void)
 
void HibernateRTCDisable (void)
 
void HibernateBatCheckStart (void)
 
uint32_t HibernateBatCheckDone (void)
 
void HibernateWakeSet (uint32_t ui32WakeFlags)
 
uint32_t HibernateWakeGet (void)
 
void HibernateLowBatSet (uint32_t ui32LowBatFlags)
 
uint32_t HibernateLowBatGet (void)
 
void HibernateRTCSet (uint32_t ui32RTCValue)
 
uint32_t HibernateRTCGet (void)
 
void HibernateRTCMatchSet (uint32_t ui32Match, uint32_t ui32Value)
 
uint32_t HibernateRTCMatchGet (uint32_t ui32Match)
 
void HibernateRTCSSMatchSet (uint32_t ui32Match, uint32_t ui32Value)
 
uint32_t HibernateRTCSSMatchGet (uint32_t ui32Match)
 
uint32_t HibernateRTCSSGet (void)
 
void HibernateRTCTrimSet (uint32_t ui32Trim)
 
uint32_t HibernateRTCTrimGet (void)
 
void HibernateDataSet (uint32_t *pui32Data, uint32_t ui32Count)
 
void HibernateDataGet (uint32_t *pui32Data, uint32_t ui32Count)
 
void HibernateRequest (void)
 
void HibernateIntEnable (uint32_t ui32IntFlags)
 
void HibernateIntDisable (uint32_t ui32IntFlags)
 
void HibernateIntRegister (void(*pfnHandler)(void))
 
void HibernateIntUnregister (void)
 
uint32_t HibernateIntStatus (bool bMasked)
 
void HibernateIntClear (uint32_t ui32IntFlags)
 
uint32_t HibernateIsActive (void)
 
void HibernateGPIORetentionEnable (void)
 
void HibernateGPIORetentionDisable (void)
 
bool HibernateGPIORetentionGet (void)
 

Detailed Description

Function Documentation

uint32_t HibernateBatCheckDone ( void  )

Returns if a forced battery check has completed.

This function returns if the forced battery check initiated by a call to the HibernateBatCheckStart() function has completed. This function returns a non-zero value until the battery level check has completed. Once this function returns a value of zero, the hibernation module has completed the battery check and the HibernateIntStatus() function can be used to check if the battery was low by checking if the value returned has the HIBERNATE_INT_LOW_BAT set.

Returns
The value is zero when the battery level check has completed or non-zero if the check is still in process.
void HibernateBatCheckStart ( void  )

Forces the Hibernation module to initiate a check of the battery voltage.

This function forces the Hibernation module to initiate a check of the battery voltage immediately rather than waiting for the next check interval to pass. After calling this function, the application should call the HibernateBatCheckDone() function and wait for the function to return a zero value before calling the HibernateIntStatus() to check if the return code has the HIBERNATE_INT_LOW_BAT set. If HIBERNATE_INT_LOW_BAT is set, the battery level is low. The application can also enable the HIBERNATE_INT_LOW_BAT interrupt and wait for an interrupt to indicate that the battery level is low.

Note
A hibernation request is held off if a battery check is in progress.
Returns
None.
void HibernateClockConfig ( uint32_t  ui32Config)

Configures the clock input for the Hibernation module.

Parameters
ui32Configis one of the possible configuration options for the clock input listed below.

This function is used to configure the clock input for the Hibernation module. The ui32Config parameter can be one of the following values:

  • HIBERNATE_OSC_DISABLE specifies that the internal oscillator is powered off. This is used when an externally supplied oscillator is connected to the XOSC0 pin or to save power when the LFIOSC is used in devices that have an LFIOSC in the hibernation module.
  • HIBERNATE_OSC_HIGHDRIVE specifies a higher drive strength when a 24pF filter capacitor is used with a crystal.
  • HIBERNATE_OSC_LOWDRIVE specifies a lower drive strength when a 12pF filter capacitor is used with a crystal.

The HIBERNATE_OSC_DISABLE option is used to disable and power down the internal oscillator if an external clock source or no clock source is used instead of a 32.768-kHz crystal. In the case where an external crystal is used, either the HIBERNATE_OSC_HIGHDRIVE or HIBERNATE_OSC_LOWDRIVE is used. These settings optimizes the oscillator drive strength to match the size of the filter capacitor that is used with the external crystal circuit.

Returns
None.
void HibernateDataGet ( uint32_t *  pui32Data,
uint32_t  ui32Count 
)

Reads a set of data from the battery-backed memory of the Hibernation module.

Parameters
pui32Datapoints to a location where the data that is read from the Hibernation module is stored.
ui32Countis the count of 32-bit words to read.

This function retrieves a set of data from the Hibernation module battery-backed memory that was previously stored with the HibernateDataSet() function. The caller must ensure that pui32Data points to a large enough memory block to hold all the data that is read from the battery-backed memory.

Returns
None.
void HibernateDataSet ( uint32_t *  pui32Data,
uint32_t  ui32Count 
)

Stores data in the battery-backed memory of the Hibernation module.

Parameters
pui32Datapoints to the data that the caller wants to store in the memory of the Hibernation module.
ui32Countis the count of 32-bit words to store.

Stores a set of data in the Hibernation module battery-backed memory. This memory is preserved when the power to the processor is turned off and can be used to store application state information that is needed when the processor wakes. Up to 16 32-bit words can be stored in the battery-backed memory. The data can be restored by calling the HibernateDataGet() function.

Returns
None.
void HibernateDisable ( void  )

Disables the Hibernation module for operation.

This function disables the Hibernation module. After this function is called, none of the Hibernation module features are available.

Returns
None.
void HibernateEnableExpClk ( uint32_t  ui32HibClk)

Enables the Hibernation module for operation.

Parameters
ui32HibClkis the rate of the clock supplied to the Hibernation module.

This function enables the Hibernation module for operation. This function should be called before any of the Hibernation module features are used.

The peripheral clock is the same as the processor clock. This value is returned by SysCtlClockGet(), or it can be explicitly hard-coded if it is constant and known (to save the code/execution overhead of a call to SysCtlClockGet()).

Returns
None.
void HibernateGPIORetentionDisable ( void  )

Disables GPIO retention after wake from hibernation.

This function disables the retention of the GPIO pin state during hibernation and allows the GPIO pins to be controlled by the system. If the HibernateGPIORetentionEnable() function is called before entering hibernation, this function must be called after returning from hibernation to allow the GPIO pins to be controlled by GPIO module.

Note
The hibernate GPIO retention setting is not available on all Tiva devices. Please consult the data sheet to determine if the device you are using supports this feature in the Hibernation module.
Returns
None.
void HibernateGPIORetentionEnable ( void  )

Enables GPIO retention after wake from hibernation.

This function enables the GPIO pin state to be maintained during hibernation and remain active even when waking from hibernation. The GPIO module itself is reset upon entering hibernation and no longer controls the output pins. To maintain the current output level after waking from hibernation, the GPIO module must be reconfigured and then the HibernateGPIORetentionDisable() function must be called to return control of the GPIO pin to the GPIO module.

Note
The hibernation GPIO retention setting is not available on all Tiva devices. Please consult the data sheet to determine if the device you are using supports this feature in the Hibernation module.
Returns
None.
bool HibernateGPIORetentionGet ( void  )

Returns the current setting for GPIO retention.

This function returns the current setting for GPIO retention in the hibernate module.

Note
The hibernation GPIO retention setting is not available on all Tiva devices. Please consult the data sheet to determine if the device you are using supports this feature in the Hibernation module.
Returns
Returns true if GPIO retention is enabled and false if GPIO retention is disabled.
void HibernateIntClear ( uint32_t  ui32IntFlags)

Clears pending interrupts from the Hibernation module.

Parameters
ui32IntFlagsis the bit mask of the interrupts to be cleared.

This function clears the specified interrupt sources. This function must be called within the interrupt handler or else the handler is called again upon exit.

The ui32IntFlags parameter has the same definition as the ui32IntFlags parameter to the HibernateIntEnable() function.

Note
Because there is a write buffer in the Cortex-M processor, it may take several clock cycles before the interrupt source is actually cleared. Therefore, it is recommended that the interrupt source be cleared early in the interrupt handler (as opposed to the very last action) to avoid returning from the interrupt handler before the interrupt source is actually cleared. Failure to do so may result in the interrupt handler being immediately reentered (because the interrupt controller still sees the interrupt source asserted).
Returns
None.
void HibernateIntDisable ( uint32_t  ui32IntFlags)

Disables interrupts for the Hibernation module.

Parameters
ui32IntFlagsis the bit mask of the interrupts to be disabled.

This function disables the specified interrupt sources from the Hibernation module.

The ui32IntFlags parameter has the same definition as the ui32IntFlags parameter to the HibernateIntEnable() function.

Returns
None.
void HibernateIntEnable ( uint32_t  ui32IntFlags)

Enables interrupts for the Hibernation module.

Parameters
ui32IntFlagsis the bit mask of the interrupts to be enabled.

This function enables the specified interrupt sources from the Hibernation module.

The ui32IntFlags parameter must be the logical OR of any combination of the following:

  • HIBERNATE_INT_WR_COMPLETE - write complete interrupt
  • HIBERNATE_INT_PIN_WAKE - wake from pin interrupt
  • HIBERNATE_INT_LOW_BAT - low-battery interrupt
  • HIBERNATE_INT_RTC_MATCH_0 - RTC match 0 interrupt
Returns
None.
void HibernateIntRegister ( void(*)(void)  pfnHandler)

Registers an interrupt handler for the Hibernation module interrupt.

Parameters
pfnHandlerpoints to the function to be called when a hibernation interrupt occurs.

This function registers the interrupt handler in the system interrupt controller. The interrupt is enabled at the global level, but individual interrupt sources must still be enabled with a call to HibernateIntEnable().

See also
IntRegister() for important information about registering interrupt handlers.
Returns
None.
uint32_t HibernateIntStatus ( bool  bMasked)

Gets the current interrupt status of the Hibernation module.

Parameters
bMaskedis false to retrieve the raw interrupt status, and true to retrieve the masked interrupt status.

This function returns the interrupt status of the Hibernation module. The caller can use this function to determine the cause of a hibernation interrupt. Either the masked or raw interrupt status can be returned.

Returns
Returns the interrupt status as a bit field with the values as described in the HibernateIntEnable() function.
void HibernateIntUnregister ( void  )

Unregisters an interrupt handler for the Hibernation module interrupt.

This function unregisters the interrupt handler in the system interrupt controller. The interrupt is disabled at the global level, and the interrupt handler is no longer called.

See also
IntRegister() for important information about registering interrupt handlers.
Returns
None.
uint32_t HibernateIsActive ( void  )

Checks to see if the Hibernation module is already powered up.

This function queries the control register to determine if the module is already active. This function can be called at a power-on reset to help determine if the reset is due to a wake from hibernation or a cold start. If the Hibernation module is already active, then it does not need to be re-enabled, and its status can be queried immediately.

The software application should also use the HibernateIntStatus() function to read the raw interrupt status to determine the cause of the wake. The HibernateDataGet() function can be used to restore state. These combinations of functions can be used by the software to determine if the processor is waking from hibernation and the appropriate action to take as a result.

Returns
Returns true if the module is already active, and false if not.
uint32_t HibernateLowBatGet ( void  )

Gets the currently configured low-battery detection behavior.

This function returns a value representing the currently configured low battery detection behavior.

The return value is a combination of the values described in the HibernateLowBatSet() function.

Returns
Returns a value indicating the configured low-battery detection.
void HibernateLowBatSet ( uint32_t  ui32LowBatFlags)

Configures the low-battery detection.

Parameters
ui32LowBatFlagsspecifies behavior of low-battery detection.

This function enables the low-battery detection and whether hibernation is allowed if a low battery is detected. If low-battery detection is enabled, then a low-battery condition is indicated in the raw interrupt status register, which can be enabled to trigger an interrupt. Optionally, hibernation can be aborted if a low battery condition is detected.

The ui32LowBatFlags parameter is one of the following values:

  • HIBERNATE_LOW_BAT_DETECT - detect a low-battery condition
  • HIBERNATE_LOW_BAT_ABORT - detect a low-battery condition and abort hibernation if low-battery is detected

The other setting in the ui32LowBatFlags allows the caller to set one of the following voltage level trigger values :

  • HIBERNATE_LOW_BAT_1_9V - voltage low level is 1.9 V
  • HIBERNATE_LOW_BAT_2_1V - voltage low level is 2.1 V
  • HIBERNATE_LOW_BAT_2_3V - voltage low level is 2.3 V
  • HIBERNATE_LOW_BAT_2_5V - voltage low level is 2.5 V

Example: Abort hibernate if the voltage level is below 2.1 V.

//! HibernateLowBatSet(HIBERNATE_LOW_BAT_ABORT | HIBERNATE_LOW_BAT_2_1V);
//! 
\return None.  
void HibernateRequest ( void  )

Requests hibernation mode.

This function requests the Hibernation module to disable the external regulator, thus removing power from the processor and all peripherals. The Hibernation module remains powered from the battery or auxiliary power supply.

The Hibernation module re-enables the external regulator when one of the configured wake conditions occurs (such as RTC match or external WAKE pin). When the power is restored, the processor goes through a power-on reset although the Hibernation module is not reset. The processor can retrieve saved state information with the HibernateDataGet() function. Prior to calling the function to request hibernation mode, the conditions for waking must have already been set by using the HibernateWakeSet() function.

Note that this function may return because some time may elapse before the power is actually removed, or it may not be removed at all. For this reason, the processor continues to execute instructions for some time, and the caller should be prepared for this function to return. There are various reasons why the power may not be removed. For example, if the HibernateLowBatSet() function was used to configure an abort if low battery is detected, then the power is not removed if the battery voltage is too low. There may be other reasons related to the external circuit design, that a request for hibernation may not actually occur.

For all these reasons, the caller must be prepared for this function to return. The simplest way to handle it is to just enter an infinite loop and wait for the power to be removed.

Returns
None.
void HibernateRTCDisable ( void  )

Disables the RTC feature of the Hibernation module.

This function disables the RTC in the Hibernation module. After calling this function, the RTC features of the Hibernation module are not available.

Returns
None.
void HibernateRTCEnable ( void  )

Enables the RTC feature of the Hibernation module.

This function enables the RTC in the Hibernation module. The RTC can be used to wake the processor from hibernation at a certain time, or to generate interrupts at certain times. This function must be called before using any of the RTC features of the Hibernation module.

Returns
None.
uint32_t HibernateRTCGet ( void  )

Gets the value of the real time clock (RTC) counter.

This function gets the value of the RTC and returns it to the caller.

Returns
Returns the value of the RTC counter in seconds.
uint32_t HibernateRTCMatchGet ( uint32_t  ui32Match)

Gets the value of the requested RTC match register.

Parameters
ui32Matchis the index of the match register.

This function gets the value of the match register for the RTC. The only value that can be used with the ui32Match parameter is zero, other values are reserved for future use.

Returns
Returns the value of the requested match register.
void HibernateRTCMatchSet ( uint32_t  ui32Match,
uint32_t  ui32Value 
)

Sets the value of the RTC match register.

Parameters
ui32Matchis the index of the match register.
ui32Valueis the value for the match register.

This function sets a match register for the RTC. The Hibernation module can be configured to wake from hibernation, and/or generate an interrupt when the value of the RTC counter is the same as the match register.

Returns
None.
void HibernateRTCSet ( uint32_t  ui32RTCValue)

Sets the value of the real time clock (RTC) counter.

Parameters
ui32RTCValueis the new value for the RTC.

This function sets the value of the RTC. The RTC counter contains the count in seconds when a 32.768kHz clock source is in use. The RTC must be enabled by calling HibernateRTCEnable() before calling this function.

Returns
None.
uint32_t HibernateRTCSSGet ( void  )

Returns the current value of the RTC sub second count.

This function returns the current value of the sub second count for the RTC in 1/32768 of a second increments. The only value that can be used with the ui32Match parameter is zero, other values are reserved for future use.

Returns
The current RTC sub second count in 1/32768 seconds.
uint32_t HibernateRTCSSMatchGet ( uint32_t  ui32Match)

Returns the value of the requested RTC sub second match register.

Parameters
ui32Matchis the index of the match register.

This function returns the current value of the sub second match register for the RTC. The value returned is in 1/32768 second increments. The only value that can be used with the ui32Match parameter is zero, other values are reserved for future use.

Returns
Returns the value of the requested sub section match register.
void HibernateRTCSSMatchSet ( uint32_t  ui32Match,
uint32_t  ui32Value 
)

Sets the value of the RTC sub second match register.

Parameters
ui32Matchis the index of the match register.
ui32Valueis the value for the sub second match register.

This function sets the sub second match register for the RTC in 1/32768 of a second increments. The Hibernation module can be configured to wake from hibernation, and/or generate an interrupt when the value of the RTC counter is the same as the match combined with the sub second match register. The only value that can be used with the ui32Match parameter is zero, other values are reserved for future use.

Returns
None.
uint32_t HibernateRTCTrimGet ( void  )

Gets the value of the RTC pre-divider trim register.

This function gets the value of the pre-divider trim register. This function can be used to get the current value of the trim register prior to making an adjustment by using the HibernateRTCTrimSet() function.

Returns
None.
void HibernateRTCTrimSet ( uint32_t  ui32Trim)

Sets the value of the RTC pre-divider trim register.

Parameters
ui32Trimis the new value for the pre-divider trim register.

This function sets the value of the pre-divider trim register. The input time source is divided by the pre-divider to achieve a one-second clock rate. Once every 64 seconds, the value of the pre-divider trim register is applied to the pre-divider to allow fine-tuning of the RTC rate, in order to make corrections to the rate. The software application can make adjustments to the pre-divider trim register to account for variations in the accuracy of the input time source. The nominal value is 0x7FFF, and it can be adjusted up or down in order to fine-tune the RTC rate.

Returns
None.
uint32_t HibernateWakeGet ( void  )

Gets the currently configured wake conditions for the Hibernation module.

This function returns the flags representing the wake configuration for the Hibernation module. The return value is a combination of the following flags:

  • HIBERNATE_WAKE_PIN - wake when the external wake pin is asserted
  • HIBERNATE_WAKE_RTC - wake when the RTC matches occurs
  • HIBERNATE_WAKE_LOW_BAT - wake from hibernation due to a low-battery level being detected
Note
The HIBERNATE_WAKE_LOW_BAT parameter is only available on some Tiva devices.
Returns
Returns flags indicating the configured wake conditions.
void HibernateWakeSet ( uint32_t  ui32WakeFlags)

Configures the wake conditions for the Hibernation module.

Parameters
ui32WakeFlagsspecifies which conditions should be used for waking.

This function enables the conditions under which the Hibernation module wakes. The ui32WakeFlags parameter is the logical OR of any combination of the following:

  • HIBERNATE_WAKE_PIN - wake when the external wake pin is asserted.
  • HIBERNATE_WAKE_RTC - wake when the RTC match occurs.
  • HIBERNATE_WAKE_LOW_BAT - wake from hibernate due to a low-battery level being detected.
Returns
None.