tests/usbus_hid: uncrustify main.c

This commit is contained in:
Alexandre Abadie 2021-01-12 17:23:10 +01:00
parent a469942ecf
commit c7781189b7
No known key found for this signature in database
GPG Key ID: 1C919A403CAE1405

View File

@ -24,10 +24,10 @@
#include "usb/usbus/hid.h" #include "usb/usbus/hid.h"
/* /*
this descriptor is used, because the basic usb_hid interface was developed in this descriptor is used, because the basic usb_hid interface was developed in
conjunction with FIDO2. Descriptor is taken from CTAP2 specification conjunction with FIDO2. Descriptor is taken from CTAP2 specification
(version 20190130) section 8.1.8.2 (version 20190130) section 8.1.8.2
*/ */
static uint8_t report_desc_ctap[] = { static uint8_t report_desc_ctap[] = {
0x06, 0xD0, 0xF1, /* HID_UsagePage ( FIDO_USAGE_PAGE ) */ 0x06, 0xD0, 0xF1, /* HID_UsagePage ( FIDO_USAGE_PAGE ) */
0x09, 0x01, /* HID_Usage ( FIDO_USAGE_CTAPHID ) */ 0x09, 0x01, /* HID_Usage ( FIDO_USAGE_CTAPHID ) */
@ -50,13 +50,14 @@ static uint8_t report_desc_ctap[] = {
static usbus_t usbus; static usbus_t usbus;
static char _stack[USBUS_STACKSIZE]; static char _stack[USBUS_STACKSIZE];
void usb_hid_io_init(usbus_t* usbus, uint8_t* report_desc, void usb_hid_io_init(usbus_t *usbus, uint8_t *report_desc,
size_t report_desc_size); size_t report_desc_size);
ssize_t usb_hid_io_read(void* buffer, size_t len); ssize_t usb_hid_io_read(void *buffer, size_t len);
void init(void) void init(void)
{ {
usbdev_t *usbdev = usbdev_get_ctx(0); usbdev_t *usbdev = usbdev_get_ctx(0);
usbus_init(&usbus, usbdev); usbus_init(&usbus, usbdev);
usb_hid_io_init(&usbus, report_desc_ctap, sizeof(report_desc_ctap)); usb_hid_io_init(&usbus, report_desc_ctap, sizeof(report_desc_ctap));
@ -70,11 +71,14 @@ int main(void)
xtimer_sleep(3); xtimer_sleep(3);
init(); init();
puts("RIOT USB HID echo test"); puts("RIOT USB HID echo test");
puts("Write input to the hidraw device under /dev/hidrawX, and see if it gets echoed here"); puts(
"Write input to the hidraw device under /dev/hidrawX, and see if it gets echoed here");
uint8_t buffer[CONFIG_USBUS_HID_INTERRUPT_EP_SIZE]; uint8_t buffer[CONFIG_USBUS_HID_INTERRUPT_EP_SIZE];
for (;;) { for (;;) {
ssize_t len = usb_hid_io_read(buffer, CONFIG_USBUS_HID_INTERRUPT_EP_SIZE); ssize_t len =
usb_hid_io_read(buffer, CONFIG_USBUS_HID_INTERRUPT_EP_SIZE);
printf("Msg received via USB HID: "); printf("Msg received via USB HID: ");
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {