Skip to content

Commit

Permalink
samples: pmic: Align samples to new convert functions
Browse files Browse the repository at this point in the history
Signed-off-by: Marcin Kleszcz <marcin.kleszcz@nordicsemi.no>
  • Loading branch information
mkleszcz-no authored and masz-nordic committed Jul 12, 2023
1 parent 0516eff commit 2cbb2aa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
10 changes: 8 additions & 2 deletions samples/buck/src/main.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Nordic Semiconductor ASA
* Copyright (c) 2022-2023 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: BSD-3-Clause
*/
Expand Down Expand Up @@ -87,7 +87,13 @@ static void get_and_log_voltage(npmx_buck_t *p_buck)
LOG_ERR("Unable to get voltage status.");
}

LOG_INF("Voltage BUCK1: %u mV.", npmx_buck_voltage_convert_to_mv(buck_voltage));
uint32_t voltage_mv;

if (npmx_buck_voltage_convert_to_mv(buck_voltage, &voltage_mv)) {
LOG_INF("Voltage BUCK1: %u mV.", voltage_mv);
} else {
LOG_ERR("Unable to convert voltage value to mV.");
}
}

/**
Expand Down
8 changes: 6 additions & 2 deletions samples/ldo/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,17 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME);
static void get_and_log_voltage(npmx_ldsw_t *p_ldsw)
{
npmx_ldsw_voltage_t ldsw_voltage;
uint32_t voltage_mv;

if (npmx_ldsw_ldo_voltage_get(p_ldsw, &ldsw_voltage) != NPMX_SUCCESS) {
LOG_ERR("Unable to get voltage status.");
}

LOG_INF("Voltage LDO%d: %d mV.", (p_ldsw->hw_index + 1),
npmx_ldsw_voltage_convert_to_mv(ldsw_voltage));
if (npmx_ldsw_voltage_convert_to_mv(ldsw_voltage, &voltage_mv)) {
LOG_INF("Voltage LDO%d: %d mV.", (p_ldsw->hw_index + 1), voltage_mv);
} else {
LOG_ERR("Unable to convert voltage value to mV.");
}
}

/**
Expand Down

0 comments on commit 2cbb2aa

Please sign in to comment.