mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
adis16497 move to px4 work queue
This commit is contained in:
parent
5ebb0d5d96
commit
5e427b4e46
@ -68,6 +68,7 @@ using namespace time_literals;
|
||||
|
||||
ADIS16497::ADIS16497(int bus, const char *path_accel, const char *path_gyro, uint32_t device, enum Rotation rotation) :
|
||||
SPI("ADIS16497", path_accel, bus, device, SPIDEV_MODE3, 5000000),
|
||||
ScheduledWorkItem(px4::device_bus_to_wq(get_device_id())),
|
||||
_gyro(new ADIS16497_gyro(this, path_gyro)),
|
||||
_sample_perf(perf_alloc(PC_ELAPSED, "ADIS16497_read")),
|
||||
_sample_interval_perf(perf_alloc(PC_INTERVAL, "ADIS16497_read_int")),
|
||||
@ -474,7 +475,7 @@ ADIS16497::start()
|
||||
stop();
|
||||
|
||||
// Start polling at the specified rate
|
||||
hrt_call_every(&_call, 1000, _call_interval, (hrt_callout)&ADIS16497::measure_trampoline, this);
|
||||
ScheduleOnInterval(_call_interval, 1000);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -485,7 +486,7 @@ ADIS16497::stop()
|
||||
// Disable data ready callback
|
||||
px4_arch_gpiosetevent(GPIO_SPI1_DRDY1_ADIS16497, false, false, false, nullptr, nullptr);
|
||||
#else
|
||||
hrt_cancel(&_call);
|
||||
ScheduleClear();
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -495,18 +496,16 @@ ADIS16497::data_ready_interrupt(int irq, void *context, void *arg)
|
||||
ADIS16497 *dev = reinterpret_cast<ADIS16497 *>(arg);
|
||||
|
||||
/* make another measurement */
|
||||
dev->measure();
|
||||
dev->ScheduleNow();
|
||||
|
||||
return PX4_OK;
|
||||
}
|
||||
|
||||
void
|
||||
ADIS16497::measure_trampoline(void *arg)
|
||||
ADIS16497::Run()
|
||||
{
|
||||
ADIS16497 *dev = reinterpret_cast<ADIS16497 *>(arg);
|
||||
|
||||
/* make another measurement */
|
||||
dev->measure();
|
||||
measure();
|
||||
}
|
||||
|
||||
int
|
||||
|
||||
@ -49,6 +49,7 @@
|
||||
#include <lib/conversion/rotation.h>
|
||||
#include <perf/perf_counter.h>
|
||||
#include <ecl/geo/geo.h>
|
||||
#include <px4_work_queue/ScheduledWorkItem.hpp>
|
||||
|
||||
#define ADIS16497_GYRO_DEFAULT_RATE 1000
|
||||
#define ADIS16497_GYRO_DEFAULT_DRIVER_FILTER_FREQ 80
|
||||
@ -94,7 +95,7 @@ static const uint32_t crc32_tab[] = {
|
||||
|
||||
class ADIS16497_gyro;
|
||||
|
||||
class ADIS16497 : public device::SPI
|
||||
class ADIS16497 : public device::SPI, public px4::ScheduledWorkItem
|
||||
{
|
||||
public:
|
||||
ADIS16497(int bus, const char *path_accel, const char *path_gyro, uint32_t device, enum Rotation rotation);
|
||||
@ -116,7 +117,6 @@ protected:
|
||||
private:
|
||||
ADIS16497_gyro *_gyro{nullptr};
|
||||
|
||||
struct hrt_call _call {};
|
||||
unsigned _call_interval{1000};
|
||||
|
||||
struct gyro_calibration_s _gyro_scale {};
|
||||
@ -197,15 +197,10 @@ private:
|
||||
int reset();
|
||||
|
||||
/**
|
||||
* Static trampoline from the hrt_call context; because we don't have a
|
||||
* generic hrt wrapper yet.
|
||||
*
|
||||
* Called by the HRT in interrupt context at the specified rate if
|
||||
* Called by the ScheduledWorkItem at the specified rate if
|
||||
* automatic polling is enabled.
|
||||
*
|
||||
* @param arg Instance pointer for the driver that is polling.
|
||||
*/
|
||||
static void measure_trampoline(void *arg);
|
||||
void Run() override;
|
||||
|
||||
static int data_ready_interrupt(int irq, void *context, void *arg);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user