I2C/SPI require device type in constructor

This commit is contained in:
Daniel Agar
2020-04-01 12:24:22 -04:00
committed by GitHub
parent 04bf9afd1b
commit 02f4ad61ec
128 changed files with 181 additions and 351 deletions
+4 -4
View File
@@ -35,11 +35,11 @@
PAW3902::PAW3902(I2CSPIBusOption bus_option, int bus, int devid, enum Rotation yaw_rotation, int bus_frequency,
spi_mode_e spi_mode) :
SPI("PAW3902", nullptr, bus, devid, spi_mode, bus_frequency),
SPI(DRV_FLOW_DEVTYPE_PAW3902, MODULE_NAME, bus, devid, spi_mode, bus_frequency),
I2CSPIDriver(MODULE_NAME, px4::device_bus_to_wq(get_device_id()), bus_option, bus),
_sample_perf(perf_alloc(PC_ELAPSED, "paw3902: read")),
_comms_errors(perf_alloc(PC_COUNT, "paw3902: com_err")),
_dupe_count_perf(perf_alloc(PC_COUNT, "paw3902: duplicate reading")),
_sample_perf(perf_alloc(PC_ELAPSED, MODULE_NAME": read")),
_comms_errors(perf_alloc(PC_COUNT, MODULE_NAME": com_err")),
_dupe_count_perf(perf_alloc(PC_COUNT, MODULE_NAME": duplicate reading")),
_yaw_rotation(yaw_rotation)
{
}
+1 -1
View File
@@ -37,7 +37,7 @@ static constexpr uint32_t TIME_us_TSWW = 11; // - actually 10.5us
PMW3901::PMW3901(I2CSPIBusOption bus_option, int bus, int devid, enum Rotation yaw_rotation, int bus_frequency,
spi_mode_e spi_mode) :
SPI("PMW3901", PMW3901_DEVICE_PATH, bus, devid, spi_mode, bus_frequency),
SPI(DRV_FLOW_DEVTYPE_PMW3901, MODULE_NAME, bus, devid, spi_mode, bus_frequency),
I2CSPIDriver(MODULE_NAME, px4::device_bus_to_wq(get_device_id()), bus_option, bus),
_sample_perf(perf_alloc(PC_ELAPSED, "pmw3901: read")),
_comms_errors(perf_alloc(PC_COUNT, "pmw3901: com err")),
@@ -58,13 +58,10 @@
#define DIR_WRITE(a) ((a) | (1 << 7))
#define DIR_READ(a) ((a) & 0x7f)
#define PMW3901_DEVICE_PATH "/dev/pmw3901"
/* PMW3901 Registers addresses */
#define PMW3901_US 1000 /* 1 ms */
#define PMW3901_SAMPLE_INTERVAL 10000 /* 10 ms */
class PMW3901 : public device::SPI, public I2CSPIDriver<PMW3901>
{
public:
+3 -5
View File
@@ -55,8 +55,6 @@
#include <uORB/topics/distance_sensor.h>
#include <uORB/topics/optical_flow.h>
#define PX4FLOW0_DEVICE_PATH "/dev/px4flow0"
/* Configuration Constants */
#define I2C_FLOW_ADDRESS_DEFAULT 0x42 ///< 7-bit address. 8-bit address is 0x84, range 0x42 - 0x49
#define I2C_FLOW_ADDRESS_MIN 0x42 ///< 7-bit address.
@@ -147,11 +145,11 @@ extern "C" __EXPORT int px4flow_main(int argc, char *argv[]);
PX4FLOW::PX4FLOW(I2CSPIBusOption bus_option, int bus, int address, uint8_t sonar_rotation, int bus_frequency,
int conversion_interval, enum Rotation rotation) :
I2C("PX4FLOW", PX4FLOW0_DEVICE_PATH, bus, address, bus_frequency),
I2C(DRV_FLOW_DEVTYPE_PX4FLOW, MODULE_NAME, bus, address, bus_frequency),
I2CSPIDriver(MODULE_NAME, px4::device_bus_to_wq(get_device_id()), bus_option, bus, address),
_sonar_rotation(sonar_rotation),
_sample_perf(perf_alloc(PC_ELAPSED, "px4f_read")),
_comms_errors(perf_alloc(PC_COUNT, "px4f_com_err")),
_sample_perf(perf_alloc(PC_ELAPSED, MODULE_NAME": read")),
_comms_errors(perf_alloc(PC_COUNT, MODULE_NAME": com_err")),
_sensor_rotation(rotation)
{
}