├── hw ├── schematic.pdf ├── usbavrfloppy.pro ├── usbavrfloppy.lib └── usbavrfloppy.sch ├── .gitignore ├── amigafloppy ├── Makefile └── src │ ├── adf.h │ ├── opt.h │ ├── dev.h │ ├── adf.c │ ├── serial.h │ ├── main.c │ ├── unix │ └── serial.c │ ├── opt.c │ └── dev.c ├── fw ├── Makefile └── src │ └── avrfloppy.c ├── README.md ├── LICENSE.hw └── LICENSE.sw /hw/schematic.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jtsiomb/usbamigafloppy/HEAD/hw/schematic.pdf -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.d 3 | *.swp 4 | amigafloppy/amigafloppy 5 | fw/avrfloppy 6 | *.eep 7 | *.hex 8 | *.map 9 | *-cache.lib 10 | *.kicad_pcb-bak 11 | *.net 12 | *.dcm 13 | *.bak 14 | -------------------------------------------------------------------------------- /amigafloppy/Makefile: -------------------------------------------------------------------------------- 1 | PREFIX = /usr/local 2 | 3 | src = $(wildcard src/*.c) $(wildcard src/unix/*.c) 4 | obj = $(src:.c=.o) 5 | dep = $(obj:.o=.d) 6 | bin = amigafloppy 7 | 8 | CFLAGS = -pedantic -Wall -g -Isrc 9 | 10 | $(bin): $(obj) 11 | $(CC) -o $@ $(obj) $(LDFLAGS) 12 | 13 | -include $(dep) 14 | 15 | %.d: %.c 16 | @$(CPP) $(CFLAGS) $< -MM -MT $(@:.d=.o) >$@ 17 | 18 | .PHONY: clean 19 | clean: 20 | rm -f $(obj) $(bin) 21 | 22 | .PHONY: cleandep 23 | cleandep: 24 | rm -f $(dep) 25 | -------------------------------------------------------------------------------- /amigafloppy/src/adf.h: -------------------------------------------------------------------------------- 1 | /* 2 | amigafloppy - driver for the USB floppy controller for amiga disks 3 | Copyright (C) 2018 John Tsiombikas 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | #ifndef ADF_H_ 19 | #define ADF_H_ 20 | 21 | int adf_open(const char *fname); 22 | void adf_close(void); 23 | 24 | int adf_write_track(void *trackbuf); 25 | 26 | #endif /* ADF_H_ */ 27 | -------------------------------------------------------------------------------- /amigafloppy/src/opt.h: -------------------------------------------------------------------------------- 1 | /* 2 | amigafloppy - driver for the USB floppy controller for amiga disks 3 | Copyright (C) 2018 John Tsiombikas 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | #ifndef OPT_H_ 19 | #define OPT_H_ 20 | 21 | struct options { 22 | char *fname; 23 | char *devfile; 24 | int verify; 25 | int write_disk; 26 | int verbose; 27 | int retries; 28 | } opt; 29 | 30 | int init_options(int argc, char **argv); 31 | 32 | #endif /* OPT_H_ */ 33 | -------------------------------------------------------------------------------- /fw/Makefile: -------------------------------------------------------------------------------- 1 | src = $(wildcard src/*.c) 2 | obj = $(src:.c=.o) 3 | bin = avrfloppy 4 | hex = $(bin).hex 5 | eep = $(bin).eep 6 | 7 | mcu_gcc = atmega88 8 | mcu_dude = m88 9 | mcu_minipro = ATMEGA88A 10 | 11 | CC = avr-gcc 12 | OBJCOPY = avr-objcopy 13 | 14 | CFLAGS = -Os -pedantic -Wall -mmcu=$(mcu_gcc) -DF_CPU=16000000 15 | LDFLAGS = -Wl,-Map,$(bin).map -mmcu=$(mcu_gcc) 16 | 17 | .PHONY: all 18 | all: $(hex) $(eep) 19 | 20 | $(bin): $(obj) 21 | $(CC) -o $@ $(obj) $(LDFLAGS) 22 | 23 | $(hex): $(bin) 24 | $(OBJCOPY) -j .text -j .data -O ihex -R .eeprom $< $@ 25 | 26 | $(eep): $(bin) 27 | $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O ihex $< $@ 28 | 29 | .PHONY: fuses 30 | fuses: 31 | avrdude -c usbtiny -p $(mcu_dude) -U lfuse:w:0xe6:m -U hfuse:w:0xdf:m -U efuse:w:0xf9:m 32 | 33 | .PHONY: program 34 | program: $(hex) 35 | avrdude -c usbtiny -p $(mcu_dude) -e -U flash:w:$(hex) 36 | 37 | .PHONY: burn 38 | burn: 39 | minipro -p $(mcu_minipro) -s -w $(hex) 40 | 41 | .PHONY: burnfuses 42 | burnfuses: 43 | echo 'fuses_lo = 0x00e6' >/tmp/fuses 44 | echo 'fuses_hi = 0x00df' >>/tmp/fuses 45 | echo 'fuses_ext = 0x00f9' >>/tmp/fuses 46 | echo 'lock_byte = 0x00ff' >>/tmp/fuses 47 | minipro -p $(mcu_minipro) -e -c config -w /tmp/fuses 48 | 49 | .PHONY: clean 50 | clean: 51 | rm -f $(bin) $(obj) $(hex) $(eep) $(bin).map 52 | -------------------------------------------------------------------------------- /amigafloppy/src/dev.h: -------------------------------------------------------------------------------- 1 | /* 2 | amigafloppy - driver for the USB floppy controller for amiga disks 3 | Copyright (C) 2018 John Tsiombikas 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | #ifndef DEV_H_ 19 | #define DEV_H_ 20 | 21 | int init_device(const char *devname); 22 | void shutdown_device(void); 23 | 24 | /* returns non-zero for success, zero for failure, and -1 on comm. error */ 25 | int wait_response(void); 26 | 27 | int get_fw_version(int *major, int *minor); 28 | 29 | int begin_read(void); 30 | int begin_write(void); 31 | int end_access(void); 32 | 33 | int select_head(int s); 34 | int move_head(int track); 35 | 36 | int read_track(unsigned char *buf); 37 | 38 | #endif /* DEV_H_ */ 39 | -------------------------------------------------------------------------------- /amigafloppy/src/adf.c: -------------------------------------------------------------------------------- 1 | /* 2 | amigafloppy - driver for the USB floppy controller for amiga disks 3 | Copyright (C) 2018 John Tsiombikas 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | #include 19 | #include 20 | #include 21 | #include "adf.h" 22 | 23 | static FILE *fp; 24 | 25 | int adf_open(const char *fname) 26 | { 27 | if(fp) return -1; 28 | 29 | if(!(fp = fopen(fname, "wb"))) { 30 | fprintf(stderr, "failed to open %s for writing: %s\n", fname, strerror(errno)); 31 | return -1; 32 | } 33 | 34 | return 0; 35 | } 36 | 37 | void adf_close(void) 38 | { 39 | if(fp) { 40 | fclose(fp); 41 | fp = 0; 42 | } 43 | } 44 | 45 | int adf_write_track(void *trackbuf) 46 | { 47 | if(!fp) return -1; 48 | return fwrite(trackbuf, 512, 11, fp) == 11 ? 0 : -1; 49 | } 50 | -------------------------------------------------------------------------------- /amigafloppy/src/serial.h: -------------------------------------------------------------------------------- 1 | /* 2 | amigafloppy - driver for the USB floppy controller for amiga disks 3 | Copyright (C) 2018 John Tsiombikas 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | #ifndef SERIAL_H_ 19 | #define SERIAL_H_ 20 | 21 | #define SER_8N1 0 22 | #define SER_8N2 1 23 | #define SER_HWFLOW 2 24 | 25 | int ser_open(const char *port, int baud, unsigned int mode); 26 | void ser_close(int fd); 27 | 28 | int ser_block(int fd); 29 | int ser_nonblock(int fd); 30 | 31 | int ser_pending(int fd); 32 | /* if msec < 0: wait for ever */ 33 | int ser_wait(int fd, long msec); 34 | 35 | int ser_write(int fd, const void *buf, int count); 36 | int ser_read(int fd, void *buf, int count); 37 | 38 | void ser_printf(int fd, const char *fmt, ...); 39 | char *ser_getline(int fd, char *buf, int bsz); 40 | 41 | #endif /* SERIAL_H_ */ 42 | -------------------------------------------------------------------------------- /hw/usbavrfloppy.pro: -------------------------------------------------------------------------------- 1 | update=Wed 28 Feb 2018 11:39:57 PM EET 2 | version=1 3 | last_client=kicad 4 | [pcbnew] 5 | version=1 6 | LastNetListRead= 7 | UseCmpFile=1 8 | PadDrill=0.600000000000 9 | PadDrillOvalY=0.600000000000 10 | PadSizeH=1.500000000000 11 | PadSizeV=1.500000000000 12 | PcbTextSizeV=1.500000000000 13 | PcbTextSizeH=1.500000000000 14 | PcbTextThickness=0.300000000000 15 | ModuleTextSizeV=1.000000000000 16 | ModuleTextSizeH=1.000000000000 17 | ModuleTextSizeThickness=0.150000000000 18 | SolderMaskClearance=0.000000000000 19 | SolderMaskMinWidth=0.000000000000 20 | DrawSegmentWidth=0.200000000000 21 | BoardOutlineThickness=0.100000000000 22 | ModuleOutlineThickness=0.150000000000 23 | [cvpcb] 24 | version=1 25 | NetIExt=net 26 | [general] 27 | version=1 28 | [eeschema] 29 | version=1 30 | LibDir=../usbavrfloppy 31 | [eeschema/libraries] 32 | LibName1=power 33 | LibName2=device 34 | LibName3=transistors 35 | LibName4=conn 36 | LibName5=linear 37 | LibName6=regul 38 | LibName7=74xx 39 | LibName8=cmos4000 40 | LibName9=adc-dac 41 | LibName10=memory 42 | LibName11=xilinx 43 | LibName12=microcontrollers 44 | LibName13=dsp 45 | LibName14=microchip 46 | LibName15=analog_switches 47 | LibName16=motorola 48 | LibName17=texas 49 | LibName18=intel 50 | LibName19=audio 51 | LibName20=interface 52 | LibName21=digital-audio 53 | LibName22=philips 54 | LibName23=display 55 | LibName24=cypress 56 | LibName25=siliconi 57 | LibName26=opto 58 | LibName27=atmel 59 | LibName28=contrib 60 | LibName29=valves 61 | LibName30=ftdi 62 | LibName31=usbavrfloppy 63 | LibName32=switches 64 | -------------------------------------------------------------------------------- /hw/usbavrfloppy.lib: -------------------------------------------------------------------------------- 1 | EESchema-LIBRARY Version 2.3 2 | #encoding utf-8 3 | # 4 | # floppy_conn 5 | # 6 | DEF floppy_conn J 0 1 Y Y 1 F N 7 | F0 "J" 0 900 50 H V C CNN 8 | F1 "floppy_conn" 0 0 50 V V C CNN 9 | F2 "" 0 -1100 50 H I C CNN 10 | F3 "" 0 -1100 50 H I C CNN 11 | $FPLIST 12 | Pin_Header_Straight_2X* 13 | Pin_Header_Angled_2X* 14 | Socket_Strip_Straight_2X* 15 | Socket_Strip_Angled_2X* 16 | IDC_Header_Straight_* 17 | $ENDFPLIST 18 | DRAW 19 | S -300 850 300 -850 0 1 0 N 20 | X GND 1 -450 800 150 R 50 50 1 1 P 21 | X ~REDWC 2 450 800 150 L 50 50 1 1 P 22 | X GND 3 -450 700 150 R 50 50 1 1 P 23 | X NC 4 450 700 150 L 50 50 1 1 N N 24 | X GND 5 -450 600 150 R 50 50 1 1 P 25 | X NC 6 450 600 150 L 50 50 1 1 N N 26 | X GND 7 -450 500 150 R 50 50 1 1 P 27 | X ~INDEX 8 450 500 150 L 50 50 1 1 P 28 | X GND 9 -450 400 150 R 50 50 1 1 P 29 | X ~MOTEA 10 450 400 150 L 50 50 1 1 P 30 | X ~STEP 20 450 -100 150 L 50 50 1 1 P 31 | X ~RDATA 30 450 -600 150 L 50 50 1 1 P 32 | X GND 11 -450 300 150 R 50 50 1 1 P 33 | X GND 21 -450 -200 150 R 50 50 1 1 P 34 | X GND 31 -450 -700 150 R 50 50 1 1 P 35 | X ~DRVSB 12 450 300 150 L 50 50 1 1 P 36 | X ~WDATA 22 450 -200 150 L 50 50 1 1 P 37 | X ~SIDE1 32 450 -700 150 L 50 50 1 1 P 38 | X GND 13 -450 200 150 R 50 50 1 1 P 39 | X GND 23 -450 -300 150 R 50 50 1 1 P 40 | X GND 33 -450 -800 150 R 50 50 1 1 P 41 | X ~DRVSA 14 450 200 150 L 50 50 1 1 P 42 | X ~WGATE 24 450 -300 150 L 50 50 1 1 P 43 | X ~DRDY 34 450 -800 150 L 50 50 1 1 P 44 | X GND 15 -450 100 150 R 50 50 1 1 P 45 | X GND 25 -450 -400 150 R 50 50 1 1 P 46 | X ~MOTEB 16 450 100 150 L 50 50 1 1 P 47 | X ~TRK0 26 450 -400 150 L 50 50 1 1 P 48 | X GND 17 -450 0 150 R 50 50 1 1 P 49 | X GND 27 -450 -500 150 R 50 50 1 1 P 50 | X ~DIR 18 450 0 150 L 50 50 1 1 P 51 | X ~WPROT 28 450 -500 150 L 50 50 1 1 P 52 | X GND 19 -450 -100 150 R 50 50 1 1 P 53 | X GND 29 -450 -600 150 R 50 50 1 1 P 54 | ENDDRAW 55 | ENDDEF 56 | # 57 | #End Library 58 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | USB floppy controller for Amiga disks 2 | ===================================== 3 | 4 | This is a USB floppy disk controller, for reading and writing amiga disks. In 5 | conjunction with the accompanying `amigafloppy` program, it allows archiving 6 | amiga disks as ADF disk images, or writing ADF disk images back to disks, to use 7 | with an Amiga computer. 8 | 9 | The firmware for this controller is based on the ArduinoFloppyDiskReader 10 | project by Rob Smith (https://github.com/RobSmithDev/ArduinoFloppyDiskReader), 11 | converted to run on standalone AVR hardware (as opposed to an arduino) by John 12 | Tsiombikas. 13 | 14 | The new AVR hardware is designed to be compatible with the original host 15 | software, so you may use the `AmigaFloppyReader` or `AmigaFloppyReaderWin` 16 | programs from Rob's project, if you prefer. 17 | 18 | Directory structure: 19 | 20 | * `hw` - hardware: kicad files and pdf schematics. 21 | * `fw` - firmware for the AVR microcontroller. 22 | * `amigafloppy` - host program for reading/writing ADF images. 23 | 24 | Note: The `amigafloppy` host program is not completed yet. And it's not a high 25 | priority, since Rob's original .NET programs seem to work fine with wine on 26 | GNU/Linux. I'd like to complete it at some stage, but I can't say when that will 27 | happen. Contributions are of course welcome, but please coordinate with me 28 | first. Until then, please use `AmigaFloppyReader` or `AmigaFloppyReaderWin`. 29 | 30 | Hardware License 31 | ---------------- 32 | Copyright (C) 2018 John Tsiombikas 33 | 34 | The hardware of this project is released as free/open hardware under the 35 | Creative Commons Attribution Share-Alike license. See `LICENSE.hw` for details. 36 | 37 | Firmware License 38 | ---------------- 39 | Copyright (C) 2017 Rob Smith 40 | 41 | Copyright (C) 2018 John Tsiombikas 42 | 43 | The microcontroller firmware of this project is released as free software, 44 | under the terms of the GNU General Public License v3, or later. See 45 | `LICENSE.sw` for details. 46 | 47 | Software License 48 | ---------------- 49 | Copyright (C) 2018 John Tsiombikas 50 | 51 | The host software (amigafloppy tool) is released as free software, under the 52 | terms of the GNU General Public License v3, or later. See `LICENSE.sw` for 53 | details. 54 | -------------------------------------------------------------------------------- /amigafloppy/src/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | amigafloppy - driver for the USB floppy controller for amiga disks 3 | Copyright (C) 2018 John Tsiombikas 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | #include 19 | #include 20 | #include "dev.h" 21 | #include "opt.h" 22 | #include "adf.h" 23 | 24 | #define TRACK_SIZE (0x1900 * 2 + 0x440) 25 | #define NUM_TRACKS 80 26 | 27 | static void print_progress(int cyl, int head); 28 | 29 | int main(int argc, char **argv) 30 | { 31 | int i, j, num_tries, res, status = 1; 32 | unsigned char buf[TRACK_SIZE]; 33 | 34 | if(init_options(argc, argv) == -1) { 35 | return 1; 36 | } 37 | 38 | if(init_device(opt.devfile) == -1) { 39 | return 1; 40 | } 41 | 42 | if(adf_open(opt.fname) == -1) { 43 | shutdown_device(); 44 | return 1; 45 | } 46 | 47 | begin_read(); 48 | for(i=0; i 0); 55 | if(res == -1) { 56 | fprintf(stderr, "failed to read track %d side %d\n", i, j); 57 | goto done; 58 | } 59 | 60 | if(adf_write_track(buf) == -1) { 61 | fprintf(stderr, "failed to write track %d side %d to ADF image\n", i, j); 62 | goto done; 63 | } 64 | if(opt.verbose) { 65 | print_progress(i, j); 66 | } 67 | } 68 | } 69 | putchar('\n'); 70 | status = 0; 71 | 72 | done: 73 | end_access(); 74 | adf_close(); 75 | shutdown_device(); 76 | if(status != 0) { 77 | remove(opt.fname); 78 | } 79 | return status; 80 | } 81 | 82 | static void print_progress(int cyl, int head) 83 | { 84 | int i, p, count; 85 | 86 | p = ((cyl << 1) | head) * 100 / ((NUM_TRACKS - 1) * 2); 87 | count = p / 2; 88 | 89 | printf("Reading (C:%02d H:%d) [", cyl, head); 90 | 91 | for(i=0; i<50; i++) { 92 | if(i < count || count == 50) { 93 | putchar('='); 94 | } else if(i == count) { 95 | putchar('>'); 96 | } else { 97 | putchar(' '); 98 | } 99 | } 100 | 101 | printf("] %d%% \r", p); 102 | fflush(stdout); 103 | } 104 | -------------------------------------------------------------------------------- /amigafloppy/src/unix/serial.c: -------------------------------------------------------------------------------- 1 | /* 2 | amigafloppy - driver for the USB floppy controller for amiga disks 3 | Copyright (C) 2018 John Tsiombikas 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include "serial.h" 29 | 30 | static int baud_id(int baud); 31 | 32 | int ser_open(const char *port, int baud, unsigned int mode) 33 | { 34 | int fd; 35 | struct termios term; 36 | 37 | if((baud = baud_id(baud)) == -1) { 38 | fprintf(stderr, "ser_open: invalid baud number: %d\n", baud); 39 | return -1; 40 | } 41 | 42 | if((fd = open(port, O_RDWR | O_NOCTTY)) == -1) { 43 | fprintf(stderr, "ser_open: failed to open device: %s: %s\n", port, strerror(errno)); 44 | return -1; 45 | } 46 | 47 | tcgetattr(fd, &term); 48 | 49 | term.c_oflag = 0; 50 | term.c_lflag = 0; 51 | term.c_cc[VMIN] = 0; 52 | term.c_cc[VTIME] = 0; 53 | 54 | term.c_cflag = CLOCAL | CREAD | CS8 | HUPCL; 55 | if(mode & SER_8N2) { 56 | term.c_cflag |= CSTOPB; 57 | } 58 | if(mode & SER_HWFLOW) { 59 | term.c_cflag |= CRTSCTS; 60 | } 61 | 62 | term.c_iflag = IGNBRK | IGNPAR; 63 | 64 | cfsetispeed(&term, baud); 65 | cfsetospeed(&term, baud); 66 | 67 | if(tcsetattr(fd, TCSANOW, &term) < 0) { 68 | fprintf(stderr, "ser_open: failed to set terminal attributes\n"); 69 | close(fd); 70 | return -1; 71 | } 72 | 73 | #ifdef TIOCM_RTS 74 | /* assert DTR/RTS lines */ 75 | { 76 | int st; 77 | if(ioctl(fd, TIOCMGET, &st) == -1) { 78 | perror("ser_open: failed to get modem status"); 79 | close(fd); 80 | return -1; 81 | } 82 | st |= TIOCM_DTR | TIOCM_RTS; 83 | if(ioctl(fd, TIOCMSET, &st) == -1) { 84 | perror("ser_open: failed to set flow control"); 85 | close(fd); 86 | return -1; 87 | } 88 | } 89 | #endif 90 | 91 | return fd; 92 | } 93 | 94 | void ser_close(int fd) 95 | { 96 | close(fd); 97 | } 98 | 99 | int ser_block(int fd) 100 | { 101 | return fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) & ~O_NONBLOCK); 102 | } 103 | 104 | int ser_nonblock(int fd) 105 | { 106 | return fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_NONBLOCK); 107 | } 108 | 109 | int ser_pending(int fd) 110 | { 111 | static struct timeval tv_zero; 112 | fd_set rd; 113 | 114 | FD_ZERO(&rd); 115 | FD_SET(fd, &rd); 116 | 117 | while(select(fd + 1, &rd, 0, 0, &tv_zero) == -1 && errno == EINTR); 118 | return FD_ISSET(fd, &rd); 119 | } 120 | 121 | int ser_wait(int fd, long msec) 122 | { 123 | struct timeval tv, tv0; 124 | fd_set rd; 125 | 126 | FD_ZERO(&rd); 127 | FD_SET(fd, &rd); 128 | 129 | tv.tv_sec = msec / 1000; 130 | tv.tv_usec = msec * 1000; 131 | 132 | gettimeofday(&tv0, 0); 133 | 134 | while(select(fd + 1, &rd, 0, 0, msec >= 0 ? &tv : 0) == -1 && errno == EINTR) { 135 | /* interrupted, recalc timeout and go back to sleep */ 136 | if(msec >= 0) { 137 | gettimeofday(&tv, 0); 138 | msec -= (tv.tv_sec - tv0.tv_sec) * 1000 + (tv.tv_usec - tv0.tv_usec) / 1000; 139 | if(msec < 0) msec = 0; 140 | 141 | tv.tv_sec = msec / 1000; 142 | tv.tv_usec = msec * 1000; 143 | } 144 | } 145 | 146 | return FD_ISSET(fd, &rd); 147 | } 148 | 149 | int ser_write(int fd, const void *buf, int count) 150 | { 151 | return write(fd, buf, count); 152 | } 153 | 154 | int ser_read(int fd, void *buf, int count) 155 | { 156 | return read(fd, buf, count); 157 | } 158 | 159 | void ser_printf(int fd, const char *fmt, ...) 160 | { 161 | va_list ap; 162 | 163 | va_start(ap, fmt); 164 | vdprintf(fd, fmt, ap); 165 | va_end(ap); 166 | } 167 | 168 | char *ser_getline(int fd, char *buf, int bsz) 169 | { 170 | static char linebuf[512]; 171 | static int widx; 172 | int i, rd, size, offs; 173 | 174 | size = sizeof linebuf - widx; 175 | while(size && (rd = read(fd, linebuf + widx, size)) > 0) { 176 | widx += rd; 177 | size -= rd; 178 | } 179 | 180 | linebuf[widx] = 0; 181 | 182 | for(i=0; i= bsz ? bsz - 1 : i; 185 | memcpy(buf, linebuf, size); 186 | buf[size] = 0; 187 | 188 | offs = i + 1; 189 | memmove(linebuf, linebuf + offs, widx - offs); 190 | widx -= offs; 191 | return buf; 192 | } 193 | } 194 | return 0; 195 | } 196 | 197 | static int baud_id(int baud) 198 | { 199 | switch(baud) { 200 | case 50: return B50; 201 | case 75: return B75; 202 | case 110: return B110; 203 | case 134: return B134; 204 | case 150: return B150; 205 | case 200: return B200; 206 | case 300: return B300; 207 | case 600: return B600; 208 | case 1200: return B1200; 209 | case 1800: return B1800; 210 | case 2400: return B2400; 211 | case 4800: return B4800; 212 | case 9600: return B9600; 213 | case 19200: return B19200; 214 | case 38400: return B38400; 215 | case 57600: return B57600; 216 | case 115200: return B115200; 217 | case 1000000: return B1000000; 218 | case 2000000: return B2000000; 219 | default: 220 | break; 221 | } 222 | return -1; 223 | } 224 | -------------------------------------------------------------------------------- /amigafloppy/src/opt.c: -------------------------------------------------------------------------------- 1 | /* 2 | amigafloppy - driver for the USB floppy controller for amiga disks 3 | Copyright (C) 2018 John Tsiombikas 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include "opt.h" 26 | 27 | static void print_usage(const char *argv0); 28 | static int load_config(void); 29 | static char *skip_wspace(char *s); 30 | static char *cleanstr(char *s); 31 | static int strbool(char *s); 32 | 33 | #ifndef WIN32 34 | #define DEVFILE_FMT "/dev/ttyUSB%d" 35 | #define DEV_DEFAULT "/dev/ttyUSB0" 36 | #else 37 | #define DEVFILE_FMT "COM%d" 38 | #define DEV_DEFAULT "COM3" 39 | #endif 40 | 41 | #define RETRIES_DEFAULT 5 42 | 43 | 44 | int init_options(int argc, char **argv) 45 | { 46 | int i, num; 47 | char *endp; 48 | static char devbuf[16]; 49 | 50 | opt.devfile = DEV_DEFAULT; 51 | opt.verbose = 1; 52 | opt.retries = RETRIES_DEFAULT; 53 | 54 | load_config(); 55 | 56 | for(i=1; i\n", argv0); 126 | printf("Options:\n"); 127 | printf(" -w write ADF image to disk (default: read from disk)\n"); 128 | printf(" -v verify after writing (default: no verification)\n"); 129 | printf(" -d specify which device to use (default: " DEV_DEFAULT ")\n"); 130 | printf(" -s run silent, print only errors\n"); 131 | printf(" -r how many retries to attempt while reading (default: %d)\n", RETRIES_DEFAULT); 132 | printf(" -h print help and exit\n"); 133 | } 134 | 135 | 136 | static int load_config(void) 137 | { 138 | FILE *fp; 139 | int val; 140 | char buf[512], *line, *endp, *valstr; 141 | char *fname; 142 | 143 | if((fp = fopen("amigafloppy.conf", "r"))) { 144 | fname = alloca(20); 145 | strcpy(fname, "amigafloppy.conf"); 146 | } else { 147 | char *env; 148 | struct passwd *pw; 149 | 150 | if((pw = getpwuid(getuid()))) { 151 | sprintf(buf, "%s/.amigafloppy.conf", pw->pw_dir); 152 | } else if((env = getenv("HOME"))) { 153 | sprintf(buf, "%s/.amigafloppy.conf", env); 154 | } else { 155 | return -1; 156 | } 157 | if(!(fp = fopen(buf, "r"))) { 158 | return -1; 159 | } 160 | fname = alloca(strlen(buf) + 1); 161 | strcpy(fname, buf); 162 | } 163 | 164 | while(fgets(buf, sizeof buf, fp)) { 165 | line = skip_wspace(buf); 166 | if((endp = strchr(line, '#'))) { 167 | *endp = 0; 168 | } 169 | if(!*line) continue; 170 | if(!(endp = strchr(line, '=')) || !*(valstr = cleanstr(endp + 1))) { 171 | fprintf(stderr, "config file: %s: invalid line: %s\n", fname, line); 172 | continue; 173 | } 174 | *endp = 0; 175 | line = cleanstr(line); 176 | 177 | if(strcasecmp(line, "verify") == 0) { 178 | if((val = strbool(valstr)) == -1) { 179 | fprintf(stderr, "config file: %s: verify must be followed by a boolean value (found: %s)\n", fname, valstr); 180 | continue; 181 | } 182 | opt.verify = val; 183 | 184 | } else if(strcasecmp(line, "device") == 0) { 185 | if(!(opt.devfile = malloc(strlen(valstr) + 1))) { 186 | fprintf(stderr, "failed to allocate device filename buffer (%s)\n", valstr); 187 | abort(); 188 | } 189 | strcpy(opt.devfile, valstr); 190 | 191 | } else { 192 | fprintf(stderr, "config file: %s: invalid option: %s\n", fname, line); 193 | } 194 | } 195 | 196 | fclose(fp); 197 | return 0; 198 | } 199 | 200 | static char *skip_wspace(char *s) 201 | { 202 | while(*s && isspace(*s)) s++; 203 | return s; 204 | } 205 | 206 | static char *cleanstr(char *s) 207 | { 208 | char *endp; 209 | if(!*(s = skip_wspace(s))) return s; 210 | endp = s + strlen(s) - 1; 211 | while(endp > s && isspace(*endp)) endp--; 212 | endp[1] = 0; 213 | return s; 214 | } 215 | 216 | static int strbool(char *s) 217 | { 218 | if(s[1] == 0) { 219 | if(*s == '1') return 1; 220 | if(*s == '0') return 0; 221 | return -1; 222 | } 223 | if(strcasecmp(s, "true") == 0 || strcasecmp(s, "yes") == 0 || strcasecmp(s, "on") == 0) { 224 | return 1; 225 | } 226 | if(strcasecmp(s, "false") == 0 || strcasecmp(s, "no") == 0 || strcasecmp(s, "off") == 0) { 227 | return 0; 228 | } 229 | return -1; 230 | } 231 | -------------------------------------------------------------------------------- /amigafloppy/src/dev.c: -------------------------------------------------------------------------------- 1 | /* 2 | amigafloppy - driver for the USB floppy controller for amiga disks 3 | Copyright (C) 2018 John Tsiombikas 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include "dev.h" 26 | #include "serial.h" 27 | #include "opt.h" 28 | 29 | #ifdef __GNUC__ 30 | #define PACKED __attribute__ ((packed)) 31 | #else 32 | #define PACKED 33 | #endif 34 | 35 | #define MFM_HDR_FMT_OFFSET (offsetof(struct sector_header, fmt) * 2) 36 | #define MFM_HDR_OSINFO_OFFSET (offsetof(struct sector_header, osinfo) * 2) 37 | #define MFM_HDR_HSUM_OFFSET (offsetof(struct sector_header, hdr_sum) * 2) 38 | #define MFM_HDR_DSUM_OFFSET (offsetof(struct sector_header, data_sum) * 2) 39 | #define MFM_DATA_OFFSET (sizeof(struct sector_header) * 2) 40 | 41 | struct sector_header { 42 | unsigned char magic[4]; 43 | unsigned char fmt; 44 | unsigned char track; 45 | unsigned char sector; 46 | unsigned char sec_to_gap; 47 | unsigned char osinfo[16]; 48 | uint32_t hdr_sum, data_sum; 49 | } PACKED; 50 | 51 | struct sector_node { 52 | struct sector_header hdr; 53 | unsigned char *rawptr; 54 | struct sector_node *next; 55 | }; 56 | 57 | #define TIMEOUT_MSEC 2000 58 | #define TRACK_SIZE (0x1900 * 2 + 0x440) 59 | #define SECTORS_PER_TRACK 11 60 | 61 | static int uncompress(unsigned char *dest, unsigned char *src, int size); 62 | static int align_track(unsigned char *buf, int size); 63 | static struct sector_node *find_sectors(unsigned char *buf, int size); 64 | static void debug_print(unsigned char *dest, int size); 65 | static void dbg_print_header(struct sector_header *hdr); 66 | static void decode_mfm(unsigned char *dest, unsigned char *src, int blksz); 67 | static uint32_t checksum(void *buf, int size); 68 | 69 | static int dev_fd = -1; 70 | 71 | int init_device(const char *devname) 72 | { 73 | int major, minor; 74 | 75 | if((dev_fd = ser_open(devname, 2000000, SER_HWFLOW)) == -1) { 76 | return -1; 77 | } 78 | ser_nonblock(dev_fd); 79 | 80 | if(get_fw_version(&major, &minor) == -1) { 81 | ser_close(dev_fd); 82 | dev_fd = -1; 83 | return -1; 84 | } 85 | if(opt.verbose) { 86 | printf("Firmware version: %d.%d\n", major, minor); 87 | } 88 | 89 | return dev_fd; 90 | } 91 | 92 | void shutdown_device(void) 93 | { 94 | ser_close(dev_fd); 95 | } 96 | 97 | int wait_response(void) 98 | { 99 | char res; 100 | 101 | if(dev_fd < 0) return -1; 102 | 103 | if(!ser_wait(dev_fd, TIMEOUT_MSEC)) { 104 | fprintf(stderr, "timeout while waiting for response from device\n"); 105 | return -1; 106 | } 107 | if(ser_read(dev_fd, &res, 1) != 1) { 108 | fprintf(stderr, "failed to read response from device\n"); 109 | return -1; 110 | } 111 | return res == '1' ? 1 : 0; 112 | } 113 | 114 | static int command(char c) 115 | { 116 | if(dev_fd < 0) return -1; 117 | 118 | if(ser_write(dev_fd, &c, 1) != 1) { 119 | fprintf(stderr, "failed to send command to the device\n"); 120 | return -1; 121 | } 122 | return wait_response(); 123 | } 124 | 125 | int get_fw_version(int *major, int *minor) 126 | { 127 | char buf[5] = {0}; 128 | 129 | if(command('?') <= 0) { 130 | return -1; 131 | } 132 | 133 | if(ser_read(dev_fd, buf, 4) != 4) { 134 | fprintf(stderr, "failed to read firmware version\n"); 135 | return -1; 136 | } 137 | 138 | if(sscanf(buf, "V%d.%d", major, minor) != 2) { 139 | fprintf(stderr, "got malformed response to version command\n"); 140 | return -1; 141 | } 142 | return 0; 143 | } 144 | 145 | int begin_read(void) 146 | { 147 | if(command('+') <= 0) { 148 | fprintf(stderr, "begin_read failed\n"); 149 | return -1; 150 | } 151 | return 0; 152 | } 153 | 154 | int begin_write(void) 155 | { 156 | if(command('~') <= 0) { 157 | fprintf(stderr, "begin_write failed\n"); 158 | return -1; 159 | } 160 | return 0; 161 | } 162 | 163 | int end_access(void) 164 | { 165 | if(command('-') <= 0) { 166 | fprintf(stderr, "end_access failed\n"); 167 | return -1; 168 | } 169 | return 0; 170 | } 171 | 172 | int select_head(int s) 173 | { 174 | if(command(s ? '[' : ']') <= 0) { 175 | fprintf(stderr, "select_head(%d) failed\n", s); 176 | return -1; 177 | } 178 | return 0; 179 | } 180 | 181 | int move_head(int track) 182 | { 183 | char buf[4]; 184 | 185 | if(track > 99) { 186 | fprintf(stderr, "move_head(%d): invalid track number\n", track); 187 | return -1; 188 | } 189 | 190 | if(track <= 0) { 191 | return command('.'); 192 | } 193 | sprintf(buf, "#%02d", track); 194 | 195 | ser_write(dev_fd, buf, 3); 196 | return wait_response(); 197 | } 198 | 199 | int read_track(unsigned char *resbuf) 200 | { 201 | unsigned char *ptr, buf[TRACK_SIZE]; 202 | char waitidx = 0; 203 | int i, sz, rdbytes, total_read = 0; 204 | struct sector_node *slist; 205 | 206 | if(command('<') <= 0) { 207 | return -1; 208 | } 209 | ser_write(dev_fd, &waitidx, 1); 210 | 211 | ptr = buf; 212 | 213 | while(total_read < TRACK_SIZE) { 214 | if(!ser_wait(dev_fd, TIMEOUT_MSEC)) { 215 | fprintf(stderr, "timeout while reading track\n"); 216 | return -1; 217 | } 218 | sz = TRACK_SIZE - total_read; 219 | if((rdbytes = ser_read(dev_fd, ptr, sz)) <= 0) { 220 | fprintf(stderr, "failed to read track\n"); 221 | return -1; 222 | } 223 | 224 | ptr += rdbytes; 225 | total_read += rdbytes; 226 | 227 | if(!buf[total_read - 1]) { 228 | break; /* end of data */ 229 | } 230 | } 231 | 232 | total_read = uncompress(resbuf, buf, total_read); 233 | 234 | /* move uncompressed data back to the temporary buffer */ 235 | memcpy(buf, resbuf, total_read); 236 | 237 | if(align_track(buf, total_read) == -1) { 238 | return -1; 239 | } 240 | 241 | if(!(slist = find_sectors(buf, total_read))) { 242 | return -1; 243 | } 244 | 245 | ptr = resbuf; 246 | for(i=0; ihdr.sector == i) { 250 | uint32_t sum; 251 | 252 | decode_mfm(ptr, sec->rawptr + MFM_DATA_OFFSET, 512); 253 | 254 | sum = checksum(ptr, 512); 255 | if(sum != ntohl(sec->hdr.data_sum)) { 256 | fprintf(stderr, "Track %d, sector %d data checksum error\n", sec->hdr.track, sec->hdr.sector); 257 | return -1; 258 | } 259 | 260 | ptr += 512; 261 | break; 262 | } 263 | sec = sec->next; 264 | } 265 | 266 | if(!sec) { 267 | fprintf(stderr, "\nread_track: failed to find sector %d\n", i); 268 | return -1; 269 | } 270 | } 271 | 272 | return 0; 273 | } 274 | 275 | static int uncompress(unsigned char *dest, unsigned char *src, int size) 276 | { 277 | int i, j; 278 | int outbits = 0; 279 | unsigned int val = 0; 280 | unsigned char *dptr = dest; 281 | 282 | for(i=0; i> shift) & 3) { 286 | case 1: 287 | val = (val << 2) | 1; 288 | outbits += 2; 289 | break; 290 | 291 | case 2: 292 | val = (val << 3) | 1; 293 | outbits += 3; 294 | break; 295 | 296 | case 3: 297 | val = (val << 4) | 1; 298 | outbits += 4; 299 | break; 300 | 301 | default: 302 | goto done; 303 | } 304 | 305 | if(outbits >= 8) { 306 | *dptr++ = (val >> (outbits - 8)) & 0xff; 307 | outbits -= 8; 308 | 309 | if(dptr - dest >= TRACK_SIZE) { 310 | goto done; 311 | } 312 | } 313 | } 314 | ++src; 315 | } 316 | 317 | done: 318 | return dptr - dest; 319 | } 320 | 321 | /* reads at most size + 1 bytes from src and writes size bytes to dest, left-shifted accordingly */ 322 | static void copy_bits(unsigned char *dest, unsigned char *src, int size, int shift) 323 | { 324 | int i; 325 | if(!shift) { 326 | memcpy(dest, src, size); 327 | } else { 328 | for(i=0; i> (8 - shift)); 330 | ++src; 331 | } 332 | } 333 | } 334 | 335 | static const unsigned char magic[] = { 0xaa, 0xaa, 0xaa, 0xaa, 0x44, 0x89, 0x44, 0x89 }; 336 | 337 | static int check_magic(unsigned char *buf) 338 | { 339 | return memcmp(buf + 1, magic + 1, sizeof magic - 1) == 0 && 340 | (buf[0] & 0x7f) == (magic[0] & 0x7f); 341 | } 342 | 343 | static int align_track(unsigned char *buf, int size) 344 | { 345 | int i, j, offset, shift = -1; 346 | unsigned char *ptr = buf; 347 | unsigned char tmp[sizeof magic]; 348 | 349 | for(i=0; ihdr.fmt, ptr + MFM_HDR_FMT_OFFSET, 4); 387 | decode_mfm((unsigned char*)&node->hdr.osinfo, ptr + MFM_HDR_OSINFO_OFFSET, 16); 388 | decode_mfm((unsigned char*)&node->hdr.hdr_sum, ptr + MFM_HDR_HSUM_OFFSET, 4); 389 | decode_mfm((unsigned char*)&node->hdr.data_sum, ptr + MFM_HDR_DSUM_OFFSET, 4); 390 | node->rawptr = ptr; 391 | node->next = 0; 392 | 393 | /* verify header checksum */ 394 | sum = checksum(&node->hdr.fmt, 20); 395 | if(sum != ntohl(node->hdr.hdr_sum)) { 396 | fprintf(stderr, "Track %d, sector %d header checksum error\n", node->hdr.track, node->hdr.sector); 397 | fprintf(stderr, " calculated: %lu, on disk: %lu\n", (unsigned long)sum, (unsigned long)ntohl(node->hdr.hdr_sum)); 398 | goto err; 399 | } 400 | 401 | if(head) { 402 | tail->next = node; 403 | tail = node; 404 | } else { 405 | head = tail = node; 406 | } 407 | ptr += (512 + sizeof node->hdr) * 2; 408 | ++nfound; 409 | } else { 410 | ++ptr; 411 | } 412 | } 413 | 414 | if(nfound < SECTORS_PER_TRACK) { 415 | fprintf(stderr, "error while reading track: found only %d sectors\n", nfound); 416 | goto err; 417 | } 418 | 419 | return head; 420 | err: 421 | while(head) { 422 | void *tmp = head; 423 | head = head->next; 424 | free(tmp); 425 | } 426 | return 0; 427 | } 428 | 429 | static void print_byte(unsigned char val) 430 | { 431 | printf("%02x ", (unsigned int)val); 432 | } 433 | 434 | static void debug_print(unsigned char *buf, int size) 435 | { 436 | int i = 0; 437 | /* TODO */ 438 | 439 | while(size > 0) { 440 | print_byte(*buf++); 441 | if(++i == 16) { 442 | putchar('\n'); 443 | i = 0; 444 | } 445 | --size; 446 | } 447 | if(i) putchar('\n'); 448 | } 449 | 450 | static void dbg_print_header(struct sector_header *hdr) 451 | { 452 | printf("Sector header\n"); 453 | printf(" format: %x\n", (unsigned int)hdr->fmt); 454 | printf(" track: %u\n", (unsigned int)hdr->track); 455 | printf(" sector: %u\n", (unsigned int)hdr->sector); 456 | printf(" sectors before gap: %u\n", (unsigned int)hdr->sec_to_gap); 457 | printf(" header checksum: %lu\n", (unsigned long)hdr->hdr_sum); 458 | printf(" data checksum: %lu\n", (unsigned long)hdr->data_sum); 459 | } 460 | 461 | /* this can work in-place (dest == src) */ 462 | static void decode_mfm(unsigned char *dest, unsigned char *src, int blksz) 463 | { 464 | int i, j; 465 | 466 | for(i=0; i> 1)) & 0x55555555; 498 | } 499 | -------------------------------------------------------------------------------- /LICENSE.hw: -------------------------------------------------------------------------------- 1 | Attribution-ShareAlike 4.0 International 2 | 3 | ======================================================================= 4 | 5 | Creative Commons Corporation ("Creative Commons") is not a law firm and 6 | does not provide legal services or legal advice. Distribution of 7 | Creative Commons public licenses does not create a lawyer-client or 8 | other relationship. Creative Commons makes its licenses and related 9 | information available on an "as-is" basis. Creative Commons gives no 10 | warranties regarding its licenses, any material licensed under their 11 | terms and conditions, or any related information. Creative Commons 12 | disclaims all liability for damages resulting from their use to the 13 | fullest extent possible. 14 | 15 | Using Creative Commons Public Licenses 16 | 17 | Creative Commons public licenses provide a standard set of terms and 18 | conditions that creators and other rights holders may use to share 19 | original works of authorship and other material subject to copyright 20 | and certain other rights specified in the public license below. The 21 | following considerations are for informational purposes only, are not 22 | exhaustive, and do not form part of our licenses. 23 | 24 | Considerations for licensors: Our public licenses are 25 | intended for use by those authorized to give the public 26 | permission to use material in ways otherwise restricted by 27 | copyright and certain other rights. Our licenses are 28 | irrevocable. Licensors should read and understand the terms 29 | and conditions of the license they choose before applying it. 30 | Licensors should also secure all rights necessary before 31 | applying our licenses so that the public can reuse the 32 | material as expected. Licensors should clearly mark any 33 | material not subject to the license. This includes other CC- 34 | licensed material, or material used under an exception or 35 | limitation to copyright. More considerations for licensors: 36 | wiki.creativecommons.org/Considerations_for_licensors 37 | 38 | Considerations for the public: By using one of our public 39 | licenses, a licensor grants the public permission to use the 40 | licensed material under specified terms and conditions. If 41 | the licensor's permission is not necessary for any reason--for 42 | example, because of any applicable exception or limitation to 43 | copyright--then that use is not regulated by the license. Our 44 | licenses grant only permissions under copyright and certain 45 | other rights that a licensor has authority to grant. Use of 46 | the licensed material may still be restricted for other 47 | reasons, including because others have copyright or other 48 | rights in the material. A licensor may make special requests, 49 | such as asking that all changes be marked or described. 50 | Although not required by our licenses, you are encouraged to 51 | respect those requests where reasonable. More_considerations 52 | for the public: 53 | wiki.creativecommons.org/Considerations_for_licensees 54 | 55 | ======================================================================= 56 | 57 | Creative Commons Attribution-ShareAlike 4.0 International Public 58 | License 59 | 60 | By exercising the Licensed Rights (defined below), You accept and agree 61 | to be bound by the terms and conditions of this Creative Commons 62 | Attribution-ShareAlike 4.0 International Public License ("Public 63 | License"). To the extent this Public License may be interpreted as a 64 | contract, You are granted the Licensed Rights in consideration of Your 65 | acceptance of these terms and conditions, and the Licensor grants You 66 | such rights in consideration of benefits the Licensor receives from 67 | making the Licensed Material available under these terms and 68 | conditions. 69 | 70 | 71 | Section 1 -- Definitions. 72 | 73 | a. Adapted Material means material subject to Copyright and Similar 74 | Rights that is derived from or based upon the Licensed Material 75 | and in which the Licensed Material is translated, altered, 76 | arranged, transformed, or otherwise modified in a manner requiring 77 | permission under the Copyright and Similar Rights held by the 78 | Licensor. For purposes of this Public License, where the Licensed 79 | Material is a musical work, performance, or sound recording, 80 | Adapted Material is always produced where the Licensed Material is 81 | synched in timed relation with a moving image. 82 | 83 | b. Adapter's License means the license You apply to Your Copyright 84 | and Similar Rights in Your contributions to Adapted Material in 85 | accordance with the terms and conditions of this Public License. 86 | 87 | c. BY-SA Compatible License means a license listed at 88 | creativecommons.org/compatiblelicenses, approved by Creative 89 | Commons as essentially the equivalent of this Public License. 90 | 91 | d. Copyright and Similar Rights means copyright and/or similar rights 92 | closely related to copyright including, without limitation, 93 | performance, broadcast, sound recording, and Sui Generis Database 94 | Rights, without regard to how the rights are labeled or 95 | categorized. For purposes of this Public License, the rights 96 | specified in Section 2(b)(1)-(2) are not Copyright and Similar 97 | Rights. 98 | 99 | e. Effective Technological Measures means those measures that, in the 100 | absence of proper authority, may not be circumvented under laws 101 | fulfilling obligations under Article 11 of the WIPO Copyright 102 | Treaty adopted on December 20, 1996, and/or similar international 103 | agreements. 104 | 105 | f. Exceptions and Limitations means fair use, fair dealing, and/or 106 | any other exception or limitation to Copyright and Similar Rights 107 | that applies to Your use of the Licensed Material. 108 | 109 | g. License Elements means the license attributes listed in the name 110 | of a Creative Commons Public License. The License Elements of this 111 | Public License are Attribution and ShareAlike. 112 | 113 | h. Licensed Material means the artistic or literary work, database, 114 | or other material to which the Licensor applied this Public 115 | License. 116 | 117 | i. Licensed Rights means the rights granted to You subject to the 118 | terms and conditions of this Public License, which are limited to 119 | all Copyright and Similar Rights that apply to Your use of the 120 | Licensed Material and that the Licensor has authority to license. 121 | 122 | j. Licensor means the individual(s) or entity(ies) granting rights 123 | under this Public License. 124 | 125 | k. Share means to provide material to the public by any means or 126 | process that requires permission under the Licensed Rights, such 127 | as reproduction, public display, public performance, distribution, 128 | dissemination, communication, or importation, and to make material 129 | available to the public including in ways that members of the 130 | public may access the material from a place and at a time 131 | individually chosen by them. 132 | 133 | l. Sui Generis Database Rights means rights other than copyright 134 | resulting from Directive 96/9/EC of the European Parliament and of 135 | the Council of 11 March 1996 on the legal protection of databases, 136 | as amended and/or succeeded, as well as other essentially 137 | equivalent rights anywhere in the world. 138 | 139 | m. You means the individual or entity exercising the Licensed Rights 140 | under this Public License. Your has a corresponding meaning. 141 | 142 | 143 | Section 2 -- Scope. 144 | 145 | a. License grant. 146 | 147 | 1. Subject to the terms and conditions of this Public License, 148 | the Licensor hereby grants You a worldwide, royalty-free, 149 | non-sublicensable, non-exclusive, irrevocable license to 150 | exercise the Licensed Rights in the Licensed Material to: 151 | 152 | a. reproduce and Share the Licensed Material, in whole or 153 | in part; and 154 | 155 | b. produce, reproduce, and Share Adapted Material. 156 | 157 | 2. Exceptions and Limitations. For the avoidance of doubt, where 158 | Exceptions and Limitations apply to Your use, this Public 159 | License does not apply, and You do not need to comply with 160 | its terms and conditions. 161 | 162 | 3. Term. The term of this Public License is specified in Section 163 | 6(a). 164 | 165 | 4. Media and formats; technical modifications allowed. The 166 | Licensor authorizes You to exercise the Licensed Rights in 167 | all media and formats whether now known or hereafter created, 168 | and to make technical modifications necessary to do so. The 169 | Licensor waives and/or agrees not to assert any right or 170 | authority to forbid You from making technical modifications 171 | necessary to exercise the Licensed Rights, including 172 | technical modifications necessary to circumvent Effective 173 | Technological Measures. For purposes of this Public License, 174 | simply making modifications authorized by this Section 2(a) 175 | (4) never produces Adapted Material. 176 | 177 | 5. Downstream recipients. 178 | 179 | a. Offer from the Licensor -- Licensed Material. Every 180 | recipient of the Licensed Material automatically 181 | receives an offer from the Licensor to exercise the 182 | Licensed Rights under the terms and conditions of this 183 | Public License. 184 | 185 | b. Additional offer from the Licensor -- Adapted Material. 186 | Every recipient of Adapted Material from You 187 | automatically receives an offer from the Licensor to 188 | exercise the Licensed Rights in the Adapted Material 189 | under the conditions of the Adapter's License You apply. 190 | 191 | c. No downstream restrictions. You may not offer or impose 192 | any additional or different terms or conditions on, or 193 | apply any Effective Technological Measures to, the 194 | Licensed Material if doing so restricts exercise of the 195 | Licensed Rights by any recipient of the Licensed 196 | Material. 197 | 198 | 6. No endorsement. Nothing in this Public License constitutes or 199 | may be construed as permission to assert or imply that You 200 | are, or that Your use of the Licensed Material is, connected 201 | with, or sponsored, endorsed, or granted official status by, 202 | the Licensor or others designated to receive attribution as 203 | provided in Section 3(a)(1)(A)(i). 204 | 205 | b. Other rights. 206 | 207 | 1. Moral rights, such as the right of integrity, are not 208 | licensed under this Public License, nor are publicity, 209 | privacy, and/or other similar personality rights; however, to 210 | the extent possible, the Licensor waives and/or agrees not to 211 | assert any such rights held by the Licensor to the limited 212 | extent necessary to allow You to exercise the Licensed 213 | Rights, but not otherwise. 214 | 215 | 2. Patent and trademark rights are not licensed under this 216 | Public License. 217 | 218 | 3. To the extent possible, the Licensor waives any right to 219 | collect royalties from You for the exercise of the Licensed 220 | Rights, whether directly or through a collecting society 221 | under any voluntary or waivable statutory or compulsory 222 | licensing scheme. In all other cases the Licensor expressly 223 | reserves any right to collect such royalties. 224 | 225 | 226 | Section 3 -- License Conditions. 227 | 228 | Your exercise of the Licensed Rights is expressly made subject to the 229 | following conditions. 230 | 231 | a. Attribution. 232 | 233 | 1. If You Share the Licensed Material (including in modified 234 | form), You must: 235 | 236 | a. retain the following if it is supplied by the Licensor 237 | with the Licensed Material: 238 | 239 | i. identification of the creator(s) of the Licensed 240 | Material and any others designated to receive 241 | attribution, in any reasonable manner requested by 242 | the Licensor (including by pseudonym if 243 | designated); 244 | 245 | ii. a copyright notice; 246 | 247 | iii. a notice that refers to this Public License; 248 | 249 | iv. a notice that refers to the disclaimer of 250 | warranties; 251 | 252 | v. a URI or hyperlink to the Licensed Material to the 253 | extent reasonably practicable; 254 | 255 | b. indicate if You modified the Licensed Material and 256 | retain an indication of any previous modifications; and 257 | 258 | c. indicate the Licensed Material is licensed under this 259 | Public License, and include the text of, or the URI or 260 | hyperlink to, this Public License. 261 | 262 | 2. You may satisfy the conditions in Section 3(a)(1) in any 263 | reasonable manner based on the medium, means, and context in 264 | which You Share the Licensed Material. For example, it may be 265 | reasonable to satisfy the conditions by providing a URI or 266 | hyperlink to a resource that includes the required 267 | information. 268 | 269 | 3. If requested by the Licensor, You must remove any of the 270 | information required by Section 3(a)(1)(A) to the extent 271 | reasonably practicable. 272 | 273 | b. ShareAlike. 274 | 275 | In addition to the conditions in Section 3(a), if You Share 276 | Adapted Material You produce, the following conditions also apply. 277 | 278 | 1. The Adapter's License You apply must be a Creative Commons 279 | license with the same License Elements, this version or 280 | later, or a BY-SA Compatible License. 281 | 282 | 2. You must include the text of, or the URI or hyperlink to, the 283 | Adapter's License You apply. You may satisfy this condition 284 | in any reasonable manner based on the medium, means, and 285 | context in which You Share Adapted Material. 286 | 287 | 3. You may not offer or impose any additional or different terms 288 | or conditions on, or apply any Effective Technological 289 | Measures to, Adapted Material that restrict exercise of the 290 | rights granted under the Adapter's License You apply. 291 | 292 | 293 | Section 4 -- Sui Generis Database Rights. 294 | 295 | Where the Licensed Rights include Sui Generis Database Rights that 296 | apply to Your use of the Licensed Material: 297 | 298 | a. for the avoidance of doubt, Section 2(a)(1) grants You the right 299 | to extract, reuse, reproduce, and Share all or a substantial 300 | portion of the contents of the database; 301 | 302 | b. if You include all or a substantial portion of the database 303 | contents in a database in which You have Sui Generis Database 304 | Rights, then the database in which You have Sui Generis Database 305 | Rights (but not its individual contents) is Adapted Material, 306 | 307 | including for purposes of Section 3(b); and 308 | c. You must comply with the conditions in Section 3(a) if You Share 309 | all or a substantial portion of the contents of the database. 310 | 311 | For the avoidance of doubt, this Section 4 supplements and does not 312 | replace Your obligations under this Public License where the Licensed 313 | Rights include other Copyright and Similar Rights. 314 | 315 | 316 | Section 5 -- Disclaimer of Warranties and Limitation of Liability. 317 | 318 | a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE 319 | EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS 320 | AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF 321 | ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, 322 | IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, 323 | WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR 324 | PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS, 325 | ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT 326 | KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT 327 | ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU. 328 | 329 | b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE 330 | TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, 331 | NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, 332 | INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES, 333 | COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR 334 | USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN 335 | ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR 336 | DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR 337 | IN PART, THIS LIMITATION MAY NOT APPLY TO YOU. 338 | 339 | c. The disclaimer of warranties and limitation of liability provided 340 | above shall be interpreted in a manner that, to the extent 341 | possible, most closely approximates an absolute disclaimer and 342 | waiver of all liability. 343 | 344 | 345 | Section 6 -- Term and Termination. 346 | 347 | a. This Public License applies for the term of the Copyright and 348 | Similar Rights licensed here. However, if You fail to comply with 349 | this Public License, then Your rights under this Public License 350 | terminate automatically. 351 | 352 | b. Where Your right to use the Licensed Material has terminated under 353 | Section 6(a), it reinstates: 354 | 355 | 1. automatically as of the date the violation is cured, provided 356 | it is cured within 30 days of Your discovery of the 357 | violation; or 358 | 359 | 2. upon express reinstatement by the Licensor. 360 | 361 | For the avoidance of doubt, this Section 6(b) does not affect any 362 | right the Licensor may have to seek remedies for Your violations 363 | of this Public License. 364 | 365 | c. For the avoidance of doubt, the Licensor may also offer the 366 | Licensed Material under separate terms or conditions or stop 367 | distributing the Licensed Material at any time; however, doing so 368 | will not terminate this Public License. 369 | 370 | d. Sections 1, 5, 6, 7, and 8 survive termination of this Public 371 | License. 372 | 373 | 374 | Section 7 -- Other Terms and Conditions. 375 | 376 | a. The Licensor shall not be bound by any additional or different 377 | terms or conditions communicated by You unless expressly agreed. 378 | 379 | b. Any arrangements, understandings, or agreements regarding the 380 | Licensed Material not stated herein are separate from and 381 | independent of the terms and conditions of this Public License. 382 | 383 | 384 | Section 8 -- Interpretation. 385 | 386 | a. For the avoidance of doubt, this Public License does not, and 387 | shall not be interpreted to, reduce, limit, restrict, or impose 388 | conditions on any use of the Licensed Material that could lawfully 389 | be made without permission under this Public License. 390 | 391 | b. To the extent possible, if any provision of this Public License is 392 | deemed unenforceable, it shall be automatically reformed to the 393 | minimum extent necessary to make it enforceable. If the provision 394 | cannot be reformed, it shall be severed from this Public License 395 | without affecting the enforceability of the remaining terms and 396 | conditions. 397 | 398 | c. No term or condition of this Public License will be waived and no 399 | failure to comply consented to unless expressly agreed to by the 400 | Licensor. 401 | 402 | d. Nothing in this Public License constitutes or may be interpreted 403 | as a limitation upon, or waiver of, any privileges and immunities 404 | that apply to the Licensor or You, including from the legal 405 | processes of any jurisdiction or authority. 406 | 407 | 408 | ======================================================================= 409 | 410 | Creative Commons is not a party to its public 411 | licenses. Notwithstanding, Creative Commons may elect to apply one of 412 | its public licenses to material it publishes and in those instances 413 | will be considered the “Licensor.” The text of the Creative Commons 414 | public licenses is dedicated to the public domain under the CC0 Public 415 | Domain Dedication. Except for the limited purpose of indicating that 416 | material is shared under a Creative Commons public license or as 417 | otherwise permitted by the Creative Commons policies published at 418 | creativecommons.org/policies, Creative Commons does not authorize the 419 | use of the trademark "Creative Commons" or any other trademark or logo 420 | of Creative Commons without its prior written consent including, 421 | without limitation, in connection with any unauthorized modifications 422 | to any of its public licenses or any other arrangements, 423 | understandings, or agreements concerning use of licensed material. For 424 | the avoidance of doubt, this paragraph does not form part of the 425 | public licenses. 426 | 427 | Creative Commons may be contacted at creativecommons.org. 428 | 429 | -------------------------------------------------------------------------------- /hw/usbavrfloppy.sch: -------------------------------------------------------------------------------- 1 | EESchema Schematic File Version 2 2 | LIBS:power 3 | LIBS:device 4 | LIBS:transistors 5 | LIBS:conn 6 | LIBS:linear 7 | LIBS:regul 8 | LIBS:74xx 9 | LIBS:cmos4000 10 | LIBS:adc-dac 11 | LIBS:memory 12 | LIBS:xilinx 13 | LIBS:microcontrollers 14 | LIBS:dsp 15 | LIBS:microchip 16 | LIBS:analog_switches 17 | LIBS:motorola 18 | LIBS:texas 19 | LIBS:intel 20 | LIBS:audio 21 | LIBS:interface 22 | LIBS:digital-audio 23 | LIBS:philips 24 | LIBS:display 25 | LIBS:cypress 26 | LIBS:siliconi 27 | LIBS:opto 28 | LIBS:atmel 29 | LIBS:contrib 30 | LIBS:valves 31 | LIBS:ftdi 32 | LIBS:usbavrfloppy 33 | LIBS:switches 34 | EELAYER 25 0 35 | EELAYER END 36 | $Descr A4 11693 8268 37 | encoding utf-8 38 | Sheet 1 1 39 | Title "USB amiga floppy controller" 40 | Date "2018-03-01" 41 | Rev "1" 42 | Comp "" 43 | Comment1 "Creative Commons Attribution Share-Alike (CC BY-SA)" 44 | Comment2 "Copyright (C) John Tsiombikas 2018" 45 | Comment3 "" 46 | Comment4 "" 47 | $EndDescr 48 | $Comp 49 | L ATMEGA88A-PU U1 50 | U 1 1 5A95DE62 51 | P 4900 2550 52 | F 0 "U1" H 4150 3800 50 0000 L BNN 53 | F 1 "ATMEGA88A-PU" H 5300 1150 50 0000 L BNN 54 | F 2 "Housings_DIP:DIP-28_W7.62mm_Socket" H 4900 2550 50 0001 C CIN 55 | F 3 "" H 4900 2550 50 0001 C CNN 56 | 1 4900 2550 57 | 1 0 0 -1 58 | $EndComp 59 | $Comp 60 | L FT232RL U2 61 | U 1 1 5A95DEF7 62 | P 5450 5350 63 | F 0 "U2" H 4800 6250 50 0000 L CNN 64 | F 1 "FT232RL" H 5850 6250 50 0000 L CNN 65 | F 2 "Housings_SSOP:SSOP-28_5.3x10.2mm_Pitch0.65mm" H 5450 5350 50 0001 C CNN 66 | F 3 "" H 5450 5350 50 0001 C CNN 67 | 1 5450 5350 68 | 1 0 0 -1 69 | $EndComp 70 | $Comp 71 | L floppy_conn J2 72 | U 1 1 5A96F2AA 73 | P 8300 2250 74 | F 0 "J2" H 8300 3150 50 0000 C CNN 75 | F 1 "floppy_conn" V 8300 2250 50 0000 C CNN 76 | F 2 "Connectors:IDC_Header_Straight_34pins" H 8300 1150 50 0001 C CNN 77 | F 3 "" H 8300 1150 50 0001 C CNN 78 | 1 8300 2250 79 | -1 0 0 -1 80 | $EndComp 81 | $Comp 82 | L CONN_01X04 J3 83 | U 1 1 5A96F46A 84 | P 8350 3550 85 | F 0 "J3" H 8350 3800 50 0000 C CNN 86 | F 1 "floppy_power" V 8450 3550 50 0000 C CNN 87 | F 2 "Connectors_Molex:Molex_KK-6410-04_04x2.54mm_Straight" H 8350 3550 50 0001 C CNN 88 | F 3 "" H 8350 3550 50 0001 C CNN 89 | 1 8350 3550 90 | 1 0 0 -1 91 | $EndComp 92 | $Comp 93 | L VCC #PWR01 94 | U 1 1 5A96F4B3 95 | P 8150 3400 96 | F 0 "#PWR01" H 8150 3250 50 0001 C CNN 97 | F 1 "VCC" H 8150 3550 50 0000 C CNN 98 | F 2 "" H 8150 3400 50 0001 C CNN 99 | F 3 "" H 8150 3400 50 0001 C CNN 100 | 1 8150 3400 101 | 1 0 0 -1 102 | $EndComp 103 | $Comp 104 | L GND #PWR02 105 | U 1 1 5A96F4F5 106 | P 8050 3600 107 | F 0 "#PWR02" H 8050 3350 50 0001 C CNN 108 | F 1 "GND" H 8050 3450 50 0000 C CNN 109 | F 2 "" H 8050 3600 50 0001 C CNN 110 | F 3 "" H 8050 3600 50 0001 C CNN 111 | 1 8050 3600 112 | 1 0 0 -1 113 | $EndComp 114 | Wire Wire Line 115 | 8050 3600 8150 3600 116 | Wire Wire Line 117 | 8150 3500 8050 3500 118 | Wire Wire Line 119 | 8050 3500 8050 3600 120 | Connection ~ 8050 3600 121 | $Comp 122 | L CONN_01X02 J1 123 | U 1 1 5A96F78C 124 | P 7500 1650 125 | F 0 "J1" H 7500 1800 50 0000 C CNN 126 | F 1 "bothdrv" V 7600 1650 50 0000 C CNN 127 | F 2 "Pin_Headers:Pin_Header_Straight_1x02_Pitch2.54mm" H 7500 1650 50 0001 C CNN 128 | F 3 "" H 7500 1650 50 0001 C CNN 129 | 1 7500 1650 130 | 0 -1 -1 0 131 | $EndComp 132 | Wire Wire Line 133 | 7550 1850 7850 1850 134 | Wire Wire Line 135 | 7850 2050 7700 2050 136 | Wire Wire Line 137 | 7700 2050 7700 1850 138 | Connection ~ 7700 1850 139 | Wire Wire Line 140 | 7450 1950 7850 1950 141 | Wire Wire Line 142 | 7450 1950 7450 1850 143 | Wire Wire Line 144 | 6800 2150 7850 2150 145 | Wire Wire Line 146 | 7650 2150 7650 1950 147 | Connection ~ 7650 1950 148 | Wire Wire Line 149 | 6800 3550 5900 3550 150 | Wire Wire Line 151 | 7850 2250 6900 2250 152 | Wire Wire Line 153 | 6900 2250 6900 3650 154 | Wire Wire Line 155 | 6900 3650 5900 3650 156 | Text Label 6000 3550 0 60 ~ 0 157 | ~MOTEN 158 | Text Label 6000 3650 0 60 ~ 0 159 | ~DIR 160 | Wire Wire Line 161 | 7850 2350 7000 2350 162 | Wire Wire Line 163 | 7000 2350 7000 3750 164 | Wire Wire Line 165 | 7000 3750 5900 3750 166 | Text Label 6000 3750 0 60 ~ 0 167 | ~STEP 168 | Wire Wire Line 169 | 7850 2450 7100 2450 170 | Wire Wire Line 171 | 7100 2450 7100 3350 172 | Wire Wire Line 173 | 7100 3350 5900 3350 174 | Text Label 6000 3350 0 60 ~ 0 175 | ~WDATA 176 | Wire Wire Line 177 | 7850 2550 6700 2550 178 | Wire Wire Line 179 | 6700 2550 6700 2300 180 | Wire Wire Line 181 | 6700 2300 5900 2300 182 | Text Label 5950 2300 0 60 ~ 0 183 | ~WGATE 184 | Wire Wire Line 185 | 7850 2650 7200 2650 186 | Wire Wire Line 187 | 7200 2650 7200 1450 188 | Wire Wire Line 189 | 7200 1450 5900 1450 190 | Text Label 5950 1450 0 60 ~ 0 191 | ~TRK0 192 | Wire Wire Line 193 | 7850 2750 6600 2750 194 | Wire Wire Line 195 | 6600 2750 6600 2400 196 | Wire Wire Line 197 | 6600 2400 5900 2400 198 | Text Label 5950 2400 0 60 ~ 0 199 | ~WPROTECT 200 | Wire Wire Line 201 | 7850 2850 7200 2850 202 | Wire Wire Line 203 | 7200 2850 7200 3450 204 | Wire Wire Line 205 | 7200 3450 5900 3450 206 | Text Label 6000 3450 0 60 ~ 0 207 | ~RDATA 208 | Wire Wire Line 209 | 7850 2950 7300 2950 210 | Wire Wire Line 211 | 7300 2950 7300 1550 212 | Wire Wire Line 213 | 7300 1550 5900 1550 214 | Text Label 5950 1550 0 60 ~ 0 215 | ~HSEL 216 | NoConn ~ 7850 3050 217 | NoConn ~ 7850 1450 218 | Wire Wire Line 219 | 7850 1750 7750 1750 220 | Wire Wire Line 221 | 7750 1750 7750 3250 222 | Wire Wire Line 223 | 7750 3250 5900 3250 224 | Text Label 6000 3250 0 60 ~ 0 225 | ~INDEX 226 | Wire Wire Line 227 | 5900 3150 6600 3150 228 | Wire Wire Line 229 | 6600 3150 6600 4750 230 | Wire Wire Line 231 | 6600 4750 6250 4750 232 | Wire Wire Line 233 | 5900 3050 6700 3050 234 | Wire Wire Line 235 | 6700 3050 6700 4650 236 | Wire Wire Line 237 | 6700 4650 6250 4650 238 | Text Label 6000 3050 0 60 ~ 0 239 | RXD 240 | Text Label 6000 3150 0 60 ~ 0 241 | TXD 242 | Wire Wire Line 243 | 6250 4950 6500 4950 244 | Wire Wire Line 245 | 6500 4950 6500 2500 246 | Wire Wire Line 247 | 6500 2500 5900 2500 248 | Text Label 5950 2500 0 60 ~ 0 249 | CTS 250 | $Comp 251 | L GND #PWR03 252 | U 1 1 5A971B5E 253 | P 5450 6450 254 | F 0 "#PWR03" H 5450 6200 50 0001 C CNN 255 | F 1 "GND" H 5450 6300 50 0000 C CNN 256 | F 2 "" H 5450 6450 50 0001 C CNN 257 | F 3 "" H 5450 6450 50 0001 C CNN 258 | 1 5450 6450 259 | 1 0 0 -1 260 | $EndComp 261 | Wire Wire Line 262 | 4650 6350 5650 6350 263 | Wire Wire Line 264 | 5450 6350 5450 6450 265 | Connection ~ 5450 6350 266 | Connection ~ 5550 6350 267 | $Comp 268 | L VCC #PWR04 269 | U 1 1 5A971D61 270 | P 5550 4350 271 | F 0 "#PWR04" H 5550 4200 50 0001 C CNN 272 | F 1 "VCC" H 5550 4500 50 0000 C CNN 273 | F 2 "" H 5550 4350 50 0001 C CNN 274 | F 3 "" H 5550 4350 50 0001 C CNN 275 | 1 5550 4350 276 | 1 0 0 -1 277 | $EndComp 278 | Wire Wire Line 279 | 5550 4350 5350 4350 280 | Connection ~ 5550 4350 281 | $Comp 282 | L C C4 283 | U 1 1 5A971DBE 284 | P 4400 4650 285 | F 0 "C4" H 4425 4750 50 0000 L CNN 286 | F 1 "0.1uF" H 4425 4550 50 0000 L CNN 287 | F 2 "Capacitors_SMD:C_0805_HandSoldering" H 4438 4500 50 0001 C CNN 288 | F 3 "" H 4400 4650 50 0001 C CNN 289 | 1 4400 4650 290 | 0 -1 -1 0 291 | $EndComp 292 | Wire Wire Line 293 | 4550 4650 4650 4650 294 | $Comp 295 | L GND #PWR05 296 | U 1 1 5A972060 297 | P 4250 4650 298 | F 0 "#PWR05" H 4250 4400 50 0001 C CNN 299 | F 1 "GND" H 4250 4500 50 0000 C CNN 300 | F 2 "" H 4250 4650 50 0001 C CNN 301 | F 3 "" H 4250 4650 50 0001 C CNN 302 | 1 4250 4650 303 | 1 0 0 -1 304 | $EndComp 305 | $Comp 306 | L USB_B J5 307 | U 1 1 5A972187 308 | P 3500 4950 309 | F 0 "J5" H 3300 5400 50 0000 L CNN 310 | F 1 "USB_B" H 3300 5300 50 0000 L CNN 311 | F 2 "Connectors:USB_B" H 3650 4900 50 0001 C CNN 312 | F 3 "" H 3650 4900 50 0001 C CNN 313 | 1 3500 4950 314 | 1 0 0 -1 315 | $EndComp 316 | Wire Wire Line 317 | 3800 4950 4650 4950 318 | Wire Wire Line 319 | 4650 5050 3800 5050 320 | Text Label 4250 4950 0 60 ~ 0 321 | USBD+ 322 | Text Label 4250 5050 0 60 ~ 0 323 | USBD- 324 | $Comp 325 | L GND #PWR06 326 | U 1 1 5A9722C0 327 | P 3500 5350 328 | F 0 "#PWR06" H 3500 5100 50 0001 C CNN 329 | F 1 "GND" H 3500 5200 50 0000 C CNN 330 | F 2 "" H 3500 5350 50 0001 C CNN 331 | F 3 "" H 3500 5350 50 0001 C CNN 332 | 1 3500 5350 333 | 1 0 0 -1 334 | $EndComp 335 | Wire Wire Line 336 | 3400 5350 3500 5350 337 | Connection ~ 3500 5350 338 | $Comp 339 | L CONN_01X02 J4 340 | U 1 1 5A972447 341 | P 4000 4700 342 | F 0 "J4" H 4000 4850 50 0000 C CNN 343 | F 1 "usbpower" V 4100 4700 50 0000 C CNN 344 | F 2 "Pin_Headers:Pin_Header_Straight_1x02_Pitch2.54mm" H 4000 4700 50 0001 C CNN 345 | F 3 "" H 4000 4700 50 0001 C CNN 346 | 1 4000 4700 347 | 1 0 0 -1 348 | $EndComp 349 | $Comp 350 | L VCC #PWR07 351 | U 1 1 5A97284C 352 | P 3800 4650 353 | F 0 "#PWR07" H 3800 4500 50 0001 C CNN 354 | F 1 "VCC" H 3800 4800 50 0000 C CNN 355 | F 2 "" H 3800 4650 50 0001 C CNN 356 | F 3 "" H 3800 4650 50 0001 C CNN 357 | 1 3800 4650 358 | 1 0 0 -1 359 | $EndComp 360 | Wire Wire Line 361 | 4650 6050 4650 6350 362 | Connection ~ 5250 6350 363 | NoConn ~ 4650 5550 364 | NoConn ~ 4650 5750 365 | NoConn ~ 6250 5650 366 | NoConn ~ 6250 5750 367 | NoConn ~ 6250 5850 368 | NoConn ~ 6250 5950 369 | NoConn ~ 6250 6050 370 | NoConn ~ 6250 4850 371 | $Comp 372 | L C C6 373 | U 1 1 5A972D2B 374 | P 4400 5800 375 | F 0 "C6" H 4425 5900 50 0000 L CNN 376 | F 1 "0.1uF" H 4425 5700 50 0000 L CNN 377 | F 2 "Capacitors_SMD:C_0805_HandSoldering" H 4438 5650 50 0001 C CNN 378 | F 3 "" H 4400 5800 50 0001 C CNN 379 | 1 4400 5800 380 | 1 0 0 -1 381 | $EndComp 382 | $Comp 383 | L VCC #PWR08 384 | U 1 1 5A972D8C 385 | P 4400 5650 386 | F 0 "#PWR08" H 4400 5500 50 0001 C CNN 387 | F 1 "VCC" H 4400 5800 50 0000 C CNN 388 | F 2 "" H 4400 5650 50 0001 C CNN 389 | F 3 "" H 4400 5650 50 0001 C CNN 390 | 1 4400 5650 391 | 1 0 0 -1 392 | $EndComp 393 | $Comp 394 | L GND #PWR09 395 | U 1 1 5A972DB2 396 | P 4400 5950 397 | F 0 "#PWR09" H 4400 5700 50 0001 C CNN 398 | F 1 "GND" H 4400 5800 50 0000 C CNN 399 | F 2 "" H 4400 5950 50 0001 C CNN 400 | F 3 "" H 4400 5950 50 0001 C CNN 401 | 1 4400 5950 402 | 1 0 0 -1 403 | $EndComp 404 | $Comp 405 | L CP C5 406 | U 1 1 5A972DE3 407 | P 4150 5800 408 | F 0 "C5" H 4175 5900 50 0000 L CNN 409 | F 1 "2.2uF" H 4175 5700 50 0000 L CNN 410 | F 2 "Capacitors_SMD:CP_Elec_5x5.7" H 4188 5650 50 0001 C CNN 411 | F 3 "" H 4150 5800 50 0001 C CNN 412 | 1 4150 5800 413 | -1 0 0 -1 414 | $EndComp 415 | Wire Wire Line 416 | 4400 5650 4150 5650 417 | Wire Wire Line 418 | 4400 5950 4150 5950 419 | Connection ~ 4400 5950 420 | Connection ~ 4400 5650 421 | NoConn ~ 4650 5350 422 | NoConn ~ 6250 5050 423 | NoConn ~ 6250 5150 424 | NoConn ~ 6250 5250 425 | NoConn ~ 6250 5350 426 | $Comp 427 | L C C3 428 | U 1 1 5A973A15 429 | P 3850 2800 430 | F 0 "C3" H 3875 2900 50 0000 L CNN 431 | F 1 "0.1uF" H 3875 2700 50 0000 L CNN 432 | F 2 "Capacitors_SMD:C_0805_HandSoldering" H 3888 2650 50 0001 C CNN 433 | F 3 "" H 3850 2800 50 0001 C CNN 434 | 1 3850 2800 435 | 1 0 0 -1 436 | $EndComp 437 | $Comp 438 | L VCC #PWR010 439 | U 1 1 5A973CBB 440 | P 3850 2650 441 | F 0 "#PWR010" H 3850 2500 50 0001 C CNN 442 | F 1 "VCC" H 3850 2800 50 0000 C CNN 443 | F 2 "" H 3850 2650 50 0001 C CNN 444 | F 3 "" H 3850 2650 50 0001 C CNN 445 | 1 3850 2650 446 | 1 0 0 -1 447 | $EndComp 448 | $Comp 449 | L GND #PWR011 450 | U 1 1 5A973E10 451 | P 3850 2950 452 | F 0 "#PWR011" H 3850 2700 50 0001 C CNN 453 | F 1 "GND" H 3850 2800 50 0000 C CNN 454 | F 2 "" H 3850 2950 50 0001 C CNN 455 | F 3 "" H 3850 2950 50 0001 C CNN 456 | 1 3850 2950 457 | 1 0 0 -1 458 | $EndComp 459 | $Comp 460 | L Crystal Y1 461 | U 1 1 5A9740E8 462 | P 6400 2000 463 | F 0 "Y1" V 6400 2000 50 0000 C CNN 464 | F 1 "16MHz" V 6300 2200 50 0000 C CNN 465 | F 2 "Crystals:Crystal_SMD_HC49-SD" H 6400 2000 50 0001 C CNN 466 | F 3 "" H 6400 2000 50 0001 C CNN 467 | 1 6400 2000 468 | 0 -1 -1 0 469 | $EndComp 470 | $Comp 471 | L GND #PWR012 472 | U 1 1 5A97442B 473 | P 6900 1850 474 | F 0 "#PWR012" H 6900 1600 50 0001 C CNN 475 | F 1 "GND" H 6900 1700 50 0000 C CNN 476 | F 2 "" H 6900 1850 50 0001 C CNN 477 | F 3 "" H 6900 1850 50 0001 C CNN 478 | 1 6900 1850 479 | 1 0 0 -1 480 | $EndComp 481 | Wire Wire Line 482 | 5900 2150 6550 2150 483 | Wire Wire Line 484 | 5900 2050 6250 2050 485 | Wire Wire Line 486 | 6250 2050 6250 1850 487 | Wire Wire Line 488 | 6250 1850 6550 1850 489 | Connection ~ 6400 2150 490 | Connection ~ 6400 1850 491 | Wire Wire Line 492 | 5900 1750 6100 1750 493 | Wire Wire Line 494 | 5900 1850 6100 1850 495 | Wire Wire Line 496 | 5900 1950 6200 1950 497 | Text Label 5900 1750 0 60 ~ 0 498 | MOSI 499 | Text Label 5900 1850 0 60 ~ 0 500 | MISO 501 | Text Label 5900 1950 0 60 ~ 0 502 | SCK 503 | NoConn ~ 5900 1650 504 | NoConn ~ 5900 2600 505 | NoConn ~ 5900 2700 506 | NoConn ~ 5900 2800 507 | Wire Wire Line 508 | 6200 2900 5900 2900 509 | Text Label 5900 2900 0 60 ~ 0 510 | ~RESET 511 | $Comp 512 | L VCC #PWR013 513 | U 1 1 5A977AD4 514 | P 4000 1450 515 | F 0 "#PWR013" H 4000 1300 50 0001 C CNN 516 | F 1 "VCC" H 4000 1600 50 0000 C CNN 517 | F 2 "" H 4000 1450 50 0001 C CNN 518 | F 3 "" H 4000 1450 50 0001 C CNN 519 | 1 4000 1450 520 | 1 0 0 -1 521 | $EndComp 522 | Wire Wire Line 523 | 4000 1450 4000 1750 524 | Connection ~ 4000 1450 525 | NoConn ~ 4000 2050 526 | $Comp 527 | L GND #PWR014 528 | U 1 1 5A977D91 529 | P 4000 3750 530 | F 0 "#PWR014" H 4000 3500 50 0001 C CNN 531 | F 1 "GND" H 4000 3600 50 0000 C CNN 532 | F 2 "" H 4000 3750 50 0001 C CNN 533 | F 3 "" H 4000 3750 50 0001 C CNN 534 | 1 4000 3750 535 | 1 0 0 -1 536 | $EndComp 537 | Wire Wire Line 538 | 4000 3650 4000 3750 539 | Connection ~ 4000 3750 540 | Wire Wire Line 541 | 8750 1450 8750 3100 542 | Connection ~ 8750 1550 543 | Connection ~ 8750 1650 544 | Connection ~ 8750 1750 545 | Connection ~ 8750 1850 546 | Connection ~ 8750 1950 547 | Connection ~ 8750 2050 548 | Connection ~ 8750 2150 549 | Connection ~ 8750 2250 550 | Connection ~ 8750 2350 551 | Connection ~ 8750 2450 552 | Connection ~ 8750 2550 553 | Connection ~ 8750 2650 554 | Connection ~ 8750 2750 555 | Connection ~ 8750 2850 556 | Connection ~ 8750 2950 557 | $Comp 558 | L GND #PWR015 559 | U 1 1 5A979174 560 | P 8750 3100 561 | F 0 "#PWR015" H 8750 2850 50 0001 C CNN 562 | F 1 "GND" H 8750 2950 50 0000 C CNN 563 | F 2 "" H 8750 3100 50 0001 C CNN 564 | F 3 "" H 8750 3100 50 0001 C CNN 565 | 1 8750 3100 566 | 1 0 0 -1 567 | $EndComp 568 | Connection ~ 8750 3050 569 | $Comp 570 | L avr_isp CON1 571 | U 1 1 5A97BF85 572 | P 7750 4050 573 | F 0 "CON1" H 7550 4250 50 0000 C CNN 574 | F 1 "avr_isp" V 7900 3800 50 0000 L BNN 575 | F 2 "Connectors:IDC_Header_Straight_6pins" V 7950 4000 50 0001 C CNN 576 | F 3 "" H 7725 4050 50 0001 C CNN 577 | 1 7750 4050 578 | 1 0 0 -1 579 | $EndComp 580 | $Comp 581 | L VCC #PWR016 582 | U 1 1 5A97C03C 583 | P 7750 3800 584 | F 0 "#PWR016" H 7750 3650 50 0001 C CNN 585 | F 1 "VCC" H 7750 3950 50 0000 C CNN 586 | F 2 "" H 7750 3800 50 0001 C CNN 587 | F 3 "" H 7750 3800 50 0001 C CNN 588 | 1 7750 3800 589 | 1 0 0 -1 590 | $EndComp 591 | $Comp 592 | L GND #PWR017 593 | U 1 1 5A97C077 594 | P 7750 4400 595 | F 0 "#PWR017" H 7750 4150 50 0001 C CNN 596 | F 1 "GND" H 7750 4250 50 0000 C CNN 597 | F 2 "" H 7750 4400 50 0001 C CNN 598 | F 3 "" H 7750 4400 50 0001 C CNN 599 | 1 7750 4400 600 | 1 0 0 -1 601 | $EndComp 602 | Wire Wire Line 603 | 7400 3950 7150 3950 604 | Wire Wire Line 605 | 7400 4050 7150 4050 606 | Wire Wire Line 607 | 7400 4150 7150 4150 608 | Wire Wire Line 609 | 7400 4250 7150 4250 610 | Text Label 7150 4250 0 60 ~ 0 611 | ~RESET 612 | Text Label 7200 3950 0 60 ~ 0 613 | MISO 614 | Text Label 7200 4050 0 60 ~ 0 615 | MOSI 616 | Text Label 7200 4150 0 60 ~ 0 617 | SCK 618 | $Comp 619 | L PWR_FLAG #FLG018 620 | U 1 1 5A97CF41 621 | P 3500 2650 622 | F 0 "#FLG018" H 3500 2725 50 0001 C CNN 623 | F 1 "PWR_FLAG" H 3500 2800 50 0000 C CNN 624 | F 2 "" H 3500 2650 50 0001 C CNN 625 | F 3 "" H 3500 2650 50 0001 C CNN 626 | 1 3500 2650 627 | -1 0 0 1 628 | $EndComp 629 | $Comp 630 | L VCC #PWR019 631 | U 1 1 5A97D29F 632 | P 3500 2650 633 | F 0 "#PWR019" H 3500 2500 50 0001 C CNN 634 | F 1 "VCC" H 3500 2800 50 0000 C CNN 635 | F 2 "" H 3500 2650 50 0001 C CNN 636 | F 3 "" H 3500 2650 50 0001 C CNN 637 | 1 3500 2650 638 | 1 0 0 -1 639 | $EndComp 640 | $Comp 641 | L R R2 642 | U 1 1 5A97FFD8 643 | P 7350 3450 644 | F 0 "R2" V 7430 3450 50 0000 C CNN 645 | F 1 "1k" V 7350 3450 50 0000 C CNN 646 | F 2 "Resistors_SMD:R_0805_HandSoldering" V 7280 3450 50 0001 C CNN 647 | F 3 "" H 7350 3450 50 0001 C CNN 648 | 1 7350 3450 649 | 0 1 1 0 650 | $EndComp 651 | Connection ~ 7200 3450 652 | $Comp 653 | L VCC #PWR020 654 | U 1 1 5A98009E 655 | P 7500 3450 656 | F 0 "#PWR020" H 7500 3300 50 0001 C CNN 657 | F 1 "VCC" H 7500 3600 50 0000 C CNN 658 | F 2 "" H 7500 3450 50 0001 C CNN 659 | F 3 "" H 7500 3450 50 0001 C CNN 660 | 1 7500 3450 661 | 1 0 0 -1 662 | $EndComp 663 | Connection ~ 7650 2150 664 | Wire Wire Line 665 | 6800 2150 6800 3550 666 | Wire Wire Line 667 | 6750 1850 6750 2150 668 | Wire Wire Line 669 | 6750 1850 6900 1850 670 | Connection ~ 6750 1850 671 | Wire Wire Line 672 | 6200 1950 6200 1700 673 | Wire Wire Line 674 | 6200 1700 6300 1700 675 | $Comp 676 | L R R1 677 | U 1 1 5A981693 678 | P 6750 1700 679 | F 0 "R1" V 6830 1700 50 0000 C CNN 680 | F 1 "330" V 6750 1700 50 0000 C CNN 681 | F 2 "Resistors_SMD:R_0805_HandSoldering" V 6680 1700 50 0001 C CNN 682 | F 3 "" H 6750 1700 50 0001 C CNN 683 | 1 6750 1700 684 | 0 -1 -1 0 685 | $EndComp 686 | $Comp 687 | L LED_Small D1 688 | U 1 1 5A98174A 689 | P 6400 1700 690 | F 0 "D1" H 6250 1750 50 0000 L CNN 691 | F 1 "ACT" H 6450 1750 50 0000 L CNN 692 | F 2 "LEDs:LED_0805" V 6400 1700 50 0001 C CNN 693 | F 3 "" V 6400 1700 50 0001 C CNN 694 | 1 6400 1700 695 | -1 0 0 -1 696 | $EndComp 697 | $Comp 698 | L C_Small C2 699 | U 1 1 5A981C24 700 | P 6650 2150 701 | F 0 "C2" H 6660 2220 50 0000 L CNN 702 | F 1 "22pF" V 6700 1900 50 0000 L CNN 703 | F 2 "Capacitors_SMD:C_0805_HandSoldering" H 6650 2150 50 0001 C CNN 704 | F 3 "" H 6650 2150 50 0001 C CNN 705 | 1 6650 2150 706 | 0 1 1 0 707 | $EndComp 708 | $Comp 709 | L C_Small C1 710 | U 1 1 5A981F76 711 | P 6650 1850 712 | F 0 "C1" H 6660 1920 50 0000 L CNN 713 | F 1 "22pF" V 6600 1600 50 0000 L CNN 714 | F 2 "Capacitors_SMD:C_0805_HandSoldering" H 6650 1850 50 0001 C CNN 715 | F 3 "" H 6650 1850 50 0001 C CNN 716 | 1 6650 1850 717 | 0 1 1 0 718 | $EndComp 719 | Wire Wire Line 720 | 6900 1850 6900 1700 721 | Connection ~ 6900 1850 722 | Wire Wire Line 723 | 6600 1700 6500 1700 724 | $Comp 725 | L CONN_01X04 J6 726 | U 1 1 5A98368D 727 | P 7000 4700 728 | F 0 "J6" H 7000 4950 50 0000 C CNN 729 | F 1 "PWRIN" V 7100 4700 50 0000 C CNN 730 | F 2 "Connectors_Molex:Molex_SPOX-5267_22-03-5045_04x2.54mm_Straight" H 7000 4700 50 0001 C CNN 731 | F 3 "" H 7000 4700 50 0001 C CNN 732 | 1 7000 4700 733 | -1 0 0 1 734 | $EndComp 735 | $Comp 736 | L VCC #PWR021 737 | U 1 1 5A983776 738 | P 7200 4550 739 | F 0 "#PWR021" H 7200 4400 50 0001 C CNN 740 | F 1 "VCC" H 7200 4700 50 0000 C CNN 741 | F 2 "" H 7200 4550 50 0001 C CNN 742 | F 3 "" H 7200 4550 50 0001 C CNN 743 | 1 7200 4550 744 | 1 0 0 -1 745 | $EndComp 746 | $Comp 747 | L +12V #PWR022 748 | U 1 1 5A9839E4 749 | P 7500 4850 750 | F 0 "#PWR022" H 7500 4700 50 0001 C CNN 751 | F 1 "+12V" H 7500 4990 50 0000 C CNN 752 | F 2 "" H 7500 4850 50 0001 C CNN 753 | F 3 "" H 7500 4850 50 0001 C CNN 754 | 1 7500 4850 755 | 1 0 0 -1 756 | $EndComp 757 | Wire Wire Line 758 | 7200 4750 7200 4650 759 | $Comp 760 | L GND #PWR023 761 | U 1 1 5A983BDC 762 | P 7300 4650 763 | F 0 "#PWR023" H 7300 4400 50 0001 C CNN 764 | F 1 "GND" H 7300 4500 50 0000 C CNN 765 | F 2 "" H 7300 4650 50 0001 C CNN 766 | F 3 "" H 7300 4650 50 0001 C CNN 767 | 1 7300 4650 768 | 1 0 0 -1 769 | $EndComp 770 | Wire Wire Line 771 | 7200 4650 7300 4650 772 | Connection ~ 7200 4650 773 | Wire Wire Line 774 | 7200 4850 7500 4850 775 | $Comp 776 | L +12V #PWR024 777 | U 1 1 5A983DBE 778 | P 8300 3950 779 | F 0 "#PWR024" H 8300 3800 50 0001 C CNN 780 | F 1 "+12V" H 8300 4090 50 0000 C CNN 781 | F 2 "" H 8300 3950 50 0001 C CNN 782 | F 3 "" H 8300 3950 50 0001 C CNN 783 | 1 8300 3950 784 | 1 0 0 -1 785 | $EndComp 786 | Wire Wire Line 787 | 8300 3950 8150 3950 788 | Wire Wire Line 789 | 8150 3950 8150 3700 790 | $Comp 791 | L PWR_FLAG #FLG025 792 | U 1 1 5A98668E 793 | P 7400 4850 794 | F 0 "#FLG025" H 7400 4925 50 0001 C CNN 795 | F 1 "PWR_FLAG" H 7400 5000 50 0000 C CNN 796 | F 2 "" H 7400 4850 50 0001 C CNN 797 | F 3 "" H 7400 4850 50 0001 C CNN 798 | 1 7400 4850 799 | -1 0 0 1 800 | $EndComp 801 | Connection ~ 7400 4850 802 | $Comp 803 | L USB_OTG J7 804 | U 1 1 5A993665 805 | P 3500 6000 806 | F 0 "J7" H 3300 6450 50 0000 L CNN 807 | F 1 "USB_OTG" H 3300 6350 50 0000 L CNN 808 | F 2 "Connectors:USB_Mini-B" H 3650 5950 50 0001 C CNN 809 | F 3 "" H 3650 5950 50 0001 C CNN 810 | 1 3500 6000 811 | 1 0 0 -1 812 | $EndComp 813 | Wire Wire Line 814 | 3400 6400 3500 6400 815 | $Comp 816 | L GND #PWR026 817 | U 1 1 5A993B44 818 | P 3500 6400 819 | F 0 "#PWR026" H 3500 6150 50 0001 C CNN 820 | F 1 "GND" H 3500 6250 50 0000 C CNN 821 | F 2 "" H 3500 6400 50 0001 C CNN 822 | F 3 "" H 3500 6400 50 0001 C CNN 823 | 1 3500 6400 824 | 1 0 0 -1 825 | $EndComp 826 | Wire Wire Line 827 | 3800 5800 3850 5800 828 | Wire Wire Line 829 | 3850 5800 3850 4850 830 | Wire Wire Line 831 | 3850 4850 3800 4850 832 | Wire Wire Line 833 | 3800 4850 3800 4750 834 | Connection ~ 3800 4750 835 | Wire Wire Line 836 | 4000 5050 4000 6100 837 | Wire Wire Line 838 | 4000 6100 3800 6100 839 | Connection ~ 4000 5050 840 | Wire Wire Line 841 | 3950 4950 3950 6000 842 | Wire Wire Line 843 | 3950 6000 3800 6000 844 | Connection ~ 3950 4950 845 | NoConn ~ 3800 6200 846 | $EndSCHEMATC 847 | -------------------------------------------------------------------------------- /fw/src/avrfloppy.c: -------------------------------------------------------------------------------- 1 | /* USB floppy controller for amiga disks 2 | * 3 | * Copyright (C) 2017-2018 Robert Smith (@RobSmithDev) 4 | * Copyright (C) 2018 John Tsiombikas 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 3 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Library General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Library General Public 17 | * License along with this program; if not, see http://www.gnu.org/licenses 18 | */ 19 | /* Ported from arduino to standalone AVR by John Tsiombikas */ 20 | 21 | #include 22 | #include 23 | 24 | 25 | #define INDEX_PORT PIND 26 | #define INDEX_BIT 0x04 27 | 28 | #define WDATA_PORT PORTD 29 | #define WDATA_BIT 0x08 30 | 31 | #define RDATA_PORT PIND 32 | #define RDATA_BIT 0x10 33 | 34 | #define MOTOR_PORT PORTD 35 | #define MOTOR_ENABLE_BIT 0x20 36 | #define MOTOR_DIR_BIT 0x40 37 | #define MOTOR_STEP_BIT 0x80 38 | 39 | #define TRACK0_PORT PINB 40 | #define TRACK0_BIT 0x01 41 | 42 | #define HEADSEL_PORT PORTB 43 | #define HEAD_SELECT_BIT 0x02 44 | 45 | #define WGATE_PORT PORTC 46 | #define WGATE_BIT 0x01 47 | 48 | #define WPROT_PORT PINC 49 | #define WPROT_BIT 0x02 50 | 51 | #define CTS_PORT PORTC 52 | #define CTS_BIT 0x04 53 | 54 | #define LED_PORT PORTB 55 | #define LED_BIT 0x20 56 | 57 | #define BAUDRATE 2000000 58 | 59 | #define BAUD_PRESCALLER_NORMAL_MODE (((F_CPU / (BAUDRATE * 16UL))) - 1) 60 | #define BAUD_PRESCALLER_DOUBLESPEED_MODE (((F_CPU / (BAUDRATE * 8UL))) - 1) 61 | /* We're using double speed mode */ 62 | #define UART_USE_DOUBLESPEED_MODE 63 | 64 | /* Motor directions for PIN settings */ 65 | #define MOTOR_TRACK_DECREASE 1 66 | #define MOTOR_TRACK_INCREASE 0 67 | #define MOTOR_DIR(x) ((x) ? (MOTOR_PORT |= MOTOR_DIR_BIT) : (MOTOR_PORT &= ~MOTOR_DIR_BIT)) 68 | 69 | /* Paula on the Amiga used to find the SYNC WORDS and then read 0x1900 further WORDS. 70 | * A dos track is 11968 bytes in size, theritical revolution is 12800 bytes. 71 | * Paula assumed it was 12868 bytes, so we read that, plus thre size of a sectors 72 | */ 73 | #define RAW_TRACKDATA_LENGTH (0x1900 * 2 + 0x440) 74 | 75 | static void setup(void); 76 | static void loop(void); 77 | static void smalldelay(unsigned long delay_time); 78 | static void step_direction_head(void); 79 | static void prep_serial_interface(void); 80 | static inline unsigned char read_byte_from_uart(void); 81 | static inline void write_byte_to_uart(const char value); 82 | static int goto_track0(void); 83 | static int goto_track_x(void); 84 | static void write_track_from_uart(void); 85 | static void erase_track(void); 86 | static void read_track_data_fast(void); 87 | static void run_diagnostic(void); 88 | 89 | static int current_track; /* The current track that the head is over */ 90 | static int drive_enabled; /* If the drive has been switched on or not */ 91 | static int in_write_mode; /* If we're in WRITING mode or not */ 92 | 93 | int main(void) 94 | { 95 | setup(); 96 | for(;;) { 97 | loop(); 98 | } 99 | return 0; 100 | } 101 | 102 | static void setup(void) 103 | { 104 | DDRB = 0x22; /* outputs: 1 (head sel), 5 (act LED) */ 105 | DDRC = 0xf5; /* outputs: 0 (wr.gate), 2 (cts) */ 106 | DDRD = 0xe8; /* outputs: 3 (write), 5 (motor en), 6 (dir), 7 (step) */ 107 | 108 | /* Do these right away to prevent the disk being written to */ 109 | PORTC = WGATE_BIT | WPROT_BIT; /* write gate off and pullup on pin 1 (wprot) */ 110 | PORTD = WDATA_BIT | RDATA_BIT; /* write data hight and pullup on pin 4 (read) */ 111 | PORTB = TRACK0_BIT; /* pullup on track0 detect */ 112 | 113 | MOTOR_PORT |= MOTOR_ENABLE_BIT; 114 | HEADSEL_PORT &= ~HEAD_SELECT_BIT; 115 | 116 | /* Disable all interrupts - we dont want them! */ 117 | cli(); 118 | 119 | /* Setup the USART */ 120 | prep_serial_interface(); 121 | } 122 | 123 | 124 | /* The main command loop */ 125 | static void loop(void) 126 | { 127 | unsigned char command; 128 | 129 | CTS_PORT &= ~CTS_BIT; /* Allow data incoming */ 130 | WGATE_PORT |= WGATE_BIT; /* always turn writing off */ 131 | 132 | /* Read the command from the PC */ 133 | command = read_byte_from_uart(); 134 | 135 | switch(command) { 136 | case '?': 137 | /* Command: "?" Means information about the firmware */ 138 | write_byte_to_uart('1'); /* Success */ 139 | write_byte_to_uart('V'); /* Followed */ 140 | write_byte_to_uart('1'); /* By */ 141 | write_byte_to_uart('.'); /* Version */ 142 | write_byte_to_uart('3'); /* Number */ 143 | break; 144 | 145 | /* Command "." means go back to track 0 */ 146 | case '.': 147 | if(!drive_enabled) { 148 | write_byte_to_uart('0'); 149 | } else { 150 | if(goto_track0() != -1) { /* reset */ 151 | write_byte_to_uart('1'); 152 | } else { 153 | write_byte_to_uart('#'); 154 | } 155 | } 156 | break; 157 | 158 | case '#': 159 | /* Command "#" means goto track. Should be formatted as #00 or #32 etc */ 160 | if(!drive_enabled) { 161 | read_byte_from_uart(); 162 | read_byte_from_uart(); 163 | write_byte_to_uart('0'); 164 | } else { 165 | if(goto_track_x()) { 166 | smalldelay(100); /* wait for drive */ 167 | write_byte_to_uart('1'); 168 | } else { 169 | write_byte_to_uart('0'); 170 | } 171 | } 172 | break; 173 | 174 | case '[': 175 | /* Command "[" select LOWER disk side */ 176 | HEADSEL_PORT &= ~HEAD_SELECT_BIT; 177 | write_byte_to_uart('1'); 178 | break; 179 | 180 | case ']': 181 | /* Command "]" select UPPER disk side */ 182 | HEADSEL_PORT |= HEAD_SELECT_BIT; 183 | write_byte_to_uart('1'); 184 | break; 185 | 186 | case '<': 187 | /* Command "<" Read track from the drive */ 188 | if(!drive_enabled) { 189 | write_byte_to_uart('0'); 190 | } else { 191 | write_byte_to_uart('1'); 192 | read_track_data_fast(); 193 | } 194 | break; 195 | 196 | case '>': 197 | /* Command ">" Write track to the drive */ 198 | if(!drive_enabled) { 199 | write_byte_to_uart('0'); 200 | } else { 201 | if(!in_write_mode) { 202 | write_byte_to_uart('0'); 203 | } else { 204 | write_byte_to_uart('1'); 205 | write_track_from_uart(); 206 | } 207 | } 208 | break; 209 | 210 | case 'X': 211 | /* command "X" Erase current track (writes 0xAA to it) */ 212 | if(!drive_enabled) { 213 | write_byte_to_uart('0'); 214 | } else { 215 | if(!in_write_mode) { 216 | write_byte_to_uart('0'); 217 | } else { 218 | write_byte_to_uart('1'); 219 | erase_track(); 220 | } 221 | } 222 | break; 223 | 224 | case '-': 225 | /* Turn off the drive motor */ 226 | MOTOR_PORT |= MOTOR_ENABLE_BIT; 227 | WGATE_PORT |= WGATE_BIT; 228 | drive_enabled = 0; 229 | write_byte_to_uart('1'); 230 | in_write_mode = 0; 231 | break; 232 | 233 | case '+': 234 | /* Turn on the drive motor and setup in READ MODE */ 235 | if(in_write_mode) { 236 | /* Ensure writing is turned off */ 237 | MOTOR_PORT |= MOTOR_ENABLE_BIT; 238 | WGATE_PORT |= WGATE_BIT; 239 | smalldelay(100); 240 | drive_enabled = 0; 241 | in_write_mode = 0; 242 | } 243 | if(!drive_enabled) { 244 | MOTOR_PORT &= ~MOTOR_ENABLE_BIT; 245 | drive_enabled = 1; 246 | smalldelay(750); /* wait for drive */ 247 | } 248 | write_byte_to_uart('1'); 249 | break; 250 | 251 | case '~': 252 | /* Turn on the drive motor and setup in WRITE MODE */ 253 | if(drive_enabled) { 254 | WGATE_PORT |= WGATE_BIT; 255 | MOTOR_PORT |= MOTOR_ENABLE_BIT; 256 | drive_enabled = 0; 257 | smalldelay(100); 258 | } 259 | /* We're writing! */ 260 | WGATE_PORT &= ~WGATE_BIT; 261 | /* Gate has to be pulled LOW BEFORE we turn the drive on */ 262 | MOTOR_PORT &= ~MOTOR_ENABLE_BIT; 263 | /* Raise the write gate again */ 264 | WGATE_PORT |= WGATE_BIT; 265 | smalldelay(750); /* wait for drive */ 266 | 267 | /* At this point we can see the status of the write protect flag */ 268 | if((WPROT_PORT & WPROT_BIT) == 0) { 269 | write_byte_to_uart('0'); 270 | in_write_mode = 0; 271 | MOTOR_PORT |= MOTOR_ENABLE_BIT; 272 | /*WGATE_PORT |= WGATE_BIT;*/ 273 | } else { 274 | in_write_mode = 1; 275 | drive_enabled = 1; 276 | write_byte_to_uart('1'); 277 | } 278 | break; 279 | 280 | case '&': 281 | run_diagnostic(); 282 | break; 283 | 284 | default: 285 | /* We don't recognise the command! */ 286 | write_byte_to_uart('!'); /* error */ 287 | break; 288 | } 289 | } 290 | 291 | 292 | /* Because we turned off interrupts delay() doesnt work! */ 293 | static void smalldelay(unsigned long delay_time) 294 | { 295 | unsigned long i; 296 | 297 | delay_time *= (F_CPU / 9000); 298 | 299 | for(i=0; i>8); 320 | UBRR0L = (uint8_t)(BAUD_PRESCALLER_DOUBLESPEED_MODE); 321 | UCSR0A |= 1<>8); 324 | UBRR0L = (uint8_t)(BAUD_PRESCALLER_NORMAL_MODE); 325 | UCSR0A &= ~(1< 170) { 358 | /* we've stepped twice as much as the maximum possible steps needed, and still 359 | * haven't reached track 0 360 | */ 361 | return -1; 362 | } 363 | } 364 | current_track = 0; /* Reset the track number */ 365 | return 0; 366 | } 367 | 368 | /* Goto a specific track. During testing it was easier for the track number 369 | * to be supplied as two ASCII characters, so I left it like this 370 | */ 371 | static int goto_track_x(void) 372 | { 373 | int track; 374 | unsigned char track1, track2; 375 | 376 | /* Read the bytes */ 377 | track1 = read_byte_from_uart(); 378 | track2 = read_byte_from_uart(); 379 | 380 | /* Validate */ 381 | if((track1 < '0') || (track1 > '9')) return 0; 382 | if((track2 < '0') || (track2 > '9')) return 0; 383 | 384 | /* Calculate target track and validate */ 385 | track = ((track1 - '0') * 10) + (track2 - '0'); 386 | if(track < 0) return 0; 387 | if(track > 81) return 0; /* yes amiga could read track 81! */ 388 | 389 | /* Exit if its already been reached */ 390 | if(track == current_track) return 1; 391 | 392 | /* And step the head until we reach this track number */ 393 | if(current_track < track) { 394 | MOTOR_DIR(MOTOR_TRACK_INCREASE); /* move out */ 395 | while(current_track < track) { 396 | step_direction_head(); 397 | current_track++; 398 | } 399 | } else { 400 | MOTOR_DIR(MOTOR_TRACK_DECREASE); /* move in */ 401 | while(current_track > track) { 402 | step_direction_head(); 403 | current_track--; 404 | } 405 | } 406 | 407 | return 1; 408 | } 409 | 410 | 411 | /* 256 byte circular buffer - 412 | * don't change this, we abuse the unsigned char to overflow back to zero! 413 | */ 414 | #define SERIAL_BUFFER_SIZE 256 415 | #define SERIAL_BUFFER_START (SERIAL_BUFFER_SIZE - 16) 416 | static unsigned char SERIAL_BUFFER[SERIAL_BUFFER_SIZE]; 417 | 418 | 419 | #define CHECK_SERIAL() \ 420 | do { \ 421 | if(UCSR0A & (1 << RXC0)) { \ 422 | SERIAL_BUFFER[serial_write_pos++] = UDR0; \ 423 | serial_bytes_in_use++; \ 424 | } else if(serial_bytes_in_use < SERIAL_BUFFER_START) { \ 425 | CTS_PORT &= ~CTS_BIT; \ 426 | CTS_PORT |= CTS_BIT; \ 427 | } \ 428 | } while(0) 429 | 430 | 431 | 432 | /* Small Macro to write a '1' pulse to the drive if a bit is set based on the supplied bitmask */ 433 | #define WRITE_BIT(value, bitmask) \ 434 | do { \ 435 | if(current_byte & bitmask) { \ 436 | while(TCNT2 < value); \ 437 | WDATA_PORT &= ~WDATA_BIT; \ 438 | } else { \ 439 | while(TCNT2 < value); \ 440 | WDATA_PORT |= WDATA_BIT; \ 441 | } \ 442 | } while(0) 443 | 444 | /* Write a track to disk from the UART - 445 | * the data should be pre-MFM encoded raw track data where '1's are the 446 | * pulses/phase reversals to trigger 447 | */ 448 | static void write_track_from_uart(void) 449 | { 450 | unsigned int i, serial_bytes_in_use; 451 | unsigned char high_byte, low_byte, wait_for_index, current_byte; 452 | unsigned char serial_read_pos, serial_write_pos; 453 | unsigned short num_bytes; 454 | 455 | /* Configure timer 2 just as a counter in NORMAL mode */ 456 | TCCR2A = 0; /* No physical output port pins and normal operation */ 457 | TCCR2B = (1 << CS20); /* Prescale = 1 */ 458 | 459 | /* Check if its write protected. 460 | * You can only do this after the write gate has been pulled low 461 | */ 462 | if((WPROT_PORT & WPROT_BIT) == 0) { 463 | write_byte_to_uart('N'); 464 | WGATE_PORT |= WGATE_BIT; 465 | return; 466 | } 467 | write_byte_to_uart('Y'); 468 | 469 | /* Find out how many bytes they want to send */ 470 | high_byte = read_byte_from_uart(); 471 | low_byte = read_byte_from_uart(); 472 | wait_for_index = read_byte_from_uart(); 473 | CTS_PORT |= CTS_BIT; /* stop any more data coming in! */ 474 | 475 | num_bytes = (((unsigned short)high_byte) << 8) | low_byte; 476 | 477 | write_byte_to_uart('!'); 478 | 479 | /* Signal we're ready for another byte to come */ 480 | CTS_PORT &= ~CTS_BIT; 481 | 482 | /* Fill our buffer to give us a head start */ 483 | for(i=0; i= 240); 533 | 534 | /* Now we write the data. Hopefully by the time we get back to the top 535 | * everything is ready again 536 | */ 537 | WRITE_BIT(0x10, 0x80); 538 | CHECK_SERIAL(); 539 | WRITE_BIT(0x30, 0x40); 540 | CHECK_SERIAL(); 541 | WRITE_BIT(0x50, 0x20); 542 | CHECK_SERIAL(); 543 | WRITE_BIT(0x70, 0x10); 544 | CHECK_SERIAL(); 545 | WRITE_BIT(0x90, 0x08); 546 | CHECK_SERIAL(); 547 | WRITE_BIT(0xb0, 0x04); 548 | CHECK_SERIAL(); 549 | WRITE_BIT(0xd0, 0x02); 550 | CHECK_SERIAL(); 551 | WRITE_BIT(0xf0, 0x01); 552 | } 553 | WGATE_PORT |= WGATE_BIT; 554 | 555 | /* Done! */ 556 | write_byte_to_uart('1'); 557 | LED_PORT &= ~LED_BIT; 558 | 559 | /* Disable the 500khz signal */ 560 | TCCR2B = 0; /* No Clock (turn off) */ 561 | } 562 | 563 | 564 | static void erase_track(void) 565 | { 566 | int i; 567 | unsigned char current_byte; 568 | 569 | /* configure timer 2 just as a counter in NORMAL mode */ 570 | TCCR2A = 0; /* no physical output port pins and normal operation */ 571 | TCCR2B = (1 << CS20); /* prescale = 1 */ 572 | 573 | /* check if it's write protected */ 574 | if((WPROT_PORT & WPROT_BIT) == 0) { 575 | write_byte_to_uart('N'); 576 | WGATE_PORT |= WGATE_BIT; 577 | return; 578 | } 579 | write_byte_to_uart('Y'); 580 | 581 | LED_PORT |= LED_BIT; 582 | 583 | /* enable writing */ 584 | WGATE_PORT &= ~WGATE_BIT; 585 | 586 | /* reset the counter, ready for writing */ 587 | TCNT2 = 0; 588 | current_byte = 0xaa; 589 | 590 | /* write complete blank track - at 300rpm, 500kbps, a track takes approx 1/5 591 | * second to write. this is roughly 12500 bytes. our RAW read is 13888 bytes, 592 | * so we'll use that just to make sure we get every last bit. 593 | */ 594 | for(i=0; i= 240); 605 | } 606 | 607 | /* turn the write head off */ 608 | WGATE_PORT |= WGATE_BIT; 609 | 610 | /* done! */ 611 | write_byte_to_uart('1'); 612 | LED_PORT &= ~LED_BIT; 613 | 614 | /* disable the 500khz signal */ 615 | TCCR2B = 0; /* no clock (turn off) */ 616 | } 617 | 618 | 619 | /* Read the track using a timings to calculate which MFM sequence has been triggered */ 620 | static void read_track_data_fast(void) 621 | { 622 | unsigned char data_output_byte, counter, bits; 623 | long total_bits, target; 624 | 625 | /* Configure timer 2 just as a counter in NORMAL mode */ 626 | TCCR2A = 0; /* No physical output port pins and normal operation */ 627 | TCCR2B = (1 << CS20); /* Prescale = 1 */ 628 | 629 | /* First wait for the serial port to be available */ 630 | while(!(UCSR0A & (1 << UDRE0))); 631 | 632 | /* Signal we're active */ 633 | LED_PORT |= LED_BIT; 634 | 635 | /* While the INDEX pin is high wait if the other end requires us to */ 636 | if(read_byte_from_uart()) { 637 | while(INDEX_PORT & INDEX_BIT); 638 | } 639 | 640 | /* Prepare the two counter values as follows: */ 641 | TCNT2=0; /* Reset the counter */ 642 | 643 | data_output_byte = 0; 644 | total_bits = 0; 645 | target = (long)RAW_TRACKDATA_LENGTH * 8L; 646 | 647 | while(total_bits < target) { 648 | for(bits=0; bits<4; bits++) { 649 | /* Wait while pin is high */ 650 | 651 | while(RDATA_PORT & RDATA_BIT); 652 | counter = TCNT2; 653 | TCNT2 = 0; /* reset */ 654 | 655 | data_output_byte <<= 2; 656 | 657 | if(counter < 80) { 658 | data_output_byte |= 1; 659 | total_bits += 2; 660 | } else if(counter > 111) { 661 | /* this accounts for just a '1' or a '01' as two '1' arent allowed in a row */ 662 | data_output_byte |= 3; 663 | total_bits += 4; 664 | } else { 665 | data_output_byte |= 2; 666 | total_bits += 3; 667 | } 668 | 669 | /* Wait until pin is high again */ 670 | while(!(RDATA_PORT & RDATA_BIT)); 671 | } 672 | UDR0 = data_output_byte; 673 | } 674 | /* Because of the above rules the actual valid two-bit sequences output 675 | * are 01, 10 and 11, so we use 00 to say "END OF DATA" 676 | */ 677 | write_byte_to_uart(0); 678 | 679 | /* turn off the status LED */ 680 | LED_PORT &= ~LED_BIT; 681 | 682 | /* Disable the counter */ 683 | TCCR2B = 0; /* No Clock (turn off) */ 684 | } 685 | 686 | static void run_diagnostic(void) 687 | { 688 | int i, state1, state2, res; 689 | char test; 690 | 691 | test = read_byte_from_uart(); 692 | switch(test) { 693 | case '1': /* turn off CTS */ 694 | CTS_PORT &= ~CTS_BIT; 695 | write_byte_to_uart('1'); 696 | read_byte_from_uart(); 697 | write_byte_to_uart('1'); 698 | break; 699 | 700 | case '2': /* turn on CTS */ 701 | CTS_PORT |= CTS_BIT; 702 | write_byte_to_uart('1'); 703 | read_byte_from_uart(); 704 | write_byte_to_uart('1'); 705 | break; 706 | 707 | case '3': /* index pulse test (with timeout) */ 708 | state1 = state2 = res = 0; 709 | 710 | /* At the 300 RPM (5 turns per second) this runs at, this loop needs to 711 | * run a few times to check for index pulses. This runs for approx 1 sec 712 | */ 713 | for(i=0; i<20 * 60000; i++) { 714 | if(INDEX_PORT & INDEX_BIT) { 715 | state1 = 1; 716 | } else { 717 | state2 = 1; 718 | } 719 | if(state1 && state2) { 720 | res = 1; 721 | break; 722 | } 723 | } 724 | write_byte_to_uart(res ? '1' : '0'); 725 | break; 726 | 727 | case '4': /* data pulse test (with timeout) */ 728 | state1 = state2 = res = 0; 729 | 730 | for(i=0; i<20 * 60000; i++) { 731 | if(RDATA_PORT & RDATA_BIT) { 732 | state1 = 1; 733 | } else { 734 | state2 = 1; 735 | } 736 | if(state1 && state2) { 737 | res = 1; 738 | break; 739 | } 740 | } 741 | 742 | write_byte_to_uart(res ? '1' : '0'); 743 | break; 744 | 745 | default: 746 | write_byte_to_uart('0'); 747 | break; 748 | } 749 | } 750 | -------------------------------------------------------------------------------- /LICENSE.sw: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------