├── utils ├── eeprom.bin ├── eeprom.bin.bak ├── passwords.txt ├── password_rules.txt └── pass2bin.py ├── LICENCE.txt ├── README.md ├── .gitattributes ├── firmware ├── bootloader │ ├── firmware │ │ ├── usbdrv │ │ │ ├── usbdrvasm.asm │ │ │ ├── oddebug.c │ │ │ ├── oddebug.h │ │ │ ├── usbportability.h │ │ │ ├── USB-ID-FAQ.txt │ │ │ ├── USB-IDs-for-free.txt │ │ │ ├── CommercialLicense.txt │ │ │ ├── asmcommon.inc │ │ │ ├── Readme.txt │ │ │ ├── usbdrvasm.S │ │ │ └── usbdrvasm16.inc │ │ ├── Makefile │ │ ├── bootloaderconfig.h │ │ └── main.c │ ├── Changelog.txt │ └── Readme.txt └── device │ ├── usbdrv │ ├── usbdrvasm.asm │ ├── oddebug.c │ ├── oddebug.h │ ├── usbportability.h │ ├── USB-ID-FAQ.txt │ ├── USB-IDs-for-free.txt │ ├── CommercialLicense.txt │ ├── asmcommon.inc │ ├── Readme.txt │ ├── usbconfig3.h │ └── usbdrvasm.S │ ├── Makefile │ └── 7segments.h ├── circuit ├── Key_Pass.drd ├── Key_Pass.dri ├── Key_Pass.gpi ├── BOM.txt ├── Key_Pass.stc └── Key_Pass.sts └── .gitignore /utils/eeprom.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Danjovic/PassKey/HEAD/utils/eeprom.bin -------------------------------------------------------------------------------- /utils/eeprom.bin.bak: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Danjovic/PassKey/HEAD/utils/eeprom.bin.bak -------------------------------------------------------------------------------- /LICENCE.txt: -------------------------------------------------------------------------------- 1 | # License 2 | 3 | All Hardware is licensed under The TAPR Open Hardware License. 4 | See http://www.tapr.org/TAPR_Open_Hardware_License_v1.0.txt 5 | 6 | All software/firmware is licensed under GPL V3.0 7 | See http://www.gnu.org/licenses/gpl-3.0.en.html -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PassKey 2 | Keychain USB multiple password manager/generator/injector 3 | 4 | This project provides an usb device to stor passwords that can be sent to your PC like keystrokes. 5 | It was inspired by USB Key Generator by Code & Life, and therefore is also based on AVR and V-USB. 6 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /firmware/bootloader/firmware/usbdrv/usbdrvasm.asm: -------------------------------------------------------------------------------- 1 | /* Name: usbdrvasm.asm 2 | * Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers 3 | * Author: Christian Starkjohann 4 | * Creation Date: 2006-03-01 5 | * Tabsize: 4 6 | * Copyright: (c) 2006 by OBJECTIVE DEVELOPMENT Software GmbH 7 | * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) 8 | */ 9 | 10 | /* 11 | General Description: 12 | The IAR compiler/assembler system prefers assembler files with file extension 13 | ".asm". We simply provide this file as an alias for usbdrvasm.S. 14 | 15 | Thanks to Oleg Semyonov for his help with the IAR tools port! 16 | */ 17 | 18 | #include "usbdrvasm.S" 19 | 20 | end 21 | -------------------------------------------------------------------------------- /firmware/device/usbdrv/usbdrvasm.asm: -------------------------------------------------------------------------------- 1 | /* Name: usbdrvasm.asm 2 | * Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers 3 | * Author: Christian Starkjohann 4 | * Creation Date: 2006-03-01 5 | * Tabsize: 4 6 | * Copyright: (c) 2006 by OBJECTIVE DEVELOPMENT Software GmbH 7 | * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) 8 | * This Revision: $Id$ 9 | */ 10 | 11 | /* 12 | General Description: 13 | The IAR compiler/assembler system prefers assembler files with file extension 14 | ".asm". We simply provide this file as an alias for usbdrvasm.S. 15 | 16 | Thanks to Oleg Semyonov for his help with the IAR tools port! 17 | */ 18 | 19 | #include "usbdrvasm.S" 20 | 21 | end 22 | -------------------------------------------------------------------------------- /circuit/Key_Pass.drd: -------------------------------------------------------------------------------- 1 | % 2 | M48 3 | M72 4 | T01C0.01969 5 | T02C0.03150 6 | T03C0.03622 7 | T04C0.04000 8 | T05C0.04528 9 | T06C0.05900 10 | T07C0.11811 11 | % 12 | T01 13 | X107203Y79835 14 | X110953Y93585 15 | X110953Y101085 16 | X110953Y108585 17 | X110953Y113585 18 | X95953Y108585 19 | X78453Y107335 20 | T02 21 | X67347Y95764 22 | X74418Y88693 23 | X81489Y81622 24 | X88561Y74551 25 | X95632Y67480 26 | X138058Y109906 27 | X130987Y116977 28 | X123916Y124048 29 | X116845Y131119 30 | X109774Y138190 31 | T03 32 | X53556Y85981 33 | X65805Y85425 34 | X72765Y78465 35 | X78333Y72897 36 | X85292Y65937 37 | X85849Y53688 38 | T04 39 | X121874Y55077 40 | X134461Y67663 41 | X67531Y134593 42 | X54945Y122006 43 | T05 44 | X75966Y63571 45 | X63439Y76099 46 | T06 47 | X58409Y111612 48 | X77926Y131128 49 | X130996Y78058 50 | X111480Y58542 51 | T07 52 | X134703Y134835 53 | M30 54 | -------------------------------------------------------------------------------- /utils/passwords.txt: -------------------------------------------------------------------------------- 1 | #################################################### 2 | # Example of legacy passord file for Key Pass # 3 | # # 4 | # ATTENTION # 5 | # DELETE THIS FILE AFTER UPLOADING # 6 | # # 7 | # # 8 | # Read 'password_rules.txt' for more info. # 9 | # # 10 | #################################################### 11 | 111 12 | 123456789012 13 | %%% This is the starting mark 14 | 123456 characters after 12th will be ignored 15 | 16 | password blank lines like above and below too 17 | 18 | admin trailing spaces on comment line too 19 | 0000 20 | admin you can use this space to describe your 21 | 1qaz2wsx passwords but I highly discourage this 22 | 12characters 23 | hackaday # this password will have a at the end 24 | 25 | ZX-81.Rulz this is the 10th password 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /firmware/bootloader/Changelog.txt: -------------------------------------------------------------------------------- 1 | This file documents changes in the firmware of USBaspLoader. 2 | New entries are always appended to the end of the file. Scroll down to the 3 | bottom to see the most recent changes. 4 | 5 | 6 | * Release 2008-01-21 7 | 8 | - Use most recent driver. 9 | 10 | * Release 2008-02-05 11 | 12 | - Disable USB interrupt before we jump to loaded application. Applications 13 | which don't use INT0 would otherwise crash when they perform sei(). 14 | - Revert all config changes to RESET condition before we jump to application. 15 | - Code size optimizations suggested by Alexander Neumann. 16 | 17 | * Release 2009-03-20 18 | 19 | - Added some optimizations so that the boot loader can be used with gcc 4.3. 20 | - Added fuse options (as comments) for ATMega328p to Makefile and include in 21 | precompiled hex files. 22 | - Updated usbconfig.h to the latest template (mostly new comments). 23 | 24 | * Release 2010-07-27 25 | 26 | - Updated to latest driver, using gcc 4.6.2. This saves a couple of bytes, so 27 | that we can include EEPROM support in more configurations. 28 | 29 | * Release 2012-12-08 30 | -------------------------------------------------------------------------------- /circuit/Key_Pass.dri: -------------------------------------------------------------------------------- 1 | Generated by EAGLE CAM Processor 7.2.0 2 | 3 | Drill Station Info File: C:/Users/user/Documents/GitHub/PassKey/circuit/Eagle/Key_Pass.dri 4 | 5 | Date : 28/11/2015 11:36:05 6 | Drills : generated 7 | Device : Excellon drill station, coordinate format 2.5 inch 8 | 9 | Parameter settings: 10 | 11 | Tolerance Drill + : 2.50 % 12 | Tolerance Drill - : 2.50 % 13 | Rotate : no 14 | Mirror : no 15 | Optimize : yes 16 | Auto fit : yes 17 | OffsetX : 0inch 18 | OffsetY : 0inch 19 | Layers : Drills Holes Milling 20 | 21 | Drill File Info: 22 | 23 | Data Mode : Absolute 24 | Units : 1/100000 Inch 25 | 26 | Drills used: 27 | 28 | Code Size used 29 | 30 | T01 0.0197inch 7 31 | T02 0.0315inch 10 32 | T03 0.0362inch 6 33 | T04 0.0400inch 4 34 | T05 0.0453inch 2 35 | T06 0.0590inch 4 36 | T07 0.1181inch 1 37 | 38 | Total number of drills: 34 39 | 40 | Plotfiles: 41 | 42 | C:/Users/user/Documents/GitHub/PassKey/circuit/Eagle/Key_Pass.drd 43 | -------------------------------------------------------------------------------- /firmware/bootloader/firmware/usbdrv/oddebug.c: -------------------------------------------------------------------------------- 1 | /* Name: oddebug.c 2 | * Project: AVR library 3 | * Author: Christian Starkjohann 4 | * Creation Date: 2005-01-16 5 | * Tabsize: 4 6 | * Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH 7 | * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) 8 | */ 9 | 10 | #include "oddebug.h" 11 | 12 | #if DEBUG_LEVEL > 0 13 | 14 | #warning "Never compile production devices with debugging enabled" 15 | 16 | static void uartPutc(char c) 17 | { 18 | while(!(ODDBG_USR & (1 << ODDBG_UDRE))); /* wait for data register empty */ 19 | ODDBG_UDR = c; 20 | } 21 | 22 | static uchar hexAscii(uchar h) 23 | { 24 | h &= 0xf; 25 | if(h >= 10) 26 | h += 'a' - (uchar)10 - '0'; 27 | h += '0'; 28 | return h; 29 | } 30 | 31 | static void printHex(uchar c) 32 | { 33 | uartPutc(hexAscii(c >> 4)); 34 | uartPutc(hexAscii(c)); 35 | } 36 | 37 | void odDebug(uchar prefix, uchar *data, uchar len) 38 | { 39 | printHex(prefix); 40 | uartPutc(':'); 41 | while(len--){ 42 | uartPutc(' '); 43 | printHex(*data++); 44 | } 45 | uartPutc('\r'); 46 | uartPutc('\n'); 47 | } 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /firmware/device/usbdrv/oddebug.c: -------------------------------------------------------------------------------- 1 | /* Name: oddebug.c 2 | * Project: AVR library 3 | * Author: Christian Starkjohann 4 | * Creation Date: 2005-01-16 5 | * Tabsize: 4 6 | * Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH 7 | * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) 8 | * This Revision: $Id$ 9 | */ 10 | 11 | #include "oddebug.h" 12 | 13 | #if DEBUG_LEVEL > 0 14 | 15 | #warning "Never compile production devices with debugging enabled" 16 | 17 | static void uartPutc(char c) 18 | { 19 | while(!(ODDBG_USR & (1 << ODDBG_UDRE))); /* wait for data register empty */ 20 | ODDBG_UDR = c; 21 | } 22 | 23 | static uchar hexAscii(uchar h) 24 | { 25 | h &= 0xf; 26 | if(h >= 10) 27 | h += 'a' - (uchar)10 - '0'; 28 | h += '0'; 29 | return h; 30 | } 31 | 32 | static void printHex(uchar c) 33 | { 34 | uartPutc(hexAscii(c >> 4)); 35 | uartPutc(hexAscii(c)); 36 | } 37 | 38 | void odDebug(uchar prefix, uchar *data, uchar len) 39 | { 40 | printHex(prefix); 41 | uartPutc(':'); 42 | while(len--){ 43 | uartPutc(' '); 44 | printHex(*data++); 45 | } 46 | uartPutc('\r'); 47 | uartPutc('\n'); 48 | } 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Object files 2 | *.o 3 | *.ko 4 | *.obj 5 | *.elf 6 | 7 | # Precompiled Headers 8 | *.gch 9 | *.pch 10 | 11 | # Libraries 12 | *.lib 13 | *.a 14 | *.la 15 | *.lo 16 | 17 | # Shared objects (inc. Windows DLLs) 18 | *.dll 19 | *.so 20 | *.so.* 21 | *.dylib 22 | 23 | # Executables 24 | *.exe 25 | *.out 26 | *.app 27 | *.i*86 28 | *.x86_64 29 | *.hex 30 | 31 | # ========================= 32 | # Operating System Files 33 | # ========================= 34 | 35 | # OSX 36 | # ========================= 37 | 38 | .DS_Store 39 | .AppleDouble 40 | .LSOverride 41 | 42 | # Thumbnails 43 | ._* 44 | 45 | # Files that might appear on external disk 46 | .Spotlight-V100 47 | .Trashes 48 | 49 | # Directories potentially created on remote AFP share 50 | .AppleDB 51 | .AppleDesktop 52 | Network Trash Folder 53 | Temporary Items 54 | .apdisk 55 | 56 | # Windows 57 | # ========================= 58 | 59 | # Windows image file caches 60 | Thumbs.db 61 | ehthumbs.db 62 | 63 | # Folder config file 64 | Desktop.ini 65 | 66 | # Recycle Bin used on file shares 67 | $RECYCLE.BIN/ 68 | 69 | # Windows Installer files 70 | *.cab 71 | *.msi 72 | *.msm 73 | *.msp 74 | 75 | # Windows shortcuts 76 | *.lnk 77 | 78 | #Eagle temp files 79 | *.b#* 80 | *.s#* 81 | *.l#* 82 | -------------------------------------------------------------------------------- /firmware/device/Makefile: -------------------------------------------------------------------------------- 1 | # WinAVR cross-compiler toolchain is used here 2 | CC = avr-gcc 3 | OBJCOPY = avr-objcopy 4 | DUDE = avrdude 5 | 6 | # If you are not using ATtiny85 and the USBtiny programmer, 7 | # update the lines below to match your configuration 8 | CFLAGS = -Wall -Os -Iusbdrv -mmcu=atmega8 -DF_CPU=16000000 9 | OBJFLAGS = -j .text -j .data -O ihex 10 | DUDEFLAGS = -p m8 -c usbasp -v 11 | 12 | # Object files for the firmware (usbdrv/oddebug.o not strictly needed I think) 13 | OBJECTS = usbdrv/usbdrv.o usbdrv/oddebug.o usbdrv/usbdrvasm.o main.o 14 | 15 | # By default, build the firmware and command-line client, but do not flash 16 | all: main.hex 17 | 18 | # With this, you can flash the firmware by just typing "make flash" on command-line 19 | program: main.hex 20 | $(DUDE) $(DUDEFLAGS) -U flash:w:$< 21 | 22 | 23 | 24 | eeprom: main.eep 25 | $(DUDE) $(DUDEFLAGS) -U eeprom:w:$< 26 | 27 | # Housekeeping if you want it 28 | clean: 29 | $(RM) *.o *.hex *.elf usbdrv/*.o 30 | 31 | # From .elf file to .hex 32 | %.hex: %.elf 33 | $(OBJCOPY) $(OBJFLAGS) $< $@ 34 | 35 | # Main.elf requires additional objects to the firmware, not just main.o 36 | main.elf: $(OBJECTS) 37 | $(CC) $(CFLAGS) $(OBJECTS) -o $@ 38 | 39 | # Without this dependance, .o files will not be recompiled if you change 40 | # the config! I spent a few hours debugging because of this... 41 | $(OBJECTS): usbdrv/usbconfig.h 42 | 43 | # From C source to .o object file 44 | %.o: %.c 45 | $(CC) $(CFLAGS) -c $< -o $@ 46 | 47 | # From assembler source to .o object file 48 | %.o: %.S 49 | $(CC) $(CFLAGS) -x assembler-with-cpp -c $< -o $@ 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /utils/password_rules.txt: -------------------------------------------------------------------------------- 1 | ################################################################ 2 | # Project Key Pass # 3 | # Daniel Jose Viana, 2015 - danjovic@hotmail.com # 4 | ################################################################ 5 | # Rules for text file with legacy passwords: # 6 | # # 7 | # - Filename must be passwords.txt # 8 | # - One password per line # 9 | # - Maximum length 12 characters. # 10 | # - If the 13th character on a line is a "#" then a carriage # 11 | # return will be added. This rule is incompatible with # 12 | # passwords with trailing spaces. # 13 | # - Maximum 10 passwords # 14 | # - Blank lines will be ignored # 15 | # - Lines before a starting mark will be ignored # 16 | # - Blank lines will be ignored # 17 | # - The starting mark is a tripple percent signal at the # 18 | # beginning of a line # 19 | # - Valid Character set: a..z A..Z 0..9 . _ - (space) # 20 | # - Trailing spaces will be ignored when the line length is # 21 | # greater than 12 charactes. if your password has trailing # 22 | # spaces leave blank the rest of the line # 23 | # # 24 | ################################################################ 25 | 26 | 27 | -------------------------------------------------------------------------------- /circuit/Key_Pass.gpi: -------------------------------------------------------------------------------- 1 | Generated by EAGLE CAM Processor 7.2.0 2 | 3 | Photoplotter Info File: C:/Users/user/Documents/GitHub/PassKey/circuit/Eagle/Key_Pass.gpi 4 | 5 | Date : 28/11/2015 11:33:47 6 | Plotfile : C:/Users/user/Documents/GitHub/PassKey/circuit/Eagle/Key_Pass.sts 7 | Apertures : generated: 8 | Device : Gerber RS-274-X photoplotter, coordinate format 2.5 inch 9 | 10 | Parameter settings: 11 | 12 | Emulate Apertures : no 13 | Tolerance Draw + : 0.00 % 14 | Tolerance Draw - : 0.00 % 15 | Tolerance Flash + : 0.00 % 16 | Tolerance Flash - : 0.00 % 17 | Rotate : no 18 | Mirror : no 19 | Optimize : yes 20 | Auto fit : yes 21 | OffsetX : 0inch 22 | OffsetY : 0inch 23 | 24 | Plotfile Info: 25 | 26 | Coordinate Format : 2.5 27 | Coordinate Units : Inch 28 | Data Mode : Absolute 29 | Zero Suppression : None 30 | End Of Block : * 31 | 32 | Emulated Apertures: 33 | 34 | -------- Requested Aperture -------- ------ Used Aperture ------ 35 | 36 | Shape Size used Code Shape Size 37 | 38 | octagon 0.0660inch 4 D10 draw 0.0132inch 39 | 40 | Apertures used: 41 | 42 | Code Shape Size used 43 | 44 | D10 draw 0.0132inch 4 45 | D11 round 0.0945inch 4 46 | D12 rectangle 0.0572inch x 0.0651inch 12 47 | D13 rectangle 0.0690inch x 0.0769inch 2 48 | D14 rectangle 0.2160inch x 0.0820inch 2 49 | D15 rectangle 0.0611inch x 0.0769inch 4 50 | D16 round 0.0603inch 4 51 | D17 round 0.0513inch 2 52 | D18 draw 0.0769inch 1 53 | D19 draw 0.0847inch 1 54 | D20 round 0.0532inch 10 55 | D21 round 0.0397inch 7 56 | D22 round 0.1641inch 1 57 | 58 | -------------------------------------------------------------------------------- /firmware/device/7segments.h: -------------------------------------------------------------------------------- 1 | /* 2 | REFRESH DISPLAY: 3 | refresh display 1 segment at a time. 4 | 5 | */ 6 | 7 | #define PORT_SEG_A PORTC 8 | #define BIT_SEG_A 1 9 | 10 | #define PORT_SEG_B PORTC 11 | #define BIT_SEG_B 0 12 | 13 | #define PORT_SEG_C PORTD 14 | #define BIT_SEG_C 7 15 | 16 | #define PORT_SEG_D PORTD 17 | #define BIT_SEG_D 5 18 | 19 | #define PORT_SEG_E PORTD 20 | #define BIT_SEG_E 6 21 | 22 | #define PORT_SEG_F PORTC 23 | #define BIT_SEG_F 4 24 | 25 | #define PORT_SEG_G PORTC 26 | #define BIT_SEG_G 5 27 | 28 | #define PORT_SEG_DP PORTB 29 | #define BIT_SEG_DP 0 30 | 31 | #define _A_ON PORT_SEG_A |= (1<< BIT_SEG_A) 32 | #define _A_OFF PORT_SEG_A &= ~(1<< BIT_SEG_A) 33 | 34 | #define _B_ON PORT_SEG_B |= (1<< BIT_SEG_B) 35 | #define _B_OFF PORT_SEG_B &= ~(1<< BIT_SEG_B) 36 | 37 | #define _C_ON PORT_SEG_C |= (1<< BIT_SEG_C) 38 | #define _C_OFF PORT_SEG_C &= ~(1<< BIT_SEG_C) 39 | 40 | #define _D_ON PORT_SEG_D |= (1<< BIT_SEG_D) 41 | #define _D_OFF PORT_SEG_D &= ~(1<< BIT_SEG_D) 42 | 43 | #define _E_ON PORT_SEG_E |= (1<< BIT_SEG_E) 44 | #define _E_OFF PORT_SEG_E &= ~(1<< BIT_SEG_E) 45 | 46 | #define _F_ON PORT_SEG_F |= (1<< BIT_SEG_F) 47 | #define _F_OFF PORT_SEG_F &= ~(1<< BIT_SEG_F) 48 | 49 | #define _G_ON PORT_SEG_G |= (1<< BIT_SEG_G) 50 | #define _G_OFF PORT_SEG_G &= ~(1<< BIT_SEG_G) 51 | 52 | #define _DP_ON PORT_SEG_DP |= (1<< BIT_SEG_DP) 53 | #define _DP_OFF PORT_SEG_DP &= ~(1<< BIT_SEG_DP) 54 | 55 | // #define T_SENGMENT_ON 80 // 80 calls for each segment 56 | 57 | #define _A 0 58 | #define _B 1 59 | #define _C 2 60 | #define _D 3 61 | #define _E 4 62 | #define _F 5 63 | #define _G 6 64 | #define _DP 7 65 | 66 | 67 | 68 | // Digits Map 69 | // BIT 7 6 5 4 3 2 1 0 70 | // DP g f e d c b a 71 | // 72 | // aaaaa 73 | // f b 74 | // f b 75 | // f b 76 | // ggggg 77 | // e c 78 | // e c 79 | // e c 80 | // ddddd DP 81 | // 82 | 83 | 84 | 85 | 86 | 87 | const PROGMEM char digitos [16] = { 0x3f, // 0 } 88 | 0x06, // 1 89 | 0x5b, // 2 90 | 0x4f, // 3 91 | 0x66, // 4 92 | 0x6d, // 5 93 | 0x7d, // 6 94 | 0x07, // 7 95 | 0x7f, // 8 96 | 0x6f, // 9 97 | 0x77, // A 98 | 0x7c, // B 99 | 0x5c, // C 100 | 0x5e, // D 101 | 0x39, // E 102 | 0x73 // F 103 | }; 104 | 105 | 106 | void refresh_display( uint8_t digits); -------------------------------------------------------------------------------- /circuit/BOM.txt: -------------------------------------------------------------------------------- 1 | Key Pass - Bill of Materials 2 | 3 | Part Part Number Description Link 4 | IC1 ATMega8-16AU AVR Microcontroller, 8K Flash TQFP32-08 http://br.mouser.com/ProductDetail/Atmel/ATmega8-16AU/?qs=sGAEpiMZZMvqv2n3s2xjsVIKSdqlAUq6z54aCTlntIM%3d 5 | DS1 SC56-11GWA Single Digit Numeric Display, 7 Segment, 14.2mm (0.56 INCH) http://br.mouser.com/ProductDetail/Kingbright/SC56-11GWA/?qs=%2fha2pyFadug7Mdf%2fXh0i73RyHvw1b2RRNKkKduB8wt0%3d 6 | D1,D2 ZMM5226B Zener diode, 0.5W 3.3V 5% , SOD80C http://br.mouser.com/ProductDetail/Rectron/ZMM5226B/?qs=%2fha2pyFaduhwRV5rEbrK%2fFJ2YqGja3lN9D5Je9oo9m3BL2EqtvR0AQ%3d%3d 7 | C1 12065C104KAT2A Multilayer Ceramic Capacitor, 0.1uF/50volts, 1206 package http://br.mouser.com/ProductDetail/AVX/12065C104KAT2A/?qs=sGAEpiMZZMsh%252b1woXyUXj%2fQOiMy2nwZAegeDXPYKDmA%3d 8 | C2,C3 VJ0805A220JXGAT5Z Multilayer Ceramic Capacitors, 22pF 1KV, 0805 package http://br.mouser.com/ProductDetail/Vishay-Vitramon/VJ0805A220JXGAT5Z/?qs=sGAEpiMZZMukHu%252bjC5l7YaMIDJ0ksSe0uGMqvHUh5Do%3d 9 | R1 CRCW08052K20FKEA Thick Film Resistors, 2k2 Ohms, 1/8watt, 1%, 0805 package http://br.mouser.com/ProductDetail/Vishay-Dale/CRCW08052K20FKEA/?qs=sGAEpiMZZMuMxemD0lCBEQzL59S3xDaM 10 | R1 CRCW080568R0FKEA Thick Film Resistors, 68 Ohms, 1/8watt, 1%, 0805 package http://br.mouser.com/ProductDetail/Vishay-Dale/CRCW080568R0FKEA/?qs=sGAEpiMZZMu61qfTUdNhG2DpbjADlD3GMxLW745eEY4%3d 11 | R4 CRCW080510K0FKEA Thick Film Resistors, 10k Ohms, 1/8watt, 1%, 0805 package http://br.mouser.com/ProductDetail/Vishay-Dale/CRCW080510K0FKEA/?qs=sGAEpiMZZMu61qfTUdNhG2DpbjADlD3GOIdKSeOTyFU%3d 12 | R5 CRCW0805470RFKEA Thick Film Resistors, 470 Ohms, 1/8watt, 1%, 0805 package http://br.mouser.com/ProductDetail/Vishay-Dale/CRCW0805470RFKEA/?qs=sGAEpiMZZMu61qfTUdNhG2DpbjADlD3GUDzG2zZXJp8%3d 13 | XT1 HCM49-16.000MABJ-UT Crystal 16MHz HC49S SMD http://br.mouser.com/ProductDetail/Citizen/HCM49-16000MABJ-UT/?qs=%2fha2pyFaduiVHToR3%252b1wGN3S69A4tFmj5z0PMR5OtwQ%252byZ9bECIynW9toHMh9rf9 14 | S1,S2 B3F-3122 Tactile Switch R/A 6X6 3.85mm BTN http://br.mouser.com/ProductDetail/Omron/B3F-3122/?qs=%2fha2pyFaduh%2f%252boBDD%252bux0v7jK4zpiWPzZx8lqimIGEtFuNSTC0qQEw%3d%3d 15 | K1 48037-0001 USB Connector TYPE A RA SHLDED PLG THRU-HOLE AU http://br.mouser.com/ProductDetail/Molex/48037-0001/?qs=%2fha2pyFaduinMl8uohyjMe6YZYgp2j6CnudoqvbRJ1c%3d 16 | -------------------------------------------------------------------------------- /utils/pass2bin.py: -------------------------------------------------------------------------------- 1 | ############################################################# 2 | # KeyPass - Password list to hex file converter 3 | # Author: Daniel Jose Viana - danjovic@hotmail.com 4 | # 5 | # Version 0.1 - December 2, 2015 6 | # Basic Release 7 | # 8 | # Version 0.11 - December 7, 2015 9 | # Added support for at the end of password 10 | # 11 | # This code is released under GPL V2.0 12 | # 13 | # This script reads a text file with your legacy passwords 14 | # and generates an Hex file with the password contents and 15 | # a command line with arguments for avrdude to upload them 16 | # to KeyPass. 17 | # 18 | # Read 'password_rules.txt' for more info. 19 | # 20 | 21 | ## FUNCTIONS ## 22 | def pad_with_zeroes(s): # Keypass reserves 14 bytes for each password 23 | s=s+ ''.join(chr(0) for x in range (0,14)) 24 | return s[0:14] 25 | 26 | 27 | ## MAIN CODE ## 28 | 29 | passwords=['\0','\0','\0','\0','\0','\0','\0','\0','\0','\0'] 30 | 31 | 32 | try: 33 | fi=open("passwords.txt", "r") 34 | print "Found password file. Parsing" 35 | passes = 0 # passwords found 36 | seeking = 1 37 | cr_at_end = 0 38 | while seeking: 39 | line = fi.readline() # discard lines up to first %%% found 40 | if not line: break 41 | if line.count("%%%")!=0: seeking =0 # found start mark 42 | print "Seeking passwords" 43 | 44 | while passes < 10: 45 | line = fi.readline() 46 | if not line: break 47 | line = line.strip('\n') #strip the end of line 48 | linesize = len(line) 49 | if linesize>12 and line[12]=="#": 50 | cr_at_end = 1 51 | else: cr_at_end =0 52 | 53 | line = line[0:12] # limit the number of characters 54 | if linesize>12: 55 | line=line.rstrip() # trim spaces for lines with comments 56 | if len(line)!=0: 57 | if cr_at_end: line = line + chr(10) 58 | passwords[passes]=line 59 | passes=passes+1 60 | fi.close() # Reached End of file of found all passwords 61 | 62 | 63 | 64 | if passes!=0: 65 | print "Passwords found: %d" % passes 66 | print "Generating eeprom.bin file" 67 | 68 | eeprom_image='' # initialize eeprom image 69 | for i in range (0, passes): # fill with found passwords 70 | eeprom_image=eeprom_image+pad_with_zeroes(passwords[i]) 71 | for i in range (passes,10): # pad not found passwords 72 | eeprom_image=eeprom_image+pad_with_zeroes('') 73 | 74 | # complete bin file up to 512 bytes 75 | eeprom_image = eeprom_image + ''.join(chr(255) for x in range (140,512)) 76 | 77 | try: 78 | fo=open("eeprom.bin", "wb") # open file for write 79 | fo.write(eeprom_image) 80 | fo.close() 81 | 82 | print "Password bin file generated sucessfully" 83 | print 84 | print "Now put Keypass in programming mode and type:" 85 | print "avrdude -p m8 -c usbasp -U eeprom:w:eeprom.bin" 86 | 87 | 88 | 89 | except IOError: 90 | print "Error: Could not create eeprom.bin output file" 91 | 92 | 93 | else : 94 | print "No passwords found. Nothing to do" 95 | 96 | 97 | 98 | except IOError: 99 | print "Error: File passwords.txt not found." 100 | 101 | 102 | 103 | 104 | 105 | -------------------------------------------------------------------------------- /firmware/bootloader/firmware/usbdrv/oddebug.h: -------------------------------------------------------------------------------- 1 | /* Name: oddebug.h 2 | * Project: AVR library 3 | * Author: Christian Starkjohann 4 | * Creation Date: 2005-01-16 5 | * Tabsize: 4 6 | * Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH 7 | * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) 8 | */ 9 | 10 | #ifndef __oddebug_h_included__ 11 | #define __oddebug_h_included__ 12 | 13 | /* 14 | General Description: 15 | This module implements a function for debug logs on the serial line of the 16 | AVR microcontroller. Debugging can be configured with the define 17 | 'DEBUG_LEVEL'. If this macro is not defined or defined to 0, all debugging 18 | calls are no-ops. If it is 1, DBG1 logs will appear, but not DBG2. If it is 19 | 2, DBG1 and DBG2 logs will be printed. 20 | 21 | A debug log consists of a label ('prefix') to indicate which debug log created 22 | the output and a memory block to dump in hex ('data' and 'len'). 23 | */ 24 | 25 | 26 | #ifndef F_CPU 27 | # define F_CPU 12000000 /* 12 MHz */ 28 | #endif 29 | 30 | /* make sure we have the UART defines: */ 31 | #include "usbportability.h" 32 | 33 | #ifndef uchar 34 | # define uchar unsigned char 35 | #endif 36 | 37 | #if DEBUG_LEVEL > 0 && !(defined TXEN || defined TXEN0) /* no UART in device */ 38 | # warning "Debugging disabled because device has no UART" 39 | # undef DEBUG_LEVEL 40 | #endif 41 | 42 | #ifndef DEBUG_LEVEL 43 | # define DEBUG_LEVEL 0 44 | #endif 45 | 46 | /* ------------------------------------------------------------------------- */ 47 | 48 | #if DEBUG_LEVEL > 0 49 | # define DBG1(prefix, data, len) odDebug(prefix, data, len) 50 | #else 51 | # define DBG1(prefix, data, len) 52 | #endif 53 | 54 | #if DEBUG_LEVEL > 1 55 | # define DBG2(prefix, data, len) odDebug(prefix, data, len) 56 | #else 57 | # define DBG2(prefix, data, len) 58 | #endif 59 | 60 | /* ------------------------------------------------------------------------- */ 61 | 62 | #if DEBUG_LEVEL > 0 63 | extern void odDebug(uchar prefix, uchar *data, uchar len); 64 | 65 | /* Try to find our control registers; ATMEL likes to rename these */ 66 | 67 | #if defined UBRR 68 | # define ODDBG_UBRR UBRR 69 | #elif defined UBRRL 70 | # define ODDBG_UBRR UBRRL 71 | #elif defined UBRR0 72 | # define ODDBG_UBRR UBRR0 73 | #elif defined UBRR0L 74 | # define ODDBG_UBRR UBRR0L 75 | #endif 76 | 77 | #if defined UCR 78 | # define ODDBG_UCR UCR 79 | #elif defined UCSRB 80 | # define ODDBG_UCR UCSRB 81 | #elif defined UCSR0B 82 | # define ODDBG_UCR UCSR0B 83 | #endif 84 | 85 | #if defined TXEN 86 | # define ODDBG_TXEN TXEN 87 | #else 88 | # define ODDBG_TXEN TXEN0 89 | #endif 90 | 91 | #if defined USR 92 | # define ODDBG_USR USR 93 | #elif defined UCSRA 94 | # define ODDBG_USR UCSRA 95 | #elif defined UCSR0A 96 | # define ODDBG_USR UCSR0A 97 | #endif 98 | 99 | #if defined UDRE 100 | # define ODDBG_UDRE UDRE 101 | #else 102 | # define ODDBG_UDRE UDRE0 103 | #endif 104 | 105 | #if defined UDR 106 | # define ODDBG_UDR UDR 107 | #elif defined UDR0 108 | # define ODDBG_UDR UDR0 109 | #endif 110 | 111 | static inline void odDebugInit(void) 112 | { 113 | ODDBG_UCR |= (1< 0 && !(defined TXEN || defined TXEN0) /* no UART in device */ 39 | # warning "Debugging disabled because device has no UART" 40 | # undef DEBUG_LEVEL 41 | #endif 42 | 43 | #ifndef DEBUG_LEVEL 44 | # define DEBUG_LEVEL 0 45 | #endif 46 | 47 | /* ------------------------------------------------------------------------- */ 48 | 49 | #if DEBUG_LEVEL > 0 50 | # define DBG1(prefix, data, len) odDebug(prefix, data, len) 51 | #else 52 | # define DBG1(prefix, data, len) 53 | #endif 54 | 55 | #if DEBUG_LEVEL > 1 56 | # define DBG2(prefix, data, len) odDebug(prefix, data, len) 57 | #else 58 | # define DBG2(prefix, data, len) 59 | #endif 60 | 61 | /* ------------------------------------------------------------------------- */ 62 | 63 | #if DEBUG_LEVEL > 0 64 | extern void odDebug(uchar prefix, uchar *data, uchar len); 65 | 66 | /* Try to find our control registers; ATMEL likes to rename these */ 67 | 68 | #if defined UBRR 69 | # define ODDBG_UBRR UBRR 70 | #elif defined UBRRL 71 | # define ODDBG_UBRR UBRRL 72 | #elif defined UBRR0 73 | # define ODDBG_UBRR UBRR0 74 | #elif defined UBRR0L 75 | # define ODDBG_UBRR UBRR0L 76 | #endif 77 | 78 | #if defined UCR 79 | # define ODDBG_UCR UCR 80 | #elif defined UCSRB 81 | # define ODDBG_UCR UCSRB 82 | #elif defined UCSR0B 83 | # define ODDBG_UCR UCSR0B 84 | #endif 85 | 86 | #if defined TXEN 87 | # define ODDBG_TXEN TXEN 88 | #else 89 | # define ODDBG_TXEN TXEN0 90 | #endif 91 | 92 | #if defined USR 93 | # define ODDBG_USR USR 94 | #elif defined UCSRA 95 | # define ODDBG_USR UCSRA 96 | #elif defined UCSR0A 97 | # define ODDBG_USR UCSR0A 98 | #endif 99 | 100 | #if defined UDRE 101 | # define ODDBG_UDRE UDRE 102 | #else 103 | # define ODDBG_UDRE UDRE0 104 | #endif 105 | 106 | #if defined UDR 107 | # define ODDBG_UDR UDR 108 | #elif defined UDR0 109 | # define ODDBG_UDR UDR0 110 | #endif 111 | 112 | static inline void odDebugInit(void) 113 | { 114 | ODDBG_UCR |= (1< 38 | #ifndef __IAR_SYSTEMS_ASM__ 39 | # include 40 | #endif 41 | 42 | #define __attribute__(arg) /* not supported on IAR */ 43 | 44 | #ifdef __IAR_SYSTEMS_ASM__ 45 | # define __ASSEMBLER__ /* IAR does not define standard macro for asm */ 46 | #endif 47 | 48 | #ifdef __HAS_ELPM__ 49 | # define PROGMEM __farflash 50 | #else 51 | # define PROGMEM __flash 52 | #endif 53 | 54 | #define USB_READ_FLASH(addr) (*(PROGMEM char *)(addr)) 55 | 56 | /* The following definitions are not needed by the driver, but may be of some 57 | * help if you port a gcc based project to IAR. 58 | */ 59 | #define cli() __disable_interrupt() 60 | #define sei() __enable_interrupt() 61 | #define wdt_reset() __watchdog_reset() 62 | #define _BV(x) (1 << (x)) 63 | 64 | /* assembler compatibility macros */ 65 | #define nop2 rjmp $+2 /* jump to next instruction */ 66 | #define XL r26 67 | #define XH r27 68 | #define YL r28 69 | #define YH r29 70 | #define ZL r30 71 | #define ZH r31 72 | #define lo8(x) LOW(x) 73 | #define hi8(x) (((x)>>8) & 0xff) /* not HIGH to allow XLINK to make a proper range check */ 74 | 75 | /* Depending on the device you use, you may get problems with the way usbdrv.h 76 | * handles the differences between devices. Since IAR does not use #defines 77 | * for MCU registers, we can't check for the existence of a particular 78 | * register with an #ifdef. If the autodetection mechanism fails, include 79 | * definitions for the required USB_INTR_* macros in your usbconfig.h. See 80 | * usbconfig-prototype.h and usbdrv.h for details. 81 | */ 82 | 83 | /* ------------------------------------------------------------------------- */ 84 | #elif __CODEVISIONAVR__ /* check for CodeVision AVR */ 85 | /* ------------------------------------------------------------------------- */ 86 | /* This port is not working (yet) */ 87 | 88 | /* #define F_CPU _MCU_CLOCK_FREQUENCY_ seems to be defined automatically */ 89 | 90 | #include 91 | #include 92 | 93 | #define __attribute__(arg) /* not supported on IAR */ 94 | 95 | #define PROGMEM __flash 96 | #define USB_READ_FLASH(addr) (*(PROGMEM char *)(addr)) 97 | 98 | #ifndef __ASSEMBLER__ 99 | static inline void cli(void) 100 | { 101 | #asm("cli"); 102 | } 103 | static inline void sei(void) 104 | { 105 | #asm("sei"); 106 | } 107 | #endif 108 | #define _delay_ms(t) delay_ms(t) 109 | #define _BV(x) (1 << (x)) 110 | #define USB_CFG_USE_SWITCH_STATEMENT 1 /* macro for if() cascase fails for unknown reason */ 111 | 112 | #define macro .macro 113 | #define endm .endmacro 114 | #define nop2 rjmp .+0 /* jump to next instruction */ 115 | 116 | /* ------------------------------------------------------------------------- */ 117 | #else /* default development environment is avr-gcc/avr-libc */ 118 | /* ------------------------------------------------------------------------- */ 119 | 120 | #include 121 | #ifdef __ASSEMBLER__ 122 | # define _VECTOR(N) __vector_ ## N /* io.h does not define this for asm */ 123 | #else 124 | # include 125 | #endif 126 | 127 | #if USB_CFG_DRIVER_FLASH_PAGE 128 | # define USB_READ_FLASH(addr) pgm_read_byte_far(((long)USB_CFG_DRIVER_FLASH_PAGE << 16) | (long)(addr)) 129 | #else 130 | # define USB_READ_FLASH(addr) pgm_read_byte(addr) 131 | #endif 132 | 133 | #define macro .macro 134 | #define endm .endm 135 | #define nop2 rjmp .+0 /* jump to next instruction */ 136 | 137 | #endif /* development environment */ 138 | 139 | /* for conveniecne, ensure that PRG_RDB exists */ 140 | #ifndef PRG_RDB 141 | # define PRG_RDB(addr) USB_READ_FLASH(addr) 142 | #endif 143 | #endif /* __usbportability_h_INCLUDED__ */ 144 | -------------------------------------------------------------------------------- /firmware/device/usbdrv/usbportability.h: -------------------------------------------------------------------------------- 1 | /* Name: usbportability.h 2 | * Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers 3 | * Author: Christian Starkjohann 4 | * Creation Date: 2008-06-17 5 | * Tabsize: 4 6 | * Copyright: (c) 2008 by OBJECTIVE DEVELOPMENT Software GmbH 7 | * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) 8 | * This Revision: $Id$ 9 | */ 10 | 11 | /* 12 | General Description: 13 | This header is intended to contain all (or at least most of) the compiler 14 | and library dependent stuff. The C code is written for avr-gcc and avr-libc. 15 | The API of other development environments is converted to gcc's and avr-libc's 16 | API by means of defines. 17 | 18 | This header also contains all system includes since they depend on the 19 | development environment. 20 | 21 | Thanks to Oleg Semyonov for his help with the IAR tools port! 22 | */ 23 | 24 | #ifndef __usbportability_h_INCLUDED__ 25 | #define __usbportability_h_INCLUDED__ 26 | 27 | /* We check explicitly for IAR and CodeVision. Default is avr-gcc/avr-libc. */ 28 | 29 | /* ------------------------------------------------------------------------- */ 30 | #if defined __IAR_SYSTEMS_ICC__ || defined __IAR_SYSTEMS_ASM__ /* check for IAR */ 31 | /* ------------------------------------------------------------------------- */ 32 | 33 | #ifndef ENABLE_BIT_DEFINITIONS 34 | # define ENABLE_BIT_DEFINITIONS 1 /* Enable bit definitions */ 35 | #endif 36 | 37 | /* Include IAR headers */ 38 | #include 39 | #ifndef __IAR_SYSTEMS_ASM__ 40 | # include 41 | #endif 42 | 43 | #define __attribute__(arg) /* not supported on IAR */ 44 | 45 | #ifdef __IAR_SYSTEMS_ASM__ 46 | # define __ASSEMBLER__ /* IAR does not define standard macro for asm */ 47 | #endif 48 | 49 | #ifdef __HAS_ELPM__ 50 | # define PROGMEM __farflash 51 | #else 52 | # define PROGMEM __flash 53 | #endif 54 | 55 | #define USB_READ_FLASH(addr) (*(PROGMEM char *)(addr)) 56 | 57 | /* The following definitions are not needed by the driver, but may be of some 58 | * help if you port a gcc based project to IAR. 59 | */ 60 | #define cli() __disable_interrupt() 61 | #define sei() __enable_interrupt() 62 | #define wdt_reset() __watchdog_reset() 63 | #define _BV(x) (1 << (x)) 64 | 65 | /* assembler compatibility macros */ 66 | #define nop2 rjmp $+2 /* jump to next instruction */ 67 | #define XL r26 68 | #define XH r27 69 | #define YL r28 70 | #define YH r29 71 | #define ZL r30 72 | #define ZH r31 73 | #define lo8(x) LOW(x) 74 | #define hi8(x) (((x)>>8) & 0xff) /* not HIGH to allow XLINK to make a proper range check */ 75 | 76 | /* Depending on the device you use, you may get problems with the way usbdrv.h 77 | * handles the differences between devices. Since IAR does not use #defines 78 | * for MCU registers, we can't check for the existence of a particular 79 | * register with an #ifdef. If the autodetection mechanism fails, include 80 | * definitions for the required USB_INTR_* macros in your usbconfig.h. See 81 | * usbconfig-prototype.h and usbdrv.h for details. 82 | */ 83 | 84 | /* ------------------------------------------------------------------------- */ 85 | #elif __CODEVISIONAVR__ /* check for CodeVision AVR */ 86 | /* ------------------------------------------------------------------------- */ 87 | /* This port is not working (yet) */ 88 | 89 | /* #define F_CPU _MCU_CLOCK_FREQUENCY_ seems to be defined automatically */ 90 | 91 | #include 92 | #include 93 | 94 | #define __attribute__(arg) /* not supported on IAR */ 95 | 96 | #define PROGMEM __flash 97 | #define USB_READ_FLASH(addr) (*(PROGMEM char *)(addr)) 98 | 99 | #ifndef __ASSEMBLER__ 100 | static inline void cli(void) 101 | { 102 | #asm("cli"); 103 | } 104 | static inline void sei(void) 105 | { 106 | #asm("sei"); 107 | } 108 | #endif 109 | #define _delay_ms(t) delay_ms(t) 110 | #define _BV(x) (1 << (x)) 111 | #define USB_CFG_USE_SWITCH_STATEMENT 1 /* macro for if() cascase fails for unknown reason */ 112 | 113 | #define macro .macro 114 | #define endm .endmacro 115 | #define nop2 rjmp .+0 /* jump to next instruction */ 116 | 117 | /* ------------------------------------------------------------------------- */ 118 | #else /* default development environment is avr-gcc/avr-libc */ 119 | /* ------------------------------------------------------------------------- */ 120 | 121 | #include 122 | #ifdef __ASSEMBLER__ 123 | # define _VECTOR(N) __vector_ ## N /* io.h does not define this for asm */ 124 | #else 125 | # include 126 | #endif 127 | 128 | #if USB_CFG_DRIVER_FLASH_PAGE 129 | # define USB_READ_FLASH(addr) pgm_read_byte_far(((long)USB_CFG_DRIVER_FLASH_PAGE << 16) | (long)(addr)) 130 | #else 131 | # define USB_READ_FLASH(addr) pgm_read_byte(addr) 132 | #endif 133 | 134 | #define macro .macro 135 | #define endm .endm 136 | #define nop2 rjmp .+0 /* jump to next instruction */ 137 | 138 | #endif /* development environment */ 139 | 140 | /* for conveniecne, ensure that PRG_RDB exists */ 141 | #ifndef PRG_RDB 142 | # define PRG_RDB(addr) USB_READ_FLASH(addr) 143 | #endif 144 | #endif /* __usbportability_h_INCLUDED__ */ 145 | -------------------------------------------------------------------------------- /circuit/Key_Pass.stc: -------------------------------------------------------------------------------- 1 | G75* 2 | %MOIN*% 3 | %OFA0B0*% 4 | %FSLAX25Y25*% 5 | %IPPOS*% 6 | %LPD*% 7 | %AMOC8* 8 | 5,1,8,0,0,1.08239X$1,22.5* 9 | % 10 | %ADD10C,0.04000*% 11 | %ADD11R,0.05600X0.02800*% 12 | %ADD12R,0.02800X0.05600*% 13 | %ADD13C,0.01320*% 14 | %ADD14C,0.09450*% 15 | %ADD15R,0.05718X0.06506*% 16 | %ADD16C,0.06033*% 17 | %ADD17C,0.05128*% 18 | %ADD18C,0.07687*% 19 | %ADD19C,0.08474*% 20 | %ADD20C,0.05324*% 21 | %ADD21C,0.03969*% 22 | %ADD22C,0.16411*% 23 | D10* 24 | X0109703Y0072335D02* 25 | X0112203Y0069835D01* 26 | X0119703Y0077335D02* 27 | X0117203Y0079835D01* 28 | X0078453Y0118585D02* 29 | X0075953Y0121085D01* 30 | X0072203Y0117335D02* 31 | X0074703Y0114835D01* 32 | X0070953Y0111085D02* 33 | X0068453Y0113585D01* 34 | D11* 35 | X0085303Y0113359D03* 36 | X0085303Y0110209D03* 37 | X0085303Y0107059D03* 38 | X0085303Y0103910D03* 39 | X0085303Y0100760D03* 40 | X0085303Y0097610D03* 41 | X0085303Y0094461D03* 42 | X0085303Y0091311D03* 43 | X0119103Y0091311D03* 44 | X0119103Y0094461D03* 45 | X0119103Y0097610D03* 46 | X0119103Y0100760D03* 47 | X0119103Y0103910D03* 48 | X0119103Y0107059D03* 49 | X0119103Y0110209D03* 50 | X0119103Y0113359D03* 51 | D12* 52 | X0113226Y0119235D03* 53 | X0110077Y0119235D03* 54 | X0106927Y0119235D03* 55 | X0103777Y0119235D03* 56 | X0100628Y0119235D03* 57 | X0097478Y0119235D03* 58 | X0094329Y0119235D03* 59 | X0091179Y0119235D03* 60 | X0091179Y0085435D03* 61 | X0094329Y0085435D03* 62 | X0097478Y0085435D03* 63 | X0100628Y0085435D03* 64 | X0103777Y0085435D03* 65 | X0106927Y0085435D03* 66 | X0110077Y0085435D03* 67 | X0113226Y0085435D03* 68 | D13* 69 | X0136440Y0068096D02* 70 | X0137100Y0068756D01* 71 | X0137100Y0066570D01* 72 | X0135554Y0065024D01* 73 | X0133368Y0065024D01* 74 | X0131822Y0066570D01* 75 | X0131822Y0068756D01* 76 | X0133368Y0070302D01* 77 | X0135554Y0070302D01* 78 | X0137100Y0068756D01* 79 | X0136110Y0068346D01* 80 | X0136110Y0066980D01* 81 | X0135144Y0066014D01* 82 | X0133778Y0066014D01* 83 | X0132812Y0066980D01* 84 | X0132812Y0068346D01* 85 | X0133778Y0069312D01* 86 | X0135144Y0069312D01* 87 | X0136110Y0068346D01* 88 | X0135120Y0067936D01* 89 | X0135120Y0067390D01* 90 | X0134734Y0067004D01* 91 | X0134188Y0067004D01* 92 | X0133802Y0067390D01* 93 | X0133802Y0067936D01* 94 | X0134188Y0068322D01* 95 | X0134734Y0068322D01* 96 | X0135120Y0067936D01* 97 | X0123853Y0055510D02* 98 | X0124513Y0056170D01* 99 | X0124513Y0053984D01* 100 | X0122967Y0052438D01* 101 | X0120781Y0052438D01* 102 | X0119235Y0053984D01* 103 | X0119235Y0056170D01* 104 | X0120781Y0057716D01* 105 | X0122967Y0057716D01* 106 | X0124513Y0056170D01* 107 | X0123523Y0055760D01* 108 | X0123523Y0054394D01* 109 | X0122557Y0053428D01* 110 | X0121191Y0053428D01* 111 | X0120225Y0054394D01* 112 | X0120225Y0055760D01* 113 | X0121191Y0056726D01* 114 | X0122557Y0056726D01* 115 | X0123523Y0055760D01* 116 | X0122533Y0055350D01* 117 | X0122533Y0054804D01* 118 | X0122147Y0054418D01* 119 | X0121601Y0054418D01* 120 | X0121215Y0054804D01* 121 | X0121215Y0055350D01* 122 | X0121601Y0055736D01* 123 | X0122147Y0055736D01* 124 | X0122533Y0055350D01* 125 | X0052966Y0121573D02* 126 | X0052306Y0120913D01* 127 | X0052306Y0123099D01* 128 | X0053852Y0124645D01* 129 | X0056038Y0124645D01* 130 | X0057584Y0123099D01* 131 | X0057584Y0120913D01* 132 | X0056038Y0119367D01* 133 | X0053852Y0119367D01* 134 | X0052306Y0120913D01* 135 | X0053296Y0121323D01* 136 | X0053296Y0122689D01* 137 | X0054262Y0123655D01* 138 | X0055628Y0123655D01* 139 | X0056594Y0122689D01* 140 | X0056594Y0121323D01* 141 | X0055628Y0120357D01* 142 | X0054262Y0120357D01* 143 | X0053296Y0121323D01* 144 | X0054286Y0121733D01* 145 | X0054286Y0122279D01* 146 | X0054672Y0122665D01* 147 | X0055218Y0122665D01* 148 | X0055604Y0122279D01* 149 | X0055604Y0121733D01* 150 | X0055218Y0121347D01* 151 | X0054672Y0121347D01* 152 | X0054286Y0121733D01* 153 | X0065552Y0134160D02* 154 | X0064892Y0133500D01* 155 | X0064892Y0135686D01* 156 | X0066438Y0137232D01* 157 | X0068624Y0137232D01* 158 | X0070170Y0135686D01* 159 | X0070170Y0133500D01* 160 | X0068624Y0131954D01* 161 | X0066438Y0131954D01* 162 | X0064892Y0133500D01* 163 | X0065882Y0133910D01* 164 | X0065882Y0135276D01* 165 | X0066848Y0136242D01* 166 | X0068214Y0136242D01* 167 | X0069180Y0135276D01* 168 | X0069180Y0133910D01* 169 | X0068214Y0132944D01* 170 | X0066848Y0132944D01* 171 | X0065882Y0133910D01* 172 | X0066872Y0134320D01* 173 | X0066872Y0134866D01* 174 | X0067258Y0135252D01* 175 | X0067804Y0135252D01* 176 | X0068190Y0134866D01* 177 | X0068190Y0134320D01* 178 | X0067804Y0133934D01* 179 | X0067258Y0133934D01* 180 | X0066872Y0134320D01* 181 | D14* 182 | X0077926Y0131128D03* 183 | X0058409Y0111612D03* 184 | X0111480Y0058542D03* 185 | X0130996Y0078058D03* 186 | D15* 187 | X0098443Y0139835D03* 188 | X0090962Y0139835D03* 189 | D16* 190 | X0065805Y0085425D03* 191 | X0072765Y0078465D03* 192 | X0078333Y0072897D03* 193 | X0085292Y0065937D03* 194 | D17* 195 | X0075966Y0063571D03* 196 | X0063439Y0076099D03* 197 | D18* 198 | X0051051Y0083476D02* 199 | X0056062Y0088487D01* 200 | D19* 201 | X0088633Y0056472D02* 202 | X0083065Y0050904D01* 203 | D20* 204 | X0095632Y0067480D03* 205 | X0088561Y0074551D03* 206 | X0081489Y0081622D03* 207 | X0074418Y0088693D03* 208 | X0067347Y0095764D03* 209 | X0109774Y0138190D03* 210 | X0116845Y0131119D03* 211 | X0123916Y0124048D03* 212 | X0130987Y0116977D03* 213 | X0138058Y0109906D03* 214 | D21* 215 | X0110953Y0108585D03* 216 | X0110953Y0113585D03* 217 | X0110953Y0101085D03* 218 | X0110953Y0093585D03* 219 | X0107203Y0079835D03* 220 | X0078453Y0107335D03* 221 | X0095953Y0108585D03* 222 | D22* 223 | X0134703Y0134835D03* 224 | M02* 225 | -------------------------------------------------------------------------------- /firmware/bootloader/Readme.txt: -------------------------------------------------------------------------------- 1 | This is the README file for USBaspLoader. 2 | 3 | USBaspLoader is a USB boot loader for AVR microcontrollers. It can be used on 4 | all AVRs with at least 2 kB of boot loader section, e.g. the popular ATMega8. 5 | The firmware is flashed into the upper 2 kB of the flash memory and takes 6 | control immediately after reset. If a certain hardware condition is met 7 | (this condition can be configured, e.g. a jumper), the boot loader waits for 8 | data on the USB interface and loads it into the remaining part of the flash 9 | memory. If the condition is not met, control is passed to the loaded firmware. 10 | 11 | This boot loader is similar to Thomas Fischl's avrusbboot and our own 12 | bootloadHID, but it requires no separate command line tool to upload the data. 13 | USBaspLoader emulates Thomas Fischl's USBasp programmer instead. You can thus 14 | use AVRDUDE to upload flash memory data (and if the option is enabled) EEPROM 15 | data. 16 | 17 | Since USBaspLoader cooperates with AVRDUDE, it can be used in conjunction with 18 | the Arduino software to upload flash memory data. 19 | 20 | 21 | FILES IN THE DISTRIBUTION 22 | ========================= 23 | Readme.txt ........ The file you are currently reading. 24 | firmware .......... Source code of the controller firmware. 25 | firmware/usbdrv ... USB driver -- See Readme.txt in that directory for info 26 | License.txt ....... Public license (GPL2) for all contents of this project. 27 | Changelog.txt ..... Logfile documenting changes in soft-, firm- and hardware. 28 | 29 | 30 | BUILDING AND INSTALLING 31 | ======================= 32 | This project can be built on Unix (Linux, FreeBSD or Mac OS X) or Windows. 33 | 34 | For all platforms, you must first describe your hardware in the file 35 | "firmware/bootloaderconfig.h". See the documentation in the example provided 36 | with this distribution for details. Then edit "firmware/Makefile" to reflect 37 | the target device, the device's boot loader address and fuse bit values. 38 | 39 | Building on Windows: 40 | You need WinAVR for the firmware, see http://winavr.sourceforge.net/. 41 | To build the firmware with WinAVR, change into the "firmware" directory, 42 | check whether you need to edit the "Makefile" (e.g. change device settings, 43 | programmer hardware, clock rate etc.) or bootloaderconfig.h and type "make" 44 | to compile the source code. Before you upload the code to the device with 45 | "make flash", you should set the fuses with "make fuse". To protect the boot 46 | loader from overwriting itself, set the lock bits with "make lock" after 47 | uploading the firmware. 48 | 49 | Building on Unix (Linux, FreeBSD and Mac): 50 | You need the GNU toolchain and avr-libc for the firmware. See 51 | http://www.nongnu.org/avr-libc/user-manual/install_tools.html 52 | for a good description on how to install the GNU compiler toolchain and 53 | avr-libc on Unix. For Mac OS X, we provide a read-made package, see 54 | http://www.obdev.at/avrmacpack/ 55 | 56 | To build the firmware, change to the "firmware" directory, edit "Makefile" 57 | and bootloaderconfig.h as described in the Windows paragraph above and type 58 | "make" to compile the source code. Before you upload the code to the device 59 | with "make flash", you should set the fuses with "make fuse". Then protect the 60 | boot loader firmware with "make lock". 61 | 62 | 63 | WORKING WITH THE BOOT LOADER 64 | ============================ 65 | The boot loader is quite easy to use. Set the jumper (or whatever condition 66 | you have configured) for boot loading on the target hardware, connect it to 67 | the host computer and (if not bus powered) issue a Reset on the AVR. 68 | 69 | You can now flash the device with AVRDUDE through a "virtual" USBasp 70 | programmer. 71 | 72 | 73 | USING THE USB DRIVER FOR YOUR OWN PROJECTS 74 | ========================================== 75 | This project is not intended as a reference implementation. If you want to 76 | use AVR-USB in your own projects, please see 77 | * PowerSwitch for the most basic example, 78 | * Automator for an HID example or 79 | * AVR-Doper for a very complex example on how to simulate a serial 80 | interface (virtual COM port). 81 | All these projects can be downloaded from http://www.obdev.at/avrusb/ 82 | 83 | 84 | ABOUT THE LICENSE 85 | ================= 86 | It is our intention to make our USB driver and this demo application 87 | available to everyone. Moreover, we want to make a broad range of USB 88 | projects and ideas for USB devices available to the general public. We 89 | therefore want that all projects built with our USB driver are published 90 | under an Open Source license. Our license for the USB driver and demo code is 91 | the GNU General Public License Version 2 (GPL2). See the file "License.txt" 92 | for details. 93 | 94 | If you don't want to publish your source code under the GPL2, you can simply 95 | pay money for AVR-USB. As an additional benefit you get USB PIDs for free, 96 | licensed exclusively to you. See the file "CommercialLicense.txt" in the usbdrv 97 | directory for details. 98 | 99 | 100 | MORE INFORMATION 101 | ================ 102 | For more information about Objective Development's firmware-only USB driver 103 | for Atmel's AVR microcontrollers please visit the URL 104 | 105 | http://www.obdev.at/products/avrusb/ 106 | 107 | A technical documentation of the driver's interface can be found in the 108 | file "firmware/usbdrv/usbdrv.h". 109 | 110 | 111 | -- 112 | (c) 2008 by OBJECTIVE DEVELOPMENT Software GmbH. 113 | http://www.obdev.at/ 114 | -------------------------------------------------------------------------------- /circuit/Key_Pass.sts: -------------------------------------------------------------------------------- 1 | G75* 2 | %MOIN*% 3 | %OFA0B0*% 4 | %FSLAX25Y25*% 5 | %IPPOS*% 6 | %LPD*% 7 | %AMOC8* 8 | 5,1,8,0,0,1.08239X$1,22.5* 9 | % 10 | %ADD10C,0.01320*% 11 | %ADD11C,0.09450*% 12 | %ADD12R,0.05718X0.06506*% 13 | %ADD13R,0.06899X0.07687*% 14 | %ADD14R,0.21600X0.08200*% 15 | %ADD15R,0.06112X0.07687*% 16 | %ADD16C,0.06033*% 17 | %ADD17C,0.05128*% 18 | %ADD18C,0.07687*% 19 | %ADD19C,0.08474*% 20 | %ADD20C,0.05324*% 21 | %ADD21C,0.03969*% 22 | %ADD22C,0.16411*% 23 | D10* 24 | X0123853Y0055510D02* 25 | X0124513Y0056170D01* 26 | X0124513Y0053984D01* 27 | X0122967Y0052438D01* 28 | X0120781Y0052438D01* 29 | X0119235Y0053984D01* 30 | X0119235Y0056170D01* 31 | X0120781Y0057716D01* 32 | X0122967Y0057716D01* 33 | X0124513Y0056170D01* 34 | X0123523Y0055760D01* 35 | X0123523Y0054394D01* 36 | X0122557Y0053428D01* 37 | X0121191Y0053428D01* 38 | X0120225Y0054394D01* 39 | X0120225Y0055760D01* 40 | X0121191Y0056726D01* 41 | X0122557Y0056726D01* 42 | X0123523Y0055760D01* 43 | X0122533Y0055350D01* 44 | X0122533Y0054804D01* 45 | X0122147Y0054418D01* 46 | X0121601Y0054418D01* 47 | X0121215Y0054804D01* 48 | X0121215Y0055350D01* 49 | X0121601Y0055736D01* 50 | X0122147Y0055736D01* 51 | X0122533Y0055350D01* 52 | X0136440Y0068096D02* 53 | X0137100Y0068756D01* 54 | X0137100Y0066570D01* 55 | X0135554Y0065024D01* 56 | X0133368Y0065024D01* 57 | X0131822Y0066570D01* 58 | X0131822Y0068756D01* 59 | X0133368Y0070302D01* 60 | X0135554Y0070302D01* 61 | X0137100Y0068756D01* 62 | X0136110Y0068346D01* 63 | X0136110Y0066980D01* 64 | X0135144Y0066014D01* 65 | X0133778Y0066014D01* 66 | X0132812Y0066980D01* 67 | X0132812Y0068346D01* 68 | X0133778Y0069312D01* 69 | X0135144Y0069312D01* 70 | X0136110Y0068346D01* 71 | X0135120Y0067936D01* 72 | X0135120Y0067390D01* 73 | X0134734Y0067004D01* 74 | X0134188Y0067004D01* 75 | X0133802Y0067390D01* 76 | X0133802Y0067936D01* 77 | X0134188Y0068322D01* 78 | X0134734Y0068322D01* 79 | X0135120Y0067936D01* 80 | X0065552Y0134160D02* 81 | X0064892Y0133500D01* 82 | X0064892Y0135686D01* 83 | X0066438Y0137232D01* 84 | X0068624Y0137232D01* 85 | X0070170Y0135686D01* 86 | X0070170Y0133500D01* 87 | X0068624Y0131954D01* 88 | X0066438Y0131954D01* 89 | X0064892Y0133500D01* 90 | X0065882Y0133910D01* 91 | X0065882Y0135276D01* 92 | X0066848Y0136242D01* 93 | X0068214Y0136242D01* 94 | X0069180Y0135276D01* 95 | X0069180Y0133910D01* 96 | X0068214Y0132944D01* 97 | X0066848Y0132944D01* 98 | X0065882Y0133910D01* 99 | X0066872Y0134320D01* 100 | X0066872Y0134866D01* 101 | X0067258Y0135252D01* 102 | X0067804Y0135252D01* 103 | X0068190Y0134866D01* 104 | X0068190Y0134320D01* 105 | X0067804Y0133934D01* 106 | X0067258Y0133934D01* 107 | X0066872Y0134320D01* 108 | X0052966Y0121573D02* 109 | X0052306Y0120913D01* 110 | X0052306Y0123099D01* 111 | X0053852Y0124645D01* 112 | X0056038Y0124645D01* 113 | X0057584Y0123099D01* 114 | X0057584Y0120913D01* 115 | X0056038Y0119367D01* 116 | X0053852Y0119367D01* 117 | X0052306Y0120913D01* 118 | X0053296Y0121323D01* 119 | X0053296Y0122689D01* 120 | X0054262Y0123655D01* 121 | X0055628Y0123655D01* 122 | X0056594Y0122689D01* 123 | X0056594Y0121323D01* 124 | X0055628Y0120357D01* 125 | X0054262Y0120357D01* 126 | X0053296Y0121323D01* 127 | X0054286Y0121733D01* 128 | X0054286Y0122279D01* 129 | X0054672Y0122665D01* 130 | X0055218Y0122665D01* 131 | X0055604Y0122279D01* 132 | X0055604Y0121733D01* 133 | X0055218Y0121347D01* 134 | X0054672Y0121347D01* 135 | X0054286Y0121733D01* 136 | D11* 137 | X0058409Y0111612D03* 138 | X0077926Y0131128D03* 139 | X0130996Y0078058D03* 140 | X0111480Y0058542D03* 141 | D12* 142 | G36* 143 | X0116379Y0069412D02* 144 | X0112336Y0065369D01* 145 | X0107737Y0069968D01* 146 | X0111780Y0074011D01* 147 | X0116379Y0069412D01* 148 | G37* 149 | G36* 150 | X0121668Y0074702D02* 151 | X0117625Y0070659D01* 152 | X0113026Y0075258D01* 153 | X0117069Y0079301D01* 154 | X0121668Y0074702D01* 155 | G37* 156 | G36* 157 | X0126379Y0084412D02* 158 | X0122336Y0080369D01* 159 | X0117737Y0084968D01* 160 | X0121780Y0089011D01* 161 | X0126379Y0084412D01* 162 | G37* 163 | G36* 164 | X0131668Y0089702D02* 165 | X0127625Y0085659D01* 166 | X0123026Y0090258D01* 167 | X0127069Y0094301D01* 168 | X0131668Y0089702D01* 169 | G37* 170 | G36* 171 | X0111668Y0097202D02* 172 | X0107625Y0093159D01* 173 | X0103026Y0097758D01* 174 | X0107069Y0101801D01* 175 | X0111668Y0097202D01* 176 | G37* 177 | G36* 178 | X0106379Y0091912D02* 179 | X0102336Y0087869D01* 180 | X0097737Y0092468D01* 181 | X0101780Y0096511D01* 182 | X0106379Y0091912D01* 183 | G37* 184 | G36* 185 | X0100129Y0098162D02* 186 | X0096086Y0094119D01* 187 | X0091487Y0098718D01* 188 | X0095530Y0102761D01* 189 | X0100129Y0098162D01* 190 | G37* 191 | G36* 192 | X0105418Y0103452D02* 193 | X0101375Y0099409D01* 194 | X0096776Y0104008D01* 195 | X0100819Y0108051D01* 196 | X0105418Y0103452D01* 197 | G37* 198 | G36* 199 | X0096668Y0112202D02* 200 | X0092625Y0108159D01* 201 | X0088026Y0112758D01* 202 | X0092069Y0116801D01* 203 | X0096668Y0112202D01* 204 | G37* 205 | G36* 206 | X0091379Y0106912D02* 207 | X0087336Y0102869D01* 208 | X0082737Y0107468D01* 209 | X0086780Y0111511D01* 210 | X0091379Y0106912D01* 211 | G37* 212 | G36* 213 | X0088879Y0121912D02* 214 | X0084836Y0117869D01* 215 | X0080237Y0122468D01* 216 | X0084280Y0126511D01* 217 | X0088879Y0121912D01* 218 | G37* 219 | G36* 220 | X0094168Y0127202D02* 221 | X0090125Y0123159D01* 222 | X0085526Y0127758D01* 223 | X0089569Y0131801D01* 224 | X0094168Y0127202D01* 225 | G37* 226 | D13* 227 | G36* 228 | X0073444Y0116510D02* 229 | X0078322Y0121388D01* 230 | X0083756Y0115954D01* 231 | X0078878Y0111076D01* 232 | X0073444Y0116510D01* 233 | G37* 234 | G36* 235 | X0065649Y0108715D02* 236 | X0070527Y0113593D01* 237 | X0075961Y0108159D01* 238 | X0071083Y0103281D01* 239 | X0065649Y0108715D01* 240 | G37* 241 | D14* 242 | G36* 243 | X0096531Y0138805D02* 244 | X0111803Y0123533D01* 245 | X0106005Y0117735D01* 246 | X0090733Y0133007D01* 247 | X0096531Y0138805D01* 248 | G37* 249 | G36* 250 | X0123401Y0111935D02* 251 | X0138673Y0096663D01* 252 | X0132875Y0090865D01* 253 | X0117603Y0106137D01* 254 | X0123401Y0111935D01* 255 | G37* 256 | D15* 257 | G36* 258 | X0091914Y0079689D02* 259 | X0087592Y0084011D01* 260 | X0093026Y0089445D01* 261 | X0097348Y0085123D01* 262 | X0091914Y0079689D01* 263 | G37* 264 | G36* 265 | X0101379Y0070224D02* 266 | X0097057Y0074546D01* 267 | X0102491Y0079980D01* 268 | X0106813Y0075658D01* 269 | X0101379Y0070224D01* 270 | G37* 271 | G36* 272 | X0087491Y0094980D02* 273 | X0091813Y0090658D01* 274 | X0086379Y0085224D01* 275 | X0082057Y0089546D01* 276 | X0087491Y0094980D01* 277 | G37* 278 | G36* 279 | X0078026Y0104445D02* 280 | X0082348Y0100123D01* 281 | X0076914Y0094689D01* 282 | X0072592Y0099011D01* 283 | X0078026Y0104445D01* 284 | G37* 285 | D16* 286 | X0065805Y0085425D03* 287 | X0072765Y0078465D03* 288 | X0078333Y0072897D03* 289 | X0085292Y0065937D03* 290 | D17* 291 | X0075966Y0063571D03* 292 | X0063439Y0076099D03* 293 | D18* 294 | X0051051Y0083476D02* 295 | X0056062Y0088487D01* 296 | D19* 297 | X0088633Y0056472D02* 298 | X0083065Y0050904D01* 299 | D20* 300 | X0095632Y0067480D03* 301 | X0088561Y0074551D03* 302 | X0081489Y0081622D03* 303 | X0074418Y0088693D03* 304 | X0067347Y0095764D03* 305 | X0109774Y0138190D03* 306 | X0116845Y0131119D03* 307 | X0123916Y0124048D03* 308 | X0130987Y0116977D03* 309 | X0138058Y0109906D03* 310 | D21* 311 | X0110953Y0108585D03* 312 | X0110953Y0113585D03* 313 | X0110953Y0101085D03* 314 | X0110953Y0093585D03* 315 | X0107203Y0079835D03* 316 | X0078453Y0107335D03* 317 | X0095953Y0108585D03* 318 | D22* 319 | X0134703Y0134835D03* 320 | M02* 321 | -------------------------------------------------------------------------------- /firmware/bootloader/firmware/usbdrv/USB-ID-FAQ.txt: -------------------------------------------------------------------------------- 1 | Version 2012-07-09 2 | 3 | ========================== 4 | WHY DO WE NEED THESE IDs? 5 | ========================== 6 | 7 | USB is more than a low level protocol for data transport. It also defines a 8 | common set of requests which must be understood by all devices. And as part 9 | of these common requests, the specification defines data structures, the 10 | USB Descriptors, which are used to describe the properties of the device. 11 | 12 | From the perspective of an operating system, it is therefore possible to find 13 | out basic properties of a device (such as e.g. the manufacturer and the name 14 | of the device) without a device-specific driver. This is essential because 15 | the operating system can choose a driver to load based on this information 16 | (Plug-And-Play). 17 | 18 | Among the most important properties in the Device Descriptor are the USB 19 | Vendor- and Product-ID. Both are 16 bit integers. The most simple form of 20 | driver matching is based on these IDs. The driver announces the Vendor- and 21 | Product-IDs of the devices it can handle and the operating system loads the 22 | appropriate driver when the device is connected. 23 | 24 | It is obvious that this technique only works if the pair Vendor- plus 25 | Product-ID is unique: Only devices which require the same driver can have the 26 | same pair of IDs. 27 | 28 | 29 | ===================================================== 30 | HOW DOES THE USB STANDARD ENSURE THAT IDs ARE UNIQUE? 31 | ===================================================== 32 | 33 | Since it is so important that USB IDs are unique, the USB Implementers Forum, 34 | Inc. (usb.org) needs a way to enforce this legally. It is not forbidden by 35 | law to build a device and assign it any random numbers as IDs. Usb.org 36 | therefore needs an agreement to regulate the use of USB IDs. The agreement 37 | binds only parties who agreed to it, of course. Everybody else is free to use 38 | any numbers for their IDs. 39 | 40 | So how can usb.org ensure that every manufacturer of USB devices enters into 41 | an agreement with them? They do it via trademark licensing. Usb.org has 42 | registered the trademark "USB", all associated logos and related terms. If 43 | you want to put an USB logo on your product or claim that it is USB 44 | compliant, you must license these trademarks from usb.org. And this is where 45 | you enter into an agreement. See the "USB-IF Trademark License Agreement and 46 | Usage Guidelines for the USB-IF Logo" at 47 | http://www.usb.org/developers/logo_license/. 48 | 49 | Licensing the USB trademarks requires that you buy a USB Vendor-ID from 50 | usb.org (one-time fee of ca. 2,000 USD), that you become a member of usb.org 51 | (yearly fee of ca. 4,000 USD) and that you meet all the technical 52 | specifications from the USB spec. 53 | 54 | This means that most hobbyists and small companies will never be able to 55 | become USB compliant, just because membership is so expensive. And you can't 56 | be compliant with a driver based on V-USB anyway, because the AVR's port pins 57 | don't meet the electrical specifications for USB. So, in principle, all 58 | hobbyists and small companies are free to choose any random numbers for their 59 | IDs. They have nothing to lose... 60 | 61 | There is one exception worth noting, though: If you use a sub-component which 62 | implements USB, the vendor of the sub-components may guarantee USB 63 | compliance. This might apply to some or all of FTDI's solutions. 64 | 65 | 66 | ======================================================================= 67 | WHY SHOULD YOU OBTAIN USB IDs EVEN IF YOU DON'T LICENSE USB TRADEMARKS? 68 | ======================================================================= 69 | 70 | You have learned in the previous section that you are free to choose any 71 | numbers for your IDs anyway. So why not do exactly this? There is still the 72 | technical issue. If you choose IDs which are already in use by somebody else, 73 | operating systems will load the wrong drivers and your device won't work. 74 | Even if you choose IDs which are not currently in use, they may be in use in 75 | the next version of the operating system or even after an automatic update. 76 | 77 | So what you need is a pair of Vendor- and Product-IDs for which you have the 78 | guarantee that no USB compliant product uses them. This implies that no 79 | operating system will ever ship with drivers responsible for these IDs. 80 | 81 | 82 | ============================================== 83 | HOW DOES OBJECTIVE DEVELOPMENT HANDLE USB IDs? 84 | ============================================== 85 | 86 | Objective Development gives away pairs of USB-IDs with their V-USB licenses. 87 | In order to ensure that these IDs are unique, Objective Development has an 88 | agreement with the company/person who has bought the USB Vendor-ID from 89 | usb.org. This agreement ensures that a range of USB Product-IDs is reserved 90 | for assignment by Objective Development and that the owner of the Vendor-ID 91 | won't give it to anybody else. 92 | 93 | This means that you have to trust three parties to ensure uniqueness of 94 | your IDs: 95 | 96 | - Objective Development, that they don't give the same PID to more than 97 | one person. 98 | - The owner of the Vendor-ID that they don't assign PIDs from the range 99 | assigned to Objective Development to anybody else. 100 | - Usb.org that they don't assign the same Vendor-ID a second time. 101 | 102 | 103 | ================================== 104 | WHO IS THE OWNER OF THE VENDOR-ID? 105 | ================================== 106 | 107 | Objective Development has obtained ranges of USB Product-IDs under two 108 | Vendor-IDs: Under Vendor-ID 5824 from Wouter van Ooijen (Van Ooijen 109 | Technische Informatica, www.voti.nl) and under Vendor-ID 8352 from Jason 110 | Kotzin (now flirc.tv, Inc.). Both VID owners have received their Vendor-ID 111 | directly from usb.org. 112 | 113 | 114 | ========================================================================= 115 | CAN I USE USB-IDs FROM OBJECTIVE DEVELOPMENT WITH OTHER DRIVERS/HARDWARE? 116 | ========================================================================= 117 | 118 | The short answer is: Yes. All you get is a guarantee that the IDs are never 119 | assigned to anybody else. What more do you need? 120 | 121 | 122 | ============================ 123 | WHAT ABOUT SHARED ID PAIRS? 124 | ============================ 125 | 126 | Objective Development has reserved some PID/VID pairs for shared use. You 127 | have no guarantee of uniqueness for them, except that no USB compliant device 128 | uses them. In order to avoid technical problems, we must ensure that all 129 | devices with the same pair of IDs use the same driver on kernel level. For 130 | details, see the file USB-IDs-for-free.txt. 131 | 132 | 133 | ====================================================== 134 | I HAVE HEARD THAT SUB-LICENSING OF USB-IDs IS ILLEGAL? 135 | ====================================================== 136 | 137 | A 16 bit integer number cannot be protected by copyright laws. It is not 138 | sufficiently complex. And since none of the parties involved entered into the 139 | USB-IF Trademark License Agreement, we are not bound by this agreement. So 140 | there is no reason why it should be illegal to sub-license USB-IDs. 141 | 142 | 143 | ============================================= 144 | WHO IS LIABLE IF THERE ARE INCOMPATIBILITIES? 145 | ============================================= 146 | 147 | Objective Development disclaims all liabilities which might arise from the 148 | assignment of IDs. If you guarantee product features to your customers 149 | without proper disclaimer, YOU are liable for that. 150 | -------------------------------------------------------------------------------- /firmware/device/usbdrv/USB-ID-FAQ.txt: -------------------------------------------------------------------------------- 1 | Version 2009-08-22 2 | 3 | ========================== 4 | WHY DO WE NEED THESE IDs? 5 | ========================== 6 | 7 | USB is more than a low level protocol for data transport. It also defines a 8 | common set of requests which must be understood by all devices. And as part 9 | of these common requests, the specification defines data structures, the 10 | USB Descriptors, which are used to describe the properties of the device. 11 | 12 | From the perspective of an operating system, it is therefore possible to find 13 | out basic properties of a device (such as e.g. the manufacturer and the name 14 | of the device) without a device-specific driver. This is essential because 15 | the operating system can choose a driver to load based on this information 16 | (Plug-And-Play). 17 | 18 | Among the most important properties in the Device Descriptor are the USB 19 | Vendor- and Product-ID. Both are 16 bit integers. The most simple form of 20 | driver matching is based on these IDs. The driver announces the Vendor- and 21 | Product-IDs of the devices it can handle and the operating system loads the 22 | appropriate driver when the device is connected. 23 | 24 | It is obvious that this technique only works if the pair Vendor- plus 25 | Product-ID is unique: Only devices which require the same driver can have the 26 | same pair of IDs. 27 | 28 | 29 | ===================================================== 30 | HOW DOES THE USB STANDARD ENSURE THAT IDs ARE UNIQUE? 31 | ===================================================== 32 | 33 | Since it is so important that USB IDs are unique, the USB Implementers Forum, 34 | Inc. (usb.org) needs a way to enforce this legally. It is not forbidden by 35 | law to build a device and assign it any random numbers as IDs. Usb.org 36 | therefore needs an agreement to regulate the use of USB IDs. The agreement 37 | binds only parties who agreed to it, of course. Everybody else is free to use 38 | any numbers for their IDs. 39 | 40 | So how can usb.org ensure that every manufacturer of USB devices enters into 41 | an agreement with them? They do it via trademark licensing. Usb.org has 42 | registered the trademark "USB", all associated logos and related terms. If 43 | you want to put an USB logo on your product or claim that it is USB 44 | compliant, you must license these trademarks from usb.org. And this is where 45 | you enter into an agreement. See the "USB-IF Trademark License Agreement and 46 | Usage Guidelines for the USB-IF Logo" at 47 | http://www.usb.org/developers/logo_license/. 48 | 49 | Licensing the USB trademarks requires that you buy a USB Vendor-ID from 50 | usb.org (one-time fee of ca. 2,000 USD), that you become a member of usb.org 51 | (yearly fee of ca. 4,000 USD) and that you meet all the technical 52 | specifications from the USB spec. 53 | 54 | This means that most hobbyists and small companies will never be able to 55 | become USB compliant, just because membership is so expensive. And you can't 56 | be compliant with a driver based on V-USB anyway, because the AVR's port pins 57 | don't meet the electrical specifications for USB. So, in principle, all 58 | hobbyists and small companies are free to choose any random numbers for their 59 | IDs. They have nothing to lose... 60 | 61 | There is one exception worth noting, though: If you use a sub-component which 62 | implements USB, the vendor of the sub-components may guarantee USB 63 | compliance. This might apply to some or all of FTDI's solutions. 64 | 65 | 66 | ======================================================================= 67 | WHY SHOULD YOU OBTAIN USB IDs EVEN IF YOU DON'T LICENSE USB TRADEMARKS? 68 | ======================================================================= 69 | 70 | You have learned in the previous section that you are free to choose any 71 | numbers for your IDs anyway. So why not do exactly this? There is still the 72 | technical issue. If you choose IDs which are already in use by somebody else, 73 | operating systems will load the wrong drivers and your device won't work. 74 | Even if you choose IDs which are not currently in use, they may be in use in 75 | the next version of the operating system or even after an automatic update. 76 | 77 | So what you need is a pair of Vendor- and Product-IDs for which you have the 78 | guarantee that no USB compliant product uses them. This implies that no 79 | operating system will ever ship with drivers responsible for these IDs. 80 | 81 | 82 | ============================================== 83 | HOW DOES OBJECTIVE DEVELOPMENT HANDLE USB IDs? 84 | ============================================== 85 | 86 | Objective Development gives away pairs of USB-IDs with their V-USB licenses. 87 | In order to ensure that these IDs are unique, Objective Development has an 88 | agreement with the company/person who has bought the USB Vendor-ID from 89 | usb.org. This agreement ensures that a range of USB Product-IDs is reserved 90 | for assignment by Objective Development and that the owner of the Vendor-ID 91 | won't give it to anybody else. 92 | 93 | This means that you have to trust three parties to ensure uniqueness of 94 | your IDs: 95 | 96 | - Objective Development, that they don't give the same PID to more than 97 | one person. 98 | - The owner of the Vendor-ID that they don't assign PIDs from the range 99 | assigned to Objective Development to anybody else. 100 | - Usb.org that they don't assign the same Vendor-ID a second time. 101 | 102 | 103 | ================================== 104 | WHO IS THE OWNER OF THE VENDOR-ID? 105 | ================================== 106 | 107 | Objective Development has obtained ranges of USB Product-IDs under two 108 | Vendor-IDs: Under Vendor-ID 5824 from Wouter van Ooijen (Van Ooijen 109 | Technische Informatica, www.voti.nl) and under Vendor-ID 8352 from Jason 110 | Kotzin (Clay Logic, www.claylogic.com). Both VID owners have received their 111 | Vendor-ID directly from usb.org. 112 | 113 | 114 | ========================================================================= 115 | CAN I USE USB-IDs FROM OBJECTIVE DEVELOPMENT WITH OTHER DRIVERS/HARDWARE? 116 | ========================================================================= 117 | 118 | The short answer is: Yes. All you get is a guarantee that the IDs are never 119 | assigned to anybody else. What more do you need? 120 | 121 | 122 | ============================ 123 | WHAT ABOUT SHARED ID PAIRS? 124 | ============================ 125 | 126 | Objective Development has reserved some PID/VID pairs for shared use. You 127 | have no guarantee of uniqueness for them, except that no USB compliant device 128 | uses them. In order to avoid technical problems, we must ensure that all 129 | devices with the same pair of IDs use the same driver on kernel level. For 130 | details, see the file USB-IDs-for-free.txt. 131 | 132 | 133 | ====================================================== 134 | I HAVE HEARD THAT SUB-LICENSING OF USB-IDs IS ILLEGAL? 135 | ====================================================== 136 | 137 | A 16 bit integer number cannot be protected by copyright laws. It is not 138 | sufficiently complex. And since none of the parties involved entered into the 139 | USB-IF Trademark License Agreement, we are not bound by this agreement. So 140 | there is no reason why it should be illegal to sub-license USB-IDs. 141 | 142 | 143 | ============================================= 144 | WHO IS LIABLE IF THERE ARE INCOMPATIBILITIES? 145 | ============================================= 146 | 147 | Objective Development disclaims all liabilities which might arise from the 148 | assignment of IDs. If you guarantee product features to your customers 149 | without proper disclaimer, YOU are liable for that. 150 | -------------------------------------------------------------------------------- /firmware/device/usbdrv/USB-IDs-for-free.txt: -------------------------------------------------------------------------------- 1 | Version 2009-08-22 2 | 3 | =========================== 4 | FREE USB-IDs FOR SHARED USE 5 | =========================== 6 | 7 | Objective Development has reserved a set of USB Product-IDs for use according 8 | to the guidelines outlined below. For more information about the concept of 9 | USB IDs please see the file USB-ID-FAQ.txt. Objective Development guarantees 10 | that the IDs listed below are not used by any USB compliant devices. 11 | 12 | 13 | ==================== 14 | MECHANISM OF SHARING 15 | ==================== 16 | 17 | From a technical point of view, two different devices can share the same USB 18 | Vendor- and Product-ID if they require the same driver on operating system 19 | level. We make use of this fact by assigning separate IDs for various device 20 | classes. On application layer, devices must be distinguished by their textual 21 | name or serial number. We offer separate sets of IDs for discrimination by 22 | textual name and for serial number. 23 | 24 | Examples for shared use of USB IDs are included with V-USB in the "examples" 25 | subdirectory. 26 | 27 | 28 | ====================================== 29 | IDs FOR DISCRIMINATION BY TEXTUAL NAME 30 | ====================================== 31 | 32 | If you use one of the IDs listed below, your device and host-side software 33 | must conform to these rules: 34 | 35 | (1) The USB device MUST provide a textual representation of the manufacturer 36 | and product identification. The manufacturer identification MUST be available 37 | at least in USB language 0x0409 (English/US). 38 | 39 | (2) The textual manufacturer identification MUST contain either an Internet 40 | domain name (e.g. "mycompany.com") registered and owned by you, or an e-mail 41 | address under your control (e.g. "myname@gmx.net"). You can embed the domain 42 | name or e-mail address in any string you like, e.g. "Objective Development 43 | http://www.obdev.at/vusb/". 44 | 45 | (3) You are responsible for retaining ownership of the domain or e-mail 46 | address for as long as any of your products are in use. 47 | 48 | (4) You may choose any string for the textual product identification, as long 49 | as this string is unique within the scope of your textual manufacturer 50 | identification. 51 | 52 | (5) Application side device look-up MUST be based on the textual manufacturer 53 | and product identification in addition to VID/PID matching. The driver 54 | matching MUST be a comparison of the entire strings, NOT a sub-string match. 55 | 56 | (6) For devices which implement a particular USB device class (e.g. HID), the 57 | operating system's default class driver MUST be used. If an operating system 58 | driver for Vendor Class devices is needed, this driver must be libusb or 59 | libusb-win32 (see http://libusb.org/ and 60 | http://libusb-win32.sourceforge.net/). 61 | 62 | Table if IDs for discrimination by textual name: 63 | 64 | PID dec (hex) | VID dec (hex) | Description of use 65 | ==============+===============+============================================ 66 | 1500 (0x05dc) | 5824 (0x16c0) | For Vendor Class devices with libusb 67 | --------------+---------------+-------------------------------------------- 68 | 1503 (0x05df) | 5824 (0x16c0) | For generic HID class devices (which are 69 | | | NOT mice, keyboards or joysticks) 70 | --------------+---------------+-------------------------------------------- 71 | 1505 (0x05e1) | 5824 (0x16c0) | For CDC-ACM class devices (modems) 72 | --------------+---------------+-------------------------------------------- 73 | 1508 (0x05e4) | 5824 (0x16c0) | For MIDI class devices 74 | --------------+---------------+-------------------------------------------- 75 | 76 | Note that Windows caches the textual product- and vendor-description for 77 | mice, keyboards and joysticks. Name-bsed discrimination is therefore not 78 | recommended for these device classes. 79 | 80 | 81 | ======================================= 82 | IDs FOR DISCRIMINATION BY SERIAL NUMBER 83 | ======================================= 84 | 85 | If you use one of the IDs listed below, your device and host-side software 86 | must conform to these rules: 87 | 88 | (1) The USB device MUST provide a textual representation of the serial 89 | number, unless ONLY the operating system's default class driver is used. 90 | The serial number string MUST be available at least in USB language 0x0409 91 | (English/US). 92 | 93 | (2) The serial number MUST start with either an Internet domain name (e.g. 94 | "mycompany.com") registered and owned by you, or an e-mail address under your 95 | control (e.g. "myname@gmx.net"), both terminated with a colon (":") character. 96 | You MAY append any string you like for further discrimination of your devices. 97 | 98 | (3) You are responsible for retaining ownership of the domain or e-mail 99 | address for as long as any of your products are in use. 100 | 101 | (5) Application side device look-up MUST be based on the serial number string 102 | in addition to VID/PID matching. The matching must start at the first 103 | character of the serial number string and include the colon character 104 | terminating your domain or e-mail address. It MAY stop anywhere after that. 105 | 106 | (6) For devices which implement a particular USB device class (e.g. HID), the 107 | operating system's default class driver MUST be used. If an operating system 108 | driver for Vendor Class devices is needed, this driver must be libusb or 109 | libusb-win32 (see http://libusb.org/ and 110 | http://libusb-win32.sourceforge.net/). 111 | 112 | (7) If ONLY the operating system's default class driver is used, e.g. for 113 | mice, keyboards, joysticks, CDC or MIDI devices and no discrimination by an 114 | application is needed, the serial number may be omitted. 115 | 116 | 117 | Table if IDs for discrimination by serial number string: 118 | 119 | PID dec (hex) | VID dec (hex) | Description of use 120 | ===============+===============+=========================================== 121 | 10200 (0x27d8) | 5824 (0x16c0) | For Vendor Class devices with libusb 122 | ---------------+---------------+------------------------------------------- 123 | 10201 (0x27d9) | 5824 (0x16c0) | For generic HID class devices (which are 124 | | | NOT mice, keyboards or joysticks) 125 | ---------------+---------------+------------------------------------------- 126 | 10202 (0x27da) | 5824 (0x16c0) | For USB Mice 127 | ---------------+---------------+------------------------------------------- 128 | 10203 (0x27db) | 5824 (0x16c0) | For USB Keyboards 129 | ---------------+---------------+------------------------------------------- 130 | 10204 (0x27dc) | 5824 (0x16c0) | For USB Joysticks 131 | ---------------+---------------+------------------------------------------- 132 | 10205 (0x27dd) | 5824 (0x16c0) | For CDC-ACM class devices (modems) 133 | ---------------+---------------+------------------------------------------- 134 | 10206 (0x27de) | 5824 (0x16c0) | For MIDI class devices 135 | ---------------+---------------+------------------------------------------- 136 | 137 | 138 | ================= 139 | ORIGIN OF USB-IDs 140 | ================= 141 | 142 | OBJECTIVE DEVELOPMENT Software GmbH has obtained all VID/PID pairs listed 143 | here from Wouter van Ooijen (see www.voti.nl) for exclusive disposition. 144 | Wouter van Ooijen has obtained the VID from the USB Implementers Forum, Inc. 145 | (see www.usb.org). The VID is registered for the company name "Van Ooijen 146 | Technische Informatica". 147 | 148 | 149 | ========== 150 | DISCLAIMER 151 | ========== 152 | 153 | OBJECTIVE DEVELOPMENT Software GmbH disclaims all liability for any 154 | problems which are caused by the shared use of these VID/PID pairs. 155 | -------------------------------------------------------------------------------- /firmware/bootloader/firmware/usbdrv/USB-IDs-for-free.txt: -------------------------------------------------------------------------------- 1 | Version 2009-08-22 2 | 3 | =========================== 4 | FREE USB-IDs FOR SHARED USE 5 | =========================== 6 | 7 | Objective Development has reserved a set of USB Product-IDs for use according 8 | to the guidelines outlined below. For more information about the concept of 9 | USB IDs please see the file USB-ID-FAQ.txt. Objective Development guarantees 10 | that the IDs listed below are not used by any USB compliant devices. 11 | 12 | 13 | ==================== 14 | MECHANISM OF SHARING 15 | ==================== 16 | 17 | From a technical point of view, two different devices can share the same USB 18 | Vendor- and Product-ID if they require the same driver on operating system 19 | level. We make use of this fact by assigning separate IDs for various device 20 | classes. On application layer, devices must be distinguished by their textual 21 | name or serial number. We offer separate sets of IDs for discrimination by 22 | textual name and for serial number. 23 | 24 | Examples for shared use of USB IDs are included with V-USB in the "examples" 25 | subdirectory. 26 | 27 | 28 | ====================================== 29 | IDs FOR DISCRIMINATION BY TEXTUAL NAME 30 | ====================================== 31 | 32 | If you use one of the IDs listed below, your device and host-side software 33 | must conform to these rules: 34 | 35 | (1) The USB device MUST provide a textual representation of the manufacturer 36 | and product identification. The manufacturer identification MUST be available 37 | at least in USB language 0x0409 (English/US). 38 | 39 | (2) The textual manufacturer identification MUST contain either an Internet 40 | domain name (e.g. "mycompany.com") registered and owned by you, or an e-mail 41 | address under your control (e.g. "myname@gmx.net"). You can embed the domain 42 | name or e-mail address in any string you like, e.g. "Objective Development 43 | http://www.obdev.at/vusb/". 44 | 45 | (3) You are responsible for retaining ownership of the domain or e-mail 46 | address for as long as any of your products are in use. 47 | 48 | (4) You may choose any string for the textual product identification, as long 49 | as this string is unique within the scope of your textual manufacturer 50 | identification. 51 | 52 | (5) Application side device look-up MUST be based on the textual manufacturer 53 | and product identification in addition to VID/PID matching. The driver 54 | matching MUST be a comparison of the entire strings, NOT a sub-string match. 55 | 56 | (6) For devices which implement a particular USB device class (e.g. HID), the 57 | operating system's default class driver MUST be used. If an operating system 58 | driver for Vendor Class devices is needed, this driver must be libusb or 59 | libusb-win32 (see http://libusb.org/ and 60 | http://libusb-win32.sourceforge.net/). 61 | 62 | Table if IDs for discrimination by textual name: 63 | 64 | PID dec (hex) | VID dec (hex) | Description of use 65 | ==============+===============+============================================ 66 | 1500 (0x05dc) | 5824 (0x16c0) | For Vendor Class devices with libusb 67 | --------------+---------------+-------------------------------------------- 68 | 1503 (0x05df) | 5824 (0x16c0) | For generic HID class devices (which are 69 | | | NOT mice, keyboards or joysticks) 70 | --------------+---------------+-------------------------------------------- 71 | 1505 (0x05e1) | 5824 (0x16c0) | For CDC-ACM class devices (modems) 72 | --------------+---------------+-------------------------------------------- 73 | 1508 (0x05e4) | 5824 (0x16c0) | For MIDI class devices 74 | --------------+---------------+-------------------------------------------- 75 | 76 | Note that Windows caches the textual product- and vendor-description for 77 | mice, keyboards and joysticks. Name-bsed discrimination is therefore not 78 | recommended for these device classes. 79 | 80 | 81 | ======================================= 82 | IDs FOR DISCRIMINATION BY SERIAL NUMBER 83 | ======================================= 84 | 85 | If you use one of the IDs listed below, your device and host-side software 86 | must conform to these rules: 87 | 88 | (1) The USB device MUST provide a textual representation of the serial 89 | number, unless ONLY the operating system's default class driver is used. 90 | The serial number string MUST be available at least in USB language 0x0409 91 | (English/US). 92 | 93 | (2) The serial number MUST start with either an Internet domain name (e.g. 94 | "mycompany.com") registered and owned by you, or an e-mail address under your 95 | control (e.g. "myname@gmx.net"), both terminated with a colon (":") character. 96 | You MAY append any string you like for further discrimination of your devices. 97 | 98 | (3) You are responsible for retaining ownership of the domain or e-mail 99 | address for as long as any of your products are in use. 100 | 101 | (5) Application side device look-up MUST be based on the serial number string 102 | in addition to VID/PID matching. The matching must start at the first 103 | character of the serial number string and include the colon character 104 | terminating your domain or e-mail address. It MAY stop anywhere after that. 105 | 106 | (6) For devices which implement a particular USB device class (e.g. HID), the 107 | operating system's default class driver MUST be used. If an operating system 108 | driver for Vendor Class devices is needed, this driver must be libusb or 109 | libusb-win32 (see http://libusb.org/ and 110 | http://libusb-win32.sourceforge.net/). 111 | 112 | (7) If ONLY the operating system's default class driver is used, e.g. for 113 | mice, keyboards, joysticks, CDC or MIDI devices and no discrimination by an 114 | application is needed, the serial number may be omitted. 115 | 116 | 117 | Table if IDs for discrimination by serial number string: 118 | 119 | PID dec (hex) | VID dec (hex) | Description of use 120 | ===============+===============+=========================================== 121 | 10200 (0x27d8) | 5824 (0x16c0) | For Vendor Class devices with libusb 122 | ---------------+---------------+------------------------------------------- 123 | 10201 (0x27d9) | 5824 (0x16c0) | For generic HID class devices (which are 124 | | | NOT mice, keyboards or joysticks) 125 | ---------------+---------------+------------------------------------------- 126 | 10202 (0x27da) | 5824 (0x16c0) | For USB Mice 127 | ---------------+---------------+------------------------------------------- 128 | 10203 (0x27db) | 5824 (0x16c0) | For USB Keyboards 129 | ---------------+---------------+------------------------------------------- 130 | 10204 (0x27dc) | 5824 (0x16c0) | For USB Joysticks 131 | ---------------+---------------+------------------------------------------- 132 | 10205 (0x27dd) | 5824 (0x16c0) | For CDC-ACM class devices (modems) 133 | ---------------+---------------+------------------------------------------- 134 | 10206 (0x27de) | 5824 (0x16c0) | For MIDI class devices 135 | ---------------+---------------+------------------------------------------- 136 | 137 | 138 | ================= 139 | ORIGIN OF USB-IDs 140 | ================= 141 | 142 | OBJECTIVE DEVELOPMENT Software GmbH has obtained all VID/PID pairs listed 143 | here from Wouter van Ooijen (see www.voti.nl) for exclusive disposition. 144 | Wouter van Ooijen has obtained the VID from the USB Implementers Forum, Inc. 145 | (see www.usb.org). The VID is registered for the company name "Van Ooijen 146 | Technische Informatica". 147 | 148 | 149 | ========== 150 | DISCLAIMER 151 | ========== 152 | 153 | OBJECTIVE DEVELOPMENT Software GmbH disclaims all liability for any 154 | problems which are caused by the shared use of these VID/PID pairs. 155 | -------------------------------------------------------------------------------- /firmware/bootloader/firmware/Makefile: -------------------------------------------------------------------------------- 1 | # Name: Makefile 2 | # Project: USBaspLoader 3 | # Author: Christian Starkjohann 4 | # Creation Date: 2007-12-10 5 | # Tabsize: 4 6 | # Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH 7 | # License: GNU GPL v2 (see License.txt) 8 | # This Revision: $Id$ 9 | 10 | ############################################################################### 11 | # Configure the following variables according to your AVR. 12 | # Program the device with 13 | # make fuse # to set the clock generator, boot section size etc. 14 | # make flash # to load the boot loader into flash 15 | # make lock # to protect the boot loader from overwriting 16 | 17 | F_CPU = 16000000 18 | DEVICE = atmega8 19 | # BOOTLOADER_ADDRESS is 1800 for 8k devices, 3800 for 16k and 7800 for 32k. 20 | BOOTLOADER_ADDRESS = 1800 21 | FUSEOPT = $(FUSEOPT_8) 22 | LOCKOPT = -U lock:w:0x2f:m 23 | 24 | #PROGRAMMER = -c stk500v2 -P avrdoper 25 | PROGRAMMER = -c usbasp 26 | # PROGRAMMER contains AVRDUDE options to address your programmer 27 | 28 | FUSEOPT_8 = -U hfuse:w:0xc0:m -U lfuse:w:0x9f:m 29 | FUSEOPT_88 = -U hfuse:w:0xd6:m -U lfuse:w:0xdf:m -U efuse:w:0x00:m 30 | FUSEOPT_168 = -U hfuse:w:0xd6:m -U lfuse:w:0xdf:m -U efuse:w:0x00:m 31 | FUSEOPT_328 = -U lfuse:w:0xf7:m -U hfuse:w:0xda:m -U efuse:w:0x03:m 32 | # You may have to change the order of these -U commands. 33 | 34 | #--------------------------------------------------------------------- 35 | # ATMega8 36 | #--------------------------------------------------------------------- 37 | # Fuse high byte: 38 | # 0xc0 = 1 1 0 0 0 0 0 0 <-- BOOTRST (boot reset vector at 0x1800) 39 | # ^ ^ ^ ^ ^ ^ ^------ BOOTSZ0 40 | # | | | | | +-------- BOOTSZ1 41 | # | | | | + --------- EESAVE (preserve EEPROM over chip erase) 42 | # | | | +-------------- CKOPT (full output swing) 43 | # | | +---------------- SPIEN (allow serial programming) 44 | # | +------------------ WDTON (WDT not always on) 45 | # +-------------------- RSTDISBL (reset pin is enabled) 46 | # Fuse low byte: 47 | # 0x9f = 1 0 0 1 1 1 1 1 48 | # ^ ^ \ / \--+--/ 49 | # | | | +------- CKSEL 3..0 (external >8M crystal) 50 | # | | +--------------- SUT 1..0 (crystal osc, BOD enabled) 51 | # | +------------------ BODEN (BrownOut Detector enabled) 52 | # +-------------------- BODLEVEL (2.7V) 53 | #--------------------------------------------------------------------- 54 | # ATMega88, ATMega168 55 | #--------------------------------------------------------------------- 56 | # Fuse extended byte: 57 | # 0x00 = 0 0 0 0 0 0 0 0 <-- BOOTRST (boot reset vector at 0x1800) 58 | # \+/ 59 | # +------- BOOTSZ (00 = 2k bytes) 60 | # Fuse high byte: 61 | # 0xd6 = 1 1 0 1 0 1 1 0 62 | # ^ ^ ^ ^ ^ \-+-/ 63 | # | | | | | +------ BODLEVEL 0..2 (110 = 1.8 V) 64 | # | | | | + --------- EESAVE (preserve EEPROM over chip erase) 65 | # | | | +-------------- WDTON (if 0: watchdog always on) 66 | # | | +---------------- SPIEN (allow serial programming) 67 | # | +------------------ DWEN (debug wire enable) 68 | # +-------------------- RSTDISBL (reset pin is enabled) 69 | # Fuse low byte: 70 | # 0xdf = 1 1 0 1 1 1 1 1 71 | # ^ ^ \ / \--+--/ 72 | # | | | +------- CKSEL 3..0 (external >8M crystal) 73 | # | | +--------------- SUT 1..0 (crystal osc, BOD enabled) 74 | # | +------------------ CKOUT (if 0: Clock output enabled) 75 | # +-------------------- CKDIV8 (if 0: divide by 8) 76 | #--------------------------------------------------------------------- 77 | # ATMega328P 78 | #--------------------------------------------------------------------- 79 | # Fuse extended byte: 80 | # 0x03 = - - - - - 0 1 1 81 | # \-+-/ 82 | # +------ BODLEVEL 0..2 (011 = 4.3V) 83 | # Fuse high byte: 84 | # 0xda = 1 1 0 1 1 0 1 0 <-- BOOTRST (0 = jump to bootloader at start) 85 | # ^ ^ ^ ^ ^ \+/ 86 | # | | | | | +------- BOOTSZ 0..1 (01 = 2KB starting at 0x7800) 87 | # | | | | + --------- EESAVE (don't preserve EEPROM over chip erase) 88 | # | | | +-------------- WDTON (1 = watchdog disabled at start) 89 | # | | +---------------- SPIEN (0 = allow serial programming) 90 | # | +------------------ DWEN (1 = debug wire disable) 91 | # +-------------------- RSTDISBL (1 = reset pin is enabled) 92 | # Fuse low byte: 93 | # 0xf7 = 1 1 1 1 0 1 1 1 94 | # ^ ^ \ / \--+--/ 95 | # | | | +------- CKSEL 3..0 (0111 = external full-swing crystal) 96 | # | | +--------------- SUT 1..0 (11 = startup time 16K CK/14K + 65ms) 97 | # | +------------------ CKOUT (1 = clock output disabled) 98 | # +-------------------- CKDIV8 (1 = do not divide clock by 8) 99 | 100 | 101 | ############################################################################### 102 | 103 | # Tools: 104 | AVRDUDE = avrdude $(PROGRAMMER) -p $(DEVICE) 105 | CC = avr-gcc 106 | 107 | # Options: 108 | DEFINES = #-DDEBUG_LEVEL=2 109 | # Remove the -fno-* options when you use gcc 3, it does not understand them 110 | CFLAGS = -Wall -Os -fno-move-loop-invariants -fno-tree-scev-cprop -fno-inline-small-functions -I. -mmcu=$(DEVICE) -DF_CPU=$(F_CPU) $(DEFINES) 111 | LDFLAGS = -Wl,--relax,--gc-sections -Wl,--section-start=.text=$(BOOTLOADER_ADDRESS) 112 | 113 | OBJECTS = usbdrv/usbdrvasm.o usbdrv/oddebug.o main.o 114 | 115 | # symbolic targets: 116 | all: main.hex 117 | 118 | .c.o: 119 | $(CC) $(CFLAGS) -c $< -o $@ 120 | 121 | .S.o: 122 | $(CC) $(CFLAGS) -x assembler-with-cpp -c $< -o $@ 123 | # "-x assembler-with-cpp" should not be necessary since this is the default 124 | # file type for the .S (with capital S) extension. However, upper case 125 | # characters are not always preserved on Windows. To ensure WinAVR 126 | # compatibility define the file type manually. 127 | 128 | .c.s: 129 | $(CC) $(CFLAGS) -S $< -o $@ 130 | 131 | program: all 132 | $(AVRDUDE) -U flash:w:main.hex:i 133 | 134 | readflash: 135 | $(AVRDUDE) -U flash:r:read.hex:i 136 | 137 | fuse: 138 | $(AVRDUDE) $(FUSEOPT) 139 | 140 | lock: 141 | $(AVRDUDE) $(LOCKOPT) 142 | 143 | read_fuses: 144 | $(UISP) --rd_fuses 145 | 146 | clean: 147 | rm -f main.hex main.bin *.o usbdrv/*.o main.s usbdrv/oddebug.s usbdrv/usbdrv.s 148 | 149 | # file targets: 150 | main.bin: $(OBJECTS) 151 | $(CC) $(CFLAGS) -o main.bin $(OBJECTS) $(LDFLAGS) 152 | 153 | main.hex: main.bin 154 | rm -f main.hex main.eep.hex 155 | avr-objcopy -j .text -j .data -O ihex main.bin main.hex 156 | avr-size main.hex 157 | 158 | disasm: main.bin 159 | avr-objdump -d main.bin 160 | 161 | cpp: 162 | $(CC) $(CFLAGS) -E main.c 163 | 164 | # Special rules for generating hex files for various devices and clock speeds 165 | ALLHEXFILES = hexfiles/mega8_12mhz.hex hexfiles/mega8_15mhz.hex hexfiles/mega8_16mhz.hex \ 166 | hexfiles/mega88_12mhz.hex hexfiles/mega88_15mhz.hex hexfiles/mega88_16mhz.hex hexfiles/mega88_20mhz.hex\ 167 | hexfiles/mega168_12mhz.hex hexfiles/mega168_15mhz.hex hexfiles/mega168_16mhz.hex hexfiles/mega168_20mhz.hex\ 168 | hexfiles/mega328p_12mhz.hex hexfiles/mega328p_15mhz.hex hexfiles/mega328p_16mhz.hex hexfiles/mega328p_20mhz.hex 169 | 170 | allhexfiles: $(ALLHEXFILES) 171 | $(MAKE) clean 172 | avr-size hexfiles/*.hex 173 | 174 | $(ALLHEXFILES): 175 | @[ -d hexfiles ] || mkdir hexfiles 176 | @device=`echo $@ | sed -e 's|.*/mega||g' -e 's|_.*||g'`; \ 177 | clock=`echo $@ | sed -e 's|.*_||g' -e 's|mhz.*||g'`; \ 178 | addr=`echo $$device | sed -e 's/\([0-9]\)8/\1/g' | awk '{printf("%x", ($$1 - 2) * 1024)}'`; \ 179 | echo "### Make with F_CPU=$${clock}000000 DEVICE=atmega$$device BOOTLOADER_ADDRESS=$$addr"; \ 180 | $(MAKE) clean; \ 181 | $(MAKE) main.hex F_CPU=$${clock}000000 DEVICE=atmega$$device BOOTLOADER_ADDRESS=$$addr DEFINES=-DUSE_AUTOCONFIG=1 182 | mv main.hex $@ 183 | -------------------------------------------------------------------------------- /firmware/bootloader/firmware/usbdrv/CommercialLicense.txt: -------------------------------------------------------------------------------- 1 | V-USB Driver Software License Agreement 2 | Version 2012-07-09 3 | 4 | THIS LICENSE AGREEMENT GRANTS YOU CERTAIN RIGHTS IN A SOFTWARE. YOU CAN 5 | ENTER INTO THIS AGREEMENT AND ACQUIRE THE RIGHTS OUTLINED BELOW BY PAYING 6 | THE AMOUNT ACCORDING TO SECTION 4 ("PAYMENT") TO OBJECTIVE DEVELOPMENT. 7 | 8 | 9 | 1 DEFINITIONS 10 | 11 | 1.1 "OBJECTIVE DEVELOPMENT" shall mean OBJECTIVE DEVELOPMENT Software GmbH, 12 | Grosse Schiffgasse 1A/7, 1020 Wien, AUSTRIA. 13 | 14 | 1.2 "You" shall mean the Licensee. 15 | 16 | 1.3 "V-USB" shall mean all files included in the package distributed under 17 | the name "vusb" by OBJECTIVE DEVELOPMENT (http://www.obdev.at/vusb/) 18 | unless otherwise noted. This includes the firmware-only USB device 19 | implementation for Atmel AVR microcontrollers, some simple device examples 20 | and host side software examples and libraries. 21 | 22 | 23 | 2 LICENSE GRANTS 24 | 25 | 2.1 Source Code. OBJECTIVE DEVELOPMENT shall furnish you with the source 26 | code of V-USB. 27 | 28 | 2.2 Distribution and Use. OBJECTIVE DEVELOPMENT grants you the 29 | non-exclusive right to use, copy and distribute V-USB with your hardware 30 | product(s), restricted by the limitations in section 3 below. 31 | 32 | 2.3 Modifications. OBJECTIVE DEVELOPMENT grants you the right to modify 33 | the source code and your copy of V-USB according to your needs. 34 | 35 | 2.4 USB IDs. OBJECTIVE DEVELOPMENT furnishes you with one or two USB 36 | Product ID(s), sent to you in e-mail. These Product IDs are reserved 37 | exclusively for you. OBJECTIVE DEVELOPMENT has obtained USB Product ID 38 | ranges under the Vendor ID 5824 from Wouter van Ooijen (Van Ooijen 39 | Technische Informatica, www.voti.nl) and under the Vendor ID 8352 from 40 | Jason Kotzin (now flirc.tv, Inc.). Both owners of the Vendor IDs have 41 | obtained these IDs from the USB Implementers Forum, Inc. (www.usb.org). 42 | OBJECTIVE DEVELOPMENT disclaims all liability which might arise from the 43 | assignment of USB IDs. 44 | 45 | 2.5 USB Certification. Although not part of this agreement, we want to make 46 | it clear that you cannot become USB certified when you use V-USB or a USB 47 | Product ID assigned by OBJECTIVE DEVELOPMENT. AVR microcontrollers don't 48 | meet the electrical specifications required by the USB specification and 49 | the USB Implementers Forum certifies only members who bought a Vendor ID of 50 | their own. 51 | 52 | 53 | 3 LICENSE RESTRICTIONS 54 | 55 | 3.1 Number of Units. Only one of the following three definitions is 56 | applicable. Which one is determined by the amount you pay to OBJECTIVE 57 | DEVELOPMENT, see section 4 ("Payment") below. 58 | 59 | Hobby License: You may use V-USB according to section 2 above in no more 60 | than 5 hardware units. These units must not be sold for profit. 61 | 62 | Entry Level License: You may use V-USB according to section 2 above in no 63 | more than 150 hardware units. 64 | 65 | Professional License: You may use V-USB according to section 2 above in 66 | any number of hardware units, except for large scale production ("unlimited 67 | fair use"). Quantities below 10,000 units are not considered large scale 68 | production. If your reach quantities which are obviously large scale 69 | production, you must pay a license fee of 0.10 EUR per unit for all units 70 | above 10,000. 71 | 72 | 3.2 Rental. You may not rent, lease, or lend V-USB or otherwise encumber 73 | any copy of V-USB, or any of the rights granted herein. 74 | 75 | 3.3 Transfer. You may not transfer your rights under this Agreement to 76 | another party without OBJECTIVE DEVELOPMENT's prior written consent. If 77 | such consent is obtained, you may permanently transfer this License to 78 | another party. The recipient of such transfer must agree to all terms and 79 | conditions of this Agreement. 80 | 81 | 3.4 Reservation of Rights. OBJECTIVE DEVELOPMENT retains all rights not 82 | expressly granted. 83 | 84 | 3.5 Non-Exclusive Rights. Your license rights under this Agreement are 85 | non-exclusive. 86 | 87 | 3.6 Third Party Rights. This Agreement cannot grant you rights controlled 88 | by third parties. In particular, you are not allowed to use the USB logo or 89 | other trademarks owned by the USB Implementers Forum, Inc. without their 90 | consent. Since such consent depends on USB certification, it should be 91 | noted that V-USB will not pass certification because it does not 92 | implement checksum verification and the microcontroller ports do not meet 93 | the electrical specifications. 94 | 95 | 96 | 4 PAYMENT 97 | 98 | The payment amount depends on the variation of this agreement (according to 99 | section 3.1) into which you want to enter. Concrete prices are listed on 100 | OBJECTIVE DEVELOPMENT's web site, usually at 101 | http://www.obdev.at/vusb/license.html. You agree to pay the amount listed 102 | there to OBJECTIVE DEVELOPMENT or OBJECTIVE DEVELOPMENT's payment processor 103 | or reseller. 104 | 105 | 106 | 5 COPYRIGHT AND OWNERSHIP 107 | 108 | V-USB is protected by copyright laws and international copyright 109 | treaties, as well as other intellectual property laws and treaties. V-USB 110 | is licensed, not sold. 111 | 112 | 113 | 6 TERM AND TERMINATION 114 | 115 | 6.1 Term. This Agreement shall continue indefinitely. However, OBJECTIVE 116 | DEVELOPMENT may terminate this Agreement and revoke the granted license and 117 | USB-IDs if you fail to comply with any of its terms and conditions. 118 | 119 | 6.2 Survival of Terms. All provisions regarding secrecy, confidentiality 120 | and limitation of liability shall survive termination of this agreement. 121 | 122 | 123 | 7 DISCLAIMER OF WARRANTY AND LIABILITY 124 | 125 | LIMITED WARRANTY. V-USB IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 126 | KIND. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, OBJECTIVE 127 | DEVELOPMENT AND ITS SUPPLIERS HEREBY DISCLAIM ALL WARRANTIES, EITHER 128 | EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 129 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE, AND 130 | NON-INFRINGEMENT, WITH REGARD TO V-USB, AND THE PROVISION OF OR FAILURE 131 | TO PROVIDE SUPPORT SERVICES. THIS LIMITED WARRANTY GIVES YOU SPECIFIC LEGAL 132 | RIGHTS. YOU MAY HAVE OTHERS, WHICH VARY FROM STATE/JURISDICTION TO 133 | STATE/JURISDICTION. 134 | 135 | LIMITATION OF LIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, 136 | IN NO EVENT SHALL OBJECTIVE DEVELOPMENT OR ITS SUPPLIERS BE LIABLE FOR ANY 137 | SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER 138 | (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, 139 | BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR ANY OTHER PECUNIARY 140 | LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE V-USB OR THE 141 | PROVISION OF OR FAILURE TO PROVIDE SUPPORT SERVICES, EVEN IF OBJECTIVE 142 | DEVELOPMENT HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. IN ANY 143 | CASE, OBJECTIVE DEVELOPMENT'S ENTIRE LIABILITY UNDER ANY PROVISION OF THIS 144 | AGREEMENT SHALL BE LIMITED TO THE AMOUNT ACTUALLY PAID BY YOU FOR V-USB. 145 | 146 | 147 | 8 MISCELLANEOUS TERMS 148 | 149 | 8.1 Marketing. OBJECTIVE DEVELOPMENT has the right to mention for marketing 150 | purposes that you entered into this agreement. 151 | 152 | 8.2 Entire Agreement. This document represents the entire agreement between 153 | OBJECTIVE DEVELOPMENT and you. It may only be modified in writing signed by 154 | an authorized representative of both, OBJECTIVE DEVELOPMENT and you. 155 | 156 | 8.3 Severability. In case a provision of these terms and conditions should 157 | be or become partly or entirely invalid, ineffective, or not executable, 158 | the validity of all other provisions shall not be affected. 159 | 160 | 8.4 Applicable Law. This agreement is governed by the laws of the Republic 161 | of Austria. 162 | 163 | 8.5 Responsible Courts. The responsible courts in Vienna/Austria will have 164 | exclusive jurisdiction regarding all disputes in connection with this 165 | agreement. 166 | 167 | -------------------------------------------------------------------------------- /firmware/device/usbdrv/CommercialLicense.txt: -------------------------------------------------------------------------------- 1 | V-USB Driver Software License Agreement 2 | Version 2009-08-03 3 | 4 | THIS LICENSE AGREEMENT GRANTS YOU CERTAIN RIGHTS IN A SOFTWARE. YOU CAN 5 | ENTER INTO THIS AGREEMENT AND ACQUIRE THE RIGHTS OUTLINED BELOW BY PAYING 6 | THE AMOUNT ACCORDING TO SECTION 4 ("PAYMENT") TO OBJECTIVE DEVELOPMENT. 7 | 8 | 9 | 1 DEFINITIONS 10 | 11 | 1.1 "OBJECTIVE DEVELOPMENT" shall mean OBJECTIVE DEVELOPMENT Software GmbH, 12 | Grosse Schiffgasse 1A/7, 1020 Wien, AUSTRIA. 13 | 14 | 1.2 "You" shall mean the Licensee. 15 | 16 | 1.3 "V-USB" shall mean all files included in the package distributed under 17 | the name "vusb" by OBJECTIVE DEVELOPMENT (http://www.obdev.at/vusb/) 18 | unless otherwise noted. This includes the firmware-only USB device 19 | implementation for Atmel AVR microcontrollers, some simple device examples 20 | and host side software examples and libraries. 21 | 22 | 23 | 2 LICENSE GRANTS 24 | 25 | 2.1 Source Code. OBJECTIVE DEVELOPMENT shall furnish you with the source 26 | code of V-USB. 27 | 28 | 2.2 Distribution and Use. OBJECTIVE DEVELOPMENT grants you the 29 | non-exclusive right to use, copy and distribute V-USB with your hardware 30 | product(s), restricted by the limitations in section 3 below. 31 | 32 | 2.3 Modifications. OBJECTIVE DEVELOPMENT grants you the right to modify 33 | the source code and your copy of V-USB according to your needs. 34 | 35 | 2.4 USB IDs. OBJECTIVE DEVELOPMENT furnishes you with one or two USB 36 | Product ID(s), sent to you in e-mail. These Product IDs are reserved 37 | exclusively for you. OBJECTIVE DEVELOPMENT has obtained USB Product ID 38 | ranges under the Vendor ID 5824 from Wouter van Ooijen (Van Ooijen 39 | Technische Informatica, www.voti.nl) and under the Vendor ID 8352 from 40 | Jason Kotzin (Clay Logic, www.claylogic.com). Both owners of the Vendor IDs 41 | have obtained these IDs from the USB Implementers Forum, Inc. 42 | (www.usb.org). OBJECTIVE DEVELOPMENT disclaims all liability which might 43 | arise from the assignment of USB IDs. 44 | 45 | 2.5 USB Certification. Although not part of this agreement, we want to make 46 | it clear that you cannot become USB certified when you use V-USB or a USB 47 | Product ID assigned by OBJECTIVE DEVELOPMENT. AVR microcontrollers don't 48 | meet the electrical specifications required by the USB specification and 49 | the USB Implementers Forum certifies only members who bought a Vendor ID of 50 | their own. 51 | 52 | 53 | 3 LICENSE RESTRICTIONS 54 | 55 | 3.1 Number of Units. Only one of the following three definitions is 56 | applicable. Which one is determined by the amount you pay to OBJECTIVE 57 | DEVELOPMENT, see section 4 ("Payment") below. 58 | 59 | Hobby License: You may use V-USB according to section 2 above in no more 60 | than 5 hardware units. These units must not be sold for profit. 61 | 62 | Entry Level License: You may use V-USB according to section 2 above in no 63 | more than 150 hardware units. 64 | 65 | Professional License: You may use V-USB according to section 2 above in 66 | any number of hardware units, except for large scale production ("unlimited 67 | fair use"). Quantities below 10,000 units are not considered large scale 68 | production. If your reach quantities which are obviously large scale 69 | production, you must pay a license fee of 0.10 EUR per unit for all units 70 | above 10,000. 71 | 72 | 3.2 Rental. You may not rent, lease, or lend V-USB or otherwise encumber 73 | any copy of V-USB, or any of the rights granted herein. 74 | 75 | 3.3 Transfer. You may not transfer your rights under this Agreement to 76 | another party without OBJECTIVE DEVELOPMENT's prior written consent. If 77 | such consent is obtained, you may permanently transfer this License to 78 | another party. The recipient of such transfer must agree to all terms and 79 | conditions of this Agreement. 80 | 81 | 3.4 Reservation of Rights. OBJECTIVE DEVELOPMENT retains all rights not 82 | expressly granted. 83 | 84 | 3.5 Non-Exclusive Rights. Your license rights under this Agreement are 85 | non-exclusive. 86 | 87 | 3.6 Third Party Rights. This Agreement cannot grant you rights controlled 88 | by third parties. In particular, you are not allowed to use the USB logo or 89 | other trademarks owned by the USB Implementers Forum, Inc. without their 90 | consent. Since such consent depends on USB certification, it should be 91 | noted that V-USB will not pass certification because it does not 92 | implement checksum verification and the microcontroller ports do not meet 93 | the electrical specifications. 94 | 95 | 96 | 4 PAYMENT 97 | 98 | The payment amount depends on the variation of this agreement (according to 99 | section 3.1) into which you want to enter. Concrete prices are listed on 100 | OBJECTIVE DEVELOPMENT's web site, usually at 101 | http://www.obdev.at/vusb/license.html. You agree to pay the amount listed 102 | there to OBJECTIVE DEVELOPMENT or OBJECTIVE DEVELOPMENT's payment processor 103 | or reseller. 104 | 105 | 106 | 5 COPYRIGHT AND OWNERSHIP 107 | 108 | V-USB is protected by copyright laws and international copyright 109 | treaties, as well as other intellectual property laws and treaties. V-USB 110 | is licensed, not sold. 111 | 112 | 113 | 6 TERM AND TERMINATION 114 | 115 | 6.1 Term. This Agreement shall continue indefinitely. However, OBJECTIVE 116 | DEVELOPMENT may terminate this Agreement and revoke the granted license and 117 | USB-IDs if you fail to comply with any of its terms and conditions. 118 | 119 | 6.2 Survival of Terms. All provisions regarding secrecy, confidentiality 120 | and limitation of liability shall survive termination of this agreement. 121 | 122 | 123 | 7 DISCLAIMER OF WARRANTY AND LIABILITY 124 | 125 | LIMITED WARRANTY. V-USB IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 126 | KIND. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, OBJECTIVE 127 | DEVELOPMENT AND ITS SUPPLIERS HEREBY DISCLAIM ALL WARRANTIES, EITHER 128 | EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 129 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE, AND 130 | NON-INFRINGEMENT, WITH REGARD TO V-USB, AND THE PROVISION OF OR FAILURE 131 | TO PROVIDE SUPPORT SERVICES. THIS LIMITED WARRANTY GIVES YOU SPECIFIC LEGAL 132 | RIGHTS. YOU MAY HAVE OTHERS, WHICH VARY FROM STATE/JURISDICTION TO 133 | STATE/JURISDICTION. 134 | 135 | LIMITATION OF LIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, 136 | IN NO EVENT SHALL OBJECTIVE DEVELOPMENT OR ITS SUPPLIERS BE LIABLE FOR ANY 137 | SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER 138 | (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, 139 | BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR ANY OTHER PECUNIARY 140 | LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE V-USB OR THE 141 | PROVISION OF OR FAILURE TO PROVIDE SUPPORT SERVICES, EVEN IF OBJECTIVE 142 | DEVELOPMENT HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. IN ANY 143 | CASE, OBJECTIVE DEVELOPMENT'S ENTIRE LIABILITY UNDER ANY PROVISION OF THIS 144 | AGREEMENT SHALL BE LIMITED TO THE AMOUNT ACTUALLY PAID BY YOU FOR V-USB. 145 | 146 | 147 | 8 MISCELLANEOUS TERMS 148 | 149 | 8.1 Marketing. OBJECTIVE DEVELOPMENT has the right to mention for marketing 150 | purposes that you entered into this agreement. 151 | 152 | 8.2 Entire Agreement. This document represents the entire agreement between 153 | OBJECTIVE DEVELOPMENT and you. It may only be modified in writing signed by 154 | an authorized representative of both, OBJECTIVE DEVELOPMENT and you. 155 | 156 | 8.3 Severability. In case a provision of these terms and conditions should 157 | be or become partly or entirely invalid, ineffective, or not executable, 158 | the validity of all other provisions shall not be affected. 159 | 160 | 8.4 Applicable Law. This agreement is governed by the laws of the Republic 161 | of Austria. 162 | 163 | 8.5 Responsible Courts. The responsible courts in Vienna/Austria will have 164 | exclusive jurisdiction regarding all disputes in connection with this 165 | agreement. 166 | 167 | -------------------------------------------------------------------------------- /firmware/bootloader/firmware/bootloaderconfig.h: -------------------------------------------------------------------------------- 1 | /* Name: bootloaderconfig.h 2 | * Project: USBaspLoader 3 | * Author: Christian Starkjohann 4 | * Creation Date: 2007-12-08 5 | * Tabsize: 4 6 | * Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH 7 | * License: GNU GPL v2 (see License.txt) 8 | * This Revision: $Id$ 9 | */ 10 | 11 | #ifndef __bootloaderconfig_h_included__ 12 | #define __bootloaderconfig_h_included__ 13 | 14 | /* 15 | General Description: 16 | This file (together with some settings in Makefile) configures the boot loader 17 | according to the hardware. 18 | 19 | This file contains (besides the hardware configuration normally found in 20 | usbconfig.h) two functions or macros: bootLoaderInit() and 21 | bootLoaderCondition(). Whether you implement them as macros or as static 22 | inline functions is up to you, decide based on code size and convenience. 23 | 24 | bootLoaderInit() is called as one of the first actions after reset. It should 25 | be a minimum initialization of the hardware so that the boot loader condition 26 | can be read. This will usually consist of activating a pull-up resistor for an 27 | external jumper which selects boot loader mode. 28 | 29 | bootLoaderCondition() is called immediately after initialization and in each 30 | main loop iteration. If it returns TRUE, the boot loader will be active. If it 31 | returns FALSE, the boot loader jumps to address 0 (the loaded application) 32 | immediately. 33 | 34 | For compatibility with Thomas Fischl's avrusbboot, we also support the macro 35 | names BOOTLOADER_INIT and BOOTLOADER_CONDITION for this functionality. If 36 | these macros are defined, the boot loader usees them. 37 | */ 38 | 39 | /* ---------------------------- Hardware Config ---------------------------- */ 40 | 41 | #define USB_CFG_IOPORTNAME D 42 | /* This is the port where the USB bus is connected. When you configure it to 43 | * "B", the registers PORTB, PINB and DDRB will be used. 44 | */ 45 | #define USB_CFG_DMINUS_BIT 3 46 | /* This is the bit number in USB_CFG_IOPORT where the USB D- line is connected. 47 | * This may be any bit in the port. 48 | */ 49 | #define USB_CFG_DPLUS_BIT 2 50 | /* This is the bit number in USB_CFG_IOPORT where the USB D+ line is connected. 51 | * This may be any bit in the port. Please note that D+ must also be connected 52 | * to interrupt pin INT0! 53 | */ 54 | #define USB_CFG_CLOCK_KHZ (F_CPU/1000) 55 | /* Clock rate of the AVR in MHz. Legal values are 12000, 16000 or 16500. 56 | * The 16.5 MHz version of the code requires no crystal, it tolerates +/- 1% 57 | * deviation from the nominal frequency. All other rates require a precision 58 | * of 2000 ppm and thus a crystal! 59 | * Default if not specified: 12 MHz 60 | */ 61 | 62 | /* ----------------------- Optional Hardware Config ------------------------ */ 63 | 64 | #define USB_CFG_PULLUP_IOPORTNAME D 65 | /* If you connect the 1.5k pullup resistor from D- to a port pin instead of 66 | * V+, you can connect and disconnect the device from firmware by calling 67 | * the macros usbDeviceConnect() and usbDeviceDisconnect() (see usbdrv.h). 68 | * This constant defines the port on which the pullup resistor is connected. 69 | */ 70 | #define USB_CFG_PULLUP_BIT 4 71 | /* This constant defines the bit number in USB_CFG_PULLUP_IOPORT (defined 72 | * above) where the 1.5k pullup resistor is connected. See description 73 | * above for details. 74 | */ 75 | 76 | /* ------------------------------------------------------------------------- */ 77 | /* ---------------------- feature / code size options ---------------------- */ 78 | /* ------------------------------------------------------------------------- */ 79 | 80 | #define HAVE_EEPROM_PAGED_ACCESS 1 81 | /* If HAVE_EEPROM_PAGED_ACCESS is defined to 1, page mode access to EEPROM is 82 | * compiled in. Whether page mode or byte mode access is used by AVRDUDE 83 | * depends on the target device. Page mode is only used if the device supports 84 | * it, e.g. for the ATMega88, 168 etc. You can save quite a bit of memory by 85 | * disabling page mode EEPROM access. Costs ~ 138 bytes. 86 | */ 87 | #define HAVE_EEPROM_BYTE_ACCESS 1 88 | /* If HAVE_EEPROM_BYTE_ACCESS is defined to 1, byte mode access to EEPROM is 89 | * compiled in. Byte mode is only used if the device (as identified by its 90 | * signature) does not support page mode for EEPROM. It is required for 91 | * accessing the EEPROM on the ATMega8. Costs ~54 bytes. 92 | */ 93 | #define BOOTLOADER_CAN_EXIT 1 94 | /* If this macro is defined to 1, the boot loader will exit shortly after the 95 | * programmer closes the connection to the device. Costs ~36 bytes. 96 | */ 97 | #define HAVE_CHIP_ERASE 0 98 | /* If this macro is defined to 1, the boot loader implements the Chip Erase 99 | * ISP command. Otherwise pages are erased on demand before they are written. 100 | */ 101 | //#define SIGNATURE_BYTES 0x1e, 0x93, 0x07, 0 /* ATMega8 */ 102 | /* This macro defines the signature bytes returned by the emulated USBasp to 103 | * the programmer software. They should match the actual device at least in 104 | * memory size and features. If you don't define this, values for ATMega8, 105 | * ATMega88, ATMega168 and ATMega328 are guessed correctly. 106 | */ 107 | 108 | /* The following block guesses feature options so that the resulting code 109 | * should fit into 2k bytes boot block with the given device and clock rate. 110 | * Activate by passing "-DUSE_AUTOCONFIG=1" to the compiler. 111 | * This requires gcc 3.4.6 for small enough code size! 112 | */ 113 | #if USE_AUTOCONFIG 114 | # undef HAVE_EEPROM_PAGED_ACCESS 115 | # define HAVE_EEPROM_PAGED_ACCESS (USB_CFG_CLOCK_KHZ >= 16000) 116 | # undef HAVE_EEPROM_BYTE_ACCESS 117 | # define HAVE_EEPROM_BYTE_ACCESS 1 118 | # undef BOOTLOADER_CAN_EXIT 119 | # define BOOTLOADER_CAN_EXIT 1 120 | # undef SIGNATURE_BYTES 121 | #endif /* USE_AUTOCONFIG */ 122 | 123 | /* ------------------------------------------------------------------------- */ 124 | 125 | /* Example configuration: Port B bit 2 is connected to a jumper which ties 126 | * this pin to GND if the boot loader is requested. Initialization allows 127 | * several clock cycles for the input voltage to stabilize before 128 | * bootLoaderCondition() samples the value. 129 | * We use a function for bootLoaderInit() for convenience and a macro for 130 | * bootLoaderCondition() for efficiency. 131 | */ 132 | 133 | #ifndef __ASSEMBLER__ /* assembler cannot parse function definitions */ 134 | 135 | 136 | 137 | // 138 | // Definitions for boot condition: Both buttons pressed 139 | // 140 | #define BIT_BT1 1 // Button SEND on PB1 141 | #define BIT_BT2 1 // Button SELECT on PD1 142 | 143 | //#define DDR_BT1 DDRB // no need to use, since all pins are inputs 144 | //#define DDR_BT2 DDRD // right after the Reset 145 | 146 | #define PORT_BT1 PORTB 147 | #define PORT_BT2 PORTD 148 | 149 | #define PIN_BT1 PINB 150 | #define PIN_BT2 PIND 151 | 152 | // compatibility between ATMega8 and ATMega88 153 | #ifndef MCUCSR 154 | # define MCUCSR MCUSR 155 | #endif 156 | 157 | static inline void bootLoaderInit(void) 158 | { 159 | 160 | PORT_BT1 |= (1 << BIT_BT1); // activate pull-ups 161 | PORT_BT2 |= (1 << BIT_BT2); 162 | 163 | if (((PIN_BT1 & (1 << BIT_BT1)) | (PIN_BT2 & (1 << BIT_BT2))) == 0 ) { // if both buttons down 164 | 165 | // Update Configuration byte when entering bootloader // UL 0 NL SL [ slot ] 166 | eeprom_write_byte ((uint8_t *)E2END, 0xb0); // 1 0 1 1 0000 => 0xb0 167 | 168 | MCUCSR = 0; 169 | return; // continue to bootloader 170 | } 171 | 172 | // go to applicaton 173 | leaveBootloader(); 174 | } 175 | 176 | 177 | static inline void bootLoaderExit(void) 178 | { 179 | PORT_BT1 = 0; // undo bootLoaderInit() changes 180 | PORT_BT2 = 0; 181 | } 182 | 183 | #define bootLoaderCondition() (1) // Always true, otherwise both buttons should be pressed all the time 184 | // during upload 185 | 186 | #endif /* __ASSEMBLER__ */ 187 | 188 | /* ------------------------------------------------------------------------- */ 189 | 190 | #endif /* __bootloader_h_included__ */ 191 | -------------------------------------------------------------------------------- /firmware/bootloader/firmware/usbdrv/asmcommon.inc: -------------------------------------------------------------------------------- 1 | /* Name: asmcommon.inc 2 | * Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers 3 | * Author: Christian Starkjohann 4 | * Creation Date: 2007-11-05 5 | * Tabsize: 4 6 | * Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH 7 | * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) 8 | */ 9 | 10 | /* Do not link this file! Link usbdrvasm.S instead, which includes the 11 | * appropriate implementation! 12 | */ 13 | 14 | /* 15 | General Description: 16 | This file contains assembler code which is shared among the USB driver 17 | implementations for different CPU cocks. Since the code must be inserted 18 | in the middle of the module, it's split out into this file and #included. 19 | 20 | Jump destinations called from outside: 21 | sofError: Called when no start sequence was found. 22 | se0: Called when a package has been successfully received. 23 | overflow: Called when receive buffer overflows. 24 | doReturn: Called after sending data. 25 | 26 | Outside jump destinations used by this module: 27 | waitForJ: Called to receive an already arriving packet. 28 | sendAckAndReti: 29 | sendNakAndReti: 30 | sendCntAndReti: 31 | usbSendAndReti: 32 | 33 | The following macros must be defined before this file is included: 34 | .macro POP_STANDARD 35 | .endm 36 | .macro POP_RETI 37 | .endm 38 | */ 39 | 40 | #define token x1 41 | 42 | overflow: 43 | ldi x2, 1< 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | static void leaveBootloader() __attribute__((__noreturn__)); 21 | 22 | #include "bootloaderconfig.h" 23 | #include "usbdrv/usbdrv.c" 24 | 25 | /* ------------------------------------------------------------------------ */ 26 | 27 | /* Request constants used by USBasp */ 28 | #define USBASP_FUNC_CONNECT 1 29 | #define USBASP_FUNC_DISCONNECT 2 30 | #define USBASP_FUNC_TRANSMIT 3 31 | #define USBASP_FUNC_READFLASH 4 32 | #define USBASP_FUNC_ENABLEPROG 5 33 | #define USBASP_FUNC_WRITEFLASH 6 34 | #define USBASP_FUNC_READEEPROM 7 35 | #define USBASP_FUNC_WRITEEEPROM 8 36 | #define USBASP_FUNC_SETLONGADDRESS 9 37 | 38 | /* ------------------------------------------------------------------------ */ 39 | 40 | #ifndef ulong 41 | # define ulong unsigned long 42 | #endif 43 | #ifndef uint 44 | # define uint unsigned int 45 | #endif 46 | 47 | /* defaults if not in config file: */ 48 | #ifndef HAVE_EEPROM_PAGED_ACCESS 49 | # define HAVE_EEPROM_PAGED_ACCESS 0 50 | #endif 51 | #ifndef HAVE_EEPROM_BYTE_ACCESS 52 | # define HAVE_EEPROM_BYTE_ACCESS 0 53 | #endif 54 | #ifndef BOOTLOADER_CAN_EXIT 55 | # define BOOTLOADER_CAN_EXIT 0 56 | #endif 57 | 58 | /* allow compatibility with avrusbboot's bootloaderconfig.h: */ 59 | #ifdef BOOTLOADER_INIT 60 | # define bootLoaderInit() BOOTLOADER_INIT 61 | # define bootLoaderExit() 62 | #endif 63 | #ifdef BOOTLOADER_CONDITION 64 | # define bootLoaderCondition() BOOTLOADER_CONDITION 65 | #endif 66 | 67 | /* device compatibility: */ 68 | #ifndef GICR /* ATMega*8 don't have GICR, use MCUCR instead */ 69 | # define GICR MCUCR 70 | #endif 71 | 72 | /* ------------------------------------------------------------------------ */ 73 | 74 | #if (FLASHEND) > 0xffff /* we need long addressing */ 75 | # define CURRENT_ADDRESS currentAddress.l 76 | # define addr_t ulong 77 | #else 78 | # define CURRENT_ADDRESS currentAddress.w[0] 79 | # define addr_t uint 80 | #endif 81 | 82 | typedef union longConverter{ 83 | addr_t l; 84 | uint w[sizeof(addr_t)/2]; 85 | uchar b[sizeof(addr_t)]; 86 | }longConverter_t; 87 | 88 | static uchar requestBootLoaderExit; 89 | static longConverter_t currentAddress; /* in bytes */ 90 | static uchar bytesRemaining; 91 | static uchar isLastPage; 92 | #if HAVE_EEPROM_PAGED_ACCESS 93 | static uchar currentRequest; 94 | #else 95 | static const uchar currentRequest = 0; 96 | #endif 97 | 98 | static const uchar signatureBytes[4] = { 99 | #ifdef SIGNATURE_BYTES 100 | SIGNATURE_BYTES 101 | #elif defined (__AVR_ATmega8__) || defined (__AVR_ATmega8HVA__) 102 | 0x1e, 0x93, 0x07, 0 103 | #elif defined (__AVR_ATmega48__) || defined (__AVR_ATmega48P__) 104 | 0x1e, 0x92, 0x05, 0 105 | #elif defined (__AVR_ATmega88__) || defined (__AVR_ATmega88P__) 106 | 0x1e, 0x93, 0x0a, 0 107 | #elif defined (__AVR_ATmega168__) || defined (__AVR_ATmega168P__) 108 | 0x1e, 0x94, 0x06, 0 109 | #elif defined (__AVR_ATmega328P__) 110 | 0x1e, 0x95, 0x0f, 0 111 | #else 112 | # error "Device signature is not known, please edit main.c!" 113 | #endif 114 | }; 115 | 116 | /* ------------------------------------------------------------------------ */ 117 | 118 | static void (*nullVector)(void) __attribute__((__noreturn__)); 119 | 120 | static void leaveBootloader() 121 | { 122 | DBG1(0x01, 0, 0); 123 | bootLoaderExit(); 124 | cli(); 125 | USB_INTR_ENABLE = 0; 126 | USB_INTR_CFG = 0; /* also reset config bits */ 127 | GICR = (1 << IVCE); /* enable change of interrupt vectors */ 128 | GICR = (0 << IVSEL); /* move interrupts to application flash section */ 129 | /* We must go through a global function pointer variable instead of writing 130 | * ((void (*)(void))0)(); 131 | * because the compiler optimizes a constant 0 to "rcall 0" which is not 132 | * handled correctly by the assembler. 133 | */ 134 | nullVector(); 135 | } 136 | 137 | /* ------------------------------------------------------------------------ */ 138 | 139 | uchar usbFunctionSetup(uchar data[8]) 140 | { 141 | usbRequest_t *rq = (void *)data; 142 | uchar len = 0; 143 | static uchar replyBuffer[4]; 144 | 145 | usbMsgPtr = (usbMsgPtr_t)replyBuffer; 146 | if(rq->bRequest == USBASP_FUNC_TRANSMIT){ /* emulate parts of ISP protocol */ 147 | uchar rval = 0; 148 | usbWord_t address; 149 | address.bytes[1] = rq->wValue.bytes[1]; 150 | address.bytes[0] = rq->wIndex.bytes[0]; 151 | if(rq->wValue.bytes[0] == 0x30){ /* read signature */ 152 | rval = rq->wIndex.bytes[0] & 3; 153 | rval = signatureBytes[rval]; 154 | #if HAVE_EEPROM_BYTE_ACCESS 155 | }else if(rq->wValue.bytes[0] == 0xa0){ /* read EEPROM byte */ 156 | rval = eeprom_read_byte((void *)address.word); 157 | }else if(rq->wValue.bytes[0] == 0xc0){ /* write EEPROM byte */ 158 | eeprom_write_byte((void *)address.word, rq->wIndex.bytes[1]); 159 | #endif 160 | #if HAVE_CHIP_ERASE 161 | }else if(rq->wValue.bytes[0] == 0xac && rq->wValue.bytes[1] == 0x80){ /* chip erase */ 162 | addr_t addr; 163 | for(addr = 0; addr < FLASHEND + 1 - 2048; addr += SPM_PAGESIZE) { 164 | /* wait and erase page */ 165 | DBG1(0x33, 0, 0); 166 | # ifndef NO_FLASH_WRITE 167 | boot_spm_busy_wait(); 168 | cli(); 169 | boot_page_erase(addr); 170 | sei(); 171 | # endif 172 | } 173 | #endif 174 | }else{ 175 | /* ignore all others, return default value == 0 */ 176 | } 177 | replyBuffer[3] = rval; 178 | len = 4; 179 | }else if(rq->bRequest == USBASP_FUNC_ENABLEPROG){ 180 | /* replyBuffer[0] = 0; is never touched and thus always 0 which means success */ 181 | len = 1; 182 | }else if(rq->bRequest >= USBASP_FUNC_READFLASH && rq->bRequest <= USBASP_FUNC_SETLONGADDRESS){ 183 | currentAddress.w[0] = rq->wValue.word; 184 | if(rq->bRequest == USBASP_FUNC_SETLONGADDRESS){ 185 | #if (FLASHEND) > 0xffff 186 | currentAddress.w[1] = rq->wIndex.word; 187 | #endif 188 | }else{ 189 | bytesRemaining = rq->wLength.bytes[0]; 190 | /* if(rq->bRequest == USBASP_FUNC_WRITEFLASH) only evaluated during writeFlash anyway */ 191 | isLastPage = rq->wIndex.bytes[1] & 0x02; 192 | #if HAVE_EEPROM_PAGED_ACCESS 193 | currentRequest = rq->bRequest; 194 | #endif 195 | len = 0xff; /* hand over to usbFunctionRead() / usbFunctionWrite() */ 196 | } 197 | #if BOOTLOADER_CAN_EXIT 198 | }else if(rq->bRequest == USBASP_FUNC_DISCONNECT){ 199 | requestBootLoaderExit = 1; /* allow proper shutdown/close of connection */ 200 | #endif 201 | }else{ 202 | /* ignore: USBASP_FUNC_CONNECT */ 203 | } 204 | return len; 205 | } 206 | 207 | uchar usbFunctionWrite(uchar *data, uchar len) 208 | { 209 | uchar isLast; 210 | 211 | DBG1(0x31, (void *)¤tAddress.l, 4); 212 | if(len > bytesRemaining) 213 | len = bytesRemaining; 214 | bytesRemaining -= len; 215 | isLast = bytesRemaining == 0; 216 | if(currentRequest >= USBASP_FUNC_READEEPROM){ 217 | uchar i; 218 | for(i = 0; i < len; i++){ 219 | eeprom_write_byte((void *)(currentAddress.w[0]++), *data++); 220 | } 221 | }else{ 222 | uchar i; 223 | for(i = 0; i < len;){ 224 | #if !HAVE_CHIP_ERASE 225 | if((currentAddress.w[0] & (SPM_PAGESIZE - 1)) == 0){ /* if page start: erase */ 226 | DBG1(0x33, 0, 0); 227 | # ifndef NO_FLASH_WRITE 228 | cli(); 229 | boot_page_erase(CURRENT_ADDRESS); /* erase page */ 230 | sei(); 231 | boot_spm_busy_wait(); /* wait until page is erased */ 232 | # endif 233 | } 234 | #endif 235 | i += 2; 236 | DBG1(0x32, 0, 0); 237 | cli(); 238 | boot_page_fill(CURRENT_ADDRESS, *(short *)data); 239 | sei(); 240 | CURRENT_ADDRESS += 2; 241 | data += 2; 242 | /* write page when we cross page boundary or we have the last partial page */ 243 | if((currentAddress.w[0] & (SPM_PAGESIZE - 1)) == 0 || (isLast && i >= len && isLastPage)){ 244 | DBG1(0x34, 0, 0); 245 | #ifndef NO_FLASH_WRITE 246 | cli(); 247 | boot_page_write(CURRENT_ADDRESS - 2); 248 | sei(); 249 | boot_spm_busy_wait(); 250 | cli(); 251 | boot_rww_enable(); 252 | sei(); 253 | #endif 254 | } 255 | } 256 | DBG1(0x35, (void *)¤tAddress.l, 4); 257 | } 258 | return isLast; 259 | } 260 | 261 | uchar usbFunctionRead(uchar *data, uchar len) 262 | { 263 | uchar i; 264 | 265 | if(len > bytesRemaining) 266 | len = bytesRemaining; 267 | bytesRemaining -= len; 268 | for(i = 0; i < len; i++){ 269 | if(currentRequest >= USBASP_FUNC_READEEPROM){ 270 | *data = eeprom_read_byte((void *)currentAddress.w[0]); 271 | }else{ 272 | *data = pgm_read_byte((void *)CURRENT_ADDRESS); 273 | } 274 | data++; 275 | CURRENT_ADDRESS++; 276 | } 277 | return len; 278 | } 279 | 280 | /* ------------------------------------------------------------------------ */ 281 | 282 | static void initForUsbConnectivity(void) 283 | { 284 | uchar i = 0; 285 | 286 | usbInit(); 287 | /* enforce USB re-enumerate: */ 288 | usbDeviceDisconnect(); /* do this while interrupts are disabled */ 289 | while(--i){ /* fake USB disconnect for > 250 ms */ 290 | wdt_reset(); 291 | _delay_ms(1); 292 | } 293 | usbDeviceConnect(); 294 | sei(); 295 | } 296 | 297 | int __attribute__((noreturn)) main(void) 298 | { 299 | /* initialize */ 300 | wdt_disable(); /* main app may have enabled watchdog */ 301 | bootLoaderInit(); 302 | odDebugInit(); 303 | DBG1(0x00, 0, 0); 304 | #ifndef NO_FLASH_WRITE 305 | GICR = (1 << IVCE); /* enable change of interrupt vectors */ 306 | GICR = (1 << IVSEL); /* move interrupts to boot flash section */ 307 | #endif 308 | if(bootLoaderCondition()){ 309 | uchar i = 0, j = 0; 310 | initForUsbConnectivity(); 311 | do{ 312 | usbPoll(); 313 | #if BOOTLOADER_CAN_EXIT 314 | if(requestBootLoaderExit){ 315 | if(--i == 0){ 316 | if(--j == 0) 317 | break; 318 | } 319 | } 320 | #endif 321 | }while(bootLoaderCondition()); /* main event loop */ 322 | } 323 | leaveBootloader(); 324 | } 325 | 326 | /* ------------------------------------------------------------------------ */ 327 | -------------------------------------------------------------------------------- /firmware/device/usbdrv/usbconfig3.h: -------------------------------------------------------------------------------- 1 | /* Name: usbconfig.h 2 | * Project: AVR USB driver 3 | * Author: Christian Starkjohann 4 | * Creation Date: 2007-06-23 5 | * Tabsize: 4 6 | * Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH 7 | * License: GNU GPL v2 (see License.txt) or proprietary (CommercialLicense.txt) 8 | * This Revision: $Id: usbconfig.h 537 2008-02-28 21:13:01Z cs $ 9 | */ 10 | 11 | #ifndef __usbconfig_h_included__ 12 | #define __usbconfig_h_included__ 13 | 14 | /* ---------------------------- Hardware Config ---------------------------- */ 15 | 16 | #define USB_CFG_IOPORTNAME B 17 | /* This is the port where the USB bus is connected. When you configure it to 18 | * "B", the registers PORTB, PINB and DDRB will be used. 19 | */ 20 | #define USB_CFG_DMINUS_BIT 1 21 | /* This is the bit number in USB_CFG_IOPORT where the USB D- line is connected. 22 | * This may be any bit in the port. 23 | */ 24 | #define USB_CFG_DPLUS_BIT 2 25 | /* This is the bit number in USB_CFG_IOPORT where the USB D+ line is connected. 26 | * This may be any bit in the port. Please note that D+ must also be connected 27 | * to interrupt pin INT0! 28 | */ 29 | #define USB_CFG_CLOCK_KHZ (F_CPU/1000) 30 | /* Clock rate of the AVR in MHz. Legal values are 12000, 16000 or 16500. 31 | * The 16.5 MHz version of the code requires no crystal, it tolerates +/- 1% 32 | * deviation from the nominal frequency. All other rates require a precision 33 | * of 2000 ppm and thus a crystal! 34 | * Default if not specified: 12 MHz 35 | */ 36 | 37 | /* ----------------------- Optional Hardware Config ------------------------ */ 38 | 39 | /* #define USB_CFG_PULLUP_IOPORTNAME D */ 40 | /* If you connect the 1.5k pullup resistor from D- to a port pin instead of 41 | * V+, you can connect and disconnect the device from firmware by calling 42 | * the macros usbDeviceConnect() and usbDeviceDisconnect() (see usbdrv.h). 43 | * This constant defines the port on which the pullup resistor is connected. 44 | */ 45 | /* #define USB_CFG_PULLUP_BIT 4 */ 46 | /* This constant defines the bit number in USB_CFG_PULLUP_IOPORT (defined 47 | * above) where the 1.5k pullup resistor is connected. See description 48 | * above for details. 49 | */ 50 | 51 | /* --------------------------- Functional Range ---------------------------- */ 52 | 53 | #define USB_CFG_HAVE_INTRIN_ENDPOINT 1 54 | /* Define this to 1 if you want to compile a version with two endpoints: The 55 | * default control endpoint 0 and an interrupt-in endpoint 1. 56 | */ 57 | #define USB_CFG_HAVE_INTRIN_ENDPOINT3 0 58 | /* Define this to 1 if you want to compile a version with three endpoints: The 59 | * default control endpoint 0, an interrupt-in endpoint 1 and an interrupt-in 60 | * endpoint 3. You must also enable endpoint 1 above. 61 | */ 62 | #define USB_CFG_IMPLEMENT_HALT 0 63 | /* Define this to 1 if you also want to implement the ENDPOINT_HALT feature 64 | * for endpoint 1 (interrupt endpoint). Although you may not need this feature, 65 | * it is required by the standard. We have made it a config option because it 66 | * bloats the code considerably. 67 | */ 68 | #define USB_CFG_INTR_POLL_INTERVAL 10 69 | /* If you compile a version with endpoint 1 (interrupt-in), this is the poll 70 | * interval. The value is in milliseconds and must not be less than 10 ms for 71 | * low speed devices. 72 | */ 73 | #define USB_CFG_IS_SELF_POWERED 0 74 | /* Define this to 1 if the device has its own power supply. Set it to 0 if the 75 | * device is powered from the USB bus. 76 | */ 77 | #define USB_CFG_MAX_BUS_POWER 50 78 | /* Set this variable to the maximum USB bus power consumption of your device. 79 | * The value is in milliamperes. [It will be divided by two since USB 80 | * communicates power requirements in units of 2 mA.] 81 | */ 82 | #define USB_CFG_IMPLEMENT_FN_WRITE 0 83 | /* Set this to 1 if you want usbFunctionWrite() to be called for control-out 84 | * transfers. Set it to 0 if you don't need it and want to save a couple of 85 | * bytes. 86 | */ 87 | #define USB_CFG_IMPLEMENT_FN_READ 0 88 | /* Set this to 1 if you need to send control replies which are generated 89 | * "on the fly" when usbFunctionRead() is called. If you only want to send 90 | * data from a static buffer, set it to 0 and return the data from 91 | * usbFunctionSetup(). This saves a couple of bytes. 92 | */ 93 | #define USB_CFG_IMPLEMENT_FN_WRITEOUT 0 94 | /* Define this to 1 if you want to use interrupt-out (or bulk out) endpoint 1. 95 | * You must implement the function usbFunctionWriteOut() which receives all 96 | * interrupt/bulk data sent to endpoint 1. 97 | */ 98 | #define USB_CFG_HAVE_FLOWCONTROL 0 99 | /* Define this to 1 if you want flowcontrol over USB data. See the definition 100 | * of the macros usbDisableAllRequests() and usbEnableAllRequests() in 101 | * usbdrv.h. 102 | */ 103 | #ifndef __ASSEMBLER__ 104 | extern void hadUsbReset(void); 105 | #endif 106 | #define USB_RESET_HOOK(isReset) if(!isReset){hadUsbReset();} 107 | /* This macro is a hook if you need to know when an USB RESET occurs. It has 108 | * one parameter which distinguishes between the start of RESET state and its 109 | * end. 110 | */ 111 | #define USB_CFG_HAVE_MEASURE_FRAME_LENGTH 1 112 | /* define this macro to 1 if you want the function usbMeasureFrameLength() 113 | * compiled in. This function can be used to calibrate the AVR's RC oscillator. 114 | */ 115 | 116 | /* -------------------------- Device Description --------------------------- */ 117 | 118 | #define USB_CFG_VENDOR_ID 0x42, 0x42 119 | /* USB vendor ID for the device, low byte first. If you have registered your 120 | * own Vendor ID, define it here. Otherwise you use obdev's free shared 121 | * VID/PID pair. Be sure to read USBID-License.txt for rules! 122 | * This template uses obdev's shared VID/PID pair for HIDs: 0x16c0/0x5df. 123 | * Use this VID/PID pair ONLY if you understand the implications! 124 | */ 125 | #define USB_CFG_DEVICE_ID 0x31, 0xe1 126 | /* This is the ID of the product, low byte first. It is interpreted in the 127 | * scope of the vendor ID. If you have registered your own VID with usb.org 128 | * or if you have licensed a PID from somebody else, define it here. Otherwise 129 | * you use obdev's free shared VID/PID pair. Be sure to read the rules in 130 | * USBID-License.txt! 131 | * This template uses obdev's shared VID/PID pair for HIDs: 0x16c0/0x5df. 132 | * Use this VID/PID pair ONLY if you understand the implications! 133 | */ 134 | #define USB_CFG_DEVICE_VERSION 0x00, 0x01 135 | /* Version number of the device: Minor number first, then major number. 136 | */ 137 | #define USB_CFG_VENDOR_NAME 'c', 'o', 'd', 'e', 'a', 'n', 'd', 'l', \ 138 | 'i', 'f', 'e', '.', 'c', 'o', 'm' 139 | #define USB_CFG_VENDOR_NAME_LEN 15 140 | 141 | /* These two values define the vendor name returned by the USB device. The name 142 | * must be given as a list of characters under single quotes. The characters 143 | * are interpreted as Unicode (UTF-16) entities. 144 | * If you don't want a vendor name string, undefine these macros. 145 | * ALWAYS define a vendor name containing your Internet domain name if you use 146 | * obdev's free shared VID/PID pair. See the file USBID-License.txt for 147 | * details. 148 | */ 149 | #define USB_CFG_DEVICE_NAME 'E', 'a', 's', 'y', 'L', 'o', 'g', 'g', 'e', 'r' 150 | #define USB_CFG_DEVICE_NAME_LEN 10 151 | /* Same as above for the device name. If you don't want a device name, undefine 152 | * the macros. See the file USBID-License.txt before you assign a name if you 153 | * use a shared VID/PID. 154 | */ 155 | /*#define USB_CFG_SERIAL_NUMBER 'N', 'o', 'n', 'e' */ 156 | /*#define USB_CFG_SERIAL_NUMBER_LEN 0 */ 157 | /* Same as above for the serial number. If you don't want a serial number, 158 | * undefine the macros. 159 | * It may be useful to provide the serial number through other means than at 160 | * compile time. See the section about descriptor properties below for how 161 | * to fine tune control over USB descriptors such as the string descriptor 162 | * for the serial number. 163 | */ 164 | #define USB_CFG_DEVICE_CLASS 0 165 | #define USB_CFG_DEVICE_SUBCLASS 0 166 | /* See USB specification if you want to conform to an existing device class. 167 | */ 168 | #define USB_CFG_INTERFACE_CLASS 3 /* HID */ 169 | #define USB_CFG_INTERFACE_SUBCLASS 0 /* no boot interface */ 170 | #define USB_CFG_INTERFACE_PROTOCOL 0 /* no protocol */ 171 | /* See USB specification if you want to conform to an existing device class or 172 | * protocol. 173 | */ 174 | #define USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH 35 /* total length of report descriptor */ 175 | /* Define this to the length of the HID report descriptor, if you implement 176 | * an HID device. Otherwise don't define it or define it to 0. 177 | * Since this template defines a HID device, it must also specify a HID 178 | * report descriptor length. You must add a PROGMEM character array named 179 | * "usbHidReportDescriptor" to your code which contains the report descriptor. 180 | * Don't forget to keep the array and this define in sync! 181 | */ 182 | 183 | /* #define USB_PUBLIC static */ 184 | /* Use the define above if you #include usbdrv.c instead of linking against it. 185 | * This technique saves a couple of bytes in flash memory. 186 | */ 187 | 188 | /* ------------------- Fine Control over USB Descriptors ------------------- */ 189 | /* If you don't want to use the driver's default USB descriptors, you can 190 | * provide our own. These can be provided as (1) fixed length static data in 191 | * flash memory, (2) fixed length static data in RAM or (3) dynamically at 192 | * runtime in the function usbFunctionDescriptor(). See usbdrv.h for more 193 | * information about this function. 194 | * Descriptor handling is configured through the descriptor's properties. If 195 | * no properties are defined or if they are 0, the default descriptor is used. 196 | * Possible properties are: 197 | * + USB_PROP_IS_DYNAMIC: The data for the descriptor should be fetched 198 | * at runtime via usbFunctionDescriptor(). 199 | * + USB_PROP_IS_RAM: The data returned by usbFunctionDescriptor() or found 200 | * in static memory is in RAM, not in flash memory. 201 | * + USB_PROP_LENGTH(len): If the data is in static memory (RAM or flash), 202 | * the driver must know the descriptor's length. The descriptor itself is 203 | * found at the address of a well known identifier (see below). 204 | * List of static descriptor names (must be declared PROGMEM if in flash): 205 | * char usbDescriptorDevice[]; 206 | * char usbDescriptorConfiguration[]; 207 | * char usbDescriptorHidReport[]; 208 | * char usbDescriptorString0[]; 209 | * int usbDescriptorStringVendor[]; 210 | * int usbDescriptorStringDevice[]; 211 | * int usbDescriptorStringSerialNumber[]; 212 | * Other descriptors can't be provided statically, they must be provided 213 | * dynamically at runtime. 214 | * 215 | * Descriptor properties are or-ed or added together, e.g.: 216 | * #define USB_CFG_DESCR_PROPS_DEVICE (USB_PROP_IS_RAM | USB_PROP_LENGTH(18)) 217 | * 218 | * The following descriptors are defined: 219 | * USB_CFG_DESCR_PROPS_DEVICE 220 | * USB_CFG_DESCR_PROPS_CONFIGURATION 221 | * USB_CFG_DESCR_PROPS_STRINGS 222 | * USB_CFG_DESCR_PROPS_STRING_0 223 | * USB_CFG_DESCR_PROPS_STRING_VENDOR 224 | * USB_CFG_DESCR_PROPS_STRING_PRODUCT 225 | * USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER 226 | * USB_CFG_DESCR_PROPS_HID 227 | * USB_CFG_DESCR_PROPS_HID_REPORT 228 | * USB_CFG_DESCR_PROPS_UNKNOWN (for all descriptors not handled by the driver) 229 | * 230 | */ 231 | 232 | #define USB_CFG_DESCR_PROPS_DEVICE 0 233 | #define USB_CFG_DESCR_PROPS_CONFIGURATION 0 234 | #define USB_CFG_DESCR_PROPS_STRINGS 0 235 | #define USB_CFG_DESCR_PROPS_STRING_0 0 236 | #define USB_CFG_DESCR_PROPS_STRING_VENDOR 0 237 | #define USB_CFG_DESCR_PROPS_STRING_PRODUCT 0 238 | #define USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER 0 239 | #define USB_CFG_DESCR_PROPS_HID 0 240 | #define USB_CFG_DESCR_PROPS_HID_REPORT 0 241 | #define USB_CFG_DESCR_PROPS_UNKNOWN 0 242 | 243 | /* ----------------------- Optional MCU Description ------------------------ */ 244 | 245 | /* The following configurations have working defaults in usbdrv.h. You 246 | * usually don't need to set them explicitly. Only if you want to run 247 | * the driver on a device which is not yet supported or with a compiler 248 | * which is not fully supported (such as IAR C) or if you use a differnt 249 | * interrupt than INT0, you may have to define some of these. 250 | */ 251 | /* #define USB_INTR_CFG MCUCR */ 252 | /* #define USB_INTR_CFG_SET ((1 << ISC00) | (1 << ISC01)) */ 253 | /* #define USB_INTR_CFG_CLR 0 */ 254 | /* #define USB_INTR_ENABLE GIMSK */ 255 | /* #define USB_INTR_ENABLE_BIT INT0 */ 256 | /* #define USB_INTR_PENDING GIFR */ 257 | /* #define USB_INTR_PENDING_BIT INTF0 */ 258 | 259 | #endif /* __usbconfig_h_included__ */ 260 | -------------------------------------------------------------------------------- /firmware/bootloader/firmware/usbdrv/usbdrvasm.S: -------------------------------------------------------------------------------- 1 | /* Name: usbdrvasm.S 2 | * Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers 3 | * Author: Christian Starkjohann 4 | * Creation Date: 2007-06-13 5 | * Tabsize: 4 6 | * Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH 7 | * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) 8 | */ 9 | 10 | /* 11 | General Description: 12 | This module is the assembler part of the USB driver. This file contains 13 | general code (preprocessor acrobatics and CRC computation) and then includes 14 | the file appropriate for the given clock rate. 15 | */ 16 | 17 | #define __SFR_OFFSET 0 /* used by avr-libc's register definitions */ 18 | #include "usbportability.h" 19 | #include "usbdrv.h" /* for common defs */ 20 | 21 | /* register names */ 22 | #define x1 r16 23 | #define x2 r17 24 | #define shift r18 25 | #define cnt r19 26 | #define x3 r20 27 | #define x4 r21 28 | #define x5 r22 29 | #define bitcnt x5 30 | #define phase x4 31 | #define leap x4 32 | 33 | /* Some assembler dependent definitions and declarations: */ 34 | 35 | #ifdef __IAR_SYSTEMS_ASM__ 36 | extern usbRxBuf, usbDeviceAddr, usbNewDeviceAddr, usbInputBufOffset 37 | extern usbCurrentTok, usbRxLen, usbRxToken, usbTxLen 38 | extern usbTxBuf, usbTxStatus1, usbTxStatus3 39 | # if USB_COUNT_SOF 40 | extern usbSofCount 41 | # endif 42 | public usbCrc16 43 | public usbCrc16Append 44 | 45 | COMMON INTVEC 46 | # ifndef USB_INTR_VECTOR 47 | ORG INT0_vect 48 | # else /* USB_INTR_VECTOR */ 49 | ORG USB_INTR_VECTOR 50 | # undef USB_INTR_VECTOR 51 | # endif /* USB_INTR_VECTOR */ 52 | # define USB_INTR_VECTOR usbInterruptHandler 53 | rjmp USB_INTR_VECTOR 54 | RSEG CODE 55 | 56 | #else /* __IAR_SYSTEMS_ASM__ */ 57 | 58 | # ifndef USB_INTR_VECTOR /* default to hardware interrupt INT0 */ 59 | # ifdef INT0_vect 60 | # define USB_INTR_VECTOR INT0_vect // this is the "new" define for the vector 61 | # else 62 | # define USB_INTR_VECTOR SIG_INTERRUPT0 // this is the "old" vector 63 | # endif 64 | # endif 65 | .text 66 | .global USB_INTR_VECTOR 67 | .type USB_INTR_VECTOR, @function 68 | .global usbCrc16 69 | .global usbCrc16Append 70 | #endif /* __IAR_SYSTEMS_ASM__ */ 71 | 72 | 73 | #if USB_INTR_PENDING < 0x40 /* This is an I/O address, use in and out */ 74 | # define USB_LOAD_PENDING(reg) in reg, USB_INTR_PENDING 75 | # define USB_STORE_PENDING(reg) out USB_INTR_PENDING, reg 76 | #else /* It's a memory address, use lds and sts */ 77 | # define USB_LOAD_PENDING(reg) lds reg, USB_INTR_PENDING 78 | # define USB_STORE_PENDING(reg) sts USB_INTR_PENDING, reg 79 | #endif 80 | 81 | #define usbTxLen1 usbTxStatus1 82 | #define usbTxBuf1 (usbTxStatus1 + 1) 83 | #define usbTxLen3 usbTxStatus3 84 | #define usbTxBuf3 (usbTxStatus3 + 1) 85 | 86 | 87 | ;---------------------------------------------------------------------------- 88 | ; Utility functions 89 | ;---------------------------------------------------------------------------- 90 | 91 | #ifdef __IAR_SYSTEMS_ASM__ 92 | /* Register assignments for usbCrc16 on IAR cc */ 93 | /* Calling conventions on IAR: 94 | * First parameter passed in r16/r17, second in r18/r19 and so on. 95 | * Callee must preserve r4-r15, r24-r29 (r28/r29 is frame pointer) 96 | * Result is passed in r16/r17 97 | * In case of the "tiny" memory model, pointers are only 8 bit with no 98 | * padding. We therefore pass argument 1 as "16 bit unsigned". 99 | */ 100 | RTMODEL "__rt_version", "3" 101 | /* The line above will generate an error if cc calling conventions change. 102 | * The value "3" above is valid for IAR 4.10B/W32 103 | */ 104 | # define argLen r18 /* argument 2 */ 105 | # define argPtrL r16 /* argument 1 */ 106 | # define argPtrH r17 /* argument 1 */ 107 | 108 | # define resCrcL r16 /* result */ 109 | # define resCrcH r17 /* result */ 110 | 111 | # define ptrL ZL 112 | # define ptrH ZH 113 | # define ptr Z 114 | # define byte r22 115 | # define bitCnt r19 116 | # define polyL r20 117 | # define polyH r21 118 | # define scratch r23 119 | 120 | #else /* __IAR_SYSTEMS_ASM__ */ 121 | /* Register assignments for usbCrc16 on gcc */ 122 | /* Calling conventions on gcc: 123 | * First parameter passed in r24/r25, second in r22/23 and so on. 124 | * Callee must preserve r1-r17, r28/r29 125 | * Result is passed in r24/r25 126 | */ 127 | # define argLen r22 /* argument 2 */ 128 | # define argPtrL r24 /* argument 1 */ 129 | # define argPtrH r25 /* argument 1 */ 130 | 131 | # define resCrcL r24 /* result */ 132 | # define resCrcH r25 /* result */ 133 | 134 | # define ptrL XL 135 | # define ptrH XH 136 | # define ptr x 137 | # define byte r18 138 | # define bitCnt r19 139 | # define polyL r20 140 | # define polyH r21 141 | # define scratch r23 142 | 143 | #endif 144 | 145 | #if USB_USE_FAST_CRC 146 | 147 | ; This implementation is faster, but has bigger code size 148 | ; Thanks to Slawomir Fras (BoskiDialer) for this code! 149 | ; It implements the following C pseudo-code: 150 | ; unsigned table(unsigned char x) 151 | ; { 152 | ; unsigned value; 153 | ; 154 | ; value = (unsigned)x << 6; 155 | ; value ^= (unsigned)x << 7; 156 | ; if(parity(x)) 157 | ; value ^= 0xc001; 158 | ; return value; 159 | ; } 160 | ; unsigned usbCrc16(unsigned char *argPtr, unsigned char argLen) 161 | ; { 162 | ; unsigned crc = 0xffff; 163 | ; 164 | ; while(argLen--) 165 | ; crc = table(lo8(crc) ^ *argPtr++) ^ hi8(crc); 166 | ; return ~crc; 167 | ; } 168 | 169 | ; extern unsigned usbCrc16(unsigned char *argPtr, unsigned char argLen); 170 | ; argPtr r24+25 / r16+r17 171 | ; argLen r22 / r18 172 | ; temp variables: 173 | ; byte r18 / r22 174 | ; scratch r23 175 | ; resCrc r24+r25 / r16+r17 176 | ; ptr X / Z 177 | usbCrc16: 178 | mov ptrL, argPtrL 179 | mov ptrH, argPtrH 180 | ldi resCrcL, 0xFF 181 | ldi resCrcH, 0xFF 182 | rjmp usbCrc16LoopTest 183 | usbCrc16ByteLoop: 184 | ld byte, ptr+ 185 | eor resCrcL, byte ; resCrcL is now 'x' in table() 186 | mov byte, resCrcL ; compute parity of 'x' 187 | swap byte 188 | eor byte, resCrcL 189 | mov scratch, byte 190 | lsr byte 191 | lsr byte 192 | eor byte, scratch 193 | inc byte 194 | lsr byte 195 | andi byte, 1 ; byte is now parity(x) 196 | mov scratch, resCrcL 197 | mov resCrcL, resCrcH 198 | eor resCrcL, byte ; low byte of if(parity(x)) value ^= 0xc001; 199 | neg byte 200 | andi byte, 0xc0 201 | mov resCrcH, byte ; high byte of if(parity(x)) value ^= 0xc001; 202 | clr byte 203 | lsr scratch 204 | ror byte 205 | eor resCrcH, scratch 206 | eor resCrcL, byte 207 | lsr scratch 208 | ror byte 209 | eor resCrcH, scratch 210 | eor resCrcL, byte 211 | usbCrc16LoopTest: 212 | subi argLen, 1 213 | brsh usbCrc16ByteLoop 214 | com resCrcL 215 | com resCrcH 216 | ret 217 | 218 | #else /* USB_USE_FAST_CRC */ 219 | 220 | ; This implementation is slower, but has less code size 221 | ; 222 | ; extern unsigned usbCrc16(unsigned char *argPtr, unsigned char argLen); 223 | ; argPtr r24+25 / r16+r17 224 | ; argLen r22 / r18 225 | ; temp variables: 226 | ; byte r18 / r22 227 | ; bitCnt r19 228 | ; poly r20+r21 229 | ; scratch r23 230 | ; resCrc r24+r25 / r16+r17 231 | ; ptr X / Z 232 | usbCrc16: 233 | mov ptrL, argPtrL 234 | mov ptrH, argPtrH 235 | ldi resCrcL, 0 236 | ldi resCrcH, 0 237 | ldi polyL, lo8(0xa001) 238 | ldi polyH, hi8(0xa001) 239 | com argLen ; argLen = -argLen - 1: modified loop to ensure that carry is set 240 | ldi bitCnt, 0 ; loop counter with starnd condition = end condition 241 | rjmp usbCrcLoopEntry 242 | usbCrcByteLoop: 243 | ld byte, ptr+ 244 | eor resCrcL, byte 245 | usbCrcBitLoop: 246 | ror resCrcH ; carry is always set here (see brcs jumps to here) 247 | ror resCrcL 248 | brcs usbCrcNoXor 249 | eor resCrcL, polyL 250 | eor resCrcH, polyH 251 | usbCrcNoXor: 252 | subi bitCnt, 224 ; (8 * 224) % 256 = 0; this loop iterates 8 times 253 | brcs usbCrcBitLoop 254 | usbCrcLoopEntry: 255 | subi argLen, -1 256 | brcs usbCrcByteLoop 257 | usbCrcReady: 258 | ret 259 | ; Thanks to Reimar Doeffinger for optimizing this CRC routine! 260 | 261 | #endif /* USB_USE_FAST_CRC */ 262 | 263 | ; extern unsigned usbCrc16Append(unsigned char *data, unsigned char len); 264 | usbCrc16Append: 265 | rcall usbCrc16 266 | st ptr+, resCrcL 267 | st ptr+, resCrcH 268 | ret 269 | 270 | #undef argLen 271 | #undef argPtrL 272 | #undef argPtrH 273 | #undef resCrcL 274 | #undef resCrcH 275 | #undef ptrL 276 | #undef ptrH 277 | #undef ptr 278 | #undef byte 279 | #undef bitCnt 280 | #undef polyL 281 | #undef polyH 282 | #undef scratch 283 | 284 | 285 | #if USB_CFG_HAVE_MEASURE_FRAME_LENGTH 286 | #ifdef __IAR_SYSTEMS_ASM__ 287 | /* Register assignments for usbMeasureFrameLength on IAR cc */ 288 | /* Calling conventions on IAR: 289 | * First parameter passed in r16/r17, second in r18/r19 and so on. 290 | * Callee must preserve r4-r15, r24-r29 (r28/r29 is frame pointer) 291 | * Result is passed in r16/r17 292 | * In case of the "tiny" memory model, pointers are only 8 bit with no 293 | * padding. We therefore pass argument 1 as "16 bit unsigned". 294 | */ 295 | # define resL r16 296 | # define resH r17 297 | # define cnt16L r30 298 | # define cnt16H r31 299 | # define cntH r18 300 | 301 | #else /* __IAR_SYSTEMS_ASM__ */ 302 | /* Register assignments for usbMeasureFrameLength on gcc */ 303 | /* Calling conventions on gcc: 304 | * First parameter passed in r24/r25, second in r22/23 and so on. 305 | * Callee must preserve r1-r17, r28/r29 306 | * Result is passed in r24/r25 307 | */ 308 | # define resL r24 309 | # define resH r25 310 | # define cnt16L r24 311 | # define cnt16H r25 312 | # define cntH r26 313 | #endif 314 | # define cnt16 cnt16L 315 | 316 | ; extern unsigned usbMeasurePacketLength(void); 317 | ; returns time between two idle strobes in multiples of 7 CPU clocks 318 | .global usbMeasureFrameLength 319 | usbMeasureFrameLength: 320 | ldi cntH, 6 ; wait ~ 10 ms for D- == 0 321 | clr cnt16L 322 | clr cnt16H 323 | usbMFTime16: 324 | dec cntH 325 | breq usbMFTimeout 326 | usbMFWaitStrobe: ; first wait for D- == 0 (idle strobe) 327 | sbiw cnt16, 1 ;[0] [6] 328 | breq usbMFTime16 ;[2] 329 | sbic USBIN, USBMINUS ;[3] 330 | rjmp usbMFWaitStrobe ;[4] 331 | usbMFWaitIdle: ; then wait until idle again 332 | sbis USBIN, USBMINUS ;1 wait for D- == 1 333 | rjmp usbMFWaitIdle ;2 334 | ldi cnt16L, 1 ;1 represents cycles so far 335 | clr cnt16H ;1 336 | usbMFWaitLoop: 337 | in cntH, USBIN ;[0] [7] 338 | adiw cnt16, 1 ;[1] 339 | breq usbMFTimeout ;[3] 340 | andi cntH, USBMASK ;[4] 341 | brne usbMFWaitLoop ;[5] 342 | usbMFTimeout: 343 | #if resL != cnt16L 344 | mov resL, cnt16L 345 | mov resH, cnt16H 346 | #endif 347 | ret 348 | 349 | #undef resL 350 | #undef resH 351 | #undef cnt16 352 | #undef cnt16L 353 | #undef cnt16H 354 | #undef cntH 355 | 356 | #endif /* USB_CFG_HAVE_MEASURE_FRAME_LENGTH */ 357 | 358 | ;---------------------------------------------------------------------------- 359 | ; Now include the clock rate specific code 360 | ;---------------------------------------------------------------------------- 361 | 362 | #ifndef USB_CFG_CLOCK_KHZ 363 | # ifdef F_CPU 364 | # define USB_CFG_CLOCK_KHZ (F_CPU/1000) 365 | # else 366 | # error "USB_CFG_CLOCK_KHZ not defined in usbconfig.h and no F_CPU set!" 367 | # endif 368 | #endif 369 | 370 | #if USB_CFG_CHECK_CRC /* separate dispatcher for CRC type modules */ 371 | # if USB_CFG_CLOCK_KHZ == 18000 372 | # include "usbdrvasm18-crc.inc" 373 | # else 374 | # error "USB_CFG_CLOCK_KHZ is not one of the supported crc-rates!" 375 | # endif 376 | #else /* USB_CFG_CHECK_CRC */ 377 | # if USB_CFG_CLOCK_KHZ == 12000 378 | # include "usbdrvasm12.inc" 379 | # elif USB_CFG_CLOCK_KHZ == 12800 380 | # include "usbdrvasm128.inc" 381 | # elif USB_CFG_CLOCK_KHZ == 15000 382 | # include "usbdrvasm15.inc" 383 | # elif USB_CFG_CLOCK_KHZ == 16000 384 | # include "usbdrvasm16.inc" 385 | # elif USB_CFG_CLOCK_KHZ == 16500 386 | # include "usbdrvasm165.inc" 387 | # elif USB_CFG_CLOCK_KHZ == 20000 388 | # include "usbdrvasm20.inc" 389 | # else 390 | # error "USB_CFG_CLOCK_KHZ is not one of the supported non-crc-rates!" 391 | # endif 392 | #endif /* USB_CFG_CHECK_CRC */ 393 | -------------------------------------------------------------------------------- /firmware/device/usbdrv/usbdrvasm.S: -------------------------------------------------------------------------------- 1 | /* Name: usbdrvasm.S 2 | * Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers 3 | * Author: Christian Starkjohann 4 | * Creation Date: 2007-06-13 5 | * Tabsize: 4 6 | * Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH 7 | * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) 8 | * Revision: $Id$ 9 | */ 10 | 11 | /* 12 | General Description: 13 | This module is the assembler part of the USB driver. This file contains 14 | general code (preprocessor acrobatics and CRC computation) and then includes 15 | the file appropriate for the given clock rate. 16 | */ 17 | 18 | #define __SFR_OFFSET 0 /* used by avr-libc's register definitions */ 19 | #include "usbportability.h" 20 | #include "usbdrv.h" /* for common defs */ 21 | 22 | /* register names */ 23 | #define x1 r16 24 | #define x2 r17 25 | #define shift r18 26 | #define cnt r19 27 | #define x3 r20 28 | #define x4 r21 29 | #define x5 r22 30 | #define bitcnt x5 31 | #define phase x4 32 | #define leap x4 33 | 34 | /* Some assembler dependent definitions and declarations: */ 35 | 36 | #ifdef __IAR_SYSTEMS_ASM__ 37 | extern usbRxBuf, usbDeviceAddr, usbNewDeviceAddr, usbInputBufOffset 38 | extern usbCurrentTok, usbRxLen, usbRxToken, usbTxLen 39 | extern usbTxBuf, usbTxStatus1, usbTxStatus3 40 | # if USB_COUNT_SOF 41 | extern usbSofCount 42 | # endif 43 | public usbCrc16 44 | public usbCrc16Append 45 | 46 | COMMON INTVEC 47 | # ifndef USB_INTR_VECTOR 48 | ORG INT0_vect 49 | # else /* USB_INTR_VECTOR */ 50 | ORG USB_INTR_VECTOR 51 | # undef USB_INTR_VECTOR 52 | # endif /* USB_INTR_VECTOR */ 53 | # define USB_INTR_VECTOR usbInterruptHandler 54 | rjmp USB_INTR_VECTOR 55 | RSEG CODE 56 | 57 | #else /* __IAR_SYSTEMS_ASM__ */ 58 | 59 | # ifndef USB_INTR_VECTOR /* default to hardware interrupt INT0 */ 60 | # ifdef INT0_vect 61 | # define USB_INTR_VECTOR INT0_vect // this is the "new" define for the vector 62 | # else 63 | # define USB_INTR_VECTOR SIG_INTERRUPT0 // this is the "old" vector 64 | # endif 65 | # endif 66 | .text 67 | .global USB_INTR_VECTOR 68 | .type USB_INTR_VECTOR, @function 69 | .global usbCrc16 70 | .global usbCrc16Append 71 | #endif /* __IAR_SYSTEMS_ASM__ */ 72 | 73 | 74 | #if USB_INTR_PENDING < 0x40 /* This is an I/O address, use in and out */ 75 | # define USB_LOAD_PENDING(reg) in reg, USB_INTR_PENDING 76 | # define USB_STORE_PENDING(reg) out USB_INTR_PENDING, reg 77 | #else /* It's a memory address, use lds and sts */ 78 | # define USB_LOAD_PENDING(reg) lds reg, USB_INTR_PENDING 79 | # define USB_STORE_PENDING(reg) sts USB_INTR_PENDING, reg 80 | #endif 81 | 82 | #define usbTxLen1 usbTxStatus1 83 | #define usbTxBuf1 (usbTxStatus1 + 1) 84 | #define usbTxLen3 usbTxStatus3 85 | #define usbTxBuf3 (usbTxStatus3 + 1) 86 | 87 | 88 | ;---------------------------------------------------------------------------- 89 | ; Utility functions 90 | ;---------------------------------------------------------------------------- 91 | 92 | #ifdef __IAR_SYSTEMS_ASM__ 93 | /* Register assignments for usbCrc16 on IAR cc */ 94 | /* Calling conventions on IAR: 95 | * First parameter passed in r16/r17, second in r18/r19 and so on. 96 | * Callee must preserve r4-r15, r24-r29 (r28/r29 is frame pointer) 97 | * Result is passed in r16/r17 98 | * In case of the "tiny" memory model, pointers are only 8 bit with no 99 | * padding. We therefore pass argument 1 as "16 bit unsigned". 100 | */ 101 | RTMODEL "__rt_version", "3" 102 | /* The line above will generate an error if cc calling conventions change. 103 | * The value "3" above is valid for IAR 4.10B/W32 104 | */ 105 | # define argLen r18 /* argument 2 */ 106 | # define argPtrL r16 /* argument 1 */ 107 | # define argPtrH r17 /* argument 1 */ 108 | 109 | # define resCrcL r16 /* result */ 110 | # define resCrcH r17 /* result */ 111 | 112 | # define ptrL ZL 113 | # define ptrH ZH 114 | # define ptr Z 115 | # define byte r22 116 | # define bitCnt r19 117 | # define polyL r20 118 | # define polyH r21 119 | # define scratch r23 120 | 121 | #else /* __IAR_SYSTEMS_ASM__ */ 122 | /* Register assignments for usbCrc16 on gcc */ 123 | /* Calling conventions on gcc: 124 | * First parameter passed in r24/r25, second in r22/23 and so on. 125 | * Callee must preserve r1-r17, r28/r29 126 | * Result is passed in r24/r25 127 | */ 128 | # define argLen r22 /* argument 2 */ 129 | # define argPtrL r24 /* argument 1 */ 130 | # define argPtrH r25 /* argument 1 */ 131 | 132 | # define resCrcL r24 /* result */ 133 | # define resCrcH r25 /* result */ 134 | 135 | # define ptrL XL 136 | # define ptrH XH 137 | # define ptr x 138 | # define byte r18 139 | # define bitCnt r19 140 | # define polyL r20 141 | # define polyH r21 142 | # define scratch r23 143 | 144 | #endif 145 | 146 | #if USB_USE_FAST_CRC 147 | 148 | ; This implementation is faster, but has bigger code size 149 | ; Thanks to Slawomir Fras (BoskiDialer) for this code! 150 | ; It implements the following C pseudo-code: 151 | ; unsigned table(unsigned char x) 152 | ; { 153 | ; unsigned value; 154 | ; 155 | ; value = (unsigned)x << 6; 156 | ; value ^= (unsigned)x << 7; 157 | ; if(parity(x)) 158 | ; value ^= 0xc001; 159 | ; return value; 160 | ; } 161 | ; unsigned usbCrc16(unsigned char *argPtr, unsigned char argLen) 162 | ; { 163 | ; unsigned crc = 0xffff; 164 | ; 165 | ; while(argLen--) 166 | ; crc = table(lo8(crc) ^ *argPtr++) ^ hi8(crc); 167 | ; return ~crc; 168 | ; } 169 | 170 | ; extern unsigned usbCrc16(unsigned char *argPtr, unsigned char argLen); 171 | ; argPtr r24+25 / r16+r17 172 | ; argLen r22 / r18 173 | ; temp variables: 174 | ; byte r18 / r22 175 | ; scratch r23 176 | ; resCrc r24+r25 / r16+r17 177 | ; ptr X / Z 178 | usbCrc16: 179 | mov ptrL, argPtrL 180 | mov ptrH, argPtrH 181 | ldi resCrcL, 0xFF 182 | ldi resCrcH, 0xFF 183 | rjmp usbCrc16LoopTest 184 | usbCrc16ByteLoop: 185 | ld byte, ptr+ 186 | eor resCrcL, byte ; resCrcL is now 'x' in table() 187 | mov byte, resCrcL ; compute parity of 'x' 188 | swap byte 189 | eor byte, resCrcL 190 | mov scratch, byte 191 | lsr byte 192 | lsr byte 193 | eor byte, scratch 194 | inc byte 195 | lsr byte 196 | andi byte, 1 ; byte is now parity(x) 197 | mov scratch, resCrcL 198 | mov resCrcL, resCrcH 199 | eor resCrcL, byte ; low byte of if(parity(x)) value ^= 0xc001; 200 | neg byte 201 | andi byte, 0xc0 202 | mov resCrcH, byte ; high byte of if(parity(x)) value ^= 0xc001; 203 | clr byte 204 | lsr scratch 205 | ror byte 206 | eor resCrcH, scratch 207 | eor resCrcL, byte 208 | lsr scratch 209 | ror byte 210 | eor resCrcH, scratch 211 | eor resCrcL, byte 212 | usbCrc16LoopTest: 213 | subi argLen, 1 214 | brsh usbCrc16ByteLoop 215 | com resCrcL 216 | com resCrcH 217 | ret 218 | 219 | #else /* USB_USE_FAST_CRC */ 220 | 221 | ; This implementation is slower, but has less code size 222 | ; 223 | ; extern unsigned usbCrc16(unsigned char *argPtr, unsigned char argLen); 224 | ; argPtr r24+25 / r16+r17 225 | ; argLen r22 / r18 226 | ; temp variables: 227 | ; byte r18 / r22 228 | ; bitCnt r19 229 | ; poly r20+r21 230 | ; scratch r23 231 | ; resCrc r24+r25 / r16+r17 232 | ; ptr X / Z 233 | usbCrc16: 234 | mov ptrL, argPtrL 235 | mov ptrH, argPtrH 236 | ldi resCrcL, 0 237 | ldi resCrcH, 0 238 | ldi polyL, lo8(0xa001) 239 | ldi polyH, hi8(0xa001) 240 | com argLen ; argLen = -argLen - 1: modified loop to ensure that carry is set 241 | ldi bitCnt, 0 ; loop counter with starnd condition = end condition 242 | rjmp usbCrcLoopEntry 243 | usbCrcByteLoop: 244 | ld byte, ptr+ 245 | eor resCrcL, byte 246 | usbCrcBitLoop: 247 | ror resCrcH ; carry is always set here (see brcs jumps to here) 248 | ror resCrcL 249 | brcs usbCrcNoXor 250 | eor resCrcL, polyL 251 | eor resCrcH, polyH 252 | usbCrcNoXor: 253 | subi bitCnt, 224 ; (8 * 224) % 256 = 0; this loop iterates 8 times 254 | brcs usbCrcBitLoop 255 | usbCrcLoopEntry: 256 | subi argLen, -1 257 | brcs usbCrcByteLoop 258 | usbCrcReady: 259 | ret 260 | ; Thanks to Reimar Doeffinger for optimizing this CRC routine! 261 | 262 | #endif /* USB_USE_FAST_CRC */ 263 | 264 | ; extern unsigned usbCrc16Append(unsigned char *data, unsigned char len); 265 | usbCrc16Append: 266 | rcall usbCrc16 267 | st ptr+, resCrcL 268 | st ptr+, resCrcH 269 | ret 270 | 271 | #undef argLen 272 | #undef argPtrL 273 | #undef argPtrH 274 | #undef resCrcL 275 | #undef resCrcH 276 | #undef ptrL 277 | #undef ptrH 278 | #undef ptr 279 | #undef byte 280 | #undef bitCnt 281 | #undef polyL 282 | #undef polyH 283 | #undef scratch 284 | 285 | 286 | #if USB_CFG_HAVE_MEASURE_FRAME_LENGTH 287 | #ifdef __IAR_SYSTEMS_ASM__ 288 | /* Register assignments for usbMeasureFrameLength on IAR cc */ 289 | /* Calling conventions on IAR: 290 | * First parameter passed in r16/r17, second in r18/r19 and so on. 291 | * Callee must preserve r4-r15, r24-r29 (r28/r29 is frame pointer) 292 | * Result is passed in r16/r17 293 | * In case of the "tiny" memory model, pointers are only 8 bit with no 294 | * padding. We therefore pass argument 1 as "16 bit unsigned". 295 | */ 296 | # define resL r16 297 | # define resH r17 298 | # define cnt16L r30 299 | # define cnt16H r31 300 | # define cntH r18 301 | 302 | #else /* __IAR_SYSTEMS_ASM__ */ 303 | /* Register assignments for usbMeasureFrameLength on gcc */ 304 | /* Calling conventions on gcc: 305 | * First parameter passed in r24/r25, second in r22/23 and so on. 306 | * Callee must preserve r1-r17, r28/r29 307 | * Result is passed in r24/r25 308 | */ 309 | # define resL r24 310 | # define resH r25 311 | # define cnt16L r24 312 | # define cnt16H r25 313 | # define cntH r26 314 | #endif 315 | # define cnt16 cnt16L 316 | 317 | ; extern unsigned usbMeasurePacketLength(void); 318 | ; returns time between two idle strobes in multiples of 7 CPU clocks 319 | .global usbMeasureFrameLength 320 | usbMeasureFrameLength: 321 | ldi cntH, 6 ; wait ~ 10 ms for D- == 0 322 | clr cnt16L 323 | clr cnt16H 324 | usbMFTime16: 325 | dec cntH 326 | breq usbMFTimeout 327 | usbMFWaitStrobe: ; first wait for D- == 0 (idle strobe) 328 | sbiw cnt16, 1 ;[0] [6] 329 | breq usbMFTime16 ;[2] 330 | sbic USBIN, USBMINUS ;[3] 331 | rjmp usbMFWaitStrobe ;[4] 332 | usbMFWaitIdle: ; then wait until idle again 333 | sbis USBIN, USBMINUS ;1 wait for D- == 1 334 | rjmp usbMFWaitIdle ;2 335 | ldi cnt16L, 1 ;1 represents cycles so far 336 | clr cnt16H ;1 337 | usbMFWaitLoop: 338 | in cntH, USBIN ;[0] [7] 339 | adiw cnt16, 1 ;[1] 340 | breq usbMFTimeout ;[3] 341 | andi cntH, USBMASK ;[4] 342 | brne usbMFWaitLoop ;[5] 343 | usbMFTimeout: 344 | #if resL != cnt16L 345 | mov resL, cnt16L 346 | mov resH, cnt16H 347 | #endif 348 | ret 349 | 350 | #undef resL 351 | #undef resH 352 | #undef cnt16 353 | #undef cnt16L 354 | #undef cnt16H 355 | #undef cntH 356 | 357 | #endif /* USB_CFG_HAVE_MEASURE_FRAME_LENGTH */ 358 | 359 | ;---------------------------------------------------------------------------- 360 | ; Now include the clock rate specific code 361 | ;---------------------------------------------------------------------------- 362 | 363 | #ifndef USB_CFG_CLOCK_KHZ 364 | # ifdef F_CPU 365 | # define USB_CFG_CLOCK_KHZ (F_CPU/1000) 366 | # else 367 | # error "USB_CFG_CLOCK_KHZ not defined in usbconfig.h and no F_CPU set!" 368 | # endif 369 | #endif 370 | 371 | #if USB_CFG_CHECK_CRC /* separate dispatcher for CRC type modules */ 372 | # if USB_CFG_CLOCK_KHZ == 18000 373 | # include "usbdrvasm18-crc.inc" 374 | # else 375 | # error "USB_CFG_CLOCK_KHZ is not one of the supported crc-rates!" 376 | # endif 377 | #else /* USB_CFG_CHECK_CRC */ 378 | # if USB_CFG_CLOCK_KHZ == 12000 379 | # include "usbdrvasm12.inc" 380 | # elif USB_CFG_CLOCK_KHZ == 12800 381 | # include "usbdrvasm128.inc" 382 | # elif USB_CFG_CLOCK_KHZ == 15000 383 | # include "usbdrvasm15.inc" 384 | # elif USB_CFG_CLOCK_KHZ == 16000 385 | # include "usbdrvasm16.inc" 386 | # elif USB_CFG_CLOCK_KHZ == 16500 387 | # include "usbdrvasm165.inc" 388 | # elif USB_CFG_CLOCK_KHZ == 20000 389 | # include "usbdrvasm20.inc" 390 | # else 391 | # error "USB_CFG_CLOCK_KHZ is not one of the supported non-crc-rates!" 392 | # endif 393 | #endif /* USB_CFG_CHECK_CRC */ 394 | -------------------------------------------------------------------------------- /firmware/bootloader/firmware/usbdrv/usbdrvasm16.inc: -------------------------------------------------------------------------------- 1 | /* Name: usbdrvasm16.inc 2 | * Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers 3 | * Author: Christian Starkjohann 4 | * Creation Date: 2007-06-15 5 | * Tabsize: 4 6 | * Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH 7 | * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) 8 | */ 9 | 10 | /* Do not link this file! Link usbdrvasm.S instead, which includes the 11 | * appropriate implementation! 12 | */ 13 | 14 | /* 15 | General Description: 16 | This file is the 16 MHz version of the asssembler part of the USB driver. It 17 | requires a 16 MHz crystal (not a ceramic resonator and not a calibrated RC 18 | oscillator). 19 | 20 | See usbdrv.h for a description of the entire driver. 21 | 22 | Since almost all of this code is timing critical, don't change unless you 23 | really know what you are doing! Many parts require not only a maximum number 24 | of CPU cycles, but even an exact number of cycles! 25 | */ 26 | 27 | ;max stack usage: [ret(2), YL, SREG, YH, bitcnt, shift, x1, x2, x3, x4, cnt] = 12 bytes 28 | ;nominal frequency: 16 MHz -> 10.6666666 cycles per bit, 85.333333333 cycles per byte 29 | ; Numbers in brackets are clocks counted from center of last sync bit 30 | ; when instruction starts 31 | 32 | USB_INTR_VECTOR: 33 | ;order of registers pushed: YL, SREG YH, [sofError], bitcnt, shift, x1, x2, x3, x4, cnt 34 | push YL ;[-25] push only what is necessary to sync with edge ASAP 35 | in YL, SREG ;[-23] 36 | push YL ;[-22] 37 | push YH ;[-20] 38 | ;---------------------------------------------------------------------------- 39 | ; Synchronize with sync pattern: 40 | ;---------------------------------------------------------------------------- 41 | ;sync byte (D-) pattern LSb to MSb: 01010100 [1 = idle = J, 0 = K] 42 | ;sync up with J to K edge during sync pattern -- use fastest possible loops 43 | ;The first part waits at most 1 bit long since we must be in sync pattern. 44 | ;YL is guarenteed to be < 0x80 because I flag is clear. When we jump to 45 | ;waitForJ, ensure that this prerequisite is met. 46 | waitForJ: 47 | inc YL 48 | sbis USBIN, USBMINUS 49 | brne waitForJ ; just make sure we have ANY timeout 50 | waitForK: 51 | ;The following code results in a sampling window of < 1/4 bit which meets the spec. 52 | sbis USBIN, USBMINUS ;[-15] 53 | rjmp foundK ;[-14] 54 | sbis USBIN, USBMINUS 55 | rjmp foundK 56 | sbis USBIN, USBMINUS 57 | rjmp foundK 58 | sbis USBIN, USBMINUS 59 | rjmp foundK 60 | sbis USBIN, USBMINUS 61 | rjmp foundK 62 | sbis USBIN, USBMINUS 63 | rjmp foundK 64 | #if USB_COUNT_SOF 65 | lds YL, usbSofCount 66 | inc YL 67 | sts usbSofCount, YL 68 | #endif /* USB_COUNT_SOF */ 69 | #ifdef USB_SOF_HOOK 70 | USB_SOF_HOOK 71 | #endif 72 | rjmp sofError 73 | foundK: ;[-12] 74 | ;{3, 5} after falling D- edge, average delay: 4 cycles [we want 5 for center sampling] 75 | ;we have 1 bit time for setup purposes, then sample again. Numbers in brackets 76 | ;are cycles from center of first sync (double K) bit after the instruction 77 | push bitcnt ;[-12] 78 | ; [---] ;[-11] 79 | lds YL, usbInputBufOffset;[-10] 80 | ; [---] ;[-9] 81 | clr YH ;[-8] 82 | subi YL, lo8(-(usbRxBuf));[-7] [rx loop init] 83 | sbci YH, hi8(-(usbRxBuf));[-6] [rx loop init] 84 | push shift ;[-5] 85 | ; [---] ;[-4] 86 | ldi bitcnt, 0x55 ;[-3] [rx loop init] 87 | sbis USBIN, USBMINUS ;[-2] we want two bits K (sample 2 cycles too early) 88 | rjmp haveTwoBitsK ;[-1] 89 | pop shift ;[0] undo the push from before 90 | pop bitcnt ;[2] undo the push from before 91 | rjmp waitForK ;[4] this was not the end of sync, retry 92 | ; The entire loop from waitForK until rjmp waitForK above must not exceed two 93 | ; bit times (= 21 cycles). 94 | 95 | ;---------------------------------------------------------------------------- 96 | ; push more registers and initialize values while we sample the first bits: 97 | ;---------------------------------------------------------------------------- 98 | haveTwoBitsK: 99 | push x1 ;[1] 100 | push x2 ;[3] 101 | push x3 ;[5] 102 | ldi shift, 0 ;[7] 103 | ldi x3, 1<<4 ;[8] [rx loop init] first sample is inverse bit, compensate that 104 | push x4 ;[9] == leap 105 | 106 | in x1, USBIN ;[11] <-- sample bit 0 107 | andi x1, USBMASK ;[12] 108 | bst x1, USBMINUS ;[13] 109 | bld shift, 7 ;[14] 110 | push cnt ;[15] 111 | ldi leap, 0 ;[17] [rx loop init] 112 | ldi cnt, USB_BUFSIZE;[18] [rx loop init] 113 | rjmp rxbit1 ;[19] arrives at [21] 114 | 115 | ;---------------------------------------------------------------------------- 116 | ; Receiver loop (numbers in brackets are cycles within byte after instr) 117 | ;---------------------------------------------------------------------------- 118 | 119 | ; duration of unstuffing code should be 10.66666667 cycles. We adjust "leap" 120 | ; accordingly to approximate this value in the long run. 121 | 122 | unstuff6: 123 | andi x2, USBMASK ;[03] 124 | ori x3, 1<<6 ;[04] will not be shifted any more 125 | andi shift, ~0x80;[05] 126 | mov x1, x2 ;[06] sampled bit 7 is actually re-sampled bit 6 127 | subi leap, -1 ;[07] total duration = 11 bits -> subtract 1/3 128 | rjmp didUnstuff6 ;[08] 129 | 130 | unstuff7: 131 | ori x3, 1<<7 ;[09] will not be shifted any more 132 | in x2, USBIN ;[00] [10] re-sample bit 7 133 | andi x2, USBMASK ;[01] 134 | andi shift, ~0x80;[02] 135 | subi leap, 2 ;[03] total duration = 10 bits -> add 1/3 136 | rjmp didUnstuff7 ;[04] 137 | 138 | unstuffEven: 139 | ori x3, 1<<6 ;[09] will be shifted right 6 times for bit 0 140 | in x1, USBIN ;[00] [10] 141 | andi shift, ~0x80;[01] 142 | andi x1, USBMASK ;[02] 143 | breq se0 ;[03] 144 | subi leap, -1 ;[04] total duration = 11 bits -> subtract 1/3 145 | nop2 ;[05] 146 | rjmp didUnstuffE ;[06] 147 | 148 | unstuffOdd: 149 | ori x3, 1<<5 ;[09] will be shifted right 4 times for bit 1 150 | in x2, USBIN ;[00] [10] 151 | andi shift, ~0x80;[01] 152 | andi x2, USBMASK ;[02] 153 | breq se0 ;[03] 154 | subi leap, -1 ;[04] total duration = 11 bits -> subtract 1/3 155 | nop2 ;[05] 156 | rjmp didUnstuffO ;[06] 157 | 158 | rxByteLoop: 159 | andi x1, USBMASK ;[03] 160 | eor x2, x1 ;[04] 161 | subi leap, 1 ;[05] 162 | brpl skipLeap ;[06] 163 | subi leap, -3 ;1 one leap cycle every 3rd byte -> 85 + 1/3 cycles per byte 164 | nop ;1 165 | skipLeap: 166 | subi x2, 1 ;[08] 167 | ror shift ;[09] 168 | didUnstuff6: 169 | cpi shift, 0xfc ;[10] 170 | in x2, USBIN ;[00] [11] <-- sample bit 7 171 | brcc unstuff6 ;[01] 172 | andi x2, USBMASK ;[02] 173 | eor x1, x2 ;[03] 174 | subi x1, 1 ;[04] 175 | ror shift ;[05] 176 | didUnstuff7: 177 | cpi shift, 0xfc ;[06] 178 | brcc unstuff7 ;[07] 179 | eor x3, shift ;[08] reconstruct: x3 is 1 at bit locations we changed, 0 at others 180 | st y+, x3 ;[09] store data 181 | rxBitLoop: 182 | in x1, USBIN ;[00] [11] <-- sample bit 0/2/4 183 | andi x1, USBMASK ;[01] 184 | eor x2, x1 ;[02] 185 | andi x3, 0x3f ;[03] topmost two bits reserved for 6 and 7 186 | subi x2, 1 ;[04] 187 | ror shift ;[05] 188 | cpi shift, 0xfc ;[06] 189 | brcc unstuffEven ;[07] 190 | didUnstuffE: 191 | lsr x3 ;[08] 192 | lsr x3 ;[09] 193 | rxbit1: 194 | in x2, USBIN ;[00] [10] <-- sample bit 1/3/5 195 | andi x2, USBMASK ;[01] 196 | breq se0 ;[02] 197 | eor x1, x2 ;[03] 198 | subi x1, 1 ;[04] 199 | ror shift ;[05] 200 | cpi shift, 0xfc ;[06] 201 | brcc unstuffOdd ;[07] 202 | didUnstuffO: 203 | subi bitcnt, 0xab;[08] == addi 0x55, 0x55 = 0x100/3 204 | brcs rxBitLoop ;[09] 205 | 206 | subi cnt, 1 ;[10] 207 | in x1, USBIN ;[00] [11] <-- sample bit 6 208 | brcc rxByteLoop ;[01] 209 | rjmp overflow 210 | 211 | macro POP_STANDARD ; 14 cycles 212 | pop cnt 213 | pop x4 214 | pop x3 215 | pop x2 216 | pop x1 217 | pop shift 218 | pop bitcnt 219 | endm 220 | macro POP_RETI ; 7 cycles 221 | pop YH 222 | pop YL 223 | out SREG, YL 224 | pop YL 225 | endm 226 | 227 | #include "asmcommon.inc" 228 | 229 | ; USB spec says: 230 | ; idle = J 231 | ; J = (D+ = 0), (D- = 1) 232 | ; K = (D+ = 1), (D- = 0) 233 | ; Spec allows 7.5 bit times from EOP to SOP for replies 234 | 235 | bitstuffN: 236 | eor x1, x4 ;[5] 237 | ldi x2, 0 ;[6] 238 | nop2 ;[7] 239 | nop ;[9] 240 | out USBOUT, x1 ;[10] <-- out 241 | rjmp didStuffN ;[0] 242 | 243 | bitstuff6: 244 | eor x1, x4 ;[5] 245 | ldi x2, 0 ;[6] Carry is zero due to brcc 246 | rol shift ;[7] compensate for ror shift at branch destination 247 | rjmp didStuff6 ;[8] 248 | 249 | bitstuff7: 250 | ldi x2, 0 ;[2] Carry is zero due to brcc 251 | rjmp didStuff7 ;[3] 252 | 253 | 254 | sendNakAndReti: 255 | ldi x3, USBPID_NAK ;[-18] 256 | rjmp sendX3AndReti ;[-17] 257 | sendAckAndReti: 258 | ldi cnt, USBPID_ACK ;[-17] 259 | sendCntAndReti: 260 | mov x3, cnt ;[-16] 261 | sendX3AndReti: 262 | ldi YL, 20 ;[-15] x3==r20 address is 20 263 | ldi YH, 0 ;[-14] 264 | ldi cnt, 2 ;[-13] 265 | ; rjmp usbSendAndReti fallthrough 266 | 267 | ;usbSend: 268 | ;pointer to data in 'Y' 269 | ;number of bytes in 'cnt' -- including sync byte [range 2 ... 12] 270 | ;uses: x1...x4, btcnt, shift, cnt, Y 271 | ;Numbers in brackets are time since first bit of sync pattern is sent 272 | ;We don't match the transfer rate exactly (don't insert leap cycles every third 273 | ;byte) because the spec demands only 1.5% precision anyway. 274 | usbSendAndReti: ; 12 cycles until SOP 275 | in x2, USBDDR ;[-12] 276 | ori x2, USBMASK ;[-11] 277 | sbi USBOUT, USBMINUS;[-10] prepare idle state; D+ and D- must have been 0 (no pullups) 278 | in x1, USBOUT ;[-8] port mirror for tx loop 279 | out USBDDR, x2 ;[-7] <- acquire bus 280 | ; need not init x2 (bitstuff history) because sync starts with 0 281 | ldi x4, USBMASK ;[-6] exor mask 282 | ldi shift, 0x80 ;[-5] sync byte is first byte sent 283 | txByteLoop: 284 | ldi bitcnt, 0x35 ;[-4] [6] binary 0011 0101 285 | txBitLoop: 286 | sbrs shift, 0 ;[-3] [7] 287 | eor x1, x4 ;[-2] [8] 288 | out USBOUT, x1 ;[-1] [9] <-- out N 289 | ror shift ;[0] [10] 290 | ror x2 ;[1] 291 | didStuffN: 292 | cpi x2, 0xfc ;[2] 293 | brcc bitstuffN ;[3] 294 | lsr bitcnt ;[4] 295 | brcc txBitLoop ;[5] 296 | brne txBitLoop ;[6] 297 | 298 | sbrs shift, 0 ;[7] 299 | eor x1, x4 ;[8] 300 | didStuff6: 301 | out USBOUT, x1 ;[-1] [9] <-- out 6 302 | ror shift ;[0] [10] 303 | ror x2 ;[1] 304 | cpi x2, 0xfc ;[2] 305 | brcc bitstuff6 ;[3] 306 | ror shift ;[4] 307 | didStuff7: 308 | ror x2 ;[5] 309 | sbrs x2, 7 ;[6] 310 | eor x1, x4 ;[7] 311 | nop ;[8] 312 | cpi x2, 0xfc ;[9] 313 | out USBOUT, x1 ;[-1][10] <-- out 7 314 | brcc bitstuff7 ;[0] [11] 315 | ld shift, y+ ;[1] 316 | dec cnt ;[3] 317 | brne txByteLoop ;[4] 318 | ;make SE0: 319 | cbr x1, USBMASK ;[5] prepare SE0 [spec says EOP may be 21 to 25 cycles] 320 | lds x2, usbNewDeviceAddr;[6] 321 | lsl x2 ;[8] we compare with left shifted address 322 | subi YL, 20 + 2 ;[9] Only assign address on data packets, not ACK/NAK in x3 323 | sbci YH, 0 ;[10] 324 | out USBOUT, x1 ;[11] <-- out SE0 -- from now 2 bits = 22 cycles until bus idle 325 | ;2006-03-06: moved transfer of new address to usbDeviceAddr from C-Code to asm: 326 | ;set address only after data packet was sent, not after handshake 327 | breq skipAddrAssign ;[0] 328 | sts usbDeviceAddr, x2; if not skipped: SE0 is one cycle longer 329 | skipAddrAssign: 330 | ;end of usbDeviceAddress transfer 331 | ldi x2, 1<