PowerManagementClass Class

PowerManagementClass Class

Description
A class used for managing the low-power operation of Ameba.

Syntax
class PowerManagementClass

Members

Public Constructors 
A public constructor should not be used as this class is intended to be a singleton class.
Access member functions using the object instance named power management.
Public Methods 
PowerManagementClass::sleepAllow OS to automatically save power while idle.
PowerManagementClass::activeDisallow OS to automatically save power while idle.
PowerManagementClass::setPllReservedReserved Phase Locked Loop (PLL) while sleeping.
PowerManagementClass::deepsleepEnter deepsleep immediately.
PowerManagementClass::safeLockCheck if the system allows any power-saving state.
PowerManagementClass::setSafeLockPinSet pin to be used to control power save state.
PowerManagementClass::softResetReboot system in a soft way.

PowerManagementClass::sleep

Description
Allow OS to automatically save power while idle.

Syntax
void sleep(void);

Parameters
NA

Returns
NA

Example Code
Example: SleepBasic
(https://github.com/ambiot/amb1_arduino/blob/dev/Arduino_package/hardware/libraries/PowerSave/examples/SleepBasic/SleepBasic.ino)

Notes and Warnings
OS will invoke the system suspend if it anticipates an idle duration of more than 2 seconds. “PowerManagement.h” must be included to use the class function.

PowerManagementClass::active

Description
Disallow OS to automatically save power while idle.

Syntax
void active(void);

Parameters
NA

Returns
NA

Example Code
NA

Notes and Warnings
“PowerManagement.h” must be included to use the class function.

PowerManagementClass::setPllReserved

Description
Reserved Phase Locked Loop (PLL) while sleeping.

Syntax
void setPllReserved(bool reserve);

Parameters
reserve: true- reserve PLL, false- PLL is not reserved.

Returns
NA

Example Code
Example: SleepBasic
(https://github.com/ambiot/amb1_arduino/blob/dev/Arduino_package/hardware/libraries/PowerSave/examples/SleepBasic/SleepBasic.ino)

Notes and Warnings
Reserving PLL would keep the FIFO of peripherals enabled (e.g. UART) during sleep but would require more power. Not reserving PLL might lead to missing data due to disabled FIFO. “PowerManagement.h” must be included to use the class function.

PowerManagementClass::deepsleep

Description
Enter deepsleep immediately.

Syntax
void deepsleep(uint32_t duration_ms);

Parameters
duration_ms: duration to enter deepsleep, expressed in milliseconds.

Returns
NA

Example Code
Example: DeepSleepBasic
(https://github.com/ambiot/amb1_arduino/blob/dev/Arduino_package/hardware/libraries/PowerSave/examples/DeepSleepBasic/DeepSleepBasic.ino)

Notes and Warnings
Deepsleep is the power state that uses the least power. When the system wakes from deepsleep, the code behaves like after a reset. “PowerManagement.h” must be included to use the class function.

PowerManagementClass::safeLock

Description
Check if the system allows any power-saving state.

Syntax
bool safeLock(void);

Parameters
NA

Returns
This function returns true if the system is not allowed to enter power save state.

Example Code
Example: DeepSleepWithDHTUdp
(https://github.com/ambiot/amb1_arduino/blob/dev/Arduino_package/hardware/libraries/PowerSave/examples/DeepSleepWithDHTUdp/DeepSleepWithDHTUdp.ino)

Notes and Warnings
A pin can be set as a safety lock pin. If the safety lock pin is High, Ameba is prevented from entering any power save state. “PowerManagement.h” must be included to use the class function.

PowerManagementClass::setSafeLockPin

Description
Set pin to be used to control power save state.

Syntax
bool setSafeLockPin(int ulPin);

Parameters
ulPin: Pin to use as safe lock pin.

Returns
This function returns true if the pin is valid, else return false.

Example Code
NA

Notes and Warnings
This function is used to change the default safe lock pin and needs to be called on every reset. “PowerManagement.h” must be included to use the class function.

PowerManagementClass::softReset

Description
Reboot system in a soft way. Some registers is not powered off in this case but it is still regards as a reboot.

Syntax
void softReset(void);

Parameters
NA

Returns
NA

Example Code
NA

Notes and Warnings
“PowerManagement.h” must be included to use the class function.

Please confirm that QQ communication software is installed
請先確認已安裝QQ通訊軟體