diff options
| author | Scott Shawcroft <scott@chickadee.tech> | 2016-10-31 11:31:52 -0700 |
|---|---|---|
| committer | Scott Shawcroft <scott@chickadee.tech> | 2016-10-31 11:31:52 -0700 |
| commit | 19e5f1fef245fa21441e52c4da932aaf2f7d62da (patch) | |
| tree | 79b9c0b4cf8b798e335bc4d4abcd89cf810ab0a7 | |
| parent | f42b41e1e98c16ffcd55bc158df3f6f67d833a98 (diff) | |
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.
| -rw-r--r-- | atmel-samd/mphalport.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/atmel-samd/mphalport.c b/atmel-samd/mphalport.c index d442fe8a8..01a964753 100644 --- a/atmel-samd/mphalport.c +++ b/atmel-samd/mphalport.c @@ -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 { |
