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

📄 sn8_usb_setting.lib

📁 Sonix新出的MCU SN8F2255的USB的HID库。
💻 LIB
字号:
// ***************************************************************** //
//
//  USB 1.1 FULL speed device  
//
//  * USB Parameter define
//  * USB RAM define
//
// ***************************************************************** //

// ================================================================= //
//  	                   Return Kernel mode Pattern define  	     //
// ================================================================= //
// Default Pattern: 0xAA,0x55,0xA5,0x5A,0xFF,0x00,0x33,0xCC
RETURN_KERNEL_0		EQU	0xAA
RETURN_KERNEL_1		EQU	0x55
RETURN_KERNEL_2		EQU	0xA5
RETURN_KERNEL_3		EQU	0x5A
RETURN_KERNEL_4		EQU	0xFF
RETURN_KERNEL_5		EQU	0x00
RETURN_KERNEL_6		EQU	0x33
RETURN_KERNEL_7		EQU	0xCC



// ================================================================= //
//  	                   MCU Parameter define  	       	     //
// ================================================================= //

;MCU 
RBANK_TEMP	ds	1

// ================================================================= //
//  			    USB Parameter define  	       	     //
// ================================================================= //

;===============================================================================
;Feature parameter for USB
;-------------------------
;User define the value to set the device's feature
;===============================================================================
;USB SPEC 1.1 section 9.4.5
DEVICE_STATUS				EQU	0X02	;	 Power    Remote wakeup	
							;-------------------------------
							;0x00 -	  BUS	      NO 			
							;0x01 -   SELF        NO
							;0x02 -   BUS	      YES 
							;0x03 -   SELF        YES

Halt0_initial_value			EQU	0x00	;EP0' halt value
Halt1_initial_value			EQU	0x00	;EP1' halt value
Halt2_initial_value			EQU	0x00	;EP2' halt value


;USB SPEC 1.1 section 9.4.4
interface_AlternateSet_0		EQU	0x00
interface_AlternateSet_1		EQU	0x00
;Device Class Definition for Human Interface Devices (HID) Version 1.11	Chapter 7
IDLE_TIME_initial_value			EQU	0x00

; PROTOCOL = 00, only send 3 bytes, no z wheel.
; PROTOCOL = 01, support 4 bytes, including z wheel.

PROTOCOL_initial_value			EQU	0x00	

// USB Define for Delay wakeup
// User can define the parameter to fit the requirement
	
;-------------------------------
;1. Fcpu = Fosc/1 12MHz	USB_DELAY_FOR_REMOTE_WAKEUP = 80	
;2. Fcpu = Fosc/2 6MHz	USB_DELAY_FOR_REMOTE_WAKEUP = 
;3. Fcpu = Fosc/4 3MHz  USB_DELAY_FOR_REMOTE_WAKEUP = 
;4. Fcpu = Fosc/8 1.5MHz USB_DELAY_FOR_REMOTE_WAKEUP =

USB_REMOTE_WAKEUP_K_STATE_DELAY		EQU	80	


// *********************************************************************
// 			   Program code use
// *********************************************************************

// Control transfer
REQUEST_TYPE_MASK			EQU	0x60
EP0_PACKET_SIZE    			EQU	0x08
USB_DEVICE_DESCRIPTOR_TYPE		EQU	0x01
USB_CONFIGURATION_DESCRIPTOR_TYPE	EQU	0x02
USB_STRING_DESCRIPTOR_TYPE		EQU	0x03
USB_INTERFACE_DESCRIPTOR_TYPE		EQU	0x04
USB_ENDPOINT_DESCRIPTOR_TYPE		EQU	0x05
USB_HID_DESCRIPTOR_TYPE			EQU	0x21		
USB_HID_REPORT_TYPE			EQU	0x22

// Compliance equation
USB_RECIPIENT            		EQU	0x1F
USB_RECIPIENT_DEVICE     		EQU	0x00
USB_RECIPIENT_INTERFACE  		EQU	0x01
USB_RECIPIENT_ENDPOINT   		EQU	0x02
		
// USB defined Feature selectors
USB_FEATURE_ENDPOINT_STALL          	EQU	0x00
USB_FEATURE_REMOTE_WAKEUP           	EQU	0x01
USB_FEATURE_POWER_D0                	EQU	0x02
USB_FEATURE_POWER_D1                	EQU	0x03
USB_FEATURE_POWER_D2                	EQU	0x04
USB_FEATURE_POWER_D3                	EQU	0x05

// USB HID get report
GET_REPORT_TYPE_INPUT			EQU	0X01
SET_REPORT_TYPE_OUTPUT			EQU	0X02
GET_REPORT_TYPE_FEATURE			EQU	0X03

//string descriptor
STRING_iManufacturer			EQU	0x01
STRING_iProduct				EQU	0x02
STRING_iSerialnumber			EQU	0x03
STRING_iConfiguration			EQU	0x04
STRING_iInterface			EQU	0x05

// ================================================================= //
//  		  	3. USB RAM define  	               	     //
// ================================================================= //

// ----------------------------------------------------------------- //
// 		  	USB Setup token RAM 	 	             //
// ----------------------------------------------------------------- //

bmRequestType	ds	1
bRequest	ds	1
wValue_H	ds	1
wValue_L	ds	1
wIndex_H	ds	1
wIndex_L	ds	1
wLength_H	ds	1
wLength_L	ds	1

// ----------------------------------------------------------------- //
// 		   	USB Device status		             //
// ----------------------------------------------------------------- //
;USB SPEC 1.1 Chapter 9.4.5
Halt0			ds	1
Halt1			ds	1

USB_Status		ds	1
			bSetupPacket	EQU	USB_Status.0
			bSetAddress	EQU	USB_Status.1
			bAlreadySetAddr	EQU	USB_Status.2
			bRemote_Wakeup	EQU	USB_Status.3
			bSuspend 	EQU 	USB_Status.4
			bflag_index	EQU	USB_Status.5
	;		USB_sleep_index	EQU	USB_Status.6
	;		EP0_OUT_TOKEN	EQU	USB_Status.7

Wakeup_IO_status	ds	1

// ----------------------------------------------------------------- //
// 		   	USB Data structure		       	     //
// ----------------------------------------------------------------- //

UDP0_TEMP		ds	1
BSetConfiguration	ds	1

Tmp_Cnt			ds	1
bdevice_address		ds	1
G_Var1			ds	1
Accbuf			ds	1

table_index	ds	2
table_length	ds	2

// ----------------------------------------------------------------- //
//  		   	USB RAM BUFFER (HID)	             	     //
// ----------------------------------------------------------------- //

if_AlternateSet_0	ds	1
IDLE_TIME_IF0_ID	ds	1
PROTOCOL		ds	1	// For HID protocol "Get/Set PROTOCOL"
SET_REPORT_BYTE_0	ds	1	// For EP0 output data 0 (keyboard LED)
USB_HID_Status		ds	1
			set_report_flag			EQU	USB_HID_Status.0
			set_report_feature_flag		EQU 	USB_HID_Status.1
			set_report_feature_arrival	EQU	USB_HID_Status.2
			set_report_feature_done		EQU	USB_HID_Status.3

// ----------------------------------------------------------------- //
//  		   	MOUSE 			             	     //
// ----------------------------------------------------------------- //
MOUSE_KEY	ds	1
MOUSE_X_AXIS	ds	1
MOUSE_Y_AXIS	ds	1
MOUSE_Z_AXIS	ds	1
TEMP_X_AXIS	ds	1
TEMP_Y_AXIS	ds	1	
TEMP_Z_AXIS	ds	1
test_cnt	ds	1


SET_REPORT_FEATURE_Buf	ds	8


⌨️ 快捷键说明

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