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:
Beat Küng
2020-03-17 23:31:17 -04:00
committed by Daniel Agar
parent 081ab729aa
commit df99555132
12 changed files with 366 additions and 262 deletions
@@ -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)
{