From 852f5745d538f273b84cece41167c7026dc9f0af Mon Sep 17 00:00:00 2001 From: Martin Date: Sun, 25 Feb 2024 00:17:29 +0100 Subject: [PATCH] add fx2lib lib files Signed-off-by: Martin --- .gitignore | 1 - .gitmodules | 2 +- CHANGELOG | 1 + Firmware/fx2lib/lib/.gitignore | 1 + Firmware/fx2lib/lib/Makefile | 40 ++ Firmware/fx2lib/lib/delay.c | 73 ++++ Firmware/fx2lib/lib/eputils.c | 60 +++ Firmware/fx2lib/lib/fx2.mk | 105 +++++ Firmware/fx2lib/lib/gpif.c | 182 +++++++++ Firmware/fx2lib/lib/i2c.c | 298 ++++++++++++++ Firmware/fx2lib/lib/interrupts/ep0ack_isr.c | 22 ++ Firmware/fx2lib/lib/interrupts/ep0in_isr.c | 22 ++ Firmware/fx2lib/lib/interrupts/ep0out_isr.c | 22 ++ Firmware/fx2lib/lib/interrupts/ep0ping_isr.c | 22 ++ Firmware/fx2lib/lib/interrupts/ep1in_isr.c | 22 ++ Firmware/fx2lib/lib/interrupts/ep1out_isr.c | 22 ++ Firmware/fx2lib/lib/interrupts/ep1ping_isr.c | 22 ++ Firmware/fx2lib/lib/interrupts/ep2_isr.c | 22 ++ Firmware/fx2lib/lib/interrupts/ep2ef_isr.c | 22 ++ Firmware/fx2lib/lib/interrupts/ep2ff_isr.c | 22 ++ .../fx2lib/lib/interrupts/ep2isoerr_isr.c | 22 ++ Firmware/fx2lib/lib/interrupts/ep2pf_isr.c | 22 ++ Firmware/fx2lib/lib/interrupts/ep2ping_isr.c | 22 ++ Firmware/fx2lib/lib/interrupts/ep4_isr.c | 22 ++ Firmware/fx2lib/lib/interrupts/ep4ef_isr.c | 22 ++ Firmware/fx2lib/lib/interrupts/ep4ff_isr.c | 22 ++ .../fx2lib/lib/interrupts/ep4isoerr_isr.c | 22 ++ Firmware/fx2lib/lib/interrupts/ep4pf_isr.c | 22 ++ Firmware/fx2lib/lib/interrupts/ep4ping_isr.c | 22 ++ Firmware/fx2lib/lib/interrupts/ep6_isr.c | 22 ++ Firmware/fx2lib/lib/interrupts/ep6ef_isr.c | 22 ++ Firmware/fx2lib/lib/interrupts/ep6ff_isr.c | 22 ++ .../fx2lib/lib/interrupts/ep6isoerr_isr.c | 22 ++ Firmware/fx2lib/lib/interrupts/ep6pf_isr.c | 22 ++ Firmware/fx2lib/lib/interrupts/ep6ping_isr.c | 22 ++ Firmware/fx2lib/lib/interrupts/ep8_isr.c | 22 ++ Firmware/fx2lib/lib/interrupts/ep8ef_isr.c | 22 ++ Firmware/fx2lib/lib/interrupts/ep8ff_isr.c | 22 ++ .../fx2lib/lib/interrupts/ep8isoerr_isr.c | 22 ++ Firmware/fx2lib/lib/interrupts/ep8pf_isr.c | 22 ++ Firmware/fx2lib/lib/interrupts/ep8ping_isr.c | 22 ++ Firmware/fx2lib/lib/interrupts/errlimit_isr.c | 22 ++ Firmware/fx2lib/lib/interrupts/gpifdone_isr.c | 22 ++ Firmware/fx2lib/lib/interrupts/gpifwf_isr.c | 22 ++ Firmware/fx2lib/lib/interrupts/hispeed_isr.c | 22 ++ Firmware/fx2lib/lib/interrupts/ibn_isr.c | 22 ++ Firmware/fx2lib/lib/interrupts/sof_isr.c | 22 ++ Firmware/fx2lib/lib/interrupts/spare_isr.c | 22 ++ Firmware/fx2lib/lib/interrupts/sudav_isr.c | 22 ++ Firmware/fx2lib/lib/interrupts/suspend_isr.c | 22 ++ Firmware/fx2lib/lib/interrupts/sutok_isr.c | 22 ++ Firmware/fx2lib/lib/interrupts/usbreset_isr.c | 22 ++ Firmware/fx2lib/lib/serial.c | 93 +++++ Firmware/fx2lib/lib/setupdat.c | 374 ++++++++++++++++++ Firmware/fx2lib/lib/usbav.a51 | 121 ++++++ 55 files changed, 2273 insertions(+), 2 deletions(-) create mode 100644 Firmware/fx2lib/lib/.gitignore create mode 100644 Firmware/fx2lib/lib/Makefile create mode 100644 Firmware/fx2lib/lib/delay.c create mode 100644 Firmware/fx2lib/lib/eputils.c create mode 100644 Firmware/fx2lib/lib/fx2.mk create mode 100644 Firmware/fx2lib/lib/gpif.c create mode 100644 Firmware/fx2lib/lib/i2c.c create mode 100644 Firmware/fx2lib/lib/interrupts/ep0ack_isr.c create mode 100644 Firmware/fx2lib/lib/interrupts/ep0in_isr.c create mode 100644 Firmware/fx2lib/lib/interrupts/ep0out_isr.c create mode 100644 Firmware/fx2lib/lib/interrupts/ep0ping_isr.c create mode 100644 Firmware/fx2lib/lib/interrupts/ep1in_isr.c create mode 100644 Firmware/fx2lib/lib/interrupts/ep1out_isr.c create mode 100644 Firmware/fx2lib/lib/interrupts/ep1ping_isr.c create mode 100644 Firmware/fx2lib/lib/interrupts/ep2_isr.c create mode 100644 Firmware/fx2lib/lib/interrupts/ep2ef_isr.c create mode 100644 Firmware/fx2lib/lib/interrupts/ep2ff_isr.c create mode 100644 Firmware/fx2lib/lib/interrupts/ep2isoerr_isr.c create mode 100644 Firmware/fx2lib/lib/interrupts/ep2pf_isr.c create mode 100644 Firmware/fx2lib/lib/interrupts/ep2ping_isr.c create mode 100644 Firmware/fx2lib/lib/interrupts/ep4_isr.c create mode 100644 Firmware/fx2lib/lib/interrupts/ep4ef_isr.c create mode 100644 Firmware/fx2lib/lib/interrupts/ep4ff_isr.c create mode 100644 Firmware/fx2lib/lib/interrupts/ep4isoerr_isr.c create mode 100644 Firmware/fx2lib/lib/interrupts/ep4pf_isr.c create mode 100644 Firmware/fx2lib/lib/interrupts/ep4ping_isr.c create mode 100644 Firmware/fx2lib/lib/interrupts/ep6_isr.c create mode 100644 Firmware/fx2lib/lib/interrupts/ep6ef_isr.c create mode 100644 Firmware/fx2lib/lib/interrupts/ep6ff_isr.c create mode 100644 Firmware/fx2lib/lib/interrupts/ep6isoerr_isr.c create mode 100644 Firmware/fx2lib/lib/interrupts/ep6pf_isr.c create mode 100644 Firmware/fx2lib/lib/interrupts/ep6ping_isr.c create mode 100644 Firmware/fx2lib/lib/interrupts/ep8_isr.c create mode 100644 Firmware/fx2lib/lib/interrupts/ep8ef_isr.c create mode 100644 Firmware/fx2lib/lib/interrupts/ep8ff_isr.c create mode 100644 Firmware/fx2lib/lib/interrupts/ep8isoerr_isr.c create mode 100644 Firmware/fx2lib/lib/interrupts/ep8pf_isr.c create mode 100644 Firmware/fx2lib/lib/interrupts/ep8ping_isr.c create mode 100644 Firmware/fx2lib/lib/interrupts/errlimit_isr.c create mode 100644 Firmware/fx2lib/lib/interrupts/gpifdone_isr.c create mode 100644 Firmware/fx2lib/lib/interrupts/gpifwf_isr.c create mode 100644 Firmware/fx2lib/lib/interrupts/hispeed_isr.c create mode 100644 Firmware/fx2lib/lib/interrupts/ibn_isr.c create mode 100644 Firmware/fx2lib/lib/interrupts/sof_isr.c create mode 100644 Firmware/fx2lib/lib/interrupts/spare_isr.c create mode 100644 Firmware/fx2lib/lib/interrupts/sudav_isr.c create mode 100644 Firmware/fx2lib/lib/interrupts/suspend_isr.c create mode 100644 Firmware/fx2lib/lib/interrupts/sutok_isr.c create mode 100644 Firmware/fx2lib/lib/interrupts/usbreset_isr.c create mode 100644 Firmware/fx2lib/lib/serial.c create mode 100644 Firmware/fx2lib/lib/setupdat.c create mode 100644 Firmware/fx2lib/lib/usbav.a51 diff --git a/.gitignore b/.gitignore index 5c7c4d6..4e3bb6a 100644 --- a/.gitignore +++ b/.gitignore @@ -20,7 +20,6 @@ var sdist develop-eggs .installed.cfg -lib lib64 __pycache__ diff --git a/.gitmodules b/.gitmodules index b6cd8d0..467babb 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,5 +1,5 @@ [submodule "fx2lib_update"] - path = PyHT6022/Firmware/fx2lib + path = Firmware/fx2lib url = https://github.com/Ho-Ro/fx2lib [fx2lib] branch = master diff --git a/CHANGELOG b/CHANGELOG index 73b6088..403c72e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +2024-02-24: refactoring; move firmware code out of python module [0ddab5e] 2024-02-23: rework the serial number routine [1c46ba5] 2024-02-20: Merge branch 'main' of github.com:Ho-Ro/Hantek6022API [c8cee4c] 2024-02-20: add warning to dangerous example program reset_eeprom_6022.py [d1ad1a0] diff --git a/Firmware/fx2lib/lib/.gitignore b/Firmware/fx2lib/lib/.gitignore new file mode 100644 index 0000000..08711da --- /dev/null +++ b/Firmware/fx2lib/lib/.gitignore @@ -0,0 +1 @@ +fx2.lib diff --git a/Firmware/fx2lib/lib/Makefile b/Firmware/fx2lib/lib/Makefile new file mode 100644 index 0000000..fc6b3c2 --- /dev/null +++ b/Firmware/fx2lib/lib/Makefile @@ -0,0 +1,40 @@ +# Copyright (C) 2009 Ubixum, Inc. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +AS8051?=sdas8051 +CC=sdcc +SDAR?=sdar +SOURCES = serial.c i2c.c delay.c setupdat.c gpif.c eputils.c $(wildcard interrupts/*.c) +FX2_OBJS = $(patsubst %.c,%.rel, $(SOURCES)) usbav.rel +INCLUDES = -I../include +SDCC = $(CC) -mmcs51 $(SDCCFLAGS) +LIBS = fx2.lib + +all: $(LIBS) + +$(LIBS): $(FX2_OBJS) + $(SDAR) -rc fx2.lib $? + +usbav.rel: usbav.a51 + $(AS8051) -logs usbav.a51 + +%.rel: %.c + $(SDCC) $(INCLUDES) -c $< -o $@ + +clean: + rm -f *.{asm,ihx,lnk,lst,map,mem,rel,rst,sym,adb,cdb,lib} + rm -f interrupts/*.{asm,ihx,lnk,lst,map,mem,rel,rst,sym,adb,dcb,lib} + diff --git a/Firmware/fx2lib/lib/delay.c b/Firmware/fx2lib/lib/delay.c new file mode 100644 index 0000000..3e41e19 --- /dev/null +++ b/Firmware/fx2lib/lib/delay.c @@ -0,0 +1,73 @@ +/** + * Copyright (C) 2009 Ubixum, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **/ + +#include +#include +#include + +void delay(WORD millis) { + /** + * It takes 12 crystal pulses to make 1 machine cycle (8051.com) + * ez-usb trm 1.13 + * 83.3 ns at 48mhz per instruction cycle + * (assume 166.6ns at 24mhz) + * (assume 333.3ns at 12mhz) + * ez-usb trm 12.1 + * Includes the cycles for each instruction + **/ + WORD loop_count; + volatile WORD count; // NOTE perhaps use different solutions w/ out volatile + + + // set count to the number of times we need to + // go around a loop for 1 millisecond + + // then do that loop millis times. (1000 us=1ms) + + // 48mhz: 1000 us / (17 cycles * 83.3 ns / cycle / 1000 ns/us) = 706 + // 24mhz: 353 + // 12mhz: 177 + // recalculate if the number of cycles changes + // like if you change the loop below + loop_count = CPUFREQ == CLK_12M ? 177 : + CPUFREQ == CLK_24M ? 353 : 706; + + // sdcc generated assembly + /* cycles code + ; delay.c:31: do { + 00101$: + ; delay.c:32: } while ( --count ); + 2 dec _delay_count_1_1 + 2 mov a,#0xff + 4 cjne a,_delay_count_1_1,00121$ + 2 dec (_delay_count_1_1 + 1) + 00121$: + 2 mov a,_delay_count_1_1 + 2 orl a,(_delay_count_1_1 + 1) + 3 jnz 00101$ + + Total 17 + */ + + do { + count = loop_count; + do { + } while ( --count ); + } while ( --millis ); + +} diff --git a/Firmware/fx2lib/lib/eputils.c b/Firmware/fx2lib/lib/eputils.c new file mode 100644 index 0000000..e459aee --- /dev/null +++ b/Firmware/fx2lib/lib/eputils.c @@ -0,0 +1,60 @@ +/** + * Copyright (C) 2009 Ubixum, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **/ + + + + +#include + +#include + +#ifdef DEBUG_EPUTILS +#include +#else +#define printf(...) +#endif + +void readep0( BYTE* dst, WORD len) { + WORD read = 0; // n bytes read + BYTE c,avail; + while (read < len) { + EP0BCH = 0; + // NOTE need syncdelay? + EP0BCL = 0; // re-arm ep so host can send more + while (EP0CS & bmEPBUSY); + avail = EP0BCL; // max size fits in one byte (64 bytes) + for (c=0;c +#include +#include + +#include + +#define SYNCDELAY SYNCDELAY16 // using most conservative SYNCDELAY + +void gpif_init( BYTE* wavedata, BYTE* initdata ) { + + BYTE i; + + // Registers which require a synchronization delay, see section 15.14 + // FIFORESET FIFOPINPOLAR + // INPKTEND OUTPKTEND + // EPxBCH:L REVCTL + // GPIFTCB3 GPIFTCB2 + // GPIFTCB1 GPIFTCB0 + // EPxFIFOPFH:L EPxAUTOINLENH:L + // EPxFIFOCFG EPxGPIFFLGSEL + // PINFLAGSxx EPxFIFOIRQ + // EPxFIFOIE GPIFIRQ + // GPIFIE GPIFADRH:L + // UDMACRCH:L EPxGPIFTRIG + // GPIFTRIG + + // Note: The pre-REVE EPxGPIFTCH/L register are affected, as well... + // ...these have been replaced by GPIFTC[B3:B0] registers + + // 8051 doesn't have access to waveform memories 'til + // the part is in GPIF mode. + + // IFCLKSRC=1 , FIFOs executes on internal clk source + // xMHz=1 , 48MHz internal clk rate + // IFCLKOE=0 , Don't drive IFCLK pin signal at 48MHz + // IFCLKPOL=0 , Don't invert IFCLK pin signal from internal clk + // ASYNC=1 , master samples asynchronous + // GSTATE=1 , Drive GPIF states out on PORTE[2:0], debug WF + // IFCFG[1:0]=10, FX2 in GPIF master mode IFCONFIG + IFCONFIG &= ~0x03; // turn off IFCFG[1:0] + IFCONFIG |= 0x02; // set's IFCFG[1:0] to 10 to put in GPIF master mode. + + + GPIFABORT = 0xFF; // abort any waveforms pending + + GPIFREADYCFG = initdata[ 0 ]; + GPIFCTLCFG = initdata[ 1 ]; + GPIFIDLECS = initdata[ 2 ]; + GPIFIDLECTL = initdata[ 3 ]; + GPIFWFSELECT = initdata[ 5 ]; + GPIFREADYSTAT = initdata[ 6 ]; + + // use dual autopointer feature... + AUTOPTRSETUP = 0x07; // inc both pointers, + // ...warning: this introduces pdata hole(s) + // ...at E67B (XAUTODAT1) and E67C (XAUTODAT2) + + // source + AUTOPTRH1 = MSB( (WORD)wavedata ); + AUTOPTRL1 = LSB( (WORD)wavedata ); + + // destination + AUTOPTRH2 = 0xE4; + AUTOPTRL2 = 0x00; + + // transfer + for ( i = 0x00; i < 128; i++ ) + { + EXTAUTODAT2 = EXTAUTODAT1; + } + +// Configure GPIF Address pins, output initial value, +// these instructions don't do anything on the +// smaller chips (e.g., 56 pin model only has ports a,b,d) + PORTCCFG = 0xFF; // [7:0] as alt. func. GPIFADR[7:0] + OEC = 0xFF; // and as outputs + PORTECFG |= 0x80; // [8] as alt. func. GPIFADR[8] + OEE |= 0x80; // and as output + +// ...OR... tri-state GPIFADR[8:0] pins +// PORTCCFG = 0x00; // [7:0] as port I/O +// OEC = 0x00; // and as inputs +// PORTECFG &= 0x7F; // [8] as port I/O +// OEE &= 0x7F; // and as input + +// GPIF address pins update when GPIFADRH/L written + SYNCDELAY; // + GPIFADRH = 0x00; // bits[7:1] always 0 + SYNCDELAY; // + GPIFADRL = 0x00; // point to PERIPHERAL address 0x0000 + +// set the initial flowstates to be all 0 in case flow states are not used + + FLOWSTATE = 0; + FLOWLOGIC = 0; + FLOWEQ0CTL = 0; + FLOWEQ1CTL = 0; + FLOWHOLDOFF = 0; + FLOWSTB = 0; + FLOWSTBEDGE = 0; + FLOWSTBHPERIOD = 0; +} + +void gpif_setflowstate( BYTE* flowstates, BYTE bank) { + BYTE base = 9*bank; + FLOWSTATE = flowstates[ base ]; + FLOWLOGIC = flowstates[ base+1 ]; + FLOWEQ0CTL = flowstates[ base+2 ]; + FLOWEQ1CTL = flowstates[ base+3 ]; + FLOWHOLDOFF = flowstates[ base+4 ]; + FLOWSTB = flowstates[ base+5 ]; + FLOWSTBEDGE = flowstates[ base+6 ]; + FLOWSTBHPERIOD = flowstates[ base+7 ]; +} + +void gpif_set_tc32(DWORD tc) { + GPIFTCB3 = MSB(MSW(tc)); + SYNCDELAY; + GPIFTCB2 = LSB(MSW(tc)); + SYNCDELAY; + GPIFTCB1 = MSB(LSW(tc)); + SYNCDELAY; + GPIFTCB0 = LSB(LSW(tc)); +} +void gpif_set_tc16(WORD tc) { + GPIFTCB1= MSB(tc); + SYNCDELAY; + GPIFTCB0= LSB(tc); +} + + +void gpif_single_read16( WORD* res, WORD len ){ + BYTE c; + while (!(GPIFTRIG & 0x80)); // wait done + // dummy read to trigger real read + res[0] = XGPIFSGLDATLX; + for (c=0;c // NOTE this needs deleted + +#include +#include +#include +#include + + +//#define DEBUG_I2C 1 + +#ifdef DEBUG_I2C +#define i2c_printf(...) printf(__VA_ARGS__) +#else +#define i2c_printf(...) +#endif + + +volatile __xdata BOOL cancel_i2c_trans; +#define CHECK_I2C_CANCEL() if (cancel_i2c_trans) return FALSE + +/** + * + 1. Set START=1. If BERR=1, start timer*. + 2. Write the 7-bit peripheral address and the direction bit (0 for a write) to I2DAT. + 3. Wait for DONE=1 or for timer to expire*. If BERR=1, go to step 1. + 4. If ACK=0, go to step 9. + 5. Load I2DAT with a data byte. + 6. Wait for DONE=1*. If BERR=1, go to step 1. + 7. If ACK=0, go to step 9. + 8. Repeat steps 5-7 for each byte until all bytes have been transferred. + 9. Set STOP=1. Wait for STOP = 0 before initiating another transfer. + **/ +BOOL i2c_write ( BYTE addr, WORD len, BYTE *addr_buf, WORD len2, BYTE* data_buf ) { + + WORD cur_byte; + WORD total_bytes = len+len2; // NOTE overflow error? + BYTE retry_count=2; // two tries to write address/read ack + cancel_i2c_trans=FALSE; + //BOOL wait=FALSE; // use timer if needed + + // 1. Set START=1. If BERR=1, start timer*. + step1: + CHECK_I2C_CANCEL(); + cur_byte=0; + I2CS |= bmSTART; + if ( I2CS & bmBERR ) { + i2c_printf ( "Woops.. need to do the timer\n" ); + delay(10); // way too long probably + goto step1; + } + + + // 2. Write the 7-bit peripheral address and the direction bit (0 for a write) to I2DAT. + I2DAT = addr << 1; + + // 3. Wait for DONE=1 or for timer to expire*. If BERR=1, go to step 1. + while ( !(I2CS & bmDONE) && !cancel_i2c_trans); + CHECK_I2C_CANCEL(); + if (I2CS&bmBERR) { + i2c_printf ( "bmBERR, going to step 1\n" ); + goto step1; + } + + + // 4. If ACK=0, go to step 9. + if ( !(I2CS & bmACK) ) { + I2CS |= bmSTOP; + while ( (I2CS & bmSTOP) && !cancel_i2c_trans); + CHECK_I2C_CANCEL(); + --retry_count; + if (!retry_count){ + i2c_printf ( "No ack after writing address.! Fail\n"); + return FALSE; + } + delay(10); + goto step1; + } + + // 8. Repeat steps 5-7 for each byte until all bytes have been transferred. + while ( cur_byte < total_bytes ) { + // 5. Load I2DAT with a data byte. + I2DAT = cur_byte < len ? addr_buf[cur_byte] : data_buf[cur_byte-len]; + ++cur_byte; + // 6. Wait for DONE=1*. If BERR=1, go to step 1. + while (!(I2CS&bmDONE) && !cancel_i2c_trans); CHECK_I2C_CANCEL(); + if ( I2CS&bmBERR ) { + i2c_printf ( "bmBERR on byte %d. Going to step 1\n" , cur_byte-1 ); + goto step1; + //return FALSE; + } + // 7. If ACK=0, go to step 9. + if ( !(I2CS & bmACK) ) { + I2CS |= bmSTOP; + while ( (I2CS&bmSTOP) && !cancel_i2c_trans); + i2c_printf ( "No Ack after byte %d. Fail\n", cur_byte-1 ); + return FALSE; + } + } + + + // 9. Set STOP=1. Wait for STOP = 0 before initiating another transfer. + //real step 9 + I2CS |= bmSTOP; + while ( (I2CS & bmSTOP) && !cancel_i2c_trans); + CHECK_I2C_CANCEL(); + + return TRUE; + +} + +/* + trm 13.4.4 + + 1. Set START=1. If BERR = 1, start timer*. + 2. Write the 7-bit peripheral address and the direction bit (1 for a read) to I2DAT. + 3. Wait for DONE=1 or for timer to expire*. If BERR=1, go to step 1. + 4. If ACK=0, set STOP=1 and go to step 15. + 5. Read I2DAT to initiate the first burst of nine SCL pulses to clock in the first byte from the slave. + Discard the value that was read from I2DAT. + 6. Wait for DONE=1. If BERR=1, go to step 1. + 7. Read the just-received byte of data from I2DAT. This read also initiates the next read transfer. + 8. Repeat steps 6 and 7 for each byte until ready to read the second-to-last byte. + 9. Wait for DONE=1. If BERR=1, go to step 1. + 10. Before reading the second-to-last I2DAT byte, set LASTRD=1. + 11. Read the second-to-last byte from I2DAT. With LASTRD=1, this initiates the final byte read on + the bus. + 12. Wait for DONE=1. If BERR=1, go to step 1. + 13. Set STOP=1. + 14. Read the final byte from I2DAT immediately (the next instruction) after setting the STOP bit. By + reading I2DAT while the "stop" condition is being generated, the just-received data byte will be + retrieved without initiating an extra read transaction (nine more SCL pulses) on the I²Cbus. + 15. Wait for STOP = 0 before initiating another transfer +*/ + +/* + * timer should be at least as long as longest start-stop interval on the bus + serial clock for i2c bus runs at 100khz by default and can run at 400khz for devices that support it + start-stop interval is about 9 serial clock cycles + 400KHZ bit 0=100khz, 1=400khz + + how many cycles at XTAL cycles/second = 9 cycles at 400k (or 100k) cycles/second + + timeout = n i2c cycles / I2C cycles/sec = timeout seconds + timeout seconds * XTAL cycles/sec = XTAL cycles + 9 / 400 (or 100) * (XTAL) + +*/ +BOOL i2c_read( BYTE addr, WORD len, BYTE* buf) { + + + BYTE tmp; + WORD cur_byte; + cancel_i2c_trans=FALSE; + //WORD timeout_cycles = (WORD)(9.0 * XTAL / I2CFREQ ); + + // 1. Set START=1. If BERR = 1, start timer*. + start: + CHECK_I2C_CANCEL(); + cur_byte=0; + + I2CS |= bmSTART; + if ( I2CS & bmBERR ) { + i2c_printf ( "Woops, step1 BERR, need to do timeout\n"); + delay(10); // NOTE way too long + goto start; + } + + // 2. Write the 7-bit peripheral address and the direction bit (1 for a read) to I2DAT. + I2DAT = (addr << 1) | 1; // last 1 for read + + // 3. Wait for DONE=1 or for timer to expire*. If BERR=1, go to step 1. + + while ( !(I2CS & bmDONE) && !cancel_i2c_trans ); CHECK_I2C_CANCEL(); + if ( I2CS & bmBERR ) + goto start; + + // 4. If ACK=0, set STOP=1 and go to step 15. + if (!(I2CS&bmACK) ) { + I2CS |= bmSTOP; + while ( (I2CS&bmSTOP) && !cancel_i2c_trans ); + return FALSE; + } + + // with only one byte to read, this needs set here. + // (In this case, the tmp read is the 2nd to last read) + if ( len==1 ) I2CS |= bmLASTRD; + + // 5. Read I2DAT to initiate the first burst of nine SCL pulses to clock in the first byte from the slave. + // Discard the value that was read from I2DAT. + tmp = I2DAT; // discard read + + while (len>cur_byte+1) { // reserve last byte read for after the loop + + // 6. Wait for DONE=1. If BERR=1, go to step 1. + // 9. Wait for DONE=1. If BERR=1, go to step 1. + while (!(I2CS&bmDONE) && !cancel_i2c_trans); CHECK_I2C_CANCEL(); + if ( I2CS&bmBERR ) goto start; + + // 10. Before reading the second-to-last I2DAT byte, set LASTRD=1. + if (len==cur_byte+2) // 2nd to last byte + I2CS |= bmLASTRD; + + // 7. Read the just-received byte of data from I2DAT. This read also initiates the next read transfer. + // 11. Read the second-to-last byte from I2DAT. With LASTRD=1, this initiates the final byte read on + // the bus. + buf[cur_byte++] = I2DAT; + + // 8. Repeat steps 6 and 7 for each byte until ready to read the second-to-last byte. + } + + //12. Wait for DONE=1. If BERR=1, go to step 1. + while (!(I2CS&bmDONE) && !cancel_i2c_trans); CHECK_I2C_CANCEL(); + if ( I2CS&bmBERR ) goto start; + // 13. Set STOP=1. + I2CS |= bmSTOP; + // 14. Read the final byte from I2DAT immediately (the next instruction) after setting the STOP bit. By + // reading I2DAT while the "stop" condition is being generated, the just-received data byte will be + // retrieved without initiating an extra read transaction (nine more SCL pulses) on the I²Cbus. + buf[cur_byte] = I2DAT; // use instead of buffer addressing so next instruction reads I2DAT + + while ( (I2CS&bmSTOP) && !cancel_i2c_trans); CHECK_I2C_CANCEL(); + + return TRUE; +} + + + +BOOL eeprom_write(BYTE prom_addr, WORD addr, WORD length, BYTE* buf) { + BYTE addr_len=0; + // 1st bytes of buffer are address and next byte is value + BYTE data_buffer[3]; + WORD cur_byte=0; + +#ifdef DEBUG_I2C + if ( EEPROM_TWO_BYTE ) { + i2c_printf ( "Two Byte EEProm Address detected.\n" ); + } else { + i2c_printf ( "Single Byte EEProm address detected.\n" ); + } +#endif + + while ( cur_byte + +void ep0ack_isr() __interrupt {} + diff --git a/Firmware/fx2lib/lib/interrupts/ep0in_isr.c b/Firmware/fx2lib/lib/interrupts/ep0in_isr.c new file mode 100644 index 0000000..76256a9 --- /dev/null +++ b/Firmware/fx2lib/lib/interrupts/ep0in_isr.c @@ -0,0 +1,22 @@ +/** + * Copyright (C) 2010 Ubixum, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **/ + +#include + +void ep0in_isr() __interrupt {} + diff --git a/Firmware/fx2lib/lib/interrupts/ep0out_isr.c b/Firmware/fx2lib/lib/interrupts/ep0out_isr.c new file mode 100644 index 0000000..2bea93a --- /dev/null +++ b/Firmware/fx2lib/lib/interrupts/ep0out_isr.c @@ -0,0 +1,22 @@ +/** + * Copyright (C) 2010 Ubixum, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **/ + +#include + +void ep0out_isr() __interrupt {} + diff --git a/Firmware/fx2lib/lib/interrupts/ep0ping_isr.c b/Firmware/fx2lib/lib/interrupts/ep0ping_isr.c new file mode 100644 index 0000000..af07fbf --- /dev/null +++ b/Firmware/fx2lib/lib/interrupts/ep0ping_isr.c @@ -0,0 +1,22 @@ +/** + * Copyright (C) 2010 Ubixum, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **/ + +#include + +void ep0ping_isr() __interrupt {} + diff --git a/Firmware/fx2lib/lib/interrupts/ep1in_isr.c b/Firmware/fx2lib/lib/interrupts/ep1in_isr.c new file mode 100644 index 0000000..cf89ba3 --- /dev/null +++ b/Firmware/fx2lib/lib/interrupts/ep1in_isr.c @@ -0,0 +1,22 @@ +/** + * Copyright (C) 2010 Ubixum, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **/ + +#include + +void ep1in_isr() __interrupt {} + diff --git a/Firmware/fx2lib/lib/interrupts/ep1out_isr.c b/Firmware/fx2lib/lib/interrupts/ep1out_isr.c new file mode 100644 index 0000000..af2c0e9 --- /dev/null +++ b/Firmware/fx2lib/lib/interrupts/ep1out_isr.c @@ -0,0 +1,22 @@ +/** + * Copyright (C) 2010 Ubixum, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **/ + +#include + +void ep1out_isr() __interrupt {} + diff --git a/Firmware/fx2lib/lib/interrupts/ep1ping_isr.c b/Firmware/fx2lib/lib/interrupts/ep1ping_isr.c new file mode 100644 index 0000000..22bad45 --- /dev/null +++ b/Firmware/fx2lib/lib/interrupts/ep1ping_isr.c @@ -0,0 +1,22 @@ +/** + * Copyright (C) 2010 Ubixum, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **/ + +#include + +void ep1ping_isr() __interrupt {} + diff --git a/Firmware/fx2lib/lib/interrupts/ep2_isr.c b/Firmware/fx2lib/lib/interrupts/ep2_isr.c new file mode 100644 index 0000000..9699247 --- /dev/null +++ b/Firmware/fx2lib/lib/interrupts/ep2_isr.c @@ -0,0 +1,22 @@ +/** + * Copyright (C) 2010 Ubixum, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **/ + +#include + +void ep2_isr() __interrupt {} + diff --git a/Firmware/fx2lib/lib/interrupts/ep2ef_isr.c b/Firmware/fx2lib/lib/interrupts/ep2ef_isr.c new file mode 100644 index 0000000..387f52c --- /dev/null +++ b/Firmware/fx2lib/lib/interrupts/ep2ef_isr.c @@ -0,0 +1,22 @@ +/** + * Copyright (C) 2010 Ubixum, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **/ + +#include + +void ep2ef_isr() __interrupt {} + diff --git a/Firmware/fx2lib/lib/interrupts/ep2ff_isr.c b/Firmware/fx2lib/lib/interrupts/ep2ff_isr.c new file mode 100644 index 0000000..3520bb5 --- /dev/null +++ b/Firmware/fx2lib/lib/interrupts/ep2ff_isr.c @@ -0,0 +1,22 @@ +/** + * Copyright (C) 2010 Ubixum, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **/ + +#include + +void ep2ff_isr() __interrupt {} + diff --git a/Firmware/fx2lib/lib/interrupts/ep2isoerr_isr.c b/Firmware/fx2lib/lib/interrupts/ep2isoerr_isr.c new file mode 100644 index 0000000..f6d8194 --- /dev/null +++ b/Firmware/fx2lib/lib/interrupts/ep2isoerr_isr.c @@ -0,0 +1,22 @@ +/** + * Copyright (C) 2010 Ubixum, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **/ + +#include + +void ep2isoerr_isr() __interrupt {} + diff --git a/Firmware/fx2lib/lib/interrupts/ep2pf_isr.c b/Firmware/fx2lib/lib/interrupts/ep2pf_isr.c new file mode 100644 index 0000000..1228cdc --- /dev/null +++ b/Firmware/fx2lib/lib/interrupts/ep2pf_isr.c @@ -0,0 +1,22 @@ +/** + * Copyright (C) 2010 Ubixum, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **/ + +#include + +void ep2pf_isr() __interrupt {} + diff --git a/Firmware/fx2lib/lib/interrupts/ep2ping_isr.c b/Firmware/fx2lib/lib/interrupts/ep2ping_isr.c new file mode 100644 index 0000000..b9d424a --- /dev/null +++ b/Firmware/fx2lib/lib/interrupts/ep2ping_isr.c @@ -0,0 +1,22 @@ +/** + * Copyright (C) 2010 Ubixum, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **/ + +#include + +void ep2ping_isr() __interrupt {} + diff --git a/Firmware/fx2lib/lib/interrupts/ep4_isr.c b/Firmware/fx2lib/lib/interrupts/ep4_isr.c new file mode 100644 index 0000000..a71aa49 --- /dev/null +++ b/Firmware/fx2lib/lib/interrupts/ep4_isr.c @@ -0,0 +1,22 @@ +/** + * Copyright (C) 2010 Ubixum, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **/ + +#include + +void ep4_isr() __interrupt {} + diff --git a/Firmware/fx2lib/lib/interrupts/ep4ef_isr.c b/Firmware/fx2lib/lib/interrupts/ep4ef_isr.c new file mode 100644 index 0000000..275d49c --- /dev/null +++ b/Firmware/fx2lib/lib/interrupts/ep4ef_isr.c @@ -0,0 +1,22 @@ +/** + * Copyright (C) 2010 Ubixum, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **/ + +#include + +void ep4ef_isr() __interrupt {} + diff --git a/Firmware/fx2lib/lib/interrupts/ep4ff_isr.c b/Firmware/fx2lib/lib/interrupts/ep4ff_isr.c new file mode 100644 index 0000000..15edd6c --- /dev/null +++ b/Firmware/fx2lib/lib/interrupts/ep4ff_isr.c @@ -0,0 +1,22 @@ +/** + * Copyright (C) 2010 Ubixum, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **/ + +#include + +void ep4ff_isr() __interrupt {} + diff --git a/Firmware/fx2lib/lib/interrupts/ep4isoerr_isr.c b/Firmware/fx2lib/lib/interrupts/ep4isoerr_isr.c new file mode 100644 index 0000000..9fdb4fa --- /dev/null +++ b/Firmware/fx2lib/lib/interrupts/ep4isoerr_isr.c @@ -0,0 +1,22 @@ +/** + * Copyright (C) 2010 Ubixum, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **/ + +#include + +void ep4isoerr_isr() __interrupt {} + diff --git a/Firmware/fx2lib/lib/interrupts/ep4pf_isr.c b/Firmware/fx2lib/lib/interrupts/ep4pf_isr.c new file mode 100644 index 0000000..c2d0258 --- /dev/null +++ b/Firmware/fx2lib/lib/interrupts/ep4pf_isr.c @@ -0,0 +1,22 @@ +/** + * Copyright (C) 2010 Ubixum, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **/ + +#include + +void ep4pf_isr() __interrupt {} + diff --git a/Firmware/fx2lib/lib/interrupts/ep4ping_isr.c b/Firmware/fx2lib/lib/interrupts/ep4ping_isr.c new file mode 100644 index 0000000..254b38c --- /dev/null +++ b/Firmware/fx2lib/lib/interrupts/ep4ping_isr.c @@ -0,0 +1,22 @@ +/** + * Copyright (C) 2010 Ubixum, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **/ + +#include + +void ep4ping_isr() __interrupt {} + diff --git a/Firmware/fx2lib/lib/interrupts/ep6_isr.c b/Firmware/fx2lib/lib/interrupts/ep6_isr.c new file mode 100644 index 0000000..f0edc9c --- /dev/null +++ b/Firmware/fx2lib/lib/interrupts/ep6_isr.c @@ -0,0 +1,22 @@ +/** + * Copyright (C) 2010 Ubixum, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **/ + +#include + +void ep6_isr() __interrupt {} + diff --git a/Firmware/fx2lib/lib/interrupts/ep6ef_isr.c b/Firmware/fx2lib/lib/interrupts/ep6ef_isr.c new file mode 100644 index 0000000..4eb75ed --- /dev/null +++ b/Firmware/fx2lib/lib/interrupts/ep6ef_isr.c @@ -0,0 +1,22 @@ +/** + * Copyright (C) 2010 Ubixum, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **/ + +#include + +void ep6ef_isr() __interrupt {} + diff --git a/Firmware/fx2lib/lib/interrupts/ep6ff_isr.c b/Firmware/fx2lib/lib/interrupts/ep6ff_isr.c new file mode 100644 index 0000000..cb73645 --- /dev/null +++ b/Firmware/fx2lib/lib/interrupts/ep6ff_isr.c @@ -0,0 +1,22 @@ +/** + * Copyright (C) 2010 Ubixum, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **/ + +#include + +void ep6ff_isr() __interrupt {} + diff --git a/Firmware/fx2lib/lib/interrupts/ep6isoerr_isr.c b/Firmware/fx2lib/lib/interrupts/ep6isoerr_isr.c new file mode 100644 index 0000000..3d720a8 --- /dev/null +++ b/Firmware/fx2lib/lib/interrupts/ep6isoerr_isr.c @@ -0,0 +1,22 @@ +/** + * Copyright (C) 2010 Ubixum, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **/ + +#include + +void ep6isoerr_isr() __interrupt {} + diff --git a/Firmware/fx2lib/lib/interrupts/ep6pf_isr.c b/Firmware/fx2lib/lib/interrupts/ep6pf_isr.c new file mode 100644 index 0000000..59fbc6d --- /dev/null +++ b/Firmware/fx2lib/lib/interrupts/ep6pf_isr.c @@ -0,0 +1,22 @@ +/** + * Copyright (C) 2010 Ubixum, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **/ + +#include + +void ep6pf_isr() __interrupt {} + diff --git a/Firmware/fx2lib/lib/interrupts/ep6ping_isr.c b/Firmware/fx2lib/lib/interrupts/ep6ping_isr.c new file mode 100644 index 0000000..2e4dd6a --- /dev/null +++ b/Firmware/fx2lib/lib/interrupts/ep6ping_isr.c @@ -0,0 +1,22 @@ +/** + * Copyright (C) 2010 Ubixum, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **/ + +#include + +void ep6ping_isr() __interrupt {} + diff --git a/Firmware/fx2lib/lib/interrupts/ep8_isr.c b/Firmware/fx2lib/lib/interrupts/ep8_isr.c new file mode 100644 index 0000000..473f255 --- /dev/null +++ b/Firmware/fx2lib/lib/interrupts/ep8_isr.c @@ -0,0 +1,22 @@ +/** + * Copyright (C) 2010 Ubixum, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **/ + +#include + +void ep8_isr() __interrupt {} + diff --git a/Firmware/fx2lib/lib/interrupts/ep8ef_isr.c b/Firmware/fx2lib/lib/interrupts/ep8ef_isr.c new file mode 100644 index 0000000..542bbec --- /dev/null +++ b/Firmware/fx2lib/lib/interrupts/ep8ef_isr.c @@ -0,0 +1,22 @@ +/** + * Copyright (C) 2010 Ubixum, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **/ + +#include + +void ep8ef_isr() __interrupt {} + diff --git a/Firmware/fx2lib/lib/interrupts/ep8ff_isr.c b/Firmware/fx2lib/lib/interrupts/ep8ff_isr.c new file mode 100644 index 0000000..32541af --- /dev/null +++ b/Firmware/fx2lib/lib/interrupts/ep8ff_isr.c @@ -0,0 +1,22 @@ +/** + * Copyright (C) 2010 Ubixum, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **/ + +#include + +void ep8ff_isr() __interrupt {} + diff --git a/Firmware/fx2lib/lib/interrupts/ep8isoerr_isr.c b/Firmware/fx2lib/lib/interrupts/ep8isoerr_isr.c new file mode 100644 index 0000000..e103ab7 --- /dev/null +++ b/Firmware/fx2lib/lib/interrupts/ep8isoerr_isr.c @@ -0,0 +1,22 @@ +/** + * Copyright (C) 2010 Ubixum, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **/ + +#include + +void ep8isoerr_isr() __interrupt {} + diff --git a/Firmware/fx2lib/lib/interrupts/ep8pf_isr.c b/Firmware/fx2lib/lib/interrupts/ep8pf_isr.c new file mode 100644 index 0000000..4ef7ba1 --- /dev/null +++ b/Firmware/fx2lib/lib/interrupts/ep8pf_isr.c @@ -0,0 +1,22 @@ +/** + * Copyright (C) 2010 Ubixum, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **/ + +#include + +void ep8pf_isr() __interrupt {} + diff --git a/Firmware/fx2lib/lib/interrupts/ep8ping_isr.c b/Firmware/fx2lib/lib/interrupts/ep8ping_isr.c new file mode 100644 index 0000000..642221a --- /dev/null +++ b/Firmware/fx2lib/lib/interrupts/ep8ping_isr.c @@ -0,0 +1,22 @@ +/** + * Copyright (C) 2010 Ubixum, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **/ + +#include + +void ep8ping_isr() __interrupt {} + diff --git a/Firmware/fx2lib/lib/interrupts/errlimit_isr.c b/Firmware/fx2lib/lib/interrupts/errlimit_isr.c new file mode 100644 index 0000000..07608bb --- /dev/null +++ b/Firmware/fx2lib/lib/interrupts/errlimit_isr.c @@ -0,0 +1,22 @@ +/** + * Copyright (C) 2010 Ubixum, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **/ + +#include + +void errlimit_isr() __interrupt {} + diff --git a/Firmware/fx2lib/lib/interrupts/gpifdone_isr.c b/Firmware/fx2lib/lib/interrupts/gpifdone_isr.c new file mode 100644 index 0000000..ccda60a --- /dev/null +++ b/Firmware/fx2lib/lib/interrupts/gpifdone_isr.c @@ -0,0 +1,22 @@ +/** + * Copyright (C) 2010 Ubixum, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **/ + +#include + +void gpifdone_isr() __interrupt {} + diff --git a/Firmware/fx2lib/lib/interrupts/gpifwf_isr.c b/Firmware/fx2lib/lib/interrupts/gpifwf_isr.c new file mode 100644 index 0000000..417f4a1 --- /dev/null +++ b/Firmware/fx2lib/lib/interrupts/gpifwf_isr.c @@ -0,0 +1,22 @@ +/** + * Copyright (C) 2010 Ubixum, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **/ + +#include + +void gpifwf_isr() __interrupt {} + diff --git a/Firmware/fx2lib/lib/interrupts/hispeed_isr.c b/Firmware/fx2lib/lib/interrupts/hispeed_isr.c new file mode 100644 index 0000000..ca05990 --- /dev/null +++ b/Firmware/fx2lib/lib/interrupts/hispeed_isr.c @@ -0,0 +1,22 @@ +/** + * Copyright (C) 2010 Ubixum, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **/ + +#include + +void hispeed_isr()__interrupt {} + diff --git a/Firmware/fx2lib/lib/interrupts/ibn_isr.c b/Firmware/fx2lib/lib/interrupts/ibn_isr.c new file mode 100644 index 0000000..0c196fd --- /dev/null +++ b/Firmware/fx2lib/lib/interrupts/ibn_isr.c @@ -0,0 +1,22 @@ +/** + * Copyright (C) 2010 Ubixum, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **/ + +#include + +void ibn_isr() __interrupt {} + diff --git a/Firmware/fx2lib/lib/interrupts/sof_isr.c b/Firmware/fx2lib/lib/interrupts/sof_isr.c new file mode 100644 index 0000000..ea34f60 --- /dev/null +++ b/Firmware/fx2lib/lib/interrupts/sof_isr.c @@ -0,0 +1,22 @@ +/** + * Copyright (C) 2010 Ubixum, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **/ + +#include + +void sof_isr() __interrupt {} + diff --git a/Firmware/fx2lib/lib/interrupts/spare_isr.c b/Firmware/fx2lib/lib/interrupts/spare_isr.c new file mode 100644 index 0000000..06cc7f1 --- /dev/null +++ b/Firmware/fx2lib/lib/interrupts/spare_isr.c @@ -0,0 +1,22 @@ +/** + * Copyright (C) 2010 Ubixum, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **/ + +#include + +void spare_isr() __interrupt {} + diff --git a/Firmware/fx2lib/lib/interrupts/sudav_isr.c b/Firmware/fx2lib/lib/interrupts/sudav_isr.c new file mode 100644 index 0000000..13e69da --- /dev/null +++ b/Firmware/fx2lib/lib/interrupts/sudav_isr.c @@ -0,0 +1,22 @@ +/** + * Copyright (C) 2010 Ubixum, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **/ + +#include + +void sudav_isr() __interrupt {} + diff --git a/Firmware/fx2lib/lib/interrupts/suspend_isr.c b/Firmware/fx2lib/lib/interrupts/suspend_isr.c new file mode 100644 index 0000000..98cadbb --- /dev/null +++ b/Firmware/fx2lib/lib/interrupts/suspend_isr.c @@ -0,0 +1,22 @@ +/** + * Copyright (C) 2010 Ubixum, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **/ + +#include + +void suspend_isr() __interrupt {} + diff --git a/Firmware/fx2lib/lib/interrupts/sutok_isr.c b/Firmware/fx2lib/lib/interrupts/sutok_isr.c new file mode 100644 index 0000000..5f141ce --- /dev/null +++ b/Firmware/fx2lib/lib/interrupts/sutok_isr.c @@ -0,0 +1,22 @@ +/** + * Copyright (C) 2010 Ubixum, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **/ + +#include + +void sutok_isr() __interrupt {} + diff --git a/Firmware/fx2lib/lib/interrupts/usbreset_isr.c b/Firmware/fx2lib/lib/interrupts/usbreset_isr.c new file mode 100644 index 0000000..b8d3bfb --- /dev/null +++ b/Firmware/fx2lib/lib/interrupts/usbreset_isr.c @@ -0,0 +1,22 @@ +/** + * Copyright (C) 2010 Ubixum, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **/ + +#include + +void usbreset_isr() __interrupt {} + diff --git a/Firmware/fx2lib/lib/serial.c b/Firmware/fx2lib/lib/serial.c new file mode 100644 index 0000000..fbda8e5 --- /dev/null +++ b/Firmware/fx2lib/lib/serial.c @@ -0,0 +1,93 @@ +/** + * Copyright (C) 2009 Ubixum, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **/ + + +#include +#include +#include + + +/** + * using the comp port implies that timer 2 will be used as + * a baud rate generator. (Don't use timer 2) + **/ +void sio0_init( DWORD baud_rate ) __critical { // baud_rate max should be 57600 since int=2 bytes + + WORD hl; // hl value for reload + BYTE mult; // multiplier for clock speed + DWORD tmp; // scratch for mult/divide + + // 0 = 12mhz, 1=24mhz, 2=48mhz + mult = CPUFREQ == CLK_12M ? 1 : + CPUFREQ == CLK_24M ? 2 : 4; // since only 3 clock speeds, fast switch instead of doing 2^clock speed pow(2,clkspd) + + // set the clock rate + // use clock 2 + RCLK=1;TCLK=1; + +// RCAP2H:L = 0xFFFF - CLKOUT / 32 x baud_rate + + // in order to round to nearest value.. + // tmp * 2 // double + // tmp / rate // do the divide + // tmp + 1 // add one (which is like adding 1/2) + // tmp / 2 // back to original rounded + tmp = mult * 375000L * 2 ; + tmp /= baud_rate; + tmp += 1; + tmp /= 2; + + hl = 0xFFFF - (WORD)tmp; + + RCAP2H= MSB(hl); + // seems that the 24/48mhz calculations are always one less than suggested values + // trm table 14-16 + RCAP2L= LSB(hl) + (mult>0?1:0); + TR2=1; // start the timer + + // set up the serial port + SM0 = 0; SM1=1;// serial mode 1 (asyncronous) + SM2 = 0 ; // has to do with receiving + REN = 1 ; // to enable receiving + PCON |= 0x80; // SET SMOD0, baud rate doubler + TI = 1; // we send initial byte + +} + +int getchar() { // compatible with sdcc header + char c; + while (!RI) + ; + c=SBUF0; + RI=0; + return c; +} + +void _transchar(char c) { + while ( !TI ); // wait for TI=1 + TI=0; + SBUF0=c; +} + +int putchar (char c) { // compatible with sdcc header + if (c=='\n') _transchar('\r'); // transmit \r\n + _transchar(c); + if (c == '\r' ) _transchar('\n'); // transmit \r\n + return c; +} + diff --git a/Firmware/fx2lib/lib/setupdat.c b/Firmware/fx2lib/lib/setupdat.c new file mode 100644 index 0000000..19a0698 --- /dev/null +++ b/Firmware/fx2lib/lib/setupdat.c @@ -0,0 +1,374 @@ +/** + * Copyright (C) 2009 Ubixum, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + **/ + +//#define DEBUG_SETUPDAT + +#ifdef DEBUG_SETUPDAT +#include // NOTE this needs deleted +#else +#define printf(...) +#define NULL (void*)0; +#endif + +#include +#include +#include +#include + + +extern BOOL handle_get_descriptor(); +extern BOOL handle_vendorcommand(BYTE cmd); +extern BOOL handle_set_configuration(BYTE cfg); +extern BOOL handle_get_interface(BYTE ifc, BYTE* alt_ifc); +extern BOOL handle_set_interface(BYTE ifc,BYTE alt_ifc); +extern BYTE handle_get_configuration(); +extern void handle_reset_ep(BYTE ep); + +/** + * Predefs for handlers + **/ + + +// GET_STATUS, +BOOL handle_get_status(); +// CLEAR_FEATURE, +BOOL handle_clear_feature(); + // 0x02 is reserved +// SET_FEATURE=0x03, +BOOL handle_set_feature(); + // 0x04 is reserved +// SET_ADDRESS=0x05, // this is handled by EZ-USB core unless RENUM=0 +// GET_DESCRIPTOR, +void _handle_get_descriptor(); +// SET_DESCRIPTOR, +// GET_CONFIGURATION, // handled by callback +// SET_CONFIGURATION, // handled by callback +// GET_INTERFACE, // handled by callback +// SET_INTERFACE, // handled by callback +// SYNC_FRAME // not yet implemented + +/* + TRM 2.2 + Setup Token -> + data transfer -> + handshake +*/ + +void handle_setupdata() { + //printf ( "Handle setupdat: %02x\n", SETUPDAT[1] ); + + switch ( SETUPDAT[1] ) { + + case GET_STATUS: + if (!handle_get_status()) + STALLEP0(); + break; + case CLEAR_FEATURE: + if (!handle_clear_feature()) { + STALLEP0(); + } + break; + case SET_FEATURE: + if (!handle_set_feature()) { + STALLEP0(); + } + break; + case GET_DESCRIPTOR: + if (!handle_get_descriptor()) + _handle_get_descriptor(); + break; + case GET_CONFIGURATION: + EP0BUF[0] = handle_get_configuration(); + EP0BCH=0; + EP0BCL=1; + break; + case SET_CONFIGURATION: + // user callback + if( !handle_set_configuration(SETUPDAT[2])) { + STALLEP0(); + } + break; + case GET_INTERFACE: + { + BYTE alt_ifc; + if (!handle_get_interface(SETUPDAT[4],&alt_ifc)) { + STALLEP0(); + } else { + EP0BUF[0] = alt_ifc; + EP0BCH=0; + EP0BCL=1; + } + } + break; + case SET_INTERFACE: + // user callback + if ( !handle_set_interface(SETUPDAT[4],SETUPDAT[2])) { + STALLEP0(); + } + break; + default: + if (!handle_vendorcommand(SETUPDAT[1])) { + printf ( "Unhandled Vendor Command: %02x\n" , SETUPDAT[1] ); + STALLEP0(); + } + + + } + + // do the handshake + EP0CS |= bmHSNAK; + +} + +__xdata BYTE* ep_addr(BYTE ep) { // bit 8 of ep_num is the direction + BYTE ep_num = ep&~0x80; // mask the direction + switch (ep_num) { + case 0: return &EP0CS; + case 1: return ep&0x80? &EP1INCS : &EP1OUTCS; + case 2: return &EP2CS; + case 4: return &EP4CS; + case 6: return &EP6CS; + case 8: return &EP8CS; + default: return NULL; + } +} + + +// Get status has three request types +#define GS_DEVICE 0x80 +#define GS_INTERFACE 0x81 +#define GS_ENDPOINT 0x82 + + +volatile BOOL self_powered=FALSE; +volatile BOOL remote_wakeup_allowed=FALSE; + +BOOL handle_get_status() { + + switch ( SETUPDAT[0] ) { + +// case 0: // sometimes we get a 0 status too + case GS_INTERFACE: + EP0BUF[0] = 0; + EP0BUF[1] = 0; + EP0BCH=0; + EP0BCL=2; + break; + case GS_DEVICE: + + // two byte response + // byte 0 bit 0 = self powered bit 1 = remote wakeup + EP0BUF[0] = (remote_wakeup_allowed << 1) | self_powered; + // byte 1 = 0 + EP0BUF[1] = 0; + EP0BCH = 0; + EP0BCL = 2; + break; + case GS_ENDPOINT: + { + __xdata BYTE* pep=ep_addr(SETUPDAT[4]); + if ( !pep ) return FALSE; + // byte 0 bit 0 = stall bit + EP0BUF[0] = *pep & bmEPSTALL ? 1 : 0; + EP0BUF[1] = 0; + EP0BCH=0; + EP0BCL=2; + } + break; + default: + printf ( "Unexpected Get Status: %02x\n", SETUPDAT[0] ); + return FALSE; + + + } + return TRUE; +} + + +#define GF_DEVICE 0 +#define GF_ENDPOINT 2 + +BOOL handle_clear_feature() { + //printf ( "Clear Feature\n" ); + switch ( SETUPDAT[0] ) { + case GF_DEVICE: + if (SETUPDAT[2] == 1) { + remote_wakeup_allowed=FALSE; + break; + } + + if (SETUPDAT[2] == 6) // debug feature + break; + return FALSE; + case GF_ENDPOINT: + if (SETUPDAT[2] == 0) { // ep stall feature + __xdata BYTE* pep=ep_addr(SETUPDAT[4]); + printf ( "unstall endpoint %02X\n" , SETUPDAT[4] ); + *pep &= ~bmEPSTALL; + RESETTOGGLE(SETUPDAT[4]); + } else { + printf ( "unsupported ep feature %02x", SETUPDAT[2] ); + return FALSE; + } + + break; + default: + return handle_vendorcommand(SETUPDAT[1]); + } + return TRUE; +} + +BOOL handle_set_feature() { + printf ( "Set Feature %02x\n", SETUPDAT[0] ); + switch ( SETUPDAT[0] ) { + case GF_DEVICE: + if (SETUPDAT[2] == 2) break; // this is TEST_MODE and we simply need to return the handshake + if (SETUPDAT[2] == 1) { + remote_wakeup_allowed=TRUE; + break; + } + if (SETUPDAT[2] == 6) // debug feature + break; + return FALSE; + case GF_ENDPOINT: + if ( SETUPDAT[2] == 0 ) { // ep stall feature + // set TRM 2.3.2 + // stall and endpoint + __xdata BYTE* pep = ep_addr(SETUPDAT[4]); + printf ( "Stall ep %d\n", SETUPDAT[4] ); + if (!pep) { + return FALSE; + } + + *pep |= bmEPSTALL; + // should now reset data toggles + // write ep+dir to TOGCTL + RESETTOGGLE(SETUPDAT[4]); + // restore stalled ep to default condition + // NOTE + //handle_reset_ep(SETUPDAT[4]); + + } else { + printf ( "unsupported ep feature %02x\n", SETUPDAT[2] ); + return FALSE; + } + break; + default: + return handle_vendorcommand(SETUPDAT[1]); + } + return TRUE; +} + +/* these are devined in dscr.asm + and need to be customized then + linked in by the firmware manually */ +extern __code WORD dev_dscr; +extern __code WORD dev_qual_dscr; +extern __code WORD highspd_dscr; +extern __code WORD fullspd_dscr; +extern __code WORD dev_strings; + +WORD pDevConfig = (WORD)&fullspd_dscr; +WORD pOtherConfig = (WORD)&highspd_dscr; + +void handle_hispeed(BOOL highspeed) { + __critical { + printf ( "Hi Speed or reset Interrupt\n" ); + if (highspeed) { + pDevConfig=(WORD)&highspd_dscr; + pOtherConfig=(WORD)&fullspd_dscr; + } else { + pDevConfig=(WORD)&fullspd_dscr; + pOtherConfig=(WORD)&highspd_dscr; + } + } +} + +/** + * Handle: + * Device Descriptor + * Device Qualifier + * Configuration + * String + * Other-Speed + **/ +void _handle_get_descriptor() { + //printf ( "Get Descriptor\n" ); + + switch ( SETUPDAT[3] ) { + case DSCR_DEVICE_TYPE: + printf ( "Get Device Config\n" ); + SUDPTRH = MSB((WORD)&dev_dscr); + SUDPTRL = LSB((WORD)&dev_dscr); + break; + case DSCR_CONFIG_TYPE: + // get the config descriptor + printf ( "Get Config Descriptor\n"); + SUDPTRH = MSB(pDevConfig); + SUDPTRL = LSB(pDevConfig); + break; + case DSCR_STRING_TYPE: + //printf ( "Get String Descriptor idx: %d\n", SETUPDAT[2] ); + { + STRING_DSCR* pStr = (STRING_DSCR*)&dev_strings; + // pStr points to string 0 + BYTE idx = SETUPDAT[2]; + BYTE cur=0; // current check + do { + if (idx==cur++) break; + //printf ( "Length of pStr: %d\n", pStr->dsc_len ); + //printf ( "pstr: %04x to ", pStr ); + pStr = (STRING_DSCR*)((BYTE*)pStr + pStr->dsc_len); + //printf ( "%04x\n" , pStr ); + if (pStr->dsc_type != DSCR_STRING_TYPE) pStr=NULL; + } while ( pStr && cur<=idx); + + if (pStr) { + /* BYTE i; + //printf ( "found str: '"); + for (i=0;idsc_len-2;++i) { + printf ( i%2==0?"%c":"%02x", *((BYTE*)(&pStr->pstr)+i)); + } printf ( "\n"); */ + + SUDPTRH = MSB((WORD)pStr); + SUDPTRL = LSB((WORD)pStr); + //SUDPTRH = MSB((WORD)&dev_strings); + //SUDPTRL = LSB((WORD)&dev_strings); + } else {STALLEP0();} + + } + + break; + case DSCR_DEVQUAL_TYPE: + printf ( "Get Device Qualifier Descriptor\n"); + // assumes this is a high speed capable device + SUDPTRH = MSB((WORD)&dev_qual_dscr); + SUDPTRL = LSB((WORD)&dev_qual_dscr); + break; + case DSCR_OTHERSPD_TYPE: + printf ( "Other Speed Descriptor\n"); + SUDPTRH = MSB(pOtherConfig); + SUDPTRL = LSB(pOtherConfig); + break; + default: + printf ( "Unhandled Get Descriptor: %02x\n", SETUPDAT[3]); + STALLEP0(); + } + +} + diff --git a/Firmware/fx2lib/lib/usbav.a51 b/Firmware/fx2lib/lib/usbav.a51 new file mode 100644 index 0000000..a73dc9f --- /dev/null +++ b/Firmware/fx2lib/lib/usbav.a51 @@ -0,0 +1,121 @@ +; Copyright (C) 2010 Ubixum, Inc. +; +; This library is free software; you can redistribute it and/or +; modify it under the terms of the GNU Lesser General Public +; License as published by the Free Software Foundation; either +; version 2.1 of the License, or (at your option) any later version. +; +; This library is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +; Lesser General Public License for more details. +; +; You should have received a copy of the GNU Lesser General Public +; License along with this library; if not, write to the Free Software +; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +.module INT2AV ; jump table for usb auto vector + +; INT2 Jump Table +.globl _usb_isr ; define jump target for interrupt 8 (USB) +.globl _gpif_isr ; define jump target for interrupt 10 (GPIF) + +.area INT2JT ( CODE ) +;.org 0x1A00 ; needs to be on a page boundary + +_gpif_isr: +_usb_isr: + ljmp _sudav_isr + .db 0 + ljmp _sof_isr + .db 0 + ljmp _sutok_isr + .db 0 + ljmp _suspend_isr + .db 0 + ljmp _usbreset_isr + .db 0 + ljmp _hispeed_isr + .db 0 + ljmp _ep0ack_isr + .db 0 + ljmp _spare_isr + .db 0 + ljmp _ep0in_isr + .db 0 + ljmp _ep0out_isr + .db 0 + ljmp _ep1in_isr + .db 0 + ljmp _ep1out_isr + .db 0 + ljmp _ep2_isr + .db 0 + ljmp _ep4_isr + .db 0 + ljmp _ep6_isr + .db 0 + ljmp _ep8_isr + .db 0 + ljmp _ibn_isr + .db 0 + ljmp _spare_isr + .db 0 + ljmp _ep0ping_isr + .db 0 + ljmp _ep1ping_isr + .db 0 + ljmp _ep2ping_isr + .db 0 + ljmp _ep4ping_isr + .db 0 + ljmp _ep6ping_isr + .db 0 + ljmp _ep8ping_isr + .db 0 + ljmp _errlimit_isr + .db 0 + ljmp _spare_isr + .db 0 + ljmp _spare_isr + .db 0 + ljmp _spare_isr + .db 0 + ljmp _ep2isoerr_isr + .db 0 + ljmp _ep4isoerr_isr + .db 0 + ljmp _ep6isoerr_isr + .db 0 + ljmp _ep8isoerr_isr + .db 0 +; INT4JT + ljmp _ep2pf_isr + .db 0 + ljmp _ep4pf_isr + .db 0 + ljmp _ep6pf_isr + .db 0 + ljmp _ep8pf_isr + .db 0 + ljmp _ep2ef_isr + .db 0 + ljmp _ep4ef_isr + .db 0 + ljmp _ep6ef_isr + .db 0 + ljmp _ep8ef_isr + .db 0 + ljmp _ep2ff_isr + .db 0 + ljmp _ep4ff_isr + .db 0 + ljmp _ep6ff_isr + .db 0 + ljmp _ep8ff_isr + .db 0 + ljmp _gpifdone_isr + .db 0 + ljmp _gpifwf_isr + .db 0 +