88#include "asf/sam0/drivers/port/port.h"
99#include "asf/sam0/drivers/sercom/usart/usart.h"
1010#include "lib/mp-readline/readline.h"
11+ #include "lib/utils/interrupt_char.h"
1112#include "py/mphal.h"
1213#include "py/mpstate.h"
1314#include "py/smallint.h"
@@ -34,9 +35,6 @@ volatile uint8_t usb_rx_count;
3435
3536volatile bool mp_cdc_enabled = false;
3637
37- void mp_keyboard_interrupt (void );
38- int interrupt_char ;
39-
4038extern struct usart_module usart_instance ;
4139
4240static volatile bool mp_msc_enabled = false;
@@ -106,7 +104,7 @@ void usb_rx_notify(void)
106104// character!
107105c = udi_cdc_getc ();
108106
109- if (c == interrupt_char ) {
107+ if (c == mp_interrupt_char ) {
110108// We consumed a character rather than adding it to the rx
111109// buffer so undo the modifications we made to count and the
112110// tail.
@@ -219,14 +217,6 @@ void mp_hal_stdout_tx_strn(const char *str, size_t len) {
219217#endif
220218}
221219
222- extern int interrupt_char ;
223- void mp_hal_set_interrupt_char (int c ) {
224- if (c != -1 ) {
225- mp_obj_exception_clear_traceback (MP_STATE_PORT (mp_kbd_exception ));
226- }
227- interrupt_char = c ;
228- }
229-
230220void mp_hal_delay_ms (mp_uint_t delay ) {
231221// If mass storage is enabled measure the time ourselves and run any mass
232222// storage transactions in the meantime.
@@ -239,7 +229,7 @@ void mp_hal_delay_ms(mp_uint_t delay) {
239229MICROPY_VM_HOOK_LOOP
240230#endif
241231// Check to see if we've been CTRL-Ced by autoreset or the user.
242- if (MP_STATE_VM (mp_pending_exception )== MP_STATE_PORT ( mp_kbd_exception )) {
232+ if (MP_STATE_VM (mp_pending_exception )== MP_OBJ_FROM_PTR ( & MP_STATE_VM ( mp_kbd_exception ) )) {
243233break ;
244234 }
245235duration = (common_hal_time_monotonic ()- start_tick );