workaround to use lib/utils/interrupt_char.c

This commit is contained in:
hathach 2018-07-31 14:28:34 +07:00
parent ae783b0b1a
commit 221d54a595
4 changed files with 15 additions and 5 deletions

@ -1 +1 @@
Subproject commit 191b73b58c5ad6a098c652f31459ef39078a484b
Subproject commit cc143cccf414f67bf2fc04751b12ee18c447997b

View File

@ -102,7 +102,6 @@ SRC_C += \
tick.c \
background.c \
internal_flash.c \
interrupt_char.c \
drivers/bluetooth/ble_drv.c \
drivers/bluetooth/ble_uart.c \
boards/$(BOARD)/board.c \
@ -115,6 +114,7 @@ SRC_C += \
lib/utils/buffer_helper.c \
lib/utils/context_manager_helpers.c \
lib/utils/pyexec.c \
lib/utils/interrupt_char.c \
lib/utils/stdout_helpers.c \
lib/libc/string0.c \
lib/mp-readline/readline.c \
@ -219,7 +219,8 @@ SRC_SHARED_BINDINGS = \
bitbangio/SPI.c \
bitbangio/OneWire.c \
random/__init__.c \
usb_hid/__init__.c \
# usb_hid/__init__.c \
usb_hid/Device.c \
SRC_SHARED_MODULE_EXPANDED = $(addprefix shared-bindings/, $(SRC_SHARED_BINDINGS)) \

View File

@ -72,7 +72,7 @@
#define CFG_TUD_MSC 1
#define CFG_TUD_HID_KEYBOARD 0
#define CFG_TUD_HID_MOUSE 0
#define CFG_TUD_HID_GENERIC 0
#define CFG_TUD_HID 0
/*------------------------------------------------------------------*/
/* CLASS DRIVER

View File

@ -29,6 +29,7 @@
#include "tick.h"
#include "usb.h"
#include "lib/utils/interrupt_char.h"
#include "lib/mp-readline/readline.h"
#ifdef SOFTDEVICE_PRESENT
#include "nrf_sdm.h"
@ -75,7 +76,7 @@ tud_desc_set_t tud_desc_set =
.hid_report =
{
.composite = NULL,
.generic = NULL,
.boot_keyboard = NULL,
.boot_mouse = NULL
}
@ -129,6 +130,12 @@ void usb_init(void) {
}
tusb_init();
#if MICROPY_KBD_EXCEPTION
// Set Ctrl+C as wanted char, tud_cdc_rx_wanted_cb() callback will be invoked when Ctrl+C is received
// This callback always got invoked regardless of mp_interrupt_char value since we only set it once here
tud_cdc_set_wanted_char(CHAR_CTRL_C);
#endif
}
//--------------------------------------------------------------------+
@ -158,6 +165,8 @@ void tud_cdc_rx_wanted_cb(uint8_t itf, char wanted_char)
{
(void) itf; // not used
// Workaround for using lib/utils/interrupt_char.c
// Compare mp_interrupt_char with wanted_char and ignore if not matched
if (mp_interrupt_char == wanted_char) {
tud_cdc_read_flush(); // flush read fifo
mp_keyboard_interrupt();