ale_axp209 v0.2.0 AleAXP209

This module helps communicating with the AXP209 PMIC. This Power Management IC is mounted on the C.H.I.P. embedded computers. Make sure you start this Module as an Application to make it work. It will also monitor the state of the PMIC in background and allows to register for changes (not yet implemented!).

Changes in the power state are reported to Logger.

Summary

Functions

Reads the current charge current (current going into the battery) in mA

Reads the current discharge current (current comming out of the battery) in mA

Reads a pair of registers and returns the content as number. It uses 8 bits from the first register as MSB and the last 4 bits from the next register. This encoding is often used on this PMIC. Value returned as a number

Reads a register and returns the content as number

Returns a map describing the state of the power system. The result is a map like this

Sets the current input limit - how much power we’re allowed to take from USB

Functions

charge_current()

Reads the current charge current (current going into the battery) in mA.

discharge_current()

Reads the current discharge current (current comming out of the battery) in mA.

read_dreg(addr)

Reads a pair of registers and returns the content as number. It uses 8 bits from the first register as MSB and the last 4 bits from the next register. This encoding is often used on this PMIC. Value returned as a number.

read_reg(addr)

Reads a register and returns the content as number.

read_state()

Returns a map describing the state of the power system. The result is a map like this:

%{
  battery: true,         # Battery is connected
  battery_voltage: 4161, # Battery voltage in mV
  charging: false,       # Not charging
  over_temp: false,      # Temperature of PMIC is good
  usb_power: true        # USB Power is connected
 }
setCurrentLimit(limit)

Sets the current input limit - how much power we’re allowed to take from USB.