59 lines
1.4 KiB
C
59 lines
1.4 KiB
C
#ifndef __LTC2941_BATTERY_H
|
|
#define __LTC2941_BATTERY_H
|
|
|
|
#include <stdint.h>
|
|
|
|
typedef enum {
|
|
LTC2941_OK,
|
|
LTC2941_ERROR
|
|
} ltc2941_ret_t;
|
|
|
|
typedef enum {
|
|
LTC2941_ALERT_3_0V = 0x03,
|
|
LTC2941_ALERT_2_9V = 0x02,
|
|
LTC2941_ALERT_2_8V = 0x01,
|
|
LTC2941_ALERT_OFF = 0x00
|
|
} ltc2941_battery_alert_t;
|
|
|
|
typedef enum {
|
|
LTC2941_PRE_1 = 0x00,
|
|
LTC2941_PRE_2 = 0x01,
|
|
LTC2941_PRE_4 = 0x02,
|
|
LTC2941_PRE_8 = 0x03,
|
|
LTC2941_PRE_16 = 0x04,
|
|
LTC2941_PRE_32 = 0x05,
|
|
LTC2941_PRE_64 = 0x06,
|
|
LTC2941_PRE_128 = 0x07
|
|
} ltc2941_prescale_t;
|
|
|
|
typedef enum {
|
|
LTC2941_ALERT_DISABLED = 0x00,
|
|
LTC2941_ALERT_CC = 0x01,
|
|
LTC2941_ALERT_AL = 0x02
|
|
} ltc2941_alert_mode_t;
|
|
|
|
typedef struct {
|
|
ltc2941_ret_t (*write_register_cb)(void * handle, uint8_t reg, uint8_t value);
|
|
ltc2941_ret_t (*read_register_cb)(void *handle, uint8_t reg, uint8_t *value);
|
|
} ltc2941_cb_t;
|
|
|
|
typedef struct {
|
|
ltc2941_prescale_t prescaler;
|
|
ltc2941_alert_mode_t alert_mode;
|
|
ltc2941_battery_alert_t alert_level;
|
|
} ltc2941_config_t;
|
|
|
|
typedef struct {
|
|
ltc2941_cb_t cb;
|
|
ltc2941_config_t config;
|
|
void *user_data;
|
|
} ltc2941_t;
|
|
|
|
#define LTC2941_STATUS_CHIPID (1 << 7U)
|
|
#define LTC2941_STATUS_OVERFLOW (1 << 5U)
|
|
#define LTC2941_STATUS_ALRT_HIGH (1 << 3U)
|
|
#define LTC2941_STATUS_ALRT_LOW (1 << 2U)
|
|
#define LTC2941_STATUS_ALRT_VBAT (1 << 1U)
|
|
#define LTC2941_STATUS_ALRT_UVLO 1U
|
|
|
|
#endif |