digital oscilloscope
Revision | e778ca7ec17bd8291f30dd2a9082af9d0db6d65c (tree) |
---|---|
Zeit | 2018-12-03 04:14:20 |
Autor | PJ |
Commiter | PJ |
firmware/bulk/setupdat: handle_get_interface() changed; handle_hispeed() removed
@@ -282,7 +282,7 @@ | ||
282 | 282 | type_adc = 1; |
283 | 283 | |
284 | 284 | // renumerate |
285 | - RENUMERATE(); | |
285 | + USBCS|=bmDISCON|bmRENUM;delay(1500);USBCS &= ~bmDISCON; | |
286 | 286 | |
287 | 287 | CPUCS = CPU_CLK_48; // CPU clock = 48MHz |
288 | 288 |
@@ -54,13 +54,12 @@ | ||
54 | 54 | |
55 | 55 | uint8_t alternate = 0; |
56 | 56 | |
57 | -BOOL handle_get_interface(BYTE ifc, BYTE* alt_ifc) | |
57 | +uint8_t handle_get_interface(uint8_t ifc) | |
58 | 58 | { |
59 | - if (ifc==0) { | |
60 | - *alt_ifc = alternate; | |
61 | - return TRUE; | |
62 | - } | |
63 | - return FALSE; | |
59 | + if (ifc != 0) | |
60 | + return ALT_INVALID; // If the interface specified does not exist, then the device responds with a Request Error. | |
61 | + | |
62 | + return alternate; | |
64 | 63 | } |
65 | 64 | |
66 | 65 | BYTE handle_get_configuration(void) |
@@ -99,7 +98,9 @@ | ||
99 | 98 | } |
100 | 99 | |
101 | 100 | void hispeed_isr() interrupt { |
101 | +#ifdef OLD_HISPEED | |
102 | 102 | handle_hispeed(); |
103 | +#endif | |
103 | 104 | CLEAR_HISPEED(); |
104 | 105 | } |
105 | 106 |
@@ -23,13 +23,7 @@ | ||
23 | 23 | #include "FX2.h" |
24 | 24 | |
25 | 25 | |
26 | -extern BOOL handle_vendorcommand(BYTE cmd); | |
27 | -extern BOOL handle_set_configuration(BYTE cfg); | |
28 | -extern BOOL handle_get_interface(BYTE ifc, BYTE* alt_ifc); | |
29 | -extern BOOL handle_set_interface(BYTE ifc,BYTE alt_ifc); | |
30 | -extern BYTE handle_get_configuration(); | |
31 | -extern BOOL handle_set_configuration(BYTE cfg); | |
32 | -extern void handle_reset_ep(BYTE ep); | |
26 | +//extern void handle_reset_ep(BYTE ep); | |
33 | 27 | |
34 | 28 | /** |
35 | 29 | * Predefs for handlers |
@@ -100,8 +94,8 @@ | ||
100 | 94 | |
101 | 95 | case GET_INTERFACE: |
102 | 96 | { |
103 | - BYTE alt_ifc; | |
104 | - if (!handle_get_interface(SETUPDAT[4],&alt_ifc)) { | |
97 | + uint8_t alt_ifc = handle_get_interface(SETUPDAT[4]); | |
98 | + if (alt_ifc == ALT_INVALID) { | |
105 | 99 | STALLEP0(); |
106 | 100 | } else { |
107 | 101 | EP0BUF[0] = alt_ifc; |
@@ -249,14 +243,16 @@ | ||
249 | 243 | |
250 | 244 | #include "descr.h" |
251 | 245 | |
252 | -//WORD pDevConfig = (WORD)&dscr_config_fs; | |
246 | +#ifdef OLD_HISPEED | |
247 | +WORD pDevConfig = (WORD)&dscr_config_fs; | |
253 | 248 | |
254 | 249 | #ifndef USB_FS |
255 | 250 | // Hi Speed Interrupt |
256 | 251 | void handle_hispeed() __critical { |
257 | -// pDevConfig = (WORD)&dscr_config_hs; | |
252 | + pDevConfig = (WORD)&dscr_config_hs; | |
258 | 253 | } |
259 | 254 | #endif |
255 | +#endif // OLD_HISPEED | |
260 | 256 | |
261 | 257 | /** |
262 | 258 | * Handle: |
@@ -96,15 +96,25 @@ | ||
96 | 96 | \endverbatim |
97 | 97 | */ |
98 | 98 | |
99 | +#include <stdint.h> | |
100 | + | |
101 | +BOOL handle_vendorcommand(BYTE cmd); | |
102 | +BOOL handle_set_configuration(BYTE cfg); | |
103 | +uint8_t handle_get_interface(uint8_t ifc); | |
104 | +enum { ALT_INVALID = 0xff }; | |
105 | +BOOL handle_set_interface(BYTE ifc, BYTE alt_ifc); | |
106 | +BYTE handle_get_configuration(void); | |
107 | +BOOL handle_set_configuration(BYTE cfg); | |
108 | + | |
99 | 109 | // for ease functions |
100 | 110 | |
101 | 111 | #define STALLEP0() EP0CS |= bmEPSTALL |
102 | 112 | // to use this, the endpoint needs bit 8 to be IN=1,OUT=0 |
103 | 113 | //#define RESETTOGGLE(ep) TOGCTL = (ep&0x0F) + ((ep&0x80)>>3); TOGCTL |= bmRESETTOGGLE |
104 | 114 | #define RESETTOGGLE(ep) TOGCTL = (ep&0x0F) + ((ep&0x80)>>3); TOGCTL = (ep&0x0F) + ((ep&0x80)>>3) + bmRESETTOGGLE |
105 | -#define RENUMERATE_START USBCS|=bmDISCON|bmRENUM | |
106 | -#define RENUMERATE_END USBCS &= ~bmDISCON | |
107 | -#define RENUMERATE() USBCS|=bmDISCON|bmRENUM;delay(1500);USBCS &= ~bmDISCON | |
115 | +//#define RENUMERATE_START USBCS|=bmDISCON|bmRENUM | |
116 | +//#define RENUMERATE_END USBCS &= ~bmDISCON | |
117 | +//#define RENUMERATE() USBCS|=bmDISCON|bmRENUM;delay(1500);USBCS &= ~bmDISCON | |
108 | 118 | |
109 | 119 | //! see TRM 2-3 |
110 | 120 | //! here are the usb setup data commands |
@@ -139,16 +149,17 @@ | ||
139 | 149 | You can also use the usbjt and enable the sudav isr |
140 | 150 | and call the function from withing the sudav isr routine |
141 | 151 | */ |
142 | -void handle_setupdata(); | |
152 | +void handle_setupdata(void); | |
143 | 153 | |
154 | +#ifdef OLD_HISPEED | |
144 | 155 | /** |
145 | 156 | For devices to properly handle usb hispeed |
146 | 157 | (This is if your descriptor has high speed and full speed versions |
147 | - and it should since the fx2lp is a high speed capable device | |
148 | - ) | |
158 | + and it should since the fx2lp is a high speed capable device) | |
149 | 159 | enable both USBRESET and HISPEED interrupts and |
150 | 160 | call this function to switch the descriptors |
151 | 161 | **/ |
152 | 162 | void handle_hispeed(); |
163 | +#endif // OLD_HISPEED | |
153 | 164 | |
154 | 165 | #endif |
@@ -30,13 +30,12 @@ | ||
30 | 30 | |
31 | 31 | uint8_t alternate = 0; |
32 | 32 | |
33 | -BOOL handle_get_interface(BYTE ifc, BYTE* alt_ifc) | |
33 | +uint8_t handle_get_interface(uint8_t ifc) | |
34 | 34 | { |
35 | - if (ifc==0) { | |
36 | - *alt_ifc = alternate; | |
37 | - return TRUE; | |
38 | - } | |
39 | - return FALSE; | |
35 | + if (ifc != 0) | |
36 | + return ALT_INVALID; // If the interface specified does not exist, then the device responds with a Request Error. | |
37 | + | |
38 | + return alternate; | |
40 | 39 | } |
41 | 40 | |
42 | 41 | BYTE handle_get_configuration(void) |
@@ -63,7 +62,9 @@ | ||
63 | 62 | } |
64 | 63 | |
65 | 64 | void hispeed_isr() interrupt { |
65 | +#ifdef OLD_HISPEED | |
66 | 66 | handle_hispeed(); |
67 | +#endif | |
67 | 68 | CLEAR_HISPEED(); |
68 | 69 | } |
69 | 70 |
@@ -363,7 +363,7 @@ | ||
363 | 363 | OED = 0; |
364 | 364 | |
365 | 365 | // renumerate |
366 | - RENUMERATE(); | |
366 | + USBCS|=bmDISCON|bmRENUM;delay(1500);USBCS &= ~bmDISCON; | |
367 | 367 | |
368 | 368 | // set 0 wait cycles on data memory access (MOVX) |
369 | 369 | CKCON = CKCON_MD_0; |
@@ -262,18 +262,15 @@ | ||
262 | 262 | return FALSE; |
263 | 263 | } |
264 | 264 | |
265 | -BOOL handle_get_interface(uint8_t ifc, uint8_t * alt_ifc) | |
265 | +uint8_t handle_get_interface(uint8_t ifc) | |
266 | 266 | { |
267 | 267 | if (usb_config == USB_CFG_OFF) |
268 | - return FALSE; // Address state: A Request Error response is given by the device. | |
268 | + return ALT_INVALID; // Address state: A Request Error response is given by the device. | |
269 | 269 | |
270 | - switch (ifc) { | |
271 | - case USB_IFC_ID: | |
272 | - *alt_ifc = usb_ifc0_alt; | |
273 | - return TRUE; | |
274 | - } | |
270 | + if (ifc != USB_IFC_ID) | |
271 | + return ALT_INVALID; // If the interface specified does not exist, then the device responds with a Request Error. | |
275 | 272 | |
276 | - return FALSE; // If the interface specified does not exist, then the device responds with a Request Error. | |
273 | + return usb_ifc0_alt; | |
277 | 274 | } |
278 | 275 | |
279 | 276 | BOOL handle_set_interface(uint8_t ifc, uint8_t alt_ifc) |