1 // Copyright (C) 2009 Ubixum, Inc.
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.
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.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, see <http://www.gnu.org/licenses/>.
17 * Functions and macros for working with endpoints.
26 * NOTE you can't use these unless you define SYNCDELAY
27 * as a macro or function. The reason is that SYNCDELAY
28 * needs to be longer or shorter depending on your IFCONFIG
34 * #define SYNCDELAY() SYNCDELAY4 // SYNCDELAY4 from delay.h
43 #define STALLEP0() EP0CS |= bmEPSTALL
46 * \brief Reset the toggle on an endpoint.
47 * To use this, the endpoint needs bit 8 to be IN=1,OUT=0
49 #define RESETTOGGLE(ep) TOGCTL = (ep&0x0F) + ((ep&0x80)>>3); TOGCTL |= bmRESETTOGGLE
53 * RESETFIFO should not use 0x80|epnum for IN endpoints
54 * Only use 0x02, 0x04, 0x06, 0x06 for ep value
56 #define RESETFIFO(ep) {FIFORESET=0x80; SYNCDELAY();\
57 FIFORESET=ep; SYNCDELAY();\
58 FIFORESET=0x00; SYNCDELAY();}
60 * Quickly reset all endpoint FIFOS.
62 #define RESETFIFOS() {FIFORESET=0x80; SYNCDELAY();\
63 FIFORESET=0x02; SYNCDELAY();\
64 FIFORESET=0x04; SYNCDELAY();\
65 FIFORESET=0x06; SYNCDELAY();\
66 FIFORESET=0x08; SYNCDELAY();\
67 FIFORESET=0x00; SYNCDELAY();}
70 * Continually read available bytes from endpoint0 into dst, wait
71 * until more bytes are available, and loop until len bytes have
74 void readep0( BYTE* dst, WORD len );
78 * Write bytes from src to ep0, allowing host to transfer data
79 * between 64 byte blocks.
81 void writeep0 ( BYTE* src, WORD len );