For INA3221 current sensor, I found this library, however, I don't understand how to use the INA3221SetConfig() function as defined in the .cpp file link.
void SDL_Arduino_INA3221::INA3221SetConfig(void)
{
// Set Config register to take into account the settings above
uint16_t config =
INA3221_CONFIG_ENABLE_CHAN1 |
// INA3221_CONFIG_ENABLE_CHAN2 |
// INA3221_CONFIG_ENABLE_CHAN3 |
INA3221_CONFIG_RESET |
INA3221_CONFIG_AVG1 |
INA3221_CONFIG_VBUS_CT2 |
INA3221_CONFIG_VSH_CT2 |
INA3221_CONFIG_MODE_2 |
INA3221_CONFIG_MODE_1 |
INA3221_CONFIG_MODE_0;
wireWriteRegister(INA3221_REG_CONFIG, config);
}
It seems like the function is called automatically when the .begin() function is called and whatever is defined in the config function is written to the register. The use of | operator confuses me. I tried to comment out the some settings to see if it works but it makes no difference. There isn't any documentation so I am in a fix. Could you please tell how can I change the configuration settings e.g. instead of all the three channels or change the config_mode?