IPowerSubSystem

class

Abstract interface for the power sub-system. It defines 3 basic methods related to reset, enter sleep and exit sleep modes.

This interface is sub-classed by implementations of the different power supply IC’s on mono or an emulator.

Subclasses of this interface should only conduct routines related to a power sub-system - not to any CPU specific operations! This means setting up voltage levels and enabling power fencing to peripherals.

This power supply sub-system interface also defines callbacks that are called then the battery events occur. These are:

  • Battery low warning

You can listen to these events by supplying a callback handler function

Power to MCU internal modules are controller by the abstract interface for power management IPowerManagement

Public Types

enum type mono::power::IPowerSubSystem::ChargeState

Battery charing states

See
ChargeStatus

Values:

Chip does not support charging or dont disclore it

Charging has just begun (pre-condition)

Fast Charging in constant current mode

Slower charging, in Constant Voltage mode

Charge ended of cycle, battery is full

No battery attached or wrong battery voltage levels

Public Functions

virtual void mono::power::IPowerSubSystem::onSystemPowerOnReset()
= 0

Called by the application as first thing after power-on or system reset.

The function must set up the default power configuration of the system, peripherals, voltages etc.

virtual void mono::power::IPowerSubSystem::onSystemEnterSleep()
= 0

Called before the system enter a sleep mode, where the CPU is not excuting instructions. To enable the lowest possible power consumption subclasses can turn off selected periphrals here.

virtual void mono::power::IPowerSubSystem::onSystemWakeFromSleep()
= 0

Called after the system has woken from a sleep mode. This is only called after an call to onSystemEnterSleep has occured. Use this method to turn on any disabled peripheral.

virtual bool mono::power::IPowerSubSystem::IsPowerFenced()

Return the current status of the Power Fence.

The power fence cuts power to specific peripherals. Each peripheral driver should know whether or not it is behind the fence.

Return
true if the power fence is active (power is not present), false if power is ON.

virtual void mono::power::IPowerSubSystem::setPowerFence(bool active)

Turn on/off the power fence.

Some peripherals are behind a power fence, that can cut their power. You can control this power, and remove their supply upon going to sleep mode, to safe battery.

Parameters
  • active -

    true will cut the power, false will power the peripherals

virtual ChargeState mono::power::IPowerSubSystem::ChargeStatus()

Get the current charge status for the attached battery.

The Subsystem implememtation might be able to monitor the current charging state of the battery. If no battery exists the state will be SUSPENDED. If the implementation does not support charge states this method will always return UNKNOWN.

The different states is explained by the ChargeState enum.

Return
The current charge state integer
See
ChargeState

virtual bool mono::power::IPowerSubSystem::IsUSBCharging()

Get the USB charging state (True if charging now)

This methods default implementation uses the ChargeStatus method to check the CHARGE_* enum and true if it is not SUSPENDED or UNKNOWN.

PowerSubsystem subclasses might override this method do their own checks.

virtual bool mono::power::IPowerSubSystem::IsPowerOk()
= 0

Return true is the battery voltage is OK, false is empty.

This method query the system power state, to see if the battery is OK. In case this return , the system should enter low-power sleep immediately!

Public Members

mbed::FunctionPointer mono::power::IPowerSubSystem::BatteryLowHandler

Function handler that must be called when the PowerSystem detect low battery

mbed::FunctionPointer mono::power::IPowerSubSystem::BatteryEmptyHandler

Function handler that must be called when battery is empty