Power Manager API Reference#
This section provides an overview of the callback and notification mechanisms available in the Power Manager Service for Silicon Labs SiWx917 devices. These APIs enable applications to respond to power-state transitions and wakeup events, allowing for efficient and responsive power management.
For detailed API documentation, see the official reference: API Guide: Power Manager Service for Silicon Labs SiWx917
Callback and Notification APIs#
The Power Manager Service supports two primary types of callbacks:
Transition callbacks: Triggered during power-state changes.
Wakeup source callbacks: Triggered when the system wakes from sleep due to specific wakeup sources.
These callbacks let applications monitor and respond to system power events in real time.
Transition Callbacks for Power-State Changes#
Transition callbacks notify the application when the system enters or exits specific power states, letting developers perform tasks such as saving system state, reconfiguring peripherals, or logging transitions.
Overview#
The Power Manager exposes a set of transition events. Applications can register handlers for these events by using the subscription API. These handlers are invoked automatically during power-state transitions.
Callback Function Definition#
typedef void (*sl_power_manager_ps_transition_event_handle_t)(
sl_power_state_t from,
sl_power_state_t to
);sl_power_state_t: Represents the system power state.from: The power state the system is transitioning from.to: The power state the system is transitioning to.
Example Callback Implementation#
void my_power_transition_handler(sl_power_state_t from, sl_power_state_t to) {
if (to == SL_SI91X_POWER_MANAGER_PS2) {
// Transitioning to PS2: eg: Configure ULP peripherals
} else if (from == SL_SI91X_POWER_MANAGER_PS2) {
// Transitioning from PS2: eg: Configure HP peripherals
}
}Available Transition Events#
Entering power states:
SL_SI91X_POWER_MANAGER_EVENT_TRANSITION_ENTERING_PS4SL_SI91X_POWER_MANAGER_EVENT_TRANSITION_ENTERING_PS3SL_SI91X_POWER_MANAGER_EVENT_TRANSITION_ENTERING_PS2
Leaving power states:
SL_SI91X_POWER_MANAGER_EVENT_TRANSITION_LEAVING_PS4SL_SI91X_POWER_MANAGER_EVENT_TRANSITION_LEAVING_PS3SL_SI91X_POWER_MANAGER_EVENT_TRANSITION_LEAVING_PS2SL_SI91X_POWER_MANAGER_EVENT_TRANSITION_LEAVING_PS1SL_SI91X_POWER_MANAGER_EVENT_TRANSITION_LEAVING_SLEEPSL_SI91X_POWER_MANAGER_EVENT_TRANSITION_LEAVING_STANDBY
Registering a Transition Callback#
Use the following API to subscribe to transition events:
sl_status_t sl_si91x_power_manager_subscribe_ps_transition_event(
sl_power_manager_ps_transition_event_handle_t *event_handle,
const sl_power_manager_ps_transition_event_info_t *event_info);Example:
void setup_transition_callback(void)
{
sl_power_manager_ps_transition_event_handle_t event_handle;
sl_power_manager_ps_transition_event_info_t event_info = {
.event_mask = SL_SI91X_POWER_MANAGER_EVENT_TRANSITION_ENTERING_PS2 |
SL_SI91X_POWER_MANAGER_EVENT_TRANSITION_LEAVING_PS2,
.on_event = my_power_transition_handler
};
sl_si91x_power_manager_subscribe_ps_transition_event(&event_handle, &event_info);
}Unsubscribing from Transition Callbacks#
void cleanup_transition_callbacks(sl_power_manager_ps_transition_event_handle_t *handle)
{
sl_si91x_power_manager_unsubscribe_ps_transition_event(handle);
}Wakeup Source Callbacks#
Wakeup source callbacks are triggered when the system wakes from sleep due to a configured source, such as GPIO (general-purpose input/output), calendar alarms, or timers. These callbacks are automatically registered when the wakeup source is configured by using the Universal Configurator (UC).
Overview#
Each wakeup source has a corresponding callback function. These functions let the application resume operations, process input, or handle time-based events after waking from sleep.
Example Callback Implementations#
// GPIO wakeup callback
void gpio_uulp_pin_interrupt_callback(void)
{
// Handle GPIO-triggered wakeup
// Check GPIO pin states, process input
}
// Calendar alarm wakeup callback
void calendar_alarm_callback_function(void)
{
// Handle calendar alarm-triggered wakeup
// Resume scheduled tasks, process time-based events
}
// Calendar second callback
void calendar_second_callback_function(void)
{
// Handle calendar second tick
// Update time displays, time-based operations
}
// Deep Sleep Timer callback
void dst_callback_function(void)
{
// Handle Deep Sleep Timer wakeup
// Resume scheduled tasks, update time-based operations
}Integration#
To use these callbacks:
Define the callback function in your application.
Configure the wakeup source by using UC.
The Power Manager automatically registers the callback.
Example:
void dst_callback_function(void)
{
// Perform application-specific processing
// Resume scheduled tasks, update time-based operations
}Ensure that all callback functions follow the correct signature and are defined before configuring the wakeup source.