qmk_firmware

QMK firmware for my keyboards (Corne, Sweep Ferris) and trackball (Ploopy Adept)
Log | Files | Refs | Submodules | LICENSE

vusb.h (4153B)


      1 /*
      2 Copyright 2011 Jun Wako <wakojun@gmail.com>
      3 
      4 This program is free software: you can redistribute it and/or modify
      5 it under the terms of the GNU General Public License as published by
      6 the Free Software Foundation, either version 2 of the License, or
      7 (at your option) any later version.
      8 
      9 This program is distributed in the hope that it will be useful,
     10 but WITHOUT ANY WARRANTY; without even the implied warranty of
     11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     12 GNU General Public License for more details.
     13 
     14 You should have received a copy of the GNU General Public License
     15 along with this program.  If not, see <http://www.gnu.org/licenses/>.
     16 */
     17 
     18 #pragma once
     19 
     20 #include "host_driver.h"
     21 #include <usbdrv/usbdrv.h>
     22 
     23 typedef struct usbDescriptorHeader {
     24     uchar bLength;
     25     uchar bDescriptorType;
     26 } __attribute__((packed)) usbDescriptorHeader_t;
     27 
     28 typedef struct usbDeviceDescriptor {
     29     usbDescriptorHeader_t header;
     30     unsigned              bcdUSB;
     31     uchar                 bDeviceClass;
     32     uchar                 bDeviceSubClass;
     33     uchar                 bDeviceProtocol;
     34     uchar                 bMaxPacketSize0;
     35     unsigned              idVendor;
     36     unsigned              idProduct;
     37     unsigned              bcdDevice;
     38     uchar                 iManufacturer;
     39     uchar                 iProduct;
     40     uchar                 iSerialNumber;
     41     uchar                 bNumConfigurations;
     42 } __attribute__((packed)) usbDeviceDescriptor_t;
     43 
     44 typedef struct usbConfigurationDescriptorHeader {
     45     usbDescriptorHeader_t header;
     46     unsigned              wTotalLength;
     47     uchar                 bNumInterfaces;
     48     uchar                 bConfigurationValue;
     49     uchar                 iConfiguration;
     50     uchar                 bmAttributes;
     51     uchar                 bMaxPower;
     52 } __attribute__((packed)) usbConfigurationDescriptorHeader_t;
     53 
     54 typedef struct usbStringDescriptor {
     55     usbDescriptorHeader_t header;
     56     int                   bString[];
     57 } __attribute__((packed)) usbStringDescriptor_t;
     58 
     59 typedef struct usbInterfaceDescriptor {
     60     usbDescriptorHeader_t header;
     61     uchar                 bInterfaceNumber;
     62     uchar                 bAlternateSetting;
     63     uchar                 bNumEndpoints;
     64     uchar                 bInterfaceClass;
     65     uchar                 bInterfaceSubClass;
     66     uchar                 bInterfaceProtocol;
     67     uchar                 iInterface;
     68 } __attribute__((packed)) usbInterfaceDescriptor_t;
     69 
     70 typedef struct usbEndpointDescriptor {
     71     usbDescriptorHeader_t header;
     72     uchar                 bEndpointAddress;
     73     uchar                 bmAttributes;
     74     unsigned              wMaxPacketSize;
     75     uchar                 bInterval;
     76 } __attribute__((packed)) usbEndpointDescriptor_t;
     77 
     78 typedef struct usbHIDDescriptor {
     79     usbDescriptorHeader_t header;
     80     unsigned              bcdHID;
     81     uchar                 bCountryCode;
     82     uchar                 bNumDescriptors;
     83     uchar                 bDescriptorType;
     84     unsigned              wDescriptorLength;
     85 } __attribute__((packed)) usbHIDDescriptor_t;
     86 
     87 typedef struct usbConfigurationDescriptor {
     88     usbConfigurationDescriptorHeader_t header;
     89 
     90 #ifndef KEYBOARD_SHARED_EP
     91     usbInterfaceDescriptor_t keyboardInterface;
     92     usbHIDDescriptor_t       keyboardHID;
     93     usbEndpointDescriptor_t  keyboardINEndpoint;
     94 #else
     95     usbInterfaceDescriptor_t sharedInterface;
     96     usbHIDDescriptor_t       sharedHID;
     97     usbEndpointDescriptor_t  sharedINEndpoint;
     98 #endif
     99 
    100 #if defined(RAW_ENABLE)
    101     usbInterfaceDescriptor_t rawInterface;
    102     usbHIDDescriptor_t       rawHID;
    103     usbEndpointDescriptor_t  rawINEndpoint;
    104     usbEndpointDescriptor_t  rawOUTEndpoint;
    105 #endif
    106 
    107 #if defined(SHARED_EP_ENABLE) && !defined(KEYBOARD_SHARED_EP)
    108     usbInterfaceDescriptor_t sharedInterface;
    109     usbHIDDescriptor_t       sharedHID;
    110     usbEndpointDescriptor_t  sharedINEndpoint;
    111 #endif
    112 
    113 #if defined(CONSOLE_ENABLE)
    114     usbInterfaceDescriptor_t consoleInterface;
    115     usbHIDDescriptor_t       consoleHID;
    116     usbEndpointDescriptor_t  consoleINEndpoint;
    117 #endif
    118 } __attribute__((packed)) usbConfigurationDescriptor_t;
    119 
    120 extern bool vusb_suspended;
    121 
    122 host_driver_t *vusb_driver(void);