summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhathach <thach@tinyusb.org>2018-07-31 14:28:34 +0700
committerhathach <thach@tinyusb.org>2018-07-31 14:28:34 +0700
commit221d54a595ca0554d3903b9bc1bf0080696912e4 (patch)
tree591fd568d3090d806cbae8d6a1f2806ad094279a
parentae783b0b1afb61928fd0038275d2450956e9cc9c (diff)
workaround to use lib/utils/interrupt_char.c
m---------lib/tinyusb0
-rwxr-xr-xports/nrf/Makefile5
-rw-r--r--ports/nrf/usb/tusb_config.h2
-rw-r--r--ports/nrf/usb/usb.c11
4 files changed, 14 insertions, 4 deletions
diff --git a/lib/tinyusb b/lib/tinyusb
-Subproject 191b73b58c5ad6a098c652f31459ef39078a484
+Subproject cc143cccf414f67bf2fc04751b12ee18c447997
diff --git a/ports/nrf/Makefile b/ports/nrf/Makefile
index 5b1164fbd..bfe47112e 100755
--- a/ports/nrf/Makefile
+++ b/ports/nrf/Makefile
@@ -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)) \
diff --git a/ports/nrf/usb/tusb_config.h b/ports/nrf/usb/tusb_config.h
index 755e4cb6a..28f1be087 100644
--- a/ports/nrf/usb/tusb_config.h
+++ b/ports/nrf/usb/tusb_config.h
@@ -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
diff --git a/ports/nrf/usb/usb.c b/ports/nrf/usb/usb.c
index 76ae2ad39..704ed5909 100644
--- a/ports/nrf/usb/usb.c
+++ b/ports/nrf/usb/usb.c
@@ -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();