2 * Copyright (C) 2009 Ubixum, Inc.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 #include <fx2macros.h>
24 #include <autovector.h>
30 #define SYNCDELAY() SYNCDELAY4
32 #define REARM() EP2BCL=REARMVAL
45 REVCTL=0; // not using advanced endpoint controls
71 // only valid endpoints are 2/6
72 EP2CFG = 0xA2; // 10100010
74 EP6CFG = 0xE2; // 11100010
78 EP1OUTCFG &= ~bmVALID;
87 EP2BCL = 0x80; // write once
89 EP2BCL = 0x80; // do it again
92 // make it so we enumberate
95 EA=1; // global interrupt enable
96 printf ( "Done initializing stuff\n" );
104 printf ( "Handle setupdata\n" );
109 if ( !(EP2468STAT & bmEP2EMPTY) ) {
110 printf ( "ep2 out received data\n" );
111 if ( !(EP2468STAT & bmEP6FULL) ) { // wait for at least one empty in buffer
113 printf ( "Sending data to ep6 in\n");
115 bytes = MAKEWORD(EP2BCH,EP2BCL);
117 for (i=0;i<bytes;++i) EP6FIFOBUF[i] = EP2FIFOBUF[i];
119 // can copy whole string w/ autoptr instead.
120 // or copy directly from one buf to another
128 //printf ( "Re-Armed ep2\n" );
136 // copied routines from setupdat.h
138 // value (low byte) = ep
139 #define VC_EPSTAT 0xB1
141 BOOL handle_vendorcommand(BYTE cmd) {
147 xdata BYTE* pep= ep_addr(SETUPDAT[2]);
148 printf ( "ep %02x\n" , *pep );
157 printf ( "Need to implement vendor command: %02x\n", cmd );
162 // this firmware only supports 0,0
163 BOOL handle_get_interface(BYTE ifc, BYTE* alt_ifc) {
164 printf ( "Get Interface\n" );
165 if (ifc==0) {*alt_ifc=0; return TRUE;} else { return FALSE;}
167 BOOL handle_set_interface(BYTE ifc, BYTE alt_ifc) {
168 printf ( "Set interface %d to alt: %d\n" , ifc, alt_ifc );
170 if (ifc==0&&alt_ifc==0) {
175 // restore endpoints to default condition
187 // get/set configuration
188 BYTE handle_get_configuration() {
191 BOOL handle_set_configuration(BYTE cfg) {
192 return cfg==1 ? TRUE : FALSE; // we only handle cfg 1
196 // copied usb jt routines from usbjt.h
197 void sudav_isr() interrupt SUDAV_ISR {
205 void sof_isr () interrupt SOF_ISR using 1 {
207 if(sofct==8000) { // about 8000 sof interrupts per second at high speed
209 if (on5) {d5on();} else {d5off();}
215 void usbreset_isr() interrupt USBRESET_ISR {
216 handle_hispeed(FALSE);
219 void hispeed_isr() interrupt HISPEED_ISR {
220 handle_hispeed(TRUE);