Fill in the instance of the hall sensor msg with the i2c address

This commit is contained in:
Florian Achermann 2021-06-01 14:28:35 +02:00 committed by JaeyoungLim
parent e62a569f63
commit ba72e93ffb
3 changed files with 11 additions and 9 deletions

View File

@ -276,7 +276,7 @@ int SI7210::collect()
/* generate a new report */
report.timestamp = hrt_absolute_time();
report.instance = 0; //TODO: _instance
report.instance = _i2c_address;
report.mag_t = (float)(magRawData - MAG_BIAS) * MAG_CONV;
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

View File

@ -49,10 +49,7 @@
#include <px4_platform_common/i2c_spi_buses.h>
#include <uORB/topics/sensor_hall.h>
#define I2C_ADDRESS_0_SI7210 0x30 /* 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 I2C_ADDRESS_SI7210 0x30 /* Default SI7210 I2C address */
#define SI7210_MAX_DATA_RATE 50
@ -115,11 +112,12 @@
class SI7210 : public Vane, public I2CSPIDriver<SI7210>
{
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) :
Vane(bus, bus_frequency, address, SI7210_CONVERSION_INTERVAL),
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};
const bool _keep_retrying;
State _state{State::RequireConfig};
int _i2c_address;
};
#endif /* SI7210_HPP_ */

View File

@ -70,7 +70,7 @@ SI7210::print_usage()
PRINT_MODULE_USAGE_SUBCATEGORY("airspeed_sensor");
PRINT_MODULE_USAGE_COMMAND("start");
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_DEFAULT_COMMANDS();
}
@ -81,9 +81,12 @@ si7210_main(int argc, char *argv[])
using ThisDriver = SI7210;
BusCLIArguments cli{true, false};
cli.default_i2c_frequency = 100000;
cli.i2c_address = I2C_ADDRESS_2_SI7210;
cli.i2c_address = I2C_ADDRESS_SI7210;
cli.support_keep_running = true;
int ch;
while ((ch = cli.getopt(argc, argv, "")) != EOF) {}
const char *verb = cli.parseDefaultArguments(argc, argv);
if (!verb) {