Core2 for AWS IoT EduKit BSP 1.5.1
Macros | Functions
axp192.c File Reference
#include "axp192.h"
#include "axp192_i2c.h"
#include "stdio.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"

Macros

#define VALUE_LIMIT(x, min, max)   (((x) < min) ? min : (((x) > max) ? max : (x)))
 

Functions

void Axp192_Init ()
 Initializes the AXP192 over I2C. More...
 
void Axp192_EnableLDODCExt (uint8_t value)
 Extends the DC voltage range of the Low-Dropout regulator (LDO) on the AXP192. More...
 
void Axp192_EnableExten (uint8_t state)
 Enables or disables extending the Low-Dropout (LDO) voltage on the AXP192. More...
 
void Axp192_EnableLDO2 (uint8_t state)
 Enables or disables Low-Dropout (LDO) 2 on the AXP192. More...
 
void Axp192_EnableLDO3 (uint8_t state)
 Enables or disables Low-Dropout (LDO) 3 on the AXP192. More...
 
void Axp192_EnableDCDC1 (uint8_t state)
 Enables or disables DC/DC 1 Buck Boost converter on the AXP192. More...
 
void Axp192_EnableDCDC2 (uint8_t state)
 Enables or disables DC/DC 2 Buck Boost converter on the AXP192. More...
 
void Axp192_EnableDCDC3 (uint8_t state)
 Enables or disables DC/DC 3 Buck Boost converter. More...
 
void Axp192_SetLDO23Volt (uint16_t ldo2_voltage, uint16_t ldo3_voltage)
 Set both LDO 2 and LDO 3 voltage on the AXP192. More...
 
void Axp192_SetLDO2Volt (uint16_t voltage)
 Set the LDO 2 voltage on the AXP192. More...
 
void Axp192_SetLDO3Volt (uint16_t voltage)
 Set the Low-Dropout (LDO) 3 voltage on the AXP192. More...
 
void Axp192_SetDCDC1Volt (uint16_t voltage)
 Set the DC/DC 1 Buck Boost converter voltage on the AXP192. More...
 
void Axp192_SetDCDC2Volt (uint16_t voltage)
 Set the DC/DC 2 Buck Boost converter voltage on the AXP192. More...
 
void Axp192_SetDCDC3Volt (uint16_t voltage)
 Set the DC/DC 3 Buck Boost converter voltage on the AXP192. More...
 
void Axp192_SetVoffVolt (uint16_t voltage)
 Set the battery low-voltage to cut-off on the AXP192. More...
 
void Axp192_EnablePWRONShortWake ()
 Enable sleep and short wake mode on AXP192. More...
 
float Axp192_GetVbusVolt ()
 Gets VBUS voltage on the AXP192. More...
 
float Axp192_GetAcinVolt ()
 Gets ACIN voltage on the AXP192. More...
 
float Axp192_GetBatVolt ()
 Gets battery voltage on the AXP192. More...
 
float Axp192_GetVbusCurrent ()
 Gets VBUS current flowing through the AXP192. More...
 
float Axp192_GetAcinCurrent ()
 Gets ACIN current flowing through the AXP192. More...
 
float Axp192_GetBatCurrent ()
 Gets battery current flowing through the AXP192. More...
 
void Axp192_EnableCharge (uint16_t state)
 Enables or disables the battery charging circuit on the AXP192. More...
 
void Axp192_SetChargeVoltage (Axp192_ChargeVolt_t volt)
 Set the battery charge voltage on the AXP192. More...
 
void Axp192_SetChargeCurrent (Axp192_ChargeCurrent_t cur)
 Set the battery charge current on the AXP192. More...
 
void Axp192_SetSpareBatCharge (uint8_t enable, Axp192_SpareChargeVolt_t volt, Axp192_SpareChargeCurrent_t current)
 
void Axp192_GetApsVoltage ()
 
void Axp192_GetInternalTemp ()
 
void Axp192_SetAdc1Enable (uint8_t value)
 Enables or disables the ADC on the AXP192. More...
 
void Axp192_SetAdc2Enable ()
 
void Axp192_IsBatIn ()
 
void Axp192_IsCharging ()
 
void Axp192_PowerOff ()
 Powers down the device. More...
 
void Axp192_SetPressPoweroffTime (Axp192_PoweroffTime_t time)
 Sets how long the power button needs to be held to power off all components connected to the AXP192. More...
 
void Axp192_SetPressStartupTime (Axp192_StartupTime_t time)
 Sets how long the power button needs to be held to power on all components connected to the AXP192. More...
 
void Axp192_WriteDataStash ()
 
void Axp192_ReadDataStash ()
 
void Axp192_SetGPIO3Mode ()
 
void Axp192_SetGPIO0Mode (uint8_t mode)
 Sets the mode of GPIO 0 on the AXP192. More...
 
void Axp192_SetGPIO0Volt (uint16_t volt)
 Sets the voltage of GPIO 0 on the AXP192. More...
 
void Axp192_SetGPIO1Mode (uint8_t mode)
 Sets the mode of GPIO 1 on the AXP192. More...
 
void Axp192_SetGPIO1Level (uint8_t level)
 Sets the average voltage level of GPIO 1 on the AXP192 if the mode is set to PWM. More...
 
void Axp192_SetGPIO2Mode (uint8_t mode)
 Sets the mode of GPIO 2 on the AXP192. More...
 
void Axp192_SetGPIO2Level (uint8_t level)
 Sets the average voltage level of GPIO 2 on the AXP192 if the mode is set to PWM. More...
 
void Axp192_SetGPIO4Mode (uint8_t mode)
 Sets the mode of GPIO 4 on the AXP192 for charging control. More...
 
void Axp192_SetGPIO4Level (uint8_t level)
 Sets the signal status level of GPIO 4. More...
 

Macro Definition Documentation

◆ VALUE_LIMIT

#define VALUE_LIMIT (   x,
  min,
  max 
)    (((x) < min) ? min : (((x) > max) ? max : (x)))

Function Documentation

◆ Axp192_Init()

void Axp192_Init ( )

Initializes the AXP192 over I2C.

It is a wrapper to Axp192_I2CInit().

◆ Axp192_EnableLDODCExt()

void Axp192_EnableLDODCExt ( uint8_t  value)

Extends the DC voltage range of the Low-Dropout regulator (LDO) on the AXP192.

Parameters
[in]valueDesired voltage of the LDO.

◆ Axp192_EnableExten()

void Axp192_EnableExten ( uint8_t  state)

Enables or disables extending the Low-Dropout (LDO) voltage on the AXP192.

Parameters
[in]stateDesired state of LDO extention. 1 to enable, 0 to disable.

◆ Axp192_EnableLDO2()

void Axp192_EnableLDO2 ( uint8_t  state)

Enables or disables Low-Dropout (LDO) 2 on the AXP192.

Parameters
[in]stateDesired state of LDO 2. 1 to enable, 0 to disable.

◆ Axp192_EnableLDO3()

void Axp192_EnableLDO3 ( uint8_t  state)

Enables or disables Low-Dropout (LDO) 3 on the AXP192.

Parameters
[in]stateDesired state of LDO 3. 1 to enable, 0 to disable.

◆ Axp192_EnableDCDC1()

void Axp192_EnableDCDC1 ( uint8_t  state)

Enables or disables DC/DC 1 Buck Boost converter on the AXP192.

Parameters
[in]stateDesired state of DC/DC 1. 1 to enable, 0 to disable.

◆ Axp192_EnableDCDC2()

void Axp192_EnableDCDC2 ( uint8_t  state)

Enables or disables DC/DC 2 Buck Boost converter on the AXP192.

Parameters
[in]stateDesired state of DC/DC 2. 1 to enable, 0 to disable.

◆ Axp192_EnableDCDC3()

void Axp192_EnableDCDC3 ( uint8_t  state)

Enables or disables DC/DC 3 Buck Boost converter.

Parameters
[in]stateDesired state of DC/DC 3. 1 to enable, 0 to disable.

◆ Axp192_SetLDO23Volt()

void Axp192_SetLDO23Volt ( uint16_t  ldo2_voltage,
uint16_t  ldo3_voltage 
)

Set both LDO 2 and LDO 3 voltage on the AXP192.

Parameters
[in]ldo2_voltageDesired voltage of LDO 2.
[in]ldo3_voltageDesired voltage of LDO 3.

◆ Axp192_SetLDO2Volt()

void Axp192_SetLDO2Volt ( uint16_t  voltage)

Set the LDO 2 voltage on the AXP192.

Parameters
[in]voltageDesired voltage of LDO 2.

◆ Axp192_SetLDO3Volt()

void Axp192_SetLDO3Volt ( uint16_t  voltage)

Set the Low-Dropout (LDO) 3 voltage on the AXP192.

Parameters
[in]voltageDesired voltage of LDO 3.

◆ Axp192_SetDCDC1Volt()

void Axp192_SetDCDC1Volt ( uint16_t  voltage)

Set the DC/DC 1 Buck Boost converter voltage on the AXP192.

Parameters
[in]voltageDesired voltage of DC/DC 1.

◆ Axp192_SetDCDC2Volt()

void Axp192_SetDCDC2Volt ( uint16_t  voltage)

Set the DC/DC 2 Buck Boost converter voltage on the AXP192.

Parameters
[in]voltageDesired voltage of DC/DC 2.

◆ Axp192_SetDCDC3Volt()

void Axp192_SetDCDC3Volt ( uint16_t  voltage)

Set the DC/DC 3 Buck Boost converter voltage on the AXP192.

Parameters
[in]voltageDesired voltage of DC/DC 3.

◆ Axp192_SetVoffVolt()

void Axp192_SetVoffVolt ( uint16_t  voltage)

Set the battery low-voltage to cut-off on the AXP192.

Note
This value should not be set lower than the 3.0v default to avoid damaging the built-in battery.
Parameters
[in]voltageLow battery cut-off voltage.

◆ Axp192_EnablePWRONShortWake()

void Axp192_EnablePWRONShortWake ( )

Enable sleep and short wake mode on AXP192.

◆ Axp192_GetVbusVolt()

float Axp192_GetVbusVolt ( )

Gets VBUS voltage on the AXP192.

Returns
The voltage from the VBUS power source.

◆ Axp192_GetAcinVolt()

float Axp192_GetAcinVolt ( )

Gets ACIN voltage on the AXP192.

Returns
The voltage of the ACIN power source.

◆ Axp192_GetBatVolt()

float Axp192_GetBatVolt ( )

Gets battery voltage on the AXP192.

Returns
The voltage of the battery power source.

◆ Axp192_GetVbusCurrent()

float Axp192_GetVbusCurrent ( )

Gets VBUS current flowing through the AXP192.

Returns
The current usage of the VBUS power source.

◆ Axp192_GetAcinCurrent()

float Axp192_GetAcinCurrent ( )

Gets ACIN current flowing through the AXP192.

Returns
The current usage of ACIN power source.

◆ Axp192_GetBatCurrent()

float Axp192_GetBatCurrent ( )

Gets battery current flowing through the AXP192.

Returns
The current usage of battery power source.

◆ Axp192_EnableCharge()

void Axp192_EnableCharge ( uint16_t  state)

Enables or disables the battery charging circuit on the AXP192.

Parameters
[in]stateDesired state of the battery charging circuit. 1 to enable, 0 to disable.

◆ Axp192_SetChargeVoltage()

void Axp192_SetChargeVoltage ( Axp192_ChargeVolt_t  volt)

Set the battery charge voltage on the AXP192.

Note
This is the voltage applied to the battery for charging. This is not the voltage of the battery. Default is 4.2v.
Parameters
[in]voltDesired voltage to charge the battery.

◆ Axp192_SetChargeCurrent()

void Axp192_SetChargeCurrent ( Axp192_ChargeCurrent_t  cur)

Set the battery charge current on the AXP192.

Note
This is the current applied to the battery for charging. This is not the current of the battery. Default is 100mA.
Parameters
[in]curDesired current to charge the battery.

◆ Axp192_SetSpareBatCharge()

void Axp192_SetSpareBatCharge ( uint8_t  enable,
Axp192_SpareChargeVolt_t  volt,
Axp192_SpareChargeCurrent_t  current 
)

◆ Axp192_GetApsVoltage()

void Axp192_GetApsVoltage ( )

◆ Axp192_GetInternalTemp()

void Axp192_GetInternalTemp ( )

◆ Axp192_SetAdc1Enable()

void Axp192_SetAdc1Enable ( uint8_t  value)

Enables or disables the ADC on the AXP192.

Parameters
[in]valueDesired value of the ADC.

◆ Axp192_SetAdc2Enable()

void Axp192_SetAdc2Enable ( )

◆ Axp192_IsBatIn()

void Axp192_IsBatIn ( )

◆ Axp192_IsCharging()

void Axp192_IsCharging ( )

◆ Axp192_PowerOff()

void Axp192_PowerOff ( )

Powers down the device.

Note
Since the microcontroller and all the peripherals are powered by the AXP192, calling this function powers down the device.

◆ Axp192_SetPressPoweroffTime()

void Axp192_SetPressPoweroffTime ( Axp192_PoweroffTime_t  time)

Sets how long the power button needs to be held to power off all components connected to the AXP192.

Note
The default is POWEROFF_6S (6 seconds).
Parameters
[in]timeDesired time to hold the power button to turn off power.

◆ Axp192_SetPressStartupTime()

void Axp192_SetPressStartupTime ( Axp192_StartupTime_t  time)

Sets how long the power button needs to be held to power on all components connected to the AXP192.

Default is STARTUP_128mS (128 milliseconds).

Parameters
[in]timeDesired time to hold the power button to turn on power.

◆ Axp192_WriteDataStash()

void Axp192_WriteDataStash ( )

◆ Axp192_ReadDataStash()

void Axp192_ReadDataStash ( )

◆ Axp192_SetGPIO3Mode()

void Axp192_SetGPIO3Mode ( )

◆ Axp192_SetGPIO0Mode()

void Axp192_SetGPIO0Mode ( uint8_t  mode)

Sets the mode of GPIO 0 on the AXP192.

Parameters
[in]modeDesired mode of GPIO 0. 0 for Low-Dropout, 1 for ADC input. Default value for the Core2 for AWS is 0, and not meant to be changed.

◆ Axp192_SetGPIO0Volt()

void Axp192_SetGPIO0Volt ( uint16_t  volt)

Sets the voltage of GPIO 0 on the AXP192.

Parameters
[in]voltDesired voltage of GPIO 0. Default value for the Core2 for AWS is 3300mV.

◆ Axp192_SetGPIO1Mode()

void Axp192_SetGPIO1Mode ( uint8_t  mode)

Sets the mode of GPIO 1 on the AXP192.

Parameters
[in]modeDesired mode of GPIO 1. 0 for PWM, 1 for ADC input. Default value for the Core2 for AWS is 1, and not meant to be changed.

◆ Axp192_SetGPIO1Level()

void Axp192_SetGPIO1Level ( uint8_t  level)

Sets the average voltage level of GPIO 1 on the AXP192 if the mode is set to PWM.

Parameters
[in]levelDesired average voltage level of GPIO 1.

◆ Axp192_SetGPIO2Mode()

void Axp192_SetGPIO2Mode ( uint8_t  mode)

Sets the mode of GPIO 2 on the AXP192.

Parameters
[in]modeDesired mode of GPIO 2. 0 for PWM, 1 for ADC input. Default value for the Core2 for AWS is 1, and not meant to be changed.

◆ Axp192_SetGPIO2Level()

void Axp192_SetGPIO2Level ( uint8_t  level)

Sets the average voltage level of GPIO 2 on the AXP192 if the mode is set to PWM.

Parameters
[in]levelDesired average voltage level of GPIO 2.

◆ Axp192_SetGPIO4Mode()

void Axp192_SetGPIO4Mode ( uint8_t  mode)

Sets the mode of GPIO 4 on the AXP192 for charging control.

Parameters
[in]modeDesired mode of GPIO 4. 0 for NMOS open-drain ouput, 1 for universal input. Default value for the Core2 for AWS is 1, and not meant to be changed.

◆ Axp192_SetGPIO4Level()

void Axp192_SetGPIO4Level ( uint8_t  level)

Sets the signal status level of GPIO 4.

Parameters
[in]levelDesired signal status level of GPIO 4.