From e5cc681cb1b5163b9ae3453df85344326baf9759 Mon Sep 17 00:00:00 2001 From: Damien George Date: Wed, 15 Feb 2017 16:39:30 +1100 Subject: stmhal: Use generic interrupt char code. --- stmhal/usb.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'stmhal/usb.c') diff --git a/stmhal/usb.c b/stmhal/usb.c index 7eb3f179a..c413ce4ba 100644 --- a/stmhal/usb.c +++ b/stmhal/usb.c @@ -38,6 +38,7 @@ #include "py/runtime.h" #include "py/stream.h" #include "py/mperrno.h" +#include "py/mphal.h" #include "bufhelper.h" #include "usb.h" @@ -96,7 +97,7 @@ const mp_obj_tuple_t pyb_usb_hid_keyboard_obj = { }; void pyb_usb_init0(void) { - USBD_CDC_SetInterrupt(-1); + mp_hal_set_interrupt_char(-1); MP_STATE_PORT(pyb_hid_report_desc) = MP_OBJ_NULL; } @@ -141,15 +142,6 @@ bool usb_vcp_is_enabled(void) { return (pyb_usb_flags & PYB_USB_FLAG_DEV_ENABLED) != 0; } -void usb_vcp_set_interrupt_char(int c) { - if (pyb_usb_flags & PYB_USB_FLAG_DEV_ENABLED) { - if (c != -1) { - mp_obj_exception_clear_traceback(MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception))); - } - USBD_CDC_SetInterrupt(c); - } -} - int usb_vcp_recv_byte(uint8_t *c) { return USBD_CDC_Rx(c, 1, 0); } @@ -364,7 +356,7 @@ STATIC mp_obj_t pyb_usb_vcp_make_new(const mp_obj_type_t *type, size_t n_args, s } STATIC mp_obj_t pyb_usb_vcp_setinterrupt(mp_obj_t self_in, mp_obj_t int_chr_in) { - usb_vcp_set_interrupt_char(mp_obj_get_int(int_chr_in)); + mp_hal_set_interrupt_char(mp_obj_get_int(int_chr_in)); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(pyb_usb_vcp_setinterrupt_obj, pyb_usb_vcp_setinterrupt); -- cgit v1.2.3