MT7697 API Reference  LinkIt SDK v4
SLEEP_MANAGER

This section introduces the Sleep Manager driver APIs including terms and acronyms, supported features, software architecture, details on how to use this driver, Sleep Manager function groups, enums, structures and functions. More...

Overview

This section introduces the Sleep Manager driver APIs including terms and acronyms, supported features, software architecture, details on how to use this driver, Sleep Manager function groups, enums, structures and functions.

Terms and acronyms

Terms Details
Sleep Set the CPU and related modules to Sleep mode to save power consumption and extend the battery life.
Sleep Lock The Sleep Lock mechanism prevents the device to enter Sleep mode when required.

Supported features

Software architecture of the Sleep Manager

Call hal_sleep_manager_init() to initialize the hardware before using the Sleep Manager APIs to control the sleep behavior of the device.

For more information about Sleep Mode, please refer hal_sleep_mode_t.

hal_sleep_manager_arch.png

How to use this driver

Functions

hal_sleep_manager_status_t hal_sleep_manager_init (void)
 This function initializes the Sleep Manager. More...
 
uint8_t hal_sleep_manager_set_sleep_handle (const char *handle_name)
 This function sets up a sleep handle to control the sleep state of the system. More...
 
hal_sleep_manager_status_t hal_sleep_manager_lock_sleep (uint8_t handle_index)
 This function prevents the MCU from getting into sleep mode. More...
 
hal_sleep_manager_status_t hal_sleep_manager_unlock_sleep (uint8_t handle_index)
 This function unlocks the specific Sleep Lock and permits the MCU going into sleep mode when needed if all Sleep Locks are unlocked. More...
 
hal_sleep_manager_status_t hal_sleep_manager_release_sleep_handle (uint8_t handle_index)
 This function releases the sleep handle if it is no longer in use. More...
 
uint32_t hal_sleep_manager_get_lock_status (void)
 The sleep lock status is represented by an unsigned integer (uint32_t). More...
 
bool hal_sleep_manager_is_sleep_locked (void)
 This function checks if there are any Sleep Locks in the system. More...
 
bool hal_sleep_manager_is_sleep_handle_alive (uint8_t handle_index)
 This function checks whether the sleep handle is still alive. More...
 
hal_sleep_manager_status_t hal_sleep_manager_set_sleep_time (uint32_t sleep_time_ms)
 Set sleep(suspend) time length. More...
 
void hal_sleep_manager_enter_sleep_mode (hal_sleep_mode_t mode)
 This function sets the system to any of the modes defined in hal_sleep_mode_t. More...
 

Modules

 Enum
 

Function Documentation

void hal_sleep_manager_enter_sleep_mode ( hal_sleep_mode_t  mode)

This function sets the system to any of the modes defined in hal_sleep_mode_t.

Parameters
[in]modeis the desired sleep mode.
uint32_t hal_sleep_manager_get_lock_status ( void  )

The sleep lock status is represented by an unsigned integer (uint32_t).

Each sleep handle corresponds to a bit position in this unsigned integer. If the sleep handle index is 5, for example, the value at the 5th bit position of this unsigned integer represents the status of the sleep handle of index 5. If the value of the 5th bit is 1, it indicates that the sleep handle with index 5 is currently holding the sleep lock.

Returns
If handle_index's corresponding bit is 1, indicates this handle_index is holding a Sleep Lock.
Note
Call hal_sleep_manager_set_sleep_handle() to set up the sleep handle, before calling this function.
hal_sleep_manager_status_t hal_sleep_manager_init ( void  )

This function initializes the Sleep Manager.

Returns
HAL_SLEEP_MANAGER_OK, if this function completed successfully.
bool hal_sleep_manager_is_sleep_handle_alive ( uint8_t  handle_index)

This function checks whether the sleep handle is still alive.

If it is alive, it means that the system still can be controled by this sleep handle.

Parameters
[in]handle_indexis the sleep handle index returned from hal_sleep_manager_set_sleep_handle().
Returns
True, if the sleep is locked by the sleep handle. False, if the sleep is not locked by this sleep handle.
bool hal_sleep_manager_is_sleep_locked ( void  )

This function checks if there are any Sleep Locks in the system.

Apply it before entering the sleep mode.

Returns
True if any locks are on hold.
hal_sleep_manager_status_t hal_sleep_manager_lock_sleep ( uint8_t  handle_index)

This function prevents the MCU from getting into sleep mode.

Parameters
[in]handle_indexis the sleep handle index, returned from hal_sleep_manager_set_sleep_handle().
Returns
HAL_SLEEP_MANAGER_OK, Sleep Lock is locked.
Note
Call hal_sleep_manager_set_sleep_handle() to set up the sleep handle, before calling this function.
hal_sleep_manager_status_t hal_sleep_manager_release_sleep_handle ( uint8_t  handle_index)

This function releases the sleep handle if it is no longer in use.


Parameters
[in]handle_indexis the sleep handle index returned from hal_sleep_manager_set_sleep_handle().
Returns
HAL_SLEEP_MANAGER_OK, if this function completed successfully.
Note
Call hal_sleep_manager_set_sleep_handle() to set up the sleep handle, before calling this function.
uint8_t hal_sleep_manager_set_sleep_handle ( const char *  handle_name)

This function sets up a sleep handle to control the sleep state of the system.


This handle enables the Sleep Manager to identify the sleep states based on the sleep handles assigned.

Parameters
[in]handle_nameis the name of the sleep handle of type string.
Returns
The sleep handle index, if the operation is successful. If (0xFF) is returned, the operation failed.
hal_sleep_manager_status_t hal_sleep_manager_set_sleep_time ( uint32_t  sleep_time_ms)

Set sleep(suspend) time length.

If no other wake up event occurs, the system will sleep for a specific time.

Parameters
[in]sleep_time_msis time duration in milliseconds.
Returns
return HAL_SLEEP_MANAGER_OK, if supported.
Note
This api only use in non os environment
hal_sleep_manager_status_t hal_sleep_manager_unlock_sleep ( uint8_t  handle_index)

This function unlocks the specific Sleep Lock and permits the MCU going into sleep mode when needed if all Sleep Locks are unlocked.

Parameters
[in]handle_indexis the sleep handle index returned from hal_sleep_manager_set_sleep_handle().
Returns
HAL_SLEEP_MANAGER_OK, sleep lock is unlocked.
Note
Call hal_sleep_manager_set_sleep_handle() to set up the sleep handle, before calling this function.