Skip to main content

calibration

Function calibration 

Source
pub fn calibration(current_lsb_microamps: u32, shunt_milliohms: u32) -> u16
Expand description

Computes the calibration register value for a chosen current resolution and shunt.

This is the datasheet’s calibration equation, `Cal = trunc(0.04096 / (Current_LSB

  • R_shunt)), expressed in integer micro-units: with the current LSB in microamps and the shunt in milliohms, the fixed 0.04096becomes40_960_000`.

§Arguments

  • current_lsb_microamps - the amps-per-count the current register should carry.
  • shunt_milliohms - the shunt resistor value, in milliohms.

§Returns

The 16-bit value to program into the calibration register. Returns 0 if either argument is 0, which is the chip’s own uncalibrated state.