mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-22 06:14:14 +08:00
Changes from pull request feedback
This commit is contained in:
@@ -114,30 +114,6 @@ I2C::probe()
|
||||
return OK;
|
||||
}
|
||||
|
||||
int
|
||||
I2C::write(const uint8_t *send, unsigned send_len)
|
||||
{
|
||||
int ret = OK;
|
||||
|
||||
I2C_SETFREQUENCY(_dev, _frequency);
|
||||
I2C_SETADDRESS(_dev, _address, 7);
|
||||
ret = I2C_WRITE(_dev, send, send_len);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
I2C::read(uint8_t *recv, unsigned recv_len)
|
||||
{
|
||||
int ret = OK;
|
||||
|
||||
I2C_SETFREQUENCY(_dev, _frequency);
|
||||
I2C_SETADDRESS(_dev, _address, 7);
|
||||
ret = I2C_READ(_dev, recv, recv_len);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
I2C::transfer(const uint8_t *send, unsigned send_len, uint8_t *recv, unsigned recv_len)
|
||||
{
|
||||
|
||||
@@ -84,26 +84,6 @@ protected:
|
||||
* Check for the presence of the device on the bus.
|
||||
*/
|
||||
virtual int probe();
|
||||
|
||||
/**
|
||||
* Perform an I2C write to the device.
|
||||
*
|
||||
* @param send Pointer to bytes to send.
|
||||
* @param send_len Number of bytes to send.
|
||||
* @return OK if the transfer was successful, -errno
|
||||
* otherwise.
|
||||
*/
|
||||
int write(const uint8_t *send, unsigned send_len);
|
||||
|
||||
/**
|
||||
* Perform an I2C read from the device.
|
||||
*
|
||||
* @param send Pointer to bytes to send.
|
||||
* @param send_len Number of bytes to send.
|
||||
* @return OK if the transfer was successful, -errno
|
||||
* otherwise.
|
||||
*/
|
||||
int read(uint8_t *recv, unsigned recv_len);
|
||||
|
||||
/**
|
||||
* Perform an I2C transaction to the device.
|
||||
|
||||
@@ -57,14 +57,14 @@ struct range_finder_report {
|
||||
};
|
||||
|
||||
/*
|
||||
* ObjDev tag for raw accelerometer data.
|
||||
* ObjDev tag for raw range finder data.
|
||||
*/
|
||||
ORB_DECLARE(sensor_range_finder);
|
||||
|
||||
/*
|
||||
* ioctl() definitions
|
||||
*
|
||||
* Accelerometer drivers also implement the generic sensor driver
|
||||
* Rangefinder drivers also implement the generic sensor driver
|
||||
* interfaces from drv_sensor.h
|
||||
*/
|
||||
|
||||
|
||||
@@ -37,6 +37,6 @@
|
||||
|
||||
APPNAME = mb12xx
|
||||
PRIORITY = SCHED_PRIORITY_DEFAULT
|
||||
STACKSIZE = 4096
|
||||
STACKSIZE = 2048
|
||||
|
||||
include $(APPDIR)/mk/app.mk
|
||||
|
||||
@@ -157,7 +157,7 @@ private:
|
||||
|
||||
/**
|
||||
* Set the min and max distance thresholds if you want the end points of the sensors
|
||||
* range to be bought in at all, otherwise it will use the defaults MB12XX_MIN_DISTANCE
|
||||
* range to be brought in at all, otherwise it will use the defaults MB12XX_MIN_DISTANCE
|
||||
* and MB12XX_MAX_DISTANCE
|
||||
*/
|
||||
void set_minimum_distance(float min);
|
||||
@@ -388,13 +388,13 @@ MB12XX::ioctl(struct file *filp, int cmd, unsigned long arg)
|
||||
|
||||
case RANGEFINDERIOCSETMINIUMDISTANCE:
|
||||
{
|
||||
set_minimum_distance((float)arg);
|
||||
set_minimum_distance(*(float *)arg);
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
case RANGEFINDERIOCSETMAXIUMDISTANCE:
|
||||
{
|
||||
set_maximum_distance((float)arg);
|
||||
set_maximum_distance(*(float *)arg);
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
@@ -471,8 +471,8 @@ MB12XX::measure()
|
||||
/*
|
||||
* Send the command to begin a measurement.
|
||||
*/
|
||||
uint8_t cmd[] = {MB12XX_TAKE_RANGE_REG};
|
||||
ret = I2C::write(&cmd[0], 1);
|
||||
uint8_t cmd = MB12XX_TAKE_RANGE_REG;
|
||||
ret = transfer(&cmd, 1, nullptr, 0);
|
||||
|
||||
if (OK != ret)
|
||||
{
|
||||
@@ -495,7 +495,7 @@ MB12XX::collect()
|
||||
|
||||
perf_begin(_sample_perf);
|
||||
|
||||
ret = I2C::read(&val[0], 2);
|
||||
ret = transfer(nullptr, 0, &val[0], 2);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user