47 I2C(
"voxlpm", path, bus, address, 400000),
48 ScheduledWorkItem(MODULE_NAME,
px4::device_bus_to_wq(I2C::get_device_id())),
50 _bat_pub_topic(nullptr),
51 _pm_pub_topic(nullptr),
98 printf(
"- type: BATT\n");
101 printf(
"- type: P5VDC\n");
104 printf(
" - voltage: %9.2f VDC \n", (
double)
_voltage);
105 printf(
" - current: %9.2f ADC \n", (
double)
_amperage);
106 printf(
" - rsense: %9.6f ohm \n", (
double)
_rsense);
149 if ((volt_read_ret == 0) && (curr_read_ret == 0)) {
150 uint16_t volt16 = (((uint16_t)vraw[0]) << 8) | vraw[1];
154 uint16_t curr16 = (((uint16_t)iraw[0]) << 8) | iraw[1];
218 uint8_t cmd[2] = { (uint8_t)(addr), 0};
219 transfer(&cmd[0], 1, &cmd[1], 1);
227 const uint8_t cmd = (uint8_t)(addr);
228 return transfer(&cmd,
sizeof(cmd), buf, len);
234 uint8_t cmd[2] = { (uint8_t)(addr), value};
235 return transfer(cmd,
sizeof(cmd),
nullptr, 0);
perf_counter_t _sample_perf
#define VOXLPM_LTC2946_VFS_SENSE
measure the time elapsed performing an event
struct power_monitor_s _pm_status
void reset(battery_status_s *battery_status)
Reset all battery stats and report invalid/nothing.
int read_reg_buf(uint8_t addr, uint8_t *buf, uint8_t len)
orb_advert_t orb_advertise(const struct orb_metadata *meta, const void *data)
int write_reg(uint8_t value, uint8_t addr)
#define DEFAULT_CTRLB_REG_VAL
struct battery_status_s _bat_status
Shared defines for the voxlpm (QTY2 LTC2946) driver.
#define VOXLPM_LTC2946_DELTA_SENSE_MSB_REG
#define ORB_ID(_name)
Generates a pointer to the uORB metadata structure for a given topic.
#define VOXLPM_LTC2946_VFS_DELTA_SENSE
#define DEFAULT_CTRLA_REG_VAL
void perf_free(perf_counter_t handle)
Free a counter.
void init()
Activates/configures the hardware registers.
orb_advert_t _bat_pub_topic
VOXLPM(const char *path, int bus, int address, VOXLPM_CH_TYPE ch_type)
Vector< float, 6 > f(float t, const Matrix< float, 6, 1 > &, const Matrix< float, 3, 1 > &)
void perf_end(perf_counter_t handle)
End a performance event.
#define VOXLPM_LTC2946_CTRLB_REG
__BEGIN_DECLS typedef uint64_t hrt_abstime
Absolute time, in microsecond units.
int orb_publish(const struct orb_metadata *meta, orb_advert_t handle, const void *data)
void updateBatteryStatus(hrt_abstime timestamp, float voltage_v, float current_a, bool connected, bool selected_source, int priority, float throttle_normalized, bool armed, battery_status_s *status)
Update current battery status message.
uint8_t read_reg(uint8_t addr)
#define VOXLPM_LTC2946_CTRLA_REG
#define VOXLPM_LTC2946_RESOLUTION
void perf_print_counter(perf_counter_t handle)
Print one performance counter to stdout.
#define VOXLPM_RSENSE_VBATT
#define VOXLPM_RSENSE_5VOUT
#define VOXLPM_LTC2946_VIN_MSB_REG
orb_advert_t _pm_pub_topic
void perf_begin(perf_counter_t handle)
Begin a performance event.
__EXPORT hrt_abstime hrt_absolute_time(void)
Get absolute time in [us] (does not wrap).