webradio/firmware/batmon.h

23 lines
582 B
C
Raw Normal View History

2020-07-30 17:11:48 +02:00
#ifndef BATMON_H
#define BATMON_H
#include <avr/io.h>
#define ADC_CHANNEL 0
2020-08-08 16:54:23 +02:00
#define PORT_ADCC(t) t##C
2020-07-30 17:11:48 +02:00
#define PIN_ADCC (1 << 1)
2020-08-09 12:14:21 +02:00
#define PORT_CHI(t) t##B /* Charging indicator */
#define PIN_CHI (1 << 7)
// Nominal 3.7V: 195; Full 4.2V: 220
#define BAT_THRES_POWER_ON 175 // TODO: Minimum ADC value to allow turning the device on (3.3V)
#define BAT_THRES_POWER_OFF 165 // TODO: ADC value to (hard) power off the device. (3.1V)
2020-07-30 17:11:48 +02:00
void batmon_init();
uint8_t batmon_get_voltage();
uint8_t batmon_proc();
2020-07-31 18:23:58 +02:00
uint8_t batmon_ok_to_boot();
2020-08-09 12:14:21 +02:00
uint8_t batmon_is_charging();
2020-07-30 17:11:48 +02:00
#endif // BATMON_H