mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-04 19:41:35 +08:00
refactor ll40ls: split I2C and PWM into separate drivers
- there was almost nothing shared - it will fit better into the updated I2C driver structure
This commit is contained in:
@@ -42,10 +42,13 @@
|
||||
#include "LidarLiteI2C.h"
|
||||
|
||||
LidarLiteI2C::LidarLiteI2C(const int bus, const uint8_t rotation, const int address) :
|
||||
LidarLite(rotation),
|
||||
I2C("LL40LS", nullptr, bus, address, 100000),
|
||||
ScheduledWorkItem(MODULE_NAME, px4::device_bus_to_wq(get_device_id()))
|
||||
ScheduledWorkItem(MODULE_NAME, px4::device_bus_to_wq(get_device_id())),
|
||||
_px4_rangefinder(0 /* device id not yet used */, ORB_PRIO_DEFAULT, rotation)
|
||||
{
|
||||
_px4_rangefinder.set_min_distance(LL40LS_MIN_DISTANCE);
|
||||
_px4_rangefinder.set_max_distance(LL40LS_MAX_DISTANCE);
|
||||
_px4_rangefinder.set_fov(0.008); // Divergence 8 mRadian
|
||||
// up the retries since the device misses the first measure attempts
|
||||
_retries = 3;
|
||||
}
|
||||
@@ -53,6 +56,10 @@ LidarLiteI2C::LidarLiteI2C(const int bus, const uint8_t rotation, const int addr
|
||||
LidarLiteI2C::~LidarLiteI2C()
|
||||
{
|
||||
stop();
|
||||
perf_free(_sample_perf);
|
||||
perf_free(_comms_errors);
|
||||
perf_free(_sensor_resets);
|
||||
perf_free(_sensor_zero_resets);
|
||||
}
|
||||
|
||||
int
|
||||
@@ -66,6 +73,16 @@ LidarLiteI2C::init()
|
||||
return PX4_OK;
|
||||
}
|
||||
|
||||
void
|
||||
LidarLiteI2C::print_info()
|
||||
{
|
||||
perf_print_counter(_sample_perf);
|
||||
perf_print_counter(_comms_errors);
|
||||
perf_print_counter(_sensor_resets);
|
||||
perf_print_counter(_sensor_zero_resets);
|
||||
printf("poll interval: %u \n", get_measure_interval());
|
||||
}
|
||||
|
||||
int
|
||||
LidarLiteI2C::read_reg(const uint8_t reg, uint8_t &val)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user