]>
Commit | Line | Data |
---|---|---|
3608c106 UH |
1 | // Copyright (C) 2009 Ubixum, Inc. |
2 | // | |
3 | // This library is free software; you can redistribute it and/or | |
4 | // modify it under the terms of the GNU Lesser General Public | |
5 | // License as published by the Free Software Foundation; either | |
6 | // version 2.1 of the License, or (at your option) any later version. | |
7 | // | |
8 | // This library is distributed in the hope that it will be useful, | |
9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
11 | // Lesser General Public License for more details. | |
12 | // | |
13 | // You should have received a copy of the GNU Lesser General Public | |
14 | // License along with this library; if not, write to the Free Software | |
15 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
16 | ||
17 | /*! \file | |
18 | * Functions and macros for working with endpoints. | |
19 | * */ | |
20 | ||
21 | #ifndef EPUTILS_H | |
22 | #define EPUTILS_H | |
23 | ||
24 | #include "fx2types.h" | |
25 | ||
26 | /** | |
27 | * NOTE you can't use these unless you define SYNCDELAY | |
28 | * as a macro or function. The reason is that SYNCDELAY | |
29 | * needs to be longer or shorter depending on your IFCONFIG | |
30 | * settings. | |
31 | * See delay.h | |
32 | * | |
33 | * Example: | |
34 | * \code | |
35 | * #define SYNCDELAY() SYNCDELAY4 // SYNCDELAY4 from delay.h | |
36 | * \endcode | |
37 | * | |
38 | * | |
39 | **/ | |
40 | ||
41 | /** | |
42 | * Stalls EP0. | |
43 | **/ | |
44 | #define STALLEP0() EP0CS |= bmEPSTALL | |
45 | ||
46 | /** | |
47 | * \brief Reset the toggle on an endpoint. | |
48 | * To use this, the endpoint needs bit 8 to be IN=1,OUT=0 | |
49 | **/ | |
50 | #define RESETTOGGLE(ep) TOGCTL = (ep&0x0F) + ((ep&0x80)>>3); TOGCTL |= bmRESETTOGGLE | |
51 | ||
52 | ||
53 | /** | |
54 | * RESETFIFO should not use 0x80|epnum for IN endpoints | |
55 | * Only use 0x02, 0x04, 0x06, 0x06 for ep value | |
56 | **/ | |
57 | #define RESETFIFO(ep) {FIFORESET=0x80; SYNCDELAY();\ | |
58 | FIFORESET=ep; SYNCDELAY();\ | |
59 | FIFORESET=0x00; SYNCDELAY();} | |
60 | /** | |
61 | * Quickly reset all endpoint FIFOS. | |
62 | **/ | |
63 | #define RESETFIFOS() {FIFORESET=0x80; SYNCDELAY();\ | |
64 | FIFORESET=0x02; SYNCDELAY();\ | |
65 | FIFORESET=0x04; SYNCDELAY();\ | |
66 | FIFORESET=0x06; SYNCDELAY();\ | |
67 | FIFORESET=0x08; SYNCDELAY();\ | |
68 | FIFORESET=0x00; SYNCDELAY();} | |
69 | ||
70 | /** | |
71 | * Continually read available bytes from endpoint0 into dst, wait | |
72 | * until more bytes are available, and loop until len bytes have | |
73 | * been read. | |
74 | **/ | |
75 | void readep0( BYTE* dst, WORD len ); | |
76 | ||
77 | ||
78 | /** | |
79 | * Write bytes from src to ep0, allowing host to transfer data | |
80 | * between 64 byte blocks. | |
81 | **/ | |
82 | void writeep0 ( BYTE* src, WORD len ); | |
83 | ||
84 | ||
85 | ||
86 | #endif |