Skip to content

Commit 397b2f6

Browse files
committed
pin alarm configures pins again before deep sleep
1 parent e74a8e3 commit 397b2f6

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,16 @@ void alarm_pin_pinalarm_set_alarms(bool deep_sleep, size_t n_alarms, const mp_ob
185185
for (size_t i = 0; i < n_alarms; i++) {
186186
if (mp_obj_is_type(alarms[i], &alarm_pin_pinalarm_type)) {
187187
alarm_pin_pinalarm_obj_t *alarm = MP_OBJ_TO_PTR(alarms[i]);
188+
gpio_set_pin_function(alarm->pin->number, GPIO_PIN_FUNCTION_A);
189+
if (alarm->pull) {
190+
if (alarm->value) {
191+
// detect rising edge means pull down
192+
gpio_set_pin_pull_mode(alarm->pin->number, GPIO_PULL_DOWN);
193+
} else {
194+
// detect falling edge means pull up
195+
gpio_set_pin_pull_mode(alarm->pin->number, GPIO_PULL_UP);
196+
}
197+
}
188198
if (deep_sleep) {
189199
// Tamper Pins: IN0:PB00; IN1:PB02; IN2:PA02; IN3:PC00; IN4:PC01; OUT:PB01
190200
// Only these pins can do TAMPER

0 commit comments

Comments
 (0)