00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef SETUPDAT_H
00018 #define SETUPDAT_H
00019
00020 #include "fx2regs.h"
00021 #include "delay.h"
00099
00100
00101 #define STALLEP0() EP0CS |= bmEPSTALL
00102
00103 #define RESETTOGGLE(ep) TOGCTL = (ep&0x0F) + ((ep&0x80)>>3); TOGCTL |= bmRESETTOGGLE
00104 #define RENUMERATE() USBCS|=bmDISCON|bmRENUM;delay(1500);USBCS &= ~bmDISCON
00105
00106 #define SETUP_VALUE() MAKEWORD(SETUPDAT[3],SETUPDAT[2])
00107 #define SETUP_INDEX() MAKEWORD(SETUPDAT[5],SETUPDAT[4])
00108 #define SETUP_LENGTH() MAKEWORD(SETUPDAT[7],SETUPDAT[6])
00109
00110
00114
00115 typedef enum {
00116 GET_STATUS,
00117 CLEAR_FEATURE,
00118
00119 SET_FEATURE=0x03,
00120
00121 SET_ADDRESS=0x05,
00122 GET_DESCRIPTOR,
00123 SET_DESCRIPTOR,
00124 GET_CONFIGURATION,
00125 SET_CONFIGURATION,
00126 GET_INTERFACE,
00127 SET_INTERFACE,
00128 SYNC_FRAME
00129 } SETUP_DATA;
00130
00131
00136 xdata BYTE* ep_addr(BYTE ep);
00137
00138
00139
00140
00141
00142
00143
00144 void handle_setupdata();
00145
00146
00155 void handle_hispeed();
00156
00157
00158
00159 #define DSCR_DEVICE_TYPE 1
00160 #define DSCR_CONFIG_TYPE 2
00161 #define DSCR_STRING_TYPE 3
00162 #define DSCR_DEVQUAL_TYPE 6
00163 #define DSCR_OTHERSPD_TYPE 7
00164
00165
00166 #define DSCR_BCD 2
00167
00168
00169
00170 #define DSCR_DEVICE_LEN 18
00171
00172 typedef struct {
00173 BYTE dsc_len;
00174 BYTE dsc_type;
00175 WORD bcd;
00176 BYTE dev_class;
00177 BYTE dev_subclass;
00178 BYTE dev_protocol;
00179 BYTE max_pkt;
00180 WORD vendor_id;
00181 WORD product_id;
00182 WORD dev_version;
00183 BYTE idx_manstr;
00184 BYTE idx_devstr;
00185 BYTE idx_serstr;
00186 BYTE num_configs;
00187
00188 } DEVICE_DSCR;
00189
00190
00191
00192 #define DSCR_CONFIG_LEN 9
00193 typedef struct {
00194 BYTE dsc_len;
00195 BYTE dsc_type;
00196
00197 } CONFIG_DSCR;
00198
00199
00200 typedef struct {
00201 BYTE dsc_len;
00202 BYTE dsc_type;
00203 BYTE pstr;
00204 } STRING_DSCR;
00205
00206
00207 #endif