stmhal/usb: Always use the mp_kbd_exception object for VCP interrupt.
There's no need to store a separate pointer to this object.
This commit is contained in:
parent
f254cfd3c4
commit
979ab4e126
@ -96,7 +96,7 @@ const mp_obj_tuple_t pyb_usb_hid_keyboard_obj = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void pyb_usb_init0(void) {
|
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;
|
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) {
|
if (c != -1) {
|
||||||
mp_obj_exception_clear_traceback(MP_STATE_PORT(mp_kbd_exception));
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,6 +41,7 @@
|
|||||||
#include "usbd_cdc_interface.h"
|
#include "usbd_cdc_interface.h"
|
||||||
#include "pendsv.h"
|
#include "pendsv.h"
|
||||||
|
|
||||||
|
#include "py/mpstate.h"
|
||||||
#include "py/obj.h"
|
#include "py/obj.h"
|
||||||
#include "irq.h"
|
#include "irq.h"
|
||||||
#include "timer.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 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 int user_interrupt_char = -1;
|
||||||
static void *user_interrupt_data = NULL;
|
|
||||||
|
|
||||||
/* Private function prototypes -----------------------------------------------*/
|
/* Private function prototypes -----------------------------------------------*/
|
||||||
static int8_t CDC_Itf_Init (void);
|
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
|
* This can happen if the USB enumeration occurs after the call to
|
||||||
* USBD_CDC_SetInterrupt.
|
* USBD_CDC_SetInterrupt.
|
||||||
user_interrupt_char = -1;
|
user_interrupt_char = -1;
|
||||||
user_interrupt_data = NULL;
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return (USBD_OK);
|
return (USBD_OK);
|
||||||
@ -354,7 +353,7 @@ static int8_t CDC_Itf_Receive(uint8_t* Buf, uint32_t *Len) {
|
|||||||
if (*src == user_interrupt_char) {
|
if (*src == user_interrupt_char) {
|
||||||
char_found = true;
|
char_found = true;
|
||||||
// raise exception when interrupts are finished
|
// raise exception when interrupts are finished
|
||||||
pendsv_nlr_jump(user_interrupt_data);
|
pendsv_nlr_jump(MP_STATE_PORT(mp_kbd_exception));
|
||||||
} else {
|
} else {
|
||||||
if (char_found) {
|
if (char_found) {
|
||||||
*dest = *src;
|
*dest = *src;
|
||||||
@ -386,9 +385,8 @@ int USBD_CDC_IsConnected(void) {
|
|||||||
return dev_is_connected;
|
return dev_is_connected;
|
||||||
}
|
}
|
||||||
|
|
||||||
void USBD_CDC_SetInterrupt(int chr, void *data) {
|
void USBD_CDC_SetInterrupt(int chr) {
|
||||||
user_interrupt_char = chr;
|
user_interrupt_char = chr;
|
||||||
user_interrupt_data = data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int USBD_CDC_TxHalfEmpty(void) {
|
int USBD_CDC_TxHalfEmpty(void) {
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
extern const USBD_CDC_ItfTypeDef USBD_CDC_fops;
|
extern const USBD_CDC_ItfTypeDef USBD_CDC_fops;
|
||||||
|
|
||||||
int USBD_CDC_IsConnected(void);
|
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_TxHalfEmpty(void);
|
||||||
int USBD_CDC_Tx(const uint8_t *buf, uint32_t len, uint32_t timeout);
|
int USBD_CDC_Tx(const uint8_t *buf, uint32_t len, uint32_t timeout);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user