Skip to content

Commit c183b32

Browse files
committed
adc: Update ibat measurement unit
Signed-off-by: Audun Korneliussen <[email protected]>
1 parent 7f3bbb1 commit c183b32

File tree

4 files changed

+6
-3
lines changed

4 files changed

+6
-3
lines changed

drivers/npmx/shell/adc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ static int adc_meas_get(const struct shell *shell, npmx_adc_meas_t adc_meas,
5959
unit_type = UNIT_TYPE_MILLIVOLT;
6060
break;
6161
case NPMX_ADC_MEAS_VBAT2_IBAT:
62-
unit_type = UNIT_TYPE_MILLIAMPERE;
62+
unit_type = UNIT_TYPE_MICROAMPERE;
6363
break;
6464
default:
6565
return 0;

drivers/npmx/shell/shell_common.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ static const struct device *pmic_dev = DEVICE_DT_GET(DT_NODELABEL(npm_0));
1313
static const char *unit_str_get(unit_type_t unit_type)
1414
{
1515
switch (unit_type) {
16+
case UNIT_TYPE_MICROAMPERE:
17+
return " µA";
1618
case UNIT_TYPE_MILLIAMPERE:
1719
return " mA";
1820
case UNIT_TYPE_MILLIVOLT:

drivers/npmx/shell/shell_common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ typedef struct {
4545

4646
/** @brief Supported unit types. */
4747
typedef enum {
48+
UNIT_TYPE_MICROAMPERE, /* Unit type uA. */
4849
UNIT_TYPE_MILLIAMPERE, /* Unit type mA. */
4950
UNIT_TYPE_MILLIVOLT, /* Unit type mV. */
5051
UNIT_TYPE_CELSIUS, /* Unit type *C. */

samples/fuel_gauge/src/fuel_gauge.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ static int read_sensors(npmx_instance_t *const p_pm, float *voltage, float *curr
4343
return -EIO;
4444
}
4545

46-
/* Convert current in milliamperes to current in amperes. */
47-
*current = (float)meas.values[NPMX_ADC_MEAS_VBAT2_IBAT] / 1000.0f;
46+
/* Convert current in microamperes to current in amperes. */
47+
*current = (float)meas.values[NPMX_ADC_MEAS_VBAT2_IBAT] / 1000000.0f;
4848

4949
/* Convert temperature in millidegrees Celsius to temperature in Celsius */
5050
*temp = (float)meas.values[NPMX_ADC_MEAS_BAT_TEMP] / 1000.0f;

0 commit comments

Comments
 (0)