📄 ezusb.lst
字号:
C51 COMPILER V6.10 EZUSB 02/28/2008 16:41:03 PAGE 1
C51 COMPILER V6.10, COMPILATION OF MODULE EZUSB
OBJECT MODULE PLACED IN .\ezusb.OBJ
COMPILER INVOKED BY: D:\Program Files\Keil\C51\BIN\C51.EXE .\ezusb.h OPTIMIZE(6,SPEED) DEBUG OBJECTEXTEND
stmt level source
1 //-----------------------------------------------------------------------------
2 // File: ezusb.h
3 // Contents: EZ-USB constants, macros, datatypes, globals, and library
4 // function prototypes.
5 //
6 // Copyright (c) 1997 AnchorChips, Inc. All rights reserved
7 //-----------------------------------------------------------------------------
8 #ifndef EZUSB_H //Header sentry
9 #define EZUSB_H
10
11 //#define CHIPREV_B // Indicate target chip revision
12 #define CHIPREV_C
13
14 #define GET_CHIP_REV() ((CPUCS >> 4) & 0x00FF) // EzUSB Chip Rev Field
15 //#define EZUSB_CHIPREV_B 0 // This Rev has been taken over by TNG
16 #define EZUSB_TNG_CHIPREV_A 0 // Rev 0 now means TNG RevA
17 #define EZUSB_CHIPREV_C 2
18 #define EZUSB_CHIPREV_D 3
19 #define EZUSB_CHIPREV_E 4
20
21 #define INTERNAL_DSCR_ADDR 0x0080 // Relocate Descriptors to 0x80
22 #define bmSTRETCH 0x07
23 #define FW_STRETCH_VALUE 0x0 // Set stretch to 0 in frameworks
24 // Note: a RevE eratta states that stretch must=0 to set OUTxBC
25
26 //-----------------------------------------------------------------------------
27 // Constants
28 //-----------------------------------------------------------------------------
29 #define TRUE 1
30 #define FALSE 0
31
32 #define bmBIT0 0x01
33 #define bmBIT1 0x02
34 #define bmBIT2 0x04
35 #define bmBIT3 0x08
36 #define bmBIT4 0x10
37 #define bmBIT5 0x20
38 #define bmBIT6 0x40
39 #define bmBIT7 0x80
40
41 #define DEVICE_DSCR 0x01 // Descriptor type: Device
42 #define CONFIG_DSCR 0x02 // Descriptor type: Configuration
43 #define STRING_DSCR 0x03 // Descriptor type: String
44 #define INTRFC_DSCR 0x04 // Descriptor type: Interface
45 #define ENDPNT_DSCR 0x05 // Descriptor type: End Point
46
47 #define bmBUSPWR bmBIT7 // Config. attribute: Bus powered
48 #define bmSELFPWR bmBIT6 // Config. attribute: Self powered
49 #define bmRWU bmBIT5 // Config. attribute: Remote Wakeup
50
51 #define bmEPOUT bmBIT7
52 #define bmEPIN 0x00
53
54 #define EP_CONTROL 0x00 // End Point type: Control
55 #define EP_ISO 0x01 // End Point type: Isochronous
C51 COMPILER V6.10 EZUSB 02/28/2008 16:41:03 PAGE 2
56 #define EP_BULK 0x02 // End Point type: Bulk
57 #define EP_INT 0x03 // End Point type: Interrupt
58
59 #define SUD_SIZE 8 // Setup data packet size
60
61 //////////////////////////////////////////////////////////////////////////////
62 //Added for HID
63
64 #define SETUP_MASK 0x60 //Used to mask off request type
65 #define SETUP_STANDARD_REQUEST 0 //Standard Request
66 #define SETUP_CLASS_REQUEST 0x20 //Class Request
67 #define SETUP_VENDOR_REQUEST 0x40 //Vendor Request
68 #define SETUP_RESERVED_REQUEST 0x60 //Reserved or illegal request
69
70 //////////////////////////////////////////////////////////////////////////////
71
72
73 #define SC_GET_STATUS 0x00 // Setup command: Get Status
74 #define SC_CLEAR_FEATURE 0x01 // Setup command: Clear Feature
75 #define SC_RESERVED 0x02 // Setup command: Reserved
76 #define SC_SET_FEATURE 0x03 // Setup command: Set Feature
77 #define SC_SET_ADDRESS 0x05 // Setup command: Set Address
78 #define SC_GET_DESCRIPTOR 0x06 // Setup command: Get Descriptor
79 #define SC_SET_DESCRIPTOR 0x07 // Setup command: Set Descriptor
80 #define SC_GET_CONFIGURATION 0x08 // Setup command: Get Configuration
81 #define SC_SET_CONFIGURATION 0x09 // Setup command: Set Configuration
82 #define SC_GET_INTERFACE 0x0a // Setup command: Get Interface
83 #define SC_SET_INTERFACE 0x0b // Setup command: Set Interface
84 #define SC_SYNC_FRAME 0x0c // Setup command: Sync Frame
85 #define SC_ANCHOR_LOAD 0xa0 // Setup command: Anchor load
86
87 #define GD_DEVICE 0x01 // Get device descriptor: Device
88 #define GD_CONFIGURATION 0x02 // Get device descriptor: Configuration
89 #define GD_STRING 0x03 // Get device descriptor: String
90 #define GD_HID 0x21 // Get descriptor: HID
91 #define GD_REPORT 0x22 // Get descriptor: Report
92
93 #define GS_DEVICE 0x80 // Get Status: Device
94 #define GS_INTERFACE 0x81 // Get Status: Interface
95 #define GS_ENDPOINT 0x82 // Get Status: End Point
96
97 #define FT_DEVICE 0x00 // Feature: Device
98 #define FT_ENDPOINT 0x02 // Feature: End Point
99
100 #define I2C_IDLE 0 // I2C Status: Idle mode
101 #define I2C_SENDING 1 // I2C Status: I2C is sending data
102 #define I2C_RECEIVING 2 // I2C Status: I2C is receiving data
103 #define I2C_PRIME 3 // I2C Status: I2C is receiving the first byte of a string
104 #define I2C_STOP 5 // I2C Status: I2C waiting for stop completion
105 #define I2C_BERROR 6 // I2C Status: I2C error; Bit Error
106 #define I2C_NACK 7 // I2C Status: I2C error; No Acknowledge
107 #define I2C_OK 8 // I2C positive return code
108 #define I2C_WAITSTOP 9 // I2C Status: Wait for STOP complete
109
110 /*-----------------------------------------------------------------------------
111 Macros
112 -----------------------------------------------------------------------------*/
113
114 #define MSB(word) (BYTE)(((WORD)(word) >> 8) & 0xff)
115 #define LSB(word) (BYTE)((WORD)(word) & 0xff)
116
117 #define SWAP_ENDIAN(word) ((BYTE*)&word)[0] ^= ((BYTE*)&word)[1];\
C51 COMPILER V6.10 EZUSB 02/28/2008 16:41:03 PAGE 3
118 ((BYTE*)&word)[1] ^= ((BYTE*)&word)[0];\
119 ((BYTE*)&word)[0] ^= ((BYTE*)&word)[1]
120
121 #define EZUSB_IRQ_ENABLE() EUSB = 1
122 #define EZUSB_IRQ_DISABLE() EUSB = 0
123 #ifndef CHIPREV_B
124 #define EZUSB_IRQ_CLEAR() EXIF &= ~0x10 // IE2_
125 #endif
126
127 #define EZUSB_STALL_EP0() EP0CS |= bmEPSTALL
128 #define EZUSB_STALL_EP(ep_id) EPIO[ep_id].cntrl = bmEPSTALL
129 #define EZUSB_UNSTALL_EP(ep_id) EPIO[ep_id].cntrl = 0
130 #define EZUSB_GET_EP_STATUS(ep_id) EPIO[ep_id].cntrl
131 #define EZUSB_SET_EP_BYTES(ep_id,count) EPIO[ep_id].bytes = count
132
133 // the WRITEDELAY macro compiles to the time equivalent of 3 NOPs.
134 // It is used in the frameworks to allow for write recovery time
135 // requirements of certain registers. This is only necessary for
136 // EZ-USB FX parts. See the EZ-USB FX TRM register chapter for
137 // more information on write recovery time issues. (Look for "latency applies")
138 #define WRITEDELAY() {char writedelaydummy = 0;}
139 // if this firmware will never run on an EZ-USB FX part replace
140 // with:
141 // #define WRITEDELAY()
142
143 #define EZUSB_RESET_DATA_TOGGLE(ep) TOGCTL = (((ep & 0x80) >> 3) + (ep & 0x07));\
144 WRITEDELAY();\
145 TOGCTL |= 0x20
146
147
148 #define EZUSB_ENABLE_RSMIRQ() (EICON |= 0x20) // Enable Resume Interrupt (EPFI_)
149 #define EZUSB_DISABLE_RSMIRQ() (EICON &= ~0x20) // Disable Resume Interrupt (EPFI_)
150 #define EZUSB_CLEAR_RSMIRQ() (EICON &= ~0x10) // Clear Resume Interrupt Flag (PFI_)
151
152 #define EZUSB_GETI2CSTATUS() (I2CPckt.status)
153 #define EZUSB_CLEARI2CSTATUS() if((I2CPckt.status == I2C_BERROR) || (I2CPckt.status == I2C_NACK))\
154 I2CPckt.status = I2C_IDLE;
155
156 #define EZUSB_ENABLEBP() (USBBAV |= bmBPEN)
157 #define EZUSB_DISABLEBP() (USBBAV &= ~bmBPEN)
158 #define EZUSB_CLEARBP() (USBBAV |= bmBREAK)
159 #define EZUSB_BP(addr) BPADDR = (WORD)addr
160
161 #define EZUSB_EXTWAKEUP() (USBCS & bmRWAKEUP)
162
163 //-----------------------------------------------------------------------------
164 // Datatypes
165 //-----------------------------------------------------------------------------
166 typedef unsigned char BYTE;
167 typedef unsigned short WORD;
168 typedef unsigned long DWORD;
169 typedef bit BOOL;
170
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -