mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-01 03:31:37 +08:00
Fill in the instance of the hall sensor msg with the i2c address
This commit is contained in:
committed by
JaeyoungLim
parent
e62a569f63
commit
ba72e93ffb
@@ -276,7 +276,7 @@ int SI7210::collect()
|
|||||||
|
|
||||||
/* generate a new report */
|
/* generate a new report */
|
||||||
report.timestamp = hrt_absolute_time();
|
report.timestamp = hrt_absolute_time();
|
||||||
report.instance = 0; //TODO: _instance
|
report.instance = _i2c_address;
|
||||||
report.mag_t = (float)(magRawData - MAG_BIAS) * MAG_CONV;
|
report.mag_t = (float)(magRawData - MAG_BIAS) * MAG_CONV;
|
||||||
report.temp_c = (float)((tempRawData & ~0x8000) >> 3);
|
report.temp_c = (float)((tempRawData & ~0x8000) >> 3);
|
||||||
report.temp_c = _tempGain * (TEMP_CONV_A2 * report.temp_c * report.temp_c + TEMP_CONV_A1 * report.temp_c + TEMP_CONV_A0
|
report.temp_c = _tempGain * (TEMP_CONV_A2 * report.temp_c * report.temp_c + TEMP_CONV_A1 * report.temp_c + TEMP_CONV_A0
|
||||||
|
|||||||
@@ -49,10 +49,7 @@
|
|||||||
#include <px4_platform_common/i2c_spi_buses.h>
|
#include <px4_platform_common/i2c_spi_buses.h>
|
||||||
#include <uORB/topics/sensor_hall.h>
|
#include <uORB/topics/sensor_hall.h>
|
||||||
|
|
||||||
#define I2C_ADDRESS_0_SI7210 0x30 /* SI7210 I2C address */
|
#define I2C_ADDRESS_SI7210 0x30 /* Default SI7210 I2C address */
|
||||||
#define I2C_ADDRESS_1_SI7210 0x31 /* SI7210 I2C address */
|
|
||||||
#define I2C_ADDRESS_2_SI7210 0x32 /* SI7210 I2C address */
|
|
||||||
#define I2C_ADDRESS_3_SI7210 0x33 /* SI7210 I2C address */
|
|
||||||
|
|
||||||
#define SI7210_MAX_DATA_RATE 50
|
#define SI7210_MAX_DATA_RATE 50
|
||||||
|
|
||||||
@@ -115,11 +112,12 @@
|
|||||||
class SI7210 : public Vane, public I2CSPIDriver<SI7210>
|
class SI7210 : public Vane, public I2CSPIDriver<SI7210>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SI7210(I2CSPIBusOption bus_option, const int bus, int bus_frequency, int address = I2C_ADDRESS_0_SI7210,
|
SI7210(I2CSPIBusOption bus_option, const int bus, int bus_frequency, int address = I2C_ADDRESS_SI7210,
|
||||||
bool keep_retrying = false) :
|
bool keep_retrying = false) :
|
||||||
Vane(bus, bus_frequency, address, SI7210_CONVERSION_INTERVAL),
|
Vane(bus, bus_frequency, address, SI7210_CONVERSION_INTERVAL),
|
||||||
I2CSPIDriver(MODULE_NAME, px4::device_bus_to_wq(get_device_id()), bus_option, bus, address),
|
I2CSPIDriver(MODULE_NAME, px4::device_bus_to_wq(get_device_id()), bus_option, bus, address),
|
||||||
_keep_retrying{keep_retrying}
|
_keep_retrying{keep_retrying},
|
||||||
|
_i2c_address{address}
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -188,6 +186,7 @@ private:
|
|||||||
uint16_t _scale{0};
|
uint16_t _scale{0};
|
||||||
const bool _keep_retrying;
|
const bool _keep_retrying;
|
||||||
State _state{State::RequireConfig};
|
State _state{State::RequireConfig};
|
||||||
|
int _i2c_address;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* SI7210_HPP_ */
|
#endif /* SI7210_HPP_ */
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ SI7210::print_usage()
|
|||||||
PRINT_MODULE_USAGE_SUBCATEGORY("airspeed_sensor");
|
PRINT_MODULE_USAGE_SUBCATEGORY("airspeed_sensor");
|
||||||
PRINT_MODULE_USAGE_COMMAND("start");
|
PRINT_MODULE_USAGE_COMMAND("start");
|
||||||
PRINT_MODULE_USAGE_PARAMS_I2C_SPI_DRIVER(true, false);
|
PRINT_MODULE_USAGE_PARAMS_I2C_SPI_DRIVER(true, false);
|
||||||
PRINT_MODULE_USAGE_PARAMS_I2C_ADDRESS(0x30);
|
PRINT_MODULE_USAGE_PARAMS_I2C_ADDRESS(I2C_ADDRESS_SI7210);
|
||||||
PRINT_MODULE_USAGE_PARAMS_I2C_KEEP_RUNNING_FLAG();
|
PRINT_MODULE_USAGE_PARAMS_I2C_KEEP_RUNNING_FLAG();
|
||||||
PRINT_MODULE_USAGE_DEFAULT_COMMANDS();
|
PRINT_MODULE_USAGE_DEFAULT_COMMANDS();
|
||||||
}
|
}
|
||||||
@@ -81,9 +81,12 @@ si7210_main(int argc, char *argv[])
|
|||||||
using ThisDriver = SI7210;
|
using ThisDriver = SI7210;
|
||||||
BusCLIArguments cli{true, false};
|
BusCLIArguments cli{true, false};
|
||||||
cli.default_i2c_frequency = 100000;
|
cli.default_i2c_frequency = 100000;
|
||||||
cli.i2c_address = I2C_ADDRESS_2_SI7210;
|
cli.i2c_address = I2C_ADDRESS_SI7210;
|
||||||
cli.support_keep_running = true;
|
cli.support_keep_running = true;
|
||||||
|
|
||||||
|
int ch;
|
||||||
|
while ((ch = cli.getopt(argc, argv, "")) != EOF) {}
|
||||||
|
|
||||||
const char *verb = cli.parseDefaultArguments(argc, argv);
|
const char *verb = cli.parseDefaultArguments(argc, argv);
|
||||||
|
|
||||||
if (!verb) {
|
if (!verb) {
|
||||||
|
|||||||
Reference in New Issue
Block a user