summaryrefslogtreecommitdiff
path: root/firmware/export/axp173.h
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/export/axp173.h')
-rw-r--r--firmware/export/axp173.h118
1 files changed, 0 insertions, 118 deletions
diff --git a/firmware/export/axp173.h b/firmware/export/axp173.h
deleted file mode 100644
index 34f0c2ec19..0000000000
--- a/firmware/export/axp173.h
+++ /dev/null
@@ -1,118 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2021 Aidan MacDonald
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#ifndef __AXP173_H__
23#define __AXP173_H__
24
25#include <stdbool.h>
26#include <stdint.h>
27
28/* ADC channels */
29#define ADC_ACIN_VOLTAGE 0
30#define ADC_ACIN_CURRENT 1
31#define ADC_VBUS_VOLTAGE 2
32#define ADC_VBUS_CURRENT 3
33#define ADC_INTERNAL_TEMP 4
34#define ADC_TS_INPUT 5
35#define ADC_BATTERY_VOLTAGE 6
36#define ADC_CHARGE_CURRENT 7
37#define ADC_DISCHARGE_CURRENT 8
38#define ADC_APS_VOLTAGE 9
39#define ADC_BATTERY_POWER 10
40#define NUM_ADC_CHANNELS 11
41
42/* ADC sampling rates */
43#define AXP173_ADC_RATE_25HZ 0
44#define AXP173_ADC_RATE_50HZ 1
45#define AXP173_ADC_RATE_100HZ 2
46#define AXP173_ADC_RATE_200HZ 3
47
48/* Return values of axp173_battery_status() */
49#define AXP173_BATT_DISCHARGING 0
50#define AXP173_BATT_CHARGING 1
51#define AXP173_BATT_FULL 2
52
53/* Bits returned by axp173_input_status() */
54#define AXP173_INPUT_AC (1 << 0)
55#define AXP173_INPUT_USB (1 << 1)
56#define AXP173_INPUT_BATTERY (1 << 2)
57#define AXP173_INPUT_EXTERNAL (AXP173_INPUT_AC|AXP173_INPUT_USB)
58
59/* Registers -- common to AXP173 and AXP192 (incomplete listing) */
60#define AXP173_REG_POWERSTATUS 0x00
61#define AXP173_REG_CHARGESTATUS 0x01
62#define AXP173_REG_PWROUTPUTCTRL 0x12
63#define AXP173_REG_SHUTDOWNLEDCTRL 0x32
64#define AXP173_REG_CHARGECONTROL1 0x33
65#define AXP173_REG_DCDCWORKINGMODE 0x80
66#define AXP173_REG_ADCENABLE1 0x82
67#define AXP173_REG_ADCENABLE2 0x83
68#define AXP173_REG_ADCSAMPLERATE 0x84
69#define AXP173_REG_COULOMBCOUNTERBASE 0xb0
70#define AXP173_REG_COULOMBCOUNTERCTRL 0xb8
71
72/* AXP192-only registers (incomplete listing) */
73#define AXP192_REG_GPIO0FUNCTION 0x90
74#define AXP192_REG_GPIO1FUNCTION 0x92
75#define AXP192_REG_GPIO2FUNCTION 0x93
76#define AXP192_REG_GPIOSTATE1 0x94
77
78/* Must be called from power_init() to initialize the driver state */
79extern void axp173_init(void);
80
81/* Basic battery and power supply status */
82extern int axp173_battery_status(void);
83extern int axp173_input_status(void);
84
85/* ADC access -- ADCs which are not enabled will return INT_MIN if read.
86 * The output of axp173_adc_read() is normalized to appropriate units:
87 *
88 * - for voltages, the scale is millivolts
89 * - for currents, the scale is milliamps
90 * - for temperatures, the scale is tenths of a degree Celsius
91 * - for power, the scale is microwatts
92 *
93 * See the comment in axp173_adc_conv_raw() for raw value precision/scale.
94 */
95extern int axp173_adc_read(int adc);
96extern int axp173_adc_read_raw(int adc);
97extern int axp173_adc_conv_raw(int adc, int value);
98extern int axp173_adc_get_enabled(void);
99extern void axp173_adc_set_enabled(int adc_bits);
100extern int axp173_adc_get_rate(void);
101extern void axp173_adc_set_rate(int rate);
102
103/* - axp173_cc_read() reads the coulomb counters
104 * - axp173_cc_clear() resets both counters to zero
105 * - axp173_cc_enable() will stop/start the counters running
106 */
107extern void axp173_cc_read(uint32_t* charge, uint32_t* discharge);
108extern void axp173_cc_clear(void);
109extern void axp173_cc_enable(bool en);
110
111/* Set/get maximum charging current in milliamps */
112extern void axp173_set_charge_current(int maxcurrent);
113extern int axp173_get_charge_current(void);
114
115/* Debug menu */
116extern bool axp173_debug_menu(void);
117
118#endif /* __AXP173_H__ */