Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
INA226 Class Reference
INA226 High-or Low-Side Measurement,Bi-Directional CURRENT/POWER MONITOR with I2C Interface. More...
#include <INA226.h>
Public Member Functions | |
| INA226 (PinName p_sda, PinName p_scl, const INA226_TypeDef *ina226_parameter) | |
| Configure data pin. | |
| INA226 (I2C &p_i2c, const INA226_TypeDef *ina226_parameter) | |
| Configure data pin (with other devices on I2C line) | |
| float | read_current (void) |
| Read Current data. | |
| float | read_power (void) |
| Read Power data. | |
| float | read_bus_voltage (void) |
| Read Bus voltage. | |
| float | read_shunt_voltage (void) |
| Read Shunt voltage data. | |
| int16_t | read_shunt_raw_voltage (void) |
| Read Shunt voltage data. | |
| uint16_t | read_config (void) |
| Read configration reg. | |
| uint16_t | set_config (uint16_t cfg) |
| Set configration reg. | |
| uint16_t | read_calb (void) |
| Read calibration reg. | |
| uint16_t | set_calb (uint16_t clb) |
| Set calibration reg. | |
| uint16_t | read_msk_enbl (void) |
| Read Mask/Enable reg. | |
| uint16_t | set_msk_enbl (uint16_t clb) |
| Set Mask/Enable reg. | |
| uint8_t | read_ID () |
| Read ID. | |
| void | frequency (int hz) |
| Set I2C clock frequency. | |
| uint8_t | read_reg (uint8_t addr) |
| Read register (general purpose) | |
| uint8_t | write_reg (uint8_t addr, uint8_t data) |
| Write register (general purpose) | |
Detailed Description
INA226 High-or Low-Side Measurement,Bi-Directional CURRENT/POWER MONITOR with I2C Interface.
//--------- Default setting ----------------- #include "mbed.h" #include "INA226.h" // I2C Communication INA226 current(dp5, dp27, INA226_ADDR_GG); // If you connected I2C line not only this device but also other devices, // you need to declare following method. I2C i2c(dp5, dp27); INA226 current(I2C& p_i2c, INA226_ADDR_GG); int main() { while(1){ printf("I=%+6.3f [A]\r\n", current.read_current()); wait(1.0): } } //--------- Detail setting ----------------- #include "mbed.h" #include "INA226.h" const INA226_TypeDef ina226_my_paramtr = { // I2C Address INA226_ADDR_GG, // CONFIG REG INA226_PAR_R_100MOHM, // 100 milli-ohm INA226_PAR_A_1, // Averaging Mode INA226_CFG_BUS_V_T1R1, // Bus Voltage Conversion Time INA226_CFG_SHT_V_T1R1, // Shunt Voltage Conversion Time INA226_PAR_M_SHNTBUS_CONT,// Operating Mode // CALBLATION REG 2560 }; I2C i2c(dp5,dp27); INA226 current(I2C& p_i2c, &ina226_my_paramtr); int main() { while(1){ printf("I=%+6.3f [A]\r\n", current.read_current()); wait(1.0): } }
Definition at line 176 of file INA226.h.
Constructor & Destructor Documentation
| INA226 | ( | PinName | p_sda, |
| PinName | p_scl, | ||
| const INA226_TypeDef * | ina226_parameter | ||
| ) |
Configure data pin.
- Parameters:
-
data SDA and SCL pins parameter address chip (INA226_TypeDef) or just set address or just port
Definition at line 16 of file INA226.cpp.
| INA226 | ( | I2C & | p_i2c, |
| const INA226_TypeDef * | ina226_parameter | ||
| ) |
Configure data pin (with other devices on I2C line)
- Parameters:
-
I2C previous definition parameter address chip (INA226_TypeDef) or just set address or just port
Definition at line 44 of file INA226.cpp.
Member Function Documentation
| void frequency | ( | int | hz ) |
| float read_bus_voltage | ( | void | ) |
| uint16_t read_calb | ( | void | ) |
Read calibration reg.
- Parameters:
-
none
- Returns:
- calibration register value
Definition at line 153 of file INA226.cpp.
| uint16_t read_config | ( | void | ) |
Read configration reg.
- Parameters:
-
none
- Returns:
- configrartion register value
Definition at line 132 of file INA226.cpp.
| float read_current | ( | void | ) |
| uint8_t read_ID | ( | ) |
| uint16_t read_msk_enbl | ( | void | ) |
Read Mask/Enable reg.
- Parameters:
-
none
- Returns:
- calibration register value
Definition at line 174 of file INA226.cpp.
| float read_power | ( | void | ) |
| uint8_t read_reg | ( | uint8_t | addr ) |
Read register (general purpose)
- Parameters:
-
register's address
- Returns:
- register data
Definition at line 204 of file INA226.cpp.
| int16_t read_shunt_raw_voltage | ( | void | ) |
Read Shunt voltage data.
- Parameters:
-
none
- Returns:
- voltage related value
Definition at line 122 of file INA226.cpp.
| float read_shunt_voltage | ( | void | ) |
Read Shunt voltage data.
- Parameters:
-
none
- Returns:
- voltage [v]
Definition at line 103 of file INA226.cpp.
| uint16_t set_calb | ( | uint16_t | clb ) |
Set calibration reg.
- Parameters:
-
calibration data
- Returns:
- calibration register value
Definition at line 163 of file INA226.cpp.
| uint16_t set_config | ( | uint16_t | cfg ) |
Set configration reg.
- Parameters:
-
configuration data
- Returns:
- configrartion register value
Definition at line 142 of file INA226.cpp.
| uint16_t set_msk_enbl | ( | uint16_t | clb ) |
Set Mask/Enable reg.
- Parameters:
-
mask enable data
- Returns:
- calibration register value
Definition at line 184 of file INA226.cpp.
| uint8_t write_reg | ( | uint8_t | addr, |
| uint8_t | data | ||
| ) |
Write register (general purpose)
- Parameters:
-
register's address data
- Returns:
- register data
Definition at line 212 of file INA226.cpp.
Generated on Wed Aug 10 2022 13:36:09 by
1.7.2