mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-07 17:35:22 +08:00
HMC5883: Harden shutdown logic
This commit is contained in:
committed by
Lorenz Meier
parent
5759fd5726
commit
143086ba2c
@@ -781,7 +781,11 @@ HMC5883::start()
|
||||
void
|
||||
HMC5883::stop()
|
||||
{
|
||||
work_cancel(HPWORK, &_work);
|
||||
if (_measure_ticks > 0) {
|
||||
/* ensure no new items are queued while we cancel this one */
|
||||
_measure_ticks = 0;
|
||||
work_cancel(HPWORK, &_work);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
@@ -802,6 +806,10 @@ HMC5883::cycle_trampoline(void *arg)
|
||||
void
|
||||
HMC5883::cycle()
|
||||
{
|
||||
if (_measure_ticks == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* collection phase? */
|
||||
if (_collect_phase) {
|
||||
|
||||
@@ -840,12 +848,14 @@ HMC5883::cycle()
|
||||
/* next phase is collection */
|
||||
_collect_phase = true;
|
||||
|
||||
/* schedule a fresh cycle call when the measurement is done */
|
||||
work_queue(HPWORK,
|
||||
&_work,
|
||||
(worker_t)&HMC5883::cycle_trampoline,
|
||||
this,
|
||||
USEC2TICK(HMC5883_CONVERSION_INTERVAL));
|
||||
if (_measure_ticks > 0) {
|
||||
/* schedule a fresh cycle call when the measurement is done */
|
||||
work_queue(HPWORK,
|
||||
&_work,
|
||||
(worker_t)&HMC5883::cycle_trampoline,
|
||||
this,
|
||||
USEC2TICK(HMC5883_CONVERSION_INTERVAL));
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
|
||||
Reference in New Issue
Block a user