Skip to content

Commit e8ea9c7

Browse files
committed
check for missing pins; deinit txrx leds
1 parent 57c3305 commit e8ea9c7

File tree

5 files changed

+24
-3
lines changed

5 files changed

+24
-3
lines changed

main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,8 @@ STATIC bool run_code_py(safe_mode_t safe_mode) {
537537
common_hal_alarm_pretending_deep_sleep();
538538
} else if (connecting_delay_ticks < 0) {
539539
// Entering deep sleep (may be fake or real.)
540+
status_led_deinit();
541+
deinit_rxtx_leds();
540542
board_deinit();
541543
if (!supervisor_workflow_active()) {
542544
// Enter true deep sleep. When we wake up we'll be back at the

ports/atmel-samd/boards/pewpew_m4/mpconfigboard.mk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ LONGINT_IMPL = NONE
1111

1212
CIRCUITPY_FULL_BUILD = 0
1313

14-
CIRCUIPTY_USB_CDC = 0
14+
CIRCUITPY_ALARM = 0
1515
CIRCUITPY_AUDIOBUSIO = 0
1616
CIRCUITPY_AUDIOMP3 = 0
1717
CIRCUITPY_AUDIOPWMIO = 0
@@ -29,6 +29,7 @@ CIRCUITPY_ROTARYIO = 0
2929
CIRCUITPY_RTC = 0
3030
CIRCUITPY_SAMD = 0
3131
CIRCUITPY_TOUCHIO = 0
32+
CIRCUITPY_USB_CDC = 0
3233
CIRCUITPY_USB_HID = 0
3334
CIRCUITPY_USB_MIDI = 0
3435
CIRCUITPY_VECTORIO = 0

ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,16 @@ void alarm_pin_pinalarm_set_alarms(bool deep_sleep, size_t n_alarms, const mp_ob
198198
if (deep_sleep) {
199199
// Tamper Pins: IN0:PB00; IN1:PB02; IN2:PA02; IN3:PC00; IN4:PC01; OUT:PB01
200200
// Only these pins can do TAMPER
201-
if (alarm->pin != &pin_PB00 && alarm->pin != &pin_PB02 &&
202-
alarm->pin != &pin_PA02) {
201+
if (
202+
#ifdef PIN_PB00
203+
alarm->pin != &pin_PB00
204+
#else
205+
true
206+
#endif
207+
#ifdef PIN_PB02
208+
&& alarm->pin != &pin_PB02
209+
#endif
210+
&& alarm->pin != &pin_PA02) {
203211
mp_raise_ValueError(translate("Pin cannot wake from Deep Sleep"));
204212
}
205213
pinalarm_on = true;

supervisor/shared/status_leds.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,15 @@ void init_rxtx_leds(void) {
340340
#endif
341341
}
342342

343+
void deinit_rxtx_leds(void) {
344+
#if CIRCUITPY_DIGITALIO && defined(MICROPY_HW_LED_RX)
345+
common_hal_digitalio_digitalinout_deinit(&rx_led);
346+
#endif
347+
#if CIRCUITPY_DIGITALIO && defined(MICROPY_HW_LED_TX)
348+
common_hal_digitalio_digitalinout_deinit(&tx_led);
349+
#endif
350+
}
351+
343352
void toggle_rx_led(void) {
344353
#if CIRCUITPY_DIGITALIO && defined(MICROPY_HW_LED_RX)
345354
common_hal_digitalio_digitalinout_set_value(&rx_led, !common_hal_digitalio_digitalinout_get_value(&rx_led));

supervisor/shared/status_leds.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ uint32_t color_brightness(uint32_t color, uint8_t brightness);
5555
void set_status_brightness(uint8_t level);
5656

5757
void init_rxtx_leds(void);
58+
void deinit_rxtx_leds(void);
5859
void toggle_rx_led(void);
5960
void toggle_tx_led(void);
6061

0 commit comments

Comments
 (0)