Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
979ab4e1
Commit
979ab4e1
authored
Dec 15, 2016
by
Damien George
Browse files
stmhal/usb: Always use the mp_kbd_exception object for VCP interrupt.
There's no need to store a separate pointer to this object.
parent
f254cfd3
Changes
3
Hide whitespace changes
Inline
Side-by-side
stmhal/usb.c
View file @
979ab4e1
...
...
@@ -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
);
}
}
...
...
stmhal/usbd_cdc_interface.c
View file @
979ab4e1
...
...
@@ -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
)
{
...
...
stmhal/usbd_cdc_interface.h
View file @
979ab4e1
...
...
@@ -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
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment