Revision f8cf404d components/power/ina219.cpp

View differences:

components/power/ina219.cpp
2 2

  
3 3
#include <ch.hpp>
4 4
#include <chprintf.h>
5
#include <global.hpp>
5 6

  
6 7
using namespace chibios_rt;
7 8
using namespace amiro;
8 9
using namespace INA219;
9 10

  
11
extern Global global;
12

  
10 13
Driver::Driver(I2CDriver &i2c_driver, const uint8_t i2c_address) :
11 14
  BaseSensor<InitData,CalibData>(), i2c_driver(&i2c_driver), tx_params({i2c_address, NULL, 0, NULL, 0}), current_lsb_uA(0)
12 15
{
......
225 228
    bus_voltage = this->readBusVoltage();
226 229
    this->readRegister(REG_POWER, power);
227 230
  }
228
  chprintf((BaseSequentialStream*) &SD1, "shunt voltage : %fV\n", this->readShuntVoltage_uV() / 1000000.f);
229
  chprintf((BaseSequentialStream*) &SD1, "bus voltage   : %fV\n", bus_voltage.voltage_uV / 1000000.f);
230
  chprintf((BaseSequentialStream*) &SD1, "power         : %fW\n", this->readPower_uW() / 1000000.f);
231
  chprintf((BaseSequentialStream*) &SD1, "current       : %fA\n", this->readCurrent_uA() / 1000000.f);
231
  chprintf((BaseSequentialStream*) &global.sercanmux1, "shunt voltage : %fV\n", this->readShuntVoltage_uV() / 1000000.f);
232
  chprintf((BaseSequentialStream*) &global.sercanmux1, "bus voltage   : %fV\n", bus_voltage.voltage_uV / 1000000.f);
233
  chprintf((BaseSequentialStream*) &global.sercanmux1, "power         : %fW\n", this->readPower_uW() / 1000000.f);
234
  chprintf((BaseSequentialStream*) &global.sercanmux1, "current       : %fA\n", this->readCurrent_uA() / 1000000.f);
232 235

  
233 236
  return ST_OK;
234 237
}
......
343 346
      dst &= MASK_CALIBRATION;
344 347
#ifndef NDEBUG
345 348
  } else {
346
    chprintf((BaseSequentialStream*) &SD1, "%s(%d): ERROR: i2c transmit failed (%d | 0x%08X)\n", __FILE__ , __LINE__ , res, this->i2c_driver->getErrors());
349
    chprintf((BaseSequentialStream*) &global.sercanmux1, "%s(%d): ERROR: i2c transmit failed (%d | 0x%08X)\n", __FILE__ , __LINE__ , res, this->i2c_driver->getErrors());
347 350
#endif
348 351
  }
349 352

  
......
366 369

  
367 370
#ifndef NDEBUG
368 371
  if (res) {
369
    chprintf((BaseSequentialStream*) &SD1, "%s(%d): ERROR: i2c transmit failed (%d | 0x%08X)\n", __FILE__ , __LINE__ , res, this->i2c_driver->getErrors());
372
    chprintf((BaseSequentialStream*) &global.sercanmux1, "%s(%d): ERROR: i2c transmit failed (%d | 0x%08X)\n", __FILE__ , __LINE__ , res, this->i2c_driver->getErrors());
370 373
  }
371 374
#endif
372 375

  

Also available in: Unified diff