30 #if BATTERY_MONITOR_REV4
44 #if PERIODIC_TELEMETRY
49 #if BATTERY_MONITOR_REV4
62 pprz_msg_send_BATTERY_MONITOR(trans, dev, AC_ID,
65 &batmonbus_bus_trans_status,
73 &batmonbal1_bus_trans_status,
76 &batmonbal2_bus_trans_status,
92 if ((chan>8) || (chan<1)){
95 static uint8_t adr[] = {0x80, 0x90, 0xA0, 0xB0, 0xC0, 0xD0, 0xE0, 0xF0};
152 #if PERIODIC_TELEMETRY
int32_t current
current in milliamps
#define BATTERY_MONITOR_CURRENT_SENSITIVITY
void battery_monitor_check_i2c_transaction(struct i2c_transaction *t)
Complete i2c transactions once they succeed or fail.
volatile uint8_t buf[I2C_BUF_LEN]
Transaction buffer With I2C_BUF_LEN number of bytes.
float batmon_current_sensitivity
void battery_monitor_init(void)
Init variables.
transaction successfully finished by I2C driver
struct BatMonBus batmonbus
struct i2c_transaction bus_trans
Periodic telemetry system header (includes downlink utility and generated code).
struct BatMonBal batmonbal2
float bus_temp[TEMP_SENSORS_NB]
float batmon_temp_sensitivity
void battery_monitor_read_balance_ports(struct BatMonBal *batmonbal)
Read balance ADC.
static const float battery_monitor_cellgains[]
void battery_monitor_event(void)
Event function Check i2c transaction status for each device.
Battery monitor Bus ADC struct.
Battery monitor Balance ADC struct.
uint8_t battery_monitor_get_address(uint8_t chan)
Translates the channel number to the value for address pointer register Channels are numbered from 1 ...
uint16_t bus_current_mvolts
uint16_t bus_voltage_mvolts
enum BatmonBusStatus bus_status
#define BATTERY_MONITOR_VREF_MULT
int16_t batmon_temp_offset
transaction set to done by user level
driver for ADC AD7997 on a custom made power board version 4.0 and 5.0
PRINT_CONFIG_MSG("USE_INS_NAV_INIT defaulting to TRUE")
#define DefaultPeriodic
Set default periodic telemetry.
void battery_monitor_read_balance_ports_2(void)
Read Balance ADC 2.
struct BatMonBal batmonbal1
bool i2c_transceive(struct i2c_periph *p, struct i2c_transaction *t, uint8_t s_addr, uint8_t len_w, uint16_t len_r)
Submit a write/read transaction.
uint16_t bat_cell_mvolts[BATTERY_CELLS_NB]
I2C transaction structure.
int16_t batmon_current_offset
enum I2CTransactionStatus status
Transaction status.
void battery_monitor_read_balance_ports_1(void)
Read Balance ADC 1.
static const struct usb_device_descriptor dev
static void send_batmon(struct transport_tx *trans, struct link_device *dev)
void battery_monitor_init_bus(void)
Initializes bus ADC.
#define BATTERY_MONITOR_TEMP_OFFSET
uint16_t vsupply
supply voltage in decivolts
#define BATTERY_MONITOR_BUS_CURRENT_CHANNEL
static const uint8_t battery_monitor_tempmap[]
#define BATTERY_MONITOR_BIT_RES
transaction is currently ongoing
static const uint8_t battery_monitor_cellmap[]
Cell map - which cell is which channel Channels are 1-indexed, ie.e.
#define BATTERY_MONITOR_CURRENT_OFFSET
#define BATTERY_MONITOR_TEMP_SENSITIVITY
void battery_monitor_init_balance(struct BatMonBal *batmonbal)
Initalizes balance ADC.
struct Electrical electrical
static const float BatmonVbusGain
struct i2c_transaction bus_trans
#define BATTERY_MONITOR_BUS_VOLTAGE_CHANNEL
transaction is pending in queue
void battery_monitor_read_bus(void)
Read bus (current, voltage and temperature sensors)
int8_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint8_t _id, telemetry_cb _cb)
Register a telemetry callback function.
uint16_t bus_tempsensors_mvolts[TEMP_SENSORS_NB]