Skip to content

Commit 1b29cea

Browse files
committed
sam e54: disable microcontroller.cpu.voltage
This hangs, and the usual workarounds didn't work.
1 parent a8e98cd commit 1b29cea

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@
6161
* POSSIBILITY OF SUCH DAMAGE.
6262
*/
6363

64+
#include <math.h>
65+
6466
#include "py/mphal.h"
6567
#include "common-hal/microcontroller/Processor.h"
6668

@@ -276,6 +278,9 @@ float common_hal_mcu_processor_get_temperature(void) {
276278
}
277279

278280
float common_hal_mcu_processor_get_voltage(void) {
281+
#if MICROCONTROLLER_VOLTAGE_DISABLE
282+
return NAN;
283+
#else
279284
struct adc_sync_descriptor adc;
280285

281286
static Adc* adc_insts[] = ADC_INSTS;
@@ -320,6 +325,7 @@ float common_hal_mcu_processor_get_voltage(void) {
320325
adc_sync_deinit(&adc);
321326
// Multiply by 4 to compensate for SCALEDIOVCC division by 4.
322327
return (reading / 4095.0f) * 4.0f;
328+
#endif
323329
}
324330

325331
uint32_t common_hal_mcu_processor_get_frequency(void) {

ports/atmel-samd/mpconfigport.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@
7575
#define MICROPY_PY_SYS_PLATFORM "MicroChip SAMD51"
7676
#elif defined(SAME54)
7777
#define MICROPY_PY_SYS_PLATFORM "MicroChip SAME54"
78+
#ifndef MICROCONTROLLER_VOLTAGE_DISABLE
79+
#define MICROCONTROLLER_VOLTAGE_DISABLE (1)
80+
#endif
7881
#endif
7982
#define SPI_FLASH_MAX_BAUDRATE 24000000
8083
#define MICROPY_PY_BUILTINS_NOTIMPLEMENTED (1)
@@ -246,4 +249,8 @@
246249
CIRCUITPY_COMMON_ROOT_POINTERS \
247250
mp_obj_t playing_audio[AUDIO_DMA_CHANNEL_COUNT];
248251

252+
#ifndef MICROCONTROLLER_VOLTAGE_DISABLE
253+
#define MICROCONTROLLER_VOLTAGE_DISABLE (0)
254+
#endif
255+
249256
#endif // __INCLUDED_MPCONFIGPORT_H

0 commit comments

Comments
 (0)