diff --git a/ports/atmel-samd/common-hal/microcontroller/Processor.c b/ports/atmel-samd/common-hal/microcontroller/Processor.c index 199f19354b..ba8daf3fb0 100644 --- a/ports/atmel-samd/common-hal/microcontroller/Processor.c +++ b/ports/atmel-samd/common-hal/microcontroller/Processor.c @@ -61,6 +61,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include + #include "py/mphal.h" #include "common-hal/microcontroller/Processor.h" @@ -276,6 +278,9 @@ float common_hal_mcu_processor_get_temperature(void) { } float common_hal_mcu_processor_get_voltage(void) { +#if MICROCONTROLLER_VOLTAGE_DISABLE + return NAN; +#else struct adc_sync_descriptor adc; static Adc* adc_insts[] = ADC_INSTS; @@ -320,6 +325,7 @@ float common_hal_mcu_processor_get_voltage(void) { adc_sync_deinit(&adc); // Multiply by 4 to compensate for SCALEDIOVCC division by 4. return (reading / 4095.0f) * 4.0f; +#endif } uint32_t common_hal_mcu_processor_get_frequency(void) { diff --git a/ports/atmel-samd/mpconfigport.h b/ports/atmel-samd/mpconfigport.h index 2a2428d679..f185142e47 100644 --- a/ports/atmel-samd/mpconfigport.h +++ b/ports/atmel-samd/mpconfigport.h @@ -75,6 +75,9 @@ #define MICROPY_PY_SYS_PLATFORM "MicroChip SAMD51" #elif defined(SAME54) #define MICROPY_PY_SYS_PLATFORM "MicroChip SAME54" +#ifndef MICROCONTROLLER_VOLTAGE_DISABLE +#define MICROCONTROLLER_VOLTAGE_DISABLE (1) +#endif #endif #define SPI_FLASH_MAX_BAUDRATE 24000000 #define MICROPY_PY_BUILTINS_NOTIMPLEMENTED (1) @@ -246,4 +249,8 @@ CIRCUITPY_COMMON_ROOT_POINTERS \ mp_obj_t playing_audio[AUDIO_DMA_CHANNEL_COUNT]; +#ifndef MICROCONTROLLER_VOLTAGE_DISABLE +#define MICROCONTROLLER_VOLTAGE_DISABLE (0) +#endif + #endif // __INCLUDED_MPCONFIGPORT_H