Fix Espressif TouchAlarm

This commit is contained in:
Dan Halbert 2023-05-19 12:36:28 -04:00
parent f2bfced407
commit 9e995a5e98
2 changed files with 6 additions and 1 deletions

View File

@ -44,6 +44,7 @@ void common_hal_alarm_touch_touchalarm_construct(alarm_touch_touchalarm_obj_t *s
self->pin = pin;
}
// Used for light sleep.
mp_obj_t alarm_touch_touchalarm_find_triggered_alarm(const size_t n_alarms, const mp_obj_t *alarms) {
for (size_t i = 0; i < n_alarms; i++) {
if (mp_obj_is_type(alarms[i], &alarm_touch_touchalarm_type)) {
@ -76,6 +77,8 @@ mp_obj_t alarm_touch_touchalarm_record_wake_alarm(void) {
const mcu_pin_obj_t *pin_obj = MP_OBJ_TO_PTR(mcu_pin_globals.map.table[i].value);
if (pin_obj->touch_channel == wake_channel) {
alarm->pin = mcu_pin_globals.map.table[i].value;
// Undo the never reset in case it was a fake deep sleep.
reset_pin_number(alarm->pin->number);
break;
}
}
@ -101,6 +104,8 @@ void alarm_touch_touchalarm_set_alarm(const bool deep_sleep, const size_t n_alar
}
touch_alarm = MP_OBJ_TO_PTR(alarms[i]);
touch_channel_mask |= 1 << touch_alarm->pin->number;
// Resetting the pin will set a pull-up, which we don't want.
never_reset_pin_number(touch_alarm->pin->number);
touch_alarm_set = true;
}
}

View File

@ -43,7 +43,7 @@ void peripherals_touch_never_reset(const bool enable) {
void peripherals_touch_init(const touch_pad_t touchpad) {
if (!touch_inited) {
touch_pad_init();
touch_pad_set_fsm_mode(TOUCH_FSM_MODE_SW);
touch_pad_set_fsm_mode(TOUCH_FSM_MODE_TIMER);
}
// touch_pad_config() must be done before touch_pad_fsm_start() the first time.
// Otherwise the calibration is wrong and we get maximum raw values if there is