#define USB_HID_REPORT_EP (USB_DIR_IN | 1)
-static usb_device_descriptor_t usb_hid_device_descriptor =
+static UsbDeviceDesc usb_hid_device_descriptor =
{
.bLength = sizeof(usb_hid_device_descriptor),
.bDescriptorType = USB_DT_DEVICE,
.bNumConfigurations = 1,
};
-static const usb_config_descriptor_t usb_hid_config_descriptor =
+static const UsbConfigDesc usb_hid_config_descriptor =
{
.bLength = sizeof(usb_hid_config_descriptor),
.bDescriptorType = USB_DT_CONFIG,
.bMaxPower = 50, /* 100 mA */
};
-static const usb_interface_descriptor_t usb_hid_interface_descriptor =
+static const UsbInterfaceDesc usb_hid_interface_descriptor =
{
.bLength = sizeof(usb_hid_interface_descriptor),
.bDescriptorType = USB_DT_INTERFACE,
.wDescriptorLength = usb_cpu_to_le16(sizeof(hid_report_descriptor)),
};
-static const usb_endpoint_descriptor_t usb_hid_ep_descriptor =
+static const UsbEndpointDesc usb_hid_ep_descriptor =
{
.bLength = sizeof(usb_hid_ep_descriptor),
.bDescriptorType = USB_DT_ENDPOINT,
.bInterval = 10, /* resolution in ms */
};
-static const usb_descriptor_header_t *usb_hid_config[] =
+static const UsbDescHeader *usb_hid_config[] =
{
- (const usb_descriptor_header_t *)&usb_hid_config_descriptor,
- (const usb_descriptor_header_t *)&usb_hid_interface_descriptor,
- (const usb_descriptor_header_t *)&usb_hid_descriptor,
- (const usb_descriptor_header_t *)&usb_hid_ep_descriptor,
+ (const UsbDescHeader *)&usb_hid_config_descriptor,
+ (const UsbDescHeader *)&usb_hid_interface_descriptor,
+ (const UsbDescHeader *)&usb_hid_descriptor,
+ (const UsbDescHeader *)&usb_hid_ep_descriptor,
NULL,
};
USB_STRING("U", "S", "B", " ",
"K", "e", "y", "b", "o", "a", "r", "d"));
-static const usb_string_descriptor_t *usb_hid_strings[] =
+static const UsbStringDesc *usb_hid_strings[] =
{
- (usb_string_descriptor_t *)&language_str,
- (usb_string_descriptor_t *)&manufacturer_str,
- (usb_string_descriptor_t *)&product_str,
+ (UsbStringDesc *)&language_str,
+ (UsbStringDesc *)&manufacturer_str,
+ (UsbStringDesc *)&product_str,
NULL,
};
static bool hid_keyboard_configured;
-static void usb_hid_event_cb(usb_ctrlrequest_t *ctrl)
+static void usb_hid_event_cb(UsbCtrlRequest *ctrl)
{
uint16_t value = usb_le16_to_cpu(ctrl->wValue);
uint16_t index = usb_le16_to_cpu(ctrl->wIndex);
{
case HID_DT_HID:
LOG_INFO("%s: HID_DT_HID\n", __func__);
- usb_ep_write(USB_DIR_IN | 0,
+ usb_endpointWrite(USB_DIR_IN | 0,
&usb_hid_descriptor,
sizeof(usb_hid_descriptor));
break;
case HID_DT_REPORT:
LOG_INFO("%s: HID_DT_REPORT\n", __func__);
- usb_ep_write(USB_DIR_IN | 0,
+ usb_endpointWrite(USB_DIR_IN | 0,
&hid_report_descriptor,
sizeof(hid_report_descriptor));
hid_keyboard_configured = true;
break;
case HID_REQ_SET_REPORT:
LOG_INFO("%s: HID_REQ_SET_REPORT\n", __func__);
- usb_ep_write(USB_DIR_IN | 0, NULL, 0);
+ usb_endpointWrite(USB_DIR_IN | 0, NULL, 0);
break;
case HID_REQ_GET_IDLE:
LOG_INFO("%s: HID_REQ_GET_IDLE\n", __func__);
break;
case HID_REQ_SET_IDLE:
LOG_INFO("%s: HID_REQ_SET_IDLE\n", __func__);
- usb_ep_write(USB_DIR_IN | 0, NULL, 0);
+ usb_endpointWrite(USB_DIR_IN | 0, NULL, 0);
break;
case HID_REQ_GET_PROTOCOL:
LOG_INFO("%s: HID_REQ_GET_PROTOCOL\n", __func__);
}
/* Global usb-keyboard descriptor that identifies the usb-keyboard device */
-static struct usb_device usb_keyboard = {
+static UsbDevice usb_keyboard = {
.device = &usb_hid_device_descriptor,
.config = usb_hid_config,
.strings = usb_hid_strings,
/* Low-level usb-hid device initialization */
static int usb_keyboard_hw_init(void)
{
- if (usb_device_register(&usb_keyboard) < 0)
+ if (usb_deviceRegister(&usb_keyboard) < 0)
return -1;
LOG_INFO("usb-hid: registered new USB keyboard device\n");
return 0;
{
report[0] = mod;
report[2] = code;
- usb_ep_write(USB_HID_REPORT_EP, &report, sizeof(report));
+ usb_endpointWrite(USB_HID_REPORT_EP, &report, sizeof(report));
}
/*