batt_smbus move to new WQ

This commit is contained in:
Daniel Agar
2019-06-04 19:54:06 -04:00
parent 3faab909d7
commit 574f7e9f00
2 changed files with 7 additions and 20 deletions
+4 -13
View File
@@ -48,9 +48,8 @@
extern "C" __EXPORT int batt_smbus_main(int argc, char *argv[]);
struct work_s BATT_SMBUS::_work = {};
BATT_SMBUS::BATT_SMBUS(SMBus *interface, const char *path) :
ScheduledWorkItem(px4::device_bus_to_wq(interface->get_device_id())),
_interface(interface),
_cycle(perf_alloc(PC_ELAPSED, "batt_smbus_cycle")),
_batt_topic(nullptr),
@@ -151,8 +150,7 @@ int BATT_SMBUS::task_spawn(int argc, char *argv[])
return PX4_ERROR;
}
// Throw it into the work queue.
work_queue(HPWORK, &_work, (worker_t)&BATT_SMBUS::cycle_trampoline, dev, 0);
dev->ScheduleNow();
return PX4_OK;
@@ -163,13 +161,7 @@ int BATT_SMBUS::task_spawn(int argc, char *argv[])
return PX4_ERROR;
}
void BATT_SMBUS::cycle_trampoline(void *arg)
{
BATT_SMBUS *dev = (BATT_SMBUS *)arg;
dev->cycle();
}
void BATT_SMBUS::cycle()
void BATT_SMBUS::Run()
{
// Get the current time.
uint64_t now = hrt_absolute_time();
@@ -279,8 +271,7 @@ void BATT_SMBUS::cycle()
}
// Schedule a fresh cycle call when the measurement is done.
work_queue(HPWORK, &_work, (worker_t)&BATT_SMBUS::cycle_trampoline, this,
USEC2TICK(BATT_SMBUS_MEASUREMENT_INTERVAL_US));
ScheduleDelayed(BATT_SMBUS_MEASUREMENT_INTERVAL_US);
}
}