📄 usb_9602.lst
字号:
21 =1 /* this macro toggles a bit in the spec'd register or memory location */
22 =1 #define TGLBIT(reg,bit) reg^=bit
23 =1
24 =1 /* this macro tests a bit, returning a non-zero val if bit is set *****/
25 =1 #define TSTBIT(reg,bit) (reg&bit)
26 =1
19 #include "strings.h"
1 =1
2 =1 xdata const unsigned char STR_DATA[] = {4,3,9,4 /*LANGID array (English) */
3 =1
4 =1 /*[004] MFG_STR --> "National Semiconductor Corporation" -------------*/
5 =1 , 70,3, 78,0, 97,0,116,0,105,0,111,0,110,0, 97,0,108,0, 32,0, 83,0
C51 COMPILER V5.50, USB_9602 02/12/99 16:05:13 PAGE 8
6 =1 ,101,0,109,0,105,0, 99,0,111,0,110,0,100,0,117,0, 99,0,116,0,111,0
7 =1 ,114,0, 32,0, 67,0,111,0,114,0,112,0,111,0,114,0, 97,0,116,0,105,0
8 =1 ,111,0,110,0
9 =1
10 =1 /*[074] PID_STR --> "USBN9602 HID Evaluation" ------------------------*/
11 =1 , 48,3, 85,0, 83,0, 66,0, 78,0, 57,0, 54,0, 48,0, 50,0, 32,0, 72,0
12 =1 , 73,0, 68,0, 32,0, 69,0,118,0, 97,0,108,0,117,0, 97,0,116,0,105,0
13 =1 ,111,0,110,0
14 =1
15 =1 /*[122] NBR_STR --> "Jim Lyle" ---------------------------------------*/
16 =1 , 18,3, 74,0,105,0,109,0, 32,0, 76,0,121,0,108,0,101,0
17 =1
18 =1 /*[140] CFG_STR --> "Standard Configuration" -------------------------*/
19 =1 , 46,3, 83,0,116,0, 97,0,110,0,100,0, 97,0,114,0,100,0, 32,0, 67,0
20 =1 ,111,0,110,0,102,0,105,0,103,0,117,0,114,0, 97,0,116,0,105,0,111,0
21 =1 ,110,0
22 =1
23 =1 /*[186] INT_STR --> "HID JOYSTICK Interface" -------------------------*/
24 =1 , 46,3, 72,0, 73,0, 68,0, 32,0, 74,0, 79,0, 89,0, 83,0, 84,0, 73,0
25 =1 , 67,0, 75,0, 32,0, 73,0,110,0,116,0,101,0,114,0,102,0, 97,0, 99,0
26 =1 ,101,0
27 =1 }; /*end of STR_DATA */
28 =1
29 =1 #define MFG_STR_OFS 4
30 =1 #define PID_STR_OFS 74
31 =1 #define NBR_STR_OFS 122
32 =1 #define CFG_STR_OFS 140
33 =1 #define INT_STR_OFS 186
20
21 #include "joystk.h"
1 =1 /* joystk.h */
2 =1
3 =1 xdata unsigned char ReportDescriptor[59] = {
4 =1 0x05, 0x01, /* USAGE_PAGE (Generic Desktop) */
5 =1 0x15, 0x00, /* LOGICAL_MINIMUM (0) */
6 =1 0x09, 0x04, /* USAGE (Joystick) */
7 =1 0xa1, 0x01, /* COLLECTION (Application) */
8 =1 0x15, 0x00, /* LOGICAL_MINIMUM (0) */
9 =1 0x26, 0xff, 0x00, /* LOGICAL_MAXIMUM (255) */
10 =1 0x75, 0x08, /* REPORT_SIZE (8) */
11 =1 0x95, 0x01, /* REPORT_COUNT (1) */
12 =1 0x81, 0x03, /* INPUT (Cnst,Var,Abs) */
13 =1 0x05, 0x01, /* USAGE_PAGE (Generic Desktop) */
14 =1 0x09, 0x01, /* USAGE (Pointer) */
15 =1 0xa1, 0x00, /* COLLECTION (Physical) */
16 =1 0x09, 0x30, /* USAGE (X) */
17 =1 0x09, 0x31, /* USAGE (Y) */
18 =1 0x95, 0x02, /* REPORT_COUNT (2) */
19 =1 0x81, 0x02, /* INPUT (Data,Var,Abs) */
20 =1 0xc0, /* END_COLLECTION */
21 =1 0x15, 0x00, /* LOGICAL_MINIMUM (0) */
22 =1 0x25, 0x01, /* LOGICAL_MAXIMUM (1) */
23 =1 0x75, 0x01, /* REPORT_SIZE (1) */
24 =1 0x95, 0x04, /* REPORT_COUNT (4) */
25 =1 0x81, 0x03, /* INPUT (Cnst,Var,Abs) */
26 =1 0x05, 0x09, /* USAGE_PAGE (Button) */
27 =1 0x19, 0x01, /* USAGE_MINIMUM (Button 1) */
28 =1 0x29, 0x04, /* USAGE_MAXIMUM (Button 4) */
29 =1 0x55, 0x00, /* UNIT_EXPONENT (0) */
30 =1 0x65, 0x00, /* UNIT (None) */
31 =1 0x95, 0x04, /* REPORT_COUNT (4) */
32 =1 0x81, 0x02, /* INPUT (Data,Var,Abs) */
33 =1 0xc0 /* END_COLLECTION */
34 =1 };
35 =1
22
C51 COMPILER V5.50, USB_9602 02/12/99 16:05:13 PAGE 9
23
24 #define Adr_9602_Adr 0xC001 /* Adresa, od niz se adresuji registery 9602 */
25 #define Adr_9602_Dat 0xC000 /* Adresa, od niz se adresuji registery 9602 */
26 #define VREG_ST VGE
27 /* The system clock is the 48 MHz USB clock, divided by this value: */
28 #define CLKDIV 5 /*USB clock divisor */
29 /**********************************************************************/
30 /* Message related values */
31 /**********************************************************************/
32 /* Command message constants */
33 #define SYNCBYT 0xAA /*sync code expected */
34 #define MAJREV 'A' /*major revision */
35 #define MINREV 40 /*minor revision */
36
37 /**********************************************************************/
38 /* These are system independent macros and defines */
39 /**********************************************************************/
40 #define HIBYT(x) (x)/256
41 #define LOBYT(x) (x)%256
42
43 #define NORMAL_ALTMSK SD3+RESET_A /*ALTMSK if not in suspend*/
44 #define SUSPND_ALTMSK RESUME_A+RESET_A /*ALTMSK if in suspend */
45
46 #define OUTQLEN 8 /*length of outq */
47
48 /* Enforce a minimum time period active before suspending to make sure*/
49 /* that the board is detected at power on and restart. The value here*/
50 /* corresponds to the minimum number of time periods between suspend */
51 /* events. At half-second intervals, the value here equals 2 seconds */
52 #define SUSPND_TO 4
53 #define INTR_TYPE INT_L_P /*act low pushpull ints */
54 /*these are the bit definitions for the status variable *********/
55 #define RPTBUSY BIT1 /*set when report changes*/
56 #define RPTCHNG BIT2 /*set for HID data changes*/
57 #define DEBUG BIT3 /*set when host listening */
58 #define MLTIPKT BIT4 /*set for multi-packet ops*/
59 #define GETDESC BIT5 /*set for get_descr. req. */
60 #define GETRPRT BIT6 /*set for get_report req. */
61 #define USB_CMD BIT7 /*set when doing usb cmd */
62 /*sequence is underway */
63
64 /*these are the bit definitions for the dtapid variable *********/
65 #define TGL0PID BIT0 /*tracks NEXT data PID */
66 #define TGL1PID BIT1 /*tracks NEXT data PID */
67 #define TGL2PID BIT2 /*tracks NEXT data PID */
68 #define TGL3PID BIT3 /*tracks NEXT data PID */
69
70 #define DEV_DESC_SIZE sizeof(DEV_DESC)
71 #define CFG_DESC_SIZE sizeof(CFG_DESC)
72 #define RPT_DESC_SIZE sizeof(ReportDescriptor)
73
74 //#define PUT_TX(dta) SBAF=dta /*transmit top of queue !!! */
75 #define TXINTON SETBIT(SCCR2,TIE) /*turn on/off ser. tx int */
76 #define TXINTOFF CLRBIT(SCCR2,TIE)
77
78 /* Flush and disable the USB TX0 **************************************/
79 #define FLUSHTX0 {write_usb(TXC0,FLUSH);}
80
81 /* Flush and disable the USB TX1 **************************************/
82 #define FLUSHTX1 {write_usb(TXC1,FLUSH);}
83
84 /* Flush and disable the USB TX2 **************************************/
85 #define FLUSHTX2 {write_usb(TXC2,FLUSH);}
86
87 /* Flush and disable the USB TX3 **************************************/
88 #define FLUSHTX3 {write_usb(TXC3,FLUSH);}
C51 COMPILER V5.50, USB_9602 02/12/99 16:05:13 PAGE 10
89
90 /* Flush and disable the USB RX0 **************************************/
91 #define FLUSHRX0 {write_usb(RXC0,FLUSH);}
92
93 /* Flush and disable the USB RX1 **************************************/
94 #define FLUSHRX1 {write_usb(RXC1,FLUSH);}
95
96 /* Flush and disable the USB RX2 **************************************/
97 #define FLUSHRX2 {write_usb(RXC2,FLUSH);}
98
99 /* Flush and disable the USB RX3 **************************************/
100 #define FLUSHRX3 {write_usb(RXC3,FLUSH);}
101
102 /* sets status.GETDESC and status.MLTIPKT *****************************/
103 #define SET_GETDESC {SETBIT(status,GETDESC); SETBIT(status,MLTIPKT);}
104
105 /* clears the multi-packet mode bits **********************************/
106 #define CLR_MLTIPKT {CLRBIT(status,GETDESC); CLRBIT(status,GETRPRT); \
107 CLRBIT(status,MLTIPKT);}
108
109 /* enable TX1, using the appropriate DATA PID, but not toggling it ****/
110 #define TXEN1_PID_NO_TGL {if(TSTBIT(dtapid,TGL1PID)) \
111 write_usb(TXC1,TX_TOGL+TX_LAST+TX_EN); else \
112 write_usb(TXC1,TX_LAST+TX_EN);}
113
114 /* enable TX0, using the appropriate DATA PID *************************/
115 #define TXEN0_PID {if(TSTBIT(dtapid,TGL0PID)) write_usb(TXC0,TX_TOGL+TX_EN);\
116 else write_usb(TXC0,TX_EN); TGLBIT(dtapid,TGL0PID);}
117
118 /* enable TX1, using the appropriate DATA PID, but not toggling it ****/
119 #define TXEN1_PID_NO_TGL {if(TSTBIT(dtapid,TGL1PID)) \
120 write_usb(TXC1,TX_TOGL+TX_LAST+TX_EN); else \
121 write_usb(TXC1,TX_LAST+TX_EN);}
122
123 /* enable TX3, using the appropriate DATA PID, but not toggling it ****/
124 #define TXEN3_PID_NO_TGL {SETBIT(status,RPTBUSY);CLRBIT(status,RPTCHNG);\
125 if(TSTBIT(dtapid,TGL3PID)) write_usb(TXC3,TX_TOGL+TX_LAST+TX_EN);\
126 else write_usb(TXC3,TX_LAST+TX_EN);}
127
128 /* store the status byte in FIFO0 for the chosen endpoint *************/
129 #define EPSTATUS(epbit) if(TSTBIT(stalld,epbit)) write_usb(TXD0,1); \
130 else write_usb(TXD0,0); break;
131
132
133 #include "descrpt.h"
1 =1 /*SINGLE HID INTERFACE*/
2 =1
3 =1 /*for now the sizes and offsets below need to be hand calculated, */
4 =1 /*until I can find a better way to do it */
5 =1 /*for multiple byte values, LSB goes first */
6 =1 xdata const unsigned char DEV_DESC[] = {DEV_LENGTH, /*length of this desc. */
7 =1 DEVICE, /*DEVICE descriptor */
8 =1 0x00,0x01, /*spec rev level (BCD) */
9 =1 0x00, /*device class */
10 =1 0x00, /*device subclass */
11 =1 0x00, /*device protocol */
12 =1 0x08, /*max packet size */
13 =1 0x00,0x04, /*National's vendor ID */
14 =1 0x5B,0xC3, /*National's product ID */
15 =1 0x40,0x01, /*National's revision ID */
16 =1 MFG_STR_OFS, /*index of manuf. string */
17 =1 PID_STR_OFS, /*index of prod. string */
18 =1 0, /*index of ser. # string */
19 =1 0x01 /*number of configs. */
20 =1 };
21 =1
C51 COMPILER V5.50, USB_9602 02/12/99 16:05:13 PAGE 11
22 =1 #ifdef BUSPOWER
=1 #define ATTRIBUTES 0x80 /*bus powered */
=1 #else
25 =1 #define ATTRIBUTES 0x40 /*self powered */
26 =1 #endif
27 =1
28 =1 xdata const unsigned char CFG_DESC[] = {CFG_LENGTH, /*length of this desc. */
29 =1 CONFIGURATION, /*CONFIGURATION descriptor*/
30 =1 0x22,0x00, /*total length returned */
31 =1 0x01, /*number of interfaces */
32 =1 0x01, /*number of this config */
33 =1 CFG_STR_OFS, /*index of config. string */
34 =1 ATTRIBUTES, /*attr.: bus powered */
35 =1 50, /*max power (100 mA) */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -