Skip to content

Commit

Permalink
I2C/SPI require device type in constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
dagar authored Apr 1, 2020
1 parent 04bf9af commit 02f4ad6
Show file tree
Hide file tree
Showing 128 changed files with 181 additions and 351 deletions.
2 changes: 1 addition & 1 deletion boards/airmind/mindpx-v2/src/spi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ constexpr px4_spi_bus_t px4_spi_buses[SPI_BUS_MAX_BUS_ITEMS] = {
}),
initSPIBus(SPI::Bus::SPI4, {
initSPIDevice(DRV_GYR_DEVTYPE_L3GD20, SPI::CS{GPIO::PortB, GPIO::Pin2}, SPI::DRDY{GPIO::PortE, GPIO::Pin4}),
initSPIDevice(DRV_ACC_DEVTYPE_LSM303D, SPI::CS{GPIO::PortD, GPIO::Pin11}),
initSPIDevice(DRV_IMU_DEVTYPE_LSM303D, SPI::CS{GPIO::PortD, GPIO::Pin11}),
initSPIDevice(DRV_BARO_DEVTYPE_MS5611, SPI::CS{GPIO::PortC, GPIO::Pin15}),
initSPIDevice(DRV_IMU_DEVTYPE_MPU6000, SPI::CS{GPIO::PortE, GPIO::Pin3}, SPI::DRDY{GPIO::PortE, GPIO::Pin10}),
initSPIDevice(DRV_IMU_DEVTYPE_MPU6500, SPI::CS{GPIO::PortE, GPIO::Pin3}, SPI::DRDY{GPIO::PortE, GPIO::Pin10}),
Expand Down
2 changes: 1 addition & 1 deletion boards/intel/aerofc-v1/aerofc_adc/AEROFC_ADC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
using namespace time_literals;

AEROFC_ADC::AEROFC_ADC(I2CSPIBusOption bus_option, int bus_number, int bus_frequency) :
I2C("AEROFC_ADC", AEROFC_ADC_DEVICE_PATH, bus_number, SLAVE_ADDR, bus_frequency),
I2C(DRV_ADC_DEVTYPE_AEROFC, MODULE_NAME, bus_number, SLAVE_ADDR, bus_frequency),
I2CSPIDriver(MODULE_NAME, px4::device_bus_to_wq(get_device_id()), bus_option, bus_number),
_sample_perf(perf_alloc(PC_ELAPSED, MODULE_NAME": sample"))
{
Expand Down
1 change: 0 additions & 1 deletion boards/intel/aerofc-v1/aerofc_adc/AEROFC_ADC.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
#define ADC_ENABLE_REG 0x00
#define ADC_CHANNEL_REG 0x03
#define MAX_CHANNEL 5
#define AEROFC_ADC_DEVICE_PATH "/dev/aerofc_adc"

class AEROFC_ADC : public device::I2C, public I2CSPIDriver<AEROFC_ADC>
{
Expand Down
4 changes: 2 additions & 2 deletions boards/px4/fmu-v2/src/spi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ constexpr px4_spi_bus_all_hw_t px4_spi_buses_all_hw[BOARD_NUM_SPI_CFG_HW_VERSION
initSPIDevice(DRV_IMU_DEVTYPE_MPU6000, SPI::CS{GPIO::PortC, GPIO::Pin2}, SPI::DRDY{GPIO::PortD, GPIO::Pin15}),
initSPIDevice(DRV_IMU_DEVTYPE_MPU9250, SPI::CS{GPIO::PortC, GPIO::Pin2}, SPI::DRDY{GPIO::PortD, GPIO::Pin15}),
initSPIDevice(DRV_GYR_DEVTYPE_L3GD20, SPI::CS{GPIO::PortC, GPIO::Pin13}, SPI::DRDY{GPIO::PortB, GPIO::Pin0}),
initSPIDevice(DRV_ACC_DEVTYPE_LSM303D, SPI::CS{GPIO::PortC, GPIO::Pin15}),
initSPIDevice(DRV_IMU_DEVTYPE_LSM303D, SPI::CS{GPIO::PortC, GPIO::Pin15}),
initSPIDevice(DRV_BARO_DEVTYPE_MS5611, SPI::CS{GPIO::PortD, GPIO::Pin7}),
initSPIDevice(DRV_BARO_DEVTYPE_MS5607, SPI::CS{GPIO::PortD, GPIO::Pin7}),
}, {GPIO::PortE, GPIO::Pin3}),
Expand Down Expand Up @@ -180,7 +180,7 @@ constexpr px4_spi_bus_all_hw_t px4_spi_buses_all_hw[BOARD_NUM_SPI_CFG_HW_VERSION
initSPIDevice(DRV_IMU_DEVTYPE_MPU9250, SPI::CS{GPIO::PortE, GPIO::Pin4}),
initSPIDevice(DRV_GYR_DEVTYPE_L3GD20, SPI::CS{GPIO::PortC, GPIO::Pin13}),
initSPIDevice(DRV_BARO_DEVTYPE_MS5611, SPI::CS{GPIO::PortC, GPIO::Pin14}),
initSPIDevice(DRV_ACC_DEVTYPE_LSM303D, SPI::CS{GPIO::PortC, GPIO::Pin15}),
initSPIDevice(DRV_IMU_DEVTYPE_LSM303D, SPI::CS{GPIO::PortC, GPIO::Pin15}),
}),
}),

Expand Down
4 changes: 2 additions & 2 deletions boards/px4/fmu-v3/src/spi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ constexpr px4_spi_bus_all_hw_t px4_spi_buses_all_hw[BOARD_NUM_SPI_CFG_HW_VERSION
initSPIDevice(DRV_IMU_DEVTYPE_MPU6000, SPI::CS{GPIO::PortC, GPIO::Pin2}, SPI::DRDY{GPIO::PortD, GPIO::Pin15}),
initSPIDevice(DRV_IMU_DEVTYPE_MPU9250, SPI::CS{GPIO::PortC, GPIO::Pin2}, SPI::DRDY{GPIO::PortD, GPIO::Pin15}),
initSPIDevice(DRV_GYR_DEVTYPE_L3GD20, SPI::CS{GPIO::PortC, GPIO::Pin13}, SPI::DRDY{GPIO::PortB, GPIO::Pin0}),
initSPIDevice(DRV_ACC_DEVTYPE_LSM303D, SPI::CS{GPIO::PortC, GPIO::Pin15}),
initSPIDevice(DRV_IMU_DEVTYPE_LSM303D, SPI::CS{GPIO::PortC, GPIO::Pin15}),
initSPIDevice(DRV_BARO_DEVTYPE_MS5611, SPI::CS{GPIO::PortD, GPIO::Pin7}),
initSPIDevice(DRV_BARO_DEVTYPE_MS5607, SPI::CS{GPIO::PortD, GPIO::Pin7}),
}, {GPIO::PortE, GPIO::Pin3}),
Expand Down Expand Up @@ -180,7 +180,7 @@ constexpr px4_spi_bus_all_hw_t px4_spi_buses_all_hw[BOARD_NUM_SPI_CFG_HW_VERSION
initSPIDevice(DRV_IMU_DEVTYPE_MPU9250, SPI::CS{GPIO::PortE, GPIO::Pin4}),
initSPIDevice(DRV_GYR_DEVTYPE_L3GD20, SPI::CS{GPIO::PortC, GPIO::Pin13}),
initSPIDevice(DRV_BARO_DEVTYPE_MS5611, SPI::CS{GPIO::PortC, GPIO::Pin14}),
initSPIDevice(DRV_ACC_DEVTYPE_LSM303D, SPI::CS{GPIO::PortC, GPIO::Pin15}),
initSPIDevice(DRV_IMU_DEVTYPE_LSM303D, SPI::CS{GPIO::PortC, GPIO::Pin15}),
}),
}),

Expand Down
1 change: 0 additions & 1 deletion src/drivers/barometer/bmp280/BMP280.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ BMP280::BMP280(I2CSPIBusOption bus_option, int bus, bmp280::IBMP280 *interface)
_measure_perf(perf_alloc(PC_ELAPSED, MODULE_NAME": measure")),
_comms_errors(perf_alloc(PC_COUNT, MODULE_NAME": comms errors"))
{
_px4_baro.set_device_type(DRV_BARO_DEVTYPE_BMP280);
}

BMP280::~BMP280()
Expand Down
2 changes: 1 addition & 1 deletion src/drivers/barometer/bmp280/BMP280_I2C.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ bmp280::IBMP280 *bmp280_i2c_interface(uint8_t busnum, uint32_t device, int bus_f
}

BMP280_I2C::BMP280_I2C(uint8_t bus, uint32_t device, int bus_frequency) :
I2C("BMP280_I2C", nullptr, bus, device, bus_frequency)
I2C(DRV_BARO_DEVTYPE_BMP280, MODULE_NAME, bus, device, bus_frequency)
{
}

Expand Down
2 changes: 1 addition & 1 deletion src/drivers/barometer/bmp280/BMP280_SPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ bmp280_spi_interface(uint8_t busnum, uint32_t device, int bus_frequency, spi_mod
}

BMP280_SPI::BMP280_SPI(uint8_t bus, uint32_t device, int bus_frequency, spi_mode_e spi_mode) :
SPI("BMP280_SPI", nullptr, bus, device, spi_mode, bus_frequency)
SPI(DRV_BARO_DEVTYPE_BMP280, MODULE_NAME, bus, device, spi_mode, bus_frequency)
{
}

Expand Down
1 change: 0 additions & 1 deletion src/drivers/barometer/bmp388/bmp388.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ BMP388::BMP388(I2CSPIBusOption bus_option, int bus, IBMP388 *interface) :
_measure_perf(perf_alloc(PC_ELAPSED, MODULE_NAME": measure")),
_comms_errors(perf_alloc(PC_COUNT, MODULE_NAME": comms errors"))
{
_px4_baro.set_device_type(DRV_BARO_DEVTYPE_BMP388);
}

BMP388::~BMP388()
Expand Down
2 changes: 1 addition & 1 deletion src/drivers/barometer/bmp388/bmp388_i2c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ IBMP388 *bmp388_i2c_interface(uint8_t busnum, uint32_t device, int bus_frequency
}

BMP388_I2C::BMP388_I2C(uint8_t bus, uint32_t device, int bus_frequency) :
I2C("BMP388_I2C", nullptr, bus, device, bus_frequency)
I2C(DRV_BARO_DEVTYPE_BMP388, MODULE_NAME, bus, device, bus_frequency)
{
}

Expand Down
2 changes: 1 addition & 1 deletion src/drivers/barometer/bmp388/bmp388_spi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ IBMP388 *bmp388_spi_interface(uint8_t busnum, uint32_t device, int bus_frequency
}

BMP388_SPI::BMP388_SPI(uint8_t bus, uint32_t device, int bus_frequency, spi_mode_e spi_mode) :
SPI("BMP388_SPI", nullptr, bus, device, spi_mode, bus_frequency)
SPI(DRV_BARO_DEVTYPE_BMP388, MODULE_NAME, bus, device, spi_mode, bus_frequency)
{
}

Expand Down
1 change: 0 additions & 1 deletion src/drivers/barometer/dps310/DPS310.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ DPS310::DPS310(I2CSPIBusOption bus_option, int bus, device::Device *interface) :
_sample_perf(perf_alloc(PC_ELAPSED, MODULE_NAME": read")),
_comms_errors(perf_alloc(PC_COUNT, MODULE_NAME": comm errors"))
{
_px4_barometer.set_device_type(DRV_BARO_DEVTYPE_DPS310);
}

DPS310::~DPS310()
Expand Down
2 changes: 1 addition & 1 deletion src/drivers/barometer/dps310/DPS310_I2C.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ DPS310_I2C_interface(uint8_t bus, uint32_t address, int bus_frequency)
}

DPS310_I2C::DPS310_I2C(uint8_t bus, uint32_t address, int bus_frequency) :
I2C("DPS310_I2C", nullptr, bus, address, bus_frequency)
I2C(DRV_BARO_DEVTYPE_DPS310, MODULE_NAME, bus, address, bus_frequency)
{
}

Expand Down
2 changes: 1 addition & 1 deletion src/drivers/barometer/dps310/DPS310_SPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ DPS310_SPI_interface(uint8_t bus, uint32_t device, int bus_frequency, spi_mode_e
}

DPS310_SPI::DPS310_SPI(uint8_t bus, uint32_t device, int bus_frequency, spi_mode_e spi_mode) :
SPI("DPS310_SPI", nullptr, bus, device, spi_mode, bus_frequency)
SPI(DRV_BARO_DEVTYPE_DPS310, MODULE_NAME, bus, device, spi_mode, bus_frequency)
{
}

Expand Down
6 changes: 2 additions & 4 deletions src/drivers/barometer/lps22hb/LPS22HB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,9 @@ LPS22HB::LPS22HB(I2CSPIBusOption bus_option, int bus, device::Device *interface)
CDev(nullptr),
I2CSPIDriver(MODULE_NAME, px4::device_bus_to_wq(interface->get_device_id()), bus_option, bus),
_interface(interface),
_sample_perf(perf_alloc(PC_ELAPSED, "lps22hb_read")),
_comms_errors(perf_alloc(PC_COUNT, "lps22hb_comms_errors"))
_sample_perf(perf_alloc(PC_ELAPSED, MODULE_NAME": read")),
_comms_errors(perf_alloc(PC_COUNT, MODULE_NAME": comms_errors"))
{
// set the interface device type
_interface->set_device_type(DRV_BARO_DEVTYPE_LPS22HB);
}

LPS22HB::~LPS22HB()
Expand Down
2 changes: 1 addition & 1 deletion src/drivers/barometer/lps22hb/LPS22HB_I2C.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ LPS22HB_I2C_interface(int bus, int bus_frequency)
}

LPS22HB_I2C::LPS22HB_I2C(int bus, int bus_frequency) :
I2C("LPS22HB_I2C", nullptr, bus, LPS22HB_ADDRESS, bus_frequency)
I2C(DRV_BARO_DEVTYPE_LPS22HB, MODULE_NAME, bus, LPS22HB_ADDRESS, bus_frequency)
{
}

Expand Down
3 changes: 1 addition & 2 deletions src/drivers/barometer/lps22hb/LPS22HB_SPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,8 @@ LPS22HB_SPI_interface(int bus, uint32_t devid, int bus_frequency, spi_mode_e spi
}

LPS22HB_SPI::LPS22HB_SPI(int bus, uint32_t device, int bus_frequency, spi_mode_e spi_mode)
: SPI("LPS22HB_SPI", nullptr, bus, device, spi_mode, bus_frequency)
: SPI(DRV_BARO_DEVTYPE_LPS22HB, MODULE_NAME, bus, device, spi_mode, bus_frequency)
{
_device_id.devid_s.devtype = DRV_BARO_DEVTYPE_LPS22HB;
}

int
Expand Down
2 changes: 0 additions & 2 deletions src/drivers/barometer/lps25h/LPS25H.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ LPS25H::LPS25H(I2CSPIBusOption bus_option, int bus, device::Device *interface) :
_sample_perf(perf_alloc(PC_ELAPSED, MODULE_NAME": read")),
_comms_errors(perf_alloc(PC_COUNT, MODULE_NAME": comms_errors"))
{
_interface->set_device_type(DRV_BARO_DEVTYPE_LPS25H);
_px4_barometer.set_device_type(DRV_BARO_DEVTYPE_LPS25H);
}

LPS25H::~LPS25H()
Expand Down
3 changes: 1 addition & 2 deletions src/drivers/barometer/lps25h/lps25h_i2c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,8 @@ device::Device *LPS25H_I2C_interface(int bus, int bus_frequency)
}

LPS25H_I2C::LPS25H_I2C(int bus, int bus_frequency) :
I2C("LPS25H_I2C", nullptr, bus, LPS25H_ADDRESS, bus_frequency)
I2C(DRV_BARO_DEVTYPE_LPS25H, MODULE_NAME, bus, LPS25H_ADDRESS, bus_frequency)
{
set_device_type(DRV_BARO_DEVTYPE_LPS25H);
}

int LPS25H_I2C::probe()
Expand Down
3 changes: 1 addition & 2 deletions src/drivers/barometer/lps25h/lps25h_spi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,8 @@ device::Device *LPS25H_SPI_interface(int bus, uint32_t devid, int bus_frequency,
}

LPS25H_SPI::LPS25H_SPI(int bus, uint32_t device, int bus_frequency, spi_mode_e spi_mode) :
SPI("LPS25H_SPI", nullptr, bus, device, spi_mode, bus_frequency)
SPI(DRV_BARO_DEVTYPE_LPS25H, MODULE_NAME, bus, device, spi_mode, bus_frequency)
{
set_device_type(DRV_BARO_DEVTYPE_LPS25H);
}

int LPS25H_SPI::init()
Expand Down
4 changes: 1 addition & 3 deletions src/drivers/barometer/mpl3115a2/MPL3115A2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,13 @@
#define MPL3115A2_CTRL_TRIGGER (CTRL_REG1_OST | CTRL_REG1_OS(MPL3115A2_OSR))

MPL3115A2::MPL3115A2(I2CSPIBusOption bus_option, const int bus, int bus_frequency) :
I2C("MPL3115A2", nullptr, bus, MPL3115A2_ADDRESS, bus_frequency),
I2C(DRV_BARO_DEVTYPE_MPL3115A2, MODULE_NAME, bus, MPL3115A2_ADDRESS, bus_frequency),
I2CSPIDriver(MODULE_NAME, px4::device_bus_to_wq(get_device_id()), bus_option, bus),
_px4_barometer(get_device_id()),
_sample_perf(perf_alloc(PC_ELAPSED, MODULE_NAME": read")),
_measure_perf(perf_alloc(PC_ELAPSED, MODULE_NAME": measure")),
_comms_errors(perf_alloc(PC_COUNT, MODULE_NAME": com_err"))
{
set_device_type(DRV_BARO_DEVTYPE_MPL3115A2);
_px4_barometer.set_device_type(DRV_BARO_DEVTYPE_MPL3115A2);
}

MPL3115A2::~MPL3115A2()
Expand Down
2 changes: 1 addition & 1 deletion src/drivers/barometer/ms5611/ms5611_i2c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ MS5611_i2c_interface(ms5611::prom_u &prom_buf, uint32_t devid, uint8_t busnum, i
}

MS5611_I2C::MS5611_I2C(uint8_t bus, ms5611::prom_u &prom, int bus_frequency) :
I2C("MS5611_I2C", nullptr, bus, 0, bus_frequency),
I2C(DRV_BARO_DEVTYPE_MS5611, MODULE_NAME, bus, 0, bus_frequency),
_prom(prom)
{
}
Expand Down
2 changes: 1 addition & 1 deletion src/drivers/barometer/ms5611/ms5611_spi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ MS5611_spi_interface(ms5611::prom_u &prom_buf, uint32_t devid, uint8_t busnum, i
}

MS5611_SPI::MS5611_SPI(uint8_t bus, uint32_t device, ms5611::prom_u &prom_buf, int bus_frequency, spi_mode_e spi_mode) :
SPI("MS5611_SPI", nullptr, bus, device, spi_mode, bus_frequency),
SPI(DRV_BARO_DEVTYPE_MS5611, MODULE_NAME, bus, device, spi_mode, bus_frequency),
_prom(prom_buf)
{
}
Expand Down
2 changes: 0 additions & 2 deletions src/drivers/distance_sensor/leddar_one/LeddarOne.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,9 @@ LeddarOne::LeddarOne(const char *serial_port, uint8_t device_orientation):
{
_serial_port = strdup(serial_port);

_px4_rangefinder.set_device_type(distance_sensor_s::MAV_DISTANCE_SENSOR_LASER);
_px4_rangefinder.set_max_distance(LEDDAR_ONE_MAX_DISTANCE);
_px4_rangefinder.set_min_distance(LEDDAR_ONE_MIN_DISTANCE);
_px4_rangefinder.set_fov(LEDDAR_ONE_FIELD_OF_VIEW);
_px4_rangefinder.set_orientation(device_orientation);
}

LeddarOne::~LeddarOne()
Expand Down
4 changes: 2 additions & 2 deletions src/drivers/distance_sensor/ll40ls/LidarLiteI2C.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@

LidarLiteI2C::LidarLiteI2C(I2CSPIBusOption bus_option, const int bus, const uint8_t rotation, int bus_frequency,
const int address) :
I2C("LL40LS", nullptr, bus, address, bus_frequency),
I2C(DRV_RNG_DEVTYPE_LL40LS, MODULE_NAME, bus, address, bus_frequency),
I2CSPIDriver(MODULE_NAME, px4::device_bus_to_wq(get_device_id()), bus_option, bus),
_px4_rangefinder(0 /* device id not yet used */, ORB_PRIO_DEFAULT, rotation)
_px4_rangefinder(get_device_id(), ORB_PRIO_DEFAULT, rotation)
{
_px4_rangefinder.set_min_distance(LL40LS_MIN_DISTANCE);
_px4_rangefinder.set_max_distance(LL40LS_MAX_DISTANCE);
Expand Down
3 changes: 1 addition & 2 deletions src/drivers/distance_sensor/mappydot/MappyDot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@
#define MAPPYDOT_MAX_DISTANCE (4.f) // meters

#define MAPPYDOT_BUS_CLOCK 400000 // 400kHz bus speed
#define MAPPYDOT_DEVICE_PATH "/dev/mappydot"

/* Configuration Constants */
#define MAPPYDOT_BASE_ADDR 0x08
Expand Down Expand Up @@ -222,7 +221,7 @@ class MappyDot : public device::I2C, public ModuleParams, public I2CSPIDriver<Ma


MappyDot::MappyDot(I2CSPIBusOption bus_option, const int bus, int bus_frequency) :
I2C("MappyDot", MAPPYDOT_DEVICE_PATH, bus, MAPPYDOT_BASE_ADDR, bus_frequency),
I2C(DRV_DIST_DEVTYPE_MAPPYDOT, MODULE_NAME, bus, MAPPYDOT_BASE_ADDR, bus_frequency),
ModuleParams(nullptr),
I2CSPIDriver(MODULE_NAME, px4::device_bus_to_wq(get_device_id()), bus_option, bus)
{}
Expand Down
3 changes: 1 addition & 2 deletions src/drivers/distance_sensor/mb12xx/mb12xx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ using namespace time_literals;
#define MB12XX_BASE_ADDR 0x70 // 7-bit address is 0x70 = 112. 8-bit address is 0xE0 = 224.
#define MB12XX_MIN_ADDR 0x5A // 7-bit address is 0x5A = 90. 8-bit address is 0xB4 = 180.
#define MB12XX_BUS_SPEED 100000 // 100kHz bus speed.
#define MB12XX_DEVICE_PATH "/dev/mb12xx"

/* MB12xx Registers addresses */
#define MB12XX_TAKE_RANGE_REG 0x51 // Measure range Register.
Expand Down Expand Up @@ -179,7 +178,7 @@ class MB12XX : public device::I2C, public ModuleParams, public I2CSPIDriver<MB12
};

MB12XX::MB12XX(I2CSPIBusOption bus_option, const int bus, int bus_frequency, int address) :
I2C("MB12xx", MB12XX_DEVICE_PATH, bus, address, bus_frequency),
I2C(DRV_DIST_DEVTYPE_MB12XX, MODULE_NAME, bus, address, bus_frequency),
ModuleParams(nullptr),
I2CSPIDriver(MODULE_NAME, px4::device_bus_to_wq(get_device_id()), bus_option, bus, address)
{
Expand Down
4 changes: 2 additions & 2 deletions src/drivers/distance_sensor/pga460/pga460.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ uint8_t PGA460::calc_checksum(uint8_t *data, const uint8_t size)

int PGA460::close_serial()
{
int ret = px4_close(_fd);
int ret = ::close(_fd);

if (ret != 0) {
PX4_WARN("Could not close serial port");
Expand Down Expand Up @@ -292,7 +292,7 @@ float PGA460::get_temperature()

int PGA460::open_serial()
{
_fd = px4_open(_port, O_RDWR | O_NOCTTY | O_NONBLOCK);
_fd = ::open(_port, O_RDWR | O_NOCTTY | O_NONBLOCK);

if (_fd < 0) {
PX4_WARN("Failed to open serial port");
Expand Down
2 changes: 1 addition & 1 deletion src/drivers/distance_sensor/pga460/pga460.h
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ class PGA460 : public ModuleBase<PGA460>
/** @orb_advert_t orb_advert_t uORB advertisement topic. */
orb_advert_t _distance_sensor_topic{nullptr};

/** @param _fd Returns the file descriptor from px4_open(). */
/** @param _fd Returns the file descriptor from open(). */
int _fd{-1};

/** @param _port Stores the port name. */
Expand Down
2 changes: 0 additions & 2 deletions src/drivers/distance_sensor/sf0x/SF0X.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ SF0X::SF0X(const char *port, uint8_t rotation) :

/* enforce null termination */
_port[sizeof(_port) - 1] = '\0';

_px4_rangefinder.set_device_type(distance_sensor_s::MAV_DISTANCE_SENSOR_LASER);
}

SF0X::~SF0X()
Expand Down
4 changes: 1 addition & 3 deletions src/drivers/distance_sensor/sf1xx/sf1xx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@

/* Configuration Constants */
#define SF1XX_BASEADDR 0x66
#define SF1XX_DEVICE_PATH "/dev/sf1xx"


class SF1XX : public device::I2C, public I2CSPIDriver<SF1XX>
{
Expand Down Expand Up @@ -166,7 +164,7 @@ class SF1XX : public device::I2C, public I2CSPIDriver<SF1XX>
extern "C" __EXPORT int sf1xx_main(int argc, char *argv[]);

SF1XX::SF1XX(I2CSPIBusOption bus_option, const int bus, const uint8_t rotation, int bus_frequency, int address) :
I2C("SF1XX", SF1XX_DEVICE_PATH, bus, address, bus_frequency),
I2C(DRV_DIST_DEVTYPE_SF1XX, MODULE_NAME, bus, address, bus_frequency),
I2CSPIDriver(MODULE_NAME, px4::device_bus_to_wq(get_device_id()), bus_option, bus),
_rotation(rotation)
{
Expand Down
4 changes: 2 additions & 2 deletions src/drivers/distance_sensor/srf02/SRF02.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
#include "SRF02.hpp"

SRF02::SRF02(I2CSPIBusOption bus_option, const int bus, const uint8_t rotation, int bus_frequency, int address) :
I2C("SRF02", nullptr, bus, address, bus_frequency),
I2C(DRV_DIST_DEVTYPE_SRF02, MODULE_NAME, bus, address, bus_frequency),
I2CSPIDriver(MODULE_NAME, px4::device_bus_to_wq(get_device_id()), bus_option, bus),
_px4_rangefinder(0 /* device id not yet used */, ORB_PRIO_DEFAULT, rotation)
_px4_rangefinder(get_device_id(), ORB_PRIO_DEFAULT, rotation)
{
_px4_rangefinder.set_max_distance(SRF02_MAX_DISTANCE);
_px4_rangefinder.set_min_distance(SRF02_MIN_DISTANCE);
Expand Down
4 changes: 2 additions & 2 deletions src/drivers/distance_sensor/teraranger/TERARANGER.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ static uint8_t crc8(uint8_t *p, uint8_t len)
}

TERARANGER::TERARANGER(I2CSPIBusOption bus_option, const int bus, const uint8_t rotation, int bus_frequency) :
I2C("TERARANGER", nullptr, bus, TERARANGER_ONE_BASEADDR, bus_frequency),
I2C(DRV_DIST_DEVTYPE_TERARANGER, MODULE_NAME, bus, TERARANGER_ONE_BASEADDR, bus_frequency),
I2CSPIDriver(MODULE_NAME, px4::device_bus_to_wq(get_device_id()), bus_option, bus),
_px4_rangefinder(0 /* device id not yet used */, ORB_PRIO_DEFAULT, rotation)
_px4_rangefinder(get_device_id(), ORB_PRIO_DEFAULT, rotation)
{
// up the retries since the device misses the first measure attempts
I2C::_retries = 3;
Expand Down
2 changes: 1 addition & 1 deletion src/drivers/distance_sensor/vl53l0x/VL53L0X.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
#define VL53L0X_BUS_CLOCK 400000 // 400kHz bus clock speed

VL53L0X::VL53L0X(I2CSPIBusOption bus_option, const int bus, const uint8_t rotation, int bus_frequency, int address) :
I2C("VL53L0X", nullptr, bus, address, bus_frequency),
I2C(DRV_DIST_DEVTYPE_VL53L0X, MODULE_NAME, bus, address, bus_frequency),
I2CSPIDriver(MODULE_NAME, px4::device_bus_to_wq(get_device_id()), bus_option, bus),
_px4_rangefinder(0 /* device id not yet used */, ORB_PRIO_DEFAULT, rotation)
{
Expand Down
Loading

0 comments on commit 02f4ad6

Please sign in to comment.