mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-23 00:03:33 +08:00
batt_smbus move to new WQ
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user