-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Nrf52840 usb hid #1074
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nrf52840 usb hid #1074
Conversation
compiled with undefined ref
FYI - I pulled this PR and built an image for the pca10056 board. It seems ok for basic operation - I was able to mount an SD Card (SPI ) and run a BLE scan. |
I did try mounting/unmounting CIRCUITPY a few times - no errors ...yet! |
@jerryneedell you could try hid mouse, it is easiest thing to test with copy
|
@hathach I tried it and it works!! |
while ( (ticks_ms < end_ticks) && !tud_hid_generic_ready() ) { } | ||
|
||
if ( !tud_hid_generic_ready() ) { | ||
mp_raise_msg(&mp_type_OSError, "USB Busy"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use mp_raise_OSError("USB Busy")
here and similarly elsewhere. Easier to read and saves a few bytes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mp_raise_OSError takes int parameter, since usb does have its error enu, what should be the value for these in the list
https://github.com/adafruit/circuitpython/blob/master/py/mperrno.h
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, never mind, I forgot that it takes only an integer arg.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, nrf52 still got plenty of space left anyway :D
ports/nrf/usb/usb_desc.c
Outdated
TUD_DESC_STRCONV('A','d','a','f','r','u','i','t',' ','I','n','d','u','s','t','r','i','e','s'), | ||
|
||
// 2 Product | ||
TUD_DESC_STRCONV('C','i','r','c','u','i','t','P','Y',' ','n','R','F','5','2'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trivial, but make these lowercase y
. CircuitPy
instead of CircuitPY
.
ports/nrf/usb/usb_msc_flash.c
Outdated
// SCSI output | ||
} | ||
} | ||
if ( resplen > bufsize ) resplen = bufsize; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use curly braces on all if
s, even one-line ones. Thanks. We're trying to keep to that style.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only minor changes. Looks great! TinyUSB looks very clean :).
I tested mouse, keyboard, consumer control, and gamepad.
Don't worry about digitizer. I could not set up a digitizer-style device that worked across Windows, Linux, and Mac. I left the report descriptor in just to remember what I'd done.
nice work, thach! i hope to get back to testing nrf52840 again soon! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! Thanks!
#define USB_HID_DEVICE_CONSUMER 1 | ||
#define USB_HID_DEVICE_SYS_CONTROL 1 | ||
#define USB_HID_DEVICE_GAMEPAD 1 | ||
#define USB_HID_DEVICE_DIGITIZER 0 // not supported yet |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dhalbert list of enabled hid devices is here, just in case you wan to disable any of these.
@dhalbert thanks, I tried to get all the ugly part inside the tinyusb stack itself :D |
@ladyada thanks, hopefully you won't find out too many bugs :D |
Fixes #1008 as well (and maybe also via other PRs). |
Fixes #1009. |
PS: tinyusb submodule needs to be updated