⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sl811.h

📁 SL811HST与51单片机组成usb从机的程序
💻 H
字号:
//#define BYTE  unsigned char 
//#define WORD  unsigned short	
//#define DWORD unsigned long	
//#define BOOL  bit				


#define NULL    0
#define TRUE    1
#define FALSE   0
 

//#define ACTIVE_BLINK        0x20           //P35    slave  led flash
//#define ACTIVE_LED          0x20           //P35    host   led flash
//#define IRQ_INPUT           0x04           //P32  - Active high interrupt input from SL811HST
//#define nHOST_SLAVE_MODE    0x08           //P33  - f/w control of nHost/Slave pin
//#define nRESET              0x10           //P34  - f/w control of nReset pin
//#define nDACK               0x01           //P30
//#define nDRQ                0x02           //P31


#define	AUDIO_KEYS			0xc0	// P12, P11, P10
#define	MUTE_KEY			0x01	// Mute Button - (P10)
#define	VOL_UP_KEY			0x02	// Volume Up button - (P11)
#define	VOL_DN_KEY			0x04	// Volume Down button - (P12)

//----------------------------------
// USB Report Bit Mask
//----------------------------------
#define	USB_MUTE		0x01	// Mute Button
#define	USB_VOLUME_UP	0x02	// Volume Up button
#define	USB_VOLUME_DN	0x04	// Volume Down button
#define	USB_PLAY		0x08	// Play button
#define	USB_STOP		0x10	// Stop button (Audio)
#define	USB_BASSB		0x20	// Bass Boost button
#define	USB_SCAN_PREV	0x40	// Scan Previous Track button
#define	USB_SCAN_NEXT	0x80	// Scan Next Track button

#define	USB_AC_SEARCH	0x01	// Search button
#define	USB_AC_HOME		0x02	// Home button
#define	USB_AC_BACK		0x04	// Back button
#define	USB_AC_FORWARD	0x08	// Forward button
#define	USB_AC_STOP		0x10	// Stop button (Broswer)
#define	USB_AC_REFRESH	0x20	// Refresh button
#define	USB_AC_BOOKMARK	0x40	// Bookmark button
#define	USB_AC_EMAIL	0x80	// Email button

// SL811S Slave Device Specific
//#define  EP0_LEN                8
#define  EP0_LEN                8   //or 8
#define  EP1_LEN                8  //2
#define  EP2_LEN                64 
#define  MAXIFCNUM              8
#define  TIME_OUT               5

// SL811S Registers Address
#define  CtrlReg                0x05    // USB Control Registers
#define  IntEna                 0x06
#define  USBAddress             0x07
#define  IntStatus              0x0D
#define  cDATASet               0x0E
#define  cSOFcnt                0x0F

#define  EP0AControl            0x00   // EP0 Endpoint Registers (set A)
#define  EP0AAddress            0x01
#define  EP0AXferLen            0x02
#define  EP0AStatus             0x03
#define  EP0ACounter            0x04

#define  EP0BControl            0x08   // EP0 Endpoint Registers (set B)
#define  EP0BAddress            0x09
#define  EP0BXferLen            0x0A
#define  EP0BStatus             0x0B
#define  EP0BCounter            0x0C

#define  EP1AControl            0x10   // EP1 Endpoint Registers (set A)
#define  EP1AAddress            0x11
#define  EP1AXferLen            0x12
#define  EP1AStatus             0x13
#define  EP1ACounter            0x14

#define  EP2AControl            0x20   // EP1 Endpoint Registers (set A)
#define  EP2AAddress            0x21
#define  EP2AXferLen            0x22
#define  EP2AStatus             0x23
#define  EP2ACounter            0x24

#define  EP3AControl            0x30   // EP1 Endpoint Registers (set A)
#define  EP3AAddress            0x31
#define  EP3AXferLen            0x32
#define  EP3AStatus             0x33
#define  EP3ACounter            0x44

#define EP0A_Slave_Buf          0x40
#define EP1A_Slave_Buf          EP0A_Slave_Buf+EP0_LEN
#define EP2A_Slave_Buf          EP1A_Slave_Buf+EP0_LEN

// Interrupt Register Bit Masks    中断寄存器位标记
#define EP0_DONE                0x01
#define EP1_DONE                0x02
#define EP2_DONE                0x04
#define EP3_DONE                0x08
#define DMA_DONE                0x10
#define SOF_DONE                0x20
#define USB_RESET_DONE          0x40

//----------------------------------
// EPx Status Register Bit Masks
//----------------------------------
#define EP_ACK				0x01
#define EP_ERROR			0x02
#define EP_TIMEOUT			0x04
#define EP_SEQUENCE			0x08
#define EP_SETUP			0x10
#define EP_OVERFLOW			0x20
#define EP_NAK				0x40
#define EP_STALL			0x80

//----------------------------------
// EPx Control Register Bit Mask
//----------------------------------
#define DATA0_OUT    		0x03   	// (Data0 + OUT/SETUP + Enable + Arm)
#define DATA1_OUT    		0x43    // (Data1 + OUT/SETUP + Enable + Arm)
#define DATA0_IN    		0x07   	// (Data0 + IN + Enable + Arm)
#define DATA1_IN    		0x47   	// (Data1 + IN + Enable + Arm)
#define DATAX	    		0x40   	// Data sequence bits
#define ENABLE_ISO    		0x10   	// Enable ISO on endpoint
#define SEND_STALL    		0x27   	// (STALL + IN + Enable + Arm)
#define DIRECTION 		    0x04   	// OUT - '0', receive from host
									// IN  - '1', transmit to host	

#define DATA0_IN_ENABLE		0x07   	// (Data0 + IN + Enable)
#define DATA0_IN_DISABLE	0x04   	// (Data0 + IN + Disable)


//----------------------------------
// Standard Chapter 9 definition
//----------------------------------
#define STD_REQUEST		    0x00    //标准
#define CLASS_REQUEST		0x01
#define VENDOR_REQUEST		0x02
#define RECIPIENT_DEV		0x00
#define RECIPIENT_IFC		0x01
#define RECIPIENT_ENP		0x02

#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  

//----------------------------------
// Class Descriptor for HID 
//----------------------------------
#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_DEV         	0x21
#define HID_REPORT      	0x22
#define HID_PHYSICAL    	0x23

#define INPUT        		0x01
#define OUTPUT     	    	0x02
#define FEATURE    	   	    0x03

#define NONE	        	0x00
#define KEYBOARD        	0x01
#define MOUSE	        	0x02

//Function Prototypes

//#include <reg51.h>
//#include <sl811.h>
//#include <absacc.h>
//#include <des.h>
//*****************************************************************************************
// Variables Define
//*****************************************************************************************
#define    XBYTE ((unsigned char volatile xdata *) 0)
#define    SL811H_ADDR   XBYTE[0xfeff]
#define    SL811H_DATA   XBYTE[0xffff]
 
//----------------------------------

//----------------------------------
//xdata BYTE 	SL811H_ADDR	_at_ 0x4000;// A0 = '0' - Addr (A15 = nCS of SL811HS)
//xdata BYTE 	SL811H_DATA _at_ 0x4001;// A0 = '1' - Data

//xdata BYTE	Slave_USBaddr;			// USB device address
//xdata BYTE	Slave_ConfigVal;		// Device configuration value
//xdata BYTE	Slave_Protocol;			// HID device protocol status
//xdata BYTE	Slave_IdleRate;			// HID device idle rate value
//xdata BYTE	Slave_RemoteWU;			// Device remote wakeup stats
//xdata BYTE	Slave_inEPstall;		// EP0 ~ EP7's IN stall status
//xdata BYTE	Slave_outEPstall;		// EP0 ~ EP7's OUT stall status
//xdata BYTE	Slave_IfcAlt[MAXIFCNUM];// 8 interface(Ep0~7) contain alternate setting value

//xdata BYTE	Audio_Keys;				// Audio Control BitMap
//xdata BYTE	Prev_Audio_Keys;
//xdata BYTE	Internet_Keys;			// Internet Control BitMap
//xdata BYTE	Prev_Internet_Keys;


 unsigned char SL811Read( unsigned char a);
void SL811Write( unsigned char a, unsigned char d);
void SL811BufRead( unsigned char addr, unsigned char *s, unsigned char c);
void SL811BufWrite( unsigned char addr, unsigned char *s, unsigned char c);
void SL811s_init(void);
void C51_init(void);
void EP0A_OUT_Arm( unsigned char len);
void EP0A_IN_Arm( unsigned char buf_adr, unsigned char len, unsigned char seq);
void EP1A_IN_Arm( unsigned char buf_adr, unsigned char len, unsigned char seq);
void ep0_isr(void);
void ep1_isr(void);
void ep2_isr(void);
int  sof_isr(void);
// Application-Specific functions???
void audio_key_scan(void);
void internet_key_scan(void);
void Delay(void);


      

 // SL811S Variables


  


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -