USB: coding style fixes
[bertos.git] / bertos / drv / usb_mouse.c
index 35a73f8c5e12be550db0d25216e68d54ed78aecd..7a59c769e4f6c1043d15390416da4c36aacc21b5 100644 (file)
 
 #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,
        .bcdUSB = 0x100,
-       .bDeviceClass = USB_CLASS_HID,
+       .bDeviceClass = 0,
        .bDeviceSubClass = 0,
        .bDeviceProtocol = 0,
        .idVendor = USB_HID_VENDOR_ID,
@@ -85,7 +85,7 @@ static usb_device_descriptor_t usb_hid_device_descriptor =
        .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,
@@ -96,7 +96,7 @@ static const usb_config_descriptor_t usb_hid_config_descriptor =
        .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,
@@ -140,33 +140,34 @@ static const uint8_t hid_report_descriptor[] =
        0xC0    // End Collection
 };
 
-static const usb_hid_descriptor_t usb_hid_descriptor =
+static const usb_HidDesc usb_hid_descriptor =
 {
        .bLength = sizeof(usb_hid_descriptor),
        .bDescriptorType = HID_DT_HID,
-       .bcdHID = usb_cpu_to_le16(0x0110),
+       .bcdHID = usb_cpu_to_le16((uint16_t)0x0110),
        .bCountryCode = 0,
        .bNumDescriptors = 1,
        .bDescriptorHidType = HID_DT_REPORT,
-       .wDescriptorLength = usb_cpu_to_le16(sizeof(hid_report_descriptor)),
+       .wDescriptorLength =
+               usb_cpu_to_le16((uint16_t)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,
        .bEndpointAddress = USB_HID_REPORT_EP,
        .bmAttributes = USB_ENDPOINT_XFER_INT,
-       .wMaxPacketSize = usb_cpu_to_le16(4),
+       .wMaxPacketSize = usb_cpu_to_le16((uint16_t)4),
        .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,
 };
 
@@ -176,11 +177,11 @@ static DEFINE_USB_STRING(manufacturer_str,
 static DEFINE_USB_STRING(product_str,
                USB_STRING("U", "S", "B", " ", "M", "o", "u", "s", "e"));
 
-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,
 };
 
@@ -195,7 +196,7 @@ static mouse_report_t report;
 
 static bool hid_mouse_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);
@@ -212,13 +213,13 @@ static void usb_hid_event_cb(usb_ctrlrequest_t *ctrl)
                {
                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_mouse_configured = true;
@@ -236,7 +237,7 @@ static void usb_hid_event_cb(usb_ctrlrequest_t *ctrl)
                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__);
@@ -251,8 +252,8 @@ static void usb_hid_event_cb(usb_ctrlrequest_t *ctrl)
        }
 }
 
-/* Global usb-serial descriptor that identifies the usb-serial device */
-static struct usb_device usb_mouse = {
+/* Global usb-mouse descriptor that identifies the usb-mouse device */
+static UsbDevice usb_mouse = {
        .device = &usb_hid_device_descriptor,
        .config = usb_hid_config,
        .strings = usb_hid_strings,
@@ -262,19 +263,19 @@ static struct usb_device usb_mouse = {
 /* Low-level usb-hid device initialization */
 static int usb_mouse_hw_init(void)
 {
-       if (usb_device_register(&usb_mouse) < 0)
+       if (usb_deviceRegister(&usb_mouse) < 0)
                return -1;
        LOG_INFO("usb-hid: registered new USB mouse device\n");
        return 0;
 }
 
 /* Send a mouse event */
-void usb_mouse_send_event(int8_t x, int8_t y, int8_t buttons)
+void usb_mouseSendEvent(int8_t x, int8_t y, int8_t buttons)
 {
        report.x = x;
        report.y = y;
        report.buttons = buttons;
-       usb_ep_write(USB_HID_REPORT_EP, &report, sizeof(report));
+       usb_endpointWrite(USB_HID_REPORT_EP, &report, sizeof(report));
 }
 
 /*
@@ -282,7 +283,7 @@ void usb_mouse_send_event(int8_t x, int8_t y, int8_t buttons)
  *
  * TODO: support more than one device at the same time.
  */
-int usb_mouse_init(UNUSED_ARG(int, unit))
+int usb_mouseInit(UNUSED_ARG(int, unit))
 {
 #if CONFIG_KERN
        MOD_CHECK(proc);