|
41 | 41 | #include "usbd_cdc_interface.h" |
42 | 42 | #include "pendsv.h" |
43 | 43 |
|
| 44 | +#include "py/mpstate.h" |
44 | 45 | #include "py/obj.h" |
45 | 46 | #include "irq.h" |
46 | 47 | #include "timer.h" |
@@ -79,7 +80,6 @@ static uint8_t UserTxBufPtrWaitCount = 0; // used to implement a timeout waiting |
79 | 80 | static uint8_t UserTxNeedEmptyPacket = 0; // used to flush the USB IN endpoint if the last packet was exactly the endpoint packet size |
80 | 81 |
|
81 | 82 | static int user_interrupt_char = -1; |
82 | | -static void *user_interrupt_data = NULL; |
83 | 83 |
|
84 | 84 | /* Private function prototypes -----------------------------------------------*/ |
85 | 85 | static int8_t CDC_Itf_Init (void); |
@@ -152,7 +152,6 @@ static int8_t CDC_Itf_Init(void) |
152 | 152 | * This can happen if the USB enumeration occurs after the call to |
153 | 153 | * USBD_CDC_SetInterrupt. |
154 | 154 | user_interrupt_char = -1; |
155 | | - user_interrupt_data = NULL; |
156 | 155 | */ |
157 | 156 |
|
158 | 157 | return (USBD_OK); |
@@ -354,7 +353,7 @@ static int8_t CDC_Itf_Receive(uint8_t* Buf, uint32_t *Len) { |
354 | 353 | if (*src == user_interrupt_char) { |
355 | 354 | char_found = true; |
356 | 355 | // raise exception when interrupts are finished |
357 | | - pendsv_nlr_jump(user_interrupt_data); |
| 356 | + pendsv_nlr_jump(MP_STATE_PORT(mp_kbd_exception)); |
358 | 357 | } else { |
359 | 358 | if (char_found) { |
360 | 359 | *dest = *src; |
@@ -386,9 +385,8 @@ int USBD_CDC_IsConnected(void) { |
386 | 385 | return dev_is_connected; |
387 | 386 | } |
388 | 387 |
|
389 | | -void USBD_CDC_SetInterrupt(int chr, void *data) { |
| 388 | +void USBD_CDC_SetInterrupt(int chr) { |
390 | 389 | user_interrupt_char = chr; |
391 | | - user_interrupt_data = data; |
392 | 390 | } |
393 | 391 |
|
394 | 392 | int USBD_CDC_TxHalfEmpty(void) { |
|
0 commit comments