├── libraries ├── dnLogo23-01.png ├── dnLogo128x64-inverted.xcf ├── UsbKeyboard │ ├── vusb-20121206 │ │ ├── circuits │ │ │ ├── tiny45-rc.png │ │ │ ├── tiny45-rc.sch │ │ │ ├── with-vreg.png │ │ │ ├── with-vreg.sch │ │ │ ├── with-zener.png │ │ │ ├── with-zener.sch │ │ │ ├── with-series-diodes.png │ │ │ ├── with-series-diodes.sch │ │ │ └── Readme.txt │ │ ├── tests │ │ │ ├── Readme.txt │ │ │ ├── null.c │ │ │ ├── sizes-reference │ │ │ │ ├── sizes-20080418-gcc3.4.6.txt │ │ │ │ ├── sizes-20080418-gcc4.2.2.txt │ │ │ │ ├── sizes-20080513-gcc3.4.6.txt │ │ │ │ ├── sizes-20080513-gcc4.3.0.txt │ │ │ │ ├── sizes-20081022-gcc3.4.6.txt │ │ │ │ ├── sizes-20081022-gcc4.3.0.txt │ │ │ │ ├── sizes-20081126-gcc3.4.6.txt │ │ │ │ ├── sizes-20081126-gcc4.3.0.txt │ │ │ │ ├── sizes-20090323-gcc3.4.6.txt │ │ │ │ ├── sizes-20090323-gcc4.3.2.txt │ │ │ │ ├── sizes-20090415-gcc3.4.6.txt │ │ │ │ ├── sizes-20090415-gcc4.3.2.txt │ │ │ │ ├── sizes-20100715-gcc3.4.6.txt │ │ │ │ ├── sizes-20100715-gcc4.3.3.txt │ │ │ │ ├── sizes-20120109-gcc3.4.6.txt │ │ │ │ ├── sizes-20120109-gcc4.3.3.txt │ │ │ │ └── sizes-20121206-gcc4.6.2.txt │ │ │ └── compare-sizes.awk │ │ ├── examples │ │ │ ├── hid-data │ │ │ │ ├── commandline │ │ │ │ │ ├── Makefile.windows │ │ │ │ │ ├── Makefile │ │ │ │ │ ├── hidsdi.h │ │ │ │ │ ├── hiddata.h │ │ │ │ │ └── hidtool.c │ │ │ │ ├── Readme.txt │ │ │ │ └── firmware │ │ │ │ │ └── main.c │ │ │ ├── usbtool │ │ │ │ ├── Makefile.windows │ │ │ │ ├── Makefile │ │ │ │ └── opendevice.h │ │ │ ├── custom-class │ │ │ │ ├── commandline │ │ │ │ │ ├── Makefile.windows │ │ │ │ │ ├── Makefile │ │ │ │ │ ├── opendevice.h │ │ │ │ │ └── set-led.c │ │ │ │ ├── firmware │ │ │ │ │ ├── requests.h │ │ │ │ │ └── main.c │ │ │ │ └── Readme.txt │ │ │ ├── hid-custom-rq │ │ │ │ ├── commandline │ │ │ │ │ ├── Makefile.windows │ │ │ │ │ ├── Makefile │ │ │ │ │ ├── opendevice.h │ │ │ │ │ └── set-led.c │ │ │ │ ├── firmware │ │ │ │ │ ├── requests.h │ │ │ │ │ └── main.c │ │ │ │ └── Readme.txt │ │ │ ├── hid-mouse │ │ │ │ └── Readme.txt │ │ │ └── Readme.txt │ │ ├── usbdrv │ │ │ ├── usbdrvasm.asm │ │ │ ├── oddebug.c │ │ │ ├── oddebug.h │ │ │ └── usbportability.h │ │ ├── libs-device │ │ │ ├── Readme.txt │ │ │ ├── osccal.c │ │ │ ├── osccal.h │ │ │ └── osctune.h │ │ ├── libs-host │ │ │ ├── Readme.txt │ │ │ ├── hidsdi.h │ │ │ ├── hiddata.h │ │ │ └── opendevice.h │ │ ├── Makefile │ │ └── Readme.txt │ ├── usbdrvasm.asm │ ├── oddebug.c │ ├── ArduinoNotes.txt │ ├── examples │ │ └── UsbKeyboardDemo1 │ │ │ └── UsbKeyboardDemo1.pde │ ├── oddebug.h │ └── usbportability.h ├── DarkNetDisplay │ ├── library.properties │ ├── README.txt │ ├── license.txt │ └── DarkNetDisplay.h ├── IRSerial2014 │ ├── keywords.txt │ └── IRSerial-2014.h └── ArduinoMD5 │ ├── examples │ └── MD5_Hash │ │ └── MD5_Hash.ino │ ├── README.md │ └── MD5.h ├── software └── fwupdate │ ├── darknet.sh │ ├── OtherNotes.txt │ ├── setupUART.py │ ├── darknet.service │ ├── 10-avrisp.rules │ ├── buildDB.pl │ ├── make-eeprom.pl │ ├── DummyLCDController.py │ ├── BBSetup.txt │ ├── optiboot_atmega328.hex │ ├── run.pl │ ├── autoupdate.py │ ├── SFLCDController.py │ ├── updater.py │ └── AVRProg.py ├── DCDarkNet └── FirmWare │ ├── IR-protocol.txt │ ├── build │ ├── burn-flash.sh │ ├── burn-eeprom.sh │ ├── burn-bootloader.sh │ ├── buildDB.pl │ ├── make-eeprom.pl │ ├── optiboot_atmega328.hex │ └── run.pl │ ├── ButtonTest │ └── ButtonTest.ino │ ├── proc-codes.pl │ └── UsbKeyboardTest │ └── UsbKeyboardTest.ino └── README.md /libraries/dnLogo23-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedarknet/hhvkit/HEAD/libraries/dnLogo23-01.png -------------------------------------------------------------------------------- /libraries/dnLogo128x64-inverted.xcf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedarknet/hhvkit/HEAD/libraries/dnLogo128x64-inverted.xcf -------------------------------------------------------------------------------- /software/fwupdate/darknet.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | /usr/bin/python /home/debian/darknet/autoupdate.py /home/debian/code/test/firmware.hex 4 | -------------------------------------------------------------------------------- /software/fwupdate/OtherNotes.txt: -------------------------------------------------------------------------------- 1 | Other Notes 2 | 3 | AVR Dragon connection guide for atmega328p: http://www.atmel.com/webdoc/avrdragon/avrdragon.SCKT3200A2.html 4 | -------------------------------------------------------------------------------- /libraries/UsbKeyboard/vusb-20121206/circuits/tiny45-rc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedarknet/hhvkit/HEAD/libraries/UsbKeyboard/vusb-20121206/circuits/tiny45-rc.png -------------------------------------------------------------------------------- /libraries/UsbKeyboard/vusb-20121206/circuits/tiny45-rc.sch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedarknet/hhvkit/HEAD/libraries/UsbKeyboard/vusb-20121206/circuits/tiny45-rc.sch -------------------------------------------------------------------------------- /libraries/UsbKeyboard/vusb-20121206/circuits/with-vreg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedarknet/hhvkit/HEAD/libraries/UsbKeyboard/vusb-20121206/circuits/with-vreg.png -------------------------------------------------------------------------------- /libraries/UsbKeyboard/vusb-20121206/circuits/with-vreg.sch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedarknet/hhvkit/HEAD/libraries/UsbKeyboard/vusb-20121206/circuits/with-vreg.sch -------------------------------------------------------------------------------- /libraries/UsbKeyboard/vusb-20121206/circuits/with-zener.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedarknet/hhvkit/HEAD/libraries/UsbKeyboard/vusb-20121206/circuits/with-zener.png -------------------------------------------------------------------------------- /libraries/UsbKeyboard/vusb-20121206/circuits/with-zener.sch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedarknet/hhvkit/HEAD/libraries/UsbKeyboard/vusb-20121206/circuits/with-zener.sch -------------------------------------------------------------------------------- /DCDarkNet/FirmWare/IR-protocol.txt: -------------------------------------------------------------------------------- 1 | Alice Bob 2 | 0x -> weAreBob() 3 | proc 4 | weAreAlice() <- 0y 5 | <- 0a 6 | proc 7 | 0b -> 8 | msg msg 9 | 10 | -------------------------------------------------------------------------------- /libraries/UsbKeyboard/vusb-20121206/circuits/with-series-diodes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedarknet/hhvkit/HEAD/libraries/UsbKeyboard/vusb-20121206/circuits/with-series-diodes.png -------------------------------------------------------------------------------- /libraries/UsbKeyboard/vusb-20121206/circuits/with-series-diodes.sch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedarknet/hhvkit/HEAD/libraries/UsbKeyboard/vusb-20121206/circuits/with-series-diodes.sch -------------------------------------------------------------------------------- /software/fwupdate/setupUART.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # 3 | # NOTE: Must be run as root (only once per powerup) 4 | # 5 | import Adafruit_BBIO.UART as UART 6 | 7 | UART.setup("UART4") 8 | -------------------------------------------------------------------------------- /software/fwupdate/darknet.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=DCDarkNet Programmer Service 3 | 4 | [Service] 5 | Type=simple 6 | ExecStart=/home/debian/darknet/darknet.sh 7 | 8 | [Install] 9 | WantedBy=multi-user.target 10 | -------------------------------------------------------------------------------- /DCDarkNet/FirmWare/build/burn-flash.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | AVR_DUDE="/home/mark/Arduino/arduino-1.5.7/hardware/tools/avr/bin/avrdude" 3 | AVR_DUDE_CONF="/home/mark/Arduino/arduino-1.5.7/hardware/tools/avr/etc/avrdude.conf" 4 | 5 | # Upload the code through the FTDI cable 6 | $AVR_DUDE -C$AVR_DUDE_CONF -patmega328p -carduino -P/dev/ttyUSB0 -b115200 -D -Uflash:w:./IR_Quest_2014.cpp.hex:i 7 | 8 | -------------------------------------------------------------------------------- /libraries/DarkNetDisplay/library.properties: -------------------------------------------------------------------------------- 1 | name=DarkNet_Display 2 | version=1.0.0 3 | author=cmdc0de 4 | maintainer=cmdc0dez@gmail.com 5 | sentence=Based on AdaFruit libraries GFX and SSD1306 oled driver library for 'monochrome' 128x64 and 128x32 OLEDs! 6 | paragraph=SSD1306 oled driver library for 'monochrome' 128x64 and 128x32 OLEDs! 7 | category=Display 8 | url=https://github.com/thedarknet/hhvkit/libraries 9 | architectures=* 10 | -------------------------------------------------------------------------------- /DCDarkNet/FirmWare/build/burn-eeprom.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | AVR_DUDE="/home/mark/Arduino/arduino-1.5.7/hardware/tools/avr/bin/avrdude" 4 | AVR_DUDE_CONF="/home/mark/Arduino/arduino-1.5.7/hardware/tools/avr/etc/avrdude.conf" 5 | 6 | GUID=$1 7 | 8 | echo "Making EEPROM code for $GUID" 9 | ./make-eeprom.pl $1 > eeprom.hex 10 | 11 | echo "EEPROM code for $GUID is:" 12 | cat eeprom.hex 13 | 14 | $AVR_DUDE -C$AVR_DUDE_CONF -patmega328p -cusbtiny -Ueeprom:w:eeprom.hex:i 15 | 16 | -------------------------------------------------------------------------------- /DCDarkNet/FirmWare/build/burn-bootloader.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | AVR_DUDE="/home/mark/Arduino/arduino-1.5.7/hardware/tools/avr/bin/avrdude" 3 | AVR_DUDE_CONF="/home/mark/Arduino/arduino-1.5.7/hardware/tools/avr/etc/avrdude.conf" 4 | 5 | # Burn fuses 6 | $AVR_DUDE -C$AVR_DUDE_CONF -patmega328p -cusbtiny -e -Ulock:w:0x3F:m -Uefuse:w:0x05:m -Uhfuse:w:0xDE:m -Ulfuse:w:0xFF:m 7 | 8 | # Burn boot loader into flash 9 | $AVR_DUDE -C$AVR_DUDE_CONF -patmega328p -cusbtiny -Uflash:w:./optiboot_atmega328.hex:i -Ulock:w:0x0F:m 10 | 11 | 12 | -------------------------------------------------------------------------------- /libraries/UsbKeyboard/vusb-20121206/tests/Readme.txt: -------------------------------------------------------------------------------- 1 | This is the Readme file for the directory "tests" of V-USB, a firmware-only 2 | USB driver for AVR microcontrollers. 3 | 4 | WHAT IS IN THIS DIRECTORY? 5 | ========================== 6 | This directory is for driver development only. It contains tests to check 7 | whether all branches of #ifdef code compile as they should and whether the 8 | code size of the driver increased. 9 | 10 | 11 | ---------------------------------------------------------------------------- 12 | (c) 2008 by OBJECTIVE DEVELOPMENT Software GmbH. 13 | http://www.obdev.at/ 14 | -------------------------------------------------------------------------------- /software/fwupdate/10-avrisp.rules: -------------------------------------------------------------------------------- 1 | # 2 | # To install: 3 | # sudo ln -s $PWD/10-avrisp.rules /etc/udev/rules.d/ 4 | # sudo udevadm control --reload 5 | # 6 | SUBSYSTEM!="usb_device", ACTION!="add", GOTO="avrisp_end" 7 | 8 | # Atmel Corp.JTAG ICE mkII 9 | ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="2103", MODE="660", GROUP="dialout" 10 | 11 | # Atmel Corp. AVRISP mkII 12 | ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="2104", MODE="660", GROUP="dialout" 13 | 14 | # Atmel Corp. Dragon 15 | ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="2107", MODE="660", GROUP="dialout" 16 | 17 | LABEL="avrisp_end" 18 | -------------------------------------------------------------------------------- /libraries/UsbKeyboard/vusb-20121206/examples/hid-data/commandline/Makefile.windows: -------------------------------------------------------------------------------- 1 | # Name: Makefile.windows 2 | # Project: hid-data example 3 | # Author: Christian Starkjohann 4 | # Creation Date: 2008-04-11 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 | 9 | # You may use this file with 10 | # make -f Makefile.windows 11 | # on Windows with MinGW instead of editing the main Makefile. 12 | 13 | include Makefile 14 | 15 | USBFLAGS= 16 | USBLIBS= -lhid -lsetupapi 17 | EXE_SUFFIX= .exe 18 | -------------------------------------------------------------------------------- /libraries/UsbKeyboard/vusb-20121206/examples/usbtool/Makefile.windows: -------------------------------------------------------------------------------- 1 | # Name: Makefile.windows 2 | # Project: usbtool 3 | # Author: Christian Starkjohann 4 | # Creation Date: 2008-04-06 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 | 9 | # You may use this file with 10 | # make -f Makefile.windows 11 | # on Windows with MinGW instead of editing the main Makefile. 12 | 13 | include Makefile 14 | 15 | USBFLAGS = -I/usr/local/mingw/include 16 | USBLIBS = -L/usr/local/mingw/lib -lusb 17 | EXE_SUFFIX = .exe 18 | -------------------------------------------------------------------------------- /libraries/UsbKeyboard/vusb-20121206/examples/custom-class/commandline/Makefile.windows: -------------------------------------------------------------------------------- 1 | # Name: Makefile.windows 2 | # Project: custom-class example 3 | # Author: Christian Starkjohann 4 | # Creation Date: 2008-04-06 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 | 9 | # You may use this file with 10 | # make -f Makefile.windows 11 | # on Windows with MinGW instead of editing the main Makefile. 12 | 13 | include Makefile 14 | 15 | USBFLAGS = -I/usr/local/mingw/include 16 | USBLIBS = -L/usr/local/mingw/lib -lusb 17 | EXE_SUFFIX = .exe 18 | -------------------------------------------------------------------------------- /libraries/UsbKeyboard/vusb-20121206/examples/hid-custom-rq/commandline/Makefile.windows: -------------------------------------------------------------------------------- 1 | # Name: Makefile.windows 2 | # Project: hid-custom-rq example 3 | # Author: Christian Starkjohann 4 | # Creation Date: 2008-04-06 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 | 9 | # You may use this file with 10 | # make -f Makefile.windows 11 | # on Windows with MinGW instead of editing the main Makefile. 12 | 13 | include Makefile 14 | 15 | USBFLAGS = -I/usr/local/mingw/include 16 | USBLIBS = -L/usr/local/mingw/lib -lusb 17 | EXE_SUFFIX = .exe 18 | -------------------------------------------------------------------------------- /libraries/UsbKeyboard/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 | -------------------------------------------------------------------------------- /libraries/UsbKeyboard/vusb-20121206/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 | -------------------------------------------------------------------------------- /libraries/IRSerial2014/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map for NewSoftSerial 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | NewSoftSerial KEYWORD1 10 | 11 | ####################################### 12 | # Methods and Functions (KEYWORD2) 13 | ####################################### 14 | 15 | begin KEYWORD2 16 | end KEYWORD2 17 | read KEYWORD2 18 | available KEYWORD2 19 | isListening KEYWORD2 20 | overflow KEYWORD2 21 | flush KEYWORD2 22 | listen KEYWORD2 23 | 24 | ####################################### 25 | # Constants (LITERAL1) 26 | ####################################### 27 | 28 | -------------------------------------------------------------------------------- /DCDarkNet/FirmWare/ButtonTest/ButtonTest.ino: -------------------------------------------------------------------------------- 1 | 2 | #define SERIAL_BAUD 115200 3 | #include 4 | 5 | void setup() { 6 | // put your setup code here, to run once: 7 | Serial.begin(SERIAL_BAUD); 8 | pinMode(10,INPUT); 9 | digitalWrite(10,HIGH); 10 | } 11 | 12 | void loop() { 13 | // put your main code here, to run repeatedly: 14 | Serial.print("analog: A3: " ); 15 | Serial.println(analogRead(A3)); 16 | Serial.print("analog: A2: " ); 17 | Serial.println(analogRead(A2)); 18 | Serial.print("analog: A1: " ); 19 | Serial.println(analogRead(A1)); 20 | Serial.print("analog: A0: " ); 21 | Serial.println(analogRead(A0)); 22 | Serial.print("digital "); 23 | Serial.println(digitalRead(10)==LOW); 24 | delay(1000); 25 | } 26 | -------------------------------------------------------------------------------- /libraries/UsbKeyboard/vusb-20121206/tests/null.c: -------------------------------------------------------------------------------- 1 | /* Name: null.c 2 | * Project: Testing driver features 3 | * Author: Christian Starkjohann 4 | * Creation Date: 2008-04-29 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 | */ 9 | 10 | /* 11 | This is a NULL main() function to find out the code size required by libusb's 12 | startup code, interrupt vectors etc. 13 | */ 14 | #include 15 | 16 | 17 | /* ------------------------------------------------------------------------- */ 18 | 19 | int main(void) 20 | { 21 | for(;;); 22 | return 0; 23 | } 24 | 25 | /* ------------------------------------------------------------------------- */ 26 | -------------------------------------------------------------------------------- /software/fwupdate/buildDB.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | $numCodes = 350; 4 | #$numCodes = 10; 5 | 6 | use Math::Random::ISAAC; 7 | 8 | my $seed = 1; 9 | open SEED, "/dev/urandom" or die "Couldn't open /dev/urandom to get a seed"; 10 | for ($ndx = 0; $ndx < 16; $ndx++) { 11 | read SEED, $foo, 1; 12 | $seed <<= 8; 13 | $seed += ord($foo); 14 | } 15 | close SEED; 16 | 17 | printf "Seed: 0x%016X\n", $seed; 18 | my $rng = Math::Random::ISAAC->new($seed); 19 | 20 | for ($ndx = 0; $ndx < $numCodes; $ndx++) { 21 | # Make the GUID 22 | $guid = ""; 23 | for ($i = 0; $i < 8; $i++) { 24 | $guid .= chr(65 + $rng->irand()%16); 25 | } 26 | 27 | printf "%s %04X %04X %04X %04X\n", $guid, 28 | $rng->irand()%0x10000, $rng->irand()%0x10000, $rng->irand()%0x10000, $rng->irand()%0x10000; 29 | } 30 | -------------------------------------------------------------------------------- /DCDarkNet/FirmWare/build/buildDB.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | $numCodes = 650; 4 | #$numCodes = 10; 5 | 6 | use Math::Random::ISAAC; 7 | 8 | my $seed = 1; 9 | open SEED, "/dev/urandom" or die "Couldn't open /dev/urandom to get a seed"; 10 | for ($ndx = 0; $ndx < 16; $ndx++) { 11 | read SEED, $foo, 1; 12 | $seed <<= 8; 13 | $seed += ord($foo); 14 | } 15 | close SEED; 16 | 17 | printf "Seed: 0x%016X\n", $seed; 18 | my $rng = Math::Random::ISAAC->new($seed); 19 | 20 | for ($ndx = 0; $ndx < $numCodes; $ndx++) { 21 | # Make the GUID 22 | $guid = ""; 23 | for ($i = 0; $i < 8; $i++) { 24 | $guid .= chr(65 + $rng->irand()%16); 25 | } 26 | 27 | printf "%s %04X %04X %04X %04X\n", $guid, 28 | $rng->irand()%0x10000, $rng->irand()%0x10000, $rng->irand()%0x10000, $rng->irand()%0x10000; 29 | } 30 | -------------------------------------------------------------------------------- /libraries/ArduinoMD5/examples/MD5_Hash/MD5_Hash.ino: -------------------------------------------------------------------------------- 1 | #include 2 | /* 3 | This is en example of how to use my MD5 library. It provides two 4 | easy-to-use methods, one for generating the MD5 hash, and the second 5 | one to generate the hex encoding of the hash, which is frequently used. 6 | */ 7 | void setup() 8 | { 9 | //initialize serial 10 | Serial.begin(9600); 11 | //give it a second 12 | delay(1000); 13 | //generate the MD5 hash for our string 14 | unsigned char* hash=MD5::make_hash("hello world"); 15 | //generate the digest (hex encoding) of our hash 16 | char *md5str = MD5::make_digest(hash, 16); 17 | free(hash); 18 | //print it on our serial monitor 19 | Serial.println(md5str); 20 | //Give the Memory back to the System if you run the md5 Hash generation in a loop 21 | free(md5str); 22 | } 23 | 24 | void loop() 25 | { 26 | } 27 | -------------------------------------------------------------------------------- /software/fwupdate/make-eeprom.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | 4 | ($guid) = @ARGV; 5 | 6 | unless ($guid =~ m/^[A-Z0-9]{8}$/) { 7 | print STDERR "Usage: $0 [GUID]\n"; 8 | exit(1); 9 | } 10 | 11 | open DB, "DB" or die "Couldn't open DB for reading: $!"; 12 | $key = ""; 13 | while () { 14 | next unless m/$guid ([0-9A-F]{4}) ([0-9A-F]{4}) ([0-9A-F]{4}) ([0-9A-F]{4})/; 15 | $key = "$1$2$3$4"; 16 | last; 17 | } 18 | close DB; 19 | 20 | die "Couldn't find GUID in DB: $guid\nExiting.\n" if $key eq ""; 21 | 22 | my $eepromStr = "1403EC00$key"; 23 | foreach $char (split '', $guid) { 24 | $eepromStr .= sprintf "%02X", ord($char); 25 | } 26 | $eepromStr .= "00000000"; 27 | 28 | @chars = split '', $eepromStr; 29 | $checksum = 0; 30 | while (scalar(@chars)) { 31 | $a = shift(@chars); 32 | $b = shift(@chars); 33 | $checksum += hex("$a$b"); 34 | } 35 | printf ":$eepromStr%02X\n", 256-($checksum%256); 36 | print ":00000001FF\n"; 37 | -------------------------------------------------------------------------------- /DCDarkNet/FirmWare/build/make-eeprom.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | 4 | ($guid) = @ARGV; 5 | 6 | unless ($guid =~ m/^[A-Z0-9]{8}$/) { 7 | print STDERR "Usage: $0 [GUID]\n"; 8 | exit(1); 9 | } 10 | 11 | open DB, "DB" or die "Couldn't open DB for reading: $!"; 12 | $key = ""; 13 | while () { 14 | next unless m/$guid ([0-9A-F]{4}) ([0-9A-F]{4}) ([0-9A-F]{4}) ([0-9A-F]{4})/; 15 | $key = "$1$2$3$4"; 16 | last; 17 | } 18 | close DB; 19 | 20 | die "Couldn't find GUID in DB: $guid\nExiting.\n" if $key eq ""; 21 | 22 | my $eepromStr = "1403EC00$key"; 23 | foreach $char (split '', $guid) { 24 | $eepromStr .= sprintf "%02X", ord($char); 25 | } 26 | $eepromStr .= "00000000"; 27 | 28 | @chars = split '', $eepromStr; 29 | $checksum = 0; 30 | while (scalar(@chars)) { 31 | $a = shift(@chars); 32 | $b = shift(@chars); 33 | $checksum += hex("$a$b"); 34 | } 35 | printf ":$eepromStr%02X\n", 256-($checksum%256); 36 | print ":00000001FF\n"; 37 | -------------------------------------------------------------------------------- /libraries/UsbKeyboard/vusb-20121206/tests/sizes-reference/sizes-20080418-gcc3.4.6.txt: -------------------------------------------------------------------------------- 1 | Variation Flash RAM +F +RAM 2 | Minimum_with_16_MHz 1154 45 +0 +0 3 | Minimum_with_12_MHz 1274 45 +120 +0 4 | Minimum_with_15_MHz 1260 45 +106 +0 5 | Minimum_with_16_5_MHz 1276 45 +122 +0 6 | With_usbFunctionWrite 1214 45 +60 +0 7 | With_usbFunctionRead 1200 45 +46 +0 8 | With_usbFunctionRead_and_Write 1246 45 +92 +0 9 | With_usbFunctionWriteOut 1178 45 +24 +0 10 | With_Interrupt_In_Endpoint_1 1284 58 +130 +13 11 | With_Interrupt_In_Endpoint_1_and_Halt 1372 58 +218 +13 12 | With_Interrupt_In_Endpoint_1_and_3 1386 69 +232 +24 13 | With_Dynamic_Descriptor 1186 45 +32 +0 14 | -------------------------------------------------------------------------------- /libraries/UsbKeyboard/vusb-20121206/tests/sizes-reference/sizes-20080418-gcc4.2.2.txt: -------------------------------------------------------------------------------- 1 | Variation Flash RAM +F +RAM 2 | Minimum_with_16_MHz 1208 45 +0 +0 3 | Minimum_with_12_MHz 1328 45 +120 +0 4 | Minimum_with_15_MHz 1314 45 +106 +0 5 | Minimum_with_16_5_MHz 1330 45 +122 +0 6 | With_usbFunctionWrite 1268 45 +60 +0 7 | With_usbFunctionRead 1264 45 +56 +0 8 | With_usbFunctionRead_and_Write 1314 45 +106 +0 9 | With_usbFunctionWriteOut 1218 45 +10 +0 10 | With_Interrupt_In_Endpoint_1 1340 58 +132 +13 11 | With_Interrupt_In_Endpoint_1_and_Halt 1414 58 +206 +13 12 | With_Interrupt_In_Endpoint_1_and_3 1426 69 +218 +24 13 | With_Dynamic_Descriptor 1238 45 +30 +0 14 | -------------------------------------------------------------------------------- /software/fwupdate/DummyLCDController.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # 3 | # Simple module to control the Sparkfun Serial LCD Modules 4 | # 5 | import serial 6 | 7 | class Controller(): 8 | def __init__(self): 9 | return 10 | 11 | def connect(self, serialPort, baudRate): 12 | return True 13 | 14 | def write(self, string): 15 | return 16 | 17 | def disconnect(self): 18 | return 19 | 20 | def clear(self): 21 | return 22 | 23 | def setBacklight(self, brightness): 24 | return 25 | 26 | def setCursorPos(self, pos): 27 | return 28 | 29 | def cursorMoveRight(self, times = 1): 30 | return 31 | 32 | def cursorMoveLeft(self, times = 1): 33 | return 34 | 35 | def cursorScrollRight(self, times = 1): 36 | return 37 | 38 | def cursorScrollLeft(self, times = 1): 39 | return 40 | 41 | if __name__ == '__main__': 42 | print('Standalone operation not supported...') 43 | -------------------------------------------------------------------------------- /libraries/UsbKeyboard/vusb-20121206/libs-device/Readme.txt: -------------------------------------------------------------------------------- 1 | This is the Readme file for the libs-device directory. This directory contains 2 | code snippets which may be useful for USB device firmware. 3 | 4 | 5 | WHAT IS INCLUDED IN THIS DIRECTORY? 6 | =================================== 7 | 8 | osccal.c and osccal.h 9 | This module contains a function which calibrates the AVR's built-in RC 10 | oscillator based on the USB frame clock. See osccal.h for a documentation 11 | of the API. 12 | 13 | osctune.h 14 | This header file contains a code snippet for usbconfig.h. With this code, 15 | you can keep the AVR's internal RC oscillator in sync with the USB frame 16 | clock. This is a continuous synchronization, not a single calibration at 17 | USB reset as with osccal.c above. Please note that this code works only 18 | if D- is wired to the interrupt, not D+. 19 | 20 | ---------------------------------------------------------------------------- 21 | (c) 2008 by OBJECTIVE DEVELOPMENT Software GmbH. 22 | http://www.obdev.at/ 23 | -------------------------------------------------------------------------------- /libraries/ArduinoMD5/README.md: -------------------------------------------------------------------------------- 1 | This is an MD5 library for the Arduino, based on scottmac's MD5 library, which you can find here: 2 | https://github.com/scottmac/arduino 3 | 4 | I created this because I was having a really hard time finding an easy-to-install and use libray for the Arduino, 5 | so I decided to make my own. There is an example on how to use it. 6 | 7 | ### Installation 8 | Create a folder named _MD5_ in the _libraries_ folder inside your Arduino sketch folder. If the 9 | libraries folder doesn't exist, create it. Then copy everything inside. (re)launch the Arduino IDE. 10 | 11 | You're done. Time for a mojito 12 | 13 | ### Usage 14 | 15 | If you create md5 Hashes in a loop you must give the Memory back to the System 16 | ``` 17 | unsigned char* hash=MD5::make_hash("hello world"); 18 | //generate the digest (hex encoding) of our hash 19 | char *md5str = MD5::make_digest(hash, 16); 20 | //print it on our serial monitor 21 | Serial.println(md5str); 22 | //Give the Memory back to the System if you run the md5 Hash generation in a loop 23 | free(md5str); 24 | ``` 25 | -------------------------------------------------------------------------------- /libraries/UsbKeyboard/vusb-20121206/tests/sizes-reference/sizes-20080513-gcc3.4.6.txt: -------------------------------------------------------------------------------- 1 | Variation Flash RAM +F +RAM 2 | Minimum_with_16_MHz 1154 45 +0 +0 3 | Minimum_with_12_MHz 1274 45 +120 +0 4 | Minimum_with_15_MHz 1260 45 +106 +0 5 | Minimum_with_16_5_MHz 1276 45 +122 +0 6 | Minimum_with_20_MHz 1136 45 -18 +0 7 | With_usbFunctionWrite 1214 45 +60 +0 8 | With_usbFunctionRead 1192 45 +38 +0 9 | With_usbFunctionRead_and_Write 1234 45 +80 +0 10 | With_usbFunctionWriteOut 1178 45 +24 +0 11 | With_Interrupt_In_Endpoint_1 1280 57 +126 +12 12 | With_Interrupt_In_Endpoint_1_and_Halt 1370 57 +216 +12 13 | With_Interrupt_In_Endpoint_1_and_3 1346 69 +192 +24 14 | With_Dynamic_Descriptor 1182 45 +28 +0 15 | With_Long_Transfers 1200 47 +46 +2 16 | -------------------------------------------------------------------------------- /libraries/UsbKeyboard/vusb-20121206/tests/sizes-reference/sizes-20080513-gcc4.3.0.txt: -------------------------------------------------------------------------------- 1 | Variation Flash RAM +F +RAM 2 | Minimum_with_16_MHz 1192 45 +0 +0 3 | Minimum_with_12_MHz 1312 45 +120 +0 4 | Minimum_with_15_MHz 1298 45 +106 +0 5 | Minimum_with_16_5_MHz 1314 45 +122 +0 6 | Minimum_with_20_MHz 1174 45 -18 +0 7 | With_usbFunctionWrite 1246 45 +54 +0 8 | With_usbFunctionRead 1242 45 +50 +0 9 | With_usbFunctionRead_and_Write 1280 45 +88 +0 10 | With_usbFunctionWriteOut 1208 45 +16 +0 11 | With_Interrupt_In_Endpoint_1 1320 57 +128 +12 12 | With_Interrupt_In_Endpoint_1_and_Halt 1410 57 +218 +12 13 | With_Interrupt_In_Endpoint_1_and_3 1428 69 +236 +24 14 | With_Dynamic_Descriptor 1212 45 +20 +0 15 | With_Long_Transfers 1270 47 +78 +2 16 | -------------------------------------------------------------------------------- /libraries/UsbKeyboard/vusb-20121206/tests/sizes-reference/sizes-20081022-gcc3.4.6.txt: -------------------------------------------------------------------------------- 1 | Variation Flash RAM +F +RAM 2 | Minimum_with_16_MHz 1152 45 +0 +0 3 | Minimum_with_12_MHz 1202 45 +50 +0 4 | Minimum_with_12_8_MHz 1522 45 +370 +0 5 | Minimum_with_15_MHz 1258 45 +106 +0 6 | Minimum_with_16_5_MHz 1274 45 +122 +0 7 | Minimum_with_20_MHz 1134 45 -18 +0 8 | With_usbFunctionWrite 1212 45 +60 +0 9 | With_usbFunctionRead 1190 45 +38 +0 10 | With_usbFunctionRead_and_Write 1232 45 +80 +0 11 | With_usbFunctionWriteOut 1176 45 +24 +0 12 | With_Interrupt_In_Endpoint_1 1278 57 +126 +12 13 | With_Interrupt_In_Endpoint_1_and_Halt 1368 57 +216 +12 14 | With_Interrupt_In_Endpoint_1_and_3 1344 69 +192 +24 15 | With_Dynamic_Descriptor 1180 45 +28 +0 16 | With_Long_Transfers 1198 47 +46 +2 17 | -------------------------------------------------------------------------------- /libraries/UsbKeyboard/vusb-20121206/tests/sizes-reference/sizes-20081022-gcc4.3.0.txt: -------------------------------------------------------------------------------- 1 | Variation Flash RAM +F +RAM 2 | Minimum_with_16_MHz 1194 45 +0 +0 3 | Minimum_with_12_MHz 1244 45 +50 +0 4 | Minimum_with_12_8_MHz 1564 45 +370 +0 5 | Minimum_with_15_MHz 1300 45 +106 +0 6 | Minimum_with_16_5_MHz 1316 45 +122 +0 7 | Minimum_with_20_MHz 1176 45 -18 +0 8 | With_usbFunctionWrite 1248 45 +54 +0 9 | With_usbFunctionRead 1244 45 +50 +0 10 | With_usbFunctionRead_and_Write 1282 45 +88 +0 11 | With_usbFunctionWriteOut 1210 45 +16 +0 12 | With_Interrupt_In_Endpoint_1 1322 57 +128 +12 13 | With_Interrupt_In_Endpoint_1_and_Halt 1412 57 +218 +12 14 | With_Interrupt_In_Endpoint_1_and_3 1430 69 +236 +24 15 | With_Dynamic_Descriptor 1214 45 +20 +0 16 | With_Long_Transfers 1272 47 +78 +2 17 | -------------------------------------------------------------------------------- /libraries/UsbKeyboard/vusb-20121206/tests/sizes-reference/sizes-20081126-gcc3.4.6.txt: -------------------------------------------------------------------------------- 1 | Variation Flash RAM +F +RAM 2 | Minimum_with_16_MHz 1152 45 +0 +0 3 | Minimum_with_12_MHz 1202 45 +50 +0 4 | Minimum_with_12_8_MHz 1522 45 +370 +0 5 | Minimum_with_15_MHz 1258 45 +106 +0 6 | Minimum_with_16_5_MHz 1274 45 +122 +0 7 | Minimum_with_20_MHz 1134 45 -18 +0 8 | With_usbFunctionWrite 1212 45 +60 +0 9 | With_usbFunctionRead 1190 45 +38 +0 10 | With_usbFunctionRead_and_Write 1232 45 +80 +0 11 | With_usbFunctionWriteOut 1176 45 +24 +0 12 | With_Interrupt_In_Endpoint_1 1278 57 +126 +12 13 | With_Interrupt_In_Endpoint_1_and_Halt 1368 57 +216 +12 14 | With_Interrupt_In_Endpoint_1_and_3 1344 69 +192 +24 15 | With_Dynamic_Descriptor 1180 45 +28 +0 16 | With_Long_Transfers 1198 47 +46 +2 17 | -------------------------------------------------------------------------------- /libraries/UsbKeyboard/vusb-20121206/tests/sizes-reference/sizes-20081126-gcc4.3.0.txt: -------------------------------------------------------------------------------- 1 | Variation Flash RAM +F +RAM 2 | Minimum_with_16_MHz 1194 45 +0 +0 3 | Minimum_with_12_MHz 1244 45 +50 +0 4 | Minimum_with_12_8_MHz 1564 45 +370 +0 5 | Minimum_with_15_MHz 1300 45 +106 +0 6 | Minimum_with_16_5_MHz 1316 45 +122 +0 7 | Minimum_with_20_MHz 1176 45 -18 +0 8 | With_usbFunctionWrite 1248 45 +54 +0 9 | With_usbFunctionRead 1244 45 +50 +0 10 | With_usbFunctionRead_and_Write 1282 45 +88 +0 11 | With_usbFunctionWriteOut 1210 45 +16 +0 12 | With_Interrupt_In_Endpoint_1 1322 57 +128 +12 13 | With_Interrupt_In_Endpoint_1_and_Halt 1412 57 +218 +12 14 | With_Interrupt_In_Endpoint_1_and_3 1430 69 +236 +24 15 | With_Dynamic_Descriptor 1214 45 +20 +0 16 | With_Long_Transfers 1272 47 +78 +2 17 | -------------------------------------------------------------------------------- /libraries/UsbKeyboard/vusb-20121206/examples/hid-data/commandline/Makefile: -------------------------------------------------------------------------------- 1 | # Name: Makefile 2 | # Project: hid-data example 3 | # Author: Christian Starkjohann 4 | # Creation Date: 2008-04-11 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 | 9 | # Please read the definitions below and edit them as appropriate for your 10 | # system: 11 | 12 | # Use the following 3 lines on Unix and Mac OS X: 13 | USBFLAGS= `libusb-config --cflags` 14 | USBLIBS= `libusb-config --libs` 15 | EXE_SUFFIX= 16 | 17 | # Use the following 3 lines on Windows and comment out the 3 above: 18 | #USBFLAGS= 19 | #USBLIBS= -lhid -lusb -lsetupapi 20 | #EXE_SUFFIX= .exe 21 | 22 | CC= gcc 23 | CFLAGS= -O -Wall $(USBFLAGS) 24 | LIBS= $(USBLIBS) 25 | 26 | OBJ= hidtool.o hiddata.o 27 | PROGRAM= hidtool$(EXE_SUFFIX) 28 | 29 | all: $(PROGRAM) 30 | 31 | $(PROGRAM): $(OBJ) 32 | $(CC) -o $(PROGRAM) $(OBJ) $(LIBS) 33 | 34 | strip: $(PROGRAM) 35 | strip $(PROGRAM) 36 | 37 | clean: 38 | rm -f $(OBJ) $(PROGRAM) 39 | 40 | .c.o: 41 | $(CC) $(ARCH_COMPILE) $(CFLAGS) -c $*.c -o $*.o 42 | -------------------------------------------------------------------------------- /libraries/UsbKeyboard/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 | -------------------------------------------------------------------------------- /libraries/UsbKeyboard/vusb-20121206/libs-host/Readme.txt: -------------------------------------------------------------------------------- 1 | This is the Readme file for the libs-host directory. This directory contains 2 | code snippets which may be useful for host side USB software. 3 | 4 | 5 | WHAT IS INCLUDED IN THIS DIRECTORY? 6 | =================================== 7 | 8 | opendevice.c and opendevice.h 9 | This module contains a function to find and open a device given its 10 | numeric IDs (VID, PID), names (vendor name and product name) and serial 11 | number. It is based on libusb/libusb-win32 and returns a libusb device 12 | handle. See opendevice.h for an API documentation. 13 | 14 | hiddata.c and hiddata.h 15 | This module contains functions for data transfer over HID feature reports. 16 | It is based on libusb on Unix and native Windows functions on Windows. No 17 | driver DLL is needed on Windows. See hiddata.h for an API documentation. 18 | 19 | hidsdi.h 20 | This DDK header file is missing in the free MinGW version of the Windows 21 | DDK. Use this version if you get an "include file not found" error. 22 | 23 | 24 | ---------------------------------------------------------------------------- 25 | (c) 2008 by OBJECTIVE DEVELOPMENT Software GmbH. 26 | http://www.obdev.at/ 27 | -------------------------------------------------------------------------------- /libraries/UsbKeyboard/vusb-20121206/tests/sizes-reference/sizes-20090323-gcc3.4.6.txt: -------------------------------------------------------------------------------- 1 | Variation Flash RAM +F +RAM 2 | Minimum_with_16_MHz 1152 45 +0 +0 3 | Minimum_with_12_MHz 1202 45 +50 +0 4 | Minimum_with_12_8_MHz 1522 45 +370 +0 5 | Minimum_with_15_MHz 1258 45 +106 +0 6 | Minimum_with_16_5_MHz 1274 45 +122 +0 7 | Minimum_with_18_MHz+CRC 2268 45 +1116 +0 8 | Minimum_with_20_MHz 1134 45 -18 +0 9 | With_usbFunctionWrite 1212 45 +60 +0 10 | With_usbFunctionRead 1190 45 +38 +0 11 | With_usbFunctionRead_and_Write 1232 45 +80 +0 12 | With_usbFunctionWriteOut 1176 45 +24 +0 13 | With_Interrupt_In_Endpoint_1 1278 57 +126 +12 14 | With_Interrupt_In_Endpoint_1_and_Halt 1368 57 +216 +12 15 | With_Interrupt_In_Endpoint_1_and_3 1344 69 +192 +24 16 | With_Dynamic_Descriptor 1180 45 +28 +0 17 | With_Long_Transfers 1198 47 +46 +2 18 | -------------------------------------------------------------------------------- /libraries/UsbKeyboard/vusb-20121206/tests/sizes-reference/sizes-20090323-gcc4.3.2.txt: -------------------------------------------------------------------------------- 1 | Variation Flash RAM +F +RAM 2 | Minimum_with_16_MHz 1224 45 +0 +0 3 | Minimum_with_12_MHz 1274 45 +50 +0 4 | Minimum_with_12_8_MHz 1594 45 +370 +0 5 | Minimum_with_15_MHz 1330 45 +106 +0 6 | Minimum_with_16_5_MHz 1346 45 +122 +0 7 | Minimum_with_18_MHz+CRC 2298 45 +1074 +0 8 | Minimum_with_20_MHz 1206 45 -18 +0 9 | With_usbFunctionWrite 1284 45 +60 +0 10 | With_usbFunctionRead 1280 45 +56 +0 11 | With_usbFunctionRead_and_Write 1318 45 +94 +0 12 | With_usbFunctionWriteOut 1246 45 +22 +0 13 | With_Interrupt_In_Endpoint_1 1358 57 +134 +12 14 | With_Interrupt_In_Endpoint_1_and_Halt 1448 57 +224 +12 15 | With_Interrupt_In_Endpoint_1_and_3 1466 69 +242 +24 16 | With_Dynamic_Descriptor 1250 45 +26 +0 17 | With_Long_Transfers 1302 47 +78 +2 18 | -------------------------------------------------------------------------------- /libraries/UsbKeyboard/vusb-20121206/tests/sizes-reference/sizes-20090415-gcc3.4.6.txt: -------------------------------------------------------------------------------- 1 | Variation Flash RAM +F +RAM 2 | Minimum_with_16_MHz 1152 45 +0 +0 3 | Minimum_with_12_MHz 1202 45 +50 +0 4 | Minimum_with_12_8_MHz 1522 45 +370 +0 5 | Minimum_with_15_MHz 1258 45 +106 +0 6 | Minimum_with_16_5_MHz 1274 45 +122 +0 7 | Minimum_with_18_MHz+CRC 2268 45 +1116 +0 8 | Minimum_with_20_MHz 1134 45 -18 +0 9 | With_usbFunctionWrite 1212 45 +60 +0 10 | With_usbFunctionRead 1190 45 +38 +0 11 | With_usbFunctionRead_and_Write 1232 45 +80 +0 12 | With_usbFunctionWriteOut 1176 45 +24 +0 13 | With_Interrupt_In_Endpoint_1 1278 57 +126 +12 14 | With_Interrupt_In_Endpoint_1_and_Halt 1368 57 +216 +12 15 | With_Interrupt_In_Endpoint_1_and_3 1344 69 +192 +24 16 | With_Dynamic_Descriptor 1180 45 +28 +0 17 | With_Long_Transfers 1198 47 +46 +2 18 | -------------------------------------------------------------------------------- /libraries/UsbKeyboard/vusb-20121206/tests/sizes-reference/sizes-20090415-gcc4.3.2.txt: -------------------------------------------------------------------------------- 1 | Variation Flash RAM +F +RAM 2 | Minimum_with_16_MHz 1224 45 +0 +0 3 | Minimum_with_12_MHz 1274 45 +50 +0 4 | Minimum_with_12_8_MHz 1594 45 +370 +0 5 | Minimum_with_15_MHz 1330 45 +106 +0 6 | Minimum_with_16_5_MHz 1346 45 +122 +0 7 | Minimum_with_18_MHz+CRC 2298 45 +1074 +0 8 | Minimum_with_20_MHz 1206 45 -18 +0 9 | With_usbFunctionWrite 1284 45 +60 +0 10 | With_usbFunctionRead 1280 45 +56 +0 11 | With_usbFunctionRead_and_Write 1318 45 +94 +0 12 | With_usbFunctionWriteOut 1246 45 +22 +0 13 | With_Interrupt_In_Endpoint_1 1358 57 +134 +12 14 | With_Interrupt_In_Endpoint_1_and_Halt 1448 57 +224 +12 15 | With_Interrupt_In_Endpoint_1_and_3 1466 69 +242 +24 16 | With_Dynamic_Descriptor 1250 45 +26 +0 17 | With_Long_Transfers 1302 47 +78 +2 18 | -------------------------------------------------------------------------------- /libraries/UsbKeyboard/vusb-20121206/tests/sizes-reference/sizes-20100715-gcc3.4.6.txt: -------------------------------------------------------------------------------- 1 | Variation Flash RAM +F +RAM 2 | Minimum_with_16_MHz 1152 45 +0 +0 3 | Minimum_with_12_MHz 1202 45 +50 +0 4 | Minimum_with_12_8_MHz 1518 45 +366 +0 5 | Minimum_with_15_MHz 1258 45 +106 +0 6 | Minimum_with_16_5_MHz 1274 45 +122 +0 7 | Minimum_with_18_MHz+CRC 2268 45 +1116 +0 8 | Minimum_with_20_MHz 1134 45 -18 +0 9 | With_usbFunctionWrite 1212 45 +60 +0 10 | With_usbFunctionRead 1190 45 +38 +0 11 | With_usbFunctionRead_and_Write 1232 45 +80 +0 12 | With_usbFunctionWriteOut 1176 45 +24 +0 13 | With_Interrupt_In_Endpoint_1 1278 57 +126 +12 14 | With_Interrupt_In_Endpoint_1_and_Halt 1368 57 +216 +12 15 | With_Interrupt_In_Endpoint_1_and_3 1344 69 +192 +24 16 | With_Dynamic_Descriptor 1180 45 +28 +0 17 | With_Long_Transfers 1198 47 +46 +2 18 | -------------------------------------------------------------------------------- /libraries/UsbKeyboard/vusb-20121206/tests/sizes-reference/sizes-20100715-gcc4.3.3.txt: -------------------------------------------------------------------------------- 1 | Variation Flash RAM +F +RAM 2 | Minimum_with_16_MHz 1226 45 +0 +0 3 | Minimum_with_12_MHz 1276 45 +50 +0 4 | Minimum_with_12_8_MHz 1592 45 +366 +0 5 | Minimum_with_15_MHz 1332 45 +106 +0 6 | Minimum_with_16_5_MHz 1348 45 +122 +0 7 | Minimum_with_18_MHz+CRC 2298 45 +1072 +0 8 | Minimum_with_20_MHz 1208 45 -18 +0 9 | With_usbFunctionWrite 1286 45 +60 +0 10 | With_usbFunctionRead 1282 45 +56 +0 11 | With_usbFunctionRead_and_Write 1320 45 +94 +0 12 | With_usbFunctionWriteOut 1248 45 +22 +0 13 | With_Interrupt_In_Endpoint_1 1360 57 +134 +12 14 | With_Interrupt_In_Endpoint_1_and_Halt 1450 57 +224 +12 15 | With_Interrupt_In_Endpoint_1_and_3 1418 69 +192 +24 16 | With_Dynamic_Descriptor 1252 45 +26 +0 17 | With_Long_Transfers 1304 47 +78 +2 18 | -------------------------------------------------------------------------------- /libraries/UsbKeyboard/vusb-20121206/tests/sizes-reference/sizes-20120109-gcc3.4.6.txt: -------------------------------------------------------------------------------- 1 | Variation Flash RAM +F +RAM 2 | Minimum_with_16_MHz 1152 45 +0 +0 3 | Minimum_with_12_MHz 1202 45 +50 +0 4 | Minimum_with_12_8_MHz 1518 45 +366 +0 5 | Minimum_with_15_MHz 1258 45 +106 +0 6 | Minimum_with_16_5_MHz 1274 45 +122 +0 7 | Minimum_with_18_MHz+CRC 2268 45 +1116 +0 8 | Minimum_with_20_MHz 1134 45 -18 +0 9 | With_usbFunctionWrite 1212 45 +60 +0 10 | With_usbFunctionRead 1190 45 +38 +0 11 | With_usbFunctionRead_and_Write 1232 45 +80 +0 12 | With_usbFunctionWriteOut 1176 45 +24 +0 13 | With_Interrupt_In_Endpoint_1 1278 57 +126 +12 14 | With_Interrupt_In_Endpoint_1_and_Halt 1368 57 +216 +12 15 | With_Interrupt_In_Endpoint_1_and_3 1344 69 +192 +24 16 | With_Dynamic_Descriptor 1180 45 +28 +0 17 | With_Long_Transfers 1206 47 +54 +2 18 | -------------------------------------------------------------------------------- /libraries/UsbKeyboard/vusb-20121206/tests/sizes-reference/sizes-20120109-gcc4.3.3.txt: -------------------------------------------------------------------------------- 1 | Variation Flash RAM +F +RAM 2 | Minimum_with_16_MHz 1226 45 +0 +0 3 | Minimum_with_12_MHz 1276 45 +50 +0 4 | Minimum_with_12_8_MHz 1592 45 +366 +0 5 | Minimum_with_15_MHz 1332 45 +106 +0 6 | Minimum_with_16_5_MHz 1348 45 +122 +0 7 | Minimum_with_18_MHz+CRC 2298 45 +1072 +0 8 | Minimum_with_20_MHz 1208 45 -18 +0 9 | With_usbFunctionWrite 1286 45 +60 +0 10 | With_usbFunctionRead 1282 45 +56 +0 11 | With_usbFunctionRead_and_Write 1320 45 +94 +0 12 | With_usbFunctionWriteOut 1248 45 +22 +0 13 | With_Interrupt_In_Endpoint_1 1360 57 +134 +12 14 | With_Interrupt_In_Endpoint_1_and_Halt 1450 57 +224 +12 15 | With_Interrupt_In_Endpoint_1_and_3 1418 69 +192 +24 16 | With_Dynamic_Descriptor 1252 45 +26 +0 17 | With_Long_Transfers 1300 47 +74 +2 18 | -------------------------------------------------------------------------------- /libraries/UsbKeyboard/vusb-20121206/tests/sizes-reference/sizes-20121206-gcc4.6.2.txt: -------------------------------------------------------------------------------- 1 | Variation Flash RAM +F +RAM 2 | Minimum_with_16_MHz 1192 45 +0 +0 3 | Minimum_with_12_MHz 1242 45 +50 +0 4 | Minimum_with_12_8_MHz 1558 45 +366 +0 5 | Minimum_with_15_MHz 1298 45 +106 +0 6 | Minimum_with_16_5_MHz 1314 45 +122 +0 7 | Minimum_with_18_MHz+CRC 2262 45 +1070 +0 8 | Minimum_with_20_MHz 1174 45 -18 +0 9 | With_usbFunctionWrite 1252 45 +60 +0 10 | With_usbFunctionRead 1248 45 +56 +0 11 | With_usbFunctionRead_and_Write 1286 45 +94 +0 12 | With_usbFunctionWriteOut 1214 45 +22 +0 13 | With_Interrupt_In_Endpoint_1 1328 57 +136 +12 14 | With_Interrupt_In_Endpoint_1_and_Halt 1420 57 +228 +12 15 | With_Interrupt_In_Endpoint_1_and_3 1386 69 +194 +24 16 | With_Dynamic_Descriptor 1198 45 +6 +0 17 | With_Long_Transfers 1236 47 +44 +2 18 | -------------------------------------------------------------------------------- /libraries/UsbKeyboard/vusb-20121206/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 | -------------------------------------------------------------------------------- /libraries/UsbKeyboard/vusb-20121206/examples/hid-custom-rq/firmware/requests.h: -------------------------------------------------------------------------------- 1 | /* Name: requests.h 2 | * Project: custom-class, a basic USB example 3 | * Author: Christian Starkjohann 4 | * Creation Date: 2008-04-09 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 | */ 9 | 10 | /* This header is shared between the firmware and the host software. It 11 | * defines the USB request numbers (and optionally data types) used to 12 | * communicate between the host and the device. 13 | */ 14 | 15 | #ifndef __REQUESTS_H_INCLUDED__ 16 | #define __REQUESTS_H_INCLUDED__ 17 | 18 | #define CUSTOM_RQ_SET_STATUS 1 19 | /* Set the LED status. Control-OUT. 20 | * The requested status is passed in the "wValue" field of the control 21 | * transfer. No OUT data is sent. Bit 0 of the low byte of wValue controls 22 | * the LED. 23 | */ 24 | 25 | #define CUSTOM_RQ_GET_STATUS 2 26 | /* Get the current LED status. Control-IN. 27 | * This control transfer involves a 1 byte data phase where the device sends 28 | * the current status to the host. The status is in bit 0 of the byte. 29 | */ 30 | 31 | #endif /* __REQUESTS_H_INCLUDED__ */ 32 | -------------------------------------------------------------------------------- /libraries/UsbKeyboard/vusb-20121206/examples/hid-custom-rq/Readme.txt: -------------------------------------------------------------------------------- 1 | This is the Readme file for the hid-custom-rq example. This is basically the 2 | same as the custom-class example, except that the device conforms to the USB 3 | HID class. 4 | 5 | 6 | WHAT IS DEMONSTRATED? 7 | ===================== 8 | This example demonstrates how custom requests can be sent to devices which 9 | are otherwise HID compliant. This mechanism can be used to prevent the 10 | "driver CD" dialog on Windows and still control the device with libusb-win32. 11 | It can also be used to extend the functionality of the USB class, e.g. by 12 | setting parameters. 13 | 14 | Please note that you should install the filter version of libusb-win32 to 15 | take full advantage or this mode. The device driver version only has access 16 | to devices which have been registered for it with a *.inf file. The filter 17 | version has access to all devices. 18 | 19 | 20 | MORE INFORMATION 21 | ================ 22 | For information about how to build this example and how to use the command 23 | line tool see the Readme file in the custom-class example. 24 | 25 | 26 | ---------------------------------------------------------------------------- 27 | (c) 2008 by OBJECTIVE DEVELOPMENT Software GmbH. 28 | http://www.obdev.at/ 29 | -------------------------------------------------------------------------------- /libraries/UsbKeyboard/vusb-20121206/tests/compare-sizes.awk: -------------------------------------------------------------------------------- 1 | #!/usr/bin/awk -f 2 | # Name: compare-sizes.awk 3 | # Project: v-usb 4 | # Author: Christian Starkjohann 5 | # Creation Date: 2008-04-29 6 | # Tabsize: 4 7 | # Copyright: (c) 2008 by OBJECTIVE DEVELOPMENT Software GmbH 8 | # License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) 9 | 10 | BEGIN{ 11 | opt = 0; 12 | if(ARGC != 3){ 13 | printf("usage: compare-sizes.awk file1 file2\n"); 14 | printf(" computes size differences between two size lists\n"); 15 | exit 1; 16 | } 17 | file1 = ARGV[1]; 18 | file2 = ARGV[2]; 19 | } 20 | 21 | { 22 | if(($2 + 0) != 0){ 23 | if(!hadOption[$1]){ 24 | hadOption[$1] = 1; 25 | options[opt++] = $1; 26 | } 27 | flash[FILENAME, $1] = $2; 28 | ram[FILENAME, $1] = $3; 29 | } 30 | } 31 | 32 | END{ 33 | if(opt > 0){ 34 | printf ("%39s %6s %5s\n", "Variation", "+Flash", "+RAM"); 35 | } 36 | for(i = 0; i < opt; i++){ 37 | option = options[i]; 38 | if(!flash[file2, option] || !flash[file1, option]){ 39 | printf("%39s %6s %5s\n", option, "n/a", "n/a"); 40 | }else{ 41 | printf("%39s %+6d %+5d\n", option, flash[file2, option] - flash[file1, option], ram[file2, option] - ram[file1, option]); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /libraries/DarkNetDisplay/README.txt: -------------------------------------------------------------------------------- 1 | This is a library for our Monochrome OLEDs based on SSD1306 drivers 2 | 3 | Pick one up today in the adafruit shop! 4 | ------> http://www.adafruit.com/category/63_98 5 | 6 | These displays use SPI to communicate, 4 or 5 pins are required to 7 | interface 8 | 9 | Adafruit invests time and resources providing this open source code, 10 | please support Adafruit and open-source hardware by purchasing 11 | products from Adafruit! 12 | 13 | Written by Limor Fried/Ladyada for Adafruit Industries. 14 | Scrolling code contributed by Michael Gregg 15 | BSD license, check license.txt for more information 16 | All text above must be included in any redistribution 17 | 18 | To download. click the DOWNLOADS button in the top right corner, rename the uncompressed folder Adafruit_SSD1306. Check that the Adafruit_SSD1306 folder contains Adafruit_SSD1306.cpp and Adafruit_SSD1306.h 19 | 20 | Place the Adafruit_SSD1306 library folder your /libraries/ folder. You may need to create the libraries subfolder if its your first library. Restart the IDE. 21 | 22 | You will also have to download the Adafruit GFX Graphics core which does all the circles, text, rectangles, etc. You can get it from 23 | https://github.com/adafruit/Adafruit-GFX-Library 24 | and download/install that library as well -------------------------------------------------------------------------------- /DCDarkNet/FirmWare/proc-codes.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | # This takes the codes from the tv-b-gone file and modifes them 4 | # to work with the newer version of gcc that doesn't like the way 5 | # the data structures were. 6 | 7 | $DEBUG = 0; 8 | 9 | while() { 10 | if (m/const struct IrCode code_(\w\w\d+)Code/) { 11 | $code = $1; 12 | $DEBUG and print "DEBUG: Found struct $code\n"; 13 | # Starting a struct. Look for the codes block: 14 | @struct = ($_); 15 | while () { 16 | if (m/^\s+{/) { 17 | $DEBUG and print "DEBUG: Found codes\n"; 18 | # The start of the codes block. 19 | print "const uint8_t code_${code}Codes[] PROGMEM = {\n"; 20 | while() { 21 | if (m/^\s+}/) { # End of the Codes block 22 | $DEBUG and print "DEBUG: End of Codes block.\n"; 23 | print "};\n"; 24 | last; 25 | } 26 | s/^\s+/\t/; 27 | print; 28 | } 29 | # Codes block is out, dump the struct and continue on. 30 | print @struct; 31 | print "\tcode_${code}Codes,\n"; 32 | last; 33 | } 34 | push @struct, $_; 35 | } 36 | } 37 | else { 38 | print; 39 | } 40 | } 41 | 42 | -------------------------------------------------------------------------------- /libraries/UsbKeyboard/vusb-20121206/examples/usbtool/Makefile: -------------------------------------------------------------------------------- 1 | # Name: Makefile 2 | # Project: usbtool 3 | # Author: Christian Starkjohann 4 | # Creation Date: 2008-04-06 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 | 9 | 10 | # Concigure the following definitions according to your system. 11 | # This Makefile has been tested on Mac OS X, Linux and Windows. 12 | 13 | # Use the following 3 lines on Unix (uncomment the framework on Mac OS X): 14 | USBFLAGS = `libusb-config --cflags` 15 | USBLIBS = `libusb-config --libs` 16 | EXE_SUFFIX = 17 | 18 | # Use the following 3 lines on Windows and comment out the 3 above. You may 19 | # have to change the include paths to where you installed libusb-win32 20 | #USBFLAGS = -I/usr/local/include 21 | #USBLIBS = -L/usr/local/lib -lusb 22 | #EXE_SUFFIX = .exe 23 | 24 | NAME = usbtool 25 | 26 | OBJECTS = opendevice.o $(NAME).o 27 | 28 | CC = gcc 29 | CFLAGS = $(CPPFLAGS) $(USBFLAGS) -O -g -Wall 30 | LIBS = $(USBLIBS) 31 | 32 | PROGRAM = $(NAME)$(EXE_SUFFIX) 33 | 34 | 35 | all: $(PROGRAM) 36 | 37 | .c.o: 38 | $(CC) $(CFLAGS) -c $< 39 | 40 | $(PROGRAM): $(OBJECTS) 41 | $(CC) -o $(PROGRAM) $(OBJECTS) $(LIBS) 42 | 43 | strip: $(PROGRAM) 44 | strip $(PROGRAM) 45 | 46 | clean: 47 | rm -f *.o $(PROGRAM) 48 | -------------------------------------------------------------------------------- /libraries/UsbKeyboard/vusb-20121206/examples/custom-class/commandline/Makefile: -------------------------------------------------------------------------------- 1 | # Name: Makefile 2 | # Project: custom-class example 3 | # Author: Christian Starkjohann 4 | # Creation Date: 2008-04-06 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 | 9 | 10 | # Concigure the following definitions according to your system. 11 | # This Makefile has been tested on Mac OS X, Linux and Windows. 12 | 13 | # Use the following 3 lines on Unix (uncomment the framework on Mac OS X): 14 | USBFLAGS = `libusb-config --cflags` 15 | USBLIBS = `libusb-config --libs` 16 | EXE_SUFFIX = 17 | 18 | # Use the following 3 lines on Windows and comment out the 3 above. You may 19 | # have to change the include paths to where you installed libusb-win32 20 | #USBFLAGS = -I/usr/local/include 21 | #USBLIBS = -L/usr/local/lib -lusb 22 | #EXE_SUFFIX = .exe 23 | 24 | NAME = set-led 25 | 26 | OBJECTS = opendevice.o $(NAME).o 27 | 28 | CC = gcc 29 | CFLAGS = $(CPPFLAGS) $(USBFLAGS) -O -g -Wall 30 | LIBS = $(USBLIBS) 31 | 32 | PROGRAM = $(NAME)$(EXE_SUFFIX) 33 | 34 | 35 | all: $(PROGRAM) 36 | 37 | .c.o: 38 | $(CC) $(CFLAGS) -c $< 39 | 40 | $(PROGRAM): $(OBJECTS) 41 | $(CC) -o $(PROGRAM) $(OBJECTS) $(LIBS) 42 | 43 | strip: $(PROGRAM) 44 | strip $(PROGRAM) 45 | 46 | clean: 47 | rm -f *.o $(PROGRAM) 48 | -------------------------------------------------------------------------------- /libraries/UsbKeyboard/vusb-20121206/examples/hid-custom-rq/commandline/Makefile: -------------------------------------------------------------------------------- 1 | # Name: Makefile 2 | # Project: hid-custom-rq example 3 | # Author: Christian Starkjohann 4 | # Creation Date: 2008-04-06 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 | 9 | 10 | # Concigure the following definitions according to your system. 11 | # This Makefile has been tested on Mac OS X, Linux and Windows. 12 | 13 | # Use the following 3 lines on Unix (uncomment the framework on Mac OS X): 14 | USBFLAGS = `libusb-config --cflags` 15 | USBLIBS = `libusb-config --libs` 16 | EXE_SUFFIX = 17 | 18 | # Use the following 3 lines on Windows and comment out the 3 above. You may 19 | # have to change the include paths to where you installed libusb-win32 20 | #USBFLAGS = -I/usr/local/include 21 | #USBLIBS = -L/usr/local/lib -lusb 22 | #EXE_SUFFIX = .exe 23 | 24 | NAME = set-led 25 | 26 | OBJECTS = opendevice.o $(NAME).o 27 | 28 | CC = gcc 29 | CFLAGS = $(CPPFLAGS) $(USBFLAGS) -O -g -Wall 30 | LIBS = $(USBLIBS) 31 | 32 | PROGRAM = $(NAME)$(EXE_SUFFIX) 33 | 34 | 35 | all: $(PROGRAM) 36 | 37 | .c.o: 38 | $(CC) $(CFLAGS) -c $< 39 | 40 | $(PROGRAM): $(OBJECTS) 41 | $(CC) -o $(PROGRAM) $(OBJECTS) $(LIBS) 42 | 43 | strip: $(PROGRAM) 44 | strip $(PROGRAM) 45 | 46 | clean: 47 | rm -f *.o $(PROGRAM) 48 | -------------------------------------------------------------------------------- /libraries/UsbKeyboard/vusb-20121206/examples/custom-class/firmware/requests.h: -------------------------------------------------------------------------------- 1 | /* Name: requests.h 2 | * Project: custom-class, a basic USB example 3 | * Author: Christian Starkjohann 4 | * Creation Date: 2008-04-09 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 | */ 9 | 10 | /* This header is shared between the firmware and the host software. It 11 | * defines the USB request numbers (and optionally data types) used to 12 | * communicate between the host and the device. 13 | */ 14 | 15 | #ifndef __REQUESTS_H_INCLUDED__ 16 | #define __REQUESTS_H_INCLUDED__ 17 | 18 | #define CUSTOM_RQ_ECHO 0 19 | /* Request that the device sends back wValue and wIndex. This is used with 20 | * random data to test the reliability of the communication. 21 | */ 22 | #define CUSTOM_RQ_SET_STATUS 1 23 | /* Set the LED status. Control-OUT. 24 | * The requested status is passed in the "wValue" field of the control 25 | * transfer. No OUT data is sent. Bit 0 of the low byte of wValue controls 26 | * the LED. 27 | */ 28 | 29 | #define CUSTOM_RQ_GET_STATUS 2 30 | /* Get the current LED status. Control-IN. 31 | * This control transfer involves a 1 byte data phase where the device sends 32 | * the current status to the host. The status is in bit 0 of the byte. 33 | */ 34 | 35 | #endif /* __REQUESTS_H_INCLUDED__ */ 36 | -------------------------------------------------------------------------------- /libraries/UsbKeyboard/ArduinoNotes.txt: -------------------------------------------------------------------------------- 1 | Notes On Integrating AVRUSB with Arduino 2 | ======================================== 3 | 4 | * Note the license(s) under which AVRUSB is distributed. 5 | 6 | * See also: http://code.rancidbacon.com/ProjectLogArduinoUSB 7 | 8 | * Note: The pins we use on the PCB (not protoboard) hardware shield are: 9 | 10 | INT0 == PD2 == IC Pin 4 == Arduino Digital Pin 2 == D+ 11 | 12 | ---- == PD4 == -------- == Arduino Digital Pin 4 == D- 13 | 14 | ---- == PD5 == -------- == Arduino Digital Pin 5 == pull-up 15 | 16 | (DONE: Change to not use PD3 so INT1 is left free?) 17 | 18 | * In order to compile a valid 'usbconfig.h' file must exit. The content of this 19 | file will vary depending on whether the device is a generic USB device, 20 | generic HID device or specific class of HID device for example. 21 | 22 | The file 'usbconfig-prototype.h' can be used as a starting point, however 23 | it might be easier to use the 'usbconfig.h' from one of the example projects. 24 | 25 | TODO: Specify the settings that need to be changed to match the shield 26 | design we use. 27 | 28 | * (NOTE: Initial 'usbconfig.h' used will be based on the file from 29 | 'HIDKeys.2007-03-29'.) (Note: Have now upgraded to V-USB 2009-08-22.) 30 | 31 | * Versions of the Arduino IDE prior to 0018 won't compile our library 32 | so it needs to be pre-compiled with: 33 | 34 | avr-g++ -Wall -Os -I. -DF_CPU=16000000 -mmcu=atmega168 -c usbdrvasm.S -c usbdrv.c 35 | -------------------------------------------------------------------------------- /software/fwupdate/BBSetup.txt: -------------------------------------------------------------------------------- 1 | Some notes on setting up beaglebone for badge fw updates: 2 | 3 | sudo apt-get update 4 | sudo apt-get upgrade 5 | sudo apt-get install avrdude 6 | 7 | Install Adafruit_BBIO: 8 | https://learn.adafruit.com/setting-up-io-python-library-on-beaglebone-black/installation-on-ubuntu 9 | 10 | So root isn't needed for avrdude: 11 | sudo ln -s $PWD/10-avrisp.rules /etc/udev/rules.d/ 12 | 13 | avrdude -v -c avrispmkII -p m328p -P usb 14 | avrdude -v -c avrispmkII -p m328p -P usb -U flash:r:flash.bin:r 15 | 16 | *run once in python as root (not needed if using service)* 17 | TODO - automate this 18 | import Adafruit_BBIO.UART as UART 19 | UART.setup("UART4") 20 | 21 | ls -l of files that need to be placed in /home/debian/darknet/: 22 | -rw-r--r-- 1 debian debian 1959 Jul 26 18:01 autoupdate.py 23 | -rw-r--r-- 1 debian debian 4775 Jul 26 18:04 AVRProg.py 24 | -rwxr-xr-x 1 debian debian 102 Jul 26 18:02 darknet.sh 25 | -rw-r--r-- 1 debian debian 769 Jul 26 18:05 DummyLCDController.py 26 | -rw-r--r-- 1 debian debian 65141 Jul 26 18:02 firmware.hex 27 | -rw-r--r-- 1 debian debian 2830 Jul 26 18:04 SFLCDController.py 28 | 29 | Service Misc Notes: 30 | from: https://gist.github.com/tstellanova/7323116 31 | 32 | darknet.service goes in /lib/systemd/system/darknet.service 33 | 34 | sudo ln -s /lib/systemd/system/darknet.service /etc/systemd/system/darknet.service 35 | 36 | sudo systemctl daemon-reload 37 | sudo systemctl enable darknet.service 38 | sudo systemctl start darknet.service 39 | 40 | sudo systemctl stop darknet.service 41 | -------------------------------------------------------------------------------- /libraries/DarkNetDisplay/license.txt: -------------------------------------------------------------------------------- 1 | Software License Agreement (BSD License) 2 | 3 | Copyright (c) 2012, Adafruit Industries 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 1. Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 2. Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | 3. Neither the name of the copyright holders nor the 14 | names of its contributors may be used to endorse or promote products 15 | derived from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY 18 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 21 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | -------------------------------------------------------------------------------- /software/fwupdate/optiboot_atmega328.hex: -------------------------------------------------------------------------------- 1 | :107E0000112484B714BE81FFF0D085E080938100F7 2 | :107E100082E08093C00088E18093C10086E0809377 3 | :107E2000C20080E18093C4008EE0C9D0259A86E02C 4 | :107E300020E33CEF91E0309385002093840096BBD3 5 | :107E4000B09BFECF1D9AA8958150A9F7CC24DD24C4 6 | :107E500088248394B5E0AB2EA1E19A2EF3E0BF2EE7 7 | :107E6000A2D0813461F49FD0082FAFD0023811F036 8 | :107E7000013811F484E001C083E08DD089C08234E0 9 | :107E800011F484E103C0853419F485E0A6D080C0E4 10 | :107E9000853579F488D0E82EFF2485D0082F10E0AE 11 | :107EA000102F00270E291F29000F111F8ED06801E7 12 | :107EB0006FC0863521F484E090D080E0DECF843638 13 | :107EC00009F040C070D06FD0082F6DD080E0C81688 14 | :107ED00080E7D80618F4F601B7BEE895C0E0D1E017 15 | :107EE00062D089930C17E1F7F0E0CF16F0E7DF06D8 16 | :107EF00018F0F601B7BEE89568D007B600FCFDCFD4 17 | :107F0000A601A0E0B1E02C9130E011968C91119780 18 | :107F100090E0982F8827822B932B1296FA010C0160 19 | :107F200087BEE89511244E5F5F4FF1E0A038BF0790 20 | :107F300051F7F601A7BEE89507B600FCFDCF97BE46 21 | :107F4000E89526C08437B1F42ED02DD0F82E2BD052 22 | :107F50003CD0F601EF2C8F010F5F1F4F84911BD097 23 | :107F6000EA94F801C1F70894C11CD11CFA94CF0C13 24 | :107F7000D11C0EC0853739F428D08EE10CD085E9AC 25 | :107F80000AD08FE07ACF813511F488E018D01DD067 26 | :107F900080E101D065CF982F8091C00085FFFCCF94 27 | :107FA0009093C60008958091C00087FFFCCF809118 28 | :107FB000C00084FD01C0A8958091C6000895E0E648 29 | :107FC000F0E098E1908380830895EDDF803219F02E 30 | :107FD00088E0F5DFFFCF84E1DECF1F93182FE3DFCA 31 | :107FE0001150E9F7F2DF1F91089580E0E8DFEE27F6 32 | :047FF000FF270994CA 33 | :027FFE00040479 34 | :0400000300007E007B 35 | :00000001FF 36 | -------------------------------------------------------------------------------- /DCDarkNet/FirmWare/build/optiboot_atmega328.hex: -------------------------------------------------------------------------------- 1 | :107E0000112484B714BE81FFF0D085E080938100F7 2 | :107E100082E08093C00088E18093C10086E0809377 3 | :107E2000C20080E18093C4008EE0C9D0259A86E02C 4 | :107E300020E33CEF91E0309385002093840096BBD3 5 | :107E4000B09BFECF1D9AA8958150A9F7CC24DD24C4 6 | :107E500088248394B5E0AB2EA1E19A2EF3E0BF2EE7 7 | :107E6000A2D0813461F49FD0082FAFD0023811F036 8 | :107E7000013811F484E001C083E08DD089C08234E0 9 | :107E800011F484E103C0853419F485E0A6D080C0E4 10 | :107E9000853579F488D0E82EFF2485D0082F10E0AE 11 | :107EA000102F00270E291F29000F111F8ED06801E7 12 | :107EB0006FC0863521F484E090D080E0DECF843638 13 | :107EC00009F040C070D06FD0082F6DD080E0C81688 14 | :107ED00080E7D80618F4F601B7BEE895C0E0D1E017 15 | :107EE00062D089930C17E1F7F0E0CF16F0E7DF06D8 16 | :107EF00018F0F601B7BEE89568D007B600FCFDCFD4 17 | :107F0000A601A0E0B1E02C9130E011968C91119780 18 | :107F100090E0982F8827822B932B1296FA010C0160 19 | :107F200087BEE89511244E5F5F4FF1E0A038BF0790 20 | :107F300051F7F601A7BEE89507B600FCFDCF97BE46 21 | :107F4000E89526C08437B1F42ED02DD0F82E2BD052 22 | :107F50003CD0F601EF2C8F010F5F1F4F84911BD097 23 | :107F6000EA94F801C1F70894C11CD11CFA94CF0C13 24 | :107F7000D11C0EC0853739F428D08EE10CD085E9AC 25 | :107F80000AD08FE07ACF813511F488E018D01DD067 26 | :107F900080E101D065CF982F8091C00085FFFCCF94 27 | :107FA0009093C60008958091C00087FFFCCF809118 28 | :107FB000C00084FD01C0A8958091C6000895E0E648 29 | :107FC000F0E098E1908380830895EDDF803219F02E 30 | :107FD00088E0F5DFFFCF84E1DECF1F93182FE3DFCA 31 | :107FE0001150E9F7F2DF1F91089580E0E8DFEE27F6 32 | :047FF000FF270994CA 33 | :027FFE00040479 34 | :0400000300007E007B 35 | :00000001FF 36 | -------------------------------------------------------------------------------- /libraries/UsbKeyboard/examples/UsbKeyboardDemo1/UsbKeyboardDemo1.pde: -------------------------------------------------------------------------------- 1 | #include "UsbKeyboard.h" 2 | 3 | #define BUTTON_PIN 12 4 | 5 | // If the timer isr is corrected 6 | // to not take so long change this to 0. 7 | #define BYPASS_TIMER_ISR 1 8 | 9 | void setup() { 10 | pinMode(BUTTON_PIN, INPUT); 11 | digitalWrite(BUTTON_PIN, HIGH); 12 | 13 | #if BYPASS_TIMER_ISR 14 | // disable timer 0 overflow interrupt (used for millis) 15 | TIMSK0&=!(1< in 2001, and placed 11 | * in the public domain. There's absolutely no warranty. 12 | * 13 | * This differs from Colin Plumb's older public domain implementation in 14 | * that no 32-bit integer data type is required, there's no compile-time 15 | * endianness configuration, and the function prototypes match OpenSSL's. 16 | * The primary goals are portability and ease of use. 17 | * 18 | * This implementation is meant to be fast, but not as fast as possible. 19 | * Some known optimizations are not included to reduce source code size 20 | * and avoid compile-time configuration. 21 | */ 22 | 23 | /* 24 | * Updated by Scott MacVicar for arduino 25 | * 26 | */ 27 | 28 | #include 29 | 30 | typedef unsigned long MD5_u32plus; 31 | 32 | typedef struct { 33 | MD5_u32plus lo, hi; 34 | MD5_u32plus a, b, c, d; 35 | unsigned char buffer[64]; 36 | MD5_u32plus block[16]; 37 | } MD5_CTX; 38 | 39 | class MD5 40 | { 41 | public: 42 | MD5(); 43 | static unsigned char* make_hash(char *arg); 44 | static char* make_digest(const unsigned char *digest, int len); 45 | static const void *body(void *ctxBuf, const void *data, size_t size); 46 | static void MD5Init(void *ctxBuf); 47 | static void MD5Final(unsigned char *result, void *ctxBuf); 48 | static void MD5Update(void *ctxBuf, const void *data, size_t size); 49 | }; 50 | 51 | #endif -------------------------------------------------------------------------------- /DCDarkNet/FirmWare/UsbKeyboardTest/UsbKeyboardTest.ino: -------------------------------------------------------------------------------- 1 | #include "UsbKeyboard.h" 2 | //UsbKeyboardDevice UsbKeyboard = UsbKeyboardDevice(); 3 | 4 | #define BUTTON_PIN 12 5 | #define LED_PIN 3 6 | 7 | void setup() { 8 | pinMode(BUTTON_PIN, INPUT); 9 | digitalWrite(BUTTON_PIN, HIGH); 10 | pinMode(LED_PIN, OUTPUT); 11 | usbDeviceDisconnect(); 12 | 13 | } 14 | 15 | void usbDelay(long ms, UsbKeyboardDevice *ukd) { 16 | for (; ms > 25; ms-=25) { 17 | //digitalWrite(LED_PIN, (ms/250)&0x01); 18 | analogWrite(LED_PIN, ms%0xFF); 19 | delay(25); 20 | ukd->update(); 21 | } 22 | delay(ms); 23 | } 24 | 25 | void loop() { 26 | if (digitalRead(BUTTON_PIN) == LOW) { 27 | digitalWrite(LED_PIN, HIGH); 28 | UsbKeyboardDevice UsbKeyboard = UsbKeyboardDevice(); 29 | 30 | // Give the USB a few seconds to settle in and be detected by the OS. 31 | usbDelay(5000, &UsbKeyboard); 32 | if (usbInterruptIsReady()) { 33 | UsbKeyboard.sendKeyStroke(KEY_H); 34 | UsbKeyboard.sendKeyStroke(KEY_E); 35 | UsbKeyboard.sendKeyStroke(KEY_L); 36 | UsbKeyboard.sendKeyStroke(KEY_L); 37 | UsbKeyboard.sendKeyStroke(KEY_O); 38 | 39 | UsbKeyboard.sendKeyStroke(KEY_SPACE); 40 | 41 | UsbKeyboard.sendKeyStroke(KEY_W); 42 | UsbKeyboard.sendKeyStroke(KEY_O); 43 | UsbKeyboard.sendKeyStroke(KEY_R); 44 | UsbKeyboard.sendKeyStroke(KEY_L); 45 | UsbKeyboard.sendKeyStroke(KEY_D); 46 | 47 | UsbKeyboard.sendKeyStroke(KEY_ENTER); 48 | // Give the OS a second to accept the last of the characters and really be done. 49 | usbDelay(1000, &UsbKeyboard); 50 | } 51 | 52 | usbDeviceDisconnect(); 53 | digitalWrite(LED_PIN, LOW); 54 | } 55 | } 56 | 57 | void usbEventResetReady(void) { 58 | 59 | } 60 | -------------------------------------------------------------------------------- /libraries/UsbKeyboard/vusb-20121206/libs-host/hidsdi.h: -------------------------------------------------------------------------------- 1 | /* Name: hidsdi.h 2 | * Author: Christian Starkjohann 3 | * Creation Date: 2006-02-02 4 | * Tabsize: 4 5 | * Copyright: (c) 2006-2008 by OBJECTIVE DEVELOPMENT Software GmbH 6 | * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) 7 | */ 8 | 9 | /* 10 | General Description 11 | This file is a replacement for hidsdi.h from the Windows DDK. It defines some 12 | of the types and function prototypes of this header for our project. If you 13 | have the Windows DDK version of this file or a version shipped with MinGW, use 14 | that instead. 15 | */ 16 | 17 | #ifndef _HIDSDI_H 18 | #define _HIDSDI_H 19 | 20 | #include 21 | 22 | #include 23 | #include 24 | 25 | typedef struct{ 26 | ULONG Size; 27 | USHORT VendorID; 28 | USHORT ProductID; 29 | USHORT VersionNumber; 30 | }HIDD_ATTRIBUTES; 31 | 32 | void __stdcall HidD_GetHidGuid(OUT LPGUID hidGuid); 33 | 34 | BOOLEAN __stdcall HidD_GetAttributes(IN HANDLE device, OUT HIDD_ATTRIBUTES *attributes); 35 | 36 | BOOLEAN __stdcall HidD_GetManufacturerString(IN HANDLE device, OUT void *buffer, IN ULONG bufferLen); 37 | BOOLEAN __stdcall HidD_GetProductString(IN HANDLE device, OUT void *buffer, IN ULONG bufferLen); 38 | BOOLEAN __stdcall HidD_GetSerialNumberString(IN HANDLE device, OUT void *buffer, IN ULONG bufferLen); 39 | 40 | BOOLEAN __stdcall HidD_GetFeature(IN HANDLE device, OUT void *reportBuffer, IN ULONG bufferLen); 41 | BOOLEAN __stdcall HidD_SetFeature(IN HANDLE device, IN void *reportBuffer, IN ULONG bufferLen); 42 | 43 | BOOLEAN __stdcall HidD_GetNumInputBuffers(IN HANDLE device, OUT ULONG *numBuffers); 44 | BOOLEAN __stdcall HidD_SetNumInputBuffers(IN HANDLE device, OUT ULONG numBuffers); 45 | 46 | #include 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /libraries/UsbKeyboard/vusb-20121206/examples/hid-data/commandline/hidsdi.h: -------------------------------------------------------------------------------- 1 | /* Name: hidsdi.h 2 | * Author: Christian Starkjohann 3 | * Creation Date: 2006-02-02 4 | * Tabsize: 4 5 | * Copyright: (c) 2006-2008 by OBJECTIVE DEVELOPMENT Software GmbH 6 | * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) 7 | */ 8 | 9 | /* 10 | General Description 11 | This file is a replacement for hidsdi.h from the Windows DDK. It defines some 12 | of the types and function prototypes of this header for our project. If you 13 | have the Windows DDK version of this file or a version shipped with MinGW, use 14 | that instead. 15 | */ 16 | 17 | #ifndef _HIDSDI_H 18 | #define _HIDSDI_H 19 | 20 | #include 21 | 22 | #include 23 | #include 24 | 25 | typedef struct{ 26 | ULONG Size; 27 | USHORT VendorID; 28 | USHORT ProductID; 29 | USHORT VersionNumber; 30 | }HIDD_ATTRIBUTES; 31 | 32 | void __stdcall HidD_GetHidGuid(OUT LPGUID hidGuid); 33 | 34 | BOOLEAN __stdcall HidD_GetAttributes(IN HANDLE device, OUT HIDD_ATTRIBUTES *attributes); 35 | 36 | BOOLEAN __stdcall HidD_GetManufacturerString(IN HANDLE device, OUT void *buffer, IN ULONG bufferLen); 37 | BOOLEAN __stdcall HidD_GetProductString(IN HANDLE device, OUT void *buffer, IN ULONG bufferLen); 38 | BOOLEAN __stdcall HidD_GetSerialNumberString(IN HANDLE device, OUT void *buffer, IN ULONG bufferLen); 39 | 40 | BOOLEAN __stdcall HidD_GetFeature(IN HANDLE device, OUT void *reportBuffer, IN ULONG bufferLen); 41 | BOOLEAN __stdcall HidD_SetFeature(IN HANDLE device, IN void *reportBuffer, IN ULONG bufferLen); 42 | 43 | BOOLEAN __stdcall HidD_GetNumInputBuffers(IN HANDLE device, OUT ULONG *numBuffers); 44 | BOOLEAN __stdcall HidD_SetNumInputBuffers(IN HANDLE device, OUT ULONG numBuffers); 45 | 46 | #include 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /libraries/UsbKeyboard/vusb-20121206/Makefile: -------------------------------------------------------------------------------- 1 | # Name: Makefile 2 | # Project: v-usb 3 | # Author: Christian Starkjohann 4 | # Creation Date: 2012-12-05 5 | # Tabsize: 4 6 | # Copyright: (c) 2012 by OBJECTIVE DEVELOPMENT Software GmbH 7 | # License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) 8 | 9 | # This is the main Makefile. The two primary targets are "all", to build 10 | # everything which can be built (except tests), and "clean" to remove all 11 | # dependent files. In a repository clone, derived source files are generated 12 | # and deleted as well. 13 | # 14 | # We distinguish between repository clones and source packages by the existence 15 | # of make-files.sh scripts in various subdirectories. 16 | 17 | 18 | all: 19 | if [ ! -f examples/hid-mouse/firmware/Makefile ]; then \ 20 | $(MAKE) files; \ 21 | fi 22 | if [ -n "$(uname -s | grep -i mingw)" ]; then \ 23 | $(MAKE) windows; \ 24 | else \ 25 | $(MAKE) unix; \ 26 | fi 27 | 28 | clean: 29 | $(MAKE) unixclean 30 | if cross-make.sh --help >/dev/null 2>&1; then \ 31 | $(MAKE) windowsclean; \ 32 | fi 33 | $(MAKE) filesremove 34 | 35 | 36 | unix unixclean: 37 | target=$$(echo $@ | sed -e 's/unix//g'); \ 38 | find . -mindepth 3 -name Makefile -print | while read i; do \ 39 | dir=$$(dirname $$i); \ 40 | dirname=$$(basename $$dir); \ 41 | pushd $$dir >/dev/null; \ 42 | if [ "$$dirname" = firmware -a -z "$$target" ]; then \ 43 | if ! $(MAKE) hex; then break; fi; \ 44 | else \ 45 | if ! $(MAKE) $$target; then break; fi;\ 46 | fi; \ 47 | popd >/dev/null; \ 48 | done 49 | 50 | 51 | windows windowsclean: 52 | target=$$(echo $@ | sed -e 's/windows//g'); \ 53 | find . -mindepth 3 -name Makefile.windows -execdir cross-make.sh $$target \; ; \ 54 | if [ -z "$$target" ]; then target=hex; fi; \ 55 | find . -mindepth 2 -name firmware -exec sh -c "cd '{}'; $(MAKE) $$target" \; 56 | 57 | files filesremove: 58 | target=$$(echo $@ | sed -e 's/files//g'); \ 59 | find . -mindepth 2 -name make-files.sh -execdir ./make-files.sh $$target \; 60 | 61 | -------------------------------------------------------------------------------- /software/fwupdate/run.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | $AVR_DUDE = "/home/mark/Arduino/arduino-1.5.7/hardware/tools/avr/bin/avrdude"; 4 | $AVR_DUDE_CONF = "/home/mark/Arduino/arduino-1.5.7/hardware/tools/avr/etc/avrdude.conf"; 5 | 6 | open DB, "DB" or die "Couldn't open DB file: $!"; 7 | while() { 8 | next if m/Seed:/; 9 | chomp; 10 | ($guid, $k0, $k1, $k2, $k3) = split " ", $_; 11 | 12 | #print "Loading GUID: $guid\n"; 13 | push @guids, $guid; 14 | } 15 | close DB; 16 | 17 | $numGuids = scalar(@guids); 18 | print "Ready to program!\n"; 19 | for ($ndx=0; $ndx<$numGuids; $ndx++) { 20 | print "\n\nuit\n"; 21 | print "<\\d+> Jump to #\$1\n"; 22 | print "ext (GUID: ", $guids[$ndx+1], ")\n" unless $ndx == $numGuids-1; 23 | print "

rev (GUID: ", $guids[$ndx-1], ")\n" unless $ndx == 0; 24 | print "Current GUID: #$ndx $guids[$ndx]\n"; 25 | print " to program with current\n"; 26 | 27 | $foo = ; 28 | chomp $foo; 29 | exit if $foo =~ m/q/i; 30 | if ($foo =~ m/(\d+)/) { $ndx = $1-1; next; } 31 | if ($ndx < $numGuids && $foo =~ m/n/i) { next; } 32 | if ($ndx > 0 && $foo =~ m/p/i) { $ndx-=2; next; } 33 | unless ($foo =~ m/^$/) { $ndx--; next; } 34 | 35 | 36 | 37 | # Burn fuses and boot loader 38 | print "Burning fuses and boot loader...\n"; 39 | #system("$AVR_DUDE -C$AVR_DUDE_CONF -patmega328p -cusbtiny -e -Ulock:w:0x3F:m -Uefuse:w:0x05:m -Uhfuse:w:0xDE:m -Ulfuse:w:0xFF:m"); 40 | #system("$AVR_DUDE -C$AVR_DUDE_CONF -patmega328p -cusbtiny -Uflash:w:./optiboot_atmega328.hex:i -Ulock:w:0x0F:m"); 41 | # system("./burn-bootloader.sh"); 42 | 43 | # The board is now an Arduino. 44 | 45 | # Burn GUID and KEY into EEPROM 46 | print "Burning EEPROM for $guids[$ndx]...\n"; 47 | #system("./make-eeprom.pl $guids[$ndx] > eeprom.hex"); 48 | #system("$AVR_DUDE -C$AVR_DUDE_CONF -patmega328p -cusbtiny -Ueeprom:w:eeprom.hex:i"); 49 | # system("./burn-eeprom.sh $guids[$ndx]"); 50 | 51 | # Upload the code through the FTDI cable 52 | print "Burning FLASH...\n"; 53 | #system("$AVR_DUDE -C$AVR_DUDE_CONF -patmega328p -carduino -P/dev/ttyUSB0 -b115200 -D -Uflash:w:./IR_Quest_2014.cpp.hex:i"); 54 | # system("./burn-flash.sh"); 55 | 56 | } 57 | -------------------------------------------------------------------------------- /DCDarkNet/FirmWare/build/run.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | $AVR_DUDE = "/home/mark/Arduino/arduino-1.5.7/hardware/tools/avr/bin/avrdude"; 4 | $AVR_DUDE_CONF = "/home/mark/Arduino/arduino-1.5.7/hardware/tools/avr/etc/avrdude.conf"; 5 | 6 | open DB, "DB" or die "Couldn't open DB file: $!"; 7 | while() { 8 | next if m/Seed:/; 9 | chomp; 10 | ($guid, $k0, $k1, $k2, $k3) = split " ", $_; 11 | 12 | #print "Loading GUID: $guid\n"; 13 | push @guids, $guid; 14 | } 15 | close DB; 16 | 17 | $numGuids = scalar(@guids); 18 | print "Ready to program!\n"; 19 | for ($ndx=0; $ndx<$numGuids; $ndx++) { 20 | print "\n\nuit\n"; 21 | print "<\\d+> Jump to #\$1\n"; 22 | print "ext (GUID: ", $guids[$ndx+1], ")\n" unless $ndx == $numGuids-1; 23 | print "

rev (GUID: ", $guids[$ndx-1], ")\n" unless $ndx == 0; 24 | print "Current GUID: #$ndx $guids[$ndx]\n"; 25 | print " to program with current\n"; 26 | 27 | $foo = ; 28 | chomp $foo; 29 | exit if $foo =~ m/q/i; 30 | if ($foo =~ m/(\d+)/) { $ndx = $1-1; next; } 31 | if ($ndx < $numGuids && $foo =~ m/n/i) { next; } 32 | if ($ndx > 0 && $foo =~ m/p/i) { $ndx-=2; next; } 33 | unless ($foo =~ m/^$/) { $ndx--; next; } 34 | 35 | 36 | 37 | # Burn fuses and boot loader 38 | print "Burning fuses and boot loader...\n"; 39 | #system("$AVR_DUDE -C$AVR_DUDE_CONF -patmega328p -cusbtiny -e -Ulock:w:0x3F:m -Uefuse:w:0x05:m -Uhfuse:w:0xDE:m -Ulfuse:w:0xFF:m"); 40 | #system("$AVR_DUDE -C$AVR_DUDE_CONF -patmega328p -cusbtiny -Uflash:w:./optiboot_atmega328.hex:i -Ulock:w:0x0F:m"); 41 | system("./burn-bootloader.sh"); 42 | 43 | # The board is now an Arduino. 44 | 45 | # Burn GUID and KEY into EEPROM 46 | print "Burning EEPROM for $guids[$ndx]...\n"; 47 | #system("./make-eeprom.pl $guids[$ndx] > eeprom.hex"); 48 | #system("$AVR_DUDE -C$AVR_DUDE_CONF -patmega328p -cusbtiny -Ueeprom:w:eeprom.hex:i"); 49 | system("./burn-eeprom.sh $guids[$ndx]"); 50 | 51 | # Upload the code through the FTDI cable 52 | print "Burning FLASH...\n"; 53 | #system("$AVR_DUDE -C$AVR_DUDE_CONF -patmega328p -carduino -P/dev/ttyUSB0 -b115200 -D -Uflash:w:./IR_Quest_2014.cpp.hex:i"); 54 | system("./burn-flash.sh"); 55 | 56 | } 57 | -------------------------------------------------------------------------------- /libraries/UsbKeyboard/vusb-20121206/examples/hid-mouse/Readme.txt: -------------------------------------------------------------------------------- 1 | This is the Readme file for hid-mouse, an example of a USB mouse device. In 2 | order to have as little dependencies on hardware and architecture as 3 | possible, mouse movements are computed internally so that the mouse pointer 4 | moves in a circle. 5 | 6 | 7 | WHAT IS DEMONSTRATED? 8 | ===================== 9 | This example demonstrates how HID class devices are implemented. The example 10 | is kept as simple as possible, except the report descriptor which is taken 11 | from a real-world mouse. 12 | 13 | It does NOT include a host side driver because all modern operating systems 14 | include one. It does NOT implement USBRQ_HID_SET_REPORT and report-IDs. See 15 | the "hid-data" example for this topic. It does NOT implement any special 16 | features such as suspend mode etc. 17 | 18 | 19 | PREREQUISITES 20 | ============= 21 | Target hardware: You need an AVR based circuit based on one of the examples 22 | (see the "circuits" directory at the top level of this package), e.g. the 23 | metaboard (http://www.obdev.at/goto.php?t=metaboard). 24 | 25 | AVR development environment: You need the gcc tool chain for the AVR, see 26 | the Prerequisites section in the top level Readme file for how to obtain it. 27 | 28 | 29 | BUILDING THE FIRMWARE 30 | ===================== 31 | Change to the "firmware" directory and modify Makefile according to your 32 | architecture (CPU clock, target device, fuse values) and ISP programmer. Then 33 | edit usbconfig.h according to your pin assignments for D+ and D-. The default 34 | settings are for the metaboard hardware. 35 | 36 | Type "make hex" to build main.hex, then "make flash" to upload the firmware 37 | to the device. Don't forget to run "make fuse" once to program the fuses. If 38 | you use a prototyping board with boot loader, follow the instructions of the 39 | boot loader instead. 40 | 41 | Please note that the first "make hex" copies the driver from the top level 42 | into the firmware directory. If you use a different build system than our 43 | Makefile, you must copy the driver by hand. 44 | 45 | 46 | ---------------------------------------------------------------------------- 47 | (c) 2008 by OBJECTIVE DEVELOPMENT Software GmbH. 48 | http://www.obdev.at/ 49 | -------------------------------------------------------------------------------- /software/fwupdate/autoupdate.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # 3 | # Test program to update DCDarkNet badges using avrdude in FTDI(arduino) mode 4 | # 5 | # 6 | import Adafruit_BBIO.GPIO as GPIO 7 | import Adafruit_BBIO.UART as UART 8 | import SFLCDController 9 | import AVRProg 10 | import os.path 11 | import time 12 | import sys 13 | 14 | DEBUG = False 15 | 16 | def readFlash(): 17 | print('Reading flash') 18 | flashFile = AVRProg.readFlash(DEBUG) 19 | if flashFile: 20 | print('Flash dumped to: ' + flashFile) 21 | else: 22 | print('Error reading flash') 23 | 24 | def flashFirmware(filename): 25 | lcd.clear(); 26 | lcd.write('Flashing FW') 27 | 28 | rval = AVRProg.runAvrdudeCommand('avrdude -v -c ' + AVRProg.PROGRAMMER + ' -p m328p -P ' + AVRProg.PROGRAMMERS[AVRProg.PROGRAMMER] + ' -Uflash:w:' + filename + ':i', DEBUG) 29 | if rval == 1: 30 | print('Error flashing firmware') 31 | lcd.clear() 32 | lcd.write("ERROR: could not flash firmware") 33 | return rval 34 | else: 35 | print('Flashed firmware successfully!') 36 | lcd.clear() 37 | lcd.write("Success!!!") 38 | 39 | return 0 40 | 41 | def waitForButton(pin): 42 | # 43 | # Debounce! 44 | # 45 | pushed = False 46 | while not pushed: 47 | GPIO.wait_for_edge(pin, GPIO.FALLING) 48 | time.sleep(0.033) 49 | if (GPIO.input(pin) == 0): 50 | pushed = True 51 | 52 | # 53 | # Start Here! 54 | # 55 | if len(sys.argv) < 2: 56 | print('Usage: ' + sys.argv[0] + ' /path/to/firmware.bin') 57 | sys.exit(1) 58 | 59 | GPIO.setup('P9_12', GPIO.IN) 60 | UART.setup("UART4") 61 | 62 | # 63 | # Setup LCD 64 | # 65 | lcd = SFLCDController.Controller() 66 | lcd.connect('/dev/ttyO4', 9600) 67 | lcd.clear() 68 | 69 | AVRProg.lcd = lcd 70 | AVRProg.PROGRAMMER = 'arduino' 71 | 72 | if os.path.exists('/dev/ttyUSB0') is False: 73 | lcd.clear() 74 | lcd.write('DCDarkNet ERR: no /dev/ttyUSB0') 75 | 76 | while os.path.exists('/dev/ttyUSB0') is False: 77 | time.sleep(5) 78 | 79 | # TODO - add updater/error count 80 | while True: 81 | lcd.clear() 82 | lcd.write('DCDarkNet - Push to update FW') 83 | waitForButton('P9_12') 84 | flashFirmware(sys.argv[1]) 85 | time.sleep(5) 86 | # TODO - add animation here 87 | 88 | lcd.disconnect() 89 | -------------------------------------------------------------------------------- /libraries/UsbKeyboard/vusb-20121206/libs-device/osccal.c: -------------------------------------------------------------------------------- 1 | /* Name: osccal.c 2 | * Author: Christian Starkjohann 3 | * Creation Date: 2008-04-10 4 | * Tabsize: 4 5 | * Copyright: (c) 2008 by OBJECTIVE DEVELOPMENT Software GmbH 6 | * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) 7 | */ 8 | 9 | #include 10 | 11 | #ifndef uchar 12 | #define uchar unsigned char 13 | #endif 14 | 15 | /* ------------------------------------------------------------------------- */ 16 | /* ------------------------ Oscillator Calibration ------------------------- */ 17 | /* ------------------------------------------------------------------------- */ 18 | 19 | /* Calibrate the RC oscillator. Our timing reference is the Start Of Frame 20 | * signal (a single SE0 bit) repeating every millisecond immediately after 21 | * a USB RESET. We first do a binary search for the OSCCAL value and then 22 | * optimize this value with a neighboorhod search. 23 | */ 24 | void calibrateOscillator(void) 25 | { 26 | uchar step = 128; 27 | uchar trialValue = 0, optimumValue; 28 | int x, optimumDev, targetValue = (unsigned)(1499 * (double)F_CPU / 10.5e6 + 0.5); 29 | 30 | /* do a binary search: */ 31 | do{ 32 | OSCCAL = trialValue + step; 33 | x = usbMeasureFrameLength(); /* proportional to current real frequency */ 34 | if(x < targetValue) /* frequency still too low */ 35 | trialValue += step; 36 | step >>= 1; 37 | }while(step > 0); 38 | /* We have a precision of +/- 1 for optimum OSCCAL here */ 39 | /* now do a neighborhood search for optimum value */ 40 | optimumValue = trialValue; 41 | optimumDev = x; /* this is certainly far away from optimum */ 42 | for(OSCCAL = trialValue - 1; OSCCAL <= trialValue + 1; OSCCAL++){ 43 | x = usbMeasureFrameLength() - targetValue; 44 | if(x < 0) 45 | x = -x; 46 | if(x < optimumDev){ 47 | optimumDev = x; 48 | optimumValue = OSCCAL; 49 | } 50 | } 51 | OSCCAL = optimumValue; 52 | } 53 | /* 54 | Note: This calibration algorithm may try OSCCAL values of up to 192 even if 55 | the optimum value is far below 192. It may therefore exceed the allowed clock 56 | frequency of the CPU in low voltage designs! 57 | You may replace this search algorithm with any other algorithm you like if 58 | you have additional constraints such as a maximum CPU clock. 59 | For version 5.x RC oscillators (those with a split range of 2x128 steps, e.g. 60 | ATTiny25, ATTiny45, ATTiny85), it may be useful to search for the optimum in 61 | both regions. 62 | */ 63 | -------------------------------------------------------------------------------- /libraries/UsbKeyboard/vusb-20121206/examples/custom-class/Readme.txt: -------------------------------------------------------------------------------- 1 | This is the Readme file for the custom-class example. In this example, we 2 | show how an LED can be controlled via USB. 3 | 4 | 5 | WHAT IS DEMONSTRATED? 6 | ===================== 7 | This example shows how small amounts of data (several bytes) can be 8 | transferred between the device and the host. In addition to a very basic 9 | USB device, it demonstrates how to build a host side driver application 10 | using libusb or libusb-win32. It does NOT show how usbFunctionWrite() and 11 | usbFunctionRead() are used. See the hid-data example if you want to learn 12 | about these functions. 13 | 14 | 15 | PREREQUISITES 16 | ============= 17 | Target hardware: You need an AVR based circuit based on one of the examples 18 | (see the "circuits" directory at the top level of this package), e.g. the 19 | metaboard (http://www.obdev.at/goto.php?t=metaboard). 20 | 21 | AVR development environment: You need the gcc tool chain for the AVR, see 22 | the Prerequisites section in the top level Readme file for how to obtain it. 23 | 24 | Host development environment: A C compiler and libusb. See the top level 25 | Readme file, section Prerequisites for more information. 26 | 27 | 28 | BUILDING THE FIRMWARE 29 | ===================== 30 | Change to the "firmware" directory and modify Makefile according to your 31 | architecture (CPU clock, target device, fuse values) and ISP programmer. Then 32 | edit usbconfig.h according to your pin assignments for D+ and D-. The default 33 | settings are for the metaboard hardware. You should have wired an LED with a 34 | current limiting resistor of ca. 270 Ohm to a free I/O pin. Change the 35 | defines in main.c to match the port and bit number. 36 | 37 | Type "make hex" to build main.hex, then "make flash" to upload the firmware 38 | to the device. Don't forget to run "make fuse" once to program the fuses. If 39 | you use a prototyping board with boot loader, follow the instructions of the 40 | boot loader instead. 41 | 42 | Please note that the first "make hex" copies the driver from the top level 43 | into the firmware directory. If you use a different build system than our 44 | Makefile, you must copy the driver by hand. 45 | 46 | 47 | BUILDING THE HOST SOFTWARE 48 | ========================== 49 | Since the host software is based on libusb or libusb-win32, make sure that 50 | this library is installed. On Unix, ensure that libusb-config is in your 51 | search PATH. On Windows, edit Makefile.windows and set the library path 52 | appropriately. Then type "make" on Unix or "make -f Makefile.windows" on 53 | Windows to build the command line tool. 54 | 55 | 56 | USING THE COMMAND LINE TOOL 57 | =========================== 58 | The command line tool has three valid arguments: "status" to query the 59 | current LED status, "on" to turn on the LED and "off" to turn it off. 60 | 61 | 62 | ---------------------------------------------------------------------------- 63 | (c) 2008 by OBJECTIVE DEVELOPMENT Software GmbH. 64 | http://www.obdev.at/ 65 | -------------------------------------------------------------------------------- /libraries/UsbKeyboard/vusb-20121206/libs-device/osccal.h: -------------------------------------------------------------------------------- 1 | /* Name: osccal.h 2 | * Author: Christian Starkjohann 3 | * Creation Date: 2008-04-10 4 | * Tabsize: 4 5 | * Copyright: (c) 2008 by OBJECTIVE DEVELOPMENT Software GmbH 6 | * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) 7 | */ 8 | 9 | /* 10 | General Description: 11 | This module contains a function which calibrates the AVR's internal RC 12 | oscillator so that the CPU runs at F_CPU (F_CPU is a macro which must be 13 | defined when the module is compiled, best passed in the compiler command 14 | line). The time reference is the USB frame clock of 1 kHz available 15 | immediately after a USB RESET condition. Timing is done by counting CPU 16 | cycles, so all interrupts must be disabled while the calibration runs. For 17 | low level timing measurements, usbMeasureFrameLength() is called. This 18 | function must be enabled in usbconfig.h by defining 19 | USB_CFG_HAVE_MEASURE_FRAME_LENGTH to 1. It is recommended to call 20 | calibrateOscillator() from the reset hook in usbconfig.h: 21 | 22 | #ifndef __ASSEMBLER__ 23 | #include // for sei() 24 | extern void calibrateOscillator(void); 25 | #endif 26 | #define USB_RESET_HOOK(resetStarts) if(!resetStarts){cli(); calibrateOscillator(); sei();} 27 | 28 | This routine is an alternative to the continuous synchronization described 29 | in osctune.h. 30 | 31 | Algorithm used: 32 | calibrateOscillator() first does a binary search in the OSCCAL register for 33 | the best matching oscillator frequency. Then it does a next neighbor search 34 | to find the value with the lowest clock rate deviation. It is guaranteed to 35 | find the best match among neighboring values, but for version 5 oscillators 36 | (which have a discontinuous relationship between OSCCAL and frequency) a 37 | better match might be available in another OSCCAL region. 38 | 39 | Limitations: 40 | This calibration algorithm may try OSCCAL values of up to 192 even if the 41 | optimum value is far below 192. It may therefore exceed the allowed clock 42 | frequency of the CPU in low voltage designs! 43 | Precision depends on the OSCCAL vs. frequency dependency of the oscillator. 44 | Typical precision for an ATMega168 (derived from the OSCCAL vs. F_RC diagram 45 | in the data sheet) should be in the range of 0.4%. Only the 12.8 MHz and 46 | 16.5 MHz versions of V-USB (with built-in receiver PLL) can tolerate this 47 | deviation! All other frequency modules require at least 0.2% precision. 48 | */ 49 | 50 | #ifndef __OSCCAL_H_INCLUDED__ 51 | #define __OSCCAL_H_INCLUDED__ 52 | 53 | void calibrateOscillator(void); 54 | /* This function calibrates the RC oscillator so that the CPU runs at F_CPU. 55 | * It MUST be called immediately after the end of a USB RESET condition! 56 | * Disable all interrupts during the call! 57 | * It is recommended that you store the resulting value in EEPROM so that a 58 | * good guess value is available after the next reset. 59 | */ 60 | 61 | 62 | #endif /* __OSCCAL_H_INCLUDED__ */ 63 | -------------------------------------------------------------------------------- /libraries/UsbKeyboard/vusb-20121206/examples/hid-data/Readme.txt: -------------------------------------------------------------------------------- 1 | This is the Readme file for the hid-data example. In this example, we show 2 | how blocks of data can be exchanged with the device using only functionality 3 | compliant to the HID class. Since class drivers for HID are included with 4 | Windows, you don't need to install drivers on Windows. 5 | 6 | 7 | WHAT IS DEMONSTRATED? 8 | ===================== 9 | This example demonstrates how the HID class can be misused to transfer fixed 10 | size blocks of data (up to the driver's transfer size limit) over HID feature 11 | reports. This technique is of great value on Windows because no driver DLLs 12 | are needed (the hid-custom-rq example still requires the libusb-win32 DLL, 13 | although it may be in the program's directory). The host side application 14 | requires no installation, it can even be started directly from a CD. This 15 | example also demonstrates how to transfer data using usbFunctionWrite() and 16 | usbFunctionRead(). 17 | 18 | 19 | PREREQUISITES 20 | ============= 21 | Target hardware: You need an AVR based circuit based on one of the examples 22 | (see the "circuits" directory at the top level of this package), e.g. the 23 | metaboard (http://www.obdev.at/goto.php?t=metaboard). 24 | 25 | AVR development environment: You need the gcc tool chain for the AVR, see 26 | the Prerequisites section in the top level Readme file for how to obtain it. 27 | 28 | Host development environment: A C compiler and libusb on Unix. On Windows 29 | you need the Driver Development Kit (DDK) Instead of libusb. MinGW ships 30 | with a free version of the DDK. 31 | 32 | 33 | BUILDING THE FIRMWARE 34 | ===================== 35 | Change to the "firmware" directory and modify Makefile according to your 36 | architecture (CPU clock, target device, fuse values) and ISP programmer. Then 37 | edit usbconfig.h according to your pin assignments for D+ and D-. The default 38 | settings are for the metaboard hardware. 39 | 40 | Type "make hex" to build main.hex, then "make flash" to upload the firmware 41 | to the device. Don't forget to run "make fuse" once to program the fuses. If 42 | you use a prototyping board with boot loader, follow the instructions of the 43 | boot loader instead. 44 | 45 | Please note that the first "make hex" copies the driver from the top level 46 | into the firmware directory. If you use a different build system than our 47 | Makefile, you must copy the driver by hand. 48 | 49 | 50 | BUILDING THE HOST SOFTWARE 51 | ========================== 52 | Make sure that you have libusb (on Unix) or the DDK (on Windows) installed. 53 | We recommend MinGW on Windows since it includes a free version of the DDK. 54 | Then change to directory "commandline" and run "make" on Unix or 55 | "make -f Makefile.windows" on Windows. 56 | 57 | 58 | USING THE COMMAND LINE TOOL 59 | =========================== 60 | The device implements a data store of 128 bytes in EEPROM. You can send a 61 | block of 128 bytes to the device or read the block using the command line 62 | tool. 63 | 64 | To send a block to the device, use e.g. 65 | 66 | hidtool write 0x01,0x02,0x03,0x04,... 67 | 68 | and to receive the block, use 69 | 70 | hidtool read 71 | 72 | 73 | ---------------------------------------------------------------------------- 74 | (c) 2008 by OBJECTIVE DEVELOPMENT Software GmbH. 75 | http://www.obdev.at/ 76 | -------------------------------------------------------------------------------- /software/fwupdate/SFLCDController.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # 3 | # Simple module to control the Sparkfun Serial LCD Modules 4 | # 5 | import serial 6 | 7 | # 8 | # LCD Constants 9 | # 10 | LCD_BACKLIGHT_OFF = 128 11 | LCD_BACKLIGHT_MAX = 157 12 | LCD_CHARS = 16 13 | LCD_LINES = 2 14 | LCD_LINESTART = [0, 64, 16, 80] # Cursor position starts for 16 character displays 15 | LCD_MAX_CHARS = LCD_CHARS * LCD_LINES 16 | 17 | # 18 | # Control characters/commands 19 | # 20 | LCD_BACLKIGHT_CMD = 0x7C 21 | LCD_CMD = 0xFE 22 | LCD_CMD_CLEAR = 0x01 23 | LCD_CMD_CURSORPOS = 0x80 24 | LCD_CMD_MOVRIGHT = 0x14 25 | LCD_CMD_MOVLEFT = 0x10 26 | LCD_CMD_SCRLRIGHT = 0x1C 27 | LCD_CMD_SCRLLEFT = 0x18 28 | 29 | class Controller(): 30 | def __init__(self): 31 | self.backlight = 1.0 32 | self.connected = False 33 | self.serialPort = None 34 | 35 | def connect(self, serialPort, baudRate): 36 | if self.serialPort is not None and self.serialPort.isOpen(): 37 | self.serialPort.close() 38 | 39 | self.serialPort = serial.Serial(port = serialPort, baudrate = baudRate) 40 | self.serialPort.close() 41 | self.serialPort.open() 42 | 43 | if self.serialPort.isOpen(): 44 | self.connected = True 45 | return True 46 | else: 47 | self.connected = False 48 | return False 49 | 50 | def write(self, string): 51 | if self.connected: 52 | self.serialPort.write(string) 53 | 54 | def disconnect(self): 55 | if self.connected: 56 | self.serialPort.close() 57 | 58 | def clear(self): 59 | self.write(chr(LCD_CMD) + chr(LCD_CMD_CLEAR)) 60 | self.write(chr(LCD_CMD) + chr(LCD_CMD_CLEAR)) 61 | 62 | def setBacklight(self, brightness): 63 | if brightness < 0: 64 | brightness = 0 65 | elif brightness > 1: 66 | brightness = 1 67 | 68 | self.backlight = brightness 69 | LCD_newBrightness = int(self.backlight * (BACKLIGHT_MAX - LCD_BACKLIGHT_OFF)) + LCD_BACKLIGHT_OFF 70 | self.write(chr(LCD_BACLKIGHT_CMD) + chr(newBrightness)) 71 | 72 | def setCursorPos(self, pos): 73 | if pos < 0: 74 | pos = 0 75 | elif pos > (LCD_MAX_CHARS - 1): 76 | pos = (LCD_MAX_CHARS - 1) 77 | 78 | line = int(pos)/int(LCD_CHARS) 79 | lineStart = LCD_LINESTART[line] 80 | linePos = pos - line * LCD_CHARS + lineStart 81 | 82 | self.write(chr(LCD_CMD) + chr(LCD_CMD_CURSORPOS + int(linePos))) 83 | 84 | def cursorMoveRight(self, times = 1): 85 | for dummy in range(times): 86 | self.write(chr(LCD_CMD) + chr(LCD_CMD_MOVRIGHT)) 87 | 88 | def cursorMoveLeft(self, times = 1): 89 | for dummy in range(times): 90 | self.write(chr(LCD_CMD) + chr(LCD_CMD_MOVLEFT)) 91 | 92 | def cursorScrollRight(self, times = 1): 93 | for dummy in range(times): 94 | self.write(chr(LCD_CMD) + chr(LCD_CMD_SCRLRIGHT)) 95 | 96 | def cursorScrollLeft(self, times = 1): 97 | for dummy in range(times): 98 | self.write(chr(LCD_CMD) + chr(LCD_CMD_SCRLLEFT)) 99 | 100 | if __name__ == '__main__': 101 | print('Standalone operation not supported...') 102 | -------------------------------------------------------------------------------- /libraries/UsbKeyboard/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 */ 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< 23 | #include 24 | #include /* for sei() */ 25 | #include /* for _delay_ms() */ 26 | 27 | #include /* required by usbdrv.h */ 28 | #include "usbdrv.h" 29 | #include "oddebug.h" /* This is also an example for using debug macros */ 30 | #include "requests.h" /* The custom request numbers we use */ 31 | 32 | /* ------------------------------------------------------------------------- */ 33 | /* ----------------------------- USB interface ----------------------------- */ 34 | /* ------------------------------------------------------------------------- */ 35 | 36 | usbMsgLen_t usbFunctionSetup(uchar data[8]) 37 | { 38 | usbRequest_t *rq = (void *)data; 39 | static uchar dataBuffer[4]; /* buffer must stay valid when usbFunctionSetup returns */ 40 | 41 | if(rq->bRequest == CUSTOM_RQ_ECHO){ /* echo -- used for reliability tests */ 42 | dataBuffer[0] = rq->wValue.bytes[0]; 43 | dataBuffer[1] = rq->wValue.bytes[1]; 44 | dataBuffer[2] = rq->wIndex.bytes[0]; 45 | dataBuffer[3] = rq->wIndex.bytes[1]; 46 | usbMsgPtr = dataBuffer; /* tell the driver which data to return */ 47 | return 4; 48 | }else if(rq->bRequest == CUSTOM_RQ_SET_STATUS){ 49 | if(rq->wValue.bytes[0] & 1){ /* set LED */ 50 | LED_PORT_OUTPUT |= _BV(LED_BIT); 51 | }else{ /* clear LED */ 52 | LED_PORT_OUTPUT &= ~_BV(LED_BIT); 53 | } 54 | }else if(rq->bRequest == CUSTOM_RQ_GET_STATUS){ 55 | dataBuffer[0] = ((LED_PORT_OUTPUT & _BV(LED_BIT)) != 0); 56 | usbMsgPtr = dataBuffer; /* tell the driver which data to return */ 57 | return 1; /* tell the driver to send 1 byte */ 58 | } 59 | return 0; /* default for not implemented requests: return no data back to host */ 60 | } 61 | 62 | /* ------------------------------------------------------------------------- */ 63 | 64 | int __attribute__((noreturn)) main(void) 65 | { 66 | uchar i; 67 | 68 | wdt_enable(WDTO_1S); 69 | /* Even if you don't use the watchdog, turn it off here. On newer devices, 70 | * the status of the watchdog (on/off, period) is PRESERVED OVER RESET! 71 | */ 72 | /* RESET status: all port bits are inputs without pull-up. 73 | * That's the way we need D+ and D-. Therefore we don't need any 74 | * additional hardware initialization. 75 | */ 76 | odDebugInit(); 77 | DBG1(0x00, 0, 0); /* debug output: main starts */ 78 | usbInit(); 79 | usbDeviceDisconnect(); /* enforce re-enumeration, do this while interrupts are disabled! */ 80 | i = 0; 81 | while(--i){ /* fake USB disconnect for > 250 ms */ 82 | wdt_reset(); 83 | _delay_ms(1); 84 | } 85 | usbDeviceConnect(); 86 | LED_PORT_DDR |= _BV(LED_BIT); /* make the LED bit an output */ 87 | sei(); 88 | DBG1(0x01, 0, 0); /* debug output: main loop starts */ 89 | for(;;){ /* main event loop */ 90 | DBG1(0x02, 0, 0); /* debug output: main loop iterates */ 91 | wdt_reset(); 92 | usbPoll(); 93 | } 94 | } 95 | 96 | /* ------------------------------------------------------------------------- */ 97 | -------------------------------------------------------------------------------- /libraries/UsbKeyboard/vusb-20121206/libs-host/opendevice.h: -------------------------------------------------------------------------------- 1 | /* Name: opendevice.h 2 | * Project: V-USB host-side library 3 | * Author: Christian Starkjohann 4 | * Creation Date: 2008-04-10 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 | */ 9 | 10 | /* 11 | General Description: 12 | This module offers additional functionality for host side drivers based on 13 | libusb or libusb-win32. It includes a function to find and open a device 14 | based on numeric IDs and textual description. It also includes a function to 15 | obtain textual descriptions from a device. 16 | 17 | To use this functionality, simply copy opendevice.c and opendevice.h into your 18 | project and add them to your Makefile. You may modify and redistribute these 19 | files according to the GNU General Public License (GPL) version 2 or 3. 20 | */ 21 | 22 | #ifndef __OPENDEVICE_H_INCLUDED__ 23 | #define __OPENDEVICE_H_INCLUDED__ 24 | 25 | #include /* this is libusb, see http://libusb.sourceforge.net/ */ 26 | #include 27 | 28 | int usbGetStringAscii(usb_dev_handle *dev, int index, char *buf, int buflen); 29 | /* This function gets a string descriptor from the device. 'index' is the 30 | * string descriptor index. The string is returned in ISO Latin 1 encoding in 31 | * 'buf' and it is terminated with a 0-character. The buffer size must be 32 | * passed in 'buflen' to prevent buffer overflows. A libusb device handle 33 | * must be given in 'dev'. 34 | * Returns: The length of the string (excluding the terminating 0) or 35 | * a negative number in case of an error. If there was an error, use 36 | * usb_strerror() to obtain the error message. 37 | */ 38 | 39 | int usbOpenDevice(usb_dev_handle **device, int vendorID, char *vendorNamePattern, int productID, char *productNamePattern, char *serialNamePattern, FILE *printMatchingDevicesFp, FILE *warningsFp); 40 | /* This function iterates over all devices on all USB busses and searches for 41 | * a device. Matching is done first by means of Vendor- and Product-ID (passed 42 | * in 'vendorID' and 'productID'. An ID of 0 matches any numeric ID (wildcard). 43 | * When a device matches by its IDs, matching by names is performed. Name 44 | * matching can be done on textual vendor name ('vendorNamePattern'), product 45 | * name ('productNamePattern') and serial number ('serialNamePattern'). A 46 | * device matches only if all non-null pattern match. If you don't care about 47 | * a string, pass NULL for the pattern. Patterns are Unix shell style pattern: 48 | * '*' stands for 0 or more characters, '?' for one single character, a list 49 | * of characters in square brackets for a single character from the list 50 | * (dashes are allowed to specify a range) and if the lis of characters begins 51 | * with a caret ('^'), it matches one character which is NOT in the list. 52 | * Other parameters to the function: If 'warningsFp' is not NULL, warning 53 | * messages are printed to this file descriptor with fprintf(). If 54 | * 'printMatchingDevicesFp' is not NULL, no device is opened but matching 55 | * devices are printed to the given file descriptor with fprintf(). 56 | * If a device is opened, the resulting USB handle is stored in '*device'. A 57 | * pointer to a "usb_dev_handle *" type variable must be passed here. 58 | * Returns: 0 on success, an error code (see defines below) on failure. 59 | */ 60 | 61 | /* usbOpenDevice() error codes: */ 62 | #define USBOPEN_SUCCESS 0 /* no error */ 63 | #define USBOPEN_ERR_ACCESS 1 /* not enough permissions to open device */ 64 | #define USBOPEN_ERR_IO 2 /* I/O error */ 65 | #define USBOPEN_ERR_NOTFOUND 3 /* device not found */ 66 | 67 | 68 | /* Obdev's free USB IDs, see USB-IDs-for-free.txt for details */ 69 | 70 | #define USB_VID_OBDEV_SHARED 5824 /* obdev's shared vendor ID */ 71 | #define USB_PID_OBDEV_SHARED_CUSTOM 1500 /* shared PID for custom class devices */ 72 | #define USB_PID_OBDEV_SHARED_HID 1503 /* shared PID for HIDs except mice & keyboards */ 73 | #define USB_PID_OBDEV_SHARED_CDCACM 1505 /* shared PID for CDC Modem devices */ 74 | #define USB_PID_OBDEV_SHARED_MIDI 1508 /* shared PID for MIDI class devices */ 75 | 76 | #endif /* __OPENDEVICE_H_INCLUDED__ */ 77 | -------------------------------------------------------------------------------- /libraries/UsbKeyboard/vusb-20121206/examples/usbtool/opendevice.h: -------------------------------------------------------------------------------- 1 | /* Name: opendevice.h 2 | * Project: V-USB host-side library 3 | * Author: Christian Starkjohann 4 | * Creation Date: 2008-04-10 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 | */ 9 | 10 | /* 11 | General Description: 12 | This module offers additional functionality for host side drivers based on 13 | libusb or libusb-win32. It includes a function to find and open a device 14 | based on numeric IDs and textual description. It also includes a function to 15 | obtain textual descriptions from a device. 16 | 17 | To use this functionality, simply copy opendevice.c and opendevice.h into your 18 | project and add them to your Makefile. You may modify and redistribute these 19 | files according to the GNU General Public License (GPL) version 2 or 3. 20 | */ 21 | 22 | #ifndef __OPENDEVICE_H_INCLUDED__ 23 | #define __OPENDEVICE_H_INCLUDED__ 24 | 25 | #include /* this is libusb, see http://libusb.sourceforge.net/ */ 26 | #include 27 | 28 | int usbGetStringAscii(usb_dev_handle *dev, int index, char *buf, int buflen); 29 | /* This function gets a string descriptor from the device. 'index' is the 30 | * string descriptor index. The string is returned in ISO Latin 1 encoding in 31 | * 'buf' and it is terminated with a 0-character. The buffer size must be 32 | * passed in 'buflen' to prevent buffer overflows. A libusb device handle 33 | * must be given in 'dev'. 34 | * Returns: The length of the string (excluding the terminating 0) or 35 | * a negative number in case of an error. If there was an error, use 36 | * usb_strerror() to obtain the error message. 37 | */ 38 | 39 | int usbOpenDevice(usb_dev_handle **device, int vendorID, char *vendorNamePattern, int productID, char *productNamePattern, char *serialNamePattern, FILE *printMatchingDevicesFp, FILE *warningsFp); 40 | /* This function iterates over all devices on all USB busses and searches for 41 | * a device. Matching is done first by means of Vendor- and Product-ID (passed 42 | * in 'vendorID' and 'productID'. An ID of 0 matches any numeric ID (wildcard). 43 | * When a device matches by its IDs, matching by names is performed. Name 44 | * matching can be done on textual vendor name ('vendorNamePattern'), product 45 | * name ('productNamePattern') and serial number ('serialNamePattern'). A 46 | * device matches only if all non-null pattern match. If you don't care about 47 | * a string, pass NULL for the pattern. Patterns are Unix shell style pattern: 48 | * '*' stands for 0 or more characters, '?' for one single character, a list 49 | * of characters in square brackets for a single character from the list 50 | * (dashes are allowed to specify a range) and if the lis of characters begins 51 | * with a caret ('^'), it matches one character which is NOT in the list. 52 | * Other parameters to the function: If 'warningsFp' is not NULL, warning 53 | * messages are printed to this file descriptor with fprintf(). If 54 | * 'printMatchingDevicesFp' is not NULL, no device is opened but matching 55 | * devices are printed to the given file descriptor with fprintf(). 56 | * If a device is opened, the resulting USB handle is stored in '*device'. A 57 | * pointer to a "usb_dev_handle *" type variable must be passed here. 58 | * Returns: 0 on success, an error code (see defines below) on failure. 59 | */ 60 | 61 | /* usbOpenDevice() error codes: */ 62 | #define USBOPEN_SUCCESS 0 /* no error */ 63 | #define USBOPEN_ERR_ACCESS 1 /* not enough permissions to open device */ 64 | #define USBOPEN_ERR_IO 2 /* I/O error */ 65 | #define USBOPEN_ERR_NOTFOUND 3 /* device not found */ 66 | 67 | 68 | /* Obdev's free USB IDs, see USB-IDs-for-free.txt for details */ 69 | 70 | #define USB_VID_OBDEV_SHARED 5824 /* obdev's shared vendor ID */ 71 | #define USB_PID_OBDEV_SHARED_CUSTOM 1500 /* shared PID for custom class devices */ 72 | #define USB_PID_OBDEV_SHARED_HID 1503 /* shared PID for HIDs except mice & keyboards */ 73 | #define USB_PID_OBDEV_SHARED_CDCACM 1505 /* shared PID for CDC Modem devices */ 74 | #define USB_PID_OBDEV_SHARED_MIDI 1508 /* shared PID for MIDI class devices */ 75 | 76 | #endif /* __OPENDEVICE_H_INCLUDED__ */ 77 | -------------------------------------------------------------------------------- /libraries/UsbKeyboard/vusb-20121206/examples/custom-class/commandline/opendevice.h: -------------------------------------------------------------------------------- 1 | /* Name: opendevice.h 2 | * Project: V-USB host-side library 3 | * Author: Christian Starkjohann 4 | * Creation Date: 2008-04-10 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 | */ 9 | 10 | /* 11 | General Description: 12 | This module offers additional functionality for host side drivers based on 13 | libusb or libusb-win32. It includes a function to find and open a device 14 | based on numeric IDs and textual description. It also includes a function to 15 | obtain textual descriptions from a device. 16 | 17 | To use this functionality, simply copy opendevice.c and opendevice.h into your 18 | project and add them to your Makefile. You may modify and redistribute these 19 | files according to the GNU General Public License (GPL) version 2 or 3. 20 | */ 21 | 22 | #ifndef __OPENDEVICE_H_INCLUDED__ 23 | #define __OPENDEVICE_H_INCLUDED__ 24 | 25 | #include /* this is libusb, see http://libusb.sourceforge.net/ */ 26 | #include 27 | 28 | int usbGetStringAscii(usb_dev_handle *dev, int index, char *buf, int buflen); 29 | /* This function gets a string descriptor from the device. 'index' is the 30 | * string descriptor index. The string is returned in ISO Latin 1 encoding in 31 | * 'buf' and it is terminated with a 0-character. The buffer size must be 32 | * passed in 'buflen' to prevent buffer overflows. A libusb device handle 33 | * must be given in 'dev'. 34 | * Returns: The length of the string (excluding the terminating 0) or 35 | * a negative number in case of an error. If there was an error, use 36 | * usb_strerror() to obtain the error message. 37 | */ 38 | 39 | int usbOpenDevice(usb_dev_handle **device, int vendorID, char *vendorNamePattern, int productID, char *productNamePattern, char *serialNamePattern, FILE *printMatchingDevicesFp, FILE *warningsFp); 40 | /* This function iterates over all devices on all USB busses and searches for 41 | * a device. Matching is done first by means of Vendor- and Product-ID (passed 42 | * in 'vendorID' and 'productID'. An ID of 0 matches any numeric ID (wildcard). 43 | * When a device matches by its IDs, matching by names is performed. Name 44 | * matching can be done on textual vendor name ('vendorNamePattern'), product 45 | * name ('productNamePattern') and serial number ('serialNamePattern'). A 46 | * device matches only if all non-null pattern match. If you don't care about 47 | * a string, pass NULL for the pattern. Patterns are Unix shell style pattern: 48 | * '*' stands for 0 or more characters, '?' for one single character, a list 49 | * of characters in square brackets for a single character from the list 50 | * (dashes are allowed to specify a range) and if the lis of characters begins 51 | * with a caret ('^'), it matches one character which is NOT in the list. 52 | * Other parameters to the function: If 'warningsFp' is not NULL, warning 53 | * messages are printed to this file descriptor with fprintf(). If 54 | * 'printMatchingDevicesFp' is not NULL, no device is opened but matching 55 | * devices are printed to the given file descriptor with fprintf(). 56 | * If a device is opened, the resulting USB handle is stored in '*device'. A 57 | * pointer to a "usb_dev_handle *" type variable must be passed here. 58 | * Returns: 0 on success, an error code (see defines below) on failure. 59 | */ 60 | 61 | /* usbOpenDevice() error codes: */ 62 | #define USBOPEN_SUCCESS 0 /* no error */ 63 | #define USBOPEN_ERR_ACCESS 1 /* not enough permissions to open device */ 64 | #define USBOPEN_ERR_IO 2 /* I/O error */ 65 | #define USBOPEN_ERR_NOTFOUND 3 /* device not found */ 66 | 67 | 68 | /* Obdev's free USB IDs, see USB-IDs-for-free.txt for details */ 69 | 70 | #define USB_VID_OBDEV_SHARED 5824 /* obdev's shared vendor ID */ 71 | #define USB_PID_OBDEV_SHARED_CUSTOM 1500 /* shared PID for custom class devices */ 72 | #define USB_PID_OBDEV_SHARED_HID 1503 /* shared PID for HIDs except mice & keyboards */ 73 | #define USB_PID_OBDEV_SHARED_CDCACM 1505 /* shared PID for CDC Modem devices */ 74 | #define USB_PID_OBDEV_SHARED_MIDI 1508 /* shared PID for MIDI class devices */ 75 | 76 | #endif /* __OPENDEVICE_H_INCLUDED__ */ 77 | -------------------------------------------------------------------------------- /libraries/UsbKeyboard/vusb-20121206/examples/hid-custom-rq/commandline/opendevice.h: -------------------------------------------------------------------------------- 1 | /* Name: opendevice.h 2 | * Project: V-USB host-side library 3 | * Author: Christian Starkjohann 4 | * Creation Date: 2008-04-10 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 | */ 9 | 10 | /* 11 | General Description: 12 | This module offers additional functionality for host side drivers based on 13 | libusb or libusb-win32. It includes a function to find and open a device 14 | based on numeric IDs and textual description. It also includes a function to 15 | obtain textual descriptions from a device. 16 | 17 | To use this functionality, simply copy opendevice.c and opendevice.h into your 18 | project and add them to your Makefile. You may modify and redistribute these 19 | files according to the GNU General Public License (GPL) version 2 or 3. 20 | */ 21 | 22 | #ifndef __OPENDEVICE_H_INCLUDED__ 23 | #define __OPENDEVICE_H_INCLUDED__ 24 | 25 | #include /* this is libusb, see http://libusb.sourceforge.net/ */ 26 | #include 27 | 28 | int usbGetStringAscii(usb_dev_handle *dev, int index, char *buf, int buflen); 29 | /* This function gets a string descriptor from the device. 'index' is the 30 | * string descriptor index. The string is returned in ISO Latin 1 encoding in 31 | * 'buf' and it is terminated with a 0-character. The buffer size must be 32 | * passed in 'buflen' to prevent buffer overflows. A libusb device handle 33 | * must be given in 'dev'. 34 | * Returns: The length of the string (excluding the terminating 0) or 35 | * a negative number in case of an error. If there was an error, use 36 | * usb_strerror() to obtain the error message. 37 | */ 38 | 39 | int usbOpenDevice(usb_dev_handle **device, int vendorID, char *vendorNamePattern, int productID, char *productNamePattern, char *serialNamePattern, FILE *printMatchingDevicesFp, FILE *warningsFp); 40 | /* This function iterates over all devices on all USB busses and searches for 41 | * a device. Matching is done first by means of Vendor- and Product-ID (passed 42 | * in 'vendorID' and 'productID'. An ID of 0 matches any numeric ID (wildcard). 43 | * When a device matches by its IDs, matching by names is performed. Name 44 | * matching can be done on textual vendor name ('vendorNamePattern'), product 45 | * name ('productNamePattern') and serial number ('serialNamePattern'). A 46 | * device matches only if all non-null pattern match. If you don't care about 47 | * a string, pass NULL for the pattern. Patterns are Unix shell style pattern: 48 | * '*' stands for 0 or more characters, '?' for one single character, a list 49 | * of characters in square brackets for a single character from the list 50 | * (dashes are allowed to specify a range) and if the lis of characters begins 51 | * with a caret ('^'), it matches one character which is NOT in the list. 52 | * Other parameters to the function: If 'warningsFp' is not NULL, warning 53 | * messages are printed to this file descriptor with fprintf(). If 54 | * 'printMatchingDevicesFp' is not NULL, no device is opened but matching 55 | * devices are printed to the given file descriptor with fprintf(). 56 | * If a device is opened, the resulting USB handle is stored in '*device'. A 57 | * pointer to a "usb_dev_handle *" type variable must be passed here. 58 | * Returns: 0 on success, an error code (see defines below) on failure. 59 | */ 60 | 61 | /* usbOpenDevice() error codes: */ 62 | #define USBOPEN_SUCCESS 0 /* no error */ 63 | #define USBOPEN_ERR_ACCESS 1 /* not enough permissions to open device */ 64 | #define USBOPEN_ERR_IO 2 /* I/O error */ 65 | #define USBOPEN_ERR_NOTFOUND 3 /* device not found */ 66 | 67 | 68 | /* Obdev's free USB IDs, see USB-IDs-for-free.txt for details */ 69 | 70 | #define USB_VID_OBDEV_SHARED 5824 /* obdev's shared vendor ID */ 71 | #define USB_PID_OBDEV_SHARED_CUSTOM 1500 /* shared PID for custom class devices */ 72 | #define USB_PID_OBDEV_SHARED_HID 1503 /* shared PID for HIDs except mice & keyboards */ 73 | #define USB_PID_OBDEV_SHARED_CDCACM 1505 /* shared PID for CDC Modem devices */ 74 | #define USB_PID_OBDEV_SHARED_MIDI 1508 /* shared PID for MIDI class devices */ 75 | 76 | #endif /* __OPENDEVICE_H_INCLUDED__ */ 77 | -------------------------------------------------------------------------------- /software/fwupdate/updater.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # 3 | # Test program to update DCDarkNet badges using avrdude 4 | # Right now it just reads the flash and eeprom using 5 | # avrispmkII, avr dragon isp, and FTDI(arduino) 6 | # 7 | # NOTE: EEPROM data seems to be invalid while using FTDI/arduino bootloader 8 | # 9 | import Adafruit_BBIO.GPIO as GPIO 10 | import SFLCDController 11 | import AVRProg 12 | import sys 13 | 14 | DEBUG = False 15 | 16 | def modeReadFlash(): 17 | print("Reading flash") 18 | flashFile = AVRProg.readFlash(DEBUG) 19 | if flashFile: 20 | print("Flash dumped to: " + flashFile) 21 | else: 22 | print("Error reading flash") 23 | 24 | def modeReadEEPROM(): 25 | print("Reading EEPROM") 26 | eepromFile = AVRProg.readEEPROM(DEBUG); 27 | print("EEPROM dumped to: " + eepromFile) 28 | if eepromFile: 29 | if DEBUG: 30 | AVRProg.dumpEEPROM(eepromFile) 31 | else: 32 | print("Error reading EEPROM") 33 | 34 | def modeReadAll(): 35 | modeReadFlash() 36 | AVRProg.dragonWait() 37 | modeReadEEPROM() 38 | 39 | def modeFlashBootloader(): 40 | print("Erasing Chip and Burning Fuses") 41 | 42 | lcd.clear(); 43 | lcd.write("Burning Fuses") 44 | 45 | rval = AVRProg.runAvrdudeCommand('avrdude -v -c ' + AVRProg.PROGRAMMER + ' -p m328p -P ' + AVRProg.PROGRAMMERS[AVRProg.PROGRAMMER] + ' -e -Ulock:w:0x3F:m -Uefuse:w:0x05:m -Uhfuse:w:0xDE:m -Ulfuse:w:0xFF:m', DEBUG) 46 | 47 | if rval == 1: 48 | print("Error burning fuses") 49 | return rval 50 | 51 | AVRProg.dragonWait() 52 | 53 | lcd.clear(); 54 | lcd.write("Flash Bootloader") 55 | 56 | rval = AVRProg.runAvrdudeCommand('avrdude -v -c ' + AVRProg.PROGRAMMER + ' -p m328p -P ' + AVRProg.PROGRAMMERS[AVRProg.PROGRAMMER] + ' -Uflash:w:./optiboot_atmega328.hex:i -Ulock:w:0x0F:m', DEBUG) 57 | if rval == 1: 58 | print("Error flashing bootloader") 59 | return rval 60 | 61 | return 0 62 | 63 | MODES = { 'readFlash': modeReadFlash, 64 | 'readEEPROM': modeReadEEPROM, 65 | 'readAll': modeReadAll, 66 | 'flashBootloader': modeFlashBootloader, 67 | 'flashFW': None, 68 | 'flashEEPROM': None, 69 | 'updateFW': None} 70 | 71 | # 72 | # Start Here! 73 | # 74 | if len(sys.argv) < 3: 75 | print("Usage: " + sys.argv[0] + " ") 76 | print("\nSupported programmers(Use 'auto' if you're not sure):\n " + '\n '.join(AVRProg.PROGRAMMERS) + "") 77 | print("\nSupported Modes:\n " + '\n '.join(MODES) + "") 78 | sys.exit(1) 79 | 80 | # 81 | # Setup LCD 82 | # 83 | lcd = SFLCDController.Controller() 84 | lcd.connect( "/dev/ttyO4", 9600) 85 | lcd.clear() 86 | lcd.write("DarkNet FWUpdate") 87 | 88 | AVRProg.lcd = lcd 89 | 90 | # 91 | # Validate user input 92 | # 93 | if not sys.argv[2] in MODES: 94 | print("Unsupported mode '" + sys.argv[2] + "'") 95 | print("Supported Modes:\n " + '\n '.join(MODES) + "") 96 | sys.exit(1) 97 | elif MODES[sys.argv[2]] == None: 98 | print("Mode '" + sys.argv[2] + "' not yet implemented") 99 | sys.exit(1) 100 | 101 | if not sys.argv[1] in AVRProg.PROGRAMMERS: 102 | if sys.argv[1] == 'auto': 103 | print('Searching all supported programmers for device') 104 | for key in AVRProg.PROGRAMMERS.keys(): 105 | print("Checking " + key) 106 | 107 | returnCode = AVRProg.runAvrdudeCommand('avrdude -v -c ' + key + ' -p m328p -P ' + AVRProg.PROGRAMMERS[key], False) 108 | 109 | # We'll use the first one we find 110 | if returnCode == 0: 111 | print("Looks good!") 112 | AVRProg.PROGRAMMER = key 113 | break 114 | 115 | if AVRProg.PROGRAMMER == None: 116 | print("Could not find connected device") 117 | sys.exit(1) 118 | 119 | AVRProg.dragonWait() 120 | else: 121 | print("Supported programmers(Use 'auto' if you're not sure):\n " + '\n '.join(AVRProg.PROGRAMMERS) + "") 122 | sys.exit(1) 123 | else: 124 | AVRProg.PROGRAMMER = sys.argv[1] 125 | 126 | # 127 | # Do the thing! 128 | # 129 | MODES[sys.argv[2]]() 130 | 131 | lcd.disconnect() 132 | -------------------------------------------------------------------------------- /libraries/UsbKeyboard/vusb-20121206/libs-device/osctune.h: -------------------------------------------------------------------------------- 1 | /* Name: osctune.h 2 | * Author: Christian Starkjohann 3 | * Creation Date: 2008-10-18 4 | * Tabsize: 4 5 | * Copyright: (c) 2008 by OBJECTIVE DEVELOPMENT Software GmbH 6 | * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) 7 | */ 8 | 9 | /* 10 | General Description: 11 | This file is declared as C-header file although it is mostly documentation 12 | how the RC oscillator can be kept in sync to the USB frame rate. The code 13 | shown here must be added to usbconfig.h or this header file is included from 14 | there. This code works only if D- is wired to the interrupt, not D+!!! 15 | 16 | This is an alternative to the osccal routine in osccal.c. It has the advantage 17 | that the synchronization is done continuously and that it has more compact 18 | code size. The disadvantages are slow synchronization (it may take a while 19 | until the driver works), that messages immediately after the SOF pulse may be 20 | lost (and need to be retried by the host) and that the interrupt is on D- 21 | contrary to most examples. 22 | 23 | You may want to store a good calibration value in EEPROM for the next startup. 24 | You know that the calibration value is good when the first USB message is 25 | received. Do not store the value on every received message because the EEPROM 26 | has a limited endurance. 27 | 28 | Notes: 29 | (*) You must declare the global character variable "lastTimer0Value" in your 30 | main code. 31 | 32 | (*) Timer 0 must be free running (not written by your code) and the prescaling 33 | must be consistent with the TIMER0_PRESCALING define. 34 | 35 | (*) Good values for Timer 0 prescaling depend on how precise the clock must 36 | be tuned and how far away from the default clock rate the target clock is. 37 | For precise tuning, choose a low prescaler factor, for a broad range of tuning 38 | choose a high one. A prescaler factor of 64 is good for the entire OSCCAL 39 | range and allows a precision of better than +/-1%. A prescaler factor of 8 40 | allows tuning to slightly more than +/-6% of the default frequency and is 41 | more precise than one step of OSCCAL. It is therefore not suitable to tune an 42 | 8 MHz oscillator to 12.5 MHz. 43 | 44 | Thanks to Henrik Haftmann for the idea to this routine! 45 | */ 46 | 47 | #define TIMER0_PRESCALING 64 /* must match the configuration for TIMER0 in main */ 48 | #define TOLERATED_DEVIATION_PPT 5 /* max clock deviation before we tune in 1/10 % */ 49 | /* derived constants: */ 50 | #define EXPECTED_TIMER0_INCREMENT ((F_CPU / (1000 * TIMER0_PRESCALING)) & 0xff) 51 | #define TOLERATED_DEVIATION (TOLERATED_DEVIATION_PPT * F_CPU / (1000000 * TIMER0_PRESCALING)) 52 | 53 | #ifdef __ASSEMBLER__ 54 | macro tuneOsccal 55 | push YH ;[0] 56 | in YL, TCNT0 ;[2] 57 | lds YH, lastTimer0Value ;[3] 58 | sts lastTimer0Value, YL ;[5] 59 | sub YL, YH ;[7] time passed since last frame 60 | subi YL, EXPECTED_TIMER0_INCREMENT ;[8] 61 | #if OSCCAL > 0x3f /* outside I/O addressable range */ 62 | lds YH, OSCCAL ;[6] 63 | #else 64 | in YH, OSCCAL ;[6] assembler modle uses __SFR_OFFSET == 0 65 | #endif 66 | cpi YL, TOLERATED_DEVIATION + 1 ;[10] 67 | brmi notTooHigh ;[11] 68 | subi YH, 1 ;[12] clock rate was too high 69 | ; brcs tuningOverflow ; optionally check for overflow 70 | rjmp osctuneDone ;[13] 71 | notTooHigh: 72 | cpi YL, -TOLERATED_DEVIATION ;[13] 73 | brpl osctuneDone ;[14] not too low 74 | inc YH ;[15] clock rate was too low 75 | ; breq tuningOverflow ; optionally check for overflow 76 | osctuneDone: 77 | #if OSCCAL > 0x3f /* outside I/O addressable range */ 78 | sts OSCCAL, YH ;[12-13] store tuned value 79 | #else 80 | out OSCCAL, YH ;[12-13] store tuned value 81 | #endif 82 | tuningOverflow: 83 | pop YH ;[17] 84 | endm ;[19] max number of cycles 85 | #endif 86 | 87 | #define USB_SOF_HOOK tuneOsccal 88 | -------------------------------------------------------------------------------- /libraries/UsbKeyboard/vusb-20121206/examples/hid-data/commandline/hidtool.c: -------------------------------------------------------------------------------- 1 | /* Name: hidtool.c 2 | * Project: hid-data example 3 | * Author: Christian Starkjohann 4 | * Creation Date: 2008-04-11 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 | */ 9 | 10 | #include 11 | #include 12 | #include 13 | #include "hiddata.h" 14 | #include "../firmware/usbconfig.h" /* for device VID, PID, vendor name and product name */ 15 | 16 | /* ------------------------------------------------------------------------- */ 17 | 18 | static char *usbErrorMessage(int errCode) 19 | { 20 | static char buffer[80]; 21 | 22 | switch(errCode){ 23 | case USBOPEN_ERR_ACCESS: return "Access to device denied"; 24 | case USBOPEN_ERR_NOTFOUND: return "The specified device was not found"; 25 | case USBOPEN_ERR_IO: return "Communication error with device"; 26 | default: 27 | sprintf(buffer, "Unknown USB error %d", errCode); 28 | return buffer; 29 | } 30 | return NULL; /* not reached */ 31 | } 32 | 33 | static usbDevice_t *openDevice(void) 34 | { 35 | usbDevice_t *dev = NULL; 36 | unsigned char rawVid[2] = {USB_CFG_VENDOR_ID}, rawPid[2] = {USB_CFG_DEVICE_ID}; 37 | char vendorName[] = {USB_CFG_VENDOR_NAME, 0}, productName[] = {USB_CFG_DEVICE_NAME, 0}; 38 | int vid = rawVid[0] + 256 * rawVid[1]; 39 | int pid = rawPid[0] + 256 * rawPid[1]; 40 | int err; 41 | 42 | if((err = usbhidOpenDevice(&dev, vid, vendorName, pid, productName, 0)) != 0){ 43 | fprintf(stderr, "error finding %s: %s\n", productName, usbErrorMessage(err)); 44 | return NULL; 45 | } 46 | return dev; 47 | } 48 | 49 | /* ------------------------------------------------------------------------- */ 50 | 51 | static void hexdump(char *buffer, int len) 52 | { 53 | int i; 54 | FILE *fp = stdout; 55 | 56 | for(i = 0; i < len; i++){ 57 | if(i != 0){ 58 | if(i % 16 == 0){ 59 | fprintf(fp, "\n"); 60 | }else{ 61 | fprintf(fp, " "); 62 | } 63 | } 64 | fprintf(fp, "0x%02x", buffer[i] & 0xff); 65 | } 66 | if(i != 0) 67 | fprintf(fp, "\n"); 68 | } 69 | 70 | static int hexread(char *buffer, char *string, int buflen) 71 | { 72 | char *s; 73 | int pos = 0; 74 | 75 | while((s = strtok(string, ", ")) != NULL && pos < buflen){ 76 | string = NULL; 77 | buffer[pos++] = (char)strtol(s, NULL, 0); 78 | } 79 | return pos; 80 | } 81 | 82 | /* ------------------------------------------------------------------------- */ 83 | 84 | static void usage(char *myName) 85 | { 86 | fprintf(stderr, "usage:\n"); 87 | fprintf(stderr, " %s read\n", myName); 88 | fprintf(stderr, " %s write \n", myName); 89 | } 90 | 91 | int main(int argc, char **argv) 92 | { 93 | usbDevice_t *dev; 94 | char buffer[129]; /* room for dummy report ID */ 95 | int err; 96 | 97 | if(argc < 2){ 98 | usage(argv[0]); 99 | exit(1); 100 | } 101 | if((dev = openDevice()) == NULL) 102 | exit(1); 103 | if(strcasecmp(argv[1], "read") == 0){ 104 | int len = sizeof(buffer); 105 | if((err = usbhidGetReport(dev, 0, buffer, &len)) != 0){ 106 | fprintf(stderr, "error reading data: %s\n", usbErrorMessage(err)); 107 | }else{ 108 | hexdump(buffer + 1, sizeof(buffer) - 1); 109 | } 110 | }else if(strcasecmp(argv[1], "write") == 0){ 111 | int i, pos; 112 | memset(buffer, 0, sizeof(buffer)); 113 | for(pos = 1, i = 2; i < argc && pos < sizeof(buffer); i++){ 114 | pos += hexread(buffer + pos, argv[i], sizeof(buffer) - pos); 115 | } 116 | if((err = usbhidSetReport(dev, buffer, sizeof(buffer))) != 0) /* add a dummy report ID */ 117 | fprintf(stderr, "error writing data: %s\n", usbErrorMessage(err)); 118 | }else{ 119 | usage(argv[0]); 120 | exit(1); 121 | } 122 | usbhidCloseDevice(dev); 123 | return 0; 124 | } 125 | 126 | /* ------------------------------------------------------------------------- */ 127 | -------------------------------------------------------------------------------- /libraries/UsbKeyboard/vusb-20121206/circuits/Readme.txt: -------------------------------------------------------------------------------- 1 | This is the Readme file for the V-USB example circuits directory. 2 | 3 | 4 | CIRCUITS IN THIS DIRECTORY 5 | ========================== 6 | Since USB requires 3.3 V levels on D+ and D- but delivers a power supply of 7 | ca. 5 V, some kind of level conversion must be performed. There are several 8 | ways to implement this level conversion, see the example circuits below. 9 | 10 | with-vreg.png and with-vreg.sch (EAGLE schematics): 11 | This circuit uses a low drop voltage regulator to reduce the USB supply to 12 | 3.3 V. You MUST use a low drop regulator because standard regulators such 13 | as the LM317 require at least ca. 2 V drop. The advantage of this approach 14 | is that it comes closest to the voltage levels required by the USB 15 | specification and that the circuit is powered from a regulated supply. If 16 | no USB cable is used (connector directly soldered on PCB), you can even 17 | omit the 68 Ohm series resistors. The disadvantage is that you may want to 18 | use other chips in your design which require 5 V. Please check that the AVR 19 | used in your design allows the chosen clock rate at 3.3 V. 20 | 21 | with-zener.png and with-zener.sch (EAGLE schematics): 22 | This circuit enforces lower voltage levels on D+ and D- with zener diodes. 23 | The zener diodes MUST be low power / low current types to ensure that the 24 | 1k5 pull-up resistor on D- generates a voltage of well above 2.5 V (but 25 | below 3.6 V). The advantage of this circuit is its simplicity and that the 26 | circuit can be powered at 5 V (usually precise enough if the cable drop is 27 | neglected). The disadvantage is that some zener diodes have a lower voltage 28 | than 3 V when powered through 1k5 and the choice of components becomes 29 | relevant. In addition to that, the power consumption during USB data 30 | transfer is increased because the current is only limited by the 68 Ohm 31 | series resistor. The zeners may even distort the signal waveforms due to 32 | their capacity. 33 | 34 | with-series-diodes.png and with-series-diodes.sch (EAGLE schematics): 35 | This is a simplified low-cost version of the voltage regulator approach. 36 | Instead of using a voltage regulator, we reduce the voltage by the forward 37 | voltage of two silicon diodes (roughly 1.4 V). This gives ca. 3.6 V which 38 | is practically inside the allowed range. The big disadvantage is that the 39 | supply is not regulated -- it even depends strongly on the power 40 | consumption. This cannot be tolerated for analog circuits. 41 | 42 | tiny45-rc.png and tiny45-rc.sch (EAGLE schematics): 43 | This is mostly an example for connecting an 8 pin device using the internal 44 | RC oscillator for system clock. This example uses series diodes to limit 45 | the supply, but you may choose any other method. Please note that you must 46 | choose a clock rate of 12.8 or 16.5 MHz because only the receiver modules 47 | for these frequencies have a PLL to allow higher clock rate tolerances. 48 | 49 | 50 | GENERAL DESIGN NOTES 51 | ==================== 52 | All examples have D+ on hardware interrupt INT0 because this is the highest 53 | priority interrupt on AVRs. You may use other hardware interrupts (and 54 | configure the options at the end of usbconfig.h accordingly) if you make sure 55 | that no higher priority interrupt is used. 56 | 57 | If you use USB_SOF_HOOK or USB_COUNT_SOF in usbconfig.h, you must wire D- to 58 | the interrupt instead. This way the interrupt is triggered on USB Start Of 59 | Frame pulses as well. 60 | 61 | Most examples have a 1M pull-down resistor at D+. This pull-up ensures that 62 | in self-powered designs no interrupts occur while USB is not connected. You 63 | may omit this resistor in bus-powered designs. Older examples had a pull-up 64 | resistor instead. This is not compatible with the zener diode approach to 65 | level conversion: 1M pull-up in conjunction with a 3.6 V zener diode give an 66 | invalid logic level. 67 | 68 | All examples with ATMega8/88/168 have D+ at port D bit 2 (because this is 69 | hardware interrupt 0) and D- on port D bit 4 because it is also a clock input 70 | for timer/counter 0. This way the firmware can easily check for activity on 71 | D- (USB frame pulses) by checking the counter value in regular intervals. If 72 | no activity is found, the firmware should (according to the USB 73 | specification) put the system into a low power suspend mode. 74 | 75 | 76 | 77 | ---------------------------------------------------------------------------- 78 | (c) 2008 by OBJECTIVE DEVELOPMENT Software GmbH. 79 | http://www.obdev.at/ 80 | -------------------------------------------------------------------------------- /libraries/IRSerial2014/IRSerial-2014.h: -------------------------------------------------------------------------------- 1 | /* 2 | IRSerial-2014 (formerly IRSerial.h (formerly NewSoftSerial.h)) - 3 | Multi-instance software serial library for Arduino/Wiring 4 | -- Adapted for simple IR send/receive by Mark Smith (mark@halibut.com) 5 | - Allowed the inversion of TX and/or RX pins so idle state could 6 | be low for driving IR LEDs. 7 | - TX now modulates pin at 38kHz instead of just turning it on. 8 | -- Interrupt-driven receive and other improvements by ladyada 9 | (http://ladyada.net) 10 | -- Tuning, circular buffer, derivation from class Print/Stream, 11 | multi-instance support, porting to 8MHz processors, 12 | various optimizations, PROGMEM delay tables, inverse logic and 13 | direct port writing by Mikal Hart (http://www.arduiniana.org) 14 | -- Pin change interrupt macros by Paul Stoffregen (http://www.pjrc.com) 15 | -- 20MHz processor support by Garrett Mace (http://www.macetech.com) 16 | -- ATmega1280/2560 support by Brett Hagman (http://www.roguerobotics.com/) 17 | 18 | This library is free software; you can redistribute it and/or 19 | modify it under the terms of the GNU Lesser General Public 20 | License as published by the Free Software Foundation; either 21 | version 2.1 of the License, or (at your option) any later version. 22 | 23 | This library is distributed in the hope that it will be useful, 24 | but WITHOUT ANY WARRANTY; without even the implied warranty of 25 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26 | Lesser General Public License for more details. 27 | 28 | You should have received a copy of the GNU Lesser General Public 29 | License along with this library; if not, write to the Free Software 30 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 31 | 32 | The latest version of this library can always be found at 33 | http://arduiniana.org. 34 | */ 35 | 36 | #ifndef IRSerial_h 37 | #define IRSerial_h 38 | 39 | #include 40 | #include 41 | 42 | /****************************************************************************** 43 | * Definitions 44 | ******************************************************************************/ 45 | 46 | #define _SS_MAX_RX_BUFF 64 // RX buffer size 47 | #ifndef GCC_VERSION 48 | #define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) 49 | #endif 50 | 51 | class IRSerial : public Stream { 52 | private: 53 | // per object data 54 | uint8_t _receivePin; 55 | uint8_t _receiveBitMask; 56 | volatile uint8_t *_receivePortRegister; 57 | uint8_t _transmitBitMask; 58 | volatile uint8_t *_transmitPortRegister; 59 | 60 | uint16_t _rx_delay_centering; 61 | uint16_t _rx_delay_intrabit; 62 | uint16_t _rx_delay_stopbit; 63 | uint16_t _tx_delay; 64 | uint16_t _modulation_frequency; 65 | 66 | uint16_t _buffer_overflow:1; 67 | uint16_t _inverse_logic_rx:1; 68 | uint16_t _inverse_logic_tx:1; 69 | 70 | 71 | // static data 72 | static char _receive_buffer[_SS_MAX_RX_BUFF]; 73 | static volatile uint8_t _receive_buffer_tail; 74 | static volatile uint8_t _receive_buffer_head; 75 | static IRSerial *active_object; 76 | 77 | // private methods 78 | void recv(); 79 | uint8_t rx_pin_read(); 80 | void tx_pin_write(uint8_t pin_state); 81 | void tx_pin_write_and_delay(uint8_t pin_state, uint16_t delay); 82 | void setTX(uint8_t transmitPin); 83 | void setRX(uint8_t receivePin); 84 | 85 | // private static method for timing 86 | static inline void tunedDelay(uint16_t delay); 87 | 88 | public: 89 | // public methods 90 | IRSerial(uint8_t receivePin, uint8_t transmitPin, bool inverse_logic_rx = false, bool inverse_logic_tx = false, uint16_t modulation_frequency=0); 91 | ~IRSerial(); 92 | void begin(long speed); 93 | bool listen(); 94 | void end(); 95 | bool isListening() { return this == active_object; } 96 | bool overflow() { bool ret = _buffer_overflow; _buffer_overflow = false; return ret; } 97 | int peek(); 98 | 99 | virtual size_t write(uint8_t byte); 100 | virtual int read(); 101 | virtual int available(); 102 | virtual void flush(); 103 | 104 | using Print::write; 105 | 106 | // public only for easy access by interrupt handlers 107 | static inline void handle_interrupt(); 108 | }; 109 | 110 | // Arduino 0012 workaround 111 | #undef int 112 | #undef char 113 | #undef long 114 | #undef byte 115 | #undef float 116 | #undef abs 117 | #undef round 118 | 119 | #endif 120 | -------------------------------------------------------------------------------- /libraries/UsbKeyboard/vusb-20121206/examples/Readme.txt: -------------------------------------------------------------------------------- 1 | This is the Readme file for the directory "examples" of V-USB, a firmware- 2 | only USB driver for AVR microcontrollers. 3 | 4 | WHAT IS IN THIS DIRECTORY? 5 | ========================== 6 | This directory contains examples which are mostly for educational purposes. 7 | Examples can be device firmware only, host software only or both. Here is 8 | a summary: 9 | 10 | custom-class 11 | A custom class device with host software based on libusb. It demonstrates 12 | the straight forward way of sending small amounts of data to a device and 13 | receiving data from the device. It does NOT demonstrate how to send large 14 | amounts of data to the device or how to receive data generated on the fly 15 | by the device (how to use usbFunctionWrite() and usbFunctionRead()). See 16 | the hid-data example for how usbFunctionWrite() and usbFunctionRead() are 17 | used. 18 | 19 | hid-custom-rq 20 | This example implements the same functionality as the custom-class example 21 | above, but declares the device as HID. This prevents the "give me a driver 22 | CD" dialog on Windows. The device can still be controlled with libusb as in 23 | the previous example (on Windows, the filter version of libusb-win32 must 24 | be installed). In addition to the features presented in custom-class, this 25 | example demonstrates how a HID class device is defined. 26 | 27 | hid-mouse 28 | This example implements a mouse device. No host driver is required since 29 | today's operating systems have drivers for USB mice built-in. It 30 | demonstrates how a real-world HID class device is implemented and how 31 | interrupt-in endpoints are used. 32 | 33 | hid-data 34 | This example demonstrates how the HID class can be misused to transfer 35 | arbitrary data over HID feature reports. This technique is of great value 36 | on Windows because no driver DLLs are needed (the hid-custom-rq example 37 | still requires the libusb-win32 DLL, although it may be in the program's 38 | directory). The host side application requires no installation, it can 39 | even be started directly from a CD. This example also demonstrates how 40 | to transfer data using usbFunctionWrite() and usbFunctionRead(). 41 | 42 | usbtool 43 | This is a general purpose development and debugging tool for USB devices. 44 | You can use it during development of your device to test various requests 45 | without special test programs. But it is also an example how all the 46 | libusb API functions are used. 47 | 48 | More information about each example can be found in the Readme file in the 49 | respective directory. 50 | 51 | Hardware dependencies of AVR code has been kept at a minimum. All examples 52 | should work on any AVR chip which has enough resources to run the driver. 53 | Makefile and usbconfig.h have been configured for the metaboard hardware (see 54 | http://www.obdev.at/goto.php?t=metaboard for details). Edit the target 55 | device, fuse values, clock rate and programmer in Makefile and the I/O pins 56 | dedicated to USB in usbconfig.h. 57 | 58 | 59 | WHAT IS NOT DEMONSTRATED IN THESE EXAMPLES? 60 | =========================================== 61 | These examples show only the most basic functionality. More elaborate 62 | examples and real world applications showing more features of the driver are 63 | available at http://www.obdev.at/vusb/projects.html. Most of these 64 | features are described in our documentation wiki at 65 | http://www.obdev.at/goto.php?t=vusb-wiki. 66 | 67 | To mention just a few: 68 | 69 | Using RC oscillator for system clock 70 | The 12.8 MHz and 16.5 MHz modules of V-USB have been designed to cope 71 | with clock rate deviations up to 1%. This allows an RC oscillator to be 72 | used. Since the AVR's RC oscillator has a factory precision of only 10%, 73 | it must be calibrated to an external reference. The EasyLogger example 74 | shows how this can be done. 75 | 76 | Dynamically generated descriptors 77 | Sometimes you want to implement different typtes of USB device depending 78 | on a jumper or other condition. V-USB has a very flexible interface for 79 | providing USB descriptors. See AVR-Doper for how to provide descriptors 80 | at runtime. 81 | 82 | Virtual COM port 83 | Some people prefer a virtual serial interface to communicate with their 84 | device. We strongly discourage this method because it does things 85 | forbidden by the USB specification. If you still want to go this route, 86 | see AVR-CDC. 87 | 88 | Implementing suspend mode 89 | V-USB does not implement suspend mode. This means that the device does 90 | not reduce power consumption when the host goes into sleep mode. Device 91 | firmware is free to implement suspend mode, though. See USB2LPT for an 92 | example. 93 | 94 | The projects mentioned above can best be found on 95 | 96 | http://www.obdev.at/vusb/prjall.html 97 | 98 | where all projects are listed. 99 | 100 | ---------------------------------------------------------------------------- 101 | (c) 2009 by OBJECTIVE DEVELOPMENT Software GmbH. 102 | http://www.obdev.at/ 103 | -------------------------------------------------------------------------------- /libraries/UsbKeyboard/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 | */ 9 | 10 | /* 11 | General Description: 12 | This header is intended to contain all (or at least most of) the compiler 13 | and library dependent stuff. The C code is written for avr-gcc and avr-libc. 14 | The API of other development environments is converted to gcc's and avr-libc's 15 | API by means of defines. 16 | 17 | This header also contains all system includes since they depend on the 18 | development environment. 19 | 20 | Thanks to Oleg Semyonov for his help with the IAR tools port! 21 | */ 22 | 23 | #ifndef __usbportability_h_INCLUDED__ 24 | #define __usbportability_h_INCLUDED__ 25 | 26 | /* We check explicitly for IAR and CodeVision. Default is avr-gcc/avr-libc. */ 27 | 28 | /* ------------------------------------------------------------------------- */ 29 | #if defined __IAR_SYSTEMS_ICC__ || defined __IAR_SYSTEMS_ASM__ /* check for IAR */ 30 | /* ------------------------------------------------------------------------- */ 31 | 32 | #ifndef ENABLE_BIT_DEFINITIONS 33 | # define ENABLE_BIT_DEFINITIONS 1 /* Enable bit definitions */ 34 | #endif 35 | 36 | /* Include IAR headers */ 37 | #include 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 | -------------------------------------------------------------------------------- /libraries/DarkNetDisplay/DarkNetDisplay.h: -------------------------------------------------------------------------------- 1 | #ifndef _DARKNET_DISPLAY_H 2 | #define _DARKNET_DISPLAY_H 3 | 4 | #include 5 | #include "Arduino.h" 6 | #include "Print.h" 7 | 8 | #define swap(a, b) { int16_t t = a; a = b; b = t; } 9 | 10 | #define WIRE_WRITE Wire.write 11 | 12 | #define BLACK 0 13 | #define WHITE 1 14 | //#define INVERSE 2 15 | 16 | #define SSD1306_I2C_ADDRESS 0x3C // 011110+SA0+RW - 0x3C or 0x3D 17 | // Address for 128x32 is 0x3C 18 | // Address for 128x64 is 0x3D (default) or 0x3C (if SA0 is grounded) 19 | 20 | #define SSD1306_128_64 21 | 22 | #if defined SSD1306_128_64 23 | #define SSD1306_LCDWIDTH 128 24 | #define SSD1306_LCDHEIGHT 64 25 | #define HEIGHT SSD1306_LCDHEIGHT 26 | #define WIDTH SSD1306_LCDWIDTH 27 | #endif 28 | 29 | #define SSD1306_SETCONTRAST 0x81 30 | #define SSD1306_DISPLAYALLON_RESUME 0xA4 31 | #define SSD1306_DISPLAYALLON 0xA5 32 | #define SSD1306_NORMALDISPLAY 0xA6 33 | #define SSD1306_INVERTDISPLAY 0xA7 34 | #define SSD1306_DISPLAYOFF 0xAE 35 | #define SSD1306_DISPLAYON 0xAF 36 | 37 | #define SSD1306_SETDISPLAYOFFSET 0xD3 38 | #define SSD1306_SETCOMPINS 0xDA 39 | 40 | #define SSD1306_SETVCOMDETECT 0xDB 41 | 42 | #define SSD1306_SETDISPLAYCLOCKDIV 0xD5 43 | #define SSD1306_SETPRECHARGE 0xD9 44 | 45 | #define SSD1306_SETMULTIPLEX 0xA8 46 | 47 | #define SSD1306_SETLOWCOLUMN 0x00 48 | #define SSD1306_SETHIGHCOLUMN 0x10 49 | 50 | #define SSD1306_SETSTARTLINE 0x40 51 | 52 | #define SSD1306_MEMORYMODE 0x20 53 | #define SSD1306_COLUMNADDR 0x21 54 | #define SSD1306_PAGEADDR 0x22 55 | #define SSD1306_COMSCANINC 0xC0 56 | #define SSD1306_COMSCANDEC 0xC8 57 | 58 | #define SSD1306_SEGREMAP 0xA0 59 | 60 | #define SSD1306_CHARGEPUMP 0x8D 61 | 62 | #define SSD1306_EXTERNALVCC 0x1 63 | #define SSD1306_SWITCHCAPVCC 0x2 64 | 65 | // Scrolling #defines 66 | #define SSD1306_ACTIVATE_SCROLL 0x2F 67 | #define SSD1306_DEACTIVATE_SCROLL 0x2E 68 | #define SSD1306_SET_VERTICAL_SCROLL_AREA 0xA3 69 | #define SSD1306_RIGHT_HORIZONTAL_SCROLL 0x26 70 | #define SSD1306_LEFT_HORIZONTAL_SCROLL 0x27 71 | #define SSD1306_VERTICAL_AND_RIGHT_HORIZONTAL_SCROLL 0x29 72 | #define SSD1306_VERTICAL_AND_LEFT_HORIZONTAL_SCROLL 0x2A 73 | 74 | class DarkNetDisplay : public Print { 75 | 76 | public: 77 | DarkNetDisplay(int8_t RST); 78 | 79 | void drawLine(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, uint16_t color); 80 | void drawRect(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint16_t color); 81 | void fillRect(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint16_t color); 82 | void fillScreen(uint16_t color); 83 | void invertDisplay(boolean i); 84 | 85 | void 86 | drawCircle(uint8_t x0, uint8_t y0, uint8_t r, uint16_t color), 87 | drawCircleHelper(uint8_t x0, uint8_t y0, uint8_t r, uint8_t cornername, 88 | uint16_t color), 89 | fillCircle(uint8_t x0, uint8_t y0, uint8_t r, uint16_t color), 90 | fillCircleHelper(uint8_t x0, uint8_t y0, uint8_t r, uint8_t cornername, 91 | uint8_t delta, uint16_t color), 92 | drawRoundRect(uint8_t x0, uint8_t y0, uint8_t w, uint8_t h, 93 | uint8_t radius, uint16_t color), 94 | fillRoundRect(uint8_t x0, uint8_t y0, uint8_t w, uint8_t h, 95 | uint8_t radius, uint16_t color), 96 | drawChar(uint8_t x, uint8_t y, unsigned char c, uint16_t color, 97 | uint16_t bg, uint8_t size), 98 | setCursor(uint8_t x, uint8_t y), 99 | setTextColor(uint8_t c), 100 | setTextSize(uint8_t s), 101 | setTextWrap(boolean w), 102 | setRotation(uint8_t r); 103 | 104 | void begin(uint8_t switchvcc = SSD1306_SWITCHCAPVCC, uint8_t i2caddr = SSD1306_I2C_ADDRESS, bool reset=true); 105 | void ssd1306_command(uint8_t c); 106 | void ssd1306_data(uint8_t c); 107 | void clearDisplay(void); 108 | void invertDisplay(uint8_t i); 109 | void display(); 110 | void startscrollright(uint8_t start, uint8_t stop); 111 | void startscrollleft(uint8_t start, uint8_t stop); 112 | void startscrolldiagright(uint8_t start, uint8_t stop); 113 | void startscrolldiagleft(uint8_t start, uint8_t stop); 114 | void stopscroll(void); 115 | void dim(boolean dim); 116 | void drawPixel(uint8_t x, uint8_t y, uint16_t color); 117 | void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color); 118 | void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color); 119 | size_t write(uint8_t); 120 | 121 | uint8_t height(void) const; 122 | uint8_t width(void) const; 123 | uint8_t getRotation(void) const; 124 | // get current cursor position (get rotation safe maximum values, using: width() for x, height() for y) 125 | uint8_t getCursorX(void) const; 126 | uint8_t getCursorY(void) const; 127 | 128 | protected: 129 | uint8_t _width, _height, // Display w/h as modified by current rotation 130 | cursor_x, cursor_y; 131 | uint8_t 132 | textcolor:1, 133 | textsize:4, 134 | rotation:2, //max value is 3: 0-3 135 | wrap:1; // If set, 'wrap' text at right edge of display 136 | 137 | private: 138 | int8_t _i2caddr, _vccstate, rst; 139 | 140 | inline void drawFastVLineInternal(int16_t x, int16_t y, int16_t h, uint16_t color) __attribute__((always_inline)); 141 | inline void drawFastHLineInternal(int16_t x, int16_t y, int16_t w, uint16_t color) __attribute__((always_inline)); 142 | }; 143 | 144 | #endif 145 | -------------------------------------------------------------------------------- /libraries/UsbKeyboard/vusb-20121206/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 | */ 9 | 10 | /* 11 | General Description: 12 | This header is intended to contain all (or at least most of) the compiler 13 | and library dependent stuff. The C code is written for avr-gcc and avr-libc. 14 | The API of other development environments is converted to gcc's and avr-libc's 15 | API by means of defines. 16 | 17 | This header also contains all system includes since they depend on the 18 | development environment. 19 | 20 | Thanks to Oleg Semyonov for his help with the IAR tools port! 21 | */ 22 | 23 | #ifndef __usbportability_h_INCLUDED__ 24 | #define __usbportability_h_INCLUDED__ 25 | 26 | /* We check explicitly for IAR and CodeVision. Default is avr-gcc/avr-libc. */ 27 | 28 | /* ------------------------------------------------------------------------- */ 29 | #if defined __IAR_SYSTEMS_ICC__ || defined __IAR_SYSTEMS_ASM__ /* check for IAR */ 30 | /* ------------------------------------------------------------------------- */ 31 | 32 | #ifndef ENABLE_BIT_DEFINITIONS 33 | # define ENABLE_BIT_DEFINITIONS 1 /* Enable bit definitions */ 34 | #endif 35 | 36 | /* Include IAR headers */ 37 | #include 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 | -------------------------------------------------------------------------------- /libraries/UsbKeyboard/vusb-20121206/examples/hid-custom-rq/firmware/main.c: -------------------------------------------------------------------------------- 1 | /* Name: main.c 2 | * Project: hid-custom-rq example 3 | * Author: Christian Starkjohann 4 | * Creation Date: 2008-04-07 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 | */ 9 | 10 | /* 11 | This example should run on most AVRs with only little changes. No special 12 | hardware resources except INT0 are used. You may have to change usbconfig.h for 13 | different I/O pins for USB. Please note that USB D+ must be the INT0 pin, or 14 | at least be connected to INT0 as well. 15 | We assume that an LED is connected to port B bit 0. If you connect it to a 16 | different port or bit, change the macros below: 17 | */ 18 | #define LED_PORT_DDR DDRB 19 | #define LED_PORT_OUTPUT PORTB 20 | #define LED_BIT 0 21 | 22 | #include 23 | #include 24 | #include /* for sei() */ 25 | #include /* for _delay_ms() */ 26 | 27 | #include /* required by usbdrv.h */ 28 | #include "usbdrv.h" 29 | #include "oddebug.h" /* This is also an example for using debug macros */ 30 | #include "requests.h" /* The custom request numbers we use */ 31 | 32 | /* ------------------------------------------------------------------------- */ 33 | /* ----------------------------- USB interface ----------------------------- */ 34 | /* ------------------------------------------------------------------------- */ 35 | 36 | PROGMEM const char usbHidReportDescriptor[22] = { /* USB report descriptor */ 37 | 0x06, 0x00, 0xff, // USAGE_PAGE (Generic Desktop) 38 | 0x09, 0x01, // USAGE (Vendor Usage 1) 39 | 0xa1, 0x01, // COLLECTION (Application) 40 | 0x15, 0x00, // LOGICAL_MINIMUM (0) 41 | 0x26, 0xff, 0x00, // LOGICAL_MAXIMUM (255) 42 | 0x75, 0x08, // REPORT_SIZE (8) 43 | 0x95, 0x01, // REPORT_COUNT (1) 44 | 0x09, 0x00, // USAGE (Undefined) 45 | 0xb2, 0x02, 0x01, // FEATURE (Data,Var,Abs,Buf) 46 | 0xc0 // END_COLLECTION 47 | }; 48 | /* The descriptor above is a dummy only, it silences the drivers. The report 49 | * it describes consists of one byte of undefined data. 50 | * We don't transfer our data through HID reports, we use custom requests 51 | * instead. 52 | */ 53 | 54 | /* ------------------------------------------------------------------------- */ 55 | 56 | usbMsgLen_t usbFunctionSetup(uchar data[8]) 57 | { 58 | usbRequest_t *rq = (void *)data; 59 | 60 | if((rq->bmRequestType & USBRQ_TYPE_MASK) == USBRQ_TYPE_VENDOR){ 61 | DBG1(0x50, &rq->bRequest, 1); /* debug output: print our request */ 62 | if(rq->bRequest == CUSTOM_RQ_SET_STATUS){ 63 | if(rq->wValue.bytes[0] & 1){ /* set LED */ 64 | LED_PORT_OUTPUT |= _BV(LED_BIT); 65 | }else{ /* clear LED */ 66 | LED_PORT_OUTPUT &= ~_BV(LED_BIT); 67 | } 68 | }else if(rq->bRequest == CUSTOM_RQ_GET_STATUS){ 69 | static uchar dataBuffer[1]; /* buffer must stay valid when usbFunctionSetup returns */ 70 | dataBuffer[0] = ((LED_PORT_OUTPUT & _BV(LED_BIT)) != 0); 71 | usbMsgPtr = dataBuffer; /* tell the driver which data to return */ 72 | return 1; /* tell the driver to send 1 byte */ 73 | } 74 | }else{ 75 | /* calss requests USBRQ_HID_GET_REPORT and USBRQ_HID_SET_REPORT are 76 | * not implemented since we never call them. The operating system 77 | * won't call them either because our descriptor defines no meaning. 78 | */ 79 | } 80 | return 0; /* default for not implemented requests: return no data back to host */ 81 | } 82 | 83 | /* ------------------------------------------------------------------------- */ 84 | 85 | int __attribute__((noreturn)) main(void) 86 | { 87 | uchar i; 88 | 89 | wdt_enable(WDTO_1S); 90 | /* Even if you don't use the watchdog, turn it off here. On newer devices, 91 | * the status of the watchdog (on/off, period) is PRESERVED OVER RESET! 92 | */ 93 | /* RESET status: all port bits are inputs without pull-up. 94 | * That's the way we need D+ and D-. Therefore we don't need any 95 | * additional hardware initialization. 96 | */ 97 | odDebugInit(); 98 | DBG1(0x00, 0, 0); /* debug output: main starts */ 99 | usbInit(); 100 | usbDeviceDisconnect(); /* enforce re-enumeration, do this while interrupts are disabled! */ 101 | i = 0; 102 | while(--i){ /* fake USB disconnect for > 250 ms */ 103 | wdt_reset(); 104 | _delay_ms(1); 105 | } 106 | usbDeviceConnect(); 107 | LED_PORT_DDR |= _BV(LED_BIT); /* make the LED bit an output */ 108 | sei(); 109 | DBG1(0x01, 0, 0); /* debug output: main loop starts */ 110 | for(;;){ /* main event loop */ 111 | #if 0 /* this is a bit too aggressive for a debug output */ 112 | DBG2(0x02, 0, 0); /* debug output: main loop iterates */ 113 | #endif 114 | wdt_reset(); 115 | usbPoll(); 116 | } 117 | } 118 | 119 | /* ------------------------------------------------------------------------- */ 120 | -------------------------------------------------------------------------------- /software/fwupdate/AVRProg.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # 3 | # Test module to update DCDarkNet badges using avrdude 4 | # Right now it just reads the flash and eeprom using 5 | # avrispmkII, avr dragon isp, and FTDI(arduino) 6 | # 7 | # NOTE: EEPROM data seems to be invalid while using FTDI/arduino bootloader 8 | # 9 | import Adafruit_BBIO.GPIO as GPIO 10 | import SFLCDController 11 | import DummyLCDController 12 | import subprocess 13 | import tempfile 14 | import time 15 | import sys 16 | import os 17 | 18 | # Max number of '#' characters in progress bar 19 | AVRDUDE_PROGRESS_MAX = 50.0 20 | 21 | # 22 | # Supported programmers 23 | # 24 | PROGRAMMERS = { 'avrispmkII': 'usb', 25 | 'dragon_isp': 'usb', 26 | 'arduino': '/dev/ttyUSB0'} 27 | 28 | PROGRAMMER = None 29 | 30 | lcd = DummyLCDController.Controller() 31 | 32 | # 33 | # Strings that precede a progress bar in avrdude stderr output 34 | # along with the respective LCD string to display while this happens 35 | # 36 | pbStrings = [ ['reading flash memory','Reading Flash'], 37 | ['reading eeprom memory','Reading EEPROM'], 38 | ['reading on-chip flash data','Verify Flash'], 39 | ['writing flash','Write Flash'] ] 40 | 41 | errorStrings = [ ['No such device', 'ERR: Programmer'], 42 | ['did not find any USB device', 'ERR: Programmer'], 43 | ['Target not detected', 'ERR: No Target'] ] 44 | 45 | def getStringWithArray(line, stringArray): 46 | for index in range(len(stringArray)): 47 | if stringArray[index][0] in line: 48 | return stringArray[index][1] 49 | 50 | return None 51 | 52 | def getProgressBarString(line): 53 | return getStringWithArray(line, pbStrings) 54 | 55 | def getErrorString(line): 56 | return getStringWithArray(line, errorStrings) 57 | 58 | def runAvrdudeCommand(command, debugPrint = False): 59 | liveread = False 60 | line = '' # Current line being read 61 | hashCount = 0 # Number of '#'s which represent the progress bar 62 | 63 | proc = subprocess.Popen(command.split(' '), stderr=subprocess.PIPE) 64 | while proc.poll() is None: 65 | 66 | if liveread: 67 | char = proc.stderr.read(1) 68 | line += char 69 | 70 | # Display in serial console 71 | if debugPrint: 72 | sys.stdout.write(char) 73 | sys.stdout.flush() 74 | 75 | if char == '\n' or char == '\r': 76 | # Only finish 'progress bar' mode after a newline 77 | # when the progress bar is actually displayed 78 | if ('Reading' in line) or ('Writing' in line): 79 | liveread = False 80 | 81 | line = '' 82 | hashCount = 0 83 | 84 | # Progress bar is updating! 85 | if char == '#': 86 | hashCount += 1 87 | # Only update every other hash (since lcd is so slow) 88 | if hashCount % 2 == 0: 89 | progress = hashCount / AVRDUDE_PROGRESS_MAX 90 | lcd.setCursorPos(16) 91 | lcd.write(str(int(progress * 100)) + "%") 92 | 93 | else: 94 | line = proc.stderr.readline() 95 | 96 | errString = getErrorString(line) 97 | if errString: 98 | print(errString) 99 | lcd.clear() 100 | lcd.write(errString) 101 | 102 | pbString = getProgressBarString(line) 103 | if pbString: 104 | liveread = True 105 | line = '' 106 | lcd.clear() 107 | lcd.write(pbString) 108 | 109 | if debugPrint: 110 | if line != '': 111 | print(line.rstrip()) 112 | 113 | return proc.returncode 114 | 115 | def deleteFile(filename): 116 | try: 117 | os.remove(filename) 118 | except OSError: 119 | pass 120 | 121 | def readFlash(debugPrint = False): 122 | filename = tempfile.gettempdir() + '/flash.bin' 123 | deleteFile(filename) 124 | 125 | runAvrdudeCommand('avrdude -v -c ' + PROGRAMMER + ' -p m328p -P ' + PROGRAMMERS[PROGRAMMER] + ' -U flash:r:' + filename + ':r', debugPrint) 126 | 127 | if not os.path.isfile(filename): 128 | filename = None 129 | 130 | return filename 131 | 132 | def readEEPROM(debugPrint = False): 133 | filename = tempfile.gettempdir() + '/eeprom.bin' 134 | deleteFile(filename) 135 | 136 | runAvrdudeCommand('avrdude -v -c ' + PROGRAMMER + ' -p m328p -P ' + PROGRAMMERS[PROGRAMMER] + ' -U eeprom:r:' + filename + ':r', debugPrint) 137 | 138 | if not os.path.isfile(filename): 139 | filename = None 140 | 141 | return filename 142 | 143 | # Test function to dump eeprom file 144 | def dumpEEPROM(filename): 145 | f = open(filename, "rb") 146 | byteCount = 0 147 | try: 148 | byte = f.read(1) 149 | while byte != '': 150 | byteCount += 1 151 | sys.stdout.write(hex(ord(byte[0])) + ' ') 152 | if byteCount % 8 == 0: 153 | sys.stdout.write('\n') 154 | byte = f.read(1) 155 | 156 | 157 | sys.stdout.write('\n') 158 | 159 | finally: 160 | f.close() 161 | 162 | def dragonWait(): 163 | # The dragon doesn't like it when you try to re-connect too quickly 164 | if PROGRAMMER == 'dragon_isp': 165 | time.sleep(2) 166 | -------------------------------------------------------------------------------- /libraries/UsbKeyboard/vusb-20121206/examples/hid-data/firmware/main.c: -------------------------------------------------------------------------------- 1 | /* Name: main.c 2 | * Project: hid-data, example how to use HID for data transfer 3 | * Author: Christian Starkjohann 4 | * Creation Date: 2008-04-11 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 | */ 9 | 10 | /* 11 | This example should run on most AVRs with only little changes. No special 12 | hardware resources except INT0 are used. You may have to change usbconfig.h for 13 | different I/O pins for USB. Please note that USB D+ must be the INT0 pin, or 14 | at least be connected to INT0 as well. 15 | */ 16 | 17 | #include 18 | #include 19 | #include /* for sei() */ 20 | #include /* for _delay_ms() */ 21 | #include 22 | 23 | #include /* required by usbdrv.h */ 24 | #include "usbdrv.h" 25 | #include "oddebug.h" /* This is also an example for using debug macros */ 26 | 27 | /* ------------------------------------------------------------------------- */ 28 | /* ----------------------------- USB interface ----------------------------- */ 29 | /* ------------------------------------------------------------------------- */ 30 | 31 | PROGMEM const char usbHidReportDescriptor[22] = { /* USB report descriptor */ 32 | 0x06, 0x00, 0xff, // USAGE_PAGE (Generic Desktop) 33 | 0x09, 0x01, // USAGE (Vendor Usage 1) 34 | 0xa1, 0x01, // COLLECTION (Application) 35 | 0x15, 0x00, // LOGICAL_MINIMUM (0) 36 | 0x26, 0xff, 0x00, // LOGICAL_MAXIMUM (255) 37 | 0x75, 0x08, // REPORT_SIZE (8) 38 | 0x95, 0x80, // REPORT_COUNT (128) 39 | 0x09, 0x00, // USAGE (Undefined) 40 | 0xb2, 0x02, 0x01, // FEATURE (Data,Var,Abs,Buf) 41 | 0xc0 // END_COLLECTION 42 | }; 43 | /* Since we define only one feature report, we don't use report-IDs (which 44 | * would be the first byte of the report). The entire report consists of 128 45 | * opaque data bytes. 46 | */ 47 | 48 | /* The following variables store the status of the current data transfer */ 49 | static uchar currentAddress; 50 | static uchar bytesRemaining; 51 | 52 | /* ------------------------------------------------------------------------- */ 53 | 54 | /* usbFunctionRead() is called when the host requests a chunk of data from 55 | * the device. For more information see the documentation in usbdrv/usbdrv.h. 56 | */ 57 | uchar usbFunctionRead(uchar *data, uchar len) 58 | { 59 | if(len > bytesRemaining) 60 | len = bytesRemaining; 61 | eeprom_read_block(data, (uchar *)0 + currentAddress, len); 62 | currentAddress += len; 63 | bytesRemaining -= len; 64 | return len; 65 | } 66 | 67 | /* usbFunctionWrite() is called when the host sends a chunk of data to the 68 | * device. For more information see the documentation in usbdrv/usbdrv.h. 69 | */ 70 | uchar usbFunctionWrite(uchar *data, uchar len) 71 | { 72 | if(bytesRemaining == 0) 73 | return 1; /* end of transfer */ 74 | if(len > bytesRemaining) 75 | len = bytesRemaining; 76 | eeprom_write_block(data, (uchar *)0 + currentAddress, len); 77 | currentAddress += len; 78 | bytesRemaining -= len; 79 | return bytesRemaining == 0; /* return 1 if this was the last chunk */ 80 | } 81 | 82 | /* ------------------------------------------------------------------------- */ 83 | 84 | usbMsgLen_t usbFunctionSetup(uchar data[8]) 85 | { 86 | usbRequest_t *rq = (void *)data; 87 | 88 | if((rq->bmRequestType & USBRQ_TYPE_MASK) == USBRQ_TYPE_CLASS){ /* HID class request */ 89 | if(rq->bRequest == USBRQ_HID_GET_REPORT){ /* wValue: ReportType (highbyte), ReportID (lowbyte) */ 90 | /* since we have only one report type, we can ignore the report-ID */ 91 | bytesRemaining = 128; 92 | currentAddress = 0; 93 | return USB_NO_MSG; /* use usbFunctionRead() to obtain data */ 94 | }else if(rq->bRequest == USBRQ_HID_SET_REPORT){ 95 | /* since we have only one report type, we can ignore the report-ID */ 96 | bytesRemaining = 128; 97 | currentAddress = 0; 98 | return USB_NO_MSG; /* use usbFunctionWrite() to receive data from host */ 99 | } 100 | }else{ 101 | /* ignore vendor type requests, we don't use any */ 102 | } 103 | return 0; 104 | } 105 | 106 | /* ------------------------------------------------------------------------- */ 107 | 108 | int main(void) 109 | { 110 | uchar i; 111 | 112 | wdt_enable(WDTO_1S); 113 | /* Even if you don't use the watchdog, turn it off here. On newer devices, 114 | * the status of the watchdog (on/off, period) is PRESERVED OVER RESET! 115 | */ 116 | /* RESET status: all port bits are inputs without pull-up. 117 | * That's the way we need D+ and D-. Therefore we don't need any 118 | * additional hardware initialization. 119 | */ 120 | odDebugInit(); 121 | DBG1(0x00, 0, 0); /* debug output: main starts */ 122 | usbInit(); 123 | usbDeviceDisconnect(); /* enforce re-enumeration, do this while interrupts are disabled! */ 124 | i = 0; 125 | while(--i){ /* fake USB disconnect for > 250 ms */ 126 | wdt_reset(); 127 | _delay_ms(1); 128 | } 129 | usbDeviceConnect(); 130 | sei(); 131 | DBG1(0x01, 0, 0); /* debug output: main loop starts */ 132 | for(;;){ /* main event loop */ 133 | DBG1(0x02, 0, 0); /* debug output: main loop iterates */ 134 | wdt_reset(); 135 | usbPoll(); 136 | } 137 | return 0; 138 | } 139 | 140 | /* ------------------------------------------------------------------------- */ 141 | -------------------------------------------------------------------------------- /libraries/UsbKeyboard/vusb-20121206/examples/hid-custom-rq/commandline/set-led.c: -------------------------------------------------------------------------------- 1 | /* Name: set-led.c 2 | * Project: hid-custom-rq example 3 | * Author: Christian Starkjohann 4 | * Creation Date: 2008-04-10 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 | */ 9 | 10 | /* 11 | General Description: 12 | This is the host-side driver for the custom-class example device. It searches 13 | the USB for the LEDControl device and sends the requests understood by this 14 | device. 15 | This program must be linked with libusb on Unix and libusb-win32 on Windows. 16 | See http://libusb.sourceforge.net/ or http://libusb-win32.sourceforge.net/ 17 | respectively. 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | #include /* this is libusb */ 24 | #include "opendevice.h" /* common code moved to separate module */ 25 | 26 | #include "../firmware/requests.h" /* custom request numbers */ 27 | #include "../firmware/usbconfig.h" /* device's VID/PID and names */ 28 | 29 | static void usage(char *name) 30 | { 31 | fprintf(stderr, "usage:\n"); 32 | fprintf(stderr, " %s on ....... turn on LED\n", name); 33 | fprintf(stderr, " %s off ...... turn off LED\n", name); 34 | fprintf(stderr, " %s status ... ask current status of LED\n", name); 35 | #if ENABLE_TEST 36 | fprintf(stderr, " %s test ..... run driver reliability test\n", name); 37 | #endif /* ENABLE_TEST */ 38 | } 39 | 40 | int main(int argc, char **argv) 41 | { 42 | usb_dev_handle *handle = NULL; 43 | const unsigned char rawVid[2] = {USB_CFG_VENDOR_ID}, rawPid[2] = {USB_CFG_DEVICE_ID}; 44 | char vendor[] = {USB_CFG_VENDOR_NAME, 0}, product[] = {USB_CFG_DEVICE_NAME, 0}; 45 | char buffer[4]; 46 | int cnt, vid, pid, isOn; 47 | 48 | usb_init(); 49 | if(argc < 2){ /* we need at least one argument */ 50 | usage(argv[0]); 51 | exit(1); 52 | } 53 | /* compute VID/PID from usbconfig.h so that there is a central source of information */ 54 | vid = rawVid[1] * 256 + rawVid[0]; 55 | pid = rawPid[1] * 256 + rawPid[0]; 56 | /* The following function is in opendevice.c: */ 57 | if(usbOpenDevice(&handle, vid, vendor, pid, product, NULL, NULL, NULL) != 0){ 58 | fprintf(stderr, "Could not find USB device \"%s\" with vid=0x%x pid=0x%x\n", product, vid, pid); 59 | exit(1); 60 | } 61 | /* Since we use only control endpoint 0, we don't need to choose a 62 | * configuration and interface. Reading device descriptor and setting a 63 | * configuration and interface is done through endpoint 0 after all. 64 | * However, newer versions of Linux require that we claim an interface 65 | * even for endpoint 0. Enable the following code if your operating system 66 | * needs it: */ 67 | #if 0 68 | int retries = 1, usbConfiguration = 1, usbInterface = 0; 69 | if(usb_set_configuration(handle, usbConfiguration) && showWarnings){ 70 | fprintf(stderr, "Warning: could not set configuration: %s\n", usb_strerror()); 71 | } 72 | /* now try to claim the interface and detach the kernel HID driver on 73 | * Linux and other operating systems which support the call. */ 74 | while((len = usb_claim_interface(handle, usbInterface)) != 0 && retries-- > 0){ 75 | #ifdef LIBUSB_HAS_DETACH_KERNEL_DRIVER_NP 76 | if(usb_detach_kernel_driver_np(handle, 0) < 0 && showWarnings){ 77 | fprintf(stderr, "Warning: could not detach kernel driver: %s\n", usb_strerror()); 78 | } 79 | #endif 80 | } 81 | #endif 82 | 83 | if(strcasecmp(argv[1], "status") == 0){ 84 | cnt = usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_IN, CUSTOM_RQ_GET_STATUS, 0, 0, buffer, sizeof(buffer), 5000); 85 | if(cnt < 1){ 86 | if(cnt < 0){ 87 | fprintf(stderr, "USB error: %s\n", usb_strerror()); 88 | }else{ 89 | fprintf(stderr, "only %d bytes received.\n", cnt); 90 | } 91 | }else{ 92 | printf("LED is %s\n", buffer[0] ? "on" : "off"); 93 | } 94 | }else if((isOn = (strcasecmp(argv[1], "on") == 0)) || strcasecmp(argv[1], "off") == 0){ 95 | cnt = usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, CUSTOM_RQ_SET_STATUS, isOn, 0, buffer, 0, 5000); 96 | if(cnt < 0){ 97 | fprintf(stderr, "USB error: %s\n", usb_strerror()); 98 | } 99 | #if ENABLE_TEST 100 | }else if(strcasecmp(argv[1], "test") == 0){ 101 | int i; 102 | srandomdev(); 103 | for(i = 0; i < 50000; i++){ 104 | int value = random() & 0xffff, index = random() & 0xffff; 105 | int rxValue, rxIndex; 106 | if((i+1) % 100 == 0){ 107 | fprintf(stderr, "\r%05d", i+1); 108 | fflush(stderr); 109 | } 110 | cnt = usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_IN, CUSTOM_RQ_ECHO, value, index, buffer, sizeof(buffer), 5000); 111 | if(cnt < 0){ 112 | fprintf(stderr, "\nUSB error in iteration %d: %s\n", i, usb_strerror()); 113 | break; 114 | }else if(cnt != 4){ 115 | fprintf(stderr, "\nerror in iteration %d: %d bytes received instead of 4\n", i, cnt); 116 | break; 117 | } 118 | rxValue = ((int)buffer[0] & 0xff) | (((int)buffer[1] & 0xff) << 8); 119 | rxIndex = ((int)buffer[2] & 0xff) | (((int)buffer[3] & 0xff) << 8); 120 | if(rxValue != value || rxIndex != index){ 121 | fprintf(stderr, "\ndata error in iteration %d:\n", i); 122 | fprintf(stderr, "rxValue = 0x%04x value = 0x%04x\n", rxValue, value); 123 | fprintf(stderr, "rxIndex = 0x%04x index = 0x%04x\n", rxIndex, index); 124 | } 125 | } 126 | fprintf(stderr, "\nTest completed.\n"); 127 | #endif /* ENABLE_TEST */ 128 | }else{ 129 | usage(argv[0]); 130 | exit(1); 131 | } 132 | usb_close(handle); 133 | return 0; 134 | } 135 | -------------------------------------------------------------------------------- /libraries/UsbKeyboard/vusb-20121206/examples/custom-class/commandline/set-led.c: -------------------------------------------------------------------------------- 1 | /* Name: set-led.c 2 | * Project: custom-class, a basic USB example 3 | * Author: Christian Starkjohann 4 | * Creation Date: 2008-04-10 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 | */ 9 | 10 | /* 11 | General Description: 12 | This is the host-side driver for the custom-class example device. It searches 13 | the USB for the LEDControl device and sends the requests understood by this 14 | device. 15 | This program must be linked with libusb on Unix and libusb-win32 on Windows. 16 | See http://libusb.sourceforge.net/ or http://libusb-win32.sourceforge.net/ 17 | respectively. 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | #include /* this is libusb */ 24 | #include "opendevice.h" /* common code moved to separate module */ 25 | 26 | #include "../firmware/requests.h" /* custom request numbers */ 27 | #include "../firmware/usbconfig.h" /* device's VID/PID and names */ 28 | 29 | static void usage(char *name) 30 | { 31 | fprintf(stderr, "usage:\n"); 32 | fprintf(stderr, " %s on ....... turn on LED\n", name); 33 | fprintf(stderr, " %s off ...... turn off LED\n", name); 34 | fprintf(stderr, " %s status ... ask current status of LED\n", name); 35 | #if ENABLE_TEST 36 | fprintf(stderr, " %s test ..... run driver reliability test\n", name); 37 | #endif /* ENABLE_TEST */ 38 | } 39 | 40 | int main(int argc, char **argv) 41 | { 42 | usb_dev_handle *handle = NULL; 43 | const unsigned char rawVid[2] = {USB_CFG_VENDOR_ID}, rawPid[2] = {USB_CFG_DEVICE_ID}; 44 | char vendor[] = {USB_CFG_VENDOR_NAME, 0}, product[] = {USB_CFG_DEVICE_NAME, 0}; 45 | char buffer[4]; 46 | int cnt, vid, pid, isOn; 47 | 48 | usb_init(); 49 | if(argc < 2){ /* we need at least one argument */ 50 | usage(argv[0]); 51 | exit(1); 52 | } 53 | /* compute VID/PID from usbconfig.h so that there is a central source of information */ 54 | vid = rawVid[1] * 256 + rawVid[0]; 55 | pid = rawPid[1] * 256 + rawPid[0]; 56 | /* The following function is in opendevice.c: */ 57 | if(usbOpenDevice(&handle, vid, vendor, pid, product, NULL, NULL, NULL) != 0){ 58 | fprintf(stderr, "Could not find USB device \"%s\" with vid=0x%x pid=0x%x\n", product, vid, pid); 59 | exit(1); 60 | } 61 | /* Since we use only control endpoint 0, we don't need to choose a 62 | * configuration and interface. Reading device descriptor and setting a 63 | * configuration and interface is done through endpoint 0 after all. 64 | * However, newer versions of Linux require that we claim an interface 65 | * even for endpoint 0. Enable the following code if your operating system 66 | * needs it: */ 67 | #if 0 68 | int retries = 1, usbConfiguration = 1, usbInterface = 0; 69 | if(usb_set_configuration(handle, usbConfiguration) && showWarnings){ 70 | fprintf(stderr, "Warning: could not set configuration: %s\n", usb_strerror()); 71 | } 72 | /* now try to claim the interface and detach the kernel HID driver on 73 | * Linux and other operating systems which support the call. */ 74 | while((len = usb_claim_interface(handle, usbInterface)) != 0 && retries-- > 0){ 75 | #ifdef LIBUSB_HAS_DETACH_KERNEL_DRIVER_NP 76 | if(usb_detach_kernel_driver_np(handle, 0) < 0 && showWarnings){ 77 | fprintf(stderr, "Warning: could not detach kernel driver: %s\n", usb_strerror()); 78 | } 79 | #endif 80 | } 81 | #endif 82 | 83 | if(strcasecmp(argv[1], "status") == 0){ 84 | cnt = usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_IN, CUSTOM_RQ_GET_STATUS, 0, 0, buffer, sizeof(buffer), 5000); 85 | if(cnt < 1){ 86 | if(cnt < 0){ 87 | fprintf(stderr, "USB error: %s\n", usb_strerror()); 88 | }else{ 89 | fprintf(stderr, "only %d bytes received.\n", cnt); 90 | } 91 | }else{ 92 | printf("LED is %s\n", buffer[0] ? "on" : "off"); 93 | } 94 | }else if((isOn = (strcasecmp(argv[1], "on") == 0)) || strcasecmp(argv[1], "off") == 0){ 95 | cnt = usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, CUSTOM_RQ_SET_STATUS, isOn, 0, buffer, 0, 5000); 96 | if(cnt < 0){ 97 | fprintf(stderr, "USB error: %s\n", usb_strerror()); 98 | } 99 | #if ENABLE_TEST 100 | }else if(strcasecmp(argv[1], "test") == 0){ 101 | int i; 102 | srandomdev(); 103 | for(i = 0; i < 50000; i++){ 104 | int value = random() & 0xffff, index = random() & 0xffff; 105 | int rxValue, rxIndex; 106 | if((i+1) % 100 == 0){ 107 | fprintf(stderr, "\r%05d", i+1); 108 | fflush(stderr); 109 | } 110 | cnt = usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_IN, CUSTOM_RQ_ECHO, value, index, buffer, sizeof(buffer), 5000); 111 | if(cnt < 0){ 112 | fprintf(stderr, "\nUSB error in iteration %d: %s\n", i, usb_strerror()); 113 | break; 114 | }else if(cnt != 4){ 115 | fprintf(stderr, "\nerror in iteration %d: %d bytes received instead of 4\n", i, cnt); 116 | break; 117 | } 118 | rxValue = ((int)buffer[0] & 0xff) | (((int)buffer[1] & 0xff) << 8); 119 | rxIndex = ((int)buffer[2] & 0xff) | (((int)buffer[3] & 0xff) << 8); 120 | if(rxValue != value || rxIndex != index){ 121 | fprintf(stderr, "\ndata error in iteration %d:\n", i); 122 | fprintf(stderr, "rxValue = 0x%04x value = 0x%04x\n", rxValue, value); 123 | fprintf(stderr, "rxIndex = 0x%04x index = 0x%04x\n", rxIndex, index); 124 | } 125 | } 126 | fprintf(stderr, "\nTest completed.\n"); 127 | #endif /* ENABLE_TEST */ 128 | }else{ 129 | usage(argv[0]); 130 | exit(1); 131 | } 132 | usb_close(handle); 133 | return 0; 134 | } 135 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | hhvkit 2 | ====== 3 | 4 | DefCon 23 Hardware Hacking Village Learn To Solder Kit, by: 5 | - Smitty, mark@halibut.com (concept, crypto, and firmware (2014)) 6 | - Krux, krux@thcnet.net (hardware) 7 | - Cmdc0de, comc0dez@gmail.com (firmware (2015)) 8 | 9 | These are the files needed to build the firmware for the DefCon DarkNet 10 | ID Badge that was sold as the Hardware Hacking Village's Learn To Solder 11 | kit at DefCon 23 in 2015. 12 | 13 | If you checkout the repo into your Arduino folder, it should just build 14 | on Arduino v1.6.4. 15 | 16 | It creates the following directories: 17 | 18 | DCDarkNet/Firmware/ 19 | - Contains the code. 20 | 21 | DCDarkNet/Firmware/build/ 22 | - The automated build/burn system used to program over 300 chips in 23 | just a couple hours. (ZIF socket not included. Some assembly required.) 24 | 25 | libraries/IRSerial2014/ 26 | - A modified version of SoftwareSerial from Arduino 1.0 (don't know if 27 | it's changed at all in 1.5) to allow for independent inverted logic 28 | on the Rx and Tx lines (so the idle state isn't HIGH on the IR LED 29 | and burn through battery), and to perform 38kHz modulation for the IR. 30 | 31 | libraries/UsbKeyboard/ 32 | - A version of vusb-for-arduino [1] modified so it doesn't instantiate 33 | the USB object in the .h file and therefore immeidately upon startup. 34 | Instead, you instantiate the object whenever you want it and can 35 | delete it when you're done. 36 | [1] https://code.google.com/p/vusb-for-arduino/ 37 | 38 | 39 | libraries/DarkNetDisplay 40 | - Modified version of the adafruit gfx and ssd_1306 libraries to work with our 41 | darknet badge display 42 | https://github.com/adafruit/Adafruit-GFX-Library 43 | https://github.com/adafruit/Adafruit_SSD1306 44 | 45 | Building and Burning 46 | ====== 47 | 48 | All the following commands are run inside DCDarkNet/Firmware/build/ 49 | This section is really only relevant if you are burning this code into 50 | a whole bunch of chips. If you're just burning your own chip, or are 51 | playing around with different code, you're better off just using the 52 | Arduino IDE to program the board directly with an FTDI cable. 53 | 54 | Preparation: GUIDs and private keys 55 | ====== 56 | The code is programmed to FLASH, but there are a few things needed in 57 | EEPROM before the badge is functional. If you have a chip from us, it 58 | was already programmed with your GUID and private key, which will persist 59 | through a re-flash. But if you have a new chip, you'll need to program 60 | your GUID and private key into the chip. 61 | 62 | We don't currently (2015-08-2) have a way to generate new GUIDs and 63 | keys for you, nor to take in GUIDs and keys from you to put into the DB. 64 | So you're welcome to play with this code and use it for other things, 65 | but unless you got a chip from us at DefCon, you won't be able to 66 | use your code on the live DarkNet site (https://dcdark.net.) 67 | 68 | If you're building a whole new name space and don't need to interact 69 | with the DefCon DarkNet Daemon, you can generate your own DB of random 70 | GUIDs and private keys using the build/buildDB.pl script, and redirecting 71 | the output to a file called DB. This doesn't actually do anything with 72 | the chip, it just generates random numbers and formats them correctly. 73 | 74 | build$ ./buildDB.pl > DB 75 | 76 | Preparation: Program 77 | ======= 78 | All the source code is compiled down into a .hex file by Arduino. Those 79 | who do more microcontroller work than I do can build this by hand. I'm 80 | lazy and let Arduino do all the drudgery for me. 81 | 82 | Go to preferences and enable "verbose output of the build process" or 83 | whatever it's called. This will make Arduino NOT delete the temporary 84 | build directories it creates in /tmp. Then build the code with Ctrl-R. 85 | That will burn into /tmp/build[some number].tmp/ Find the most recent 86 | build directory (the one that was likely just created or updated), and 87 | copy Firmware.cpp.hex to your build/ directory: 88 | 89 | build$ cp /tmp/build[some number].tmp/Firmware.cpp.hex . 90 | 91 | You will have to do this EVERY TIME you build. 92 | 93 | Burning Chips 94 | ======= 95 | The burn-bootloader.sh script assumes you have a USBtinyISP [2]. You'll 96 | need to modify the avr-dude command if you have a different ISP. 97 | [2] http://www.adafruit.com/product/46 98 | 99 | Connect the USBtinyISP to the ICSP header on your board and run: 100 | 101 | build$ ./burn-bootloader.sh 102 | 103 | Congrats! Your badge is now an Arduino! It can be programmed through 104 | the FTDI header as if it were an Uno. 105 | 106 | But to make it a DarkNet ID Badge, it needs the GUID and private key in 107 | EEPROM, and the program in flash. 108 | 109 | The burn-eeprom.sh script takes a GUID on the command line, pulls it 110 | and it's associated key from the "DB" file generated above, formats 111 | them into a .hex file that avr-dude can burn to EEPROM, and burns it. 112 | Again, you'll need the USBtinyISP plugged into the ICSP header: 113 | 114 | build$ ./burn-eeprom.sh GUIDGUID 115 | 116 | After those two are done, the program can be written to flash using 117 | the FTDI serial console cable (it's much faster than using the ICSP.) 118 | burn-flash.sh takes the local file Firmware.cpp.hex you copied 119 | above. 120 | 121 | build$ ./burn-flash.sh 122 | 123 | Automating the Build 124 | ====== 125 | I wasn't about to run these three commands manually for 350 chips, so 126 | I wrote run.pl which pulls all the GUIDs from DB and cycles through 127 | them. If all is happy and working, you can just run.pl, hit enter to 128 | program a chip, swap the chip in the programming rig, hit enter again, 129 | lather, rinse, repeat. It takes care of all the iteration on GUID, 130 | as well as allows you to ext and

rev through the DB list in case 131 | a burn goes awry and needs to be redone. 132 | 133 | build$ ./run.pl 134 | 135 | BOM and Assembly Instructions 136 | ====== 137 | 138 | The Bill of Materials is located here: 139 | 140 | https://www.mouser.com/ProjectManager/ProjectDetail.aspx?AccessID=6bc2d848d8 141 | 142 | 143 | Assembly Instructions are located here: 144 | 145 | - https://dcdark.net/2015/hhv-badge/ 146 | - https://dcdark.net/2015/hhv-display/ 147 | 148 | --------------------------------------------------------------------------------