Skip to content

Commit 910d288

Browse files
committed
loader: fix unoq analog_reference return values
Restore a minimal error handling for analog_reference() by returning an int status code. Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
1 parent 814ad18 commit 910d288

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

loader/fixups.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ SYS_INIT(maybe_flash_bootloader, POST_KERNEL, CONFIG_FILE_SYSTEM_INIT_PRIORITY);
195195

196196
int analog_reference(uint8_t reference) {
197197
uint8_t init_status;
198+
198199
/* VREF+ is connected to VDDA by default */
199200
const struct gpio_dt_spec spec =
200201
GPIO_DT_SPEC_GET_BY_IDX(DT_PATH(zephyr_user), analog_switch_gpios, 0);
@@ -210,7 +211,7 @@ int analog_reference(uint8_t reference) {
210211
if (reference == AR_DEFAULT) {
211212
/* VREF+ is connected to VDDA */
212213
gpio_pin_set_dt(&spec, 0);
213-
return;
214+
return 0;
214215
}
215216

216217
gpio_pin_set_dt(&spec, 1);
@@ -236,7 +237,7 @@ int analog_reference(uint8_t reference) {
236237
}
237238

238239
HAL_SYSCFG_VREFBUF_VoltageScalingConfig(voltageScaling);
239-
HAL_SYSCFG_EnableVREFBUF();
240+
init_status = HAL_SYSCFG_EnableVREFBUF();
240241
HAL_SYSCFG_VREFBUF_HighImpedanceConfig(SYSCFG_VREFBUF_HIGH_IMPEDANCE_DISABLE);
241242

242243
__ASSERT(init_status == HAL_OK, "ADC Conversion value may be incorrect");
@@ -248,7 +249,7 @@ EXPORT_SYMBOL(analog_reference);
248249

249250
int disable_vrefbuf() {
250251
// This is the safe HW configuration
251-
analog_reference(AR_DEFAULT);
252+
return analog_reference(AR_DEFAULT);
252253
}
253254

254255
SYS_INIT(disable_vrefbuf, POST_KERNEL, 0);

0 commit comments

Comments
 (0)