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, write to the Free Software
15 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 * Functions and macros for working with endpoints.
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
35 * #define SYNCDELAY() SYNCDELAY4 // SYNCDELAY4 from delay.h
44 #define STALLEP0() EP0CS |= bmEPSTALL
47 * \brief Reset the toggle on an endpoint.
48 * To use this, the endpoint needs bit 8 to be IN=1,OUT=0
50 #define RESETTOGGLE(ep) TOGCTL = (ep&0x0F) + ((ep&0x80)>>3); TOGCTL |= bmRESETTOGGLE
54 * RESETFIFO should not use 0x80|epnum for IN endpoints
55 * Only use 0x02, 0x04, 0x06, 0x06 for ep value
57 #define RESETFIFO(ep) {FIFORESET=0x80; SYNCDELAY();\
58 FIFORESET=ep; SYNCDELAY();\
59 FIFORESET=0x00; SYNCDELAY();}
61 * Quickly reset all endpoint FIFOS.
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();}
71 * Continually read available bytes from endpoint0 into dst, wait
72 * until more bytes are available, and loop until len bytes have
75 void readep0( BYTE* dst, WORD len );
79 * Write bytes from src to ep0, allowing host to transfer data
80 * between 64 byte blocks.
82 void writeep0 ( BYTE* src, WORD len );