forked from len0rd/rockbox
Minor enhancements to axp173 driver
- Added register names to reduce usage of magic numbers - Added function to control max charging current, needed for USB - Corrected comment about axp173, since FiiO M3K has an axp192 Change-Id: I6604ce8d44e5a2ee84061cf042d17ccc4734ac57
This commit is contained in:
parent
f6d3680cb8
commit
088ebb5fac
4 changed files with 120 additions and 32 deletions
|
|
@ -25,6 +25,7 @@
|
|||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/* ADC channels */
|
||||
#define ADC_ACIN_VOLTAGE 0
|
||||
#define ADC_ACIN_CURRENT 1
|
||||
#define ADC_VBUS_VOLTAGE 2
|
||||
|
|
@ -55,6 +56,25 @@
|
|||
#define AXP173_INPUT_BATTERY (1 << 2)
|
||||
#define AXP173_INPUT_EXTERNAL (AXP173_INPUT_AC|AXP173_INPUT_USB)
|
||||
|
||||
/* Registers -- common to AXP173 and AXP192 (incomplete listing) */
|
||||
#define AXP173_REG_POWERSTATUS 0x00
|
||||
#define AXP173_REG_CHARGESTATUS 0x01
|
||||
#define AXP173_REG_PWROUTPUTCTRL 0x12
|
||||
#define AXP173_REG_SHUTDOWNLEDCTRL 0x32
|
||||
#define AXP173_REG_CHARGECONTROL1 0x33
|
||||
#define AXP173_REG_DCDCWORKINGMODE 0x80
|
||||
#define AXP173_REG_ADCENABLE1 0x82
|
||||
#define AXP173_REG_ADCENABLE2 0x83
|
||||
#define AXP173_REG_ADCSAMPLERATE 0x84
|
||||
#define AXP173_REG_COULOMBCOUNTERBASE 0xb0
|
||||
#define AXP173_REG_COULOMBCOUNTERCTRL 0xb8
|
||||
|
||||
/* AXP192-only registers (incomplete listing) */
|
||||
#define AXP192_REG_GPIO0FUNCTION 0x90
|
||||
#define AXP192_REG_GPIO1FUNCTION 0x92
|
||||
#define AXP192_REG_GPIO2FUNCTION 0x93
|
||||
#define AXP192_REG_GPIOSTATE1 0x94
|
||||
|
||||
/* Must be called from power_init() to initialize the driver state */
|
||||
extern void axp173_init(void);
|
||||
|
||||
|
|
@ -88,6 +108,10 @@ extern void axp173_cc_read(uint32_t* charge, uint32_t* discharge);
|
|||
extern void axp173_cc_clear(void);
|
||||
extern void axp173_cc_enable(bool en);
|
||||
|
||||
/* Set/get maximum charging current in milliamps */
|
||||
extern void axp173_set_charge_current(int maxcurrent);
|
||||
extern int axp173_get_charge_current(void);
|
||||
|
||||
/* Debug menu */
|
||||
extern bool axp173_debug_menu(void);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue