FreeRTOS: Common I/O
AWS IoT Common I/O library
Return to main page ↑
iot_power.h File Reference

This file contains all the Power HAL API definitions. More...

#include <stdbool.h>
#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  IotPowerWakeupSources_t
 Wakeup source information. More...
 

Macros

#define IOT_POWER_SUCCESS   ( 0 )
 Return values used by the driver. More...
 
#define IOT_POWER_INVALID_VALUE   ( 1 )
 
#define IOT_POWER_NOT_INITIALIZED   ( 2 )
 
#define IOT_POWER_GET_FAILED   ( 3 )
 
#define IOT_POWER_SET_FAILED   ( 4 )
 
#define IOT_POWER_FUNCTION_NOT_SUPPORTED   ( 5 )
 

Typedefs

typedef struct IotPowerDescriptor * IotPowerHandle_t
 IotPowerHandle_t type is the power handle returned by calling iot_power_open() this is initialized in open and returned to caller. Caller must pass this pointer to the rest of the APIs.
 
typedef void(* IotPowerCallback_t) (bool bIdleState, void *pvUserContext)
 This callback type is used to set a callback for idle enter and exit notification callback type. This callback is used for notifying the registered caller(s) before entering and after coming out of target low power state (i,e:idle/sleep). bIdleState is used to let the caller know if the callback is called when entering or exiting the low power mode. "true" indicates that target is entering idle and "false" indicates that its exiting. The callback is not used for any other mode transitions which are synchronous and blocking. For example when the caller calls a set_mode to eHighPerfMode, the mode is set in the same context and the call is blocking. More...
 

Enumerations

enum  IotPowerMode_t { eHighPowerPerfMode, eNormalPowerPerfMode, eLowPowerPerfMode, eUnknownPowerMode = 0xFFFF }
 Power modes supported by the driver. These power modes may perform different actions on different platforms based on the underlying HW support. More...
 
enum  IotPowerIdleMode_t { eIdleNoneMode, eIdlePCMode, eIdleClkSrcOffModeMode, eIdleVddOffMode }
 Different Idle mode mappings to the threshold values set using the IOCTLs. More...
 
enum  IotPowerIoctlRequest_t {
  eSetPCWakeThreshold, eGetPCWakeThreshold, eSetClkSrcOffWakeThreshold, eGetClkSrcOffWakeThreshold,
  eSetVddOfffWakeThreshold, eGetVddOfffWakeThreshold, eSetWakeupSources, eGetWakeupSources,
  eGetLastIdleMode
}
 Ioctl request types. More...
 

Functions

IotPowerHandle_t iot_power_open (void)
 iot_power_open is used to Initialize the CPU power management driver. power_open sets up the default mode to eNomralMode, so when the power_open is called, the caller must set the mode using set_mode to a specific mode of interest. More...
 
int32_t iot_power_set_mode (IotPowerHandle_t const pxPowerHandle, IotPowerMode_t xMode)
 iot_power_set_mode is used to set or change the power mode to a specific mode. The actual changes made as part of switching to a specific power mode are platform specific. When set_mode is called to switch from high mode to low mode, the target may go through several steps to enter low performance mode. The aggregation of switching to a particular mode must be made prior to calling this, as a call to this API may change the CPU frequency and voltage which may affect the software execution. This API is blocking and the mode switched in the same context as the caller and is a blocking call. More...
 
int32_t iot_power_reset_mode (IotPowerHandle_t const pxPowerHandle)
 iot_power_reset_mode is used to reset the mode (i,e remove the vote to set mode). When reset mode is called, its implicitly notifying the OS to enter deepest low power mode possible in idle state based on existing timers. If a set_mode is called with any of the performance modes with out calling reset_mode, then when target enters idle state, it will not be able to enter deep power states since there is an existing vote for a performance mode from the caller. The target will still do clock gating of the core by doing a WFI and WFE. Additionally, if a reset_mode is called, followed by a get_mode, eUnKnownMode will be returned to the caller. But if reset_mode is called, and then target enters idle state, when coming out of the idle_state it will resume to a known previous state. For example, if we take the following flow: More...
 
void iot_power_set_callback (IotPowerHandle_t const pxPowerHandle, IotPowerCallback_t xCallback, void *pvUserContext)
 iot_power_set_callback is used to set the callback to be called when the target is entering low power mode, and when target is coming out of low power mode. Callback must not use any HW resources when this callback is called with out first requesting for a performance mode. More...
 
int32_t iot_power_ioctl (IotPowerHandle_t const pxPowerHandle, IotPowerIoctlRequest_t xRequest, void *const pvBuffer)
 iot_power_ioctl is used to set power configuration and power properties like Wakeup time thresholds. Supported IOCTL requests are defined in iot_PowerIoctlRequest_t More...
 
int32_t iot_power_get_mode (IotPowerHandle_t const pxPowerHandle, IotPowerMode_t *xMode)
 iot_power_get_mode is used to get the current power mode the target is in. More...
 
int32_t iot_power_close (IotPowerHandle_t const pxPowerHandle)
 iot_power_close is used to de-initialize power driver. More...
 

Detailed Description

This file contains all the Power HAL API definitions.