43 #include <px4_platform_common/px4_config.h> 48 #include <ltc2946/LTC2946.hpp> 71 int _publish(
const struct ltc2946_sensor_data &
data);
77 int _actuator_ctrl_0_sub{-1};
78 int _vcontrol_mode_sub{-1};
83 LTC2946(LTC2946_DEVICE_PATH)
107 PX4_ERR(
"LTC2946 init fail: %d", ret);
114 PX4_ERR(
"LTC2946 start fail: %d", ret);
127 PX4_ERR(
"LTC2946 stop fail: %d", ret);
137 bool connected = data.battery_voltage_V > BOARD_ADC_OPEN_CIRCUIT_V;
146 ctrl.
control[actuator_controls_s::INDEX_THROTTLE],
168 PX4_WARN(
"starting LTC2946");
171 if (g_dev ==
nullptr) {
172 PX4_ERR(
"failed instantiating DfLtc2946Wrapper object");
176 PX4_INFO(
"started LTC2946");
179 int ret = g_dev->
start();
182 PX4_ERR(
"DfLtc2946Wrapper start failed");
191 if (g_dev ==
nullptr) {
192 PX4_ERR(
"driver not running");
196 int ret = g_dev->
stop();
199 PX4_ERR(
"driver could not be stopped");
214 if (g_dev ==
nullptr) {
215 PX4_ERR(
"driver not running");
219 PX4_DEBUG(
"state @ %p", g_dev);
227 PX4_WARN(
"Usage: df_ltc2946_wrapper 'start', 'info', 'stop'");
243 const char *verb = argv[1];
246 if (!strcmp(verb,
"start")) {
250 else if (!strcmp(verb,
"stop")) {
254 else if (!strcmp(verb,
"info")) {
orb_advert_t _battery_pub
int orb_copy(const struct orb_metadata *meta, int handle, void *buffer)
API for the uORB lightweight object broker.
void usage(const char *reason)
Print the correct usage.
void reset(battery_status_s *battery_status)
Reset all battery stats and report invalid/nothing.
High-resolution timer with callouts and timekeeping.
Library calls for battery functionality.
int orb_subscribe(const struct orb_metadata *meta)
#define ORB_ID(_name)
Generates a pointer to the uORB metadata structure for a given topic.
void init()
Activates/configures the hardware registers.
int orb_unsubscribe(int handle)
Simple error/warning functions, heavily inspired by the BSD functions of the same names...
void usage()
Prints info about the driver argument usage.
int stop()
Stop the driver.
__BEGIN_DECLS typedef uint64_t hrt_abstime
Absolute time, in microsecond units.
__BEGIN_DECLS typedef void * orb_advert_t
ORB topic advertiser handle.
battery_status_s _battery_status
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.
int _publish(const struct ltc2946_sensor_data &data)
__EXPORT int df_ltc2946_wrapper_main(int argc, char *argv[])
int start()
Attempt to start driver on all available I2C busses.
__EXPORT hrt_abstime hrt_absolute_time(void)
Get absolute time in [us] (does not wrap).
static int orb_publish_auto(const struct orb_metadata *meta, orb_advert_t *handle, const void *data, int *instance, int priority)
Advertise as the publisher of a topic.
int info()
Print a little info about the driver.