?? host_811.h
字號:
#define USB_A_DONE 0x01
#define USB_B_DONE 0x02
#define BABBLE_DETECT 0x04
#define INT_RESERVE 0x08
#define SOF_TIMER 0x10
#define INSERT_REMOVE 0x20
#define USB_RESET 0x40
#define USB_DPLUS 0x80
#define INT_CLEAR 0xFF
//EP0 Status Mask
#define EP0_ACK 0x01 // EPxStatus bits mask during a read
#define EP0_ERROR 0x02
#define EP0_TIMEOUT 0x04
#define EP0_SEQUENCE 0x08
#define EP0_SETUP 0x10
#define EP0_OVERFLOW 0x20
#define EP0_NAK 0x40
#define EP0_STALL 0x80
/*-------------------------------------------------------------------------
* Standard Chapter 9 definition
*-------------------------------------------------------------------------
*/
#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_CONFIG 0x08
#define SET_CONFIG 0x09
#define GET_INTERFACE 0x0a
#define SET_INTERFACE 0x0b
#define SYNCH_FRAME 0x0c
#define DEVICE 0x01
#define CONFIGURATION 0x02
#define STRING 0x03
#define INTERFACE 0x04
#define ENDPOINT 0x05
#define STDCLASS 0x00
#define HIDCLASS 0x03
#define HUBCLASS 0x09 // bDeviceClass, bInterfaceClass
/*-------------------------------------------------------------------------
* SL11H/SL811H definition
*-------------------------------------------------------------------------
*/
// USB-A, USB-B Host Control Register [00H, 08H]
// Pre Reserved
// DatT Dir [1=Trans, 0=Recv]
// SOF Enable
// ISO Arm
#define DATA0_WR 0x07 // 0000 0111 ( Data0 + OUT + Enable + Arm)
#define sDATA0_WR 0x27 // 0010 0111 ( Data0 + SOF + OUT + Enable + Arm)
#define pDATA0_WR 0x87 // 1000 0111 (Pre + Data0 + OUT + Enable + Arm)
#define psDATA0_WR 0xA7 // 1010 0111 (Pre + Data0 + SOF + OUT + Enable + Arm)
#define DATA0_RD 0x03 // 0000 0011 ( Data0 + IN + Enable + Arm)
#define sDATA0_RD 0x23 // 0010 0011 ( Data0 + SOF + IN + Enable + Arm)
#define pDATA0_RD 0x83 // 1000 0011 (Pre + Data0 + IN + Enable + Arm)
#define psDATA0_RD 0xA3 // 1010 0011 (Pre + Data0 + SOF + IN + Enable + Arm)
#define PID_SETUP 0xD0
#define PID_IN 0x90
#define PID_OUT 0x10
/*-------------------------------------------------------------------------
* Class Descriptor for HID (chap.7) : These values from bRequest
*-------------------------------------------------------------------------
*/
// HID Class-Specific Request
#define GET_REPORT 0x01
#define GET_IDLE 0x02
#define GET_PROTOCOL 0x03
// 0x04-0x08 is reserved
#define SET_REPORT 0x09
#define SET_IDLE 0x0A
#define SET_PROTOCOL 0x0B
// 0x24-0x2F is reserved
#define HID_DEV 0x21
#define HID_REPORT 0x22
#define HID_PHYSICAL 0x23
// 0x24-0x2F is reserved
/*-------------------------------------------------------------------------
* Report Type
*-------------------------------------------------------------------------
*/
#define INPUT 0x01
#define OUPUT 0x02
#define FEATURE 0x03
/*-------------------------------------------------------------------------
* Protocol Codes in the bInterfaceProtocol
*-------------------------------------------------------------------------
*/
#define NONE 0
#define KEYBOARD 1
#define MOUSE 2
#define OTHER 3 // 3-255 is reserved
/*-------------------------------------------------------------------------
* SubClass Codes in the bInterfaceSubClass
*-------------------------------------------------------------------------
*/
#define sCLASS 1
#define sOTHER 2
/*-------------------------------------------------------------------------
* HUB CLASS
*-------------------------------------------------------------------------
*/
//Hub Status & Hub Change bit masks
#define HUB_STATUS_LOCAL_POWER 0x0001
#define HUB_STATUS_OVERCURRENT 0x0002
#define HUB_CHANGE_LOCAL_POWER 0x0001
#define HUB_CHANGE_OVERCURRENT 0x0002
// wPortStatus bits
#define USB_PORT_STAT_CONNECTION 0x0001
#define USB_PORT_STAT_ENABLE 0x0002
#define USB_PORT_STAT_SUSPEND 0x0004
#define USB_PORT_STAT_OVERCURRENT 0x0008
#define USB_PORT_STAT_RESET 0x0010
#define USB_PORT_STAT_POWER 0x0100
#define USB_PORT_STAT_LOW_SPEED 0x0200
// wPortChange bits
#define USB_PORT_STAT_C_CONNECTION 0x0001
#define USB_PORT_STAT_C_ENABLE 0x0002
#define USB_PORT_STAT_C_SUSPEND 0x0004
#define USB_PORT_STAT_C_OVERCURRENT 0x0008
#define USB_PORT_STAT_C_RESET 0x0010
/*-------------------------------------------------------------------------
* Standard Chapter 11 definition
*-------------------------------------------------------------------------
*/
#define USB_HUB_NOT_USED 0
#define USB_HUB_USED 1
#define USB_HUB_IN_SHUTDOWN 2
// HUB Class Feature Selector
#define HUB_LOCAL_POWER 0x00
#define HUB_OVER_POWER 0x01
// Port Status Field, wPortStatus
#define PORT_CONNECTION 0x00
#define PORT_ENABLE 0x01
#define PORT_SUSPEND 0x02
#define PORT_OVER_CURRENT 0x03
#define PORT_RESET 0x04
#define PORT_POWER 0x08
#define PORT_LOW_SPEED 0x09
// Port Change Field, wPortChange
#define C_PORT_CONNECTION 0x10
#define C_PORT_ENABLE 0x11
#define C_PORT_SUSPEND 0x12
#define C_PORT_OVER_CURRENT 0x13
#define C_PORT_RESET 0x14
//HUB Characteristic
#define HUB_GANG_POWER 0
#define HUB_INDIVIDUAL_POWER 1
#define HUB_NO_POWER_SWITCH 2
#define HUB_POWER_MASK 3
// HUB Port Status
#define HUB_STATUS_PORT_CONNECTION 1
#define HUB_STATUS_PORT_ENABLE 2
#define HUB_STATUS_PORT_SUSPEND 4
#define HUB_STATUS_PORT_OVER_CURRENT 8
#define HUB_STATUS_PORT_RESET 0x10
#define HUB_STATUS_PORT_POWER 0x100
#define HUB_STATUS_PORT_LOW_SPEED 0x200
#define HUB_CHANGE_PORT_CONNECTION 0x010000
#define HUB_CHANGE_PORT_ENABLE 0x020000
#define HUB_CHANGE_PORT_SUSPEND 0x040000
#define HUB_CHANGE_PORT_OVER_CURRENT 0x080000
#define HUB_CHANGE_PORT_RESET 0x100000
// Other various equivalences
#define PORT_SPEED_SHIFT 9
#define HUB_WAIT_PORT_RESET 25
#define RETRY_PORT_RESET 10
// Possiblities Hub Error
#define ERROR_HUB_SET_POWER 0x8500
/*-------------------------------------------------------------------------
* Function Protocol
*-------------------------------------------------------------------------
*/
void sl811h_init(void);
int slave_detect(void);
int speed_detect(void) ;
BYTE SL811Read(BYTE a);
void SL811Write(BYTE a, BYTE d);
void SL811BufRead(BYTE addr, BYTE *s, BYTE c);
void SL811BufWrite(BYTE addr, BYTE *s, BYTE c);
void USBReset();
int usbXfer(BYTE usbaddr, BYTE endpoint, BYTE pid, BYTE iso, WORD wPayload, WORD wLen, BYTE *buffer);
int ep0Xfer(BYTE usbaddr, WORD payload, pSetupPKG setup, BYTE *pData);
int VendorCmd(BYTE usbaddr,BYTE bReq, BYTE bCmd, WORD wValue, WORD wIndex,WORD wLen,BYTE* pData);
int GetHubDesc(BYTE usbaddr,WORD wValue, WORD wLen, BYTE *desc);
int GetDesc(BYTE usbaddr, WORD wValue, WORD wIndex, WORD wLen, BYTE *desc);
int GetHid_Desc(BYTE usbaddr,WORD wValue, WORD wLen, BYTE *desc);
int GetStatus(BYTE usbaddr, BYTE *desc);
int SetAddress(WORD addr);
int Set_Configuration(BYTE usbaddr,WORD wVal);
int EnumUsbDev(BYTE DevAddr);
WORD WordSwap(WORD input);
int DataRW(BYTE usbaddr, BYTE epaddr, WORD wPayload, WORD wLen, BYTE *pData);
int HubPortEnum(void);
int PortFeature(BYTE usbaddr, BYTE bReq, WORD wValue, BYTE cPort);
int GetPortStatus(BYTE usbaddr, BYTE cPort, BYTE *desc);
void Clear_ezIN1(void);
void Clear_ezIN3(void);
void Set_ezDEV(BYTE chg);
int Slave_Detach(void);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -