Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
979ab4e1
Commit
979ab4e1
authored
8 years ago
by
Damien George
Browse files
Options
Downloads
Patches
Plain Diff
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
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
stmhal/usb.c
+2
-2
2 additions, 2 deletions
stmhal/usb.c
stmhal/usbd_cdc_interface.c
+3
-5
3 additions, 5 deletions
stmhal/usbd_cdc_interface.c
stmhal/usbd_cdc_interface.h
+1
-1
1 addition, 1 deletion
stmhal/usbd_cdc_interface.h
with
6 additions
and
8 deletions
stmhal/usb.c
+
2
−
2
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
);
}
}
...
...
This diff is collapsed.
Click to expand it.
stmhal/usbd_cdc_interface.c
+
3
−
5
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
)
{
...
...
This diff is collapsed.
Click to expand it.
stmhal/usbd_cdc_interface.h
+
1
−
1
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
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment