atmel-samd: Break out of delays with CTRL-C.

This means you can CTRL from within time.sleep() and that autoreset
will work from within a long sleep too. Fixes #45.
This commit is contained in:
Scott Shawcroft 2016-10-31 11:31:52 -07:00
parent f42b41e1e9
commit 19e5f1fef2
1 changed files with 4 additions and 0 deletions

View File

@ -236,6 +236,10 @@ void mp_hal_delay_ms(mp_uint_t delay) {
uint32_t duration = 0;
while (duration < delay) {
udi_msc_process_trans();
// Check to see if we've been CTRL-Ced by autoreset or the user.
if(MP_STATE_VM(mp_pending_exception) == MP_STATE_PORT(mp_kbd_exception)) {
break;
}
duration = (mp_hal_ticks_ms() - start_tick) & MP_SMALL_INT_POSITIVE_MASK;
}
} else {