usbus/hid: uncrustify files
This commit is contained in:
parent
834ac3f5a5
commit
2c2eb88c0e
@ -34,7 +34,7 @@ extern "C" {
|
|||||||
/**
|
/**
|
||||||
* @brief USBUS HID IO RX callback function
|
* @brief USBUS HID IO RX callback function
|
||||||
*/
|
*/
|
||||||
typedef void (*usb_hid_io_cb_t)(void*);
|
typedef void (*usb_hid_io_cb_t)(void *);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Set USBUS HID IO RX callback
|
* @brief Set USBUS HID IO RX callback
|
||||||
|
|||||||
@ -107,9 +107,9 @@ static void _init(usbus_t *usbus, usbus_handler_t *handler)
|
|||||||
hid->hid_descr.arg = hid;
|
hid->hid_descr.arg = hid;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Configure Interface as USB_HID interface, choosing NONE for subclass and
|
Configure Interface as USB_HID interface, choosing NONE for subclass and
|
||||||
protocol in order to represent a generic I/O device
|
protocol in order to represent a generic I/O device
|
||||||
*/
|
*/
|
||||||
hid->iface.class = USB_CLASS_HID;
|
hid->iface.class = USB_CLASS_HID;
|
||||||
hid->iface.subclass = USB_HID_SUBCLASS_NONE;
|
hid->iface.subclass = USB_HID_SUBCLASS_NONE;
|
||||||
hid->iface.protocol = USB_HID_PROTOCOL_NONE;
|
hid->iface.protocol = USB_HID_PROTOCOL_NONE;
|
||||||
@ -118,9 +118,9 @@ static void _init(usbus_t *usbus, usbus_handler_t *handler)
|
|||||||
|
|
||||||
/* IN endpoint to send data to host */
|
/* IN endpoint to send data to host */
|
||||||
hid->ep_in = usbus_add_endpoint(usbus, &hid->iface,
|
hid->ep_in = usbus_add_endpoint(usbus, &hid->iface,
|
||||||
USB_EP_TYPE_INTERRUPT,
|
USB_EP_TYPE_INTERRUPT,
|
||||||
USB_EP_DIR_IN,
|
USB_EP_DIR_IN,
|
||||||
CONFIG_USBUS_HID_INTERRUPT_EP_SIZE);
|
CONFIG_USBUS_HID_INTERRUPT_EP_SIZE);
|
||||||
|
|
||||||
/* interrupt endpoint polling rate in ms */
|
/* interrupt endpoint polling rate in ms */
|
||||||
hid->ep_in->interval = 0x05;
|
hid->ep_in->interval = 0x05;
|
||||||
@ -129,8 +129,8 @@ static void _init(usbus_t *usbus, usbus_handler_t *handler)
|
|||||||
|
|
||||||
/* OUT endpoint to receive data from host */
|
/* OUT endpoint to receive data from host */
|
||||||
hid->ep_out = usbus_add_endpoint(usbus, &hid->iface,
|
hid->ep_out = usbus_add_endpoint(usbus, &hid->iface,
|
||||||
USB_EP_TYPE_INTERRUPT, USB_EP_DIR_OUT,
|
USB_EP_TYPE_INTERRUPT, USB_EP_DIR_OUT,
|
||||||
CONFIG_USBUS_HID_INTERRUPT_EP_SIZE);
|
CONFIG_USBUS_HID_INTERRUPT_EP_SIZE);
|
||||||
|
|
||||||
/* interrupt endpoint polling rate in ms */
|
/* interrupt endpoint polling rate in ms */
|
||||||
hid->ep_out->interval = 0x05;
|
hid->ep_out->interval = 0x05;
|
||||||
@ -150,9 +150,9 @@ static void _event_handler(usbus_t *usbus, usbus_handler_t *handler,
|
|||||||
(void)handler;
|
(void)handler;
|
||||||
|
|
||||||
switch (event) {
|
switch (event) {
|
||||||
default:
|
default:
|
||||||
DEBUG("USB HID unhandled event: 0x%x\n", event);
|
DEBUG("USB HID unhandled event: 0x%x\n", event);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,39 +167,39 @@ static int _control_handler(usbus_t *usbus, usbus_handler_t *handler,
|
|||||||
|
|
||||||
/* Requests defined in USB HID 1.11 spec section 7 */
|
/* Requests defined in USB HID 1.11 spec section 7 */
|
||||||
switch (setup->request) {
|
switch (setup->request) {
|
||||||
case USB_SETUP_REQ_GET_DESCRIPTOR: {
|
case USB_SETUP_REQ_GET_DESCRIPTOR: {
|
||||||
uint8_t desc_type = setup->value >> 8;
|
uint8_t desc_type = setup->value >> 8;
|
||||||
if (desc_type == USB_HID_DESCR_REPORT) {
|
if (desc_type == USB_HID_DESCR_REPORT) {
|
||||||
usbus_control_slicer_put_bytes(usbus, hid->report_desc,
|
usbus_control_slicer_put_bytes(usbus, hid->report_desc,
|
||||||
hid->report_desc_size);
|
hid->report_desc_size);
|
||||||
}
|
|
||||||
else if (desc_type == USB_HID_DESCR_HID) {
|
|
||||||
_gen_hid_descriptor(usbus, NULL);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case USB_HID_REQUEST_GET_REPORT:
|
else if (desc_type == USB_HID_DESCR_HID) {
|
||||||
break;
|
_gen_hid_descriptor(usbus, NULL);
|
||||||
case USB_HID_REQUEST_GET_IDLE:
|
}
|
||||||
break;
|
break;
|
||||||
case USB_HID_REQUEST_GET_PROTOCOL:
|
}
|
||||||
break;
|
case USB_HID_REQUEST_GET_REPORT:
|
||||||
case USB_HID_REQUEST_SET_REPORT:
|
break;
|
||||||
if ((state == USBUS_CONTROL_REQUEST_STATE_OUTDATA)) {
|
case USB_HID_REQUEST_GET_IDLE:
|
||||||
size_t size = 0;
|
break;
|
||||||
uint8_t *data = usbus_control_get_out_data(usbus, &size);
|
case USB_HID_REQUEST_GET_PROTOCOL:
|
||||||
if (size > 0) {
|
break;
|
||||||
hid->cb(hid, data, size);
|
case USB_HID_REQUEST_SET_REPORT:
|
||||||
}
|
if ((state == USBUS_CONTROL_REQUEST_STATE_OUTDATA)) {
|
||||||
|
size_t size = 0;
|
||||||
|
uint8_t *data = usbus_control_get_out_data(usbus, &size);
|
||||||
|
if (size > 0) {
|
||||||
|
hid->cb(hid, data, size);
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
case USB_HID_REQUEST_SET_IDLE:
|
break;
|
||||||
break;
|
case USB_HID_REQUEST_SET_IDLE:
|
||||||
case USB_HID_REQUEST_SET_PROTOCOL:
|
break;
|
||||||
break;
|
case USB_HID_REQUEST_SET_PROTOCOL:
|
||||||
default:
|
break;
|
||||||
DEBUG("USB_HID: unknown request %d \n", setup->request);
|
default:
|
||||||
return -1;
|
DEBUG("USB_HID: unknown request %d \n", setup->request);
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -52,8 +52,9 @@ static usbus_t usbus;
|
|||||||
static char _stack[USBUS_STACKSIZE];
|
static char _stack[USBUS_STACKSIZE];
|
||||||
static char test_arg[] = { "Test argument" };
|
static char test_arg[] = { "Test argument" };
|
||||||
|
|
||||||
static void rx_cb(void* arg) {
|
static void rx_cb(void *arg)
|
||||||
printf("USB_HID rx_cb: %s \n", (char*)arg);
|
{
|
||||||
|
printf("USB_HID rx_cb: %s \n", (char *)arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void init(void)
|
static void init(void)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user