123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333 |
-
- #ifndef _USB_H_
- #define _USB_H_
-
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- #include "yc11xx.h"
- #include "yc_drv_common.h"
- #define SDK_DEBUG
- #define USB_TEST
- #define MS_REPORT_ID 0X01
- #define KB_NORMAL_REPORT_ID 0X00
- #define KB_MULTIKEY_REPORT_ID 0X03
- #define USB_EP1_KB 0x10
- #define USB_EP2_MS 0x20
- #define USB_EP2_MULTIKEY 0x21
- #define MAC_BOOT_MODE 0x01
- #define R_KEY 0x02
- #define LR_KEY 0x03
- #define STANDARD_REQ 0x00
- #define CLASS_REQ 0x01
- #define HCI_CLASS_REQUEST_TYPE 0x20
- #define HID_CLASS_REQUEST_TYPE 0x21
- #define HID_TESTS_REQUEST_TYPE 0xa1
- #define CLEAR_PORT_REQUEST_TYPE 0x23
- #define GET_PORT_REQUEST_TYPE 0xa3
- #define ZERO_CLASS_REQUEST_TYPE 0X00
- #define GET_STATUS 0x00
- #define CLEAR_FEATURE 0x01
- #define SET_FEATURE 0x03
- #define SET_ADDRESS 0x05
- #define GET_DESCRIPTOR 0x06
- #define SET_DESCRIPTOR 0x07
- #define GET_CONFIGURATION 0x08
- #define SET_CONFIGURATION 0x09
- #define GET_INTERFACE 0x0A
- #define SET_INTERFACE 0x0B
- #define SYNCH_FRAME 0x0C
- #define DSC_DEVICE 0x01
- #define DSC_CONFIG 0x02
- #define DSC_STRING 0x03
- #define DSC_INTERFACE 0x04
- #define DSC_ENDPOINT 0x05
- #define DSC_HID 0x21
- #define DSC_HID_REPORT 0x22
- #define IN_DEVICE 0x80
-
- #define OUT_DEVICE 0x00
-
- #define IN_INTERFACE 0x81
-
- #define OUT_INTERFACE 0x01
-
- #define IN_ENDPOINT 0x82
-
- #define OUT_ENDPOINT 0x02
- #define GET_REPORT 0x01
- #define GET_IDLE 0x02
- #define GET_PROTOCOL 0x03
- #define SET_REPORT 0x09
- #define SET_IDLE 0x0A
- #define SET_PROTOCOL 0x0B
- #define HID_REPORT_ID 0xF2
- #define EP0_PACKET_SIZE 0x40
- #define EP1_PACKET_SIZE 0x40
- #define EP2_PACKET_SIZE 0x40
- #define HID_REPORT_SIZE 16
- #define HID_REPORT_DESCRIPTOR_SIZE 0x001B
- #define USB_STATUS_SETUP 0x10
- #define USB_STATUS_NAK 0x40
- #define USB_STAY_BY 0
- #define USB_GOT_REPORT_REQ 1
- #define USB_CONNECTED 2
- #define USB_SLEEP 3
- #define USB_RESUME 4
- #define USB_SETIDLE_1 5
- #define DEV_ATTACHED 0X00
- #define DEV_POWERED 0X01
- #define DEV_DEFAULT 0X02
- #define DEV_ADDRESS 0X03
- #define DEV_CONFIGURED 0X04
- #define DEV_SUSPENDED 0X05
- #define IN_EP1 0x81
- #define OUT_EP1 0x01
- #define IN_EP2 0x82
- #define OUT_EP2 0x02
- #define IN_EP3 0x83
- #define OUT_EP3 0x03
- #define ENDPOINT_HALT 0x00
- #define DEVICE_REMOTE_WAKEUP 0x01
- #define BOOT_PROTOCOL 0x00
- #define REPORT_PROTOCOL 0x01
- #define USB_MAX_NUM_CFG 0x01
- #define PC_GET_REPORT 0x01ba
- #define PC_SET_REPORT 0x02ba
- #define PC_SET_REPORT_bValue 0x0200
- #define PC_SET_REPORT_wIndex 0x0000
- #define PC_SET_REPORT_bLength 0x0001
- #define PC_REPORT_ID 0xba
- #ifndef MSB
- #define MSB 1
- #endif
- #ifndef LSB
- #define LSB 0
- #endif
- typedef union{uint16_t i;uint8_t c[2];} WORDER;
- typedef struct
- {
- uint8_t bmRequestType;
- uint8_t bRequest;
- WORDER bValue;
- WORDER wIndex;
- WORDER bLength;
- uint32_t redundant_buf1;
- uint32_t redundant_buf2;
- } usb_setup;
- typedef struct
- {
- uint8_t bLength;
- uint8_t bDescriptorType;
- uint16_t bcdUSB;
- uint8_t bDeviceClass;
- uint8_t bDeviceSubClass;
- uint8_t bDeviceProtocol;
- uint8_t bMaxPacketSize0;
- uint16_t idVendor;
- uint16_t idProduct;
- uint16_t bcdDevice;
- uint8_t iManufacturer;
- uint8_t iProduct;
- uint8_t iSerialNumber;
- uint8_t bNumConfigurations;
- } device_descriptor;
- typedef struct
- {
- uint8_t bLength;
- uint8_t bDescriptorType;
- uint16_t wTotalLength;
- uint8_t bNumInterfaces;
- uint8_t bConfigurationValue;
- uint8_t iConfiguration;
- uint8_t bmAttributes;
- uint8_t bMaxPower;
-
- } configuration_descriptor;
- typedef struct
- {
- uint8_t bLength;
- uint8_t bDescriptorType;
- uint8_t bInterfaceNumber;
- uint8_t bAlternateSetting;
- uint8_t bNumEndpoints;
- uint8_t bInterfaceClass;
- uint8_t bInterfaceSubClass;
- uint8_t bInterfaceProtocol;
- uint8_t iInterface;
- } interface_descriptor;
- typedef struct
- {
- uint8_t bLength;
- uint8_t bDescriptorType;
- uint16_t bcdHID;
-
- uint8_t bCountryCode;
- uint8_t bNumDescriptors;
- uint8_t bReportDescriptorType;
- uint16_t wItemLength;
- } class_descriptor;
- typedef struct
- {
- uint8_t bLength;
- uint8_t bDescriptorType;
- uint8_t bEndpointAddress;
- uint8_t bmAttributes;
- uint16_t wMaxPacketSize;
- uint8_t bInterval;
- } endpoint_descriptor;
- typedef struct {
- configuration_descriptor hid_configuration_descriptor;
- interface_descriptor hid_keyboard_interface_descriptor;
- class_descriptor hid_keyboard_descriptor;
- endpoint_descriptor hid_keyboard_endpoint_in_descriptor;
- interface_descriptor hid_ms_interface_descriptor;
- class_descriptor hid_ms_descriptor;
- endpoint_descriptor hid_ms_endpoint_in_descriptor;
- } hid_configuration_descriptor;
- #define HID_KB_RP_DESCRIPTOR_LEN 0x3f
- #define HID_MO_RP_DESCRIPTOR_LEN 0xc3
- #define HID_CONFIG_DESCRIPTOR_LEN 0x3b
- void usb_init();
- void USB_IRQHandler();
- #endif
|