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
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 ...
int16_t batmon_current_offset
void battery_monitor_event(void)
Event function Check i2c transaction status for each device.
void battery_monitor_read_balance_ports_1(void)
Read Balance ADC 1.
void battery_monitor_init_balance(struct BatMonBal *batmonbal)
Initalizes balance ADC.
void battery_monitor_read_balance_ports_2(void)
Read Balance ADC 2.
float batmon_current_sensitivity
float batmon_temp_sensitivity
void battery_monitor_check_i2c_transaction(struct i2c_transaction *t)
Complete i2c transactions once they succeed or fail.
void battery_monitor_read_balance_ports(struct BatMonBal *batmonbal)
Read balance ADC.
struct BatMonBal batmonbal2
static void send_batmon(struct transport_tx *trans, struct link_device *dev)
void battery_monitor_init_bus(void)
Initializes bus ADC.
int16_t batmon_temp_offset
void battery_monitor_read_bus(void)
Read bus (current, voltage and temperature sensors)
void battery_monitor_init(void)
Init variables.
struct BatMonBal batmonbal1
struct BatMonBus batmonbus
driver for ADC AD7997 on a custom made power board version 4.0 and 5.0
enum BatmonBusStatus bus_status
static const float BatmonVbusGain
#define BATTERY_MONITOR_BUS_VOLTAGE_CHANNEL
struct i2c_transaction bus_trans
#define BATTERY_MONITOR_BIT_RES
struct i2c_transaction bus_trans
#define BATTERY_MONITOR_BUS_CURRENT_CHANNEL
#define BATTERY_MONITOR_CURRENT_SENSITIVITY
#define BATTERY_MONITOR_CURRENT_OFFSET
@ BATTERY_MONITOR_BUS_VOLTAGE_REQ
@ BATTERY_MONITOR_BUS_VOLTAGE_READ
@ BATTERY_MONITOR_BUS_CURRENT_REQ
@ BATTERY_MONITOR_BUS_TEMPERATURE_READ
@ BATTERY_MONITOR_BUS_CURRENT_READ
@ BATTERY_MONITOR_BUS_TEMPERATURE_REQ
#define BATTERY_MONITOR_TEMP_OFFSET
#define BATTERY_MONITOR_TEMP_SENSITIVITY
static const uint8_t battery_monitor_tempmap[]
uint16_t bus_voltage_mvolts
static const uint8_t battery_monitor_cellmap[]
Cell map - which cell is which channel Channels are 1-indexed, ie.e.
#define BATTERY_MONITOR_VREF_MULT
static const float battery_monitor_cellgains[]
uint16_t bus_current_mvolts
float bus_temp[TEMP_SENSORS_NB]
uint16_t bus_tempsensors_mvolts[TEMP_SENSORS_NB]
uint16_t bat_cell_mvolts[BATTERY_CELLS_NB]
Battery monitor Balance ADC struct.
Battery monitor Bus ADC struct.
struct Electrical electrical
float current
current in A
float vsupply
supply voltage in V
volatile uint8_t buf[I2C_BUF_LEN]
Transaction buffer With I2C_BUF_LEN number of bytes.
enum I2CTransactionStatus status
Transaction status.
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.
@ I2CTransRunning
transaction is currently ongoing
@ I2CTransSuccess
transaction successfully finished by I2C driver
@ I2CTransFailed
transaction failed
@ I2CTransDone
transaction set to done by user level
@ I2CTransPending
transaction is pending in queue
I2C transaction structure.
PRINT_CONFIG_MSG("USE_INS_NAV_INIT defaulting to TRUE")
static const struct usb_device_descriptor dev
int8_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint8_t _id, telemetry_cb _cb)
Register a telemetry callback function.
Periodic telemetry system header (includes downlink utility and generated code).
#define DefaultPeriodic
Set default periodic telemetry.
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
short int16_t
Typedef defining 16 bit short type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.