AP_TemperatureSensor: Update TSYS01 for Pixhawk2

This commit is contained in:
Willian Galvani 2019-09-27 09:39:48 -03:00 committed by Jacob Walser
parent 177f7bed81
commit 0c5753112a
3 changed files with 6 additions and 5 deletions

View File

@ -40,13 +40,16 @@ void Sub::init_ardupilot()
switch (AP_BoardConfig::get_board_type()) {
case AP_BoardConfig::PX4_BOARD_PIXHAWK2:
AP_Param::set_by_name("GND_EXT_BUS", 0);
celsius.init(0);
break;
default:
AP_Param::set_by_name("GND_EXT_BUS", 1);
celsius.init(1);
break;
}
#else
AP_Param::set_default_by_name("GND_EXT_BUS", 1);
celsius.init(1);
#endif
// identify ourselves correctly with the ground station
@ -71,8 +74,6 @@ void Sub::init_ardupilot()
barometer.init();
celsius.init();
// Register the mavlink service callback. This will run
// anytime there are more than 5ms remaining in a call to
// hal.scheduler->delay.

View File

@ -13,9 +13,9 @@ static const uint8_t TSYS01_CMD_READ_PROM = 0xA0;
static const uint8_t TSYS01_CMD_CONVERT = 0x40;
static const uint8_t TSYS01_CMD_READ_ADC = 0x00;
bool TSYS01::init()
bool TSYS01::init(uint8_t bus)
{
_dev = std::move(hal.i2c_mgr->get_device(1, TSYS01_ADDR));
_dev = std::move(hal.i2c_mgr->get_device(bus, TSYS01_ADDR));
if (!_dev) {
printf("TSYS01 device is null!");
return false;

View File

@ -13,7 +13,7 @@
class TSYS01 {
public:
bool init(void);
bool init(uint8_t bus);
float temperature(void) { return _temperature; } // temperature in degrees C
bool healthy(void) { // do we have a valid temperature reading?
#if CONFIG_HAL_BOARD == HAL_BOARD_SITL