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
6ace84b0
Commit
6ace84b0
authored
Dec 28, 2016
by
Pavol Rusnak
Committed by
Damien George
Jan 19, 2017
Browse files
stmhal: Implement ioctl for USB HID read.
parent
89f2b620
Changes
3
Hide whitespace changes
Inline
Side-by-side
stmhal/usb.c
View file @
6ace84b0
...
...
@@ -636,6 +636,9 @@ STATIC mp_uint_t pyb_usb_hid_ioctl(mp_obj_t self_in, mp_uint_t request, mp_uint_
if
(
request
==
MP_STREAM_POLL
)
{
mp_uint_t
flags
=
arg
;
ret
=
0
;
if
((
flags
&
MP_STREAM_POLL_RD
)
&&
USBD_HID_RxNum
()
>
0
)
{
ret
|=
MP_STREAM_POLL_RD
;
}
if
((
flags
&
MP_STREAM_POLL_WR
)
&&
USBD_HID_CanSendReport
(
&
hUSBDDevice
))
{
ret
|=
MP_STREAM_POLL_WR
;
}
...
...
stmhal/usbd_hid_interface.c
View file @
6ace84b0
...
...
@@ -93,6 +93,11 @@ static int8_t HID_Itf_Receive(uint8_t* Buf, uint32_t Len) {
return
USBD_OK
;
}
// Returns number of ready rx buffers.
int
USBD_HID_RxNum
(
void
)
{
return
(
current_read_buffer
!=
current_write_buffer
);
}
// timout in milliseconds.
// Returns number of bytes read from the device.
int
USBD_HID_Rx
(
uint8_t
*
buf
,
uint32_t
len
,
uint32_t
timeout
)
{
...
...
stmhal/usbd_hid_interface.h
View file @
6ace84b0
...
...
@@ -6,4 +6,5 @@
extern
const
USBD_HID_ItfTypeDef
USBD_HID_fops
;
int
USBD_HID_RxNum
(
void
);
int
USBD_HID_Rx
(
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