INA219.Registers (ina219 v2.0.0)
The INA219 uses a bank of registers for holding configuration settings, measurement results, maximum/minimum limits, and status information.
registers
Registers
configuration-register
Configuration register
All-register reset, settings for bus voltage range, PGA Gain, ADC resolution/averaging. Read write.
shunt-voltage-register
Shunt Voltage register
Shunt voltage measurement data. Read only.
bus-voltage-register
Bus Voltage register
Bus voltage measurement data. Read-only,
power-register
Power register
Power measurement data. Read only.
current-register
Current register
Contains the value of the current flowing through the shunt resistor. Read only.
calibration-register
Calibration register
Sets full-scale range and LSB of current and power measurements. Overall system calibration. Read write.
Link to this section Summary
Functions
Read the contents of the bus_voltage
register.
Read the contents of the calibration
register.
Read the contents of the configuration
register.
Read the contents of the current
register.
Read the contents of the power
register.
Read the contents of the shunt_voltage
register.
Swap the contents of the calibration
register.
Swap the contents of the configuration
register.
Update the contents of the calibration
register using a
transformation function.
Update the contents of the configuration
register using a
transformation function.
Write new contents to the calibration
register.
Write new contents to the configuration
register.
Link to this section Functions
read_bus_voltage(conn)
@spec read_bus_voltage(Wafer.Conn.t()) :: {:ok, binary()} | {:error, reason :: any()}
Read the contents of the bus_voltage
register.
example
Example
iex> read_bus_voltage(conn)
{:ok, <<0, 0>>}
read_calibration(conn)
@spec read_calibration(Wafer.Conn.t()) :: {:ok, binary()} | {:error, reason :: any()}
Read the contents of the calibration
register.
example
Example
iex> read_calibration(conn)
{:ok, <<0, 0>>}
read_configuration(conn)
@spec read_configuration(Wafer.Conn.t()) :: {:ok, binary()} | {:error, reason :: any()}
Read the contents of the configuration
register.
example
Example
iex> read_configuration(conn)
{:ok, <<0, 0>>}
read_current(conn)
@spec read_current(Wafer.Conn.t()) :: {:ok, binary()} | {:error, reason :: any()}
Read the contents of the current
register.
example
Example
iex> read_current(conn)
{:ok, <<0, 0>>}
read_power(conn)
@spec read_power(Wafer.Conn.t()) :: {:ok, binary()} | {:error, reason :: any()}
Read the contents of the power
register.
example
Example
iex> read_power(conn)
{:ok, <<0, 0>>}
read_shunt_voltage(conn)
@spec read_shunt_voltage(Wafer.Conn.t()) :: {:ok, binary()} | {:error, reason :: any()}
Read the contents of the shunt_voltage
register.
example
Example
iex> read_shunt_voltage(conn)
{:ok, <<0, 0>>}
swap_calibration(conn, data)
@spec swap_calibration(Wafer.Conn.t(), data :: binary()) :: {:ok, Wafer.Conn.t()} | {:error, reason :: any()}
Swap the contents of the calibration
register.
Reads the contents of the register, then replaces it, returning the previous contents. Some drivers may implement this atomically.
example
Example
iex> swap_calibration(conn, <<0, 0>>)
{:ok, <<0, 0>>, _conn}
swap_configuration(conn, data)
@spec swap_configuration(Wafer.Conn.t(), data :: binary()) :: {:ok, Wafer.Conn.t()} | {:error, reason :: any()}
Swap the contents of the configuration
register.
Reads the contents of the register, then replaces it, returning the previous contents. Some drivers may implement this atomically.
example
Example
iex> swap_configuration(conn, <<0, 0>>)
{:ok, <<0, 0>>, _conn}
update_calibration(conn, callback)
@spec update_calibration(Wafer.Conn.t(), (<<_::_*16>> -> <<_::_*16>>)) :: {:ok, Wafer.Conn.t()} | {:error, reason :: any()}
Update the contents of the calibration
register using a
transformation function.
example
Example
iex> transform = fn <<data::size(16)>> -> <<(data * 2)::size(16)>> end
...> update_calibration(conn, transform)
{:ok, _conn}
update_configuration(conn, callback)
@spec update_configuration(Wafer.Conn.t(), (<<_::_*16>> -> <<_::_*16>>)) :: {:ok, Wafer.Conn.t()} | {:error, reason :: any()}
Update the contents of the configuration
register using a
transformation function.
example
Example
iex> transform = fn <<data::size(16)>> -> <<(data * 2)::size(16)>> end
...> update_configuration(conn, transform)
{:ok, _conn}
write_calibration(conn, data)
@spec write_calibration(Wafer.Conn.t(), data :: binary()) :: {:ok, Wafer.Conn.t()} | {:error, reason :: any()}
Write new contents to the calibration
register.
example
Example
iex> write_calibration(conn, <<0, 0>>)
{:ok, _conn}
write_configuration(conn, data)
@spec write_configuration(Wafer.Conn.t(), data :: binary()) :: {:ok, Wafer.Conn.t()} | {:error, reason :: any()}
Write new contents to the configuration
register.
example
Example
iex> write_configuration(conn, <<0, 0>>)
{:ok, _conn}