Skip to content

Commit 26a75f7

Browse files
authored
Merge pull request #4862 from DavePutz/issue_3383
Fix for issue #3383 - SAMD5x microcontroller.cpu.voltage
2 parents c6dee52 + bc34403 commit 26a75f7

File tree

2 files changed

+1
-11
lines changed

2 files changed

+1
-11
lines changed

ports/atmel-samd/common-hal/microcontroller/Processor.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,9 +279,6 @@ float common_hal_mcu_processor_get_temperature(void) {
279279
}
280280

281281
float common_hal_mcu_processor_get_voltage(void) {
282-
#if MICROCONTROLLER_VOLTAGE_DISABLE
283-
return NAN;
284-
#else
285282
struct adc_sync_descriptor adc;
286283

287284
static Adc *adc_insts[] = ADC_INSTS;
@@ -292,6 +289,7 @@ float common_hal_mcu_processor_get_voltage(void) {
292289
#endif
293290

294291
#ifdef SAM_D5X_E5X
292+
hri_supc_clear_VREF_ONDEMAND_bit(SUPC);
295293
hri_supc_set_VREF_SEL_bf(SUPC, SUPC_VREF_SEL_1V0_Val);
296294
hri_supc_set_VREF_VREFOE_bit(SUPC);
297295

@@ -326,7 +324,6 @@ float common_hal_mcu_processor_get_voltage(void) {
326324
adc_sync_deinit(&adc);
327325
// Multiply by 4 to compensate for SCALEDIOVCC division by 4.
328326
return (reading / 4095.0f) * 4.0f;
329-
#endif
330327
}
331328

332329
uint32_t common_hal_mcu_processor_get_frequency(void) {

ports/atmel-samd/mpconfigport.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,6 @@
7373
#define MICROPY_PY_SYS_PLATFORM "MicroChip SAMD51"
7474
#elif defined(SAME54)
7575
#define MICROPY_PY_SYS_PLATFORM "MicroChip SAME54"
76-
#ifndef MICROCONTROLLER_VOLTAGE_DISABLE
77-
#define MICROCONTROLLER_VOLTAGE_DISABLE (1)
78-
#endif
7976
#endif
8077
#define SPI_FLASH_MAX_BAUDRATE 24000000
8178
#define MICROPY_PY_BUILTINS_NOTIMPLEMENTED (1)
@@ -243,8 +240,4 @@
243240
CIRCUITPY_COMMON_ROOT_POINTERS \
244241
mp_obj_t playing_audio[AUDIO_DMA_CHANNEL_COUNT];
245242

246-
#ifndef MICROCONTROLLER_VOLTAGE_DISABLE
247-
#define MICROCONTROLLER_VOLTAGE_DISABLE (0)
248-
#endif
249-
250243
#endif // __INCLUDED_MPCONFIGPORT_H

0 commit comments

Comments
 (0)