summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--stmhal/usb.c4
-rw-r--r--stmhal/usbd_cdc_interface.c8
-rw-r--r--stmhal/usbd_cdc_interface.h2
3 files changed, 6 insertions, 8 deletions
diff --git a/stmhal/usb.c b/stmhal/usb.c
index 591cb321aa..c6303befb1 100644
--- a/stmhal/usb.c
+++ b/stmhal/usb.c
@@ -96,7 +96,7 @@ const mp_obj_tuple_t pyb_usb_hid_keyboard_obj = {
};
void pyb_usb_init0(void) {
- USBD_CDC_SetInterrupt(-1, MP_STATE_PORT(mp_kbd_exception));
+ USBD_CDC_SetInterrupt(-1);
MP_STATE_PORT(pyb_hid_report_desc) = MP_OBJ_NULL;
}
@@ -146,7 +146,7 @@ void usb_vcp_set_interrupt_char(int c) {
if (c != -1) {
mp_obj_exception_clear_traceback(MP_STATE_PORT(mp_kbd_exception));
}
- USBD_CDC_SetInterrupt(c, MP_STATE_PORT(mp_kbd_exception));
+ USBD_CDC_SetInterrupt(c);
}
}
diff --git a/stmhal/usbd_cdc_interface.c b/stmhal/usbd_cdc_interface.c
index b42d3e2194..12aa38470c 100644
--- a/stmhal/usbd_cdc_interface.c
+++ b/stmhal/usbd_cdc_interface.c
@@ -41,6 +41,7 @@
#include "usbd_cdc_interface.h"
#include "pendsv.h"
+#include "py/mpstate.h"
#include "py/obj.h"
#include "irq.h"
#include "timer.h"
@@ -79,7 +80,6 @@ static uint8_t UserTxBufPtrWaitCount = 0; // used to implement a timeout waiting
static uint8_t UserTxNeedEmptyPacket = 0; // used to flush the USB IN endpoint if the last packet was exactly the endpoint packet size
static int user_interrupt_char = -1;
-static void *user_interrupt_data = NULL;
/* Private function prototypes -----------------------------------------------*/
static int8_t CDC_Itf_Init (void);
@@ -152,7 +152,6 @@ static int8_t CDC_Itf_Init(void)
* This can happen if the USB enumeration occurs after the call to
* USBD_CDC_SetInterrupt.
user_interrupt_char = -1;
- user_interrupt_data = NULL;
*/
return (USBD_OK);
@@ -354,7 +353,7 @@ static int8_t CDC_Itf_Receive(uint8_t* Buf, uint32_t *Len) {
if (*src == user_interrupt_char) {
char_found = true;
// raise exception when interrupts are finished
- pendsv_nlr_jump(user_interrupt_data);
+ pendsv_nlr_jump(MP_STATE_PORT(mp_kbd_exception));
} else {
if (char_found) {
*dest = *src;
@@ -386,9 +385,8 @@ int USBD_CDC_IsConnected(void) {
return dev_is_connected;
}
-void USBD_CDC_SetInterrupt(int chr, void *data) {
+void USBD_CDC_SetInterrupt(int chr) {
user_interrupt_char = chr;
- user_interrupt_data = data;
}
int USBD_CDC_TxHalfEmpty(void) {
diff --git a/stmhal/usbd_cdc_interface.h b/stmhal/usbd_cdc_interface.h
index f74b42bbee..2ea1a42c4a 100644
--- a/stmhal/usbd_cdc_interface.h
+++ b/stmhal/usbd_cdc_interface.h
@@ -32,7 +32,7 @@
extern const USBD_CDC_ItfTypeDef USBD_CDC_fops;
int USBD_CDC_IsConnected(void);
-void USBD_CDC_SetInterrupt(int chr, void *data);
+void USBD_CDC_SetInterrupt(int chr);
int USBD_CDC_TxHalfEmpty(void);
int USBD_CDC_Tx(const uint8_t *buf, uint32_t len, uint32_t timeout);