summaryrefslogtreecommitdiffstatshomepage
path: root/stmhal/usbd_cdc_interface.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2017-02-15 16:39:30 +1100
committerDamien George <damien.p.george@gmail.com>2017-02-15 16:39:30 +1100
commite5cc681cb1b5163b9ae3453df85344326baf9759 (patch)
tree200ae1f6b6387fbd12ee9dd3cc4223ca32cdd560 /stmhal/usbd_cdc_interface.c
parent05a4859585c4e0a55fca2e7467ba70da6453fdcb (diff)
downloadmicropython-e5cc681cb1b5163b9ae3453df85344326baf9759.tar.gz
micropython-e5cc681cb1b5163b9ae3453df85344326baf9759.zip
stmhal: Use generic interrupt char code.
Diffstat (limited to 'stmhal/usbd_cdc_interface.c')
-rw-r--r--stmhal/usbd_cdc_interface.c22
1 files changed, 5 insertions, 17 deletions
diff --git a/stmhal/usbd_cdc_interface.c b/stmhal/usbd_cdc_interface.c
index 1f46b9dcc1..1c12cdc1c8 100644
--- a/stmhal/usbd_cdc_interface.c
+++ b/stmhal/usbd_cdc_interface.c
@@ -43,6 +43,7 @@
#include "py/mpstate.h"
#include "py/obj.h"
+#include "lib/utils/interrupt_char.h"
#include "irq.h"
#include "timer.h"
#include "usb.h"
@@ -79,8 +80,6 @@ static uint16_t UserTxBufPtrOutShadow = 0; // shadow of above
static uint8_t UserTxBufPtrWaitCount = 0; // used to implement a timeout waiting for low-level USB driver
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;
-
/* Private function prototypes -----------------------------------------------*/
static int8_t CDC_Itf_Init (void);
static int8_t CDC_Itf_DeInit (void);
@@ -147,13 +146,6 @@ static int8_t CDC_Itf_Init(void)
UserRxBufCur = 0;
UserRxBufLen = 0;
- /* NOTE: we cannot reset these here, because USBD_CDC_SetInterrupt
- * may be called before this init function to set these values.
- * This can happen if the USB enumeration occurs after the call to
- * USBD_CDC_SetInterrupt.
- user_interrupt_char = -1;
- */
-
return (USBD_OK);
}
@@ -339,7 +331,7 @@ static int8_t CDC_Itf_Receive(uint8_t* Buf, uint32_t *Len) {
uint32_t delta_len;
- if (user_interrupt_char == -1) {
+ if (mp_interrupt_char == -1) {
// no special interrupt character
delta_len = *Len;
@@ -350,10 +342,10 @@ static int8_t CDC_Itf_Receive(uint8_t* Buf, uint32_t *Len) {
uint8_t *src = Buf;
uint8_t *buf_top = Buf + *Len;
for (; src < buf_top; src++) {
- if (*src == user_interrupt_char) {
+ if (*src == mp_interrupt_char) {
char_found = true;
- // raise exception when interrupts are finished
- pendsv_nlr_jump(&MP_STATE_VM(mp_kbd_exception));
+ // raise KeyboardInterrupt when interrupts are finished
+ pendsv_kbd_intr();
} else {
if (char_found) {
*dest = *src;
@@ -385,10 +377,6 @@ int USBD_CDC_IsConnected(void) {
return dev_is_connected;
}
-void USBD_CDC_SetInterrupt(int chr) {
- user_interrupt_char = chr;
-}
-
int USBD_CDC_TxHalfEmpty(void) {
int32_t tx_waiting = (int32_t)UserTxBufPtrIn - (int32_t)UserTxBufPtrOut;
if (tx_waiting < 0) {