I am working with this INA260 library. In the Advanced Example I find this:
// create an instance of the register structure. note the ={0} used
// to zero-initialize the instance. You could also use memset() or
// manually initialize all of the fields to zero. All of the fields
// are written to the config. register so you want to make sure you
// know what they're all set to.
INA260::ConfigurationRegister configReg = {0};
configReg.mode = INA260::MODE_ISH_VBUS_CONTINUOUS; // continuously sample voltage and current (this is default)
configReg.ishct = INA260::ISHCT_1_1MS; // allow 2.116ms also for the ADC sampling of the current
configReg.vbusct = INA260::VBUSCT_1_1MS; // allow 2.116ms for the ADC sampling of the bus voltage
configReg.avg = INA260::AVG_16; // average 64 samples for each reading
ina260.writeConfigurationRegister(configReg); //Write the configuration register to the INA260 over I2C
... and this, I think, is the relevant section from INA260.h:
union ConfigurationRegister {
struct __attribute__((packed)) {
uint16_t mode : 3;
uint16_t ishct : 3;
uint16_t vbusct : 3;
uint16_t avg : 3;
uint16_t : 3;
uint16_t rst : 1;
};
uint16_t rawValue;
};
... which is mapping to this hardware:
How do I print (in binary format) this structure to see if I am doing what I think I am?
Regards, M.
