check for missing pins; deinit txrx leds

This commit is contained in:
Dan Halbert 2021-11-30 19:16:21 -05:00
parent 57c33059f3
commit e8ea9c75a1
5 changed files with 24 additions and 3 deletions

2
main.c
View File

@ -537,6 +537,8 @@ STATIC bool run_code_py(safe_mode_t safe_mode) {
common_hal_alarm_pretending_deep_sleep(); common_hal_alarm_pretending_deep_sleep();
} else if (connecting_delay_ticks < 0) { } else if (connecting_delay_ticks < 0) {
// Entering deep sleep (may be fake or real.) // Entering deep sleep (may be fake or real.)
status_led_deinit();
deinit_rxtx_leds();
board_deinit(); board_deinit();
if (!supervisor_workflow_active()) { if (!supervisor_workflow_active()) {
// Enter true deep sleep. When we wake up we'll be back at the // Enter true deep sleep. When we wake up we'll be back at the

View File

@ -11,7 +11,7 @@ LONGINT_IMPL = NONE
CIRCUITPY_FULL_BUILD = 0 CIRCUITPY_FULL_BUILD = 0
CIRCUIPTY_USB_CDC = 0 CIRCUITPY_ALARM = 0
CIRCUITPY_AUDIOBUSIO = 0 CIRCUITPY_AUDIOBUSIO = 0
CIRCUITPY_AUDIOMP3 = 0 CIRCUITPY_AUDIOMP3 = 0
CIRCUITPY_AUDIOPWMIO = 0 CIRCUITPY_AUDIOPWMIO = 0
@ -29,6 +29,7 @@ CIRCUITPY_ROTARYIO = 0
CIRCUITPY_RTC = 0 CIRCUITPY_RTC = 0
CIRCUITPY_SAMD = 0 CIRCUITPY_SAMD = 0
CIRCUITPY_TOUCHIO = 0 CIRCUITPY_TOUCHIO = 0
CIRCUITPY_USB_CDC = 0
CIRCUITPY_USB_HID = 0 CIRCUITPY_USB_HID = 0
CIRCUITPY_USB_MIDI = 0 CIRCUITPY_USB_MIDI = 0
CIRCUITPY_VECTORIO = 0 CIRCUITPY_VECTORIO = 0

View File

@ -198,8 +198,16 @@ void alarm_pin_pinalarm_set_alarms(bool deep_sleep, size_t n_alarms, const mp_ob
if (deep_sleep) { if (deep_sleep) {
// Tamper Pins: IN0:PB00; IN1:PB02; IN2:PA02; IN3:PC00; IN4:PC01; OUT:PB01 // Tamper Pins: IN0:PB00; IN1:PB02; IN2:PA02; IN3:PC00; IN4:PC01; OUT:PB01
// Only these pins can do TAMPER // Only these pins can do TAMPER
if (alarm->pin != &pin_PB00 && alarm->pin != &pin_PB02 && if (
alarm->pin != &pin_PA02) { #ifdef PIN_PB00
alarm->pin != &pin_PB00
#else
true
#endif
#ifdef PIN_PB02
&& alarm->pin != &pin_PB02
#endif
&& alarm->pin != &pin_PA02) {
mp_raise_ValueError(translate("Pin cannot wake from Deep Sleep")); mp_raise_ValueError(translate("Pin cannot wake from Deep Sleep"));
} }
pinalarm_on = true; pinalarm_on = true;

View File

@ -340,6 +340,15 @@ void init_rxtx_leds(void) {
#endif #endif
} }
void deinit_rxtx_leds(void) {
#if CIRCUITPY_DIGITALIO && defined(MICROPY_HW_LED_RX)
common_hal_digitalio_digitalinout_deinit(&rx_led);
#endif
#if CIRCUITPY_DIGITALIO && defined(MICROPY_HW_LED_TX)
common_hal_digitalio_digitalinout_deinit(&tx_led);
#endif
}
void toggle_rx_led(void) { void toggle_rx_led(void) {
#if CIRCUITPY_DIGITALIO && defined(MICROPY_HW_LED_RX) #if CIRCUITPY_DIGITALIO && defined(MICROPY_HW_LED_RX)
common_hal_digitalio_digitalinout_set_value(&rx_led, !common_hal_digitalio_digitalinout_get_value(&rx_led)); common_hal_digitalio_digitalinout_set_value(&rx_led, !common_hal_digitalio_digitalinout_get_value(&rx_led));

View File

@ -55,6 +55,7 @@ uint32_t color_brightness(uint32_t color, uint8_t brightness);
void set_status_brightness(uint8_t level); void set_status_brightness(uint8_t level);
void init_rxtx_leds(void); void init_rxtx_leds(void);
void deinit_rxtx_leds(void);
void toggle_rx_led(void); void toggle_rx_led(void);
void toggle_tx_led(void); void toggle_tx_led(void);