From f7832f9ce0838bdff7b3985e18378f63953bc86f Mon Sep 17 00:00:00 2001 From: Kai Lauterbach Date: Sat, 15 Oct 2011 11:31:15 +0200 Subject: [PATCH 01/38] Replaced with a more comfortable version. --- firmware/Makefile | 482 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 439 insertions(+), 43 deletions(-) diff --git a/firmware/Makefile b/firmware/Makefile index 4c59588..95d1425 100644 --- a/firmware/Makefile +++ b/firmware/Makefile @@ -1,66 +1,462 @@ -# Mini-LED-Cube 1.0 +# Hey Emacs, this is a -*- makefile -*- +# +# WinAVR makefile written by Eric B. Weddington, Jörg Wunsch, et al. +# Released to the Public Domain +# Please read the make user manual! +# +# Additional material for this makefile was submitted by: +# Tim Henigan +# Peter Fleury +# Reiner Patommel +# Sander Pool +# Frederik Rouleau +# Markus Pfaff +# +# On command line: +# +# make all = Make software. +# +# make clean = Clean out built project files. +# +# make coff = Convert ELF to AVR COFF (for use with AVR Studio 3.x or VMLAB). +# +# make extcoff = Convert ELF to AVR Extended COFF (for use with AVR Studio +# 4.07 or greater). +# +# make program = Download the hex file to the device, using avrdude. Please +# customize the avrdude settings below first! +# +# make filename.s = Just compile filename.c into the assembler code only +# +# To rebuild project do "make clean" then "make all". # -# Copyright (C) 2009 Paul Wilhelm -# http://mosfetkiller.de/?s=miniledcube -# Project specific settings -TARGET = miniledcube-1.0 +# mth 2004/09 +# Differences from WinAVR 20040720 sample: +# - DEPFLAGS according to Eric Weddingtion's fix (avrfreaks/gcc-forum) +# - F_CPU Define in CFLAGS and AFLAGS + + +# MCU name MCU = attiny2313 -SRC = main.c -# You probably want to change this to your own programming device +# Main Oscillator Frequency +# This is only used to define F_CPU in all assembler and c-sources. +F_CPU = 12000000UL -# AVR ISP mkII -PGMDEV = dragon_isp -PGMOPT = -P usb # Try -B 10 in case of programming errors +# 8MHz internal (basic firmware) +#LFUSE=0xE4 +# external clock +LFUSE=0xFF +HFUSE=0xDF -# Pony-STK200 -#PGMDEV = pony-stk200 -#PGMOPT = -E noreset +# Output format. (can be srec, ihex, binary) +FORMAT = ihex -# AVR-GCC and AVRDUDE need to be installed +# Target file name (without extension). +TARGET = main + + +# List C source files here. (C dependencies are automatically generated.) +SRC = $(TARGET).c usbdrv/usbdrv.c usb.c + + +# List Assembler source files here. +# Make them always end in a capital .S. Files ending in a lowercase .s +# will not be considered source files but generated files (assembler +# output from the compiler), and will be deleted upon "make clean"! +# Even though the DOS/Win* filesystem matches both .s and .S the same, +# it will preserve the spelling of the filenames, and gcc itself does +# care about how the name is spelled on its command-line. +ASRC = usbdrv/usbdrvasm.S + + + +# Optimization level, can be [0, 1, 2, 3, s]. +# 0 = turn off optimization. s = optimize for size. +# (Note: 3 is not always the best optimization level. See avr-libc FAQ.) +OPT = s + +# Debugging format. +# Native formats for AVR-GCC's -g are stabs [default], or dwarf-2. +# AVR (extended) COFF requires stabs, plus an avr-objcopy run. +#DEBUG = stabs +DEBUG = # dwarf-2 + +# List any extra directories to look for include files here. +# Each directory must be seperated by a space. +EXTRAINCDIRS = + + +# Compiler flag to set the C Standard level. +# c89 - "ANSI" C +# gnu89 - c89 plus GCC extensions +# c99 - ISO C99 standard (not yet fully implemented) +# gnu99 - c99 plus GCC extensions +CSTANDARD = -std=gnu99 + +# Place -D or -U options here +CDEFS = + +# Place -I options here +CINCS = -Iusbdrv +#CINCS += -I../../avrlib +#CINCS += -I"C:\Users\klaute\Documents\My Dropbox\Privat\developing\avr\avrlib" + + +# Compiler flags. +# -g*: generate debugging information +# -O*: optimization level +# -f...: tuning, see GCC manual and avr-libc documentation +# -Wall...: warning level +# -Wa,...: tell GCC to pass this to the assembler. +# -adhlns...: create assembler listing +CFLAGS = #-g$(DEBUG) +CFLAGS += $(CDEFS) $(CINCS) +CFLAGS += -O$(OPT) +CFLAGS += -funsigned-char +#CFLAGS += -funsigned-bitfields +#CFLAGS += -fpack-struct +#CFLAGS += -fshort-enums +CFLAGS += -fno-split-wide-types +CFLAGS += -fno-move-loop-invariants +CFLAGS += -fno-tree-scev-cprop +#CFLAGS += -fno-inline-small-functions +#CFLAGS += -fno-tree-loop-optimize +#CFLAGS += -ffunction-sections +#CFLAGS += -fdata-sections +CFLAGS += -mcall-prologues +CFLAGS += -mtiny-stack +#CFLAGS += -mint8 +CFLAGS += -Wall -Wstrict-prototypes +CFLAGS += -Wa,-adhlns=$(<:.c=.lst) +CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) +CFLAGS += $(CSTANDARD) +CFLAGS += -DF_CPU=$(F_CPU) +CFLAGS += -ffunction-sections +CFLAGS += -fdata-sections +CFLAGS += -Wl,--gc-sections + + +# Assembler flags. +# -Wa,...: tell GCC to pass this to the assembler. +# -ahlms: create listing +# -gstabs: have the assembler create line number information; note that +# for use in COFF files, additional information about filenames +# and function names needs to be present in the assembler source +# files -- see avr-libc docs [FIXME: not yet described there] +ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs +ASFLAGS += -DF_CPU=$(F_CPU) + + +#Additional libraries. + +# Minimalistic printf version +PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min + +# Floating point printf version (requires MATH_LIB = -lm below) +PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt + +PRINTF_LIB = #$(PRINTF_LIB_MIN) + +# Minimalistic scanf version +SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min + +# Floating point + %[ scanf version (requires MATH_LIB = -lm below) +SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt + +SCANF_LIB = #$(SCANF_LIB_MIN) + +MATH_LIB = #-lm + +# External memory options + +# 64 KB of external RAM, starting after internal RAM (ATmega128!), +# used for variables (.data/.bss) and heap (malloc()). +#EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff + +# 64 KB of external RAM, starting after internal RAM (ATmega128!), +# only used for heap (malloc()). +#EXTMEMOPTS = -Wl,--defsym=__heap_start=0x801100,--defsym=__heap_end=0x80ffff + +EXTMEMOPTS = + +# Linker flags. +# -Wl,...: tell GCC to pass this to linker. +# -Map: create map file +# --cref: add cross reference to map file +LDFLAGS = -Wl,-Map=$(TARGET).map,--cref +LDFLAGS += $(EXTMEMOPTS) +LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB) +LDFLAGS += -Wl,--relax + +# Programming support using avrdude. Settings and variables. + +# Programming hardware: alf avr910 avrisp bascom bsd +# dt006 pavr picoweb pony-stk200 sp12 stk200 stk500 +# +# Type: avrdude -c ? +# to get a full listing. +# +AVRDUDE_PROGRAMMER = dragon_isp + +# com1 = serial port. Use lpt1 to connect to parallel port. +AVRDUDE_PORT = -P usb #-P com1 # programmer connected to serial device + +AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex +#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep + + +# Uncomment the following if you want avrdude's erase cycle counter. +# Note that this counter needs to be initialized first using -Yn, +# see avrdude manual. +#AVRDUDE_ERASE_COUNTER = -y + +# Uncomment the following if you do /not/ wish a verification to be +# performed after programming the device. +#AVRDUDE_NO_VERIFY = -V + +# Increase verbosity level. Please use this when submitting bug +# reports about avrdude. See +# to submit bug reports. +#AVRDUDE_VERBOSE = -v -v + +AVRDUDE_FLAGS = -p $(MCU) -c $(AVRDUDE_PROGRAMMER) $(AVRDUDE_PORT) +AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY) +AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE) +AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER) + + + +# --------------------------------------------------------------------------- + +# Define directories, if needed. +DIRAVR = c:/winavr +DIRAVRBIN = $(DIRAVR)/bin +DIRAVRUTILS = $(DIRAVR)/utils/bin +DIRINC = . +DIRLIB = $(DIRAVR)/avr/lib + + +# Define programs and commands. +SHELL = sh CC = avr-gcc OBJCOPY = avr-objcopy +OBJDUMP = avr-objdump +SIZE = avr-size +NM = avr-nm AVRDUDE = avrdude REMOVE = rm -f +COPY = cp -# Some C flags -CSTANDARD = gnu99 -CFLAGS = -Wall -O2 -help: + + +# Define Messages +# English +MSG_ERRORS_NONE = Errors: none +MSG_BEGIN = -------- begin -------- +MSG_END = -------- end -------- +MSG_SIZE_BEFORE = Size before: +MSG_SIZE_AFTER = Size after: +MSG_COFF = Converting to AVR COFF: +MSG_EXTENDED_COFF = Converting to AVR Extended COFF: +MSG_FLASH = Creating load file for Flash: +MSG_EEPROM = Creating load file for EEPROM: +MSG_EXTENDED_LISTING = Creating Extended Listing: +MSG_SYMBOL_TABLE = Creating Symbol Table: +MSG_LINKING = Linking: +MSG_COMPILING = Compiling: +MSG_ASSEMBLING = Assembling: +MSG_CLEANING = Cleaning project: + + + + +# Define all object files. +OBJ = $(SRC:.c=.o) $(ASRC:.S=.o) + +# Define all listing files. +LST = $(ASRC:.S=.lst) $(SRC:.c=.lst) + + +# Compiler flags to generate dependency files. +### GENDEPFLAGS = -Wp,-M,-MP,-MT,$(*F).o,-MF,.dep/$(@F).d +GENDEPFLAGS = -MD -MP -MF .dep/$(@F).d + +# Combine all necessary flags and optional flags. +# Add target processor to flags. +ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS) +ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS) + + + + + +# Default target. +all: begin gccversion sizebefore build sizeafter finished end + +build: elf hex eep lss sym + +elf: $(TARGET).elf +hex: $(TARGET).hex +eep: $(TARGET).eep +lss: $(TARGET).lss +sym: $(TARGET).sym + + + +# Eye candy. +# AVR Studio 3.x does not check make's exit code but relies on +# the following magic strings to be generated by the compile job. +begin: @echo - @echo "Availiable targets:" - @echo " help - Display this help" - @echo - @echo " compile - Compiles source code" - @echo " info - Outputs device memory information" - @echo " program - Programs the device" - @echo " clean - Deletes temporary files" - @echo " fuses - Writes fuse settings to device (necessary only once per device)" - @echo - @echo " all - Compile, info, program, clean" - @echo - @echo "IMPORTANT: Device programming may only be possible as super user" - @echo - @echo "See Makefile for contact information." + @echo $(MSG_BEGIN) + +finished: + @echo $(MSG_ERRORS_NONE) + +end: + @echo $(MSG_END) @echo -all: compile info program clean -compile: - @$(CC) -std=$(CSTANDARD) $(CFLAGS) -mmcu=$(MCU) $(SRC) -o $(TARGET).elf - @$(OBJCOPY) -O ihex -j .text -j .data $(TARGET).elf $(TARGET).hex +# Display size of file. +HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex +#ELFSIZE = $(SIZE) -A $(TARGET).elf +ELFSIZE = $(SIZE) --mcu=$(MCU) -C $(TARGET).elf +OBJSIZE = $(SIZE) -x *.o **/*.o +sizebefore: + @if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); echo; $(HEXSIZE); echo; fi -info: - avr-size $(TARGET).elf +sizeafter: + @if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); $(OBJSIZE); echo; $(HEXSIZE); echo; fi -program: - @$(AVRDUDE) -p $(MCU) -u -V -c $(PGMDEV) $(PGMOPT) -U flash:w:$(TARGET).hex:i + + +# Display compiler version information. +gccversion : + @$(CC) --version + + + +# Program the device. +program: $(TARGET).hex $(TARGET).eep + $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) + + + + +# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB. +COFFCONVERT=$(OBJCOPY) --debugging \ +--change-section-address .data-0x800000 \ +--change-section-address .bss-0x800000 \ +--change-section-address .noinit-0x800000 \ +--change-section-address .eeprom-0x810000 + + +coff: $(TARGET).elf + @echo + @echo $(MSG_COFF) $(TARGET).cof + $(COFFCONVERT) -O coff-avr $< $(TARGET).cof + + +extcoff: $(TARGET).elf + @echo + @echo $(MSG_EXTENDED_COFF) $(TARGET).cof + $(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof + + + +# Create final output files (.hex, .eep) from ELF output file. +%.hex: %.elf + @echo + @echo $(MSG_FLASH) $@ + $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@ + +%.eep: %.elf + @echo + @echo $(MSG_EEPROM) $@ + -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ + --change-section-lma .eeprom=0 -O $(FORMAT) $< $@ + +# Create extended listing file from ELF output file. +%.lss: %.elf + @echo + @echo $(MSG_EXTENDED_LISTING) $@ + $(OBJDUMP) -h -S $< > $@ + +# Create a symbol table from ELF output file. +%.sym: %.elf + @echo + @echo $(MSG_SYMBOL_TABLE) $@ + $(NM) -n $< > $@ + + + +# Link: create ELF output file from object files. +.SECONDARY : $(TARGET).elf +.PRECIOUS : $(OBJ) +%.elf: $(OBJ) + @echo + @echo $(MSG_LINKING) $@ + $(CC) $(ALL_CFLAGS) $(OBJ) --output $@ $(LDFLAGS) + + +# Compile: create object files from C source files. +%.o : %.c + @echo + @echo $(MSG_COMPILING) $< + $(CC) -c $(ALL_CFLAGS) $< -o $@ + + +# Compile: create assembler files from C source files. +%.s : %.c + $(CC) -S $(ALL_CFLAGS) $< -o $@ + + +# Assemble: create object files from assembler source files. +%.o : %.S + @echo + @echo $(MSG_ASSEMBLING) $< + $(CC) -c $(ALL_ASFLAGS) $< -o $@ + + + +# Target: clean project. +clean: begin clean_list finished end + +clean_list : + @echo + @echo $(MSG_CLEANING) + $(REMOVE) $(TARGET).hex + $(REMOVE) $(TARGET).eep + $(REMOVE) $(TARGET).obj + $(REMOVE) $(TARGET).cof + $(REMOVE) $(TARGET).elf + $(REMOVE) $(TARGET).map + $(REMOVE) $(TARGET).obj + $(REMOVE) $(TARGET).a90 + $(REMOVE) $(TARGET).sym + $(REMOVE) $(TARGET).lnk + $(REMOVE) $(TARGET).lss + $(REMOVE) $(OBJ) + $(REMOVE) $(LST) + $(REMOVE) $(SRC:.c=.s) + $(REMOVE) $(SRC:.c=.d) + $(REMOVE) .dep/* fuses: - @$(AVRDUDE) -p $(MCU) -u -V -c $(PGMDEV) $(PGMOPT) -U lfuse:w:0xE4:m -U hfuse:w:0xDF:m + $(AVRDUDE) $(AVRDUDE_FLAGS) -U lfuse:w:$(LFUSE):m -U hfuse:w:$(HFUSE):m + + +# Include the dependency files. +-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*) + + +# Listing of phony targets. +.PHONY : all begin finish end sizebefore sizeafter gccversion \ +build elf hex eep lss sym coff extcoff \ +clean clean_list program -clean: - @$(REMOVE) $(TARGET).elf From fb3374eca769d6a9bc3a8f27a72c9e5ac4c8f248 Mon Sep 17 00:00:00 2001 From: Kai Lauterbach Date: Wed, 19 Oct 2011 00:13:30 +0200 Subject: [PATCH 02/38] Fixing a bug in the schematics (and the pcb board) --- pcb/miniledcube.brd | Bin 30143 -> 26279 bytes pcb/miniledcube.sch | Bin 309421 -> 309421 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/pcb/miniledcube.brd b/pcb/miniledcube.brd index 4f61734a46488a83f6cd3a9a664a276d4fb967ef..759716d0a924bb4020f8a1df2d5b63939344509e 100644 GIT binary patch delta 5078 zcmaJ_e{5A(9si#D<2@ejw)b8;2cy8-<89DV+P>E^Fc4kKTajYRLOZ5K(%EkQfzenf z#w<0rnM(XI*JT}KBg&pll+BQVbb{L-n?ceUGqwaZF8<*r0b_JiLNx14w0=L|b5GxW zulM#eoOkZ$`#s;^=iKk*^}nlAmsK%2(MiwQL~f0<-TA`d<_AvyYM}dX-W@6WTIRXZ zojYH=oOG!0?9A!6#=dhoSwjJw49m}oAGo*Qm!^Ns|9SpW~AFnQc>}AWzVD;F_S}QTkD{l~wldIxZ;srdO z#N+d;2VCb(UQK6gNxC zmh$!H8NU;E#)OtFwFz#X%`b2;m}es>U!vq&D~OU`a_QAw5;QwO=><2z%FnpJwu&^7*HkXWH-_ zJrkq!*n-TT`#gpA(Y0>`d5}ga7xMn-^IT+}_k%nO=_GI7=h@pa>ZQ8;@Icp_DZg~c z%K>jF*3n^g!1}Vg-9^ARZr+C<`b3F1KlQQ>PQX*hT-5;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(J&cj>Y2m^zAC0{CFuX{DhRetva`FzIh9%^~wUA?z$5~(2hMQYUwMmND#J2quc2pduJbjw;pM~_CB*&L& z9n{wCSAtui$R`>5KpS(;Xpe~*Q0DnF+5k;|j;T51uIIFIeqtj-o(k>lfhH6lrD>ao zr%dr*rQxv}&!Kw1cb?2)DOA zVCz_?*PXI8#q*U>Fg-35^P7v>)A%Lm;sDJSo~KNz#G|78e_?nqx3GtUrO(Gs8~moL zE#Ee&-TnZZ?L<52NBz}rm)2bR3DUQ@JKJh9?~(o}`h)U}qd#cz;vs<1>_@GucpS>? z^CNGXPtttp3Rd%cs()S4^2H*yhh5dm8;h4|cB{dfUPbez8f}W7qM6r!)#BSmI&5{G zI*%<6|HHq;9;`N7u&uf6gC?;}ceH8QrrxQq{qk(KaO2}&wYJ8s=Aw;px|wLxremJ% zVeYSOy1%vGeUAFu?x@C|W}>~3-%K5z-VJry|t=86Q&Ic0ltS$cq+Zx+WwcxHy_OEy9YsWmr7};EeDyp%txp>CRbBL+{ Pqmx6Vn_q;8A71@`kfBQ` From b1b9c93fe83c2393c967a30bad50ae8c7e1ef0c8 Mon Sep 17 00:00:00 2001 From: Kai Lauterbach Date: Sat, 15 Oct 2011 11:31:44 +0200 Subject: [PATCH 03/38] V-USB support addad. --- firmware/usb.c | 79 +++ firmware/usb.h | 59 ++ firmware/usbconfig.h | 373 +++++++++++++ firmware/usbdrv/Changelog.txt | 308 +++++++++++ firmware/usbdrv/CommercialLicense.txt | 166 ++++++ firmware/usbdrv/License.txt | 361 +++++++++++++ firmware/usbdrv/Readme.txt | 172 ++++++ firmware/usbdrv/USB-ID-FAQ.txt | 149 +++++ firmware/usbdrv/USB-IDs-for-free.txt | 148 +++++ firmware/usbdrv/asmcommon.inc | 188 +++++++ firmware/usbdrv/oddebug.c | 50 ++ firmware/usbdrv/oddebug.h | 123 +++++ firmware/usbdrv/usbconfig-prototype.h | 376 +++++++++++++ firmware/usbdrv/usbdrv.c | 625 +++++++++++++++++++++ firmware/usbdrv/usbdrv.h | 735 +++++++++++++++++++++++++ firmware/usbdrv/usbdrvasm.S | 393 ++++++++++++++ firmware/usbdrv/usbdrvasm.asm | 21 + firmware/usbdrv/usbdrvasm12.inc | 393 ++++++++++++++ firmware/usbdrv/usbdrvasm128.inc | 750 ++++++++++++++++++++++++++ firmware/usbdrv/usbdrvasm15.inc | 423 +++++++++++++++ firmware/usbdrv/usbdrvasm16.inc | 346 ++++++++++++ firmware/usbdrv/usbdrvasm165.inc | 453 ++++++++++++++++ firmware/usbdrv/usbdrvasm18-crc.inc | 707 ++++++++++++++++++++++++ firmware/usbdrv/usbdrvasm20.inc | 360 +++++++++++++ firmware/usbdrv/usbportability.h | 144 +++++ 25 files changed, 7902 insertions(+) create mode 100644 firmware/usb.c create mode 100644 firmware/usb.h create mode 100644 firmware/usbconfig.h create mode 100644 firmware/usbdrv/Changelog.txt create mode 100644 firmware/usbdrv/CommercialLicense.txt create mode 100644 firmware/usbdrv/License.txt create mode 100644 firmware/usbdrv/Readme.txt create mode 100644 firmware/usbdrv/USB-ID-FAQ.txt create mode 100644 firmware/usbdrv/USB-IDs-for-free.txt create mode 100644 firmware/usbdrv/asmcommon.inc create mode 100644 firmware/usbdrv/oddebug.c create mode 100644 firmware/usbdrv/oddebug.h create mode 100644 firmware/usbdrv/usbconfig-prototype.h create mode 100644 firmware/usbdrv/usbdrv.c create mode 100644 firmware/usbdrv/usbdrv.h create mode 100644 firmware/usbdrv/usbdrvasm.S create mode 100644 firmware/usbdrv/usbdrvasm.asm create mode 100644 firmware/usbdrv/usbdrvasm12.inc create mode 100644 firmware/usbdrv/usbdrvasm128.inc create mode 100644 firmware/usbdrv/usbdrvasm15.inc create mode 100644 firmware/usbdrv/usbdrvasm16.inc create mode 100644 firmware/usbdrv/usbdrvasm165.inc create mode 100644 firmware/usbdrv/usbdrvasm18-crc.inc create mode 100644 firmware/usbdrv/usbdrvasm20.inc create mode 100644 firmware/usbdrv/usbportability.h diff --git a/firmware/usb.c b/firmware/usb.c new file mode 100644 index 0000000..fdcf4f5 --- /dev/null +++ b/firmware/usb.c @@ -0,0 +1,79 @@ +/* Name: usb.h by Kai Lauterbach + * Based on Project: hid-custom-rq example + * Revision: $Id: main.c 790 2010-05-30 21:00:26Z cs $ + * Author: Christian Starkjohann + * Copyright: (c) 2008 by OBJECTIVE DEVELOPMENT Software GmbH + * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) + */ + +#include "usb.h" + +/* ------------------------------------------------------------------------- */ + +usbMsgLen_t usbFunctionSetup(uchar data[8]) +{ +usbRequest_t *rq = (void *)data; + + if((rq->bmRequestType & USBRQ_TYPE_MASK) == USBRQ_TYPE_VENDOR){ + if(rq->bRequest == CUSTOM_RQ_SET_STATUS){ + + // receive animation data + + }else if(rq->bRequest == CUSTOM_RQ_GET_STATUS){ + //static uchar dataBuffer[1]; // buffer must stay valid when usbFunctionSetup returns + //dataBuffer[0] = ((LED_PORT_OUTPUT & _BV(LED_BIT)) != 0); + //usbMsgPtr = dataBuffer; // tell the driver which data to return + //return 1; // tell the driver to send 1 byte + return 0; // tell the driver to send 1 byte + } + }else{ + /* class requests USBRQ_HID_GET_REPORT and USBRQ_HID_SET_REPORT are + * not implemented since we never call them. The operating system + * won't call them either because our descriptor defines no meaning. + */ + } + return 0; /* default for not implemented requests: return no data back to host */ +} + +/* ------------------------------------------------------------------------- */ + +void init_usb(void) +{ + uchar i; + + usbInit(); + usbDeviceDisconnect(); /* enforce re-enumeration, do this while interrupts are disabled! */ + i = 0; + while(--i){ /* fake USB disconnect for > 250 ms */ + //wdt_reset(); + _delay_ms(1); + } + usbDeviceConnect(); + + sei(); // enable global interrupts + +} + +/* TODO add to the projects main + + init_usb(); + + // Even if you don't use the watchdog, turn it off here. On newer devices, + // the status of the watchdog (on/off, period) is PRESERVED OVER RESET! + // + // RESET status: all port bits are inputs without pull-up. + // That's the way we need D+ and D-. Therefore we don't need any + // additional hardware initialization. + wdt_enable(WDTO_1S); + + ...mainloop start... + + wdt_reset(); // we are alive, please dont reset the µC + usbPoll(); // keep the usb connection up + + ...end mainloop... + + +*/ + +/* ------------------------------------------------------------------------- */ diff --git a/firmware/usb.h b/firmware/usb.h new file mode 100644 index 0000000..eeae5c1 --- /dev/null +++ b/firmware/usb.h @@ -0,0 +1,59 @@ +/* Name: usb.h by Kai Lauterbach + * Based on Project: hid-custom-rq example + * Revision: $Id: main.c 790 2010-05-30 21:00:26Z cs $ + * Author: Christian Starkjohann + * Copyright: (c) 2008 by OBJECTIVE DEVELOPMENT Software GmbH + * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) + * This + */ + +#ifndef __usb_h__ +#define __usb_h__ + +/* +This example should run on most AVRs with only little changes. No special +hardware resources except INT0 are used. You may have to change usbconfig.h for +different I/O pins for USB. Please note that USB D+ must be the INT0 pin, or +at least be connected to INT0 as well. +We assume that an LED is connected to port B bit 0. If you connect it to a +different port or bit, change the macros below: +*/ + +#include +//#include +#include /* for sei() */ +#include /* for _delay_ms() */ + +#include /* required by usbdrv.h */ + +#include "usbconfig.h" +#include "usbdrv.h" +#include "requests.h" /* The custom request numbers we use */ + +/* ------------------------------------------------------------------------- */ +/* ----------------------------- USB interface ----------------------------- */ +/* ------------------------------------------------------------------------- */ + +PROGMEM char usbHidReportDescriptor[22] = { /* USB report descriptor */ + 0x06, 0x00, 0xff, // USAGE_PAGE (Generic Desktop) + 0x09, 0x01, // USAGE (Vendor Usage 1) + 0xa1, 0x01, // COLLECTION (Application) + 0x15, 0x00, // LOGICAL_MINIMUM (0) + 0x26, 0xff, 0x00, // LOGICAL_MAXIMUM (255) + 0x75, 0x08, // REPORT_SIZE (8) + 0x95, 0x01, // REPORT_COUNT (1) + 0x09, 0x00, // USAGE (Undefined) + 0xb2, 0x02, 0x01, // FEATURE (Data,Var,Abs,Buf) + 0xc0 // END_COLLECTION +}; +/* The descriptor above is a dummy only, it silences the drivers. The report + * it describes consists of one byte of undefined data. + * We don't transfer our data through HID reports, we use custom requests + * instead. + */ + +void init_usb(void); + + +#endif // __usb_h__ + diff --git a/firmware/usbconfig.h b/firmware/usbconfig.h new file mode 100644 index 0000000..2562001 --- /dev/null +++ b/firmware/usbconfig.h @@ -0,0 +1,373 @@ +/* Name: usbconfig.h + * Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers + * Author: Christian Starkjohann + * Creation Date: 2005-04-01 + * Tabsize: 4 + * Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH + * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) + * This Revision: $Id: usbconfig-prototype.h 785 2010-05-30 17:57:07Z cs $ + */ + +#ifndef __usbconfig_h_included__ +#define __usbconfig_h_included__ + +/* +General Description: +This file is an example configuration (with inline documentation) for the USB +driver. It configures V-USB for USB D+ connected to Port D bit 2 (which is +also hardware interrupt 0 on many devices) and USB D- to Port D bit 4. You may +wire the lines to any other port, as long as D+ is also wired to INT0 (or any +other hardware interrupt, as long as it is the highest level interrupt, see +section at the end of this file). +*/ + +/* ---------------------------- Hardware Config ---------------------------- */ + +#define USB_CFG_IOPORTNAME D +/* This is the port where the USB bus is connected. When you configure it to + * "B", the registers PORTB, PINB and DDRB will be used. + */ +#define USB_CFG_DMINUS_BIT 3 +/* This is the bit number in USB_CFG_IOPORT where the USB D- line is connected. + * This may be any bit in the port. + */ +#define USB_CFG_DPLUS_BIT 6 +/* This is the bit number in USB_CFG_IOPORT where the USB D+ line is connected. + * This may be any bit in the port. Please note that D+ must also be connected + * to interrupt pin INT0! [You can also use other interrupts, see section + * "Optional MCU Description" below, or you can connect D- to the interrupt, as + * it is required if you use the USB_COUNT_SOF feature. If you use D- for the + * interrupt, the USB interrupt will also be triggered at Start-Of-Frame + * markers every millisecond.] + */ +#define USB_CFG_CLOCK_KHZ (F_CPU/1000) +/* Clock rate of the AVR in kHz. Legal values are 12000, 12800, 15000, 16000, + * 16500, 18000 and 20000. The 12.8 MHz and 16.5 MHz versions of the code + * require no crystal, they tolerate +/- 1% deviation from the nominal + * frequency. All other rates require a precision of 2000 ppm and thus a + * crystal! + * Since F_CPU should be defined to your actual clock rate anyway, you should + * not need to modify this setting. + */ +#define USB_CFG_CHECK_CRC 0 +/* Define this to 1 if you want that the driver checks integrity of incoming + * data packets (CRC checks). CRC checks cost quite a bit of code size and are + * currently only available for 18 MHz crystal clock. You must choose + * USB_CFG_CLOCK_KHZ = 18000 if you enable this option. + */ + +/* ----------------------- Optional Hardware Config ------------------------ */ + +/* #define USB_CFG_PULLUP_IOPORTNAME D */ +/* If you connect the 1.5k pullup resistor from D- to a port pin instead of + * V+, you can connect and disconnect the device from firmware by calling + * the macros usbDeviceConnect() and usbDeviceDisconnect() (see usbdrv.h). + * This constant defines the port on which the pullup resistor is connected. + */ +/* #define USB_CFG_PULLUP_BIT 4 */ +/* This constant defines the bit number in USB_CFG_PULLUP_IOPORT (defined + * above) where the 1.5k pullup resistor is connected. See description + * above for details. + */ + +/* --------------------------- Functional Range ---------------------------- */ + +#define USB_CFG_HAVE_INTRIN_ENDPOINT 1 +/* Define this to 1 if you want to compile a version with two endpoints: The + * default control endpoint 0 and an interrupt-in endpoint (any other endpoint + * number). + */ +#define USB_CFG_HAVE_INTRIN_ENDPOINT3 0 +/* Define this to 1 if you want to compile a version with three endpoints: The + * default control endpoint 0, an interrupt-in endpoint 3 (or the number + * configured below) and a catch-all default interrupt-in endpoint as above. + * You must also define USB_CFG_HAVE_INTRIN_ENDPOINT to 1 for this feature. + */ +#define USB_CFG_EP3_NUMBER 3 +/* If the so-called endpoint 3 is used, it can now be configured to any other + * endpoint number (except 0) with this macro. Default if undefined is 3. + */ +/* #define USB_INITIAL_DATATOKEN USBPID_DATA1 */ +/* The above macro defines the startup condition for data toggling on the + * interrupt/bulk endpoints 1 and 3. Defaults to USBPID_DATA1. + * Since the token is toggled BEFORE sending any data, the first packet is + * sent with the oposite value of this configuration! + */ +#define USB_CFG_IMPLEMENT_HALT 0 +/* Define this to 1 if you also want to implement the ENDPOINT_HALT feature + * for endpoint 1 (interrupt endpoint). Although you may not need this feature, + * it is required by the standard. We have made it a config option because it + * bloats the code considerably. + */ +#define USB_CFG_SUPPRESS_INTR_CODE 0 +/* Define this to 1 if you want to declare interrupt-in endpoints, but don't + * want to send any data over them. If this macro is defined to 1, functions + * usbSetInterrupt() and usbSetInterrupt3() are omitted. This is useful if + * you need the interrupt-in endpoints in order to comply to an interface + * (e.g. HID), but never want to send any data. This option saves a couple + * of bytes in flash memory and the transmit buffers in RAM. + */ +#define USB_CFG_INTR_POLL_INTERVAL 10 +/* If you compile a version with endpoint 1 (interrupt-in), this is the poll + * interval. The value is in milliseconds and must not be less than 10 ms for + * low speed devices. + */ +#define USB_CFG_IS_SELF_POWERED 0 +/* Define this to 1 if the device has its own power supply. Set it to 0 if the + * device is powered from the USB bus. + */ +#define USB_CFG_MAX_BUS_POWER 200 +/* Set this variable to the maximum USB bus power consumption of your device. + * The value is in milliamperes. [It will be divided by two since USB + * communicates power requirements in units of 2 mA.] + */ +#define USB_CFG_IMPLEMENT_FN_WRITE 0 +/* Set this to 1 if you want usbFunctionWrite() to be called for control-out + * transfers. Set it to 0 if you don't need it and want to save a couple of + * bytes. + */ +#define USB_CFG_IMPLEMENT_FN_READ 0 +/* Set this to 1 if you need to send control replies which are generated + * "on the fly" when usbFunctionRead() is called. If you only want to send + * data from a static buffer, set it to 0 and return the data from + * usbFunctionSetup(). This saves a couple of bytes. + */ +#define USB_CFG_IMPLEMENT_FN_WRITEOUT 0 +/* Define this to 1 if you want to use interrupt-out (or bulk out) endpoints. + * You must implement the function usbFunctionWriteOut() which receives all + * interrupt/bulk data sent to any endpoint other than 0. The endpoint number + * can be found in 'usbRxToken'. + */ +#define USB_CFG_HAVE_FLOWCONTROL 0 +/* Define this to 1 if you want flowcontrol over USB data. See the definition + * of the macros usbDisableAllRequests() and usbEnableAllRequests() in + * usbdrv.h. + */ +#define USB_CFG_DRIVER_FLASH_PAGE 0 +/* If the device has more than 64 kBytes of flash, define this to the 64 k page + * where the driver's constants (descriptors) are located. Or in other words: + * Define this to 1 for boot loaders on the ATMega128. + */ +#define USB_CFG_LONG_TRANSFERS 0 +/* Define this to 1 if you want to send/receive blocks of more than 254 bytes + * in a single control-in or control-out transfer. Note that the capability + * for long transfers increases the driver size. + */ +/* #define USB_RX_USER_HOOK(data, len) if(usbRxToken == (uchar)USBPID_SETUP) blinkLED(); */ +/* This macro is a hook if you want to do unconventional things. If it is + * defined, it's inserted at the beginning of received message processing. + * If you eat the received message and don't want default processing to + * proceed, do a return after doing your things. One possible application + * (besides debugging) is to flash a status LED on each packet. + */ +/* #define USB_RESET_HOOK(resetStarts) if(!resetStarts){hadUsbReset();} */ +/* This macro is a hook if you need to know when an USB RESET occurs. It has + * one parameter which distinguishes between the start of RESET state and its + * end. + */ +/* #define USB_SET_ADDRESS_HOOK() hadAddressAssigned(); */ +/* This macro (if defined) is executed when a USB SET_ADDRESS request was + * received. + */ +#define USB_COUNT_SOF 0 +/* define this macro to 1 if you need the global variable "usbSofCount" which + * counts SOF packets. This feature requires that the hardware interrupt is + * connected to D- instead of D+. + */ +/* #ifdef __ASSEMBLER__ + * macro myAssemblerMacro + * in YL, TCNT0 + * sts timer0Snapshot, YL + * endm + * #endif + * #define USB_SOF_HOOK myAssemblerMacro + * This macro (if defined) is executed in the assembler module when a + * Start Of Frame condition is detected. It is recommended to define it to + * the name of an assembler macro which is defined here as well so that more + * than one assembler instruction can be used. The macro may use the register + * YL and modify SREG. If it lasts longer than a couple of cycles, USB messages + * immediately after an SOF pulse may be lost and must be retried by the host. + * What can you do with this hook? Since the SOF signal occurs exactly every + * 1 ms (unless the host is in sleep mode), you can use it to tune OSCCAL in + * designs running on the internal RC oscillator. + * Please note that Start Of Frame detection works only if D- is wired to the + * interrupt, not D+. THIS IS DIFFERENT THAN MOST EXAMPLES! + */ +#define USB_CFG_CHECK_DATA_TOGGLING 0 +/* define this macro to 1 if you want to filter out duplicate data packets + * sent by the host. Duplicates occur only as a consequence of communication + * errors, when the host does not receive an ACK. Please note that you need to + * implement the filtering yourself in usbFunctionWriteOut() and + * usbFunctionWrite(). Use the global usbCurrentDataToken and a static variable + * for each control- and out-endpoint to check for duplicate packets. + */ +#define USB_CFG_HAVE_MEASURE_FRAME_LENGTH 0 +/* define this macro to 1 if you want the function usbMeasureFrameLength() + * compiled in. This function can be used to calibrate the AVR's RC oscillator. + */ +#define USB_USE_FAST_CRC 0 +/* The assembler module has two implementations for the CRC algorithm. One is + * faster, the other is smaller. This CRC routine is only used for transmitted + * messages where timing is not critical. The faster routine needs 31 cycles + * per byte while the smaller one needs 61 to 69 cycles. The faster routine + * may be worth the 32 bytes bigger code size if you transmit lots of data and + * run the AVR close to its limit. + */ + +/* -------------------------- Device Description --------------------------- */ + +#define USB_CFG_VENDOR_ID 0xc0, 0x16 /* = 0x16c0 = 5824 = voti.nl */ +/* USB vendor ID for the device, low byte first. If you have registered your + * own Vendor ID, define it here. Otherwise you may use one of obdev's free + * shared VID/PID pairs. Be sure to read USB-IDs-for-free.txt for rules! + * *** IMPORTANT NOTE *** + * This template uses obdev's shared VID/PID pair for Vendor Class devices + * with libusb: 0x16c0/0x5dc. Use this VID/PID pair ONLY if you understand + * the implications! + */ +#define USB_CFG_DEVICE_ID 0xdf, 0x05 /* obdev's shared PID for HIDs */ +/* This is the ID of the product, low byte first. It is interpreted in the + * scope of the vendor ID. If you have registered your own VID with usb.org + * or if you have licensed a PID from somebody else, define it here. Otherwise + * you may use one of obdev's free shared VID/PID pairs. See the file + * USB-IDs-for-free.txt for details! + * *** IMPORTANT NOTE *** + * This template uses obdev's shared VID/PID pair for Vendor Class devices + * with libusb: 0x16c0/0x5dc. Use this VID/PID pair ONLY if you understand + * the implications! + */ +#define USB_CFG_DEVICE_VERSION 0x00, 0x01 +/* Version number of the device: Minor number first, then major number. + */ +#define USB_CFG_VENDOR_NAME 'C', 'T', 'H', 'N', '.', 'd', 'e' +#define USB_CFG_VENDOR_NAME_LEN 7 +/* These two values define the vendor name returned by the USB device. The name + * must be given as a list of characters under single quotes. The characters + * are interpreted as Unicode (UTF-16) entities. + * If you don't want a vendor name string, undefine these macros. + * ALWAYS define a vendor name containing your Internet domain name if you use + * obdev's free shared VID/PID pair. See the file USB-IDs-for-free.txt for + * details. + */ +#define USB_CFG_DEVICE_NAME 'M', 'i', 'n', 'i', 'L', 'E', 'D', 'C', 'u', 'b', 'e' +#define USB_CFG_DEVICE_NAME_LEN 11 +/* Same as above for the device name. If you don't want a device name, undefine + * the macros. See the file USB-IDs-for-free.txt before you assign a name if + * you use a shared VID/PID. + */ +/*#define USB_CFG_SERIAL_NUMBER 'N', 'o', 'n', 'e' */ +/*#define USB_CFG_SERIAL_NUMBER_LEN 0 */ +/* Same as above for the serial number. If you don't want a serial number, + * undefine the macros. + * It may be useful to provide the serial number through other means than at + * compile time. See the section about descriptor properties below for how + * to fine tune control over USB descriptors such as the string descriptor + * for the serial number. + */ +#define USB_CFG_DEVICE_CLASS 0 +#define USB_CFG_DEVICE_SUBCLASS 0 +/* See USB specification if you want to conform to an existing device class. + * Class 0xff is "vendor specific". + */ +#define USB_CFG_INTERFACE_CLASS 3 +#define USB_CFG_INTERFACE_SUBCLASS 0 +#define USB_CFG_INTERFACE_PROTOCOL 0 +/* See USB specification if you want to conform to an existing device class or + * protocol. The following classes must be set at interface level: + * HID class is 3, no subclass and protocol required (but may be useful!) + * CDC class is 2, use subclass 2 and protocol 1 for ACM + */ +#define USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH 22 +/* Define this to the length of the HID report descriptor, if you implement + * an HID device. Otherwise don't define it or define it to 0. + * If you use this define, you must add a PROGMEM character array named + * "usbHidReportDescriptor" to your code which contains the report descriptor. + * Don't forget to keep the array and this define in sync! + */ + +/* #define USB_PUBLIC static */ +/* Use the define above if you #include usbdrv.c instead of linking against it. + * This technique saves a couple of bytes in flash memory. + */ + +/* ------------------- Fine Control over USB Descriptors ------------------- */ +/* If you don't want to use the driver's default USB descriptors, you can + * provide our own. These can be provided as (1) fixed length static data in + * flash memory, (2) fixed length static data in RAM or (3) dynamically at + * runtime in the function usbFunctionDescriptor(). See usbdrv.h for more + * information about this function. + * Descriptor handling is configured through the descriptor's properties. If + * no properties are defined or if they are 0, the default descriptor is used. + * Possible properties are: + * + USB_PROP_IS_DYNAMIC: The data for the descriptor should be fetched + * at runtime via usbFunctionDescriptor(). If the usbMsgPtr mechanism is + * used, the data is in FLASH by default. Add property USB_PROP_IS_RAM if + * you want RAM pointers. + * + USB_PROP_IS_RAM: The data returned by usbFunctionDescriptor() or found + * in static memory is in RAM, not in flash memory. + * + USB_PROP_LENGTH(len): If the data is in static memory (RAM or flash), + * the driver must know the descriptor's length. The descriptor itself is + * found at the address of a well known identifier (see below). + * List of static descriptor names (must be declared PROGMEM if in flash): + * char usbDescriptorDevice[]; + * char usbDescriptorConfiguration[]; + * char usbDescriptorHidReport[]; + * char usbDescriptorString0[]; + * int usbDescriptorStringVendor[]; + * int usbDescriptorStringDevice[]; + * int usbDescriptorStringSerialNumber[]; + * Other descriptors can't be provided statically, they must be provided + * dynamically at runtime. + * + * Descriptor properties are or-ed or added together, e.g.: + * #define USB_CFG_DESCR_PROPS_DEVICE (USB_PROP_IS_RAM | USB_PROP_LENGTH(18)) + * + * The following descriptors are defined: + * USB_CFG_DESCR_PROPS_DEVICE + * USB_CFG_DESCR_PROPS_CONFIGURATION + * USB_CFG_DESCR_PROPS_STRINGS + * USB_CFG_DESCR_PROPS_STRING_0 + * USB_CFG_DESCR_PROPS_STRING_VENDOR + * USB_CFG_DESCR_PROPS_STRING_PRODUCT + * USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER + * USB_CFG_DESCR_PROPS_HID + * USB_CFG_DESCR_PROPS_HID_REPORT + * USB_CFG_DESCR_PROPS_UNKNOWN (for all descriptors not handled by the driver) + * + * Note about string descriptors: String descriptors are not just strings, they + * are Unicode strings prefixed with a 2 byte header. Example: + * int serialNumberDescriptor[] = { + * USB_STRING_DESCRIPTOR_HEADER(6), + * 'S', 'e', 'r', 'i', 'a', 'l' + * }; + */ + +#define USB_CFG_DESCR_PROPS_DEVICE 0 +#define USB_CFG_DESCR_PROPS_CONFIGURATION 0 +#define USB_CFG_DESCR_PROPS_STRINGS 0 +#define USB_CFG_DESCR_PROPS_STRING_0 0 +#define USB_CFG_DESCR_PROPS_STRING_VENDOR 0 +#define USB_CFG_DESCR_PROPS_STRING_PRODUCT 0 +#define USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER 0 +#define USB_CFG_DESCR_PROPS_HID 0 +#define USB_CFG_DESCR_PROPS_HID_REPORT 0 +#define USB_CFG_DESCR_PROPS_UNKNOWN 0 + +/* ----------------------- Optional MCU Description ------------------------ */ + +/* The following configurations have working defaults in usbdrv.h. You + * usually don't need to set them explicitly. Only if you want to run + * the driver on a device which is not yet supported or with a compiler + * which is not fully supported (such as IAR C) or if you use a differnt + * interrupt than INT0, you may have to define some of these. + */ +/* #define USB_INTR_CFG MCUCR */ +/* #define USB_INTR_CFG_SET ((1 << ISC00) | (1 << ISC01)) */ +/* #define USB_INTR_CFG_CLR 0 */ +/* #define USB_INTR_ENABLE GIMSK */ +/* #define USB_INTR_ENABLE_BIT INT0 */ +/* #define USB_INTR_PENDING GIFR */ +/* #define USB_INTR_PENDING_BIT INTF0 */ +/* #define USB_INTR_VECTOR INT0_vect */ + +#endif /* __usbconfig_h_included__ */ diff --git a/firmware/usbdrv/Changelog.txt b/firmware/usbdrv/Changelog.txt new file mode 100644 index 0000000..5c6354a --- /dev/null +++ b/firmware/usbdrv/Changelog.txt @@ -0,0 +1,308 @@ +This file documents changes in the firmware-only USB driver for atmel's AVR +microcontrollers. New entries are always appended to the end of the file. +Scroll down to the bottom to see the most recent changes. + +2005-04-01: + - Implemented endpoint 1 as interrupt-in endpoint. + - Moved all configuration options to usbconfig.h which is not part of the + driver. + - Changed interface for usbVendorSetup(). + - Fixed compatibility with ATMega8 device. + - Various minor optimizations. + +2005-04-11: + - Changed interface to application: Use usbFunctionSetup(), usbFunctionRead() + and usbFunctionWrite() now. Added configuration options to choose which + of these functions to compile in. + - Assembler module delivers receive data non-inverted now. + - Made register and bit names compatible with more AVR devices. + +2005-05-03: + - Allow address of usbRxBuf on any memory page as long as the buffer does + not cross 256 byte page boundaries. + - Better device compatibility: works with Mega88 now. + - Code optimization in debugging module. + - Documentation updates. + +2006-01-02: + - Added (free) default Vendor- and Product-IDs bought from voti.nl. + - Added USBID-License.txt file which defines the rules for using the free + shared VID/PID pair. + - Added Readme.txt to the usbdrv directory which clarifies administrative + issues. + +2006-01-25: + - Added "configured state" to become more standards compliant. + - Added "HALT" state for interrupt endpoint. + - Driver passes the "USB Command Verifier" test from usb.org now. + - Made "serial number" a configuration option. + - Minor optimizations, we now recommend compiler option "-Os" for best + results. + - Added a version number to usbdrv.h + +2006-02-03: + - New configuration variable USB_BUFFER_SECTION for the memory section where + the USB rx buffer will go. This defaults to ".bss" if not defined. Since + this buffer MUST NOT cross 256 byte pages (not even touch a page at the + end), the user may want to pass a linker option similar to + "-Wl,--section-start=.mybuffer=0x800060". + - Provide structure for usbRequest_t. + - New defines for USB constants. + - Prepared for HID implementations. + - Increased data size limit for interrupt transfers to 8 bytes. + - New macro usbInterruptIsReady() to query interrupt buffer state. + +2006-02-18: + - Ensure that the data token which is sent as an ack to an OUT transfer is + always zero sized. This fixes a bug where the host reports an error after + sending an out transfer to the device, although all data arrived at the + device. + - Updated docs in usbdrv.h to reflect changed API in usbFunctionWrite(). + +* Release 2006-02-20 + + - Give a compiler warning when compiling with debugging turned on. + - Added Oleg Semyonov's changes for IAR-cc compatibility. + - Added new (optional) functions usbDeviceConnect() and usbDeviceDisconnect() + (also thanks to Oleg!). + - Rearranged tests in usbPoll() to save a couple of instructions in the most + likely case that no actions are pending. + - We need a delay between the SET ADDRESS request until the new address + becomes active. This delay was handled in usbPoll() until now. Since the + spec says that the delay must not exceed 2ms, previous versions required + aggressive polling during the enumeration phase. We have now moved the + handling of the delay into the interrupt routine. + - We must not reply with NAK to a SETUP transaction. We can only achieve this + by making sure that the rx buffer is empty when SETUP tokens are expected. + We therefore don't pass zero sized data packets from the status phase of + a transfer to usbPoll(). This change MAY cause troubles if you rely on + receiving a less than 8 bytes long packet in usbFunctionWrite() to + identify the end of a transfer. usbFunctionWrite() will NEVER be called + with a zero length. + +* Release 2006-03-14 + + - Improved IAR C support: tiny memory model, more devices + - Added template usbconfig.h file under the name usbconfig-prototype.h + +* Release 2006-03-26 + + - Added provision for one more interrupt-in endpoint (endpoint 3). + - Added provision for one interrupt-out endpoint (endpoint 1). + - Added flowcontrol macros for USB. + - Added provision for custom configuration descriptor. + - Allow ANY two port bits for D+ and D-. + - Merged (optional) receive endpoint number into global usbRxToken variable. + - Use USB_CFG_IOPORTNAME instead of USB_CFG_IOPORT. We now construct the + variable name from the single port letter instead of computing the address + of related ports from the output-port address. + +* Release 2006-06-26 + + - Updated documentation in usbdrv.h and usbconfig-prototype.h to reflect the + new features. + - Removed "#warning" directives because IAR does not understand them. Use + unused static variables instead to generate a warning. + - Do not include when compiling with IAR. + - Introduced USB_CFG_DESCR_PROPS_* in usbconfig.h to configure how each + USB descriptor should be handled. It is now possible to provide descriptor + data in Flash, RAM or dynamically at runtime. + - STALL is now a status in usbTxLen* instead of a message. We can now conform + to the spec and leave the stall status pending until it is cleared. + - Made usbTxPacketCnt1 and usbTxPacketCnt3 public. This allows the + application code to reset data toggling on interrupt pipes. + +* Release 2006-07-18 + + - Added an #if !defined __ASSEMBLER__ to the warning in usbdrv.h. This fixes + an assembler error. + - usbDeviceDisconnect() takes pull-up resistor to high impedance now. + +* Release 2007-02-01 + + - Merged in some code size improvements from usbtiny (thanks to Dick + Streefland for these optimizations!) + - Special alignment requirement for usbRxBuf not required any more. Thanks + again to Dick Streefland for this hint! + - Reverted to "#warning" instead of unused static variables -- new versions + of IAR CC should handle this directive. + - Changed Open Source license to GNU GPL v2 in order to make linking against + other free libraries easier. We no longer require publication of the + circuit diagrams, but we STRONGLY encourage it. If you improve the driver + itself, PLEASE grant us a royalty free license to your changes for our + commercial license. + +* Release 2007-03-29 + + - New configuration option "USB_PUBLIC" in usbconfig.h. + - Set USB version number to 1.10 instead of 1.01. + - Code used USB_CFG_DESCR_PROPS_STRING_DEVICE and + USB_CFG_DESCR_PROPS_STRING_PRODUCT inconsistently. Changed all occurrences + to USB_CFG_DESCR_PROPS_STRING_PRODUCT. + - New assembler module for 16.5 MHz RC oscillator clock with PLL in receiver + code. + - New assembler module for 16 MHz crystal. + - usbdrvasm.S contains common code only, clock-specific parts have been moved + to usbdrvasm12.S, usbdrvasm16.S and usbdrvasm165.S respectively. + +* Release 2007-06-25 + + - 16 MHz module: Do SE0 check in stuffed bits as well. + +* Release 2007-07-07 + + - Define hi8(x) for IAR compiler to limit result to 8 bits. This is necessary + for negative values. + - Added 15 MHz module contributed by V. Bosch. + - Interrupt vector name can now be configured. This is useful if somebody + wants to use a different hardware interrupt than INT0. + +* Release 2007-08-07 + + - Moved handleIn3 routine in usbdrvasm16.S so that relative jump range is + not exceeded. + - More config options: USB_RX_USER_HOOK(), USB_INITIAL_DATATOKEN, + USB_COUNT_SOF + - USB_INTR_PENDING can now be a memory address, not just I/O + +* Release 2007-09-19 + + - Split out common parts of assembler modules into separate include file + - Made endpoint numbers configurable so that given interface definitions + can be matched. See USB_CFG_EP3_NUMBER in usbconfig-prototype.h. + - Store endpoint number for interrupt/bulk-out so that usbFunctionWriteOut() + can handle any number of endpoints. + - Define usbDeviceConnect() and usbDeviceDisconnect() even if no + USB_CFG_PULLUP_IOPORTNAME is defined. Directly set D+ and D- to 0 in this + case. + +* Release 2007-12-01 + + - Optimize usbDeviceConnect() and usbDeviceDisconnect() for less code size + when USB_CFG_PULLUP_IOPORTNAME is not defined. + +* Release 2007-12-13 + + - Renamed all include-only assembler modules from *.S to *.inc so that + people don't add them to their project sources. + - Distribute leap bits in tx loop more evenly for 16 MHz module. + - Use "macro" and "endm" instead of ".macro" and ".endm" for IAR + - Avoid compiler warnings for constant expr range by casting some values in + USB descriptors. + +* Release 2008-01-21 + + - Fixed bug in 15 and 16 MHz module where the new address set with + SET_ADDRESS was already accepted at the next NAK or ACK we send, not at + the next data packet we send. This caused problems when the host polled + too fast. Thanks to Alexander Neumann for his help and patience debugging + this issue! + +* Release 2008-02-05 + + - Fixed bug in 16.5 MHz module where a register was used in the interrupt + handler before it was pushed. This bug was introduced with version + 2007-09-19 when common parts were moved to a separate file. + - Optimized CRC routine (thanks to Reimar Doeffinger). + +* Release 2008-02-16 + + - Removed outdated IAR compatibility stuff (code sections). + - Added hook macros for USB_RESET_HOOK() and USB_SET_ADDRESS_HOOK(). + - Added optional routine usbMeasureFrameLength() for calibration of the + internal RC oscillator. + +* Release 2008-02-28 + + - USB_INITIAL_DATATOKEN defaults to USBPID_DATA1 now, which means that we + start with sending USBPID_DATA0. + - Changed defaults in usbconfig-prototype.h + - Added free USB VID/PID pair for MIDI class devices + - Restructured AVR-USB as separate package, not part of PowerSwitch any more. + +* Release 2008-04-18 + + - Restructured usbdrv.c so that it is easier to read and understand. + - Better code optimization with gcc 4. + - If a second interrupt in endpoint is enabled, also add it to config + descriptor. + - Added config option for long transfers (above 254 bytes), see + USB_CFG_LONG_TRANSFERS in usbconfig.h. + - Added 20 MHz module contributed by Jeroen Benschop. + +* Release 2008-05-13 + + - Fixed bug in libs-host/hiddata.c function usbhidGetReport(): length + was not incremented, pointer to length was incremented instead. + - Added code to command line tool(s) which claims an interface. This code + is disabled by default, but may be necessary on newer Linux kernels. + - Added usbconfig.h option "USB_CFG_CHECK_DATA_TOGGLING". + - New header "usbportability.h" prepares ports to other development + environments. + - Long transfers (above 254 bytes) did not work when usbFunctionRead() was + used to supply the data. Fixed this bug. [Thanks to Alexander Neumann!] + - In hiddata.c (example code for sending/receiving data over HID), use + USB_RECIP_DEVICE instead of USB_RECIP_INTERFACE for control transfers so + that we need not claim the interface. + - in usbPoll() loop 20 times polling for RESET state instead of 10 times. + This accounts for the higher clock rates we now support. + - Added a module for 12.8 MHz RC oscillator with PLL in receiver loop. + - Added hook to SOF code so that oscillator can be tuned to USB frame clock. + - Added timeout to waitForJ loop. Helps preventing unexpected hangs. + - Added example code for oscillator tuning to libs-device (thanks to + Henrik Haftmann for the idea to this routine). + - Implemented option USB_CFG_SUPPRESS_INTR_CODE. + +* Release 2008-10-22 + + - Fixed libs-device/osctune.h: OSCCAL is memory address on ATMega88 and + similar, not offset of 0x20 needs to be added. + - Allow distribution under GPLv3 for those who have to link against other + code distributed under GPLv3. + +* Release 2008-11-26 + + - Removed libusb-win32 dependency for hid-data example in Makefile.windows. + It was never required and confused many people. + - Added extern uchar usbRxToken to usbdrv.h. + - Integrated a module with CRC checks at 18 MHz by Lukas Schrittwieser. + +* Release 2009-03-23 + + - Hid-mouse example used settings from hid-data example, fixed that. + - Renamed project to V-USB due to a trademark issue with Atmel(r). + - Changed CommercialLicense.txt and USBID-License.txt to make the + background of USB ID registration clearer. + +* Release 2009-04-15 + + - Changed CommercialLicense.txt to reflect the new range of PIDs from + Jason Kotzin. + - Removed USBID-License.txt in favor of USB-IDs-for-free.txt and + USB-ID-FAQ.txt + - Fixed a bug in the 12.8 MHz module: End Of Packet decection was made in + the center between bit 0 and 1 of each byte. This is where the data lines + are expected to change and the sampled data may therefore be nonsense. + We therefore check EOP ONLY if bits 0 AND 1 have both been read as 0 on D-. + - Fixed a bitstuffing problem in the 16 MHz module: If bit 6 was stuffed, + the unstuffing code in the receiver routine was 1 cycle too long. If + multiple bytes had the unstuffing in bit 6, the error summed up until the + receiver was out of sync. + - Included option for faster CRC routine. + Thanks to Slawomir Fras (BoskiDialer) for this code! + - Updated bits in Configuration Descriptor's bmAttributes according to + USB 1.1 (in particular bit 7, it is a must-be-set bit now). + +* Release 2009-08-22 + + - Moved first DBG1() after odDebugInit() in all examples. + - Use vector INT0_vect instead of SIG_INTERRUPT0 if defined. This makes + V-USB compatible with the new "p" suffix devices (e.g. ATMega328p). + - USB_CFG_CLOCK_KHZ setting is now required in usbconfig.h (no default any + more). + - New option USB_CFG_DRIVER_FLASH_PAGE allows boot loaders on devices with + more than 64 kB flash. + - Built-in configuration descriptor allows custom definition for second + endpoint now. + +* Release 2010-07-15 diff --git a/firmware/usbdrv/CommercialLicense.txt b/firmware/usbdrv/CommercialLicense.txt new file mode 100644 index 0000000..11d07d9 --- /dev/null +++ b/firmware/usbdrv/CommercialLicense.txt @@ -0,0 +1,166 @@ +V-USB Driver Software License Agreement +Version 2009-08-03 + +THIS LICENSE AGREEMENT GRANTS YOU CERTAIN RIGHTS IN A SOFTWARE. YOU CAN +ENTER INTO THIS AGREEMENT AND ACQUIRE THE RIGHTS OUTLINED BELOW BY PAYING +THE AMOUNT ACCORDING TO SECTION 4 ("PAYMENT") TO OBJECTIVE DEVELOPMENT. + + +1 DEFINITIONS + +1.1 "OBJECTIVE DEVELOPMENT" shall mean OBJECTIVE DEVELOPMENT Software GmbH, +Grosse Schiffgasse 1A/7, 1020 Wien, AUSTRIA. + +1.2 "You" shall mean the Licensee. + +1.3 "V-USB" shall mean all files included in the package distributed under +the name "vusb" by OBJECTIVE DEVELOPMENT (http://www.obdev.at/vusb/) +unless otherwise noted. This includes the firmware-only USB device +implementation for Atmel AVR microcontrollers, some simple device examples +and host side software examples and libraries. + + +2 LICENSE GRANTS + +2.1 Source Code. OBJECTIVE DEVELOPMENT shall furnish you with the source +code of V-USB. + +2.2 Distribution and Use. OBJECTIVE DEVELOPMENT grants you the +non-exclusive right to use, copy and distribute V-USB with your hardware +product(s), restricted by the limitations in section 3 below. + +2.3 Modifications. OBJECTIVE DEVELOPMENT grants you the right to modify +the source code and your copy of V-USB according to your needs. + +2.4 USB IDs. OBJECTIVE DEVELOPMENT furnishes you with one or two USB +Product ID(s), sent to you in e-mail. These Product IDs are reserved +exclusively for you. OBJECTIVE DEVELOPMENT has obtained USB Product ID +ranges under the Vendor ID 5824 from Wouter van Ooijen (Van Ooijen +Technische Informatica, www.voti.nl) and under the Vendor ID 8352 from +Jason Kotzin (Clay Logic, www.claylogic.com). Both owners of the Vendor IDs +have obtained these IDs from the USB Implementers Forum, Inc. +(www.usb.org). OBJECTIVE DEVELOPMENT disclaims all liability which might +arise from the assignment of USB IDs. + +2.5 USB Certification. Although not part of this agreement, we want to make +it clear that you cannot become USB certified when you use V-USB or a USB +Product ID assigned by OBJECTIVE DEVELOPMENT. AVR microcontrollers don't +meet the electrical specifications required by the USB specification and +the USB Implementers Forum certifies only members who bought a Vendor ID of +their own. + + +3 LICENSE RESTRICTIONS + +3.1 Number of Units. Only one of the following three definitions is +applicable. Which one is determined by the amount you pay to OBJECTIVE +DEVELOPMENT, see section 4 ("Payment") below. + +Hobby License: You may use V-USB according to section 2 above in no more +than 5 hardware units. These units must not be sold for profit. + +Entry Level License: You may use V-USB according to section 2 above in no +more than 150 hardware units. + +Professional License: You may use V-USB according to section 2 above in +any number of hardware units, except for large scale production ("unlimited +fair use"). Quantities below 10,000 units are not considered large scale +production. If your reach quantities which are obviously large scale +production, you must pay a license fee of 0.10 EUR per unit for all units +above 10,000. + +3.2 Rental. You may not rent, lease, or lend V-USB or otherwise encumber +any copy of V-USB, or any of the rights granted herein. + +3.3 Transfer. You may not transfer your rights under this Agreement to +another party without OBJECTIVE DEVELOPMENT's prior written consent. If +such consent is obtained, you may permanently transfer this License to +another party. The recipient of such transfer must agree to all terms and +conditions of this Agreement. + +3.4 Reservation of Rights. OBJECTIVE DEVELOPMENT retains all rights not +expressly granted. + +3.5 Non-Exclusive Rights. Your license rights under this Agreement are +non-exclusive. + +3.6 Third Party Rights. This Agreement cannot grant you rights controlled +by third parties. In particular, you are not allowed to use the USB logo or +other trademarks owned by the USB Implementers Forum, Inc. without their +consent. Since such consent depends on USB certification, it should be +noted that V-USB will not pass certification because it does not +implement checksum verification and the microcontroller ports do not meet +the electrical specifications. + + +4 PAYMENT + +The payment amount depends on the variation of this agreement (according to +section 3.1) into which you want to enter. Concrete prices are listed on +OBJECTIVE DEVELOPMENT's web site, usually at +http://www.obdev.at/vusb/license.html. You agree to pay the amount listed +there to OBJECTIVE DEVELOPMENT or OBJECTIVE DEVELOPMENT's payment processor +or reseller. + + +5 COPYRIGHT AND OWNERSHIP + +V-USB is protected by copyright laws and international copyright +treaties, as well as other intellectual property laws and treaties. V-USB +is licensed, not sold. + + +6 TERM AND TERMINATION + +6.1 Term. This Agreement shall continue indefinitely. However, OBJECTIVE +DEVELOPMENT may terminate this Agreement and revoke the granted license and +USB-IDs if you fail to comply with any of its terms and conditions. + +6.2 Survival of Terms. All provisions regarding secrecy, confidentiality +and limitation of liability shall survive termination of this agreement. + + +7 DISCLAIMER OF WARRANTY AND LIABILITY + +LIMITED WARRANTY. V-USB IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +KIND. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, OBJECTIVE +DEVELOPMENT AND ITS SUPPLIERS HEREBY DISCLAIM ALL WARRANTIES, EITHER +EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE, AND +NON-INFRINGEMENT, WITH REGARD TO V-USB, AND THE PROVISION OF OR FAILURE +TO PROVIDE SUPPORT SERVICES. THIS LIMITED WARRANTY GIVES YOU SPECIFIC LEGAL +RIGHTS. YOU MAY HAVE OTHERS, WHICH VARY FROM STATE/JURISDICTION TO +STATE/JURISDICTION. + +LIMITATION OF LIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, +IN NO EVENT SHALL OBJECTIVE DEVELOPMENT OR ITS SUPPLIERS BE LIABLE FOR ANY +SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER +(INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, +BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR ANY OTHER PECUNIARY +LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE V-USB OR THE +PROVISION OF OR FAILURE TO PROVIDE SUPPORT SERVICES, EVEN IF OBJECTIVE +DEVELOPMENT HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. IN ANY +CASE, OBJECTIVE DEVELOPMENT'S ENTIRE LIABILITY UNDER ANY PROVISION OF THIS +AGREEMENT SHALL BE LIMITED TO THE AMOUNT ACTUALLY PAID BY YOU FOR V-USB. + + +8 MISCELLANEOUS TERMS + +8.1 Marketing. OBJECTIVE DEVELOPMENT has the right to mention for marketing +purposes that you entered into this agreement. + +8.2 Entire Agreement. This document represents the entire agreement between +OBJECTIVE DEVELOPMENT and you. It may only be modified in writing signed by +an authorized representative of both, OBJECTIVE DEVELOPMENT and you. + +8.3 Severability. In case a provision of these terms and conditions should +be or become partly or entirely invalid, ineffective, or not executable, +the validity of all other provisions shall not be affected. + +8.4 Applicable Law. This agreement is governed by the laws of the Republic +of Austria. + +8.5 Responsible Courts. The responsible courts in Vienna/Austria will have +exclusive jurisdiction regarding all disputes in connection with this +agreement. + diff --git a/firmware/usbdrv/License.txt b/firmware/usbdrv/License.txt new file mode 100644 index 0000000..4460cfb --- /dev/null +++ b/firmware/usbdrv/License.txt @@ -0,0 +1,361 @@ +OBJECTIVE DEVELOPMENT GmbH's V-USB driver software is distributed under the +terms and conditions of the GNU GPL version 2 or the GNU GPL version 3. It is +your choice whether you apply the terms of version 2 or version 3. The full +text of GPLv2 is included below. In addition to the requirements in the GPL, +we STRONGLY ENCOURAGE you to do the following: + +(1) Publish your entire project on a web site and drop us a note with the URL. +Use the form at http://www.obdev.at/vusb/feedback.html for your submission. + +(2) Adhere to minimum publication standards. Please include AT LEAST: + - a circuit diagram in PDF, PNG or GIF format + - full source code for the host software + - a Readme.txt file in ASCII format which describes the purpose of the + project and what can be found in which directories and which files + - a reference to http://www.obdev.at/vusb/ + +(3) If you improve the driver firmware itself, please give us a free license +to your modifications for our commercial license offerings. + + + + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/firmware/usbdrv/Readme.txt b/firmware/usbdrv/Readme.txt new file mode 100644 index 0000000..970dc66 --- /dev/null +++ b/firmware/usbdrv/Readme.txt @@ -0,0 +1,172 @@ +This is the Readme file to Objective Development's firmware-only USB driver +for Atmel AVR microcontrollers. For more information please visit +http://www.obdev.at/vusb/ + +This directory contains the USB firmware only. Copy it as-is to your own +project and add all .c and .S files to your project (these files are marked +with an asterisk in the list below). Then copy usbconfig-prototype.h as +usbconfig.h to your project and edit it according to your configuration. + + +TECHNICAL DOCUMENTATION +======================= +The technical documentation (API) for the firmware driver is contained in the +file "usbdrv.h". Please read all of it carefully! Configuration options are +documented in "usbconfig-prototype.h". + +The driver consists of the following files: + Readme.txt ............. The file you are currently reading. + Changelog.txt .......... Release notes for all versions of the driver. + usbdrv.h ............... Driver interface definitions and technical docs. +* usbdrv.c ............... High level language part of the driver. Link this + module to your code! +* usbdrvasm.S ............ Assembler part of the driver. This module is mostly + a stub and includes one of the usbdrvasm*.S files + depending on processor clock. Link this module to + your code! + usbdrvasm*.inc ......... Assembler routines for particular clock frequencies. + Included by usbdrvasm.S, don't link it directly! + asmcommon.inc .......... Common assembler routines. Included by + usbdrvasm*.inc, don't link it directly! + usbconfig-prototype.h .. Prototype for your own usbdrv.h file. +* oddebug.c .............. Debug functions. Only used when DEBUG_LEVEL is + defined to a value greater than 0. Link this module + to your code! + oddebug.h .............. Interface definitions of the debug module. + usbportability.h ....... Header with compiler-dependent stuff. + usbdrvasm.asm .......... Compatibility stub for IAR-C-compiler. Use this + module instead of usbdrvasm.S when you assembler + with IAR's tools. + License.txt ............ Open Source license for this driver. + CommercialLicense.txt .. Optional commercial license for this driver. + USB-ID-FAQ.txt ......... General infos about USB Product- and Vendor-IDs. + USB-IDs-for-free.txt ... List and terms of use for free shared PIDs. + +(*) ... These files should be linked to your project. + + +CPU CORE CLOCK FREQUENCY +======================== +We supply assembler modules for clock frequencies of 12 MHz, 12.8 MHz, 15 MHz, +16 MHz, 16.5 MHz 18 MHz and 20 MHz. Other clock rates are not supported. The +actual clock rate must be configured in usbconfig.h. + +12 MHz Clock +This is the traditional clock rate of V-USB because it's the lowest clock +rate where the timing constraints of the USB spec can be met. + +15 MHz Clock +Similar to 12 MHz, but some NOPs inserted. On the other hand, the higher clock +rate allows for some loops which make the resulting code size somewhat smaller +than the 12 MHz version. + +16 MHz Clock +This clock rate has been added for users of the Arduino board and other +ready-made boards which come with a fixed 16 MHz crystal. It's also an option +if you need the slightly higher clock rate for performance reasons. Since +16 MHz is not divisible by the USB low speed bit clock of 1.5 MHz, the code +is somewhat tricky and has to insert a leap cycle every third byte. + +12.8 MHz and 16.5 MHz Clock +The assembler modules for these clock rates differ from the other modules +because they have been built for an RC oscillator with only 1% precision. The +receiver code inserts leap cycles to compensate for clock deviations. 1% is +also the precision which can be achieved by calibrating the internal RC +oscillator of the AVR. Please note that only AVRs with internal 64 MHz PLL +oscillator can reach 16.5 MHz with the RC oscillator. This includes the very +popular ATTiny25, ATTiny45, ATTiny85 series as well as the ATTiny26. Almost +all AVRs can reach 12.8 MHz, although this is outside the specified range. + +See the EasyLogger example at http://www.obdev.at/vusb/easylogger.html for +code which calibrates the RC oscillator based on the USB frame clock. + +18 MHz Clock +This module is closer to the USB specification because it performs an on the +fly CRC check for incoming packets. Packets with invalid checksum are +discarded as required by the spec. If you also implement checks for data +PID toggling on application level (see option USB_CFG_CHECK_DATA_TOGGLING +in usbconfig.h for more info), this ensures data integrity. Due to the CRC +tables and alignment requirements, this code is bigger than modules for other +clock rates. To activate this module, you must define USB_CFG_CHECK_CRC to 1 +and USB_CFG_CLOCK_KHZ to 18000 in usbconfig.h. + +20 MHz Clock +This module is for people who won't do it with less than the maximum. Since +20 MHz is not divisible by the USB low speed bit clock of 1.5 MHz, the code +uses similar tricks as the 16 MHz module to insert leap cycles. + + +USB IDENTIFIERS +=============== +Every USB device needs a vendor- and a product-identifier (VID and PID). VIDs +are obtained from usb.org for a price of 1,500 USD. Once you have a VID, you +can assign PIDs at will. + +Since an entry level cost of 1,500 USD is too high for most small companies +and hobbyists, we provide some VID/PID pairs for free. See the file +USB-IDs-for-free.txt for details. + +Objective Development also has some license offerings which include product +IDs. See http://www.obdev.at/vusb/ for details. + + +DEVELOPMENT SYSTEM +================== +This driver has been developed and optimized for the GNU compiler version 3 +and 4. We recommend that you use the GNU compiler suite because it is freely +available. V-USB has also been ported to the IAR compiler and assembler. It +has been tested with IAR 4.10B/W32 and 4.12A/W32 on an ATmega8 with the +"small" and "tiny" memory model. Not every release is tested with IAR CC and +the driver may therefore fail to compile with IAR. Please note that gcc is +more efficient for usbdrv.c because this module has been deliberately +optimized for gcc. + +Gcc version 3 produces smaller code than version 4 due to new optimizing +capabilities which don't always improve things on 8 bit CPUs. The code size +generated by gcc 4 can be reduced with the compiler options +-fno-move-loop-invariants, -fno-tree-scev-cprop and +-fno-inline-small-functions in addition to -Os. On devices with more than +8k of flash memory, we also recommend the linker option --relax (written as +-Wl,--relax for gcc) to convert absolute calls into relative where possible. + +For more information about optimizing options see: + + http://www.tty1.net/blog/2008-04-29-avr-gcc-optimisations_en.html + +These optimizations are good for gcc 4.x. Version 3.x of gcc does not support +most of these options and produces good code anyway. + + +USING V-USB FOR FREE +==================== +The AVR firmware driver is published under the GNU General Public License +Version 2 (GPL2) and the GNU General Public License Version 3 (GPL3). It is +your choice whether you apply the terms of version 2 or version 3. + +If you decide for the free GPL2 or GPL3, we STRONGLY ENCOURAGE you to do the +following things IN ADDITION to the obligations from the GPL: + +(1) Publish your entire project on a web site and drop us a note with the URL. +Use the form at http://www.obdev.at/vusb/feedback.html for your submission. +If you don't have a web site, you can publish the project in obdev's +documentation wiki at +http://www.obdev.at/goto.php?t=vusb-wiki&p=hosted-projects. + +(2) Adhere to minimum publication standards. Please include AT LEAST: + - a circuit diagram in PDF, PNG or GIF format + - full source code for the host software + - a Readme.txt file in ASCII format which describes the purpose of the + project and what can be found in which directories and which files + - a reference to http://www.obdev.at/vusb/ + +(3) If you improve the driver firmware itself, please give us a free license +to your modifications for our commercial license offerings. + + +COMMERCIAL LICENSES FOR V-USB +============================= +If you don't want to publish your source code under the terms of the GPL, +you can simply pay money for V-USB. As an additional benefit you get +USB PIDs for free, reserved exclusively to you. See the file +"CommercialLicense.txt" for details. + diff --git a/firmware/usbdrv/USB-ID-FAQ.txt b/firmware/usbdrv/USB-ID-FAQ.txt new file mode 100644 index 0000000..d1de8fb --- /dev/null +++ b/firmware/usbdrv/USB-ID-FAQ.txt @@ -0,0 +1,149 @@ +Version 2009-08-22 + +========================== +WHY DO WE NEED THESE IDs? +========================== + +USB is more than a low level protocol for data transport. It also defines a +common set of requests which must be understood by all devices. And as part +of these common requests, the specification defines data structures, the +USB Descriptors, which are used to describe the properties of the device. + +From the perspective of an operating system, it is therefore possible to find +out basic properties of a device (such as e.g. the manufacturer and the name +of the device) without a device-specific driver. This is essential because +the operating system can choose a driver to load based on this information +(Plug-And-Play). + +Among the most important properties in the Device Descriptor are the USB +Vendor- and Product-ID. Both are 16 bit integers. The most simple form of +driver matching is based on these IDs. The driver announces the Vendor- and +Product-IDs of the devices it can handle and the operating system loads the +appropriate driver when the device is connected. + +It is obvious that this technique only works if the pair Vendor- plus +Product-ID is unique: Only devices which require the same driver can have the +same pair of IDs. + + +===================================================== +HOW DOES THE USB STANDARD ENSURE THAT IDs ARE UNIQUE? +===================================================== + +Since it is so important that USB IDs are unique, the USB Implementers Forum, +Inc. (usb.org) needs a way to enforce this legally. It is not forbidden by +law to build a device and assign it any random numbers as IDs. Usb.org +therefore needs an agreement to regulate the use of USB IDs. The agreement +binds only parties who agreed to it, of course. Everybody else is free to use +any numbers for their IDs. + +So how can usb.org ensure that every manufacturer of USB devices enters into +an agreement with them? They do it via trademark licensing. Usb.org has +registered the trademark "USB", all associated logos and related terms. If +you want to put an USB logo on your product or claim that it is USB +compliant, you must license these trademarks from usb.org. And this is where +you enter into an agreement. See the "USB-IF Trademark License Agreement and +Usage Guidelines for the USB-IF Logo" at +http://www.usb.org/developers/logo_license/. + +Licensing the USB trademarks requires that you buy a USB Vendor-ID from +usb.org (one-time fee of ca. 2,000 USD), that you become a member of usb.org +(yearly fee of ca. 4,000 USD) and that you meet all the technical +specifications from the USB spec. + +This means that most hobbyists and small companies will never be able to +become USB compliant, just because membership is so expensive. And you can't +be compliant with a driver based on V-USB anyway, because the AVR's port pins +don't meet the electrical specifications for USB. So, in principle, all +hobbyists and small companies are free to choose any random numbers for their +IDs. They have nothing to lose... + +There is one exception worth noting, though: If you use a sub-component which +implements USB, the vendor of the sub-components may guarantee USB +compliance. This might apply to some or all of FTDI's solutions. + + +======================================================================= +WHY SHOULD YOU OBTAIN USB IDs EVEN IF YOU DON'T LICENSE USB TRADEMARKS? +======================================================================= + +You have learned in the previous section that you are free to choose any +numbers for your IDs anyway. So why not do exactly this? There is still the +technical issue. If you choose IDs which are already in use by somebody else, +operating systems will load the wrong drivers and your device won't work. +Even if you choose IDs which are not currently in use, they may be in use in +the next version of the operating system or even after an automatic update. + +So what you need is a pair of Vendor- and Product-IDs for which you have the +guarantee that no USB compliant product uses them. This implies that no +operating system will ever ship with drivers responsible for these IDs. + + +============================================== +HOW DOES OBJECTIVE DEVELOPMENT HANDLE USB IDs? +============================================== + +Objective Development gives away pairs of USB-IDs with their V-USB licenses. +In order to ensure that these IDs are unique, Objective Development has an +agreement with the company/person who has bought the USB Vendor-ID from +usb.org. This agreement ensures that a range of USB Product-IDs is reserved +for assignment by Objective Development and that the owner of the Vendor-ID +won't give it to anybody else. + +This means that you have to trust three parties to ensure uniqueness of +your IDs: + + - Objective Development, that they don't give the same PID to more than + one person. + - The owner of the Vendor-ID that they don't assign PIDs from the range + assigned to Objective Development to anybody else. + - Usb.org that they don't assign the same Vendor-ID a second time. + + +================================== +WHO IS THE OWNER OF THE VENDOR-ID? +================================== + +Objective Development has obtained ranges of USB Product-IDs under two +Vendor-IDs: Under Vendor-ID 5824 from Wouter van Ooijen (Van Ooijen +Technische Informatica, www.voti.nl) and under Vendor-ID 8352 from Jason +Kotzin (Clay Logic, www.claylogic.com). Both VID owners have received their +Vendor-ID directly from usb.org. + + +========================================================================= +CAN I USE USB-IDs FROM OBJECTIVE DEVELOPMENT WITH OTHER DRIVERS/HARDWARE? +========================================================================= + +The short answer is: Yes. All you get is a guarantee that the IDs are never +assigned to anybody else. What more do you need? + + +============================ +WHAT ABOUT SHARED ID PAIRS? +============================ + +Objective Development has reserved some PID/VID pairs for shared use. You +have no guarantee of uniqueness for them, except that no USB compliant device +uses them. In order to avoid technical problems, we must ensure that all +devices with the same pair of IDs use the same driver on kernel level. For +details, see the file USB-IDs-for-free.txt. + + +====================================================== +I HAVE HEARD THAT SUB-LICENSING OF USB-IDs IS ILLEGAL? +====================================================== + +A 16 bit integer number cannot be protected by copyright laws. It is not +sufficiently complex. And since none of the parties involved entered into the +USB-IF Trademark License Agreement, we are not bound by this agreement. So +there is no reason why it should be illegal to sub-license USB-IDs. + + +============================================= +WHO IS LIABLE IF THERE ARE INCOMPATIBILITIES? +============================================= + +Objective Development disclaims all liabilities which might arise from the +assignment of IDs. If you guarantee product features to your customers +without proper disclaimer, YOU are liable for that. diff --git a/firmware/usbdrv/USB-IDs-for-free.txt b/firmware/usbdrv/USB-IDs-for-free.txt new file mode 100644 index 0000000..2f4d59a --- /dev/null +++ b/firmware/usbdrv/USB-IDs-for-free.txt @@ -0,0 +1,148 @@ +Version 2009-08-22 + +=========================== +FREE USB-IDs FOR SHARED USE +=========================== + +Objective Development has reserved a set of USB Product-IDs for use according +to the guidelines outlined below. For more information about the concept of +USB IDs please see the file USB-ID-FAQ.txt. Objective Development guarantees +that the IDs listed below are not used by any USB compliant devices. + + +==================== +MECHANISM OF SHARING +==================== + +From a technical point of view, two different devices can share the same USB +Vendor- and Product-ID if they require the same driver on operating system +level. We make use of this fact by assigning separate IDs for various device +classes. On application layer, devices must be distinguished by their textual +name or serial number. We offer separate sets of IDs for discrimination by +textual name and for serial number. + +Examples for shared use of USB IDs are included with V-USB in the "examples" +subdirectory. + + +====================================== +IDs FOR DISCRIMINATION BY TEXTUAL NAME +====================================== + +If you use one of the IDs listed below, your device and host-side software +must conform to these rules: + +(1) The USB device MUST provide a textual representation of the manufacturer +and product identification. The manufacturer identification MUST be available +at least in USB language 0x0409 (English/US). + +(2) The textual manufacturer identification MUST contain either an Internet +domain name (e.g. "mycompany.com") registered and owned by you, or an e-mail +address under your control (e.g. "myname@gmx.net"). You can embed the domain +name or e-mail address in any string you like, e.g. "Objective Development +http://www.obdev.at/vusb/". + +(3) You are responsible for retaining ownership of the domain or e-mail +address for as long as any of your products are in use. + +(4) You may choose any string for the textual product identification, as long +as this string is unique within the scope of your textual manufacturer +identification. + +(5) Application side device look-up MUST be based on the textual manufacturer +and product identification in addition to VID/PID matching. The driver +matching MUST be a comparison of the entire strings, NOT a sub-string match. + +(6) For devices which implement a particular USB device class (e.g. HID), the +operating system's default class driver MUST be used. If an operating system +driver for Vendor Class devices is needed, this driver must be libusb or +libusb-win32 (see http://libusb.org/ and +http://libusb-win32.sourceforge.net/). + +Table if IDs for discrimination by textual name: + +PID dec (hex) | VID dec (hex) | Description of use +==============+===============+============================================ +1500 (0x05dc) | 5824 (0x16c0) | For Vendor Class devices with libusb +--------------+---------------+-------------------------------------------- +1503 (0x05df) | 5824 (0x16c0) | For generic HID class devices (which are + | | NOT mice, keyboards or joysticks) +--------------+---------------+-------------------------------------------- +1505 (0x05e1) | 5824 (0x16c0) | For CDC-ACM class devices (modems) +--------------+---------------+-------------------------------------------- +1508 (0x05e4) | 5824 (0x16c0) | For MIDI class devices +--------------+---------------+-------------------------------------------- + +Note that Windows caches the textual product- and vendor-description for +mice, keyboards and joysticks. Name-bsed discrimination is therefore not +recommended for these device classes. + + +======================================= +IDs FOR DISCRIMINATION BY SERIAL NUMBER +======================================= + +If you use one of the IDs listed below, your device and host-side software +must conform to these rules: + +(1) The USB device MUST provide a textual representation of the serial +number. The serial number string MUST be available at least in USB language +0x0409 (English/US). + +(2) The serial number MUST start with either an Internet domain name (e.g. +"mycompany.com") registered and owned by you, or an e-mail address under your +control (e.g. "myname@gmx.net"), both terminated with a colon (":") character. +You MAY append any string you like for further discrimination of your devices. + +(3) You are responsible for retaining ownership of the domain or e-mail +address for as long as any of your products are in use. + +(5) Application side device look-up MUST be based on the serial number string +in addition to VID/PID matching. The matching must start at the first +character of the serial number string and include the colon character +terminating your domain or e-mail address. It MAY stop anywhere after that. + +(6) For devices which implement a particular USB device class (e.g. HID), the +operating system's default class driver MUST be used. If an operating system +driver for Vendor Class devices is needed, this driver must be libusb or +libusb-win32 (see http://libusb.org/ and +http://libusb-win32.sourceforge.net/). + +Table if IDs for discrimination by serial number string: + +PID dec (hex) | VID dec (hex) | Description of use +===============+===============+=========================================== +10200 (0x27d8) | 5824 (0x16c0) | For Vendor Class devices with libusb +---------------+---------------+------------------------------------------- +10201 (0x27d9) | 5824 (0x16c0) | For generic HID class devices (which are + | | NOT mice, keyboards or joysticks) +---------------+---------------+------------------------------------------- +10202 (0x27da) | 5824 (0x16c0) | For USB Mice +---------------+---------------+------------------------------------------- +10203 (0x27db) | 5824 (0x16c0) | For USB Keyboards +---------------+---------------+------------------------------------------- +10204 (0x27db) | 5824 (0x16c0) | For USB Joysticks +---------------+---------------+------------------------------------------- +10205 (0x27dc) | 5824 (0x16c0) | For CDC-ACM class devices (modems) +---------------+---------------+------------------------------------------- +10206 (0x27dd) | 5824 (0x16c0) | For MIDI class devices +---------------+---------------+------------------------------------------- + + +================= +ORIGIN OF USB-IDs +================= + +OBJECTIVE DEVELOPMENT Software GmbH has obtained all VID/PID pairs listed +here from Wouter van Ooijen (see www.voti.nl) for exclusive disposition. +Wouter van Ooijen has obtained the VID from the USB Implementers Forum, Inc. +(see www.usb.org). The VID is registered for the company name "Van Ooijen +Technische Informatica". + + +========== +DISCLAIMER +========== + +OBJECTIVE DEVELOPMENT Software GmbH disclaims all liability for any +problems which are caused by the shared use of these VID/PID pairs. diff --git a/firmware/usbdrv/asmcommon.inc b/firmware/usbdrv/asmcommon.inc new file mode 100644 index 0000000..07d692b --- /dev/null +++ b/firmware/usbdrv/asmcommon.inc @@ -0,0 +1,188 @@ +/* Name: asmcommon.inc + * Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers + * Author: Christian Starkjohann + * Creation Date: 2007-11-05 + * Tabsize: 4 + * Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH + * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) + * Revision: $Id$ + */ + +/* Do not link this file! Link usbdrvasm.S instead, which includes the + * appropriate implementation! + */ + +/* +General Description: +This file contains assembler code which is shared among the USB driver +implementations for different CPU cocks. Since the code must be inserted +in the middle of the module, it's split out into this file and #included. + +Jump destinations called from outside: + sofError: Called when no start sequence was found. + se0: Called when a package has been successfully received. + overflow: Called when receive buffer overflows. + doReturn: Called after sending data. + +Outside jump destinations used by this module: + waitForJ: Called to receive an already arriving packet. + sendAckAndReti: + sendNakAndReti: + sendCntAndReti: + usbSendAndReti: + +The following macros must be defined before this file is included: + .macro POP_STANDARD + .endm + .macro POP_RETI + .endm +*/ + +#define token x1 + +overflow: + ldi x2, 1< 0 + +#warning "Never compile production devices with debugging enabled" + +static void uartPutc(char c) +{ + while(!(ODDBG_USR & (1 << ODDBG_UDRE))); /* wait for data register empty */ + ODDBG_UDR = c; +} + +static uchar hexAscii(uchar h) +{ + h &= 0xf; + if(h >= 10) + h += 'a' - (uchar)10 - '0'; + h += '0'; + return h; +} + +static void printHex(uchar c) +{ + uartPutc(hexAscii(c >> 4)); + uartPutc(hexAscii(c)); +} + +void odDebug(uchar prefix, uchar *data, uchar len) +{ + printHex(prefix); + uartPutc(':'); + while(len--){ + uartPutc(' '); + printHex(*data++); + } + uartPutc('\r'); + uartPutc('\n'); +} + +#endif diff --git a/firmware/usbdrv/oddebug.h b/firmware/usbdrv/oddebug.h new file mode 100644 index 0000000..d61309d --- /dev/null +++ b/firmware/usbdrv/oddebug.h @@ -0,0 +1,123 @@ +/* Name: oddebug.h + * Project: AVR library + * Author: Christian Starkjohann + * Creation Date: 2005-01-16 + * Tabsize: 4 + * Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH + * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) + * This Revision: $Id: oddebug.h 692 2008-11-07 15:07:40Z cs $ + */ + +#ifndef __oddebug_h_included__ +#define __oddebug_h_included__ + +/* +General Description: +This module implements a function for debug logs on the serial line of the +AVR microcontroller. Debugging can be configured with the define +'DEBUG_LEVEL'. If this macro is not defined or defined to 0, all debugging +calls are no-ops. If it is 1, DBG1 logs will appear, but not DBG2. If it is +2, DBG1 and DBG2 logs will be printed. + +A debug log consists of a label ('prefix') to indicate which debug log created +the output and a memory block to dump in hex ('data' and 'len'). +*/ + + +#ifndef F_CPU +# define F_CPU 12000000 /* 12 MHz */ +#endif + +/* make sure we have the UART defines: */ +#include "usbportability.h" + +#ifndef uchar +# define uchar unsigned char +#endif + +#if DEBUG_LEVEL > 0 && !(defined TXEN || defined TXEN0) /* no UART in device */ +# warning "Debugging disabled because device has no UART" +# undef DEBUG_LEVEL +#endif + +#ifndef DEBUG_LEVEL +# define DEBUG_LEVEL 0 +#endif + +/* ------------------------------------------------------------------------- */ + +#if DEBUG_LEVEL > 0 +# define DBG1(prefix, data, len) odDebug(prefix, data, len) +#else +# define DBG1(prefix, data, len) +#endif + +#if DEBUG_LEVEL > 1 +# define DBG2(prefix, data, len) odDebug(prefix, data, len) +#else +# define DBG2(prefix, data, len) +#endif + +/* ------------------------------------------------------------------------- */ + +#if DEBUG_LEVEL > 0 +extern void odDebug(uchar prefix, uchar *data, uchar len); + +/* Try to find our control registers; ATMEL likes to rename these */ + +#if defined UBRR +# define ODDBG_UBRR UBRR +#elif defined UBRRL +# define ODDBG_UBRR UBRRL +#elif defined UBRR0 +# define ODDBG_UBRR UBRR0 +#elif defined UBRR0L +# define ODDBG_UBRR UBRR0L +#endif + +#if defined UCR +# define ODDBG_UCR UCR +#elif defined UCSRB +# define ODDBG_UCR UCSRB +#elif defined UCSR0B +# define ODDBG_UCR UCSR0B +#endif + +#if defined TXEN +# define ODDBG_TXEN TXEN +#else +# define ODDBG_TXEN TXEN0 +#endif + +#if defined USR +# define ODDBG_USR USR +#elif defined UCSRA +# define ODDBG_USR UCSRA +#elif defined UCSR0A +# define ODDBG_USR UCSR0A +#endif + +#if defined UDRE +# define ODDBG_UDRE UDRE +#else +# define ODDBG_UDRE UDRE0 +#endif + +#if defined UDR +# define ODDBG_UDR UDR +#elif defined UDR0 +# define ODDBG_UDR UDR0 +#endif + +static inline void odDebugInit(void) +{ + ODDBG_UCR |= (1<len & 0x10){ /* packet buffer was empty */ + txStatus->buffer[0] ^= USBPID_DATA0 ^ USBPID_DATA1; /* toggle token */ + }else{ + txStatus->len = USBPID_NAK; /* avoid sending outdated (overwritten) interrupt data */ + } + p = txStatus->buffer + 1; + i = len; + do{ /* if len == 0, we still copy 1 byte, but that's no problem */ + *p++ = *data++; + }while(--i > 0); /* loop control at the end is 2 bytes shorter than at beginning */ + usbCrc16Append(&txStatus->buffer[1], len); + txStatus->len = len + 4; /* len must be given including sync byte */ + DBG2(0x21 + (((int)txStatus >> 3) & 3), txStatus->buffer, len + 3); +} + +USB_PUBLIC void usbSetInterrupt(uchar *data, uchar len) +{ + usbGenericSetInterrupt(data, len, &usbTxStatus1); +} +#endif + +#if USB_CFG_HAVE_INTRIN_ENDPOINT3 +USB_PUBLIC void usbSetInterrupt3(uchar *data, uchar len) +{ + usbGenericSetInterrupt(data, len, &usbTxStatus3); +} +#endif +#endif /* USB_CFG_SUPPRESS_INTR_CODE */ + +/* ------------------ utilities for code following below ------------------- */ + +/* Use defines for the switch statement so that we can choose between an + * if()else if() and a switch/case based implementation. switch() is more + * efficient for a LARGE set of sequential choices, if() is better in all other + * cases. + */ +#if USB_CFG_USE_SWITCH_STATEMENT +# define SWITCH_START(cmd) switch(cmd){{ +# define SWITCH_CASE(value) }break; case (value):{ +# define SWITCH_CASE2(v1,v2) }break; case (v1): case(v2):{ +# define SWITCH_CASE3(v1,v2,v3) }break; case (v1): case(v2): case(v3):{ +# define SWITCH_DEFAULT }break; default:{ +# define SWITCH_END }} +#else +# define SWITCH_START(cmd) {uchar _cmd = cmd; if(0){ +# define SWITCH_CASE(value) }else if(_cmd == (value)){ +# define SWITCH_CASE2(v1,v2) }else if(_cmd == (v1) || _cmd == (v2)){ +# define SWITCH_CASE3(v1,v2,v3) }else if(_cmd == (v1) || _cmd == (v2) || (_cmd == v3)){ +# define SWITCH_DEFAULT }else{ +# define SWITCH_END }} +#endif + +#ifndef USB_RX_USER_HOOK +#define USB_RX_USER_HOOK(data, len) +#endif +#ifndef USB_SET_ADDRESS_HOOK +#define USB_SET_ADDRESS_HOOK() +#endif + +/* ------------------------------------------------------------------------- */ + +/* We use if() instead of #if in the macro below because #if can't be used + * in macros and the compiler optimizes constant conditions anyway. + * This may cause problems with undefined symbols if compiled without + * optimizing! + */ +#define GET_DESCRIPTOR(cfgProp, staticName) \ + if(cfgProp){ \ + if((cfgProp) & USB_PROP_IS_RAM) \ + flags = 0; \ + if((cfgProp) & USB_PROP_IS_DYNAMIC){ \ + len = usbFunctionDescriptor(rq); \ + }else{ \ + len = USB_PROP_LENGTH(cfgProp); \ + usbMsgPtr = (uchar *)(staticName); \ + } \ + } + +/* usbDriverDescriptor() is similar to usbFunctionDescriptor(), but used + * internally for all types of descriptors. + */ +static inline usbMsgLen_t usbDriverDescriptor(usbRequest_t *rq) +{ +usbMsgLen_t len = 0; +uchar flags = USB_FLG_MSGPTR_IS_ROM; + + SWITCH_START(rq->wValue.bytes[1]) + SWITCH_CASE(USBDESCR_DEVICE) /* 1 */ + GET_DESCRIPTOR(USB_CFG_DESCR_PROPS_DEVICE, usbDescriptorDevice) + SWITCH_CASE(USBDESCR_CONFIG) /* 2 */ + GET_DESCRIPTOR(USB_CFG_DESCR_PROPS_CONFIGURATION, usbDescriptorConfiguration) + SWITCH_CASE(USBDESCR_STRING) /* 3 */ +#if USB_CFG_DESCR_PROPS_STRINGS & USB_PROP_IS_DYNAMIC + if(USB_CFG_DESCR_PROPS_STRINGS & USB_PROP_IS_RAM) + flags = 0; + len = usbFunctionDescriptor(rq); +#else /* USB_CFG_DESCR_PROPS_STRINGS & USB_PROP_IS_DYNAMIC */ + SWITCH_START(rq->wValue.bytes[0]) + SWITCH_CASE(0) + GET_DESCRIPTOR(USB_CFG_DESCR_PROPS_STRING_0, usbDescriptorString0) + SWITCH_CASE(1) + GET_DESCRIPTOR(USB_CFG_DESCR_PROPS_STRING_VENDOR, usbDescriptorStringVendor) + SWITCH_CASE(2) + GET_DESCRIPTOR(USB_CFG_DESCR_PROPS_STRING_PRODUCT, usbDescriptorStringDevice) + SWITCH_CASE(3) + GET_DESCRIPTOR(USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER, usbDescriptorStringSerialNumber) + SWITCH_DEFAULT + if(USB_CFG_DESCR_PROPS_UNKNOWN & USB_PROP_IS_DYNAMIC){ + len = usbFunctionDescriptor(rq); + } + SWITCH_END +#endif /* USB_CFG_DESCR_PROPS_STRINGS & USB_PROP_IS_DYNAMIC */ +#if USB_CFG_DESCR_PROPS_HID_REPORT /* only support HID descriptors if enabled */ + SWITCH_CASE(USBDESCR_HID) /* 0x21 */ + GET_DESCRIPTOR(USB_CFG_DESCR_PROPS_HID, usbDescriptorConfiguration + 18) + SWITCH_CASE(USBDESCR_HID_REPORT)/* 0x22 */ + GET_DESCRIPTOR(USB_CFG_DESCR_PROPS_HID_REPORT, usbDescriptorHidReport) +#endif + SWITCH_DEFAULT + if(USB_CFG_DESCR_PROPS_UNKNOWN & USB_PROP_IS_DYNAMIC){ + len = usbFunctionDescriptor(rq); + } + SWITCH_END + usbMsgFlags = flags; + return len; +} + +/* ------------------------------------------------------------------------- */ + +/* usbDriverSetup() is similar to usbFunctionSetup(), but it's used for + * standard requests instead of class and custom requests. + */ +static inline usbMsgLen_t usbDriverSetup(usbRequest_t *rq) +{ +uchar len = 0, *dataPtr = usbTxBuf + 9; /* there are 2 bytes free space at the end of the buffer */ +uchar value = rq->wValue.bytes[0]; +#if USB_CFG_IMPLEMENT_HALT +uchar index = rq->wIndex.bytes[0]; +#endif + + dataPtr[0] = 0; /* default reply common to USBRQ_GET_STATUS and USBRQ_GET_INTERFACE */ + SWITCH_START(rq->bRequest) + SWITCH_CASE(USBRQ_GET_STATUS) /* 0 */ + uchar recipient = rq->bmRequestType & USBRQ_RCPT_MASK; /* assign arith ops to variables to enforce byte size */ + if(USB_CFG_IS_SELF_POWERED && recipient == USBRQ_RCPT_DEVICE) + dataPtr[0] = USB_CFG_IS_SELF_POWERED; +#if USB_CFG_IMPLEMENT_HALT + if(recipient == USBRQ_RCPT_ENDPOINT && index == 0x81) /* request status for endpoint 1 */ + dataPtr[0] = usbTxLen1 == USBPID_STALL; +#endif + dataPtr[1] = 0; + len = 2; +#if USB_CFG_IMPLEMENT_HALT + SWITCH_CASE2(USBRQ_CLEAR_FEATURE, USBRQ_SET_FEATURE) /* 1, 3 */ + if(value == 0 && index == 0x81){ /* feature 0 == HALT for endpoint == 1 */ + usbTxLen1 = rq->bRequest == USBRQ_CLEAR_FEATURE ? USBPID_NAK : USBPID_STALL; + usbResetDataToggling(); + } +#endif + SWITCH_CASE(USBRQ_SET_ADDRESS) /* 5 */ + usbNewDeviceAddr = value; + USB_SET_ADDRESS_HOOK(); + SWITCH_CASE(USBRQ_GET_DESCRIPTOR) /* 6 */ + len = usbDriverDescriptor(rq); + goto skipMsgPtrAssignment; + SWITCH_CASE(USBRQ_GET_CONFIGURATION) /* 8 */ + dataPtr = &usbConfiguration; /* send current configuration value */ + len = 1; + SWITCH_CASE(USBRQ_SET_CONFIGURATION) /* 9 */ + usbConfiguration = value; + usbResetStall(); + SWITCH_CASE(USBRQ_GET_INTERFACE) /* 10 */ + len = 1; +#if USB_CFG_HAVE_INTRIN_ENDPOINT && !USB_CFG_SUPPRESS_INTR_CODE + SWITCH_CASE(USBRQ_SET_INTERFACE) /* 11 */ + usbResetDataToggling(); + usbResetStall(); +#endif + SWITCH_DEFAULT /* 7=SET_DESCRIPTOR, 12=SYNC_FRAME */ + /* Should we add an optional hook here? */ + SWITCH_END + usbMsgPtr = dataPtr; +skipMsgPtrAssignment: + return len; +} + +/* ------------------------------------------------------------------------- */ + +/* usbProcessRx() is called for every message received by the interrupt + * routine. It distinguishes between SETUP and DATA packets and processes + * them accordingly. + */ +static inline void usbProcessRx(uchar *data, uchar len) +{ +usbRequest_t *rq = (void *)data; + +/* usbRxToken can be: + * 0x2d 00101101 (USBPID_SETUP for setup data) + * 0xe1 11100001 (USBPID_OUT: data phase of setup transfer) + * 0...0x0f for OUT on endpoint X + */ + DBG2(0x10 + (usbRxToken & 0xf), data, len + 2); /* SETUP=1d, SETUP-DATA=11, OUTx=1x */ + USB_RX_USER_HOOK(data, len) +#if USB_CFG_IMPLEMENT_FN_WRITEOUT + if(usbRxToken < 0x10){ /* OUT to endpoint != 0: endpoint number in usbRxToken */ + usbFunctionWriteOut(data, len); + return; + } +#endif + if(usbRxToken == (uchar)USBPID_SETUP){ + if(len != 8) /* Setup size must be always 8 bytes. Ignore otherwise. */ + return; + usbMsgLen_t replyLen; + usbTxBuf[0] = USBPID_DATA0; /* initialize data toggling */ + usbTxLen = USBPID_NAK; /* abort pending transmit */ + usbMsgFlags = 0; + uchar type = rq->bmRequestType & USBRQ_TYPE_MASK; + if(type != USBRQ_TYPE_STANDARD){ /* standard requests are handled by driver */ + replyLen = usbFunctionSetup(data); + }else{ + replyLen = usbDriverSetup(rq); + } +#if USB_CFG_IMPLEMENT_FN_READ || USB_CFG_IMPLEMENT_FN_WRITE + if(replyLen == USB_NO_MSG){ /* use user-supplied read/write function */ + /* do some conditioning on replyLen, but on IN transfers only */ + if((rq->bmRequestType & USBRQ_DIR_MASK) != USBRQ_DIR_HOST_TO_DEVICE){ + if(sizeof(replyLen) < sizeof(rq->wLength.word)){ /* help compiler with optimizing */ + replyLen = rq->wLength.bytes[0]; + }else{ + replyLen = rq->wLength.word; + } + } + usbMsgFlags = USB_FLG_USE_USER_RW; + }else /* The 'else' prevents that we limit a replyLen of USB_NO_MSG to the maximum transfer len. */ +#endif + if(sizeof(replyLen) < sizeof(rq->wLength.word)){ /* help compiler with optimizing */ + if(!rq->wLength.bytes[1] && replyLen > rq->wLength.bytes[0]) /* limit length to max */ + replyLen = rq->wLength.bytes[0]; + }else{ + if(replyLen > rq->wLength.word) /* limit length to max */ + replyLen = rq->wLength.word; + } + usbMsgLen = replyLen; + }else{ /* usbRxToken must be USBPID_OUT, which means data phase of setup (control-out) */ +#if USB_CFG_IMPLEMENT_FN_WRITE + if(usbMsgFlags & USB_FLG_USE_USER_RW){ + uchar rval = usbFunctionWrite(data, len); + if(rval == 0xff){ /* an error occurred */ + usbTxLen = USBPID_STALL; + }else if(rval != 0){ /* This was the final package */ + usbMsgLen = 0; /* answer with a zero-sized data packet */ + } + } +#endif + } +} + +/* ------------------------------------------------------------------------- */ + +/* This function is similar to usbFunctionRead(), but it's also called for + * data handled automatically by the driver (e.g. descriptor reads). + */ +static uchar usbDeviceRead(uchar *data, uchar len) +{ + if(len > 0){ /* don't bother app with 0 sized reads */ +#if USB_CFG_IMPLEMENT_FN_READ + if(usbMsgFlags & USB_FLG_USE_USER_RW){ + len = usbFunctionRead(data, len); + }else +#endif + { + uchar i = len, *r = usbMsgPtr; + if(usbMsgFlags & USB_FLG_MSGPTR_IS_ROM){ /* ROM data */ + do{ + uchar c = USB_READ_FLASH(r); /* assign to char size variable to enforce byte ops */ + *data++ = c; + r++; + }while(--i); + }else{ /* RAM data */ + do{ + *data++ = *r++; + }while(--i); + } + usbMsgPtr = r; + } + } + return len; +} + +/* ------------------------------------------------------------------------- */ + +/* usbBuildTxBlock() is called when we have data to transmit and the + * interrupt routine's transmit buffer is empty. + */ +static inline void usbBuildTxBlock(void) +{ +usbMsgLen_t wantLen; +uchar len; + + wantLen = usbMsgLen; + if(wantLen > 8) + wantLen = 8; + usbMsgLen -= wantLen; + usbTxBuf[0] ^= USBPID_DATA0 ^ USBPID_DATA1; /* DATA toggling */ + len = usbDeviceRead(usbTxBuf + 1, wantLen); + if(len <= 8){ /* valid data packet */ + usbCrc16Append(&usbTxBuf[1], len); + len += 4; /* length including sync byte */ + if(len < 12) /* a partial package identifies end of message */ + usbMsgLen = USB_NO_MSG; + }else{ + len = USBPID_STALL; /* stall the endpoint */ + usbMsgLen = USB_NO_MSG; + } + usbTxLen = len; + DBG2(0x20, usbTxBuf, len-1); +} + +/* ------------------------------------------------------------------------- */ + +static inline void usbHandleResetHook(uchar notResetState) +{ +#ifdef USB_RESET_HOOK +static uchar wasReset; +uchar isReset = !notResetState; + + if(wasReset != isReset){ + USB_RESET_HOOK(isReset); + wasReset = isReset; + } +#endif +} + +/* ------------------------------------------------------------------------- */ + +USB_PUBLIC void usbPoll(void) +{ +schar len; +uchar i; + + len = usbRxLen - 3; + if(len >= 0){ +/* We could check CRC16 here -- but ACK has already been sent anyway. If you + * need data integrity checks with this driver, check the CRC in your app + * code and report errors back to the host. Since the ACK was already sent, + * retries must be handled on application level. + * unsigned crc = usbCrc16(buffer + 1, usbRxLen - 3); + */ + usbProcessRx(usbRxBuf + USB_BUFSIZE + 1 - usbInputBufOffset, len); +#if USB_CFG_HAVE_FLOWCONTROL + if(usbRxLen > 0) /* only mark as available if not inactivated */ + usbRxLen = 0; +#else + usbRxLen = 0; /* mark rx buffer as available */ +#endif + } + if(usbTxLen & 0x10){ /* transmit system idle */ + if(usbMsgLen != USB_NO_MSG){ /* transmit data pending? */ + usbBuildTxBlock(); + } + } + for(i = 20; i > 0; i--){ + uchar usbLineStatus = USBIN & USBMASK; + if(usbLineStatus != 0) /* SE0 has ended */ + goto isNotReset; + } + /* RESET condition, called multiple times during reset */ + usbNewDeviceAddr = 0; + usbDeviceAddr = 0; + usbResetStall(); + DBG1(0xff, 0, 0); +isNotReset: + usbHandleResetHook(i); +} + +/* ------------------------------------------------------------------------- */ + +USB_PUBLIC void usbInit(void) +{ +#if USB_INTR_CFG_SET != 0 + USB_INTR_CFG |= USB_INTR_CFG_SET; +#endif +#if USB_INTR_CFG_CLR != 0 + USB_INTR_CFG &= ~(USB_INTR_CFG_CLR); +#endif + USB_INTR_ENABLE |= (1 << USB_INTR_ENABLE_BIT); + usbResetDataToggling(); +#if USB_CFG_HAVE_INTRIN_ENDPOINT && !USB_CFG_SUPPRESS_INTR_CODE + usbTxLen1 = USBPID_NAK; +#if USB_CFG_HAVE_INTRIN_ENDPOINT3 + usbTxLen3 = USBPID_NAK; +#endif +#endif +} + +/* ------------------------------------------------------------------------- */ diff --git a/firmware/usbdrv/usbdrv.h b/firmware/usbdrv/usbdrv.h new file mode 100644 index 0000000..3a78f30 --- /dev/null +++ b/firmware/usbdrv/usbdrv.h @@ -0,0 +1,735 @@ +/* Name: usbdrv.h + * Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers + * Author: Christian Starkjohann + * Creation Date: 2004-12-29 + * Tabsize: 4 + * Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH + * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) + * This Revision: $Id: usbdrv.h 793 2010-07-15 15:58:11Z cs $ + */ + +#ifndef __usbdrv_h_included__ +#define __usbdrv_h_included__ +#include "usbconfig.h" +#include "usbportability.h" + +/* +Hardware Prerequisites: +======================= +USB lines D+ and D- MUST be wired to the same I/O port. We recommend that D+ +triggers the interrupt (best achieved by using INT0 for D+), but it is also +possible to trigger the interrupt from D-. If D- is used, interrupts are also +triggered by SOF packets. D- requires a pull-up of 1.5k to +3.5V (and the +device must be powered at 3.5V) to identify as low-speed USB device. A +pull-down or pull-up of 1M SHOULD be connected from D+ to +3.5V to prevent +interference when no USB master is connected. If you use Zener diodes to limit +the voltage on D+ and D-, you MUST use a pull-down resistor, not a pull-up. +We use D+ as interrupt source and not D- because it does not trigger on +keep-alive and RESET states. If you want to count keep-alive events with +USB_COUNT_SOF, you MUST use D- as an interrupt source. + +As a compile time option, the 1.5k pull-up resistor on D- can be made +switchable to allow the device to disconnect at will. See the definition of +usbDeviceConnect() and usbDeviceDisconnect() further down in this file. + +Please adapt the values in usbconfig.h according to your hardware! + +The device MUST be clocked at exactly 12 MHz, 15 MHz, 16 MHz or 20 MHz +or at 12.8 MHz resp. 16.5 MHz +/- 1%. See usbconfig-prototype.h for details. + + +Limitations: +============ +Robustness with respect to communication errors: +The driver assumes error-free communication. It DOES check for errors in +the PID, but does NOT check bit stuffing errors, SE0 in middle of a byte, +token CRC (5 bit) and data CRC (16 bit). CRC checks can not be performed due +to timing constraints: We must start sending a reply within 7 bit times. +Bit stuffing and misplaced SE0 would have to be checked in real-time, but CPU +performance does not permit that. The driver does not check Data0/Data1 +toggling, but application software can implement the check. + +Input characteristics: +Since no differential receiver circuit is used, electrical interference +robustness may suffer. The driver samples only one of the data lines with +an ordinary I/O pin's input characteristics. However, since this is only a +low speed USB implementation and the specification allows for 8 times the +bit rate over the same hardware, we should be on the safe side. Even the spec +requires detection of asymmetric states at high bit rate for SE0 detection. + +Number of endpoints: +The driver supports the following endpoints: + +- Endpoint 0, the default control endpoint. +- Any number of interrupt- or bulk-out endpoints. The data is sent to + usbFunctionWriteOut() and USB_CFG_IMPLEMENT_FN_WRITEOUT must be defined + to 1 to activate this feature. The endpoint number can be found in the + global variable 'usbRxToken'. +- One default interrupt- or bulk-in endpoint. This endpoint is used for + interrupt- or bulk-in transfers which are not handled by any other endpoint. + You must define USB_CFG_HAVE_INTRIN_ENDPOINT in order to activate this + feature and call usbSetInterrupt() to send interrupt/bulk data. +- One additional interrupt- or bulk-in endpoint. This was endpoint 3 in + previous versions of this driver but can now be configured to any endpoint + number. You must define USB_CFG_HAVE_INTRIN_ENDPOINT3 in order to activate + this feature and call usbSetInterrupt3() to send interrupt/bulk data. The + endpoint number can be set with USB_CFG_EP3_NUMBER. + +Please note that the USB standard forbids bulk endpoints for low speed devices! +Most operating systems allow them anyway, but the AVR will spend 90% of the CPU +time in the USB interrupt polling for bulk data. + +Maximum data payload: +Data payload of control in and out transfers may be up to 254 bytes. In order +to accept payload data of out transfers, you need to implement +'usbFunctionWrite()'. + +USB Suspend Mode supply current: +The USB standard limits power consumption to 500uA when the bus is in suspend +mode. This is not a problem for self-powered devices since they don't need +bus power anyway. Bus-powered devices can achieve this only by putting the +CPU in sleep mode. The driver does not implement suspend handling by itself. +However, the application may implement activity monitoring and wakeup from +sleep. The host sends regular SE0 states on the bus to keep it active. These +SE0 states can be detected by using D- as the interrupt source. Define +USB_COUNT_SOF to 1 and use the global variable usbSofCount to check for bus +activity. + +Operation without an USB master: +The driver behaves neutral without connection to an USB master if D- reads +as 1. To avoid spurious interrupts, we recommend a high impedance (e.g. 1M) +pull-down or pull-up resistor on D+ (interrupt). If Zener diodes are used, +use a pull-down. If D- becomes statically 0, the driver may block in the +interrupt routine. + +Interrupt latency: +The application must ensure that the USB interrupt is not disabled for more +than 25 cycles (this is for 12 MHz, faster clocks allow longer latency). +This implies that all interrupt routines must either have the "ISR_NOBLOCK" +attribute set (see "avr/interrupt.h") or be written in assembler with "sei" +as the first instruction. + +Maximum interrupt duration / CPU cycle consumption: +The driver handles all USB communication during the interrupt service +routine. The routine will not return before an entire USB message is received +and the reply is sent. This may be up to ca. 1200 cycles @ 12 MHz (= 100us) if +the host conforms to the standard. The driver will consume CPU cycles for all +USB messages, even if they address another (low-speed) device on the same bus. + +*/ + +/* ------------------------------------------------------------------------- */ +/* --------------------------- Module Interface ---------------------------- */ +/* ------------------------------------------------------------------------- */ + +#define USBDRV_VERSION 20100715 +/* This define uniquely identifies a driver version. It is a decimal number + * constructed from the driver's release date in the form YYYYMMDD. If the + * driver's behavior or interface changes, you can use this constant to + * distinguish versions. If it is not defined, the driver's release date is + * older than 2006-01-25. + */ + + +#ifndef USB_PUBLIC +#define USB_PUBLIC +#endif +/* USB_PUBLIC is used as declaration attribute for all functions exported by + * the USB driver. The default is no attribute (see above). You may define it + * to static either in usbconfig.h or from the command line if you include + * usbdrv.c instead of linking against it. Including the C module of the driver + * directly in your code saves a couple of bytes in flash memory. + */ + +#ifndef __ASSEMBLER__ +#ifndef uchar +#define uchar unsigned char +#endif +#ifndef schar +#define schar signed char +#endif +/* shortcuts for well defined 8 bit integer types */ + +#if USB_CFG_LONG_TRANSFERS /* if more than 254 bytes transfer size required */ +# define usbMsgLen_t unsigned +#else +# define usbMsgLen_t uchar +#endif +/* usbMsgLen_t is the data type used for transfer lengths. By default, it is + * defined to uchar, allowing a maximum of 254 bytes (255 is reserved for + * USB_NO_MSG below). If the usbconfig.h defines USB_CFG_LONG_TRANSFERS to 1, + * a 16 bit data type is used, allowing up to 16384 bytes (the rest is used + * for flags in the descriptor configuration). + */ +#define USB_NO_MSG ((usbMsgLen_t)-1) /* constant meaning "no message" */ + +struct usbRequest; /* forward declaration */ + +USB_PUBLIC void usbInit(void); +/* This function must be called before interrupts are enabled and the main + * loop is entered. We exepct that the PORT and DDR bits for D+ and D- have + * not been changed from their default status (which is 0). If you have changed + * them, set both back to 0 (configure them as input with no internal pull-up). + */ +USB_PUBLIC void usbPoll(void); +/* This function must be called at regular intervals from the main loop. + * Maximum delay between calls is somewhat less than 50ms (USB timeout for + * accepting a Setup message). Otherwise the device will not be recognized. + * Please note that debug outputs through the UART take ~ 0.5ms per byte + * at 19200 bps. + */ +extern uchar *usbMsgPtr; +/* This variable may be used to pass transmit data to the driver from the + * implementation of usbFunctionWrite(). It is also used internally by the + * driver for standard control requests. + */ +USB_PUBLIC usbMsgLen_t usbFunctionSetup(uchar data[8]); +/* This function is called when the driver receives a SETUP transaction from + * the host which is not answered by the driver itself (in practice: class and + * vendor requests). All control transfers start with a SETUP transaction where + * the host communicates the parameters of the following (optional) data + * transfer. The SETUP data is available in the 'data' parameter which can + * (and should) be casted to 'usbRequest_t *' for a more user-friendly access + * to parameters. + * + * If the SETUP indicates a control-in transfer, you should provide the + * requested data to the driver. There are two ways to transfer this data: + * (1) Set the global pointer 'usbMsgPtr' to the base of the static RAM data + * block and return the length of the data in 'usbFunctionSetup()'. The driver + * will handle the rest. Or (2) return USB_NO_MSG in 'usbFunctionSetup()'. The + * driver will then call 'usbFunctionRead()' when data is needed. See the + * documentation for usbFunctionRead() for details. + * + * If the SETUP indicates a control-out transfer, the only way to receive the + * data from the host is through the 'usbFunctionWrite()' call. If you + * implement this function, you must return USB_NO_MSG in 'usbFunctionSetup()' + * to indicate that 'usbFunctionWrite()' should be used. See the documentation + * of this function for more information. If you just want to ignore the data + * sent by the host, return 0 in 'usbFunctionSetup()'. + * + * Note that calls to the functions usbFunctionRead() and usbFunctionWrite() + * are only done if enabled by the configuration in usbconfig.h. + */ +USB_PUBLIC usbMsgLen_t usbFunctionDescriptor(struct usbRequest *rq); +/* You need to implement this function ONLY if you provide USB descriptors at + * runtime (which is an expert feature). It is very similar to + * usbFunctionSetup() above, but it is called only to request USB descriptor + * data. See the documentation of usbFunctionSetup() above for more info. + */ +#if USB_CFG_HAVE_INTRIN_ENDPOINT +USB_PUBLIC void usbSetInterrupt(uchar *data, uchar len); +/* This function sets the message which will be sent during the next interrupt + * IN transfer. The message is copied to an internal buffer and must not exceed + * a length of 8 bytes. The message may be 0 bytes long just to indicate the + * interrupt status to the host. + * If you need to transfer more bytes, use a control read after the interrupt. + */ +#define usbInterruptIsReady() (usbTxLen1 & 0x10) +/* This macro indicates whether the last interrupt message has already been + * sent. If you set a new interrupt message before the old was sent, the + * message already buffered will be lost. + */ +#if USB_CFG_HAVE_INTRIN_ENDPOINT3 +USB_PUBLIC void usbSetInterrupt3(uchar *data, uchar len); +#define usbInterruptIsReady3() (usbTxLen3 & 0x10) +/* Same as above for endpoint 3 */ +#endif +#endif /* USB_CFG_HAVE_INTRIN_ENDPOINT */ +#if USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH /* simplified interface for backward compatibility */ +#define usbHidReportDescriptor usbDescriptorHidReport +/* should be declared as: PROGMEM char usbHidReportDescriptor[]; */ +/* If you implement an HID device, you need to provide a report descriptor. + * The HID report descriptor syntax is a bit complex. If you understand how + * report descriptors are constructed, we recommend that you use the HID + * Descriptor Tool from usb.org, see http://www.usb.org/developers/hidpage/. + * Otherwise you should probably start with a working example. + */ +#endif /* USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH */ +#if USB_CFG_IMPLEMENT_FN_WRITE +USB_PUBLIC uchar usbFunctionWrite(uchar *data, uchar len); +/* This function is called by the driver to provide a control transfer's + * payload data (control-out). It is called in chunks of up to 8 bytes. The + * total count provided in the current control transfer can be obtained from + * the 'length' property in the setup data. If an error occurred during + * processing, return 0xff (== -1). The driver will answer the entire transfer + * with a STALL token in this case. If you have received the entire payload + * successfully, return 1. If you expect more data, return 0. If you don't + * know whether the host will send more data (you should know, the total is + * provided in the usbFunctionSetup() call!), return 1. + * NOTE: If you return 0xff for STALL, 'usbFunctionWrite()' may still be called + * for the remaining data. You must continue to return 0xff for STALL in these + * calls. + * In order to get usbFunctionWrite() called, define USB_CFG_IMPLEMENT_FN_WRITE + * to 1 in usbconfig.h and return 0xff in usbFunctionSetup().. + */ +#endif /* USB_CFG_IMPLEMENT_FN_WRITE */ +#if USB_CFG_IMPLEMENT_FN_READ +USB_PUBLIC uchar usbFunctionRead(uchar *data, uchar len); +/* This function is called by the driver to ask the application for a control + * transfer's payload data (control-in). It is called in chunks of up to 8 + * bytes each. You should copy the data to the location given by 'data' and + * return the actual number of bytes copied. If you return less than requested, + * the control-in transfer is terminated. If you return 0xff, the driver aborts + * the transfer with a STALL token. + * In order to get usbFunctionRead() called, define USB_CFG_IMPLEMENT_FN_READ + * to 1 in usbconfig.h and return 0xff in usbFunctionSetup().. + */ +#endif /* USB_CFG_IMPLEMENT_FN_READ */ + +extern uchar usbRxToken; /* may be used in usbFunctionWriteOut() below */ +#if USB_CFG_IMPLEMENT_FN_WRITEOUT +USB_PUBLIC void usbFunctionWriteOut(uchar *data, uchar len); +/* This function is called by the driver when data is received on an interrupt- + * or bulk-out endpoint. The endpoint number can be found in the global + * variable usbRxToken. You must define USB_CFG_IMPLEMENT_FN_WRITEOUT to 1 in + * usbconfig.h to get this function called. + */ +#endif /* USB_CFG_IMPLEMENT_FN_WRITEOUT */ +#ifdef USB_CFG_PULLUP_IOPORTNAME +#define usbDeviceConnect() ((USB_PULLUP_DDR |= (1<device, 1=device->host + * t ..... type: 0=standard, 1=class, 2=vendor, 3=reserved + * r ..... recipient: 0=device, 1=interface, 2=endpoint, 3=other + */ + +/* USB setup recipient values */ +#define USBRQ_RCPT_MASK 0x1f +#define USBRQ_RCPT_DEVICE 0 +#define USBRQ_RCPT_INTERFACE 1 +#define USBRQ_RCPT_ENDPOINT 2 + +/* USB request type values */ +#define USBRQ_TYPE_MASK 0x60 +#define USBRQ_TYPE_STANDARD (0<<5) +#define USBRQ_TYPE_CLASS (1<<5) +#define USBRQ_TYPE_VENDOR (2<<5) + +/* USB direction values: */ +#define USBRQ_DIR_MASK 0x80 +#define USBRQ_DIR_HOST_TO_DEVICE (0<<7) +#define USBRQ_DIR_DEVICE_TO_HOST (1<<7) + +/* USB Standard Requests */ +#define USBRQ_GET_STATUS 0 +#define USBRQ_CLEAR_FEATURE 1 +#define USBRQ_SET_FEATURE 3 +#define USBRQ_SET_ADDRESS 5 +#define USBRQ_GET_DESCRIPTOR 6 +#define USBRQ_SET_DESCRIPTOR 7 +#define USBRQ_GET_CONFIGURATION 8 +#define USBRQ_SET_CONFIGURATION 9 +#define USBRQ_GET_INTERFACE 10 +#define USBRQ_SET_INTERFACE 11 +#define USBRQ_SYNCH_FRAME 12 + +/* USB descriptor constants */ +#define USBDESCR_DEVICE 1 +#define USBDESCR_CONFIG 2 +#define USBDESCR_STRING 3 +#define USBDESCR_INTERFACE 4 +#define USBDESCR_ENDPOINT 5 +#define USBDESCR_HID 0x21 +#define USBDESCR_HID_REPORT 0x22 +#define USBDESCR_HID_PHYS 0x23 + +//#define USBATTR_BUSPOWER 0x80 // USB 1.1 does not define this value any more +#define USBATTR_SELFPOWER 0x40 +#define USBATTR_REMOTEWAKE 0x20 + +/* USB HID Requests */ +#define USBRQ_HID_GET_REPORT 0x01 +#define USBRQ_HID_GET_IDLE 0x02 +#define USBRQ_HID_GET_PROTOCOL 0x03 +#define USBRQ_HID_SET_REPORT 0x09 +#define USBRQ_HID_SET_IDLE 0x0a +#define USBRQ_HID_SET_PROTOCOL 0x0b + +/* ------------------------------------------------------------------------- */ + +#endif /* __usbdrv_h_included__ */ diff --git a/firmware/usbdrv/usbdrvasm.S b/firmware/usbdrv/usbdrvasm.S new file mode 100644 index 0000000..45fcf18 --- /dev/null +++ b/firmware/usbdrv/usbdrvasm.S @@ -0,0 +1,393 @@ +/* Name: usbdrvasm.S + * Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers + * Author: Christian Starkjohann + * Creation Date: 2007-06-13 + * Tabsize: 4 + * Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH + * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) + * Revision: $Id: usbdrvasm.S 785 2010-05-30 17:57:07Z cs $ + */ + +/* +General Description: +This module is the assembler part of the USB driver. This file contains +general code (preprocessor acrobatics and CRC computation) and then includes +the file appropriate for the given clock rate. +*/ + +#define __SFR_OFFSET 0 /* used by avr-libc's register definitions */ +#include "usbportability.h" +#include "usbdrv.h" /* for common defs */ + +/* register names */ +#define x1 r16 +#define x2 r17 +#define shift r18 +#define cnt r19 +#define x3 r20 +#define x4 r21 +#define x5 r22 +#define bitcnt x5 +#define phase x4 +#define leap x4 + +/* Some assembler dependent definitions and declarations: */ + +#ifdef __IAR_SYSTEMS_ASM__ + extern usbRxBuf, usbDeviceAddr, usbNewDeviceAddr, usbInputBufOffset + extern usbCurrentTok, usbRxLen, usbRxToken, usbTxLen + extern usbTxBuf, usbTxStatus1, usbTxStatus3 +# if USB_COUNT_SOF + extern usbSofCount +# endif + public usbCrc16 + public usbCrc16Append + + COMMON INTVEC +# ifndef USB_INTR_VECTOR + ORG INT0_vect +# else /* USB_INTR_VECTOR */ + ORG USB_INTR_VECTOR +# undef USB_INTR_VECTOR +# endif /* USB_INTR_VECTOR */ +# define USB_INTR_VECTOR usbInterruptHandler + rjmp USB_INTR_VECTOR + RSEG CODE + +#else /* __IAR_SYSTEMS_ASM__ */ + +# ifndef USB_INTR_VECTOR /* default to hardware interrupt INT0 */ +# ifdef INT0_vect +# define USB_INTR_VECTOR INT0_vect // this is the "new" define for the vector +# else +# define USB_INTR_VECTOR SIG_INTERRUPT0 // this is the "old" vector +# endif +# endif + .text + .global USB_INTR_VECTOR + .type USB_INTR_VECTOR, @function + .global usbCrc16 + .global usbCrc16Append +#endif /* __IAR_SYSTEMS_ASM__ */ + + +#if USB_INTR_PENDING < 0x40 /* This is an I/O address, use in and out */ +# define USB_LOAD_PENDING(reg) in reg, USB_INTR_PENDING +# define USB_STORE_PENDING(reg) out USB_INTR_PENDING, reg +#else /* It's a memory address, use lds and sts */ +# define USB_LOAD_PENDING(reg) lds reg, USB_INTR_PENDING +# define USB_STORE_PENDING(reg) sts USB_INTR_PENDING, reg +#endif + +#define usbTxLen1 usbTxStatus1 +#define usbTxBuf1 (usbTxStatus1 + 1) +#define usbTxLen3 usbTxStatus3 +#define usbTxBuf3 (usbTxStatus3 + 1) + + +;---------------------------------------------------------------------------- +; Utility functions +;---------------------------------------------------------------------------- + +#ifdef __IAR_SYSTEMS_ASM__ +/* Register assignments for usbCrc16 on IAR cc */ +/* Calling conventions on IAR: + * First parameter passed in r16/r17, second in r18/r19 and so on. + * Callee must preserve r4-r15, r24-r29 (r28/r29 is frame pointer) + * Result is passed in r16/r17 + * In case of the "tiny" memory model, pointers are only 8 bit with no + * padding. We therefore pass argument 1 as "16 bit unsigned". + */ +RTMODEL "__rt_version", "3" +/* The line above will generate an error if cc calling conventions change. + * The value "3" above is valid for IAR 4.10B/W32 + */ +# define argLen r18 /* argument 2 */ +# define argPtrL r16 /* argument 1 */ +# define argPtrH r17 /* argument 1 */ + +# define resCrcL r16 /* result */ +# define resCrcH r17 /* result */ + +# define ptrL ZL +# define ptrH ZH +# define ptr Z +# define byte r22 +# define bitCnt r19 +# define polyL r20 +# define polyH r21 +# define scratch r23 + +#else /* __IAR_SYSTEMS_ASM__ */ +/* Register assignments for usbCrc16 on gcc */ +/* Calling conventions on gcc: + * First parameter passed in r24/r25, second in r22/23 and so on. + * Callee must preserve r1-r17, r28/r29 + * Result is passed in r24/r25 + */ +# define argLen r22 /* argument 2 */ +# define argPtrL r24 /* argument 1 */ +# define argPtrH r25 /* argument 1 */ + +# define resCrcL r24 /* result */ +# define resCrcH r25 /* result */ + +# define ptrL XL +# define ptrH XH +# define ptr x +# define byte r18 +# define bitCnt r19 +# define polyL r20 +# define polyH r21 +# define scratch r23 + +#endif + +#if USB_USE_FAST_CRC + +; This implementation is faster, but has bigger code size +; Thanks to Slawomir Fras (BoskiDialer) for this code! +; It implements the following C pseudo-code: +; unsigned table(unsigned char x) +; { +; unsigned value; +; +; value = (unsigned)x << 6; +; value ^= (unsigned)x << 7; +; if(parity(x)) +; value ^= 0xc001; +; return value; +; } +; unsigned usbCrc16(unsigned char *argPtr, unsigned char argLen) +; { +; unsigned crc = 0xffff; +; +; while(argLen--) +; crc = table(lo8(crc) ^ *argPtr++) ^ hi8(crc); +; return ~crc; +; } + +; extern unsigned usbCrc16(unsigned char *argPtr, unsigned char argLen); +; argPtr r24+25 / r16+r17 +; argLen r22 / r18 +; temp variables: +; byte r18 / r22 +; scratch r23 +; resCrc r24+r25 / r16+r17 +; ptr X / Z +usbCrc16: + mov ptrL, argPtrL + mov ptrH, argPtrH + ldi resCrcL, 0xFF + ldi resCrcH, 0xFF + rjmp usbCrc16LoopTest +usbCrc16ByteLoop: + ld byte, ptr+ + eor resCrcL, byte ; resCrcL is now 'x' in table() + mov byte, resCrcL ; compute parity of 'x' + swap byte + eor byte, resCrcL + mov scratch, byte + lsr byte + lsr byte + eor byte, scratch + inc byte + lsr byte + andi byte, 1 ; byte is now parity(x) + mov scratch, resCrcL + mov resCrcL, resCrcH + eor resCrcL, byte ; low byte of if(parity(x)) value ^= 0xc001; + neg byte + andi byte, 0xc0 + mov resCrcH, byte ; high byte of if(parity(x)) value ^= 0xc001; + clr byte + lsr scratch + ror byte + eor resCrcH, scratch + eor resCrcL, byte + lsr scratch + ror byte + eor resCrcH, scratch + eor resCrcL, byte +usbCrc16LoopTest: + subi argLen, 1 + brsh usbCrc16ByteLoop + com resCrcL + com resCrcH + ret + +#else /* USB_USE_FAST_CRC */ + +; This implementation is slower, but has less code size +; +; extern unsigned usbCrc16(unsigned char *argPtr, unsigned char argLen); +; argPtr r24+25 / r16+r17 +; argLen r22 / r18 +; temp variables: +; byte r18 / r22 +; bitCnt r19 +; poly r20+r21 +; scratch r23 +; resCrc r24+r25 / r16+r17 +; ptr X / Z +usbCrc16: + mov ptrL, argPtrL + mov ptrH, argPtrH + ldi resCrcL, 0 + ldi resCrcH, 0 + ldi polyL, lo8(0xa001) + ldi polyH, hi8(0xa001) + com argLen ; argLen = -argLen - 1: modified loop to ensure that carry is set + ldi bitCnt, 0 ; loop counter with starnd condition = end condition + rjmp usbCrcLoopEntry +usbCrcByteLoop: + ld byte, ptr+ + eor resCrcL, byte +usbCrcBitLoop: + ror resCrcH ; carry is always set here (see brcs jumps to here) + ror resCrcL + brcs usbCrcNoXor + eor resCrcL, polyL + eor resCrcH, polyH +usbCrcNoXor: + subi bitCnt, 224 ; (8 * 224) % 256 = 0; this loop iterates 8 times + brcs usbCrcBitLoop +usbCrcLoopEntry: + subi argLen, -1 + brcs usbCrcByteLoop +usbCrcReady: + ret +; Thanks to Reimar Doeffinger for optimizing this CRC routine! + +#endif /* USB_USE_FAST_CRC */ + +; extern unsigned usbCrc16Append(unsigned char *data, unsigned char len); +usbCrc16Append: + rcall usbCrc16 + st ptr+, resCrcL + st ptr+, resCrcH + ret + +#undef argLen +#undef argPtrL +#undef argPtrH +#undef resCrcL +#undef resCrcH +#undef ptrL +#undef ptrH +#undef ptr +#undef byte +#undef bitCnt +#undef polyL +#undef polyH +#undef scratch + + +#if USB_CFG_HAVE_MEASURE_FRAME_LENGTH +#ifdef __IAR_SYSTEMS_ASM__ +/* Register assignments for usbMeasureFrameLength on IAR cc */ +/* Calling conventions on IAR: + * First parameter passed in r16/r17, second in r18/r19 and so on. + * Callee must preserve r4-r15, r24-r29 (r28/r29 is frame pointer) + * Result is passed in r16/r17 + * In case of the "tiny" memory model, pointers are only 8 bit with no + * padding. We therefore pass argument 1 as "16 bit unsigned". + */ +# define resL r16 +# define resH r17 +# define cnt16L r30 +# define cnt16H r31 +# define cntH r18 + +#else /* __IAR_SYSTEMS_ASM__ */ +/* Register assignments for usbMeasureFrameLength on gcc */ +/* Calling conventions on gcc: + * First parameter passed in r24/r25, second in r22/23 and so on. + * Callee must preserve r1-r17, r28/r29 + * Result is passed in r24/r25 + */ +# define resL r24 +# define resH r25 +# define cnt16L r24 +# define cnt16H r25 +# define cntH r26 +#endif +# define cnt16 cnt16L + +; extern unsigned usbMeasurePacketLength(void); +; returns time between two idle strobes in multiples of 7 CPU clocks +.global usbMeasureFrameLength +usbMeasureFrameLength: + ldi cntH, 6 ; wait ~ 10 ms for D- == 0 + clr cnt16L + clr cnt16H +usbMFTime16: + dec cntH + breq usbMFTimeout +usbMFWaitStrobe: ; first wait for D- == 0 (idle strobe) + sbiw cnt16, 1 ;[0] [6] + breq usbMFTime16 ;[2] + sbic USBIN, USBMINUS ;[3] + rjmp usbMFWaitStrobe ;[4] +usbMFWaitIdle: ; then wait until idle again + sbis USBIN, USBMINUS ;1 wait for D- == 1 + rjmp usbMFWaitIdle ;2 + ldi cnt16L, 1 ;1 represents cycles so far + clr cnt16H ;1 +usbMFWaitLoop: + in cntH, USBIN ;[0] [7] + adiw cnt16, 1 ;[1] + breq usbMFTimeout ;[3] + andi cntH, USBMASK ;[4] + brne usbMFWaitLoop ;[5] +usbMFTimeout: +#if resL != cnt16L + mov resL, cnt16L + mov resH, cnt16H +#endif + ret + +#undef resL +#undef resH +#undef cnt16 +#undef cnt16L +#undef cnt16H +#undef cntH + +#endif /* USB_CFG_HAVE_MEASURE_FRAME_LENGTH */ + +;---------------------------------------------------------------------------- +; Now include the clock rate specific code +;---------------------------------------------------------------------------- + +#ifndef USB_CFG_CLOCK_KHZ +# ifdef F_CPU +# define USB_CFG_CLOCK_KHZ (F_CPU/1000) +# else +# error "USB_CFG_CLOCK_KHZ not defined in usbconfig.h and no F_CPU set!" +# endif +#endif + +#if USB_CFG_CHECK_CRC /* separate dispatcher for CRC type modules */ +# if USB_CFG_CLOCK_KHZ == 18000 +# include "usbdrvasm18-crc.inc" +# else +# error "USB_CFG_CLOCK_KHZ is not one of the supported crc-rates!" +# endif +#else /* USB_CFG_CHECK_CRC */ +# if USB_CFG_CLOCK_KHZ == 12000 +# include "usbdrvasm12.inc" +# elif USB_CFG_CLOCK_KHZ == 12800 +# include "usbdrvasm128.inc" +# elif USB_CFG_CLOCK_KHZ == 15000 +# include "usbdrvasm15.inc" +# elif USB_CFG_CLOCK_KHZ == 16000 +# include "usbdrvasm16.inc" +# elif USB_CFG_CLOCK_KHZ == 16500 +# include "usbdrvasm165.inc" +# elif USB_CFG_CLOCK_KHZ == 20000 +# include "usbdrvasm20.inc" +# else +# error "USB_CFG_CLOCK_KHZ is not one of the supported non-crc-rates!" +# endif +#endif /* USB_CFG_CHECK_CRC */ diff --git a/firmware/usbdrv/usbdrvasm.asm b/firmware/usbdrv/usbdrvasm.asm new file mode 100644 index 0000000..9cc4e4d --- /dev/null +++ b/firmware/usbdrv/usbdrvasm.asm @@ -0,0 +1,21 @@ +/* Name: usbdrvasm.asm + * Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers + * Author: Christian Starkjohann + * Creation Date: 2006-03-01 + * Tabsize: 4 + * Copyright: (c) 2006 by OBJECTIVE DEVELOPMENT Software GmbH + * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) + * This Revision: $Id$ + */ + +/* +General Description: +The IAR compiler/assembler system prefers assembler files with file extension +".asm". We simply provide this file as an alias for usbdrvasm.S. + +Thanks to Oleg Semyonov for his help with the IAR tools port! +*/ + +#include "usbdrvasm.S" + +end diff --git a/firmware/usbdrv/usbdrvasm12.inc b/firmware/usbdrv/usbdrvasm12.inc new file mode 100644 index 0000000..c116758 --- /dev/null +++ b/firmware/usbdrv/usbdrvasm12.inc @@ -0,0 +1,393 @@ +/* Name: usbdrvasm12.inc + * Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers + * Author: Christian Starkjohann + * Creation Date: 2004-12-29 + * Tabsize: 4 + * Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH + * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) + * This Revision: $Id: usbdrvasm12.inc 740 2009-04-13 18:23:31Z cs $ + */ + +/* Do not link this file! Link usbdrvasm.S instead, which includes the + * appropriate implementation! + */ + +/* +General Description: +This file is the 12 MHz version of the asssembler part of the USB driver. It +requires a 12 MHz crystal (not a ceramic resonator and not a calibrated RC +oscillator). + +See usbdrv.h for a description of the entire driver. + +Since almost all of this code is timing critical, don't change unless you +really know what you are doing! Many parts require not only a maximum number +of CPU cycles, but even an exact number of cycles! + + +Timing constraints according to spec (in bit times): +timing subject min max CPUcycles +--------------------------------------------------------------------------- +EOP of OUT/SETUP to sync pattern of DATA0 (both rx) 2 16 16-128 +EOP of IN to sync pattern of DATA0 (rx, then tx) 2 7.5 16-60 +DATAx (rx) to ACK/NAK/STALL (tx) 2 7.5 16-60 +*/ + +;Software-receiver engine. Strict timing! Don't change unless you can preserve timing! +;interrupt response time: 4 cycles + insn running = 7 max if interrupts always enabled +;max allowable interrupt latency: 34 cycles -> max 25 cycles interrupt disable +;max stack usage: [ret(2), YL, SREG, YH, shift, x1, x2, x3, cnt, x4] = 11 bytes +;Numbers in brackets are maximum cycles since SOF. +USB_INTR_VECTOR: +;order of registers pushed: YL, SREG [sofError], YH, shift, x1, x2, x3, cnt + push YL ;2 [35] push only what is necessary to sync with edge ASAP + in YL, SREG ;1 [37] + push YL ;2 [39] +;---------------------------------------------------------------------------- +; Synchronize with sync pattern: +;---------------------------------------------------------------------------- +;sync byte (D-) pattern LSb to MSb: 01010100 [1 = idle = J, 0 = K] +;sync up with J to K edge during sync pattern -- use fastest possible loops +;The first part waits at most 1 bit long since we must be in sync pattern. +;YL is guarenteed to be < 0x80 because I flag is clear. When we jump to +;waitForJ, ensure that this prerequisite is met. +waitForJ: + inc YL + sbis USBIN, USBMINUS + brne waitForJ ; just make sure we have ANY timeout +waitForK: +;The following code results in a sampling window of 1/4 bit which meets the spec. + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS + rjmp foundK +#if USB_COUNT_SOF + lds YL, usbSofCount + inc YL + sts usbSofCount, YL +#endif /* USB_COUNT_SOF */ +#ifdef USB_SOF_HOOK + USB_SOF_HOOK +#endif + rjmp sofError +foundK: +;{3, 5} after falling D- edge, average delay: 4 cycles [we want 4 for center sampling] +;we have 1 bit time for setup purposes, then sample again. Numbers in brackets +;are cycles from center of first sync (double K) bit after the instruction + push YH ;2 [2] + lds YL, usbInputBufOffset;2 [4] + clr YH ;1 [5] + subi YL, lo8(-(usbRxBuf));1 [6] + sbci YH, hi8(-(usbRxBuf));1 [7] + + sbis USBIN, USBMINUS ;1 [8] we want two bits K [sample 1 cycle too early] + rjmp haveTwoBitsK ;2 [10] + pop YH ;2 [11] undo the push from before + rjmp waitForK ;2 [13] this was not the end of sync, retry +haveTwoBitsK: +;---------------------------------------------------------------------------- +; push more registers and initialize values while we sample the first bits: +;---------------------------------------------------------------------------- + push shift ;2 [16] + push x1 ;2 [12] + push x2 ;2 [14] + + in x1, USBIN ;1 [17] <-- sample bit 0 + ldi shift, 0xff ;1 [18] + bst x1, USBMINUS ;1 [19] + bld shift, 0 ;1 [20] + push x3 ;2 [22] + push cnt ;2 [24] + + in x2, USBIN ;1 [25] <-- sample bit 1 + ser x3 ;1 [26] [inserted init instruction] + eor x1, x2 ;1 [27] + bst x1, USBMINUS ;1 [28] + bld shift, 1 ;1 [29] + ldi cnt, USB_BUFSIZE;1 [30] [inserted init instruction] + rjmp rxbit2 ;2 [32] + +;---------------------------------------------------------------------------- +; Receiver loop (numbers in brackets are cycles within byte after instr) +;---------------------------------------------------------------------------- + +unstuff0: ;1 (branch taken) + andi x3, ~0x01 ;1 [15] + mov x1, x2 ;1 [16] x2 contains last sampled (stuffed) bit + in x2, USBIN ;1 [17] <-- sample bit 1 again + ori shift, 0x01 ;1 [18] + rjmp didUnstuff0 ;2 [20] + +unstuff1: ;1 (branch taken) + mov x2, x1 ;1 [21] x1 contains last sampled (stuffed) bit + andi x3, ~0x02 ;1 [22] + ori shift, 0x02 ;1 [23] + nop ;1 [24] + in x1, USBIN ;1 [25] <-- sample bit 2 again + rjmp didUnstuff1 ;2 [27] + +unstuff2: ;1 (branch taken) + andi x3, ~0x04 ;1 [29] + ori shift, 0x04 ;1 [30] + mov x1, x2 ;1 [31] x2 contains last sampled (stuffed) bit + nop ;1 [32] + in x2, USBIN ;1 [33] <-- sample bit 3 + rjmp didUnstuff2 ;2 [35] + +unstuff3: ;1 (branch taken) + in x2, USBIN ;1 [34] <-- sample stuffed bit 3 [one cycle too late] + andi x3, ~0x08 ;1 [35] + ori shift, 0x08 ;1 [36] + rjmp didUnstuff3 ;2 [38] + +unstuff4: ;1 (branch taken) + andi x3, ~0x10 ;1 [40] + in x1, USBIN ;1 [41] <-- sample stuffed bit 4 + ori shift, 0x10 ;1 [42] + rjmp didUnstuff4 ;2 [44] + +unstuff5: ;1 (branch taken) + andi x3, ~0x20 ;1 [48] + in x2, USBIN ;1 [49] <-- sample stuffed bit 5 + ori shift, 0x20 ;1 [50] + rjmp didUnstuff5 ;2 [52] + +unstuff6: ;1 (branch taken) + andi x3, ~0x40 ;1 [56] + in x1, USBIN ;1 [57] <-- sample stuffed bit 6 + ori shift, 0x40 ;1 [58] + rjmp didUnstuff6 ;2 [60] + +; extra jobs done during bit interval: +; bit 0: store, clear [SE0 is unreliable here due to bit dribbling in hubs] +; bit 1: se0 check +; bit 2: overflow check +; bit 3: recovery from delay [bit 0 tasks took too long] +; bit 4: none +; bit 5: none +; bit 6: none +; bit 7: jump, eor +rxLoop: + eor x3, shift ;1 [0] reconstruct: x3 is 0 at bit locations we changed, 1 at others + in x1, USBIN ;1 [1] <-- sample bit 0 + st y+, x3 ;2 [3] store data + ser x3 ;1 [4] + nop ;1 [5] + eor x2, x1 ;1 [6] + bst x2, USBMINUS;1 [7] + bld shift, 0 ;1 [8] + in x2, USBIN ;1 [9] <-- sample bit 1 (or possibly bit 0 stuffed) + andi x2, USBMASK ;1 [10] + breq se0 ;1 [11] SE0 check for bit 1 + andi shift, 0xf9 ;1 [12] +didUnstuff0: + breq unstuff0 ;1 [13] + eor x1, x2 ;1 [14] + bst x1, USBMINUS;1 [15] + bld shift, 1 ;1 [16] +rxbit2: + in x1, USBIN ;1 [17] <-- sample bit 2 (or possibly bit 1 stuffed) + andi shift, 0xf3 ;1 [18] + breq unstuff1 ;1 [19] do remaining work for bit 1 +didUnstuff1: + subi cnt, 1 ;1 [20] + brcs overflow ;1 [21] loop control + eor x2, x1 ;1 [22] + bst x2, USBMINUS;1 [23] + bld shift, 2 ;1 [24] + in x2, USBIN ;1 [25] <-- sample bit 3 (or possibly bit 2 stuffed) + andi shift, 0xe7 ;1 [26] + breq unstuff2 ;1 [27] +didUnstuff2: + eor x1, x2 ;1 [28] + bst x1, USBMINUS;1 [29] + bld shift, 3 ;1 [30] +didUnstuff3: + andi shift, 0xcf ;1 [31] + breq unstuff3 ;1 [32] + in x1, USBIN ;1 [33] <-- sample bit 4 + eor x2, x1 ;1 [34] + bst x2, USBMINUS;1 [35] + bld shift, 4 ;1 [36] +didUnstuff4: + andi shift, 0x9f ;1 [37] + breq unstuff4 ;1 [38] + nop2 ;2 [40] + in x2, USBIN ;1 [41] <-- sample bit 5 + eor x1, x2 ;1 [42] + bst x1, USBMINUS;1 [43] + bld shift, 5 ;1 [44] +didUnstuff5: + andi shift, 0x3f ;1 [45] + breq unstuff5 ;1 [46] + nop2 ;2 [48] + in x1, USBIN ;1 [49] <-- sample bit 6 + eor x2, x1 ;1 [50] + bst x2, USBMINUS;1 [51] + bld shift, 6 ;1 [52] +didUnstuff6: + cpi shift, 0x02 ;1 [53] + brlo unstuff6 ;1 [54] + nop2 ;2 [56] + in x2, USBIN ;1 [57] <-- sample bit 7 + eor x1, x2 ;1 [58] + bst x1, USBMINUS;1 [59] + bld shift, 7 ;1 [60] +didUnstuff7: + cpi shift, 0x04 ;1 [61] + brsh rxLoop ;2 [63] loop control +unstuff7: + andi x3, ~0x80 ;1 [63] + ori shift, 0x80 ;1 [64] + in x2, USBIN ;1 [65] <-- sample stuffed bit 7 + nop ;1 [66] + rjmp didUnstuff7 ;2 [68] + +macro POP_STANDARD ; 12 cycles + pop cnt + pop x3 + pop x2 + pop x1 + pop shift + pop YH + endm +macro POP_RETI ; 5 cycles + pop YL + out SREG, YL + pop YL + endm + +#include "asmcommon.inc" + +;---------------------------------------------------------------------------- +; Transmitting data +;---------------------------------------------------------------------------- + +txByteLoop: +txBitloop: +stuffN1Delay: ; [03] + ror shift ;[-5] [11] [59] + brcc doExorN1 ;[-4] [60] + subi x4, 1 ;[-3] + brne commonN1 ;[-2] + lsl shift ;[-1] compensate ror after rjmp stuffDelay + nop ;[00] stuffing consists of just waiting 8 cycles + rjmp stuffN1Delay ;[01] after ror, C bit is reliably clear + +sendNakAndReti: ;0 [-19] 19 cycles until SOP + ldi x3, USBPID_NAK ;1 [-18] + rjmp usbSendX3 ;2 [-16] +sendAckAndReti: ;0 [-19] 19 cycles until SOP + ldi x3, USBPID_ACK ;1 [-18] + rjmp usbSendX3 ;2 [-16] +sendCntAndReti: ;0 [-17] 17 cycles until SOP + mov x3, cnt ;1 [-16] +usbSendX3: ;0 [-16] + ldi YL, 20 ;1 [-15] 'x3' is R20 + ldi YH, 0 ;1 [-14] + ldi cnt, 2 ;1 [-13] +; rjmp usbSendAndReti fallthrough + +; USB spec says: +; idle = J +; J = (D+ = 0), (D- = 1) or USBOUT = 0x01 +; K = (D+ = 1), (D- = 0) or USBOUT = 0x02 +; Spec allows 7.5 bit times from EOP to SOP for replies (= 60 cycles) + +;usbSend: +;pointer to data in 'Y' +;number of bytes in 'cnt' -- including sync byte +;uses: x1...x2, x4, shift, cnt, Y [x1 = mirror USBOUT, x2 = USBMASK, x4 = bitstuff cnt] +;Numbers in brackets are time since first bit of sync pattern is sent (start of instruction) +usbSendAndReti: + in x2, USBDDR ;[-12] 12 cycles until SOP + ori x2, USBMASK ;[-11] + sbi USBOUT, USBMINUS ;[-10] prepare idle state; D+ and D- must have been 0 (no pullups) + out USBDDR, x2 ;[-8] <--- acquire bus + in x1, USBOUT ;[-7] port mirror for tx loop + ldi shift, 0x40 ;[-6] sync byte is first byte sent (we enter loop after ror) + ldi x2, USBMASK ;[-5] + push x4 ;[-4] +doExorN1: + eor x1, x2 ;[-2] [06] [62] + ldi x4, 6 ;[-1] [07] [63] +commonN1: +stuffN2Delay: + out USBOUT, x1 ;[00] [08] [64] <--- set bit + ror shift ;[01] + brcc doExorN2 ;[02] + subi x4, 1 ;[03] + brne commonN2 ;[04] + lsl shift ;[05] compensate ror after rjmp stuffDelay + rjmp stuffN2Delay ;[06] after ror, C bit is reliably clear +doExorN2: + eor x1, x2 ;[04] [12] + ldi x4, 6 ;[05] [13] +commonN2: + nop ;[06] [14] + subi cnt, 171 ;[07] [15] trick: (3 * 171) & 0xff = 1 + out USBOUT, x1 ;[08] [16] <--- set bit + brcs txBitloop ;[09] [25] [41] + +stuff6Delay: + ror shift ;[42] [50] + brcc doExor6 ;[43] + subi x4, 1 ;[44] + brne common6 ;[45] + lsl shift ;[46] compensate ror after rjmp stuffDelay + nop ;[47] stuffing consists of just waiting 8 cycles + rjmp stuff6Delay ;[48] after ror, C bit is reliably clear +doExor6: + eor x1, x2 ;[45] [53] + ldi x4, 6 ;[46] +common6: +stuff7Delay: + ror shift ;[47] [55] + out USBOUT, x1 ;[48] <--- set bit + brcc doExor7 ;[49] + subi x4, 1 ;[50] + brne common7 ;[51] + lsl shift ;[52] compensate ror after rjmp stuffDelay + rjmp stuff7Delay ;[53] after ror, C bit is reliably clear +doExor7: + eor x1, x2 ;[51] [59] + ldi x4, 6 ;[52] +common7: + ld shift, y+ ;[53] + tst cnt ;[55] + out USBOUT, x1 ;[56] <--- set bit + brne txByteLoop ;[57] + +;make SE0: + cbr x1, USBMASK ;[58] prepare SE0 [spec says EOP may be 15 to 18 cycles] + lds x2, usbNewDeviceAddr;[59] + lsl x2 ;[61] we compare with left shifted address + subi YL, 2 + 20 ;[62] Only assign address on data packets, not ACK/NAK in x3 + sbci YH, 0 ;[63] + out USBOUT, x1 ;[00] <-- out SE0 -- from now 2 bits = 16 cycles until bus idle +;2006-03-06: moved transfer of new address to usbDeviceAddr from C-Code to asm: +;set address only after data packet was sent, not after handshake + breq skipAddrAssign ;[01] + sts usbDeviceAddr, x2 ; if not skipped: SE0 is one cycle longer +skipAddrAssign: +;end of usbDeviceAddress transfer + ldi x2, 1< 12.5625 MHz +max frequency: 69.286 cycles for 8 bit -> 12.99 MHz +nominal frequency: 12.77 MHz ( = sqrt(min * max)) + +sampling positions: (next even number in range [+/- 0.5]) +cycle index range: 0 ... 66 +bits: +.5, 8.875, 17.25, 25.625, 34, 42.375, 50.75, 59.125 +[0/1], [9], [17], [25/+26], [34], [+42/43], [51], [59] + +bit number: 0 1 2 3 4 5 6 7 +spare cycles 1 2 1 2 1 1 1 0 + +operations to perform: duration cycle + ---------------- + eor fix, shift 1 -> 00 + andi phase, USBMASK 1 -> 08 + breq se0 1 -> 16 (moved to 11) + st y+, data 2 -> 24, 25 + mov data, fix 1 -> 33 + ser data 1 -> 41 + subi cnt, 1 1 -> 49 + brcs overflow 1 -> 50 + +layout of samples and operations: +[##] = sample bit +<##> = sample phase +*##* = operation + +0: *00* [01] 02 03 04 <05> 06 07 +1: *08* [09] 10 11 12 <13> 14 15 *16* +2: [17] 18 19 20 <21> 22 23 +3: *24* *25* [26] 27 28 29 <30> 31 32 +4: *33* [34] 35 36 37 <38> 39 40 +5: *41* [42] 43 44 45 <46> 47 48 +6: *49* *50* [51] 52 53 54 <55> 56 57 58 +7: [59] 60 61 62 <63> 64 65 66 +*****************************************************************************/ + +/* we prefer positive expressions (do if condition) instead of negative + * (skip if condition), therefore use defines for skip instructions: + */ +#define ifioclr sbis +#define ifioset sbic +#define ifrclr sbrs +#define ifrset sbrc + +/* The registers "fix" and "data" swap their meaning during the loop. Use + * defines to keep their name constant. + */ +#define fix x2 +#define data x1 +#undef phase /* phase has a default definition to x4 */ +#define phase x3 + + +USB_INTR_VECTOR: +;order of registers pushed: YL, SREG [sofError], YH, shift, x1, x2, x3, cnt, r0 + push YL ;2 push only what is necessary to sync with edge ASAP + in YL, SREG ;1 + push YL ;2 +;---------------------------------------------------------------------------- +; Synchronize with sync pattern: +;---------------------------------------------------------------------------- +;sync byte (D-) pattern LSb to MSb: 01010100 [1 = idle = J, 0 = K] +;sync up with J to K edge during sync pattern -- use fastest possible loops +;The first part waits at most 1 bit long since we must be in sync pattern. +;YL is guarenteed to be < 0x80 because I flag is clear. When we jump to +;waitForJ, ensure that this prerequisite is met. +waitForJ: + inc YL + sbis USBIN, USBMINUS + brne waitForJ ; just make sure we have ANY timeout +waitForK: +;The following code results in a sampling window of 1/4 bit which meets the spec. + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS ;[0] + rjmp foundK ;[1] +#if USB_COUNT_SOF + lds YL, usbSofCount + inc YL + sts usbSofCount, YL +#endif /* USB_COUNT_SOF */ +#ifdef USB_SOF_HOOK + USB_SOF_HOOK +#endif + rjmp sofError + +foundK: +;{3, 5} after falling D- edge, average delay: 4 cycles [we want 4 for center sampling] +;we have 1 bit time for setup purposes, then sample again. Numbers in brackets +;are cycles from center of first sync (double K) bit after the instruction + push YH ;[2] + lds YL, usbInputBufOffset;[4] + clr YH ;[6] + subi YL, lo8(-(usbRxBuf));[7] + sbci YH, hi8(-(usbRxBuf));[8] + + sbis USBIN, USBMINUS ;[9] we want two bits K [we want to sample at 8 + 4 - 1.5 = 10.5] + rjmp haveTwoBitsK ;[10] + pop YH ;[11] undo the push from before + rjmp waitForK ;[13] this was not the end of sync, retry +haveTwoBitsK: +;---------------------------------------------------------------------------- +; push more registers and initialize values while we sample the first bits: +;---------------------------------------------------------------------------- +#define fix x2 +#define data x1 + + push shift ;[12] + push x1 ;[14] + push x2 ;[16] + ldi shift, 0x80 ;[18] prevent bit-unstuffing but init low bits to 0 + ifioset USBIN, USBMINUS ;[19] [01] <--- bit 0 [10.5 + 8 = 18.5] + ori shift, 1<<0 ;[02] + push x3 ;[03] + push cnt ;[05] + push r0 ;[07] + ifioset USBIN, USBMINUS ;[09] <--- bit 1 + ori shift, 1<<1 ;[10] + ser fix ;[11] + ldi cnt, USB_BUFSIZE ;[12] + mov data, shift ;[13] + lsl shift ;[14] + nop2 ;[15] + ifioset USBIN, USBMINUS ;[17] <--- bit 2 + ori data, 3<<2 ;[18] store in bit 2 AND bit 3 + eor shift, data ;[19] do nrzi decoding + andi data, 1<<3 ;[20] + in phase, USBIN ;[21] <- phase + brne jumpToEntryAfterSet ;[22] if USBMINS at bit 3 was 1 + nop ;[23] + rjmp entryAfterClr ;[24] +jumpToEntryAfterSet: + rjmp entryAfterSet ;[24] + +;---------------------------------------------------------------------------- +; Receiver loop (numbers in brackets are cycles within byte after instr) +;---------------------------------------------------------------------------- +#undef fix +#define fix x1 +#undef data +#define data x2 + +bit7IsSet: + ifrclr phase, USBMINUS ;[62] check phase only if D- changed + lpm ;[63] + in phase, USBIN ;[64] <- phase (one cycle too late) + ori shift, 1 << 7 ;[65] + nop ;[66] +;;;;rjmp bit0AfterSet ; -> [00] == [67] moved block up to save jump +bit0AfterSet: + eor fix, shift ;[00] +#undef fix +#define fix x2 +#undef data +#define data x1 /* we now have result in data, fix is reset to 0xff */ + ifioclr USBIN, USBMINUS ;[01] <--- sample 0 + rjmp bit0IsClr ;[02] + andi shift, ~(7 << 0) ;[03] + breq unstuff0s ;[04] + in phase, USBIN ;[05] <- phase + rjmp bit1AfterSet ;[06] +unstuff0s: + in phase, USBIN ;[06] <- phase (one cycle too late) + andi fix, ~(1 << 0) ;[07] + ifioclr USBIN, USBMINUS ;[00] + ifioset USBIN, USBPLUS ;[01] + rjmp bit0IsClr ;[02] executed if first expr false or second true +se0AndStore: ; executed only if both bits 0 + st y+, x1 ;[15/17] cycles after start of byte + rjmp se0 ;[17/19] + +bit0IsClr: + ifrset phase, USBMINUS ;[04] check phase only if D- changed + lpm ;[05] + in phase, USBIN ;[06] <- phase (one cycle too late) + ori shift, 1 << 0 ;[07] +bit1AfterClr: + andi phase, USBMASK ;[08] + ifioset USBIN, USBMINUS ;[09] <--- sample 1 + rjmp bit1IsSet ;[10] + breq se0AndStore ;[11] if D- was 0 in bits 0 AND 1 and D+ was 0 in between, we have SE0 + andi shift, ~(7 << 1) ;[12] + in phase, USBIN ;[13] <- phase + breq unstuff1c ;[14] + rjmp bit2AfterClr ;[15] +unstuff1c: + andi fix, ~(1 << 1) ;[16] + nop2 ;[08] + nop2 ;[10] +bit1IsSet: + ifrclr phase, USBMINUS ;[12] check phase only if D- changed + lpm ;[13] + in phase, USBIN ;[14] <- phase (one cycle too late) + ori shift, 1 << 1 ;[15] + nop ;[16] +bit2AfterSet: + ifioclr USBIN, USBMINUS ;[17] <--- sample 2 + rjmp bit2IsClr ;[18] + andi shift, ~(7 << 2) ;[19] + breq unstuff2s ;[20] + in phase, USBIN ;[21] <- phase + rjmp bit3AfterSet ;[22] +unstuff2s: + in phase, USBIN ;[22] <- phase (one cycle too late) + andi fix, ~(1 << 2) ;[23] + nop2 ;[16] + nop2 ;[18] +bit2IsClr: + ifrset phase, USBMINUS ;[20] check phase only if D- changed + lpm ;[21] + in phase, USBIN ;[22] <- phase (one cycle too late) + ori shift, 1 << 2 ;[23] +bit3AfterClr: + st y+, data ;[24] +entryAfterClr: + ifioset USBIN, USBMINUS ;[26] <--- sample 3 + rjmp bit3IsSet ;[27] + andi shift, ~(7 << 3) ;[28] + breq unstuff3c ;[29] + in phase, USBIN ;[30] <- phase + rjmp bit4AfterClr ;[31] +unstuff3c: + in phase, USBIN ;[31] <- phase (one cycle too late) + andi fix, ~(1 << 3) ;[32] + nop2 ;[25] + nop2 ;[27] +bit3IsSet: + ifrclr phase, USBMINUS ;[29] check phase only if D- changed + lpm ;[30] + in phase, USBIN ;[31] <- phase (one cycle too late) + ori shift, 1 << 3 ;[32] +bit4AfterSet: + mov data, fix ;[33] undo this move by swapping defines +#undef fix +#define fix x1 +#undef data +#define data x2 + ifioclr USBIN, USBMINUS ;[34] <--- sample 4 + rjmp bit4IsClr ;[35] + andi shift, ~(7 << 4) ;[36] + breq unstuff4s ;[37] + in phase, USBIN ;[38] <- phase + rjmp bit5AfterSet ;[39] +unstuff4s: + in phase, USBIN ;[39] <- phase (one cycle too late) + andi fix, ~(1 << 4) ;[40] + nop2 ;[33] + nop2 ;[35] +bit4IsClr: + ifrset phase, USBMINUS ;[37] check phase only if D- changed + lpm ;[38] + in phase, USBIN ;[39] <- phase (one cycle too late) + ori shift, 1 << 4 ;[40] +bit5AfterClr: + ser data ;[41] + ifioset USBIN, USBMINUS ;[42] <--- sample 5 + rjmp bit5IsSet ;[43] + andi shift, ~(7 << 5) ;[44] + breq unstuff5c ;[45] + in phase, USBIN ;[46] <- phase + rjmp bit6AfterClr ;[47] +unstuff5c: + in phase, USBIN ;[47] <- phase (one cycle too late) + andi fix, ~(1 << 5) ;[48] + nop2 ;[41] + nop2 ;[43] +bit5IsSet: + ifrclr phase, USBMINUS ;[45] check phase only if D- changed + lpm ;[46] + in phase, USBIN ;[47] <- phase (one cycle too late) + ori shift, 1 << 5 ;[48] +bit6AfterSet: + subi cnt, 1 ;[49] + brcs jumpToOverflow ;[50] + ifioclr USBIN, USBMINUS ;[51] <--- sample 6 + rjmp bit6IsClr ;[52] + andi shift, ~(3 << 6) ;[53] + cpi shift, 2 ;[54] + in phase, USBIN ;[55] <- phase + brlt unstuff6s ;[56] + rjmp bit7AfterSet ;[57] + +jumpToOverflow: + rjmp overflow + +unstuff6s: + andi fix, ~(1 << 6) ;[50] + lpm ;[51] +bit6IsClr: + ifrset phase, USBMINUS ;[54] check phase only if D- changed + lpm ;[55] + in phase, USBIN ;[56] <- phase (one cycle too late) + ori shift, 1 << 6 ;[57] + nop ;[58] +bit7AfterClr: + ifioset USBIN, USBMINUS ;[59] <--- sample 7 + rjmp bit7IsSet ;[60] + andi shift, ~(1 << 7) ;[61] + cpi shift, 4 ;[62] + in phase, USBIN ;[63] <- phase + brlt unstuff7c ;[64] + rjmp bit0AfterClr ;[65] -> [00] == [67] +unstuff7c: + andi fix, ~(1 << 7) ;[58] + nop ;[59] + rjmp bit7IsSet ;[60] + +bit7IsClr: + ifrset phase, USBMINUS ;[62] check phase only if D- changed + lpm ;[63] + in phase, USBIN ;[64] <- phase (one cycle too late) + ori shift, 1 << 7 ;[65] + nop ;[66] +;;;;rjmp bit0AfterClr ; -> [00] == [67] moved block up to save jump +bit0AfterClr: + eor fix, shift ;[00] +#undef fix +#define fix x2 +#undef data +#define data x1 /* we now have result in data, fix is reset to 0xff */ + ifioset USBIN, USBMINUS ;[01] <--- sample 0 + rjmp bit0IsSet ;[02] + andi shift, ~(7 << 0) ;[03] + breq unstuff0c ;[04] + in phase, USBIN ;[05] <- phase + rjmp bit1AfterClr ;[06] +unstuff0c: + in phase, USBIN ;[06] <- phase (one cycle too late) + andi fix, ~(1 << 0) ;[07] + ifioclr USBIN, USBMINUS ;[00] + ifioset USBIN, USBPLUS ;[01] + rjmp bit0IsSet ;[02] executed if first expr false or second true + rjmp se0AndStore ;[03] executed only if both bits 0 +bit0IsSet: + ifrclr phase, USBMINUS ;[04] check phase only if D- changed + lpm ;[05] + in phase, USBIN ;[06] <- phase (one cycle too late) + ori shift, 1 << 0 ;[07] +bit1AfterSet: + andi shift, ~(7 << 1) ;[08] compensated by "ori shift, 1<<1" if bit1IsClr + ifioclr USBIN, USBMINUS ;[09] <--- sample 1 + rjmp bit1IsClr ;[10] + breq unstuff1s ;[11] + nop2 ;[12] do not check for SE0 if bit 0 was 1 + in phase, USBIN ;[14] <- phase (one cycle too late) + rjmp bit2AfterSet ;[15] +unstuff1s: + in phase, USBIN ;[13] <- phase + andi fix, ~(1 << 1) ;[14] + lpm ;[07] + nop2 ;[10] +bit1IsClr: + ifrset phase, USBMINUS ;[12] check phase only if D- changed + lpm ;[13] + in phase, USBIN ;[14] <- phase (one cycle too late) + ori shift, 1 << 1 ;[15] + nop ;[16] +bit2AfterClr: + ifioset USBIN, USBMINUS ;[17] <--- sample 2 + rjmp bit2IsSet ;[18] + andi shift, ~(7 << 2) ;[19] + breq unstuff2c ;[20] + in phase, USBIN ;[21] <- phase + rjmp bit3AfterClr ;[22] +unstuff2c: + in phase, USBIN ;[22] <- phase (one cycle too late) + andi fix, ~(1 << 2) ;[23] + nop2 ;[16] + nop2 ;[18] +bit2IsSet: + ifrclr phase, USBMINUS ;[20] check phase only if D- changed + lpm ;[21] + in phase, USBIN ;[22] <- phase (one cycle too late) + ori shift, 1 << 2 ;[23] +bit3AfterSet: + st y+, data ;[24] +entryAfterSet: + ifioclr USBIN, USBMINUS ;[26] <--- sample 3 + rjmp bit3IsClr ;[27] + andi shift, ~(7 << 3) ;[28] + breq unstuff3s ;[29] + in phase, USBIN ;[30] <- phase + rjmp bit4AfterSet ;[31] +unstuff3s: + in phase, USBIN ;[31] <- phase (one cycle too late) + andi fix, ~(1 << 3) ;[32] + nop2 ;[25] + nop2 ;[27] +bit3IsClr: + ifrset phase, USBMINUS ;[29] check phase only if D- changed + lpm ;[30] + in phase, USBIN ;[31] <- phase (one cycle too late) + ori shift, 1 << 3 ;[32] +bit4AfterClr: + mov data, fix ;[33] undo this move by swapping defines +#undef fix +#define fix x1 +#undef data +#define data x2 + ifioset USBIN, USBMINUS ;[34] <--- sample 4 + rjmp bit4IsSet ;[35] + andi shift, ~(7 << 4) ;[36] + breq unstuff4c ;[37] + in phase, USBIN ;[38] <- phase + rjmp bit5AfterClr ;[39] +unstuff4c: + in phase, USBIN ;[39] <- phase (one cycle too late) + andi fix, ~(1 << 4) ;[40] + nop2 ;[33] + nop2 ;[35] +bit4IsSet: + ifrclr phase, USBMINUS ;[37] check phase only if D- changed + lpm ;[38] + in phase, USBIN ;[39] <- phase (one cycle too late) + ori shift, 1 << 4 ;[40] +bit5AfterSet: + ser data ;[41] + ifioclr USBIN, USBMINUS ;[42] <--- sample 5 + rjmp bit5IsClr ;[43] + andi shift, ~(7 << 5) ;[44] + breq unstuff5s ;[45] + in phase, USBIN ;[46] <- phase + rjmp bit6AfterSet ;[47] +unstuff5s: + in phase, USBIN ;[47] <- phase (one cycle too late) + andi fix, ~(1 << 5) ;[48] + nop2 ;[41] + nop2 ;[43] +bit5IsClr: + ifrset phase, USBMINUS ;[45] check phase only if D- changed + lpm ;[46] + in phase, USBIN ;[47] <- phase (one cycle too late) + ori shift, 1 << 5 ;[48] +bit6AfterClr: + subi cnt, 1 ;[49] + brcs overflow ;[50] + ifioset USBIN, USBMINUS ;[51] <--- sample 6 + rjmp bit6IsSet ;[52] + andi shift, ~(3 << 6) ;[53] + cpi shift, 2 ;[54] + in phase, USBIN ;[55] <- phase + brlt unstuff6c ;[56] + rjmp bit7AfterClr ;[57] +unstuff6c: + andi fix, ~(1 << 6) ;[50] + lpm ;[51] +bit6IsSet: + ifrclr phase, USBMINUS ;[54] check phase only if D- changed + lpm ;[55] + in phase, USBIN ;[56] <- phase (one cycle too late) + ori shift, 1 << 6 ;[57] +bit7AfterSet: + ifioclr USBIN, USBMINUS ;[59] <--- sample 7 + rjmp bit7IsClr ;[60] + andi shift, ~(1 << 7) ;[61] + cpi shift, 4 ;[62] + in phase, USBIN ;[63] <- phase + brlt unstuff7s ;[64] + rjmp bit0AfterSet ;[65] -> [00] == [67] +unstuff7s: + andi fix, ~(1 << 7) ;[58] + nop ;[59] + rjmp bit7IsClr ;[60] + +macro POP_STANDARD ; 14 cycles + pop r0 + pop cnt + pop x3 + pop x2 + pop x1 + pop shift + pop YH + endm +macro POP_RETI ; 5 cycles + pop YL + out SREG, YL + pop YL + endm + +#include "asmcommon.inc" + +;---------------------------------------------------------------------------- +; Transmitting data +;---------------------------------------------------------------------------- + +txByteLoop: +txBitloop: +stuffN1Delay: ; [03] + ror shift ;[-5] [11] [63] + brcc doExorN1 ;[-4] [64] + subi x3, 1 ;[-3] + brne commonN1 ;[-2] + lsl shift ;[-1] compensate ror after rjmp stuffDelay + nop ;[00] stuffing consists of just waiting 8 cycles + rjmp stuffN1Delay ;[01] after ror, C bit is reliably clear + +sendNakAndReti: + ldi cnt, USBPID_NAK ;[-19] + rjmp sendCntAndReti ;[-18] +sendAckAndReti: + ldi cnt, USBPID_ACK ;[-17] +sendCntAndReti: + mov r0, cnt ;[-16] + ldi YL, 0 ;[-15] R0 address is 0 + ldi YH, 0 ;[-14] + ldi cnt, 2 ;[-13] +; rjmp usbSendAndReti fallthrough + +; USB spec says: +; idle = J +; J = (D+ = 0), (D- = 1) or USBOUT = 0x01 +; K = (D+ = 1), (D- = 0) or USBOUT = 0x02 +; Spec allows 7.5 bit times from EOP to SOP for replies (= 60 cycles) + +;usbSend: +;pointer to data in 'Y' +;number of bytes in 'cnt' -- including sync byte +;uses: x1...x3, shift, cnt, Y [x1 = mirror USBOUT, x2 = USBMASK, x3 = bitstuff cnt] +;Numbers in brackets are time since first bit of sync pattern is sent (start of instruction) +usbSendAndReti: + in x2, USBDDR ;[-10] 10 cycles until SOP + ori x2, USBMASK ;[-9] + sbi USBOUT, USBMINUS ;[-8] prepare idle state; D+ and D- must have been 0 (no pullups) + out USBDDR, x2 ;[-6] <--- acquire bus + in x1, USBOUT ;[-5] port mirror for tx loop + ldi shift, 0x40 ;[-4] sync byte is first byte sent (we enter loop after ror) + ldi x2, USBMASK ;[-3] +doExorN1: + eor x1, x2 ;[-2] [06] [62] + ldi x3, 6 ;[-1] [07] [63] +commonN1: +stuffN2Delay: + out USBOUT, x1 ;[00] [08] [64] <--- set bit + ror shift ;[01] + brcc doExorN2 ;[02] + subi x3, 1 ;[03] + brne commonN2 ;[04] + lsl shift ;[05] compensate ror after rjmp stuffDelay + rjmp stuffN2Delay ;[06] after ror, C bit is reliably clear +doExorN2: + eor x1, x2 ;[04] [12] + ldi x3, 6 ;[05] [13] +commonN2: + nop2 ;[06] [14] + subi cnt, 171 ;[08] [16] trick: (3 * 171) & 0xff = 1 + out USBOUT, x1 ;[09] [17] <--- set bit + brcs txBitloop ;[10] [27] [44] + +stuff6Delay: + ror shift ;[45] [53] + brcc doExor6 ;[46] + subi x3, 1 ;[47] + brne common6 ;[48] + lsl shift ;[49] compensate ror after rjmp stuffDelay + nop ;[50] stuffing consists of just waiting 8 cycles + rjmp stuff6Delay ;[51] after ror, C bit is reliably clear +doExor6: + eor x1, x2 ;[48] [56] + ldi x3, 6 ;[49] +common6: +stuff7Delay: + ror shift ;[50] [58] + out USBOUT, x1 ;[51] <--- set bit + brcc doExor7 ;[52] + subi x3, 1 ;[53] + brne common7 ;[54] + lsl shift ;[55] compensate ror after rjmp stuffDelay + rjmp stuff7Delay ;[56] after ror, C bit is reliably clear +doExor7: + eor x1, x2 ;[54] [62] + ldi x3, 6 ;[55] +common7: + ld shift, y+ ;[56] + nop ;[58] + tst cnt ;[59] + out USBOUT, x1 ;[60] [00]<--- set bit + brne txByteLoop ;[61] [01] +;make SE0: + cbr x1, USBMASK ;[02] prepare SE0 [spec says EOP may be 15 to 18 cycles] + lds x2, usbNewDeviceAddr;[03] + lsl x2 ;[05] we compare with left shifted address + subi YL, 2 + 0 ;[06] Only assign address on data packets, not ACK/NAK in r0 + sbci YH, 0 ;[07] + out USBOUT, x1 ;[00] <-- out SE0 -- from now 2 bits = 16 cycles until bus idle +;2006-03-06: moved transfer of new address to usbDeviceAddr from C-Code to asm: +;set address only after data packet was sent, not after handshake + breq skipAddrAssign ;[01] + sts usbDeviceAddr, x2 ; if not skipped: SE0 is one cycle longer +skipAddrAssign: +;end of usbDeviceAddress transfer + ldi x2, 1< 0) + echo "$s\n"; + } +} + +function printBit($isAfterSet, $bitNum) +{ + ob_start(); + if($isAfterSet){ +?> + ifioclr USBIN, USBMINUS ;[00] <--- sample + rjmp bit#IsClr ;[01] + andi shift, ~(7 << #) ;[02] + breq unstuff#s ;[03] + in phase, USBIN ;[04] <- phase + rjmp bit@AfterSet ;[05] +unstuff#s: + in phase, USBIN ;[05] <- phase (one cycle too late) + andi fix, ~(1 << #) ;[06] + nop2 ;[-1] + nop2 ;[01] +bit#IsClr: + ifrset phase, USBMINUS ;[03] check phase only if D- changed + lpm ;[04] + in phase, USBIN ;[05] <- phase (one cycle too late) + ori shift, 1 << # ;[06] + + ifioset USBIN, USBMINUS ;[00] <--- sample + rjmp bit#IsSet ;[01] + andi shift, ~(7 << #) ;[02] + breq unstuff#c ;[03] + in phase, USBIN ;[04] <- phase + rjmp bit@AfterClr ;[05] +unstuff#c: + in phase, USBIN ;[05] <- phase (one cycle too late) + andi fix, ~(1 << #) ;[06] + nop2 ;[-1] + nop2 ;[01] +bit#IsSet: + ifrclr phase, USBMINUS ;[03] check phase only if D- changed + lpm ;[04] + in phase, USBIN ;[05] <- phase (one cycle too late) + ori shift, 1 << # ;[06] + +*****************************************************************************/ diff --git a/firmware/usbdrv/usbdrvasm15.inc b/firmware/usbdrv/usbdrvasm15.inc new file mode 100644 index 0000000..401b7f8 --- /dev/null +++ b/firmware/usbdrv/usbdrvasm15.inc @@ -0,0 +1,423 @@ +/* Name: usbdrvasm15.inc + * Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers + * Author: contributed by V. Bosch + * Creation Date: 2007-08-06 + * Tabsize: 4 + * Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH + * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) + * Revision: $Id: usbdrvasm15.inc 740 2009-04-13 18:23:31Z cs $ + */ + +/* Do not link this file! Link usbdrvasm.S instead, which includes the + * appropriate implementation! + */ + +/* +General Description: +This file is the 15 MHz version of the asssembler part of the USB driver. It +requires a 15 MHz crystal (not a ceramic resonator and not a calibrated RC +oscillator). + +See usbdrv.h for a description of the entire driver. + +Since almost all of this code is timing critical, don't change unless you +really know what you are doing! Many parts require not only a maximum number +of CPU cycles, but even an exact number of cycles! +*/ + +;max stack usage: [ret(2), YL, SREG, YH, bitcnt, shift, x1, x2, x3, x4, cnt] = 12 bytes +;nominal frequency: 15 MHz -> 10.0 cycles per bit, 80.0 cycles per byte +; Numbers in brackets are clocks counted from center of last sync bit +; when instruction starts + +;---------------------------------------------------------------------------- +; order of registers pushed: +; YL, SREG [sofError] YH, shift, x1, x2, x3, bitcnt, cnt, x4 +;---------------------------------------------------------------------------- +USB_INTR_VECTOR: + push YL ;2 push only what is necessary to sync with edge ASAP + in YL, SREG ;1 + push YL ;2 +;---------------------------------------------------------------------------- +; Synchronize with sync pattern: +; +; sync byte (D-) pattern LSb to MSb: 01010100 [1 = idle = J, 0 = K] +; sync up with J to K edge during sync pattern -- use fastest possible loops +;The first part waits at most 1 bit long since we must be in sync pattern. +;YL is guarenteed to be < 0x80 because I flag is clear. When we jump to +;waitForJ, ensure that this prerequisite is met. +waitForJ: + inc YL + sbis USBIN, USBMINUS + brne waitForJ ; just make sure we have ANY timeout +;------------------------------------------------------------------------------- +; The following code results in a sampling window of < 1/4 bit +; which meets the spec. +;------------------------------------------------------------------------------- +waitForK: ;- + sbis USBIN, USBMINUS ;1 [00] <-- sample + rjmp foundK ;2 [01] + sbis USBIN, USBMINUS ; <-- sample + rjmp foundK + sbis USBIN, USBMINUS ; <-- sample + rjmp foundK + sbis USBIN, USBMINUS ; <-- sample + rjmp foundK + sbis USBIN, USBMINUS ; <-- sample + rjmp foundK + sbis USBIN, USBMINUS ; <-- sample + rjmp foundK +#if USB_COUNT_SOF + lds YL, usbSofCount + inc YL + sts usbSofCount, YL +#endif /* USB_COUNT_SOF */ +#ifdef USB_SOF_HOOK + USB_SOF_HOOK +#endif + rjmp sofError +;------------------------------------------------------------------------------ +; {3, 5} after falling D- edge, average delay: 4 cycles [we want 5 for +; center sampling] +; we have 1 bit time for setup purposes, then sample again. +; Numbers in brackets are cycles from center of first sync (double K) +; bit after the instruction +;------------------------------------------------------------------------------ +foundK: ;- [02] + lds YL, usbInputBufOffset;2 [03+04] tx loop + push YH ;2 [05+06] + clr YH ;1 [07] + subi YL, lo8(-(usbRxBuf)) ;1 [08] [rx loop init] + sbci YH, hi8(-(usbRxBuf)) ;1 [09] [rx loop init] + push shift ;2 [10+11] + ser shift ;1 [12] + sbis USBIN, USBMINUS ;1 [-1] [13] <--sample:we want two bits K (sample 1 cycle too early) + rjmp haveTwoBitsK ;2 [00] [14] + pop shift ;2 [15+16] undo the push from before + pop YH ;2 [17+18] undo the push from before + rjmp waitForK ;2 [19+20] this was not the end of sync, retry +; The entire loop from waitForK until rjmp waitForK above must not exceed two +; bit times (= 20 cycles). + +;---------------------------------------------------------------------------- +; push more registers and initialize values while we sample the first bits: +;---------------------------------------------------------------------------- +haveTwoBitsK: ;- [01] + push x1 ;2 [02+03] + push x2 ;2 [04+05] + push x3 ;2 [06+07] + push bitcnt ;2 [08+09] + in x1, USBIN ;1 [00] [10] <-- sample bit 0 + bst x1, USBMINUS ;1 [01] + bld shift, 0 ;1 [02] + push cnt ;2 [03+04] + ldi cnt, USB_BUFSIZE ;1 [05] + push x4 ;2 [06+07] tx loop + rjmp rxLoop ;2 [08] +;---------------------------------------------------------------------------- +; Receiver loop (numbers in brackets are cycles within byte after instr) +;---------------------------------------------------------------------------- +unstuff0: ;- [07] (branch taken) + andi x3, ~0x01 ;1 [08] + mov x1, x2 ;1 [09] x2 contains last sampled (stuffed) bit + in x2, USBIN ;1 [00] [10] <-- sample bit 1 again + andi x2, USBMASK ;1 [01] + breq se0Hop ;1 [02] SE0 check for bit 1 + ori shift, 0x01 ;1 [03] 0b00000001 + nop ;1 [04] + rjmp didUnstuff0 ;2 [05] +;----------------------------------------------------- +unstuff1: ;- [05] (branch taken) + mov x2, x1 ;1 [06] x1 contains last sampled (stuffed) bit + andi x3, ~0x02 ;1 [07] + ori shift, 0x02 ;1 [08] 0b00000010 + nop ;1 [09] + in x1, USBIN ;1 [00] [10] <-- sample bit 2 again + andi x1, USBMASK ;1 [01] + breq se0Hop ;1 [02] SE0 check for bit 2 + rjmp didUnstuff1 ;2 [03] +;----------------------------------------------------- +unstuff2: ;- [05] (branch taken) + andi x3, ~0x04 ;1 [06] + ori shift, 0x04 ;1 [07] 0b00000100 + mov x1, x2 ;1 [08] x2 contains last sampled (stuffed) bit + nop ;1 [09] + in x2, USBIN ;1 [00] [10] <-- sample bit 3 + andi x2, USBMASK ;1 [01] + breq se0Hop ;1 [02] SE0 check for bit 3 + rjmp didUnstuff2 ;2 [03] +;----------------------------------------------------- +unstuff3: ;- [00] [10] (branch taken) + in x2, USBIN ;1 [01] [11] <-- sample stuffed bit 3 one cycle too late + andi x2, USBMASK ;1 [02] + breq se0Hop ;1 [03] SE0 check for stuffed bit 3 + andi x3, ~0x08 ;1 [04] + ori shift, 0x08 ;1 [05] 0b00001000 + rjmp didUnstuff3 ;2 [06] +;---------------------------------------------------------------------------- +; extra jobs done during bit interval: +; +; bit 0: store, clear [SE0 is unreliable here due to bit dribbling in hubs], +; overflow check, jump to the head of rxLoop +; bit 1: SE0 check +; bit 2: SE0 check, recovery from delay [bit 0 tasks took too long] +; bit 3: SE0 check, recovery from delay [bit 0 tasks took too long] +; bit 4: SE0 check, none +; bit 5: SE0 check, none +; bit 6: SE0 check, none +; bit 7: SE0 check, reconstruct: x3 is 0 at bit locations we changed, 1 at others +;---------------------------------------------------------------------------- +rxLoop: ;- [09] + in x2, USBIN ;1 [00] [10] <-- sample bit 1 (or possibly bit 0 stuffed) + andi x2, USBMASK ;1 [01] + brne SkipSe0Hop ;1 [02] +se0Hop: ;- [02] + rjmp se0 ;2 [03] SE0 check for bit 1 +SkipSe0Hop: ;- [03] + ser x3 ;1 [04] + andi shift, 0xf9 ;1 [05] 0b11111001 + breq unstuff0 ;1 [06] +didUnstuff0: ;- [06] + eor x1, x2 ;1 [07] + bst x1, USBMINUS ;1 [08] + bld shift, 1 ;1 [09] + in x1, USBIN ;1 [00] [10] <-- sample bit 2 (or possibly bit 1 stuffed) + andi x1, USBMASK ;1 [01] + breq se0Hop ;1 [02] SE0 check for bit 2 + andi shift, 0xf3 ;1 [03] 0b11110011 + breq unstuff1 ;1 [04] do remaining work for bit 1 +didUnstuff1: ;- [04] + eor x2, x1 ;1 [05] + bst x2, USBMINUS ;1 [06] + bld shift, 2 ;1 [07] + nop2 ;2 [08+09] + in x2, USBIN ;1 [00] [10] <-- sample bit 3 (or possibly bit 2 stuffed) + andi x2, USBMASK ;1 [01] + breq se0Hop ;1 [02] SE0 check for bit 3 + andi shift, 0xe7 ;1 [03] 0b11100111 + breq unstuff2 ;1 [04] +didUnstuff2: ;- [04] + eor x1, x2 ;1 [05] + bst x1, USBMINUS ;1 [06] + bld shift, 3 ;1 [07] +didUnstuff3: ;- [07] + andi shift, 0xcf ;1 [08] 0b11001111 + breq unstuff3 ;1 [09] + in x1, USBIN ;1 [00] [10] <-- sample bit 4 + andi x1, USBMASK ;1 [01] + breq se0Hop ;1 [02] SE0 check for bit 4 + eor x2, x1 ;1 [03] + bst x2, USBMINUS ;1 [04] + bld shift, 4 ;1 [05] +didUnstuff4: ;- [05] + andi shift, 0x9f ;1 [06] 0b10011111 + breq unstuff4 ;1 [07] + nop2 ;2 [08+09] + in x2, USBIN ;1 [00] [10] <-- sample bit 5 + andi x2, USBMASK ;1 [01] + breq se0 ;1 [02] SE0 check for bit 5 + eor x1, x2 ;1 [03] + bst x1, USBMINUS ;1 [04] + bld shift, 5 ;1 [05] +didUnstuff5: ;- [05] + andi shift, 0x3f ;1 [06] 0b00111111 + breq unstuff5 ;1 [07] + nop2 ;2 [08+09] + in x1, USBIN ;1 [00] [10] <-- sample bit 6 + andi x1, USBMASK ;1 [01] + breq se0 ;1 [02] SE0 check for bit 6 + eor x2, x1 ;1 [03] + bst x2, USBMINUS ;1 [04] + bld shift, 6 ;1 [05] +didUnstuff6: ;- [05] + cpi shift, 0x02 ;1 [06] 0b00000010 + brlo unstuff6 ;1 [07] + nop2 ;2 [08+09] + in x2, USBIN ;1 [00] [10] <-- sample bit 7 + andi x2, USBMASK ;1 [01] + breq se0 ;1 [02] SE0 check for bit 7 + eor x1, x2 ;1 [03] + bst x1, USBMINUS ;1 [04] + bld shift, 7 ;1 [05] +didUnstuff7: ;- [05] + cpi shift, 0x04 ;1 [06] 0b00000100 + brlo unstuff7 ;1 [07] + eor x3, shift ;1 [08] reconstruct: x3 is 0 at bit locations we changed, 1 at others + nop ;1 [09] + in x1, USBIN ;1 [00] [10] <-- sample bit 0 + st y+, x3 ;2 [01+02] store data + eor x2, x1 ;1 [03] + bst x2, USBMINUS ;1 [04] + bld shift, 0 ;1 [05] + subi cnt, 1 ;1 [06] + brcs overflow ;1 [07] + rjmp rxLoop ;2 [08] +;----------------------------------------------------- +unstuff4: ;- [08] + andi x3, ~0x10 ;1 [09] + in x1, USBIN ;1 [00] [10] <-- sample stuffed bit 4 + andi x1, USBMASK ;1 [01] + breq se0 ;1 [02] SE0 check for stuffed bit 4 + ori shift, 0x10 ;1 [03] + rjmp didUnstuff4 ;2 [04] +;----------------------------------------------------- +unstuff5: ;- [08] + ori shift, 0x20 ;1 [09] + in x2, USBIN ;1 [00] [10] <-- sample stuffed bit 5 + andi x2, USBMASK ;1 [01] + breq se0 ;1 [02] SE0 check for stuffed bit 5 + andi x3, ~0x20 ;1 [03] + rjmp didUnstuff5 ;2 [04] +;----------------------------------------------------- +unstuff6: ;- [08] + andi x3, ~0x40 ;1 [09] + in x1, USBIN ;1 [00] [10] <-- sample stuffed bit 6 + andi x1, USBMASK ;1 [01] + breq se0 ;1 [02] SE0 check for stuffed bit 6 + ori shift, 0x40 ;1 [03] + rjmp didUnstuff6 ;2 [04] +;----------------------------------------------------- +unstuff7: ;- [08] + andi x3, ~0x80 ;1 [09] + in x2, USBIN ;1 [00] [10] <-- sample stuffed bit 7 + andi x2, USBMASK ;1 [01] + breq se0 ;1 [02] SE0 check for stuffed bit 7 + ori shift, 0x80 ;1 [03] + rjmp didUnstuff7 ;2 [04] + +macro POP_STANDARD ; 16 cycles + pop x4 + pop cnt + pop bitcnt + pop x3 + pop x2 + pop x1 + pop shift + pop YH + endm +macro POP_RETI ; 5 cycles + pop YL + out SREG, YL + pop YL + endm + +#include "asmcommon.inc" + +;--------------------------------------------------------------------------- +; USB spec says: +; idle = J +; J = (D+ = 0), (D- = 1) +; K = (D+ = 1), (D- = 0) +; Spec allows 7.5 bit times from EOP to SOP for replies +;--------------------------------------------------------------------------- +bitstuffN: ;- [04] + eor x1, x4 ;1 [05] + clr x2 ;1 [06] + nop ;1 [07] + rjmp didStuffN ;1 [08] +;--------------------------------------------------------------------------- +bitstuff6: ;- [04] + eor x1, x4 ;1 [05] + clr x2 ;1 [06] + rjmp didStuff6 ;1 [07] +;--------------------------------------------------------------------------- +bitstuff7: ;- [02] + eor x1, x4 ;1 [03] + clr x2 ;1 [06] + nop ;1 [05] + rjmp didStuff7 ;1 [06] +;--------------------------------------------------------------------------- +sendNakAndReti: ;- [-19] + ldi x3, USBPID_NAK ;1 [-18] + rjmp sendX3AndReti ;1 [-17] +;--------------------------------------------------------------------------- +sendAckAndReti: ;- [-17] + ldi cnt, USBPID_ACK ;1 [-16] +sendCntAndReti: ;- [-16] + mov x3, cnt ;1 [-15] +sendX3AndReti: ;- [-15] + ldi YL, 20 ;1 [-14] x3==r20 address is 20 + ldi YH, 0 ;1 [-13] + ldi cnt, 2 ;1 [-12] +; rjmp usbSendAndReti fallthrough +;--------------------------------------------------------------------------- +;usbSend: +;pointer to data in 'Y' +;number of bytes in 'cnt' -- including sync byte [range 2 ... 12] +;uses: x1...x4, btcnt, shift, cnt, Y +;Numbers in brackets are time since first bit of sync pattern is sent +;We need not to match the transfer rate exactly because the spec demands +;only 1.5% precision anyway. +usbSendAndReti: ;- [-13] 13 cycles until SOP + in x2, USBDDR ;1 [-12] + ori x2, USBMASK ;1 [-11] + sbi USBOUT, USBMINUS ;2 [-09-10] prepare idle state; D+ and D- must have been 0 (no pullups) + in x1, USBOUT ;1 [-08] port mirror for tx loop + out USBDDR, x2 ;1 [-07] <- acquire bus + ; need not init x2 (bitstuff history) because sync starts with 0 + ldi x4, USBMASK ;1 [-06] exor mask + ldi shift, 0x80 ;1 [-05] sync byte is first byte sent + ldi bitcnt, 6 ;1 [-04] +txBitLoop: ;- [-04] [06] + sbrs shift, 0 ;1 [-03] [07] + eor x1, x4 ;1 [-02] [08] + ror shift ;1 [-01] [09] +didStuffN: ;- [09] + out USBOUT, x1 ;1 [00] [10] <-- out N + ror x2 ;1 [01] + cpi x2, 0xfc ;1 [02] + brcc bitstuffN ;1 [03] + dec bitcnt ;1 [04] + brne txBitLoop ;1 [05] + sbrs shift, 0 ;1 [06] + eor x1, x4 ;1 [07] + ror shift ;1 [08] +didStuff6: ;- [08] + nop ;1 [09] + out USBOUT, x1 ;1 [00] [10] <-- out 6 + ror x2 ;1 [01] + cpi x2, 0xfc ;1 [02] + brcc bitstuff6 ;1 [03] + sbrs shift, 0 ;1 [04] + eor x1, x4 ;1 [05] + ror shift ;1 [06] + ror x2 ;1 [07] +didStuff7: ;- [07] + ldi bitcnt, 6 ;1 [08] + cpi x2, 0xfc ;1 [09] + out USBOUT, x1 ;1 [00] [10] <-- out 7 + brcc bitstuff7 ;1 [01] + ld shift, y+ ;2 [02+03] + dec cnt ;1 [04] + brne txBitLoop ;1 [05] +makeSE0: + cbr x1, USBMASK ;1 [06] prepare SE0 [spec says EOP may be 19 to 23 cycles] + lds x2, usbNewDeviceAddr;2 [07+08] + lsl x2 ;1 [09] we compare with left shifted address +;2006-03-06: moved transfer of new address to usbDeviceAddr from C-Code to asm: +;set address only after data packet was sent, not after handshake + out USBOUT, x1 ;1 [00] [10] <-- out SE0-- from now 2 bits==20 cycl. until bus idle + subi YL, 20 + 2 ;1 [01] Only assign address on data packets, not ACK/NAK in x3 + sbci YH, 0 ;1 [02] + breq skipAddrAssign ;1 [03] + sts usbDeviceAddr, x2 ;2 [04+05] if not skipped: SE0 is one cycle longer +;---------------------------------------------------------------------------- +;end of usbDeviceAddress transfer +skipAddrAssign: ;- [03/04] + ldi x2, 1< 10.6666666 cycles per bit, 85.333333333 cycles per byte +; Numbers in brackets are clocks counted from center of last sync bit +; when instruction starts + +USB_INTR_VECTOR: +;order of registers pushed: YL, SREG YH, [sofError], bitcnt, shift, x1, x2, x3, x4, cnt + push YL ;[-25] push only what is necessary to sync with edge ASAP + in YL, SREG ;[-23] + push YL ;[-22] + push YH ;[-20] +;---------------------------------------------------------------------------- +; Synchronize with sync pattern: +;---------------------------------------------------------------------------- +;sync byte (D-) pattern LSb to MSb: 01010100 [1 = idle = J, 0 = K] +;sync up with J to K edge during sync pattern -- use fastest possible loops +;The first part waits at most 1 bit long since we must be in sync pattern. +;YL is guarenteed to be < 0x80 because I flag is clear. When we jump to +;waitForJ, ensure that this prerequisite is met. +waitForJ: + inc YL + sbis USBIN, USBMINUS + brne waitForJ ; just make sure we have ANY timeout +waitForK: +;The following code results in a sampling window of < 1/4 bit which meets the spec. + sbis USBIN, USBMINUS ;[-15] + rjmp foundK ;[-14] + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS + rjmp foundK +#if USB_COUNT_SOF + lds YL, usbSofCount + inc YL + sts usbSofCount, YL +#endif /* USB_COUNT_SOF */ +#ifdef USB_SOF_HOOK + USB_SOF_HOOK +#endif + rjmp sofError +foundK: ;[-12] +;{3, 5} after falling D- edge, average delay: 4 cycles [we want 5 for center sampling] +;we have 1 bit time for setup purposes, then sample again. Numbers in brackets +;are cycles from center of first sync (double K) bit after the instruction + push bitcnt ;[-12] +; [---] ;[-11] + lds YL, usbInputBufOffset;[-10] +; [---] ;[-9] + clr YH ;[-8] + subi YL, lo8(-(usbRxBuf));[-7] [rx loop init] + sbci YH, hi8(-(usbRxBuf));[-6] [rx loop init] + push shift ;[-5] +; [---] ;[-4] + ldi bitcnt, 0x55 ;[-3] [rx loop init] + sbis USBIN, USBMINUS ;[-2] we want two bits K (sample 2 cycles too early) + rjmp haveTwoBitsK ;[-1] + pop shift ;[0] undo the push from before + pop bitcnt ;[2] undo the push from before + rjmp waitForK ;[4] this was not the end of sync, retry +; The entire loop from waitForK until rjmp waitForK above must not exceed two +; bit times (= 21 cycles). + +;---------------------------------------------------------------------------- +; push more registers and initialize values while we sample the first bits: +;---------------------------------------------------------------------------- +haveTwoBitsK: + push x1 ;[1] + push x2 ;[3] + push x3 ;[5] + ldi shift, 0 ;[7] + ldi x3, 1<<4 ;[8] [rx loop init] first sample is inverse bit, compensate that + push x4 ;[9] == leap + + in x1, USBIN ;[11] <-- sample bit 0 + andi x1, USBMASK ;[12] + bst x1, USBMINUS ;[13] + bld shift, 7 ;[14] + push cnt ;[15] + ldi leap, 0 ;[17] [rx loop init] + ldi cnt, USB_BUFSIZE;[18] [rx loop init] + rjmp rxbit1 ;[19] arrives at [21] + +;---------------------------------------------------------------------------- +; Receiver loop (numbers in brackets are cycles within byte after instr) +;---------------------------------------------------------------------------- + +; duration of unstuffing code should be 10.66666667 cycles. We adjust "leap" +; accordingly to approximate this value in the long run. + +unstuff6: + andi x2, USBMASK ;[03] + ori x3, 1<<6 ;[04] will not be shifted any more + andi shift, ~0x80;[05] + mov x1, x2 ;[06] sampled bit 7 is actually re-sampled bit 6 + subi leap, -1 ;[07] total duration = 11 bits -> subtract 1/3 + rjmp didUnstuff6 ;[08] + +unstuff7: + ori x3, 1<<7 ;[09] will not be shifted any more + in x2, USBIN ;[00] [10] re-sample bit 7 + andi x2, USBMASK ;[01] + andi shift, ~0x80;[02] + subi leap, 2 ;[03] total duration = 10 bits -> add 1/3 + rjmp didUnstuff7 ;[04] + +unstuffEven: + ori x3, 1<<6 ;[09] will be shifted right 6 times for bit 0 + in x1, USBIN ;[00] [10] + andi shift, ~0x80;[01] + andi x1, USBMASK ;[02] + breq se0 ;[03] + subi leap, -1 ;[04] total duration = 11 bits -> subtract 1/3 + nop2 ;[05] + rjmp didUnstuffE ;[06] + +unstuffOdd: + ori x3, 1<<5 ;[09] will be shifted right 4 times for bit 1 + in x2, USBIN ;[00] [10] + andi shift, ~0x80;[01] + andi x2, USBMASK ;[02] + breq se0 ;[03] + subi leap, -1 ;[04] total duration = 11 bits -> subtract 1/3 + nop2 ;[05] + rjmp didUnstuffO ;[06] + +rxByteLoop: + andi x1, USBMASK ;[03] + eor x2, x1 ;[04] + subi leap, 1 ;[05] + brpl skipLeap ;[06] + subi leap, -3 ;1 one leap cycle every 3rd byte -> 85 + 1/3 cycles per byte + nop ;1 +skipLeap: + subi x2, 1 ;[08] + ror shift ;[09] +didUnstuff6: + cpi shift, 0xfc ;[10] + in x2, USBIN ;[00] [11] <-- sample bit 7 + brcc unstuff6 ;[01] + andi x2, USBMASK ;[02] + eor x1, x2 ;[03] + subi x1, 1 ;[04] + ror shift ;[05] +didUnstuff7: + cpi shift, 0xfc ;[06] + brcc unstuff7 ;[07] + eor x3, shift ;[08] reconstruct: x3 is 1 at bit locations we changed, 0 at others + st y+, x3 ;[09] store data +rxBitLoop: + in x1, USBIN ;[00] [11] <-- sample bit 0/2/4 + andi x1, USBMASK ;[01] + eor x2, x1 ;[02] + andi x3, 0x3f ;[03] topmost two bits reserved for 6 and 7 + subi x2, 1 ;[04] + ror shift ;[05] + cpi shift, 0xfc ;[06] + brcc unstuffEven ;[07] +didUnstuffE: + lsr x3 ;[08] + lsr x3 ;[09] +rxbit1: + in x2, USBIN ;[00] [10] <-- sample bit 1/3/5 + andi x2, USBMASK ;[01] + breq se0 ;[02] + eor x1, x2 ;[03] + subi x1, 1 ;[04] + ror shift ;[05] + cpi shift, 0xfc ;[06] + brcc unstuffOdd ;[07] +didUnstuffO: + subi bitcnt, 0xab;[08] == addi 0x55, 0x55 = 0x100/3 + brcs rxBitLoop ;[09] + + subi cnt, 1 ;[10] + in x1, USBIN ;[00] [11] <-- sample bit 6 + brcc rxByteLoop ;[01] + rjmp overflow + +macro POP_STANDARD ; 14 cycles + pop cnt + pop x4 + pop x3 + pop x2 + pop x1 + pop shift + pop bitcnt + endm +macro POP_RETI ; 7 cycles + pop YH + pop YL + out SREG, YL + pop YL + endm + +#include "asmcommon.inc" + +; USB spec says: +; idle = J +; J = (D+ = 0), (D- = 1) +; K = (D+ = 1), (D- = 0) +; Spec allows 7.5 bit times from EOP to SOP for replies + +bitstuffN: + eor x1, x4 ;[5] + ldi x2, 0 ;[6] + nop2 ;[7] + nop ;[9] + out USBOUT, x1 ;[10] <-- out + rjmp didStuffN ;[0] + +bitstuff6: + eor x1, x4 ;[5] + ldi x2, 0 ;[6] Carry is zero due to brcc + rol shift ;[7] compensate for ror shift at branch destination + rjmp didStuff6 ;[8] + +bitstuff7: + ldi x2, 0 ;[2] Carry is zero due to brcc + rjmp didStuff7 ;[3] + + +sendNakAndReti: + ldi x3, USBPID_NAK ;[-18] + rjmp sendX3AndReti ;[-17] +sendAckAndReti: + ldi cnt, USBPID_ACK ;[-17] +sendCntAndReti: + mov x3, cnt ;[-16] +sendX3AndReti: + ldi YL, 20 ;[-15] x3==r20 address is 20 + ldi YH, 0 ;[-14] + ldi cnt, 2 ;[-13] +; rjmp usbSendAndReti fallthrough + +;usbSend: +;pointer to data in 'Y' +;number of bytes in 'cnt' -- including sync byte [range 2 ... 12] +;uses: x1...x4, btcnt, shift, cnt, Y +;Numbers in brackets are time since first bit of sync pattern is sent +;We don't match the transfer rate exactly (don't insert leap cycles every third +;byte) because the spec demands only 1.5% precision anyway. +usbSendAndReti: ; 12 cycles until SOP + in x2, USBDDR ;[-12] + ori x2, USBMASK ;[-11] + sbi USBOUT, USBMINUS;[-10] prepare idle state; D+ and D- must have been 0 (no pullups) + in x1, USBOUT ;[-8] port mirror for tx loop + out USBDDR, x2 ;[-7] <- acquire bus +; need not init x2 (bitstuff history) because sync starts with 0 + ldi x4, USBMASK ;[-6] exor mask + ldi shift, 0x80 ;[-5] sync byte is first byte sent +txByteLoop: + ldi bitcnt, 0x35 ;[-4] [6] binary 0011 0101 +txBitLoop: + sbrs shift, 0 ;[-3] [7] + eor x1, x4 ;[-2] [8] + out USBOUT, x1 ;[-1] [9] <-- out N + ror shift ;[0] [10] + ror x2 ;[1] +didStuffN: + cpi x2, 0xfc ;[2] + brcc bitstuffN ;[3] + lsr bitcnt ;[4] + brcc txBitLoop ;[5] + brne txBitLoop ;[6] + + sbrs shift, 0 ;[7] + eor x1, x4 ;[8] +didStuff6: + out USBOUT, x1 ;[-1] [9] <-- out 6 + ror shift ;[0] [10] + ror x2 ;[1] + cpi x2, 0xfc ;[2] + brcc bitstuff6 ;[3] + ror shift ;[4] +didStuff7: + ror x2 ;[5] + sbrs x2, 7 ;[6] + eor x1, x4 ;[7] + nop ;[8] + cpi x2, 0xfc ;[9] + out USBOUT, x1 ;[-1][10] <-- out 7 + brcc bitstuff7 ;[0] [11] + ld shift, y+ ;[1] + dec cnt ;[3] + brne txByteLoop ;[4] +;make SE0: + cbr x1, USBMASK ;[5] prepare SE0 [spec says EOP may be 21 to 25 cycles] + lds x2, usbNewDeviceAddr;[6] + lsl x2 ;[8] we compare with left shifted address + subi YL, 20 + 2 ;[9] Only assign address on data packets, not ACK/NAK in x3 + sbci YH, 0 ;[10] + out USBOUT, x1 ;[11] <-- out SE0 -- from now 2 bits = 22 cycles until bus idle +;2006-03-06: moved transfer of new address to usbDeviceAddr from C-Code to asm: +;set address only after data packet was sent, not after handshake + breq skipAddrAssign ;[0] + sts usbDeviceAddr, x2; if not skipped: SE0 is one cycle longer +skipAddrAssign: +;end of usbDeviceAddress transfer + ldi x2, 1< max 52 cycles interrupt disable +;max stack usage: [ret(2), r0, SREG, YL, YH, shift, x1, x2, x3, x4, cnt] = 12 bytes +;nominal frequency: 16.5 MHz -> 11 cycles per bit +; 16.3125 MHz < F_CPU < 16.6875 MHz (+/- 1.1%) +; Numbers in brackets are clocks counted from center of last sync bit +; when instruction starts + + +USB_INTR_VECTOR: +;order of registers pushed: YL, SREG [sofError], r0, YH, shift, x1, x2, x3, x4, cnt + push YL ;[-23] push only what is necessary to sync with edge ASAP + in YL, SREG ;[-21] + push YL ;[-20] +;---------------------------------------------------------------------------- +; Synchronize with sync pattern: +;---------------------------------------------------------------------------- +;sync byte (D-) pattern LSb to MSb: 01010100 [1 = idle = J, 0 = K] +;sync up with J to K edge during sync pattern -- use fastest possible loops +;The first part waits at most 1 bit long since we must be in sync pattern. +;YL is guarenteed to be < 0x80 because I flag is clear. When we jump to +;waitForJ, ensure that this prerequisite is met. +waitForJ: + inc YL + sbis USBIN, USBMINUS + brne waitForJ ; just make sure we have ANY timeout +waitForK: +;The following code results in a sampling window of < 1/4 bit which meets the spec. + sbis USBIN, USBMINUS ;[-15] + rjmp foundK ;[-14] + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS + rjmp foundK +#if USB_COUNT_SOF + lds YL, usbSofCount + inc YL + sts usbSofCount, YL +#endif /* USB_COUNT_SOF */ +#ifdef USB_SOF_HOOK + USB_SOF_HOOK +#endif + rjmp sofError +foundK: ;[-12] +;{3, 5} after falling D- edge, average delay: 4 cycles [we want 5 for center sampling] +;we have 1 bit time for setup purposes, then sample again. Numbers in brackets +;are cycles from center of first sync (double K) bit after the instruction + push r0 ;[-12] +; [---] ;[-11] + push YH ;[-10] +; [---] ;[-9] + lds YL, usbInputBufOffset;[-8] +; [---] ;[-7] + clr YH ;[-6] + subi YL, lo8(-(usbRxBuf));[-5] [rx loop init] + sbci YH, hi8(-(usbRxBuf));[-4] [rx loop init] + mov r0, x2 ;[-3] [rx loop init] + sbis USBIN, USBMINUS ;[-2] we want two bits K (sample 2 cycles too early) + rjmp haveTwoBitsK ;[-1] + pop YH ;[0] undo the pushes from before + pop r0 ;[2] + rjmp waitForK ;[4] this was not the end of sync, retry +; The entire loop from waitForK until rjmp waitForK above must not exceed two +; bit times (= 22 cycles). + +;---------------------------------------------------------------------------- +; push more registers and initialize values while we sample the first bits: +;---------------------------------------------------------------------------- +haveTwoBitsK: ;[1] + push shift ;[1] + push x1 ;[3] + push x2 ;[5] + push x3 ;[7] + ldi shift, 0xff ;[9] [rx loop init] + ori x3, 0xff ;[10] [rx loop init] == ser x3, clear zero flag + + in x1, USBIN ;[11] <-- sample bit 0 + bst x1, USBMINUS ;[12] + bld shift, 0 ;[13] + push x4 ;[14] == phase +; [---] ;[15] + push cnt ;[16] +; [---] ;[17] + ldi phase, 0 ;[18] [rx loop init] + ldi cnt, USB_BUFSIZE;[19] [rx loop init] + rjmp rxbit1 ;[20] +; [---] ;[21] + +;---------------------------------------------------------------------------- +; Receiver loop (numbers in brackets are cycles within byte after instr) +;---------------------------------------------------------------------------- +/* +byte oriented operations done during loop: +bit 0: store data +bit 1: SE0 check +bit 2: overflow check +bit 3: catch up +bit 4: rjmp to achieve conditional jump range +bit 5: PLL +bit 6: catch up +bit 7: jump, fixup bitstuff +; 87 [+ 2] cycles +------------------------------------------------------------------ +*/ +continueWithBit5: + in x2, USBIN ;[055] <-- bit 5 + eor r0, x2 ;[056] + or phase, r0 ;[057] + sbrc phase, USBMINUS ;[058] + lpm ;[059] optional nop3; modifies r0 + in phase, USBIN ;[060] <-- phase + eor x1, x2 ;[061] + bst x1, USBMINUS ;[062] + bld shift, 5 ;[063] + andi shift, 0x3f ;[064] + in x1, USBIN ;[065] <-- bit 6 + breq unstuff5 ;[066] *** unstuff escape + eor phase, x1 ;[067] + eor x2, x1 ;[068] + bst x2, USBMINUS ;[069] + bld shift, 6 ;[070] +didUnstuff6: ;[ ] + in r0, USBIN ;[071] <-- phase + cpi shift, 0x02 ;[072] + brlo unstuff6 ;[073] *** unstuff escape +didUnstuff5: ;[ ] + nop2 ;[074] +; [---] ;[075] + in x2, USBIN ;[076] <-- bit 7 + eor x1, x2 ;[077] + bst x1, USBMINUS ;[078] + bld shift, 7 ;[079] +didUnstuff7: ;[ ] + eor r0, x2 ;[080] + or phase, r0 ;[081] + in r0, USBIN ;[082] <-- phase + cpi shift, 0x04 ;[083] + brsh rxLoop ;[084] +; [---] ;[085] +unstuff7: ;[ ] + andi x3, ~0x80 ;[085] + ori shift, 0x80 ;[086] + in x2, USBIN ;[087] <-- sample stuffed bit 7 + nop ;[088] + rjmp didUnstuff7 ;[089] +; [---] ;[090] + ;[080] + +unstuff5: ;[067] + eor phase, x1 ;[068] + andi x3, ~0x20 ;[069] + ori shift, 0x20 ;[070] + in r0, USBIN ;[071] <-- phase + mov x2, x1 ;[072] + nop ;[073] + nop2 ;[074] +; [---] ;[075] + in x1, USBIN ;[076] <-- bit 6 + eor r0, x1 ;[077] + or phase, r0 ;[078] + eor x2, x1 ;[079] + bst x2, USBMINUS ;[080] + bld shift, 6 ;[081] no need to check bitstuffing, we just had one + in r0, USBIN ;[082] <-- phase + rjmp didUnstuff5 ;[083] +; [---] ;[084] + ;[074] + +unstuff6: ;[074] + andi x3, ~0x40 ;[075] + in x1, USBIN ;[076] <-- bit 6 again + ori shift, 0x40 ;[077] + nop2 ;[078] +; [---] ;[079] + rjmp didUnstuff6 ;[080] +; [---] ;[081] + ;[071] + +unstuff0: ;[013] + eor r0, x2 ;[014] + or phase, r0 ;[015] + andi x2, USBMASK ;[016] check for SE0 + in r0, USBIN ;[017] <-- phase + breq didUnstuff0 ;[018] direct jump to se0 would be too long + andi x3, ~0x01 ;[019] + ori shift, 0x01 ;[020] + mov x1, x2 ;[021] mov existing sample + in x2, USBIN ;[022] <-- bit 1 again + rjmp didUnstuff0 ;[023] +; [---] ;[024] + ;[014] + +unstuff1: ;[024] + eor r0, x1 ;[025] + or phase, r0 ;[026] + andi x3, ~0x02 ;[027] + in r0, USBIN ;[028] <-- phase + ori shift, 0x02 ;[029] + mov x2, x1 ;[030] + rjmp didUnstuff1 ;[031] +; [---] ;[032] + ;[022] + +unstuff2: ;[035] + eor r0, x2 ;[036] + or phase, r0 ;[037] + andi x3, ~0x04 ;[038] + in r0, USBIN ;[039] <-- phase + ori shift, 0x04 ;[040] + mov x1, x2 ;[041] + rjmp didUnstuff2 ;[042] +; [---] ;[043] + ;[033] + +unstuff3: ;[043] + in x2, USBIN ;[044] <-- bit 3 again + eor r0, x2 ;[045] + or phase, r0 ;[046] + andi x3, ~0x08 ;[047] + ori shift, 0x08 ;[048] + nop ;[049] + in r0, USBIN ;[050] <-- phase + rjmp didUnstuff3 ;[051] +; [---] ;[052] + ;[042] + +unstuff4: ;[053] + andi x3, ~0x10 ;[054] + in x1, USBIN ;[055] <-- bit 4 again + ori shift, 0x10 ;[056] + rjmp didUnstuff4 ;[057] +; [---] ;[058] + ;[048] + +rxLoop: ;[085] + eor x3, shift ;[086] reconstruct: x3 is 0 at bit locations we changed, 1 at others + in x1, USBIN ;[000] <-- bit 0 + st y+, x3 ;[001] +; [---] ;[002] + eor r0, x1 ;[003] + or phase, r0 ;[004] + eor x2, x1 ;[005] + in r0, USBIN ;[006] <-- phase + ser x3 ;[007] + bst x2, USBMINUS ;[008] + bld shift, 0 ;[009] + andi shift, 0xf9 ;[010] +rxbit1: ;[ ] + in x2, USBIN ;[011] <-- bit 1 + breq unstuff0 ;[012] *** unstuff escape + andi x2, USBMASK ;[013] SE0 check for bit 1 +didUnstuff0: ;[ ] Z only set if we detected SE0 in bitstuff + breq se0 ;[014] + eor r0, x2 ;[015] + or phase, r0 ;[016] + in r0, USBIN ;[017] <-- phase + eor x1, x2 ;[018] + bst x1, USBMINUS ;[019] + bld shift, 1 ;[020] + andi shift, 0xf3 ;[021] +didUnstuff1: ;[ ] + in x1, USBIN ;[022] <-- bit 2 + breq unstuff1 ;[023] *** unstuff escape + eor r0, x1 ;[024] + or phase, r0 ;[025] + subi cnt, 1 ;[026] overflow check + brcs overflow ;[027] + in r0, USBIN ;[028] <-- phase + eor x2, x1 ;[029] + bst x2, USBMINUS ;[030] + bld shift, 2 ;[031] + andi shift, 0xe7 ;[032] +didUnstuff2: ;[ ] + in x2, USBIN ;[033] <-- bit 3 + breq unstuff2 ;[034] *** unstuff escape + eor r0, x2 ;[035] + or phase, r0 ;[036] + eor x1, x2 ;[037] + bst x1, USBMINUS ;[038] + in r0, USBIN ;[039] <-- phase + bld shift, 3 ;[040] + andi shift, 0xcf ;[041] +didUnstuff3: ;[ ] + breq unstuff3 ;[042] *** unstuff escape + nop ;[043] + in x1, USBIN ;[044] <-- bit 4 + eor x2, x1 ;[045] + bst x2, USBMINUS ;[046] + bld shift, 4 ;[047] +didUnstuff4: ;[ ] + eor r0, x1 ;[048] + or phase, r0 ;[049] + in r0, USBIN ;[050] <-- phase + andi shift, 0x9f ;[051] + breq unstuff4 ;[052] *** unstuff escape + rjmp continueWithBit5;[053] +; [---] ;[054] + +macro POP_STANDARD ; 16 cycles + pop cnt + pop x4 + pop x3 + pop x2 + pop x1 + pop shift + pop YH + pop r0 + endm +macro POP_RETI ; 5 cycles + pop YL + out SREG, YL + pop YL + endm + +#include "asmcommon.inc" + + +; USB spec says: +; idle = J +; J = (D+ = 0), (D- = 1) +; K = (D+ = 1), (D- = 0) +; Spec allows 7.5 bit times from EOP to SOP for replies + +bitstuff7: + eor x1, x4 ;[4] + ldi x2, 0 ;[5] + nop2 ;[6] C is zero (brcc) + rjmp didStuff7 ;[8] + +bitstuffN: + eor x1, x4 ;[5] + ldi x2, 0 ;[6] + lpm ;[7] 3 cycle NOP, modifies r0 + out USBOUT, x1 ;[10] <-- out + rjmp didStuffN ;[0] + +#define bitStatus x3 + +sendNakAndReti: + ldi cnt, USBPID_NAK ;[-19] + rjmp sendCntAndReti ;[-18] +sendAckAndReti: + ldi cnt, USBPID_ACK ;[-17] +sendCntAndReti: + mov r0, cnt ;[-16] + ldi YL, 0 ;[-15] R0 address is 0 + ldi YH, 0 ;[-14] + ldi cnt, 2 ;[-13] +; rjmp usbSendAndReti fallthrough + +;usbSend: +;pointer to data in 'Y' +;number of bytes in 'cnt' -- including sync byte [range 2 ... 12] +;uses: x1...x4, shift, cnt, Y +;Numbers in brackets are time since first bit of sync pattern is sent +usbSendAndReti: ; 12 cycles until SOP + in x2, USBDDR ;[-12] + ori x2, USBMASK ;[-11] + sbi USBOUT, USBMINUS;[-10] prepare idle state; D+ and D- must have been 0 (no pullups) + in x1, USBOUT ;[-8] port mirror for tx loop + out USBDDR, x2 ;[-7] <- acquire bus +; need not init x2 (bitstuff history) because sync starts with 0 + ldi x4, USBMASK ;[-6] exor mask + ldi shift, 0x80 ;[-5] sync byte is first byte sent + ldi bitStatus, 0xff ;[-4] init bit loop counter, works for up to 12 bytes +byteloop: +bitloop: + sbrs shift, 0 ;[8] [-3] + eor x1, x4 ;[9] [-2] + out USBOUT, x1 ;[10] [-1] <-- out + ror shift ;[0] + ror x2 ;[1] +didStuffN: + cpi x2, 0xfc ;[2] + brcc bitstuffN ;[3] + nop ;[4] + subi bitStatus, 37 ;[5] 256 / 7 ~=~ 37 + brcc bitloop ;[6] when we leave the loop, bitStatus has almost the initial value + sbrs shift, 0 ;[7] + eor x1, x4 ;[8] + ror shift ;[9] +didStuff7: + out USBOUT, x1 ;[10] <-- out + ror x2 ;[0] + cpi x2, 0xfc ;[1] + brcc bitstuff7 ;[2] + ld shift, y+ ;[3] + dec cnt ;[5] + brne byteloop ;[6] +;make SE0: + cbr x1, USBMASK ;[7] prepare SE0 [spec says EOP may be 21 to 25 cycles] + lds x2, usbNewDeviceAddr;[8] + lsl x2 ;[10] we compare with left shifted address + out USBOUT, x1 ;[11] <-- out SE0 -- from now 2 bits = 22 cycles until bus idle +;2006-03-06: moved transfer of new address to usbDeviceAddr from C-Code to asm: +;set address only after data packet was sent, not after handshake + subi YL, 2 ;[0] Only assign address on data packets, not ACK/NAK in r0 + sbci YH, 0 ;[1] + breq skipAddrAssign ;[2] + sts usbDeviceAddr, x2; if not skipped: SE0 is one cycle longer +skipAddrAssign: +;end of usbDeviceAddress transfer + ldi x2, 1< 12 cycles per bit +; Numbers in brackets are clocks counted from center of last sync bit +; when instruction starts +;register use in receive loop to receive the data bytes: +; shift assembles the byte currently being received +; x1 holds the D+ and D- line state +; x2 holds the previous line state +; cnt holds the number of bytes left in the receive buffer +; x3 holds the higher crc byte (see algorithm below) +; x4 is used as temporary register for the crc algorithm +; x5 is used for unstuffing: when unstuffing the last received bit is inverted in shift (to prevent further +; unstuffing calls. In the same time the corresponding bit in x5 is cleared to mark the bit as beening iverted +; zl lower crc value and crc table index +; zh used for crc table accesses + +;-------------------------------------------------------------------------------------------------------------- +; CRC mods: +; table driven crc checker, Z points to table in prog space +; ZL is the lower crc byte, x3 is the higher crc byte +; x4 is used as temp register to store different results +; the initialization of the crc register is not 0xFFFF but 0xFE54. This is because during the receipt of the +; first data byte an virtual zero data byte is added to the crc register, this results in the correct initial +; value of 0xFFFF at beginning of the second data byte before the first data byte is added to the crc. +; The magic number 0xFE54 results form the crc table: At tabH[0x54] = 0xFF = crcH (required) and +; tabL[0x54] = 0x01 -> crcL = 0x01 xor 0xFE = 0xFF +; bitcnt is renamed to x5 and is used for unstuffing purposes, the unstuffing works like in the 12MHz version +;-------------------------------------------------------------------------------------------------------------- +; CRC algorithm: +; The crc register is formed by x3 (higher byte) and ZL (lower byte). The algorithm uses a 'reversed' form +; i.e. that it takes the least significant bit first and shifts to the right. So in fact the highest order +; bit seen from the polynomial devision point of view is the lsb of ZL. (If this sounds strange to you i +; propose a research on CRC :-) ) +; Each data byte received is xored to ZL, the lower crc byte. This byte now builds the crc +; table index. Next the new high byte is loaded from the table and stored in x4 until we have space in x3 +; (its destination). +; Afterwards the lower table is loaded from the table and stored in ZL (the old index is overwritten as +; we don't need it anymore. In fact this is a right shift by 8 bits.) Now the old crc high value is xored +; to ZL, this is the second shift of the old crc value. Now x4 (the temp reg) is moved to x3 and the crc +; calculation is done. +; Prior to the first byte the two CRC register have to be initialized to 0xFFFF (as defined in usb spec) +; however the crc engine also runs during the receipt of the first byte, therefore x3 and zl are initialized +; to a magic number which results in a crc value of 0xFFFF after the first complete byte. +; +; This algorithm is split into the extra cycles of the different bits: +; bit7: XOR the received byte to ZL +; bit5: load the new high byte to x4 +; bit6: load the lower xor byte from the table, xor zl and x3, store result in zl (=the new crc low value) +; move x4 (the new high byte) to x3, the crc value is ready +; + + +macro POP_STANDARD ; 18 cycles + pop ZH + pop ZL + pop cnt + pop x5 + pop x3 + pop x2 + pop x1 + pop shift + pop x4 + endm +macro POP_RETI ; 7 cycles + pop YH + pop YL + out SREG, YL + pop YL + endm + +macro CRC_CLEANUP_AND_CHECK + ; the last byte has already been xored with the lower crc byte, we have to do the table lookup and xor + ; x3 is the higher crc byte, zl the lower one + ldi ZH, hi8(usbCrcTableHigh);[+1] get the new high byte from the table + lpm x2, Z ;[+2][+3][+4] + ldi ZH, hi8(usbCrcTableLow);[+5] get the new low xor byte from the table + lpm ZL, Z ;[+6][+7][+8] + eor ZL, x3 ;[+7] xor the old high byte with the value from the table, x2:ZL now holds the crc value + cpi ZL, 0x01 ;[+8] if the crc is ok we have a fixed remainder value of 0xb001 in x2:ZL (see usb spec) + brne ignorePacket ;[+9] detected a crc fault -> paket is ignored and retransmitted by the host + cpi x2, 0xb0 ;[+10] + brne ignorePacket ;[+11] detected a crc fault -> paket is ignored and retransmitted by the host + endm + + +USB_INTR_VECTOR: +;order of registers pushed: YL, SREG, YH, [sofError], x4, shift, x1, x2, x3, x5, cnt, ZL, ZH + push YL ;[-28] push only what is necessary to sync with edge ASAP + in YL, SREG ;[-26] + push YL ;[-25] + push YH ;[-23] +;---------------------------------------------------------------------------- +; Synchronize with sync pattern: +;---------------------------------------------------------------------------- +;sync byte (D-) pattern LSb to MSb: 01010100 [1 = idle = J, 0 = K] +;sync up with J to K edge during sync pattern -- use fastest possible loops +;The first part waits at most 1 bit long since we must be in sync pattern. +;YL is guarenteed to be < 0x80 because I flag is clear. When we jump to +;waitForJ, ensure that this prerequisite is met. +waitForJ: + inc YL + sbis USBIN, USBMINUS + brne waitForJ ; just make sure we have ANY timeout +waitForK: +;The following code results in a sampling window of < 1/4 bit which meets the spec. + sbis USBIN, USBMINUS ;[-17] + rjmp foundK ;[-16] + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS + rjmp foundK +#if USB_COUNT_SOF + lds YL, usbSofCount + inc YL + sts usbSofCount, YL +#endif /* USB_COUNT_SOF */ +#ifdef USB_SOF_HOOK + USB_SOF_HOOK +#endif + rjmp sofError +foundK: ;[-15] +;{3, 5} after falling D- edge, average delay: 4 cycles +;bit0 should be at 30 (2.5 bits) for center sampling. Currently at 4 so 26 cylces till bit 0 sample +;use 1 bit time for setup purposes, then sample again. Numbers in brackets +;are cycles from center of first sync (double K) bit after the instruction + push x4 ;[-14] +; [---] ;[-13] + lds YL, usbInputBufOffset;[-12] used to toggle the two usb receive buffers +; [---] ;[-11] + clr YH ;[-10] + subi YL, lo8(-(usbRxBuf));[-9] [rx loop init] + sbci YH, hi8(-(usbRxBuf));[-8] [rx loop init] + push shift ;[-7] +; [---] ;[-6] + ldi shift, 0x80 ;[-5] the last bit is the end of byte marker for the pid receiver loop + clc ;[-4] the carry has to be clear for receipt of pid bit 0 + sbis USBIN, USBMINUS ;[-3] we want two bits K (sample 3 cycles too early) + rjmp haveTwoBitsK ;[-2] + pop shift ;[-1] undo the push from before + pop x4 ;[1] + rjmp waitForK ;[3] this was not the end of sync, retry +; The entire loop from waitForK until rjmp waitForK above must not exceed two +; bit times (= 24 cycles). + +;---------------------------------------------------------------------------- +; push more registers and initialize values while we sample the first bits: +;---------------------------------------------------------------------------- +haveTwoBitsK: + push x1 ;[0] + push x2 ;[2] + push x3 ;[4] crc high byte + ldi x2, 1< jump back and store the byte + ori shift, 0x01 ;[11] invert the last received bit to prevent furhter unstuffing + in x2, USBIN ;[0] we have some free cycles so we could check for bit stuffing errors + andi x5, 0xFE ;[1] mark this bit as inverted (will be corrected before storing shift) + eor x1, x2 ;[2] x1 and x2 have to be different because the stuff bit is always a zero + andi x1, USBMASK ;[3] mask the interesting bits + breq stuffErr ;[4] if the stuff bit is a 1-bit something went wrong + mov x1, x2 ;[5] the next bit expects the last state to be in x1 + rjmp didunstuff0 ;[6] + ;[7] jump delay of rjmp didunstuffX + +unstuff1: ;[11] this is the jump delay of breq unstuffX + in x1, USBIN ;[0] we have some free cycles so we could check for bit stuffing errors + ori shift, 0x02 ;[1] invert the last received bit to prevent furhter unstuffing + andi x5, 0xFD ;[2] mark this bit as inverted (will be corrected before storing shift) + eor x2, x1 ;[3] x1 and x2 have to be different because the stuff bit is always a zero + andi x2, USBMASK ;[4] mask the interesting bits + breq stuffErr ;[5] if the stuff bit is a 1-bit something went wrong + mov x2, x1 ;[6] the next bit expects the last state to be in x2 + nop2 ;[7] + ;[8] + rjmp didunstuff1 ;[9] + ;[10] jump delay of rjmp didunstuffX + +unstuff2: ;[9] this is the jump delay of breq unstuffX + ori shift, 0x04 ;[10] invert the last received bit to prevent furhter unstuffing + andi x5, 0xFB ;[11] mark this bit as inverted (will be corrected before storing shift) + in x2, USBIN ;[0] we have some free cycles so we could check for bit stuffing errors + eor x1, x2 ;[1] x1 and x2 have to be different because the stuff bit is always a zero + andi x1, USBMASK ;[2] mask the interesting bits + breq stuffErr ;[3] if the stuff bit is a 1-bit something went wrong + mov x1, x2 ;[4] the next bit expects the last state to be in x1 + nop2 ;[5] + ;[6] + rjmp didunstuff2 ;[7] + ;[8] jump delay of rjmp didunstuffX + +unstuff3: ;[9] this is the jump delay of breq unstuffX + ori shift, 0x08 ;[10] invert the last received bit to prevent furhter unstuffing + andi x5, 0xF7 ;[11] mark this bit as inverted (will be corrected before storing shift) + in x1, USBIN ;[0] we have some free cycles so we could check for bit stuffing errors + eor x2, x1 ;[1] x1 and x2 have to be different because the stuff bit is always a zero + andi x2, USBMASK ;[2] mask the interesting bits + breq stuffErr ;[3] if the stuff bit is a 1-bit something went wrong + mov x2, x1 ;[4] the next bit expects the last state to be in x2 + nop2 ;[5] + ;[6] + rjmp didunstuff3 ;[7] + ;[8] jump delay of rjmp didunstuffX + + + +; the include has to be here due to branch distance restirctions +#define __USE_CRC__ +#include "asmcommon.inc" + + + +; USB spec says: +; idle = J +; J = (D+ = 0), (D- = 1) +; K = (D+ = 1), (D- = 0) +; Spec allows 7.5 bit times from EOP to SOP for replies +; 7.5 bit times is 90 cycles. ...there is plenty of time + + +sendNakAndReti: + ldi x3, USBPID_NAK ;[-18] + rjmp sendX3AndReti ;[-17] +sendAckAndReti: + ldi cnt, USBPID_ACK ;[-17] +sendCntAndReti: + mov x3, cnt ;[-16] +sendX3AndReti: + ldi YL, 20 ;[-15] x3==r20 address is 20 + ldi YH, 0 ;[-14] + ldi cnt, 2 ;[-13] +; rjmp usbSendAndReti fallthrough + +;usbSend: +;pointer to data in 'Y' +;number of bytes in 'cnt' -- including sync byte [range 2 ... 12] +;uses: x1...x4, btcnt, shift, cnt, Y +;Numbers in brackets are time since first bit of sync pattern is sent + +usbSendAndReti: ; 12 cycles until SOP + in x2, USBDDR ;[-12] + ori x2, USBMASK ;[-11] + sbi USBOUT, USBMINUS;[-10] prepare idle state; D+ and D- must have been 0 (no pullups) + in x1, USBOUT ;[-8] port mirror for tx loop + out USBDDR, x2 ;[-6] <- acquire bus + ldi x2, 0 ;[-6] init x2 (bitstuff history) because sync starts with 0 + ldi x4, USBMASK ;[-5] exor mask + ldi shift, 0x80 ;[-4] sync byte is first byte sent +txByteLoop: + ldi bitcnt, 0x40 ;[-3]=[9] binary 01000000 +txBitLoop: ; the loop sends the first 7 bits of the byte + sbrs shift, 0 ;[-2]=[10] if we have to send a 1 don't change the line state + eor x1, x4 ;[-1]=[11] + out USBOUT, x1 ;[0] + ror shift ;[1] + ror x2 ;[2] transfers the last sent bit to the stuffing history +didStuffN: + nop ;[3] + nop ;[4] + cpi x2, 0xfc ;[5] if we sent six consecutive ones + brcc bitstuffN ;[6] + lsr bitcnt ;[7] + brne txBitLoop ;[8] restart the loop while the 1 is still in the bitcount + +; transmit bit 7 + sbrs shift, 0 ;[9] + eor x1, x4 ;[10] +didStuff7: + ror shift ;[11] + out USBOUT, x1 ;[0] transfer bit 7 to the pins + ror x2 ;[1] move the bit into the stuffing history + cpi x2, 0xfc ;[2] + brcc bitstuff7 ;[3] + ld shift, y+ ;[4] get next byte to transmit + dec cnt ;[5] decrement byte counter + brne txByteLoop ;[7] if we have more bytes start next one + ;[8] branch delay + +;make SE0: + cbr x1, USBMASK ;[8] prepare SE0 [spec says EOP may be 25 to 30 cycles] + lds x2, usbNewDeviceAddr;[9] + lsl x2 ;[11] we compare with left shifted address + out USBOUT, x1 ;[0] <-- out SE0 -- from now 2 bits = 24 cycles until bus idle + subi YL, 20 + 2 ;[1] Only assign address on data packets, not ACK/NAK in x3 + sbci YH, 0 ;[2] +;2006-03-06: moved transfer of new address to usbDeviceAddr from C-Code to asm: +;set address only after data packet was sent, not after handshake + breq skipAddrAssign ;[3] + sts usbDeviceAddr, x2 ; if not skipped: SE0 is one cycle longer +skipAddrAssign: +;end of usbDeviceAddress transfer + ldi x2, 1< +int main (int argc, char **argv) +{ + int i, j; + for (i=0; i<512; i++){ + unsigned short crc = i & 0xff; + for(j=0; j<8; j++) crc = (crc >> 1) ^ ((crc & 1) ? 0xa001 : 0); + if((i & 7) == 0) printf("\n.byte "); + printf("0x%02x, ", (i > 0xff ? (crc >> 8) : crc) & 0xff); + if(i == 255) printf("\n"); + } + return 0; +} + +// Use the following algorithm to compute CRC values: +ushort computeCrc(uchar *msg, uchar msgLen) +{ + uchar i; + ushort crc = 0xffff; + for(i = 0; i < msgLen; i++) + crc = usbCrcTable16[lo8(crc) ^ msg[i]] ^ hi8(crc); + return crc; +} +*/ + +.balign 256 +usbCrcTableLow: +.byte 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41 +.byte 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40 +.byte 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40 +.byte 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41 +.byte 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40 +.byte 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41 +.byte 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41 +.byte 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40 +.byte 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40 +.byte 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41 +.byte 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41 +.byte 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40 +.byte 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41 +.byte 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40 +.byte 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40 +.byte 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41 +.byte 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40 +.byte 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41 +.byte 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41 +.byte 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40 +.byte 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41 +.byte 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40 +.byte 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40 +.byte 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41 +.byte 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41 +.byte 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40 +.byte 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40 +.byte 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41 +.byte 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40 +.byte 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41 +.byte 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41 +.byte 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40 + +; .balign 256 +usbCrcTableHigh: +.byte 0x00, 0xC0, 0xC1, 0x01, 0xC3, 0x03, 0x02, 0xC2 +.byte 0xC6, 0x06, 0x07, 0xC7, 0x05, 0xC5, 0xC4, 0x04 +.byte 0xCC, 0x0C, 0x0D, 0xCD, 0x0F, 0xCF, 0xCE, 0x0E +.byte 0x0A, 0xCA, 0xCB, 0x0B, 0xC9, 0x09, 0x08, 0xC8 +.byte 0xD8, 0x18, 0x19, 0xD9, 0x1B, 0xDB, 0xDA, 0x1A +.byte 0x1E, 0xDE, 0xDF, 0x1F, 0xDD, 0x1D, 0x1C, 0xDC +.byte 0x14, 0xD4, 0xD5, 0x15, 0xD7, 0x17, 0x16, 0xD6 +.byte 0xD2, 0x12, 0x13, 0xD3, 0x11, 0xD1, 0xD0, 0x10 +.byte 0xF0, 0x30, 0x31, 0xF1, 0x33, 0xF3, 0xF2, 0x32 +.byte 0x36, 0xF6, 0xF7, 0x37, 0xF5, 0x35, 0x34, 0xF4 +.byte 0x3C, 0xFC, 0xFD, 0x3D, 0xFF, 0x3F, 0x3E, 0xFE +.byte 0xFA, 0x3A, 0x3B, 0xFB, 0x39, 0xF9, 0xF8, 0x38 +.byte 0x28, 0xE8, 0xE9, 0x29, 0xEB, 0x2B, 0x2A, 0xEA +.byte 0xEE, 0x2E, 0x2F, 0xEF, 0x2D, 0xED, 0xEC, 0x2C +.byte 0xE4, 0x24, 0x25, 0xE5, 0x27, 0xE7, 0xE6, 0x26 +.byte 0x22, 0xE2, 0xE3, 0x23, 0xE1, 0x21, 0x20, 0xE0 +.byte 0xA0, 0x60, 0x61, 0xA1, 0x63, 0xA3, 0xA2, 0x62 +.byte 0x66, 0xA6, 0xA7, 0x67, 0xA5, 0x65, 0x64, 0xA4 +.byte 0x6C, 0xAC, 0xAD, 0x6D, 0xAF, 0x6F, 0x6E, 0xAE +.byte 0xAA, 0x6A, 0x6B, 0xAB, 0x69, 0xA9, 0xA8, 0x68 +.byte 0x78, 0xB8, 0xB9, 0x79, 0xBB, 0x7B, 0x7A, 0xBA +.byte 0xBE, 0x7E, 0x7F, 0xBF, 0x7D, 0xBD, 0xBC, 0x7C +.byte 0xB4, 0x74, 0x75, 0xB5, 0x77, 0xB7, 0xB6, 0x76 +.byte 0x72, 0xB2, 0xB3, 0x73, 0xB1, 0x71, 0x70, 0xB0 +.byte 0x50, 0x90, 0x91, 0x51, 0x93, 0x53, 0x52, 0x92 +.byte 0x96, 0x56, 0x57, 0x97, 0x55, 0x95, 0x94, 0x54 +.byte 0x9C, 0x5C, 0x5D, 0x9D, 0x5F, 0x9F, 0x9E, 0x5E +.byte 0x5A, 0x9A, 0x9B, 0x5B, 0x99, 0x59, 0x58, 0x98 +.byte 0x88, 0x48, 0x49, 0x89, 0x4B, 0x8B, 0x8A, 0x4A +.byte 0x4E, 0x8E, 0x8F, 0x4F, 0x8D, 0x4D, 0x4C, 0x8C +.byte 0x44, 0x84, 0x85, 0x45, 0x87, 0x47, 0x46, 0x86 +.byte 0x82, 0x42, 0x43, 0x83, 0x41, 0x81, 0x80, 0x40 + diff --git a/firmware/usbdrv/usbdrvasm20.inc b/firmware/usbdrv/usbdrvasm20.inc new file mode 100644 index 0000000..303abaf --- /dev/null +++ b/firmware/usbdrv/usbdrvasm20.inc @@ -0,0 +1,360 @@ +/* Name: usbdrvasm20.inc + * Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers + * Author: Jeroen Benschop + * Based on usbdrvasm16.inc from Christian Starkjohann + * Creation Date: 2008-03-05 + * Tabsize: 4 + * Copyright: (c) 2008 by Jeroen Benschop and OBJECTIVE DEVELOPMENT Software GmbH + * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) + * Revision: $Id: usbdrvasm20.inc 740 2009-04-13 18:23:31Z cs $ + */ + +/* Do not link this file! Link usbdrvasm.S instead, which includes the + * appropriate implementation! + */ + +/* +General Description: +This file is the 20 MHz version of the asssembler part of the USB driver. It +requires a 20 MHz crystal (not a ceramic resonator and not a calibrated RC +oscillator). + +See usbdrv.h for a description of the entire driver. + +Since almost all of this code is timing critical, don't change unless you +really know what you are doing! Many parts require not only a maximum number +of CPU cycles, but even an exact number of cycles! +*/ + +#define leap2 x3 +#ifdef __IAR_SYSTEMS_ASM__ +#define nextInst $+2 +#else +#define nextInst .+0 +#endif + +;max stack usage: [ret(2), YL, SREG, YH, bitcnt, shift, x1, x2, x3, x4, cnt] = 12 bytes +;nominal frequency: 20 MHz -> 13.333333 cycles per bit, 106.666667 cycles per byte +; Numbers in brackets are clocks counted from center of last sync bit +; when instruction starts +;register use in receive loop: +; shift assembles the byte currently being received +; x1 holds the D+ and D- line state +; x2 holds the previous line state +; x4 (leap) is used to add a leap cycle once every three bytes received +; X3 (leap2) is used to add a leap cycle once every three stuff bits received +; bitcnt is used to determine when a stuff bit is due +; cnt holds the number of bytes left in the receive buffer + +USB_INTR_VECTOR: +;order of registers pushed: YL, SREG YH, [sofError], bitcnt, shift, x1, x2, x3, x4, cnt + push YL ;[-28] push only what is necessary to sync with edge ASAP + in YL, SREG ;[-26] + push YL ;[-25] + push YH ;[-23] +;---------------------------------------------------------------------------- +; Synchronize with sync pattern: +;---------------------------------------------------------------------------- +;sync byte (D-) pattern LSb to MSb: 01010100 [1 = idle = J, 0 = K] +;sync up with J to K edge during sync pattern -- use fastest possible loops +;The first part waits at most 1 bit long since we must be in sync pattern. +;YL is guarenteed to be < 0x80 because I flag is clear. When we jump to +;waitForJ, ensure that this prerequisite is met. +waitForJ: + inc YL + sbis USBIN, USBMINUS + brne waitForJ ; just make sure we have ANY timeout +waitForK: +;The following code results in a sampling window of < 1/4 bit which meets the spec. + sbis USBIN, USBMINUS ;[-19] + rjmp foundK ;[-18] + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS + rjmp foundK +#if USB_COUNT_SOF + lds YL, usbSofCount + inc YL + sts usbSofCount, YL +#endif /* USB_COUNT_SOF */ +#ifdef USB_SOF_HOOK + USB_SOF_HOOK +#endif + rjmp sofError +foundK: ;[-16] +;{3, 5} after falling D- edge, average delay: 4 cycles +;bit0 should be at 34 for center sampling. Currently at 4 so 30 cylces till bit 0 sample +;use 1 bit time for setup purposes, then sample again. Numbers in brackets +;are cycles from center of first sync (double K) bit after the instruction + push bitcnt ;[-16] +; [---] ;[-15] + lds YL, usbInputBufOffset;[-14] +; [---] ;[-13] + clr YH ;[-12] + subi YL, lo8(-(usbRxBuf));[-11] [rx loop init] + sbci YH, hi8(-(usbRxBuf));[-10] [rx loop init] + push shift ;[-9] +; [---] ;[-8] + ldi shift,0x40 ;[-7] set msb to "1" so processing bit7 can be detected + nop2 ;[-6] +; [---] ;[-5] + ldi bitcnt, 5 ;[-4] [rx loop init] + sbis USBIN, USBMINUS ;[-3] we want two bits K (sample 3 cycles too early) + rjmp haveTwoBitsK ;[-2] + pop shift ;[-1] undo the push from before + pop bitcnt ;[1] + rjmp waitForK ;[3] this was not the end of sync, retry +; The entire loop from waitForK until rjmp waitForK above must not exceed two +; bit times (= 27 cycles). + +;---------------------------------------------------------------------------- +; push more registers and initialize values while we sample the first bits: +;---------------------------------------------------------------------------- +haveTwoBitsK: + push x1 ;[0] + push x2 ;[2] + push x3 ;[4] (leap2) + ldi leap2, 0x55 ;[6] add leap cycle on 2nd,5th,8th,... stuff bit + push x4 ;[7] == leap + ldi leap, 0x55 ;[9] skip leap cycle on 2nd,5th,8th,... byte received + push cnt ;[10] + ldi cnt, USB_BUFSIZE ;[12] [rx loop init] + ldi x2, 1< +#ifndef __IAR_SYSTEMS_ASM__ +# include +#endif + +#define __attribute__(arg) /* not supported on IAR */ + +#ifdef __IAR_SYSTEMS_ASM__ +# define __ASSEMBLER__ /* IAR does not define standard macro for asm */ +#endif + +#ifdef __HAS_ELPM__ +# define PROGMEM __farflash +#else +# define PROGMEM __flash +#endif + +#define USB_READ_FLASH(addr) (*(PROGMEM char *)(addr)) + +/* The following definitions are not needed by the driver, but may be of some + * help if you port a gcc based project to IAR. + */ +#define cli() __disable_interrupt() +#define sei() __enable_interrupt() +#define wdt_reset() __watchdog_reset() +#define _BV(x) (1 << (x)) + +/* assembler compatibility macros */ +#define nop2 rjmp $+2 /* jump to next instruction */ +#define XL r26 +#define XH r27 +#define YL r28 +#define YH r29 +#define ZL r30 +#define ZH r31 +#define lo8(x) LOW(x) +#define hi8(x) (((x)>>8) & 0xff) /* not HIGH to allow XLINK to make a proper range check */ + +/* Depending on the device you use, you may get problems with the way usbdrv.h + * handles the differences between devices. Since IAR does not use #defines + * for MCU registers, we can't check for the existence of a particular + * register with an #ifdef. If the autodetection mechanism fails, include + * definitions for the required USB_INTR_* macros in your usbconfig.h. See + * usbconfig-prototype.h and usbdrv.h for details. + */ + +/* ------------------------------------------------------------------------- */ +#elif __CODEVISIONAVR__ /* check for CodeVision AVR */ +/* ------------------------------------------------------------------------- */ +/* This port is not working (yet) */ + +/* #define F_CPU _MCU_CLOCK_FREQUENCY_ seems to be defined automatically */ + +#include +#include + +#define __attribute__(arg) /* not supported on IAR */ + +#define PROGMEM __flash +#define USB_READ_FLASH(addr) (*(PROGMEM char *)(addr)) + +#ifndef __ASSEMBLER__ +static inline void cli(void) +{ + #asm("cli"); +} +static inline void sei(void) +{ + #asm("sei"); +} +#endif +#define _delay_ms(t) delay_ms(t) +#define _BV(x) (1 << (x)) +#define USB_CFG_USE_SWITCH_STATEMENT 1 /* macro for if() cascase fails for unknown reason */ + +#define macro .macro +#define endm .endmacro +#define nop2 rjmp .+0 /* jump to next instruction */ + +/* ------------------------------------------------------------------------- */ +#else /* default development environment is avr-gcc/avr-libc */ +/* ------------------------------------------------------------------------- */ + +#include +#ifdef __ASSEMBLER__ +# define _VECTOR(N) __vector_ ## N /* io.h does not define this for asm */ +#else +# include +#endif + +#if USB_CFG_DRIVER_FLASH_PAGE +# define USB_READ_FLASH(addr) pgm_read_byte_far(((long)USB_CFG_DRIVER_FLASH_PAGE << 16) | (long)(addr)) +#else +# define USB_READ_FLASH(addr) pgm_read_byte(addr) +#endif + +#define macro .macro +#define endm .endm +#define nop2 rjmp .+0 /* jump to next instruction */ + +#endif /* development environment */ + +/* for conveniecne, ensure that PRG_RDB exists */ +#ifndef PRG_RDB +# define PRG_RDB(addr) USB_READ_FLASH(addr) +#endif +#endif /* __usbportability_h_INCLUDED__ */ From 35cf5ba2e9876cba1d76e8e41d5b71acbcb9daa2 Mon Sep 17 00:00:00 2001 From: Kai Lauterbach Date: Sat, 15 Oct 2011 11:32:43 +0200 Subject: [PATCH 04/38] Old animation cycle removed. Prepared to support V-USB. --- firmware/main.c | 388 +++++++++++++++++--------------------------- firmware/main.h | 122 ++++++++++++++ firmware/requests.h | 32 ++++ 3 files changed, 303 insertions(+), 239 deletions(-) create mode 100644 firmware/main.h create mode 100644 firmware/requests.h diff --git a/firmware/main.c b/firmware/main.c index 2d0cd39..8c20017 100644 --- a/firmware/main.c +++ b/firmware/main.c @@ -1,280 +1,190 @@ -// Mini-LED-Cube 1.0 -// -// Copyright (C) 2009 Paul Wilhelm -// http://mosfetkiller.de/?s=miniledcube +/* + * Based on the code of the Mini-LED-Cube 1.0 + * + * Copyright (C) 2009 Paul Wilhelm + * http: *mosfetkiller.de/?s=miniledcube + * + * Changed by Kai Lauterbach (klaute at web dot de) + */ -// Interner RC-Oszillator, CKDIV8 Disabled -#define F_CPU 8000000UL +#include "main.h" -// Includes -#include -#include -#include -#include - -// Bitpopelei -#define set_bit(var, bit) ((var) |= (1 << (bit))) -#define clear_bit(var, bit) ((var) &= (unsigned)~(1 << (bit))) - -// Bool -#define FALSE 0 -#define TRUE 1 - -// Definitionen -#define PIXEL_TON 30 -#define PIXEL_TOFF 10 - -// Cube-Array -unsigned char cube[3][3][3]; -unsigned char buffer[3][3][3]; // Framebuffer - -// Prototypen -void init(); - -// Programmzähler -unsigned int program_counter = 0; - -// Framezähler -volatile unsigned char frame_counter = 0, fps = 0; - - -// Pixelmakros -#define PSET(x,y,z) (0b01000000 | ((z * 3 + x) + y * 9)) -#define PCLEAR(x,y,z) (0b00000000 | ((z * 3 + x) + y * 9)) - -// Instructions -#define CLEAR 0b10000000 -#define SET 0b10010000 -#define FPS 0b10110000 -#define NEXT 0b11110000 - -// Variablen -#define VAR_FPS 0 - -// Für CLEAR und SET -#define CLEAR_ALL 0 -#define SET_ALL 0 - -// Für NEXT -#define JUMP_FORWARD 1 -#define JUMP_BACKWARD 2 - - -// Programmcode -const prog_char program_1[] = -{ - FPS, 10, - - CLEAR, SET + 12, NEXT, CLEAR, SET + 14, NEXT, // Vor- und zurück tanzen - CLEAR, SET + 12, NEXT, CLEAR, SET + 14, NEXT, - CLEAR, SET + 12, NEXT, CLEAR, SET + 15, NEXT, - CLEAR, SET + 12, NEXT, CLEAR, SET + 15, - - FPS, 5, CLEAR, SET + 8, NEXT, CLEAR, SET + 14, NEXT, // Umdrehung - FPS, 5, CLEAR, SET + 2, NEXT, CLEAR, SET + 15, NEXT, - FPS, 6, CLEAR, SET + 8, NEXT, CLEAR, SET + 14, NEXT, - FPS, 6, CLEAR, SET + 2, NEXT, CLEAR, SET + 15, NEXT, - FPS, 7, CLEAR, SET + 8, NEXT, CLEAR, SET + 14, NEXT, - FPS, 7, CLEAR, SET + 2, NEXT, CLEAR, SET + 15, NEXT, - FPS, 8, CLEAR, SET + 8, NEXT, CLEAR, SET + 14, NEXT, - FPS, 8, CLEAR, SET + 2, NEXT, CLEAR, SET + 15, NEXT, - FPS, 9, CLEAR, SET + 8, NEXT, CLEAR, SET + 14, NEXT, - FPS, 9, CLEAR, SET + 2, NEXT, CLEAR, SET + 15, NEXT, - FPS, 10, CLEAR, SET + 8, NEXT, CLEAR, SET + 14, NEXT, - FPS, 10, CLEAR, SET + 2, NEXT, CLEAR, SET + 15, NEXT, - CLEAR, SET + 8, NEXT, CLEAR, SET + 12, NEXT, // Umfallen - CLEAR, SET + 4, NEXT, CLEAR, SET + 5, NEXT, CLEAR, SET + 6, NEXT, // Ebenen - CLEAR, SET + 1, NEXT, CLEAR, SET + 2, NEXT, CLEAR, SET + 3, NEXT, - CLEAR, SET + 7, NEXT, CLEAR, SET + 8, NEXT, CLEAR, SET + 9, NEXT, - - FPS, 10, // Außen langlaufen - - CLEAR, - PSET(0,0,0), PSET(1,0,0), PSET(0,1,0), PSET(1,1,0), PSET(0,2,0), PSET(1,2,0), NEXT, - PCLEAR(0,0,0), PSET(2,0,0), PCLEAR(0,1,0), PSET(2,1,0), PCLEAR(0,2,0), PSET(2,2,0), NEXT, - PCLEAR(1,0,0), PSET(2,0,1), PCLEAR(1,1,0), PSET(2,1,1), PCLEAR(1,2,0), PSET(2,2,1), NEXT, - PCLEAR(2,0,0), PSET(2,0,2), PCLEAR(2,1,0), PSET(2,1,2), PCLEAR(2,2,0), PSET(2,2,2), NEXT, - PCLEAR(2,0,1), PSET(1,0,2), PCLEAR(2,1,1), PSET(1,1,2), PCLEAR(2,2,1), PSET(1,2,2), NEXT, - PCLEAR(2,0,2), PSET(0,0,2), PCLEAR(2,1,2), PSET(0,1,2), PCLEAR(2,2,2), PSET(0,2,2), NEXT, - PCLEAR(1,0,2), PSET(0,0,1), PCLEAR(1,1,2), PSET(0,1,1), PCLEAR(1,2,2), PSET(0,2,1), NEXT, - PCLEAR(0,0,2), PSET(0,0,0), PCLEAR(0,1,2), PSET(0,1,0), PCLEAR(0,2,2), PSET(0,2,0), NEXT, - PCLEAR(0,0,1), PCLEAR(0,1,1), PCLEAR(0,2,1), - - SET + 7, NEXT, CLEAR, SET + 8, NEXT, CLEAR, SET + 9, NEXT, - CLEAR, SET + 8, NEXT, CLEAR, SET + 7, NEXT, -}; - -const prog_char *program_pointer = program_1; -unsigned int program_length = sizeof(program_1); - - -// Main +// Main int main(void) { - // Initialisierung - init(); + // Initialisierung + init(); + init_usb(); - // Hauptschleife - while (1) - { - unsigned char instruction = pgm_read_byte(&(program_pointer[program_counter])); + // Hauptschleife + while (1) + { + //wdt_reset(); // we are alive, so don't reset the µC + usbPoll(); // keep connected - if ((instruction & 0b10000000) == 0) - // Pixel - { - unsigned char coord = instruction & 0b00111111; // Uns interessieren nur die 6 untersten Bits + /* + unsigned char instruction = pgm_read_byte(&(program_pointer[program_counter])); - unsigned char y = coord / 9; - unsigned char x = (coord - y * 9) % 3; - unsigned char z = (coord - y * 9) / 3; - buffer[x][y][z] = (instruction & 0b01000000) / 0b01000000; - } - else - // Instruction - { - unsigned char operation = instruction & 0b11110000; // Uns interessieren nur die 4 obersten Bits + if ((instruction & 0b10000000) == 0) + // Pixel + { + unsigned char coord = instruction & 0b00111111; // Uns interessieren nur die 6 untersten Bits - if (operation == CLEAR || operation == SET) - { - unsigned char frame = instruction & 0b00001111; + unsigned char y = coord / 9; + unsigned char x = (coord - y * 9) % 3; + unsigned char z = (coord - y * 9) / 3; + buffer[x][y][z] = (instruction & 0b01000000) / 0b01000000; + } + else + // Instruction + { + unsigned char operation = instruction & 0b11110000; // Uns interessieren nur die 4 obersten Bits - // Folgende Werte entsprechen SET_ALL - unsigned char x_min = 0, x_max = 3, y_min = 0, y_max = 3, z_min = 0, z_max = 3; + if (operation == CLEAR || operation == SET) + { + unsigned char frame = instruction & 0b00001111; - // Folgendes kann noch optimiert werden. + // Folgende Werte entsprechen SET_ALL + unsigned char x_min = 0, x_max = 3, y_min = 0, y_max = 3, z_min = 0, z_max = 3; - // Y-Z-Ebene (links, mitte, rechts) - if (frame == 1) { x_min = 0; x_max = 1; } - if (frame == 2) { x_min = 1; x_max = 2; } - if (frame == 3) { x_min = 2; x_max = 3; } + // Folgendes kann noch optimiert werden. - // X-Z-Ebene (unten, mitte, oben) - if (frame == 4) { y_min = 0; y_max = 1; } - if (frame == 5) { y_min = 1; y_max = 2; } - if (frame == 6) { y_min = 2; y_max = 3; } + // Y-Z-Ebene (links, mitte, rechts) + if (frame == 1) { x_min = 0; x_max = 1; } + if (frame == 2) { x_min = 1; x_max = 2; } + if (frame == 3) { x_min = 2; x_max = 3; } - // X-Y-Ebene (hinten, mitte, vorne) - if (frame == 7) { z_min = 0; z_max = 1; } - if (frame == 8) { z_min = 1; z_max = 2; } - if (frame == 9) { z_min = 2; z_max = 3; } + // X-Z-Ebene (unten, mitte, oben) + if (frame == 4) { y_min = 0; y_max = 1; } + if (frame == 5) { y_min = 1; y_max = 2; } + if (frame == 6) { y_min = 2; y_max = 3; } - if (frame < 10) - { - for (unsigned char z = z_min; z < z_max; z++) - for (unsigned char y = y_min; y < y_max; y++) - for (unsigned char x = x_min; x < x_max; x++) - if (operation == SET) buffer[x][y][z] = 1; else buffer[x][y][z] = 0; - } else - { - for (unsigned char a = 0; a < 3; a++) - for (unsigned char b = 0; b < 3; b++) - { - unsigned char x = 0, y = 0, z = 0; + // X-Y-Ebene (hinten, mitte, vorne) + if (frame == 7) { z_min = 0; z_max = 1; } + if (frame == 8) { z_min = 1; z_max = 2; } + if (frame == 9) { z_min = 2; z_max = 3; } - if (frame == 10) { x = a; y = b; z = b; } // Unten hinten nach oben vorne - if (frame == 11) { x = a; y = a; z = b; } // Unten links nach oben rechts - if (frame == 12) { x = a; y = b; z = 2 - b; } // Unten vorne nach oben hinten - if (frame == 13) { x = a; y = 2 - a; z = b; } // Oben links nach unten rechts - if (frame == 14) { x = b; y = a; z = b; } // Hinten links nach vorne rechts - if (frame == 15) { x = a; y = 2 - b; z = 2 - a; } // Vorne links nach hinten rechts + if (frame < 10) + { + for (unsigned char z = z_min; z < z_max; z++) + for (unsigned char y = y_min; y < y_max; y++) + for (unsigned char x = x_min; x < x_max; x++) + if (operation == SET) buffer[x][y][z] = 1; else buffer[x][y][z] = 0; + } else + { + for (unsigned char a = 0; a < 3; a++) + for (unsigned char b = 0; b < 3; b++) + { + unsigned char x = 0, y = 0, z = 0; - if (operation == SET) buffer[x][y][z] = 1; else buffer[x][y][z] = 0; - } - } - } else + if (frame == 10) { x = a; y = b; z = b; } // Unten hinten nach oben vorne + if (frame == 11) { x = a; y = a; z = b; } // Unten links nach oben rechts + if (frame == 12) { x = a; y = b; z = 2 - b; } // Unten vorne nach oben hinten + if (frame == 13) { x = a; y = 2 - a; z = b; } // Oben links nach unten rechts + if (frame == 14) { x = b; y = a; z = b; } // Hinten links nach vorne rechts + if (frame == 15) { x = a; y = 2 - b; z = 2 - a; } // Vorne links nach hinten rechts - if (operation == FPS) - { - if (program_counter + 1 < program_length) program_counter++; // else: Fehler - unsigned char byte = pgm_read_byte(&(program_pointer[program_counter])); + if (operation == SET) buffer[x][y][z] = 1; else buffer[x][y][z] = 0; + } + } + } else - fps = byte; - } else + if (operation == FPS) + { + if (program_counter + 1 < program_length) program_counter++; // else: Fehler + unsigned char byte = pgm_read_byte(&(program_pointer[program_counter])); - if (operation == NEXT) - { - // VAR_FPS = 0: Frame nicht zeichnen, keine Wartezeit - if (fps > 0) - { - // Temporäres Array ins "echte" Array kopieren - for (unsigned char z = 0; z < 3; z++) - for (unsigned char y = 0; y < 3; y++) - for (unsigned char x = 0; x < 3; x++) - cube[x][y][z] = buffer[x][y][z]; + fps = byte; + } else - for (unsigned char i = 0; i < fps; i++) - { - _delay_ms(5); - } - } - } + if (operation == NEXT) + { + // VAR_FPS = 0: Frame nicht zeichnen, keine Wartezeit + if (fps > 0) + { + // Temporäres Array ins "echte" Array kopieren + for (unsigned char z = 0; z < 3; z++) + for (unsigned char y = 0; y < 3; y++) + for (unsigned char x = 0; x < 3; x++) + cube[x][y][z] = buffer[x][y][z]; - } + for (unsigned char i = 0; i < fps; i++) + { + _delay_ms(5); + } + } + } - // Programmzähler erhöhen, bzw. bei Erreichen des Programmendes wieder von vorn beginnen - if (program_counter + 1 < program_length) program_counter++; else program_counter = 0; - } + } + + // Programmzähler erhöhen, bzw. bei Erreichen des Programmendes wieder von vorn beginnen + if (program_counter + 1 < program_length) program_counter++; else program_counter = 0; + */ + + } } -// Initialisierung +// Initialisierung void init() { - // Ports vorbereiten - DDRB = 0b11111111; // PB0-PB7: LED 1-8 (Kathoden) - PORTB = 0b11111111; // HIGH + // Ports vorbereiten + DDRB = 0b11111111; // PB0-PB7: LED 1-8 (Kathoden) + PORTB = 0b11111111; // HIGH - DDRD = 0b1111000; // PD6: LED 9 (Kathode); PD5-PD3: A-C (Anoden) - PORTD = 0b1000000; + DDRD = 0b1111000; // PD6: LED 9 (Kathode); PD5-PD3: A-C (Anoden) + PORTD = 0b1000000; - // Timer-Interrupt "TIMER1" vorbereiten - cli(); + // Timer-Interrupt "TIMER1" vorbereiten + cli(); - set_bit(TIMSK, OCIE1A); - set_bit(TCCR1B, WGM12); + set_bit(TIMSK, OCIE1A); + set_bit(TCCR1B, WGM12); - // Animations-Geschwindigkeit - OCR1AH = 0x01; - OCR1AL = 0x00; + // Animations-Geschwindigkeit + OCR1AH = 0x01; + OCR1AL = 0x00; - clear_bit(TCCR1B, CS12); // Prescaler 64 - set_bit(TCCR1B, CS11); - set_bit(TCCR1B, CS10); + clear_bit(TCCR1B, CS12); // Prescaler 64 + set_bit(TCCR1B, CS11); + set_bit(TCCR1B, CS10); - sei(); + sei(); } -// Interruptvektor von TIMER1 +// Interruptvektor von TIMER1 SIGNAL(SIG_OUTPUT_COMPARE1A) { - // Pixel multiplexen - for (unsigned char z = 0; z < 3; z++) - { - for (unsigned char y = 0; y < 3; y++) - { - for (unsigned char x = 0; x < 3; x++) - { - unsigned char n = z * 3 + x; + // Pixel multiplexen +/**/ + for (unsigned char z = 0; z < 3; z++) + { + for (unsigned char y = 0; y < 3; y++) + { + for (unsigned char x = 0; x < 3; x++) + { + unsigned char n = z * 3 + x; - // LED an - if (cube[x][y][z] == 1) - { - if (n < 8) clear_bit(PORTB, n); else clear_bit(PORTD, 6); - set_bit(PORTD, y + 3); - } - // ON-Time - for (unsigned long i = 0; i < PIXEL_TON; i++) { asm volatile("nop"::); } + // LED an + if (cube[x][y][z] == 1) + { + if (n < 8) clear_bit(PORTB, n); else clear_bit(PORTD, 6); + set_bit(PORTD, y + 3); + } + // ON-Time + for (unsigned long i = 0; i < PIXEL_TON; i++) { asm volatile("nop"::); } - // LED aus - if (cube[x][y][z] == 1) - { - clear_bit(PORTD, y + 3); - if (n < 8) set_bit(PORTB, n); else set_bit(PORTD, 6); - } - // OFF-Time - for (unsigned long i = 0; i < PIXEL_TOFF; i++) { asm volatile("nop"::); } - } - } - } + // LED aus + if (cube[x][y][z] == 1) + { + clear_bit(PORTD, y + 3); + if (n < 8) set_bit(PORTB, n); else set_bit(PORTD, 6); + } + // OFF-Time + for (unsigned long i = 0; i < PIXEL_TOFF; i++) { asm volatile("nop"::); } + } + } + } +/**/ } diff --git a/firmware/main.h b/firmware/main.h new file mode 100644 index 0000000..50b4408 --- /dev/null +++ b/firmware/main.h @@ -0,0 +1,122 @@ +// Mini-LED-Cube 1.0 +// +// Copyright (C) 2009 Paul Wilhelm +// http://mosfetkiller.de/?s=miniledcube +// +// Changed by Kai Lauterbach (klaute at web dot de) + +// Interner RC-Oszillator, CKDIV8 Disabled + +#ifndef __main_h__ +#define __main_h__ + +#define F_CPU 12000000UL + +// Includes +#include +#include +#include +#include +//#include + +// Bitpopelei +#define set_bit(var, bit) ((var) |= (1 << (bit))) +#define clear_bit(var, bit) ((var) &= (unsigned)~(1 << (bit))) + +// Bool +#define FALSE 0 +#define TRUE 1 + +// Definitionen +#define PIXEL_TON 30 +#define PIXEL_TOFF 10 + +// Cube-Array +unsigned char cube[3][3][3]; +unsigned char buffer[3][3][3]; // Framebuffer + +// Prototypen +void init(void); + +extern void init_usb(void); +extern void usbPoll(void); + +/* +// Programmzähler +unsigned int program_counter = 0; + +// Framezähler +volatile unsigned char frame_counter = 0, fps = 0; + + +// Pixelmakros +#define PSET(x,y,z) (0b01000000 | ((z * 3 + x) + y * 9)) +#define PCLEAR(x,y,z) (0b00000000 | ((z * 3 + x) + y * 9)) + +// Instructions +#define CLEAR 0b10000000 +#define SET 0b10010000 +#define FPS 0b10110000 +#define NEXT 0b11110000 + +// Variablen +#define VAR_FPS 0 + +// Für CLEAR und SET +#define CLEAR_ALL 0 +#define SET_ALL 0 + +// Für NEXT +#define JUMP_FORWARD 1 +#define JUMP_BACKWARD 2 + + +// Animation in pgmspace +const prog_char program_1[] = +{ + FPS, 10, + + CLEAR, SET + 12, NEXT, CLEAR, SET + 14, NEXT, // Vor- und zurück tanzen + CLEAR, SET + 12, NEXT, CLEAR, SET + 14, NEXT, + CLEAR, SET + 12, NEXT, CLEAR, SET + 15, NEXT, + CLEAR, SET + 12, NEXT, CLEAR, SET + 15, + + FPS, 5, CLEAR, SET + 8, NEXT, CLEAR, SET + 14, NEXT, // Umdrehung + FPS, 5, CLEAR, SET + 2, NEXT, CLEAR, SET + 15, NEXT, + FPS, 6, CLEAR, SET + 8, NEXT, CLEAR, SET + 14, NEXT, + FPS, 6, CLEAR, SET + 2, NEXT, CLEAR, SET + 15, NEXT, + FPS, 7, CLEAR, SET + 8, NEXT, CLEAR, SET + 14, NEXT, + FPS, 7, CLEAR, SET + 2, NEXT, CLEAR, SET + 15, NEXT, + FPS, 8, CLEAR, SET + 8, NEXT, CLEAR, SET + 14, NEXT, + FPS, 8, CLEAR, SET + 2, NEXT, CLEAR, SET + 15, NEXT, + FPS, 9, CLEAR, SET + 8, NEXT, CLEAR, SET + 14, NEXT, + FPS, 9, CLEAR, SET + 2, NEXT, CLEAR, SET + 15, NEXT, + FPS, 10, CLEAR, SET + 8, NEXT, CLEAR, SET + 14, NEXT, + FPS, 10, CLEAR, SET + 2, NEXT, CLEAR, SET + 15, NEXT, + CLEAR, SET + 8, NEXT, CLEAR, SET + 12, NEXT, // Umfallen + CLEAR, SET + 4, NEXT, CLEAR, SET + 5, NEXT, CLEAR, SET + 6, NEXT, // Ebenen + CLEAR, SET + 1, NEXT, CLEAR, SET + 2, NEXT, CLEAR, SET + 3, NEXT, + CLEAR, SET + 7, NEXT, CLEAR, SET + 8, NEXT, CLEAR, SET + 9, NEXT, + + FPS, 10, // Außen langlaufen + + CLEAR, + PSET(0,0,0), PSET(1,0,0), PSET(0,1,0), PSET(1,1,0), PSET(0,2,0), PSET(1,2,0), NEXT, + PCLEAR(0,0,0), PSET(2,0,0), PCLEAR(0,1,0), PSET(2,1,0), PCLEAR(0,2,0), PSET(2,2,0), NEXT, + PCLEAR(1,0,0), PSET(2,0,1), PCLEAR(1,1,0), PSET(2,1,1), PCLEAR(1,2,0), PSET(2,2,1), NEXT, + PCLEAR(2,0,0), PSET(2,0,2), PCLEAR(2,1,0), PSET(2,1,2), PCLEAR(2,2,0), PSET(2,2,2), NEXT, + PCLEAR(2,0,1), PSET(1,0,2), PCLEAR(2,1,1), PSET(1,1,2), PCLEAR(2,2,1), PSET(1,2,2), NEXT, + PCLEAR(2,0,2), PSET(0,0,2), PCLEAR(2,1,2), PSET(0,1,2), PCLEAR(2,2,2), PSET(0,2,2), NEXT, + PCLEAR(1,0,2), PSET(0,0,1), PCLEAR(1,1,2), PSET(0,1,1), PCLEAR(1,2,2), PSET(0,2,1), NEXT, + PCLEAR(0,0,2), PSET(0,0,0), PCLEAR(0,1,2), PSET(0,1,0), PCLEAR(0,2,2), PSET(0,2,0), NEXT, + PCLEAR(0,0,1), PCLEAR(0,1,1), PCLEAR(0,2,1), + + SET + 7, NEXT, CLEAR, SET + 8, NEXT, CLEAR, SET + 9, NEXT, + CLEAR, SET + 8, NEXT, CLEAR, SET + 7, NEXT, +}; + +const prog_char *program_pointer = program_1; +unsigned int program_length = sizeof(program_1); +*/ +#endif // __main_h__ + diff --git a/firmware/requests.h b/firmware/requests.h new file mode 100644 index 0000000..79282b6 --- /dev/null +++ b/firmware/requests.h @@ -0,0 +1,32 @@ +/* Name: requests.h + * Project: custom-class, a basic USB example + * Author: Christian Starkjohann + * Creation Date: 2008-04-09 + * Tabsize: 4 + * Copyright: (c) 2008 by OBJECTIVE DEVELOPMENT Software GmbH + * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) + * This Revision: $Id: requests.h 692 2008-11-07 15:07:40Z cs $ + */ + +/* This header is shared between the firmware and the host software. It + * defines the USB request numbers (and optionally data types) used to + * communicate between the host and the device. + */ + +#ifndef __REQUESTS_H_INCLUDED__ +#define __REQUESTS_H_INCLUDED__ + +#define CUSTOM_RQ_SET_STATUS 1 +/* Set the LED status. Control-OUT. + * The requested status is passed in the "wValue" field of the control + * transfer. No OUT data is sent. Bit 0 of the low byte of wValue controls + * the LED. + */ + +#define CUSTOM_RQ_GET_STATUS 2 +/* Get the current LED status. Control-IN. + * This control transfer involves a 1 byte data phase where the device sends + * the current status to the host. The status is in bit 0 of the byte. + */ + +#endif /* __REQUESTS_H_INCLUDED__ */ From 5b102adff3125f5d6afcc038be1bad359fe00bfa Mon Sep 17 00:00:00 2001 From: Kai Lauterbach Date: Sun, 16 Oct 2011 13:47:27 +0200 Subject: [PATCH 05/38] Some file extensions added which we won't to track. --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 258ee00..6f8b53e 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,7 @@ firmware/.dep *.elf *.lst *.lss +*.eep +*.map +*.sym From 1c740255d54ef15c99bf4ecf9c343fa24ee0411e Mon Sep 17 00:00:00 2001 From: Kai Lauterbach Date: Sun, 16 Oct 2011 15:02:53 +0200 Subject: [PATCH 06/38] Cleaned... --- firmware/Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/firmware/Makefile b/firmware/Makefile index 95d1425..411143a 100644 --- a/firmware/Makefile +++ b/firmware/Makefile @@ -87,7 +87,6 @@ DEBUG = # dwarf-2 # Each directory must be seperated by a space. EXTRAINCDIRS = - # Compiler flag to set the C Standard level. # c89 - "ANSI" C # gnu89 - c89 plus GCC extensions From ef1aa32741b920b34e08a7a5906689292c5761ef Mon Sep 17 00:00:00 2001 From: Kai Lauterbach Date: Sun, 16 Oct 2011 18:38:45 +0200 Subject: [PATCH 07/38] Initial commit of the VUSB custom request client. --- client/Makefile | 48 ++++++++++ client/Makefile.windows | 18 ++++ client/opendevice.c | 203 ++++++++++++++++++++++++++++++++++++++++ client/opendevice.h | 77 +++++++++++++++ client/set-led | Bin 0 -> 23439 bytes client/set-led.c | 135 ++++++++++++++++++++++++++ 6 files changed, 481 insertions(+) create mode 100644 client/Makefile create mode 100644 client/Makefile.windows create mode 100644 client/opendevice.c create mode 100644 client/opendevice.h create mode 100644 client/set-led create mode 100644 client/set-led.c diff --git a/client/Makefile b/client/Makefile new file mode 100644 index 0000000..5894ca8 --- /dev/null +++ b/client/Makefile @@ -0,0 +1,48 @@ +# Name: Makefile +# Project: hid-custom-rq example +# Author: Christian Starkjohann +# Creation Date: 2008-04-06 +# Tabsize: 4 +# Copyright: (c) 2008 by OBJECTIVE DEVELOPMENT Software GmbH +# License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) +# This Revision: $Id: Makefile 692 2008-11-07 15:07:40Z cs $ + + +# Concigure the following definitions according to your system. +# This Makefile has been tested on Mac OS X, Linux and Windows. + +# Use the following 3 lines on Unix (uncomment the framework on Mac OS X): +USBFLAGS = `libusb-config --cflags` +USBLIBS = `libusb-config --libs` +EXE_SUFFIX = + +# Use the following 3 lines on Windows and comment out the 3 above. You may +# have to change the include paths to where you installed libusb-win32 +#USBFLAGS = -I/usr/local/include +#USBLIBS = -L/usr/local/lib -lusb +#EXE_SUFFIX = .exe + +NAME = set-led + +OBJECTS = opendevice.o $(NAME).o + +CC = gcc +CFLAGS = $(CPPFLAGS) $(USBFLAGS) -O -g -Wall +LIBS = $(USBLIBS) + +PROGRAM = $(NAME)$(EXE_SUFFIX) + + +all: $(PROGRAM) + +.c.o: + $(CC) $(CFLAGS) -c $< + +$(PROGRAM): $(OBJECTS) + $(CC) -o $(PROGRAM) $(OBJECTS) $(LIBS) + +strip: $(PROGRAM) + strip $(PROGRAM) + +clean: + rm -f *.o $(PROGRAM) diff --git a/client/Makefile.windows b/client/Makefile.windows new file mode 100644 index 0000000..4ea1df6 --- /dev/null +++ b/client/Makefile.windows @@ -0,0 +1,18 @@ +# Name: Makefile.windows +# Project: hid-custom-rq example +# Author: Christian Starkjohann +# Creation Date: 2008-04-06 +# Tabsize: 4 +# Copyright: (c) 2008 by OBJECTIVE DEVELOPMENT Software GmbH +# License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) +# This Revision: $Id$ + +# You may use this file with +# make -f Makefile.windows +# on Windows with MinGW instead of editing the main Makefile. + +include Makefile + +USBFLAGS = -I/usr/local/mingw/include +USBLIBS = -L/usr/local/mingw/lib -lusb +EXE_SUFFIX = .exe diff --git a/client/opendevice.c b/client/opendevice.c new file mode 100644 index 0000000..137f50c --- /dev/null +++ b/client/opendevice.c @@ -0,0 +1,203 @@ +/* Name: opendevice.c + * Project: V-USB host-side library + * Author: Christian Starkjohann + * Creation Date: 2008-04-10 + * Tabsize: 4 + * Copyright: (c) 2008 by OBJECTIVE DEVELOPMENT Software GmbH + * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) + * This Revision: $Id: opendevice.c 740 2009-04-13 18:23:31Z cs $ + */ + +/* +General Description: +The functions in this module can be used to find and open a device based on +libusb or libusb-win32. +*/ + +#include +#include "opendevice.h" + +/* ------------------------------------------------------------------------- */ + +#define MATCH_SUCCESS 1 +#define MATCH_FAILED 0 +#define MATCH_ABORT -1 + +/* private interface: match text and p, return MATCH_SUCCESS, MATCH_FAILED, or MATCH_ABORT. */ +static int _shellStyleMatch(char *text, char *p) +{ +int last, matched, reverse; + + for(; *p; text++, p++){ + if(*text == 0 && *p != '*') + return MATCH_ABORT; + switch(*p){ + case '\\': + /* Literal match with following character. */ + p++; + /* FALLTHROUGH */ + default: + if(*text != *p) + return MATCH_FAILED; + continue; + case '?': + /* Match anything. */ + continue; + case '*': + while(*++p == '*') + /* Consecutive stars act just like one. */ + continue; + if(*p == 0) + /* Trailing star matches everything. */ + return MATCH_SUCCESS; + while(*text) + if((matched = _shellStyleMatch(text++, p)) != MATCH_FAILED) + return matched; + return MATCH_ABORT; + case '[': + reverse = p[1] == '^'; + if(reverse) /* Inverted character class. */ + p++; + matched = MATCH_FAILED; + if(p[1] == ']' || p[1] == '-') + if(*++p == *text) + matched = MATCH_SUCCESS; + for(last = *p; *++p && *p != ']'; last = *p) + if (*p == '-' && p[1] != ']' ? *text <= *++p && *text >= last : *text == *p) + matched = MATCH_SUCCESS; + if(matched == reverse) + return MATCH_FAILED; + continue; + } + } + return *text == 0; +} + +/* public interface for shell style matching: returns 0 if fails, 1 if matches */ +static int shellStyleMatch(char *text, char *pattern) +{ + if(pattern == NULL) /* NULL pattern is synonymous to "*" */ + return 1; + return _shellStyleMatch(text, pattern) == MATCH_SUCCESS; +} + +/* ------------------------------------------------------------------------- */ + +int usbGetStringAscii(usb_dev_handle *dev, int index, char *buf, int buflen) +{ +char buffer[256]; +int rval, i; + + if((rval = usb_get_string_simple(dev, index, buf, buflen)) >= 0) /* use libusb version if it works */ + return rval; + if((rval = usb_control_msg(dev, USB_ENDPOINT_IN, USB_REQ_GET_DESCRIPTOR, (USB_DT_STRING << 8) + index, 0x0409, buffer, sizeof(buffer), 5000)) < 0) + return rval; + if(buffer[1] != USB_DT_STRING){ + *buf = 0; + return 0; + } + if((unsigned char)buffer[0] < rval) + rval = (unsigned char)buffer[0]; + rval /= 2; + /* lossy conversion to ISO Latin1: */ + for(i=1;i buflen) /* destination buffer overflow */ + break; + buf[i-1] = buffer[2 * i]; + if(buffer[2 * i + 1] != 0) /* outside of ISO Latin1 range */ + buf[i-1] = '?'; + } + buf[i-1] = 0; + return i-1; +} + +/* ------------------------------------------------------------------------- */ + +int usbOpenDevice(usb_dev_handle **device, int vendorID, char *vendorNamePattern, int productID, char *productNamePattern, char *serialNamePattern, FILE *printMatchingDevicesFp, FILE *warningsFp) +{ +struct usb_bus *bus; +struct usb_device *dev; +usb_dev_handle *handle = NULL; +int errorCode = USBOPEN_ERR_NOTFOUND; + + usb_find_busses(); + usb_find_devices(); + for(bus = usb_get_busses(); bus; bus = bus->next){ + for(dev = bus->devices; dev; dev = dev->next){ /* iterate over all devices on all busses */ + if((vendorID == 0 || dev->descriptor.idVendor == vendorID) + && (productID == 0 || dev->descriptor.idProduct == productID)){ + char vendor[256], product[256], serial[256]; + int len; + handle = usb_open(dev); /* we need to open the device in order to query strings */ + if(!handle){ + errorCode = USBOPEN_ERR_ACCESS; + if(warningsFp != NULL) + fprintf(warningsFp, "Warning: cannot open VID=0x%04x PID=0x%04x: %s\n", dev->descriptor.idVendor, dev->descriptor.idProduct, usb_strerror()); + continue; + } + /* now check whether the names match: */ + len = vendor[0] = 0; + if(dev->descriptor.iManufacturer > 0){ + len = usbGetStringAscii(handle, dev->descriptor.iManufacturer, vendor, sizeof(vendor)); + } + if(len < 0){ + errorCode = USBOPEN_ERR_ACCESS; + if(warningsFp != NULL) + fprintf(warningsFp, "Warning: cannot query manufacturer for VID=0x%04x PID=0x%04x: %s\n", dev->descriptor.idVendor, dev->descriptor.idProduct, usb_strerror()); + }else{ + errorCode = USBOPEN_ERR_NOTFOUND; + /* printf("seen device from vendor ->%s<-\n", vendor); */ + if(shellStyleMatch(vendor, vendorNamePattern)){ + len = product[0] = 0; + if(dev->descriptor.iProduct > 0){ + len = usbGetStringAscii(handle, dev->descriptor.iProduct, product, sizeof(product)); + } + if(len < 0){ + errorCode = USBOPEN_ERR_ACCESS; + if(warningsFp != NULL) + fprintf(warningsFp, "Warning: cannot query product for VID=0x%04x PID=0x%04x: %s\n", dev->descriptor.idVendor, dev->descriptor.idProduct, usb_strerror()); + }else{ + errorCode = USBOPEN_ERR_NOTFOUND; + /* printf("seen product ->%s<-\n", product); */ + if(shellStyleMatch(product, productNamePattern)){ + len = serial[0] = 0; + if(dev->descriptor.iSerialNumber > 0){ + len = usbGetStringAscii(handle, dev->descriptor.iSerialNumber, serial, sizeof(serial)); + } + if(len < 0){ + errorCode = USBOPEN_ERR_ACCESS; + if(warningsFp != NULL) + fprintf(warningsFp, "Warning: cannot query serial for VID=0x%04x PID=0x%04x: %s\n", dev->descriptor.idVendor, dev->descriptor.idProduct, usb_strerror()); + } + if(shellStyleMatch(serial, serialNamePattern)){ + if(printMatchingDevicesFp != NULL){ + if(serial[0] == 0){ + fprintf(printMatchingDevicesFp, "VID=0x%04x PID=0x%04x vendor=\"%s\" product=\"%s\"\n", dev->descriptor.idVendor, dev->descriptor.idProduct, vendor, product); + }else{ + fprintf(printMatchingDevicesFp, "VID=0x%04x PID=0x%04x vendor=\"%s\" product=\"%s\" serial=\"%s\"\n", dev->descriptor.idVendor, dev->descriptor.idProduct, vendor, product, serial); + } + }else{ + break; + } + } + } + } + } + } + usb_close(handle); + handle = NULL; + } + } + if(handle) /* we have found a deice */ + break; + } + if(handle != NULL){ + errorCode = 0; + *device = handle; + } + if(printMatchingDevicesFp != NULL) /* never return an error for listing only */ + errorCode = 0; + return errorCode; +} + +/* ------------------------------------------------------------------------- */ diff --git a/client/opendevice.h b/client/opendevice.h new file mode 100644 index 0000000..79c12f6 --- /dev/null +++ b/client/opendevice.h @@ -0,0 +1,77 @@ +/* Name: opendevice.h + * Project: V-USB host-side library + * Author: Christian Starkjohann + * Creation Date: 2008-04-10 + * Tabsize: 4 + * Copyright: (c) 2008 by OBJECTIVE DEVELOPMENT Software GmbH + * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) + * This Revision: $Id: opendevice.h 755 2009-08-03 17:01:21Z cs $ + */ + +/* +General Description: +This module offers additional functionality for host side drivers based on +libusb or libusb-win32. It includes a function to find and open a device +based on numeric IDs and textual description. It also includes a function to +obtain textual descriptions from a device. + +To use this functionality, simply copy opendevice.c and opendevice.h into your +project and add them to your Makefile. You may modify and redistribute these +files according to the GNU General Public License (GPL) version 2 or 3. +*/ + +#ifndef __OPENDEVICE_H_INCLUDED__ +#define __OPENDEVICE_H_INCLUDED__ + +#include /* this is libusb, see http://libusb.sourceforge.net/ */ +#include + +int usbGetStringAscii(usb_dev_handle *dev, int index, char *buf, int buflen); +/* This function gets a string descriptor from the device. 'index' is the + * string descriptor index. The string is returned in ISO Latin 1 encoding in + * 'buf' and it is terminated with a 0-character. The buffer size must be + * passed in 'buflen' to prevent buffer overflows. A libusb device handle + * must be given in 'dev'. + * Returns: The length of the string (excluding the terminating 0) or + * a negative number in case of an error. If there was an error, use + * usb_strerror() to obtain the error message. + */ + +int usbOpenDevice(usb_dev_handle **device, int vendorID, char *vendorNamePattern, int productID, char *productNamePattern, char *serialNamePattern, FILE *printMatchingDevicesFp, FILE *warningsFp); +/* This function iterates over all devices on all USB busses and searches for + * a device. Matching is done first by means of Vendor- and Product-ID (passed + * in 'vendorID' and 'productID'. An ID of 0 matches any numeric ID (wildcard). + * When a device matches by its IDs, matching by names is performed. Name + * matching can be done on textual vendor name ('vendorNamePattern'), product + * name ('productNamePattern') and serial number ('serialNamePattern'). A + * device matches only if all non-null pattern match. If you don't care about + * a string, pass NULL for the pattern. Patterns are Unix shell style pattern: + * '*' stands for 0 or more characters, '?' for one single character, a list + * of characters in square brackets for a single character from the list + * (dashes are allowed to specify a range) and if the lis of characters begins + * with a caret ('^'), it matches one character which is NOT in the list. + * Other parameters to the function: If 'warningsFp' is not NULL, warning + * messages are printed to this file descriptor with fprintf(). If + * 'printMatchingDevicesFp' is not NULL, no device is opened but matching + * devices are printed to the given file descriptor with fprintf(). + * If a device is opened, the resulting USB handle is stored in '*device'. A + * pointer to a "usb_dev_handle *" type variable must be passed here. + * Returns: 0 on success, an error code (see defines below) on failure. + */ + +/* usbOpenDevice() error codes: */ +#define USBOPEN_SUCCESS 0 /* no error */ +#define USBOPEN_ERR_ACCESS 1 /* not enough permissions to open device */ +#define USBOPEN_ERR_IO 2 /* I/O error */ +#define USBOPEN_ERR_NOTFOUND 3 /* device not found */ + + +/* Obdev's free USB IDs, see USB-IDs-for-free.txt for details */ + +#define USB_VID_OBDEV_SHARED 5824 /* obdev's shared vendor ID */ +#define USB_PID_OBDEV_SHARED_CUSTOM 1500 /* shared PID for custom class devices */ +#define USB_PID_OBDEV_SHARED_HID 1503 /* shared PID for HIDs except mice & keyboards */ +#define USB_PID_OBDEV_SHARED_CDCACM 1505 /* shared PID for CDC Modem devices */ +#define USB_PID_OBDEV_SHARED_MIDI 1508 /* shared PID for MIDI class devices */ + +#endif /* __OPENDEVICE_H_INCLUDED__ */ diff --git a/client/set-led b/client/set-led new file mode 100644 index 0000000000000000000000000000000000000000..ec840111837e87ed0c9b1f4d57fbaac2e64d6f43 GIT binary patch literal 23439 zcmeHveRx#Wwf8JeEk`3?Xt_+IcBkAP+*pJg!4gZw;{%~%VXQS+{O-D(B-iJk;J<4c(iam^~`uDRdV!8 z%S(Q;{q3PAfBn`_u=|CTS=4ag?+u`bWzk;Xj5>IMyrc<0=AScwE}=8*K>ov;03;n6 zKrbCYuNy!+2k1Lz0DXLb{MG^Vr32_!2hjHpplhIi`J?EA2nFKpzH-p@S@c1q@4ee) zvh9YU6^GhP~(+7gb&6($R54Xh2dpcL5MLW`#h z-~6j#ZfhvwOT+`Ms6Z!FSZ%(R;0+?M4tDrho0c1x;A``T!boV#l0lIz{&=9Jqf-3^NpkLU|mubHQX&8mc@g0tA&LpnQ%VS-*-JP?h%!Qt5EBS< zF&`7cvPwd9sVYKDFf#~YXf+`Q_AEjS!ezZOg>Z$4;F6e4x^M}2*L-7i@= zy;mT$_a`v3w-Gv*U;o^}zG-JrlfLmE;h%Z>#Z4WwsDnjQ)+CtWFNdMdbvv{%yfSdbMuQ6Oo0F4#$0NSYoDa%wtp>SH8~rzeA( zNFM_|`OVeIKXx5I)zG*k*nqJeJaw1LyrwDmx39R&-Z79ry`x{S{lDq*2B;BWnJR0j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Bjrm6Pbr+ z!Fle4_Go>qgNfLMsO5Ned^rSo`$9Qx>u5R7ue6or@a+0A2vh>sfpQF-ZnRth&UkbG z&#Nm59_1MC%95+ZGfwW2u4I9BpsftN@@aiME58k$phR-ipDy=aTaJEt7;+Coj@#Ti zXt{@wKz(GL#-->q4%KTOWi|dNaLTdm4y5jzb)%CX&^N7Uu=yHTgkqK`UX%#!0f1E(R^fHWN_!}te8 zt*;he8L0K1y}rjF$MR_(zeZ5+Rs95{47wh#gQC7ll`JTizG<_0x^R>}@qj^85EI9X3l z!-0~s$W0v}H*2Q4o7MWXUuM~I+AkX}#Y%+@ZU>gdxNv~Jr)LSVgA%Q*<7IeAh?OT<)uR zO40d}=6s}R)nPgBD4MN;-RCqtT+*CJh&b&lqkbpHDc=Y}d!+f88p>e^i=B#3}fsD-)aolTuc23U3xg z`LP4&aRcbmbiX9Sh3_!31+@PRyd6c0wf_u!NpS*b?LPzl!>|@>?DleqJh2e8{8}2I zA&SLyfc&N!dlu;+U{98Oc0XqM7Wf6Wzghlf(7JsMT#3H|I=lRDf?k8`768Uoo_LIi z9jK4j54{&i{tKY>ejn*qwJ;#%PXOvYIP%{Dt=r!~`{%%5?H@cU5!@Hdrg?T*_a_7W zX$olFU%coqmxJcF>o~H8LqFd!(t*8`-!#yfX@Cd=Ai-n>^YF~?}EQKOP>Q%h^|io>XV-}nNi+5fUW?|>z%TvSk!=?XOEv@ zj&sH00rJ-lpxZ(7i+!xaFvoCtE6&gUv0u?YTL#GU(^xvt9zMBa`Ap+?M)|x?2lDx7 zQ3uk00lhp+{w>gYPnYHKkX*Jt7p73XKTQ6JtT~$cc(P9i(tP7-ncZK9JMzR_(0V_Y z`4@uL^CQ1wdd-0Rq9taSv8lR-u?fpmE&Ik literal 0 HcmV?d00001 diff --git a/client/set-led.c b/client/set-led.c new file mode 100644 index 0000000..52b2a3b --- /dev/null +++ b/client/set-led.c @@ -0,0 +1,135 @@ +/* Name: set-led.c + * Project: hid-custom-rq example + * Author: Christian Starkjohann + * Creation Date: 2008-04-10 + * Tabsize: 4 + * Copyright: (c) 2008 by OBJECTIVE DEVELOPMENT Software GmbH + * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) + * This Revision: $Id: set-led.c 692 2008-11-07 15:07:40Z cs $ + */ + +/* +General Description: +This is the host-side driver for the custom-class example device. It searches +the USB for the LEDControl device and sends the requests understood by this +device. +This program must be linked with libusb on Unix and libusb-win32 on Windows. +See http://libusb.sourceforge.net/ or http://libusb-win32.sourceforge.net/ +respectively. +*/ + +#include +#include +#include +#include /* this is libusb */ +#include "opendevice.h" /* common code moved to separate module */ + +#include "../firmware/requests.h" /* custom request numbers */ +#include "../firmware/usbconfig.h" /* device's VID/PID and names */ + +static void usage(char *name) +{ + fprintf(stderr, "usage:\n"); + fprintf(stderr, " %s on ....... turn on LED\n", name); + fprintf(stderr, " %s off ...... turn off LED\n", name); + fprintf(stderr, " %s status ... ask current status of LED\n", name); +#if ENABLE_TEST + fprintf(stderr, " %s test ..... run driver reliability test\n", name); +#endif /* ENABLE_TEST */ +} + +int main(int argc, char **argv) +{ +usb_dev_handle *handle = NULL; +const unsigned char rawVid[2] = {USB_CFG_VENDOR_ID}, rawPid[2] = {USB_CFG_DEVICE_ID}; +char vendor[] = {USB_CFG_VENDOR_NAME, 0}, product[] = {USB_CFG_DEVICE_NAME, 0}; +char buffer[4]; +int cnt, vid, pid, isOn; + + usb_init(); + if(argc < 2){ /* we need at least one argument */ + usage(argv[0]); + exit(1); + } + /* compute VID/PID from usbconfig.h so that there is a central source of information */ + vid = rawVid[1] * 256 + rawVid[0]; + pid = rawPid[1] * 256 + rawPid[0]; + /* The following function is in opendevice.c: */ + if(usbOpenDevice(&handle, vid, vendor, pid, product, NULL, NULL, NULL) != 0){ + fprintf(stderr, "Could not find USB device \"%s\" with vid=0x%x pid=0x%x\n", product, vid, pid); + exit(1); + } + /* Since we use only control endpoint 0, we don't need to choose a + * configuration and interface. Reading device descriptor and setting a + * configuration and interface is done through endpoint 0 after all. + * However, newer versions of Linux require that we claim an interface + * even for endpoint 0. Enable the following code if your operating system + * needs it: */ +#if 0 + int retries = 1, usbConfiguration = 1, usbInterface = 0; + if(usb_set_configuration(handle, usbConfiguration) && showWarnings){ + fprintf(stderr, "Warning: could not set configuration: %s\n", usb_strerror()); + } + /* now try to claim the interface and detach the kernel HID driver on + * Linux and other operating systems which support the call. */ + while((len = usb_claim_interface(handle, usbInterface)) != 0 && retries-- > 0){ +#ifdef LIBUSB_HAS_DETACH_KERNEL_DRIVER_NP + if(usb_detach_kernel_driver_np(handle, 0) < 0 && showWarnings){ + fprintf(stderr, "Warning: could not detach kernel driver: %s\n", usb_strerror()); + } +#endif + } +#endif + + if(strcasecmp(argv[1], "status") == 0){ + cnt = usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_IN, CUSTOM_RQ_GET_STATUS, 0, 0, buffer, sizeof(buffer), 5000); + if(cnt < 1){ + if(cnt < 0){ + fprintf(stderr, "USB error: %s\n", usb_strerror()); + }else{ + fprintf(stderr, "only %d bytes received.\n", cnt); + } + }else{ + printf("LED is %s\n", buffer[0] ? "on" : "off"); + } + }else if((isOn = (strcasecmp(argv[1], "on") == 0)) || strcasecmp(argv[1], "off") == 0){ + cnt = usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, CUSTOM_RQ_SET_STATUS, isOn, 0, buffer, 0, 5000); + if(cnt < 0){ + fprintf(stderr, "USB error: %s\n", usb_strerror()); + } +#if ENABLE_TEST + }else if(strcasecmp(argv[1], "test") == 0){ + int i; + srandomdev(); + for(i = 0; i < 50000; i++){ + int value = random() & 0xffff, index = random() & 0xffff; + int rxValue, rxIndex; + if((i+1) % 100 == 0){ + fprintf(stderr, "\r%05d", i+1); + fflush(stderr); + } + cnt = usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_IN, CUSTOM_RQ_ECHO, value, index, buffer, sizeof(buffer), 5000); + if(cnt < 0){ + fprintf(stderr, "\nUSB error in iteration %d: %s\n", i, usb_strerror()); + break; + }else if(cnt != 4){ + fprintf(stderr, "\nerror in iteration %d: %d bytes received instead of 4\n", i, cnt); + break; + } + rxValue = ((int)buffer[0] & 0xff) | (((int)buffer[1] & 0xff) << 8); + rxIndex = ((int)buffer[2] & 0xff) | (((int)buffer[3] & 0xff) << 8); + if(rxValue != value || rxIndex != index){ + fprintf(stderr, "\ndata error in iteration %d:\n", i); + fprintf(stderr, "rxValue = 0x%04x value = 0x%04x\n", rxValue, value); + fprintf(stderr, "rxIndex = 0x%04x index = 0x%04x\n", rxIndex, index); + } + } + fprintf(stderr, "\nTest completed.\n"); +#endif /* ENABLE_TEST */ + }else{ + usage(argv[0]); + exit(1); + } + usb_close(handle); + return 0; +} From 9ce06c02929726ad07cf3a408dad972f099dde86 Mon Sep 17 00:00:00 2001 From: Kai Lauterbach Date: Wed, 19 Oct 2011 00:04:59 +0200 Subject: [PATCH 08/38] Major changes on the core of the framework from klaute * Some interferrences with the two timers (usb/led) * Big cleanup from the codebase and separate logical parts * Documenting the code * Big space optimizations on the code to fit on the AVR --- firmware/Makefile | 22 +++--- firmware/globals.h | 37 ++++++++++ firmware/main.c | 169 +++++++++---------------------------------- firmware/main.h | 110 +++------------------------- firmware/usb.c | 45 +++++++++--- firmware/usb.h | 16 +++- firmware/usbconfig.h | 6 +- 7 files changed, 144 insertions(+), 261 deletions(-) create mode 100644 firmware/globals.h diff --git a/firmware/Makefile b/firmware/Makefile index 411143a..44c7e72 100644 --- a/firmware/Makefile +++ b/firmware/Makefile @@ -44,11 +44,9 @@ MCU = attiny2313 # This is only used to define F_CPU in all assembler and c-sources. F_CPU = 12000000UL -# 8MHz internal (basic firmware) -#LFUSE=0xE4 -# external clock -LFUSE=0xFF -HFUSE=0xDF +# external clock, boden, noclkdiv +LFUSE=0xEF +HFUSE=0xDB # Output format. (can be srec, ihex, binary) FORMAT = ihex @@ -81,7 +79,7 @@ OPT = s # Native formats for AVR-GCC's -g are stabs [default], or dwarf-2. # AVR (extended) COFF requires stabs, plus an avr-objcopy run. #DEBUG = stabs -DEBUG = # dwarf-2 +DEBUG = # List any extra directories to look for include files here. # Each directory must be seperated by a space. @@ -113,19 +111,17 @@ CINCS = -Iusbdrv CFLAGS = #-g$(DEBUG) CFLAGS += $(CDEFS) $(CINCS) CFLAGS += -O$(OPT) -CFLAGS += -funsigned-char +#CFLAGS += -funsigned-char #CFLAGS += -funsigned-bitfields #CFLAGS += -fpack-struct #CFLAGS += -fshort-enums -CFLAGS += -fno-split-wide-types +#CFLAGS += -fno-split-wide-types CFLAGS += -fno-move-loop-invariants CFLAGS += -fno-tree-scev-cprop #CFLAGS += -fno-inline-small-functions #CFLAGS += -fno-tree-loop-optimize -#CFLAGS += -ffunction-sections -#CFLAGS += -fdata-sections -CFLAGS += -mcall-prologues -CFLAGS += -mtiny-stack +#CFLAGS += -mcall-prologues +#CFLAGS += -mtiny-stack #CFLAGS += -mint8 CFLAGS += -Wall -Wstrict-prototypes CFLAGS += -Wa,-adhlns=$(<:.c=.lst) @@ -133,7 +129,7 @@ CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) CFLAGS += $(CSTANDARD) CFLAGS += -DF_CPU=$(F_CPU) CFLAGS += -ffunction-sections -CFLAGS += -fdata-sections +#CFLAGS += -fdata-sections CFLAGS += -Wl,--gc-sections diff --git a/firmware/globals.h b/firmware/globals.h new file mode 100644 index 0000000..b3827b0 --- /dev/null +++ b/firmware/globals.h @@ -0,0 +1,37 @@ +#define F_CPU 12000000UL + +// Bitpopelei +#define set_bit(var, bit) ((var) |= (1 << (bit))) +#define clear_bit(var, bit) ((var) &= (unsigned)~(1 << (bit))) + +// Bool +#define FALSE 0 +#define TRUE 1 + +// Definitionen +#define PIXEL_TON 30 +#define PIXEL_TOFF 10 + +#define sleep_nop(cnt) for (uint8_t i = 0; i < cnt; i++) { asm volatile("nop"::); } + +// Pixelmakros +#define PSET(x,y,z) (0b01000000 | ((z * 3 + x) + y * 9)) +#define PCLEAR(x,y,z) (0b00000000 | ((z * 3 + x) + y * 9)) + +// Instructions +#define CLEAR 0b10000000 +#define SET 0b10010000 +#define FPS 0b10110000 +#define NEXT 0b11110000 + +// Variablen +#define VAR_FPS 0 + +// Für CLEAR und SET +#define CLEAR_ALL 0 +#define SET_ALL 0 + +// Für NEXT +#define JUMP_FORWARD 1 +#define JUMP_BACKWARD 2 + diff --git a/firmware/main.c b/firmware/main.c index 8c20017..bd7e764 100644 --- a/firmware/main.c +++ b/firmware/main.c @@ -1,190 +1,91 @@ /* - * Based on the code of the Mini-LED-Cube 1.0 + * Based on the code of the Mini-LED-Cube 1.0 * - * Copyright (C) 2009 Paul Wilhelm - * http: *mosfetkiller.de/?s=miniledcube + * Copyright (C) 2009 Paul Wilhelm + * http: *mosfetkiller.de/?s=miniledcube * * Changed by Kai Lauterbach (klaute at web dot de) */ #include "main.h" -// Main +// Main int main(void) { - // Initialisierung + // Initialisierung init(); init_usb(); - // Hauptschleife - while (1) + // Hauptschleife + //while (1) + for (;;) { //wdt_reset(); // we are alive, so don't reset the µC usbPoll(); // keep connected - /* - unsigned char instruction = pgm_read_byte(&(program_pointer[program_counter])); - - if ((instruction & 0b10000000) == 0) - // Pixel - { - unsigned char coord = instruction & 0b00111111; // Uns interessieren nur die 6 untersten Bits - - unsigned char y = coord / 9; - unsigned char x = (coord - y * 9) % 3; - unsigned char z = (coord - y * 9) / 3; - buffer[x][y][z] = (instruction & 0b01000000) / 0b01000000; - } - else - // Instruction - { - unsigned char operation = instruction & 0b11110000; // Uns interessieren nur die 4 obersten Bits - - if (operation == CLEAR || operation == SET) - { - unsigned char frame = instruction & 0b00001111; - - // Folgende Werte entsprechen SET_ALL - unsigned char x_min = 0, x_max = 3, y_min = 0, y_max = 3, z_min = 0, z_max = 3; - - // Folgendes kann noch optimiert werden. - - // Y-Z-Ebene (links, mitte, rechts) - if (frame == 1) { x_min = 0; x_max = 1; } - if (frame == 2) { x_min = 1; x_max = 2; } - if (frame == 3) { x_min = 2; x_max = 3; } - - // X-Z-Ebene (unten, mitte, oben) - if (frame == 4) { y_min = 0; y_max = 1; } - if (frame == 5) { y_min = 1; y_max = 2; } - if (frame == 6) { y_min = 2; y_max = 3; } - - // X-Y-Ebene (hinten, mitte, vorne) - if (frame == 7) { z_min = 0; z_max = 1; } - if (frame == 8) { z_min = 1; z_max = 2; } - if (frame == 9) { z_min = 2; z_max = 3; } - - if (frame < 10) - { - for (unsigned char z = z_min; z < z_max; z++) - for (unsigned char y = y_min; y < y_max; y++) - for (unsigned char x = x_min; x < x_max; x++) - if (operation == SET) buffer[x][y][z] = 1; else buffer[x][y][z] = 0; - } else - { - for (unsigned char a = 0; a < 3; a++) - for (unsigned char b = 0; b < 3; b++) - { - unsigned char x = 0, y = 0, z = 0; - - if (frame == 10) { x = a; y = b; z = b; } // Unten hinten nach oben vorne - if (frame == 11) { x = a; y = a; z = b; } // Unten links nach oben rechts - if (frame == 12) { x = a; y = b; z = 2 - b; } // Unten vorne nach oben hinten - if (frame == 13) { x = a; y = 2 - a; z = b; } // Oben links nach unten rechts - if (frame == 14) { x = b; y = a; z = b; } // Hinten links nach vorne rechts - if (frame == 15) { x = a; y = 2 - b; z = 2 - a; } // Vorne links nach hinten rechts - - if (operation == SET) buffer[x][y][z] = 1; else buffer[x][y][z] = 0; - } - } - } else - - if (operation == FPS) - { - if (program_counter + 1 < program_length) program_counter++; // else: Fehler - unsigned char byte = pgm_read_byte(&(program_pointer[program_counter])); - - fps = byte; - } else - - if (operation == NEXT) - { - // VAR_FPS = 0: Frame nicht zeichnen, keine Wartezeit - if (fps > 0) - { - // Temporäres Array ins "echte" Array kopieren - for (unsigned char z = 0; z < 3; z++) - for (unsigned char y = 0; y < 3; y++) - for (unsigned char x = 0; x < 3; x++) - cube[x][y][z] = buffer[x][y][z]; - - for (unsigned char i = 0; i < fps; i++) - { - _delay_ms(5); - } - } - } - - } - - // Programmzähler erhöhen, bzw. bei Erreichen des Programmendes wieder von vorn beginnen - if (program_counter + 1 < program_length) program_counter++; else program_counter = 0; - */ - } } - -// Initialisierung +// Initialisierung void init() { - // Ports vorbereiten - DDRB = 0b11111111; // PB0-PB7: LED 1-8 (Kathoden) - PORTB = 0b11111111; // HIGH + // Ports vorbereiten + DDRB = 0b11111111; // PB0-PB7: LED 1-8 (Kathoden) + PORTB = 0b11111111; // HIGH - DDRD = 0b1111000; // PD6: LED 9 (Kathode); PD5-PD3: A-C (Anoden) + DDRD = 0b1111000; // PD6: LED 9 (Kathode); PD5-PD3: A-C (Anoden) PORTD = 0b1000000; - // Timer-Interrupt "TIMER1" vorbereiten - cli(); + // Timer-Interrupt "TIMER1" vorbereiten + //cli(); // set_bit(TIMSK, OCIE1A); set_bit(TCCR1B, WGM12); - // Animations-Geschwindigkeit + // Animations-Geschwindigkeit OCR1AH = 0x01; OCR1AL = 0x00; - clear_bit(TCCR1B, CS12); // Prescaler 64 + clear_bit(TCCR1B, CS12); // Prescaler 64 set_bit(TCCR1B, CS11); set_bit(TCCR1B, CS10); sei(); } - -// Interruptvektor von TIMER1 +// Interruptvektor von TIMER1 SIGNAL(SIG_OUTPUT_COMPARE1A) { - // Pixel multiplexen -/**/ - for (unsigned char z = 0; z < 3; z++) - { - for (unsigned char y = 0; y < 3; y++) - { - for (unsigned char x = 0; x < 3; x++) - { - unsigned char n = z * 3 + x; - // LED an + // Pixel multiplexen + for (uint8_t z = 0; z < 3; z++) + { + for (uint8_t y = 0; y < 3; y++) + { + for (uint8_t x = 0; x < 3; x++) + { + uint8_t n = z * 3 + x; + + // LED an if (cube[x][y][z] == 1) { if (n < 8) clear_bit(PORTB, n); else clear_bit(PORTD, 6); set_bit(PORTD, y + 3); } - // ON-Time - for (unsigned long i = 0; i < PIXEL_TON; i++) { asm volatile("nop"::); } + // ON-Time + sleep_nop(PIXEL_TON); - // LED aus + // LED aus if (cube[x][y][z] == 1) { clear_bit(PORTD, y + 3); if (n < 8) set_bit(PORTB, n); else set_bit(PORTD, 6); } - // OFF-Time - for (unsigned long i = 0; i < PIXEL_TOFF; i++) { asm volatile("nop"::); } + // OFF-Time + sleep_nop(PIXEL_TOFF) } } } -/**/ + } + diff --git a/firmware/main.h b/firmware/main.h index 50b4408..72cd2ae 100644 --- a/firmware/main.h +++ b/firmware/main.h @@ -4,119 +4,33 @@ // http://mosfetkiller.de/?s=miniledcube // // Changed by Kai Lauterbach (klaute at web dot de) - -// Interner RC-Oszillator, CKDIV8 Disabled +// +// Externes Quarz, CKDIV8 Disabled #ifndef __main_h__ #define __main_h__ -#define F_CPU 12000000UL +// Includes +#include "globals.h" -// Includes -#include #include #include -#include +//#include +//#include //#include -// Bitpopelei -#define set_bit(var, bit) ((var) |= (1 << (bit))) -#define clear_bit(var, bit) ((var) &= (unsigned)~(1 << (bit))) +// Cube-Array +uint8_t cube[3][3][3]; +uint8_t buffer[3][3][3]; // Framebuffer -// Bool -#define FALSE 0 -#define TRUE 1 +volatile uint8_t frame_done = 0; -// Definitionen -#define PIXEL_TON 30 -#define PIXEL_TOFF 10 - -// Cube-Array -unsigned char cube[3][3][3]; -unsigned char buffer[3][3][3]; // Framebuffer - -// Prototypen +// Prototypen void init(void); +void loop(uint8_t); extern void init_usb(void); extern void usbPoll(void); -/* -// Programmzähler -unsigned int program_counter = 0; - -// Framezähler -volatile unsigned char frame_counter = 0, fps = 0; - - -// Pixelmakros -#define PSET(x,y,z) (0b01000000 | ((z * 3 + x) + y * 9)) -#define PCLEAR(x,y,z) (0b00000000 | ((z * 3 + x) + y * 9)) - -// Instructions -#define CLEAR 0b10000000 -#define SET 0b10010000 -#define FPS 0b10110000 -#define NEXT 0b11110000 - -// Variablen -#define VAR_FPS 0 - -// Für CLEAR und SET -#define CLEAR_ALL 0 -#define SET_ALL 0 - -// Für NEXT -#define JUMP_FORWARD 1 -#define JUMP_BACKWARD 2 - - -// Animation in pgmspace -const prog_char program_1[] = -{ - FPS, 10, - - CLEAR, SET + 12, NEXT, CLEAR, SET + 14, NEXT, // Vor- und zurück tanzen - CLEAR, SET + 12, NEXT, CLEAR, SET + 14, NEXT, - CLEAR, SET + 12, NEXT, CLEAR, SET + 15, NEXT, - CLEAR, SET + 12, NEXT, CLEAR, SET + 15, - - FPS, 5, CLEAR, SET + 8, NEXT, CLEAR, SET + 14, NEXT, // Umdrehung - FPS, 5, CLEAR, SET + 2, NEXT, CLEAR, SET + 15, NEXT, - FPS, 6, CLEAR, SET + 8, NEXT, CLEAR, SET + 14, NEXT, - FPS, 6, CLEAR, SET + 2, NEXT, CLEAR, SET + 15, NEXT, - FPS, 7, CLEAR, SET + 8, NEXT, CLEAR, SET + 14, NEXT, - FPS, 7, CLEAR, SET + 2, NEXT, CLEAR, SET + 15, NEXT, - FPS, 8, CLEAR, SET + 8, NEXT, CLEAR, SET + 14, NEXT, - FPS, 8, CLEAR, SET + 2, NEXT, CLEAR, SET + 15, NEXT, - FPS, 9, CLEAR, SET + 8, NEXT, CLEAR, SET + 14, NEXT, - FPS, 9, CLEAR, SET + 2, NEXT, CLEAR, SET + 15, NEXT, - FPS, 10, CLEAR, SET + 8, NEXT, CLEAR, SET + 14, NEXT, - FPS, 10, CLEAR, SET + 2, NEXT, CLEAR, SET + 15, NEXT, - CLEAR, SET + 8, NEXT, CLEAR, SET + 12, NEXT, // Umfallen - CLEAR, SET + 4, NEXT, CLEAR, SET + 5, NEXT, CLEAR, SET + 6, NEXT, // Ebenen - CLEAR, SET + 1, NEXT, CLEAR, SET + 2, NEXT, CLEAR, SET + 3, NEXT, - CLEAR, SET + 7, NEXT, CLEAR, SET + 8, NEXT, CLEAR, SET + 9, NEXT, - - FPS, 10, // Außen langlaufen - - CLEAR, - PSET(0,0,0), PSET(1,0,0), PSET(0,1,0), PSET(1,1,0), PSET(0,2,0), PSET(1,2,0), NEXT, - PCLEAR(0,0,0), PSET(2,0,0), PCLEAR(0,1,0), PSET(2,1,0), PCLEAR(0,2,0), PSET(2,2,0), NEXT, - PCLEAR(1,0,0), PSET(2,0,1), PCLEAR(1,1,0), PSET(2,1,1), PCLEAR(1,2,0), PSET(2,2,1), NEXT, - PCLEAR(2,0,0), PSET(2,0,2), PCLEAR(2,1,0), PSET(2,1,2), PCLEAR(2,2,0), PSET(2,2,2), NEXT, - PCLEAR(2,0,1), PSET(1,0,2), PCLEAR(2,1,1), PSET(1,1,2), PCLEAR(2,2,1), PSET(1,2,2), NEXT, - PCLEAR(2,0,2), PSET(0,0,2), PCLEAR(2,1,2), PSET(0,1,2), PCLEAR(2,2,2), PSET(0,2,2), NEXT, - PCLEAR(1,0,2), PSET(0,0,1), PCLEAR(1,1,2), PSET(0,1,1), PCLEAR(1,2,2), PSET(0,2,1), NEXT, - PCLEAR(0,0,2), PSET(0,0,0), PCLEAR(0,1,2), PSET(0,1,0), PCLEAR(0,2,2), PSET(0,2,0), NEXT, - PCLEAR(0,0,1), PCLEAR(0,1,1), PCLEAR(0,2,1), - - SET + 7, NEXT, CLEAR, SET + 8, NEXT, CLEAR, SET + 9, NEXT, - CLEAR, SET + 8, NEXT, CLEAR, SET + 7, NEXT, -}; - -const prog_char *program_pointer = program_1; -unsigned int program_length = sizeof(program_1); -*/ #endif // __main_h__ diff --git a/firmware/usb.c b/firmware/usb.c index fdcf4f5..3915e30 100644 --- a/firmware/usb.c +++ b/firmware/usb.c @@ -12,19 +12,43 @@ usbMsgLen_t usbFunctionSetup(uchar data[8]) { -usbRequest_t *rq = (void *)data; + usbRequest_t *rq = (void *)data; - if((rq->bmRequestType & USBRQ_TYPE_MASK) == USBRQ_TYPE_VENDOR){ - if(rq->bRequest == CUSTOM_RQ_SET_STATUS){ + if ( (rq->bmRequestType & USBRQ_TYPE_MASK) == USBRQ_TYPE_VENDOR ) + { + if ( rq->bRequest == CUSTOM_RQ_SET_STATUS ) + { - // receive animation data + /*if (rq->wIndex.bytes[0] == 0) + cube[0][0][0] = 1; + if (rq->wIndex.bytes[0] == 1) + cube[0][0][1] = 1; + if (rq->wIndex.bytes[0] == 2) + cube[0][0][2] = 1; + if (rq->wIndex.bytes[0] == 3) + cube[0][1][0] = 1;*/ + + if (rq->wIndex.bytes[0] == 0) + x = rq->wValue.bytes[0]; + + else if (rq->wIndex.bytes[0] == 1) + y = rq->wValue.bytes[0]; + + else if (rq->wIndex.bytes[0] == 2) + z = rq->wValue.bytes[0]; + + else if (rq->wIndex.bytes[0] == 3) + cube[x][y][z] = rq->wValue.bytes[0]; + + } else if ( rq->bRequest == CUSTOM_RQ_GET_STATUS ) { + // Send one byte to the USB host. - }else if(rq->bRequest == CUSTOM_RQ_GET_STATUS){ //static uchar dataBuffer[1]; // buffer must stay valid when usbFunctionSetup returns - //dataBuffer[0] = ((LED_PORT_OUTPUT & _BV(LED_BIT)) != 0); - //usbMsgPtr = dataBuffer; // tell the driver which data to return + //usbMsgPtr = 0; // tell the driver which data to return //return 1; // tell the driver to send 1 byte - return 0; // tell the driver to send 1 byte + + //return 0; // tell the driver to send 0 byte + } }else{ /* class requests USBRQ_HID_GET_REPORT and USBRQ_HID_SET_REPORT are @@ -43,11 +67,14 @@ void init_usb(void) usbInit(); usbDeviceDisconnect(); /* enforce re-enumeration, do this while interrupts are disabled! */ + i = 0; while(--i){ /* fake USB disconnect for > 250 ms */ //wdt_reset(); _delay_ms(1); + //sleep_nop(255); } + usbDeviceConnect(); sei(); // enable global interrupts @@ -68,7 +95,7 @@ void init_usb(void) ...mainloop start... - wdt_reset(); // we are alive, please dont reset the µC + wdt_reset(); // we are alive, please dont reset the µC (optional) usbPoll(); // keep the usb connection up ...end mainloop... diff --git a/firmware/usb.h b/firmware/usb.h index eeae5c1..f1e4c03 100644 --- a/firmware/usb.h +++ b/firmware/usb.h @@ -10,6 +10,8 @@ #ifndef __usb_h__ #define __usb_h__ +#include "globals.h" + /* This example should run on most AVRs with only little changes. No special hardware resources except INT0 are used. You may have to change usbconfig.h for @@ -19,12 +21,11 @@ We assume that an LED is connected to port B bit 0. If you connect it to a different port or bit, change the macros below: */ -#include -//#include #include /* for sei() */ +//#include +//#include #include /* for _delay_ms() */ - -#include /* required by usbdrv.h */ +//#include /* required by usbdrv.h */ #include "usbconfig.h" #include "usbdrv.h" @@ -54,6 +55,13 @@ PROGMEM char usbHidReportDescriptor[22] = { /* USB report descriptor */ void init_usb(void); +volatile uint8_t x; +volatile uint8_t y; +volatile uint8_t z; + +// usb buffer +//extern uint8_t buffer[3][3][3]; // Framebuffer +extern uint8_t cube[3][3][3]; // Framebuffer #endif // __usb_h__ diff --git a/firmware/usbconfig.h b/firmware/usbconfig.h index 2562001..c7e6685 100644 --- a/firmware/usbconfig.h +++ b/firmware/usbconfig.h @@ -27,11 +27,11 @@ section at the end of this file). /* This is the port where the USB bus is connected. When you configure it to * "B", the registers PORTB, PINB and DDRB will be used. */ -#define USB_CFG_DMINUS_BIT 3 +#define USB_CFG_DMINUS_BIT 1 /* This is the bit number in USB_CFG_IOPORT where the USB D- line is connected. * This may be any bit in the port. */ -#define USB_CFG_DPLUS_BIT 6 +#define USB_CFG_DPLUS_BIT 2 /* This is the bit number in USB_CFG_IOPORT where the USB D+ line is connected. * This may be any bit in the port. Please note that D+ must also be connected * to interrupt pin INT0! [You can also use other interrupts, see section @@ -116,7 +116,7 @@ section at the end of this file). /* Define this to 1 if the device has its own power supply. Set it to 0 if the * device is powered from the USB bus. */ -#define USB_CFG_MAX_BUS_POWER 200 +#define USB_CFG_MAX_BUS_POWER 250 /* Set this variable to the maximum USB bus power consumption of your device. * The value is in milliamperes. [It will be divided by two since USB * communicates power requirements in units of 2 mA.] From d7dedd3baa819cfe36ec85efd94733e0339d472f Mon Sep 17 00:00:00 2001 From: Kai Lauterbach Date: Wed, 19 Oct 2011 00:12:00 +0200 Subject: [PATCH 09/38] Clean up the testcode --- client/Makefile | 2 +- client/set-led | Bin 23439 -> 0 bytes client/{set-led.c => test.c} | 105 +++++++++++++---------------------- 3 files changed, 41 insertions(+), 66 deletions(-) delete mode 100644 client/set-led rename client/{set-led.c => test.c} (50%) diff --git a/client/Makefile b/client/Makefile index 5894ca8..29dd094 100644 --- a/client/Makefile +++ b/client/Makefile @@ -22,7 +22,7 @@ EXE_SUFFIX = #USBLIBS = -L/usr/local/lib -lusb #EXE_SUFFIX = .exe -NAME = set-led +NAME = test OBJECTS = opendevice.o $(NAME).o diff --git a/client/set-led b/client/set-led deleted file mode 100644 index ec840111837e87ed0c9b1f4d57fbaac2e64d6f43..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 23439 zcmeHveRx#Wwf8JeEk`3?Xt_+IcBkAP+*pJg!4gZw;{%~%VXQS+{O-D(B-iJk;J<4c(iam^~`uDRdV!8 z%S(Q;{q3PAfBn`_u=|CTS=4ag?+u`bWzk;Xj5>IMyrc<0=AScwE}=8*K>ov;03;n6 zKrbCYuNy!+2k1Lz0DXLb{MG^Vr32_!2hjHpplhIi`J?EA2nFKpzH-p@S@c1q@4ee) zvh9YU6^GhP~(+7gb&6($R54Xh2dpcL5MLW`#h z-~6j#ZfhvwOT+`Ms6Z!FSZ%(R;0+?M4tDrho0c1x;A``T!boV#l0lIz{&=9Jqf-3^NpkLU|mubHQX&8mc@g0tA&LpnQ%VS-*-JP?h%!Qt5EBS< zF&`7cvPwd9sVYKDFf#~YXf+`Q_AEjS!ezZOg>Z$4;F6e4x^M}2*L-7i@= zy;mT$_a`v3w-Gv*U;o^}zG-JrlfLmE;h%Z>#Z4WwsDnjQ)+CtWFNdMdbvv{%yfSdbMuQ6Oo0F4#$0NSYoDa%wtp>SH8~rzeA( zNFM_|`OVeIKXx5I)zG*k*nqJeJaw1LyrwDmx39R&-Z79ry`x{S{lDq*2B;BWnJR0jgltTqZ*E6o`R~_7L zT_Cm}xRCPD-}OfE{Uwm??y-jNXBv>fhh1e%>pSw?!GZQ%+k_rbovb^a{B{05$CjS_ zEvwK2e$I}ZT68>r->@w&B?ebdv@Sof6lv90=5P6eggaR5MtAkZ#E6q)tFKq~S}Uqo z=I`ps-`8UtytFXC`$CAG_z5Rd-A(KR`Q!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7Uu=yHTgkqK`UX%#!0f1E(R^fHWN_!}te8 zt*;he8L0K1y}rjF$MR_(zeZ5+Rs95{47wh#gQC7ll`JTizG<_0x^R>}@qj^85EI9X3l z!-0~s$W0v}H*2Q4o7MWXUuM~I+AkX}#Y%+@ZU>gdxNv~Jr)LSVgA%Q*<7IeAh?OT<)uR zO40d}=6s}R)nPgBD4MN;-RCqtT+*CJh&b&lqkbpHDc=Y}d!+f88p>e^i=B#3}fsD-)aolTuc23U3xg z`LP4&aRcbmbiX9Sh3_!31+@PRyd6c0wf_u!NpS*b?LPzl!>|@>?DleqJh2e8{8}2I zA&SLyfc&N!dlu;+U{98Oc0XqM7Wf6Wzghlf(7JsMT#3H|I=lRDf?k8`768Uoo_LIi z9jK4j54{&i{tKY>ejn*qwJ;#%PXOvYIP%{Dt=r!~`{%%5?H@cU5!@Hdrg?T*_a_7W zX$olFU%coqmxJcF>o~H8LqFd!(t*8`-!#yfX@Cd=Ai-n>^YF~?}EQKOP>Q%h^|io>XV-}nNi+5fUW?|>z%TvSk!=?XOEv@ zj&sH00rJ-lpxZ(7i+!xaFvoCtE6&gUv0u?YTL#GU(^xvt9zMBa`Ap+?M)|x?2lDx7 zQ3uk00lhp+{w>gYPnYHKkX*Jt7p73XKTQ6JtT~$cc(P9i(tP7-ncZK9JMzR_(0V_Y z`4@uL^CQ1wdd-0Rq9taSv8lR-u?fpmE&Ik diff --git a/client/set-led.c b/client/test.c similarity index 50% rename from client/set-led.c rename to client/test.c index 52b2a3b..e94047c 100644 --- a/client/set-led.c +++ b/client/test.c @@ -27,30 +27,16 @@ respectively. #include "../firmware/requests.h" /* custom request numbers */ #include "../firmware/usbconfig.h" /* device's VID/PID and names */ -static void usage(char *name) -{ - fprintf(stderr, "usage:\n"); - fprintf(stderr, " %s on ....... turn on LED\n", name); - fprintf(stderr, " %s off ...... turn off LED\n", name); - fprintf(stderr, " %s status ... ask current status of LED\n", name); -#if ENABLE_TEST - fprintf(stderr, " %s test ..... run driver reliability test\n", name); -#endif /* ENABLE_TEST */ -} - int main(int argc, char **argv) { usb_dev_handle *handle = NULL; const unsigned char rawVid[2] = {USB_CFG_VENDOR_ID}, rawPid[2] = {USB_CFG_DEVICE_ID}; char vendor[] = {USB_CFG_VENDOR_NAME, 0}, product[] = {USB_CFG_DEVICE_NAME, 0}; char buffer[4]; -int cnt, vid, pid, isOn; +int cnt, vid, pid; usb_init(); - if(argc < 2){ /* we need at least one argument */ - usage(argv[0]); - exit(1); - } + /* compute VID/PID from usbconfig.h so that there is a central source of information */ vid = rawVid[1] * 256 + rawVid[0]; pid = rawPid[1] * 256 + rawPid[0]; @@ -81,55 +67,44 @@ int cnt, vid, pid, isOn; } #endif - if(strcasecmp(argv[1], "status") == 0){ - cnt = usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_IN, CUSTOM_RQ_GET_STATUS, 0, 0, buffer, sizeof(buffer), 5000); - if(cnt < 1){ - if(cnt < 0){ - fprintf(stderr, "USB error: %s\n", usb_strerror()); - }else{ - fprintf(stderr, "only %d bytes received.\n", cnt); - } - }else{ - printf("LED is %s\n", buffer[0] ? "on" : "off"); - } - }else if((isOn = (strcasecmp(argv[1], "on") == 0)) || strcasecmp(argv[1], "off") == 0){ - cnt = usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, CUSTOM_RQ_SET_STATUS, isOn, 0, buffer, 0, 5000); - if(cnt < 0){ - fprintf(stderr, "USB error: %s\n", usb_strerror()); - } -#if ENABLE_TEST - }else if(strcasecmp(argv[1], "test") == 0){ - int i; - srandomdev(); - for(i = 0; i < 50000; i++){ - int value = random() & 0xffff, index = random() & 0xffff; - int rxValue, rxIndex; - if((i+1) % 100 == 0){ - fprintf(stderr, "\r%05d", i+1); - fflush(stderr); - } - cnt = usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_IN, CUSTOM_RQ_ECHO, value, index, buffer, sizeof(buffer), 5000); - if(cnt < 0){ - fprintf(stderr, "\nUSB error in iteration %d: %s\n", i, usb_strerror()); - break; - }else if(cnt != 4){ - fprintf(stderr, "\nerror in iteration %d: %d bytes received instead of 4\n", i, cnt); - break; - } - rxValue = ((int)buffer[0] & 0xff) | (((int)buffer[1] & 0xff) << 8); - rxIndex = ((int)buffer[2] & 0xff) | (((int)buffer[3] & 0xff) << 8); - if(rxValue != value || rxIndex != index){ - fprintf(stderr, "\ndata error in iteration %d:\n", i); - fprintf(stderr, "rxValue = 0x%04x value = 0x%04x\n", rxValue, value); - fprintf(stderr, "rxIndex = 0x%04x index = 0x%04x\n", rxIndex, index); - } - } - fprintf(stderr, "\nTest completed.\n"); -#endif /* ENABLE_TEST */ - }else{ - usage(argv[0]); - exit(1); - } + int i,x,y,z,onoff = 0; + while (1) + { + onoff = (onoff == 0) ? 1 : 0; + for (x = 0; x <3; x++) + for (y = 0; y <3; y++) + for (z = 0; z <3; z++) + { + for (i = 0; i < 4; i++) + { + int v = 0; + if (i == 0) + v = x; + if (i == 1) + v = y; + if (i == 2) + v = z; + if (i == 3) + v = onoff; + cnt = -1; + do { + sleep(1); + cnt = usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, CUSTOM_RQ_SET_STATUS, v, 0, buffer, 0, 5000); + if (cnt < 0) + { + if(usbOpenDevice(&handle, vid, vendor, pid, product, NULL, NULL, NULL) != 0){ + fprintf(stderr, "Could not find USB device \"%s\" with vid=0x%x pid=0x%x\n", product, vid, pid); + exit(1); + } + } + } while (cnt < 0); + + } + + fprintf(stdout, "%d %d %d %d\n",x,y,z,onoff); + } + } + usb_close(handle); return 0; } From 1b468b8c229fca31385896afd6d4a3638064e8a1 Mon Sep 17 00:00:00 2001 From: Aaron Mueller Date: Wed, 19 Oct 2011 01:10:15 +0200 Subject: [PATCH 10/38] Start implementing a 3D GUI to configure the cube. The idea is to use OpenGL and some simple C code to display a 3D cube. With the mouse you can define which LED should be on or off on a particular frame. With this technique, you can define whole sequences of frames to form animations. --- editor/Makefile | 19 ++++++++++++++++++ editor/src/config.h | 20 ++++++++++++++++++ editor/src/display.c | 40 ++++++++++++++++++++++++++++++++++++ editor/src/display.h | 9 +++++++++ editor/src/input.c | 48 ++++++++++++++++++++++++++++++++++++++++++++ editor/src/input.h | 11 ++++++++++ editor/src/main.c | 38 +++++++++++++++++++++++++++++++++++ 7 files changed, 185 insertions(+) create mode 100644 editor/Makefile create mode 100644 editor/src/config.h create mode 100644 editor/src/display.c create mode 100644 editor/src/display.h create mode 100644 editor/src/input.c create mode 100644 editor/src/input.h create mode 100644 editor/src/main.c diff --git a/editor/Makefile b/editor/Makefile new file mode 100644 index 0000000..e9e50d8 --- /dev/null +++ b/editor/Makefile @@ -0,0 +1,19 @@ +CC=gcc +CFLAGS=-Wall +INCLUDES=-I/usr/include/GL +LIBS=-lglut -lGLU -lGL -lm + +SRCDIR=src + +all: + $(CC) $(CFLAGS) $(INCLUDES) -c $(SRCDIR)/display.c + $(CC) $(CFLAGS) $(INCLUDES) -c $(SRCDIR)/input.c + $(CC) $(CFLAGS) $(INCLUDES) -c $(SRCDIR)/main.c + + $(CC) $(CFLAGS) $(LIBS) -o ledcube-edit main.o display.o input.o + chmod +x ledcube-edit + +clean: + rm -f *.o + #rm -f ledcube-edit + diff --git a/editor/src/config.h b/editor/src/config.h new file mode 100644 index 0000000..737cde2 --- /dev/null +++ b/editor/src/config.h @@ -0,0 +1,20 @@ +#ifndef _CONFIG_H +#define _CONFIG_H + +#define WINDOW_WIDTH 800 +#define WINDOW_HEIGHT 600 + +#define CUBE_SIZE 30 +#define MOVE_SPEED 5 + +#define PI 3.14159265 + +// Materials +extern float ledOnMaterial[]; + +// Movement +extern float lookX, lookZ; +extern float eyePos, eyeAngle; + +#endif + diff --git a/editor/src/display.c b/editor/src/display.c new file mode 100644 index 0000000..773e278 --- /dev/null +++ b/editor/src/display.c @@ -0,0 +1,40 @@ +#include +#include + +#include "config.h" +#include "display.h" + +extern void moveCameraPosition(float direction); + +void drawLEDCube() { + glMatrixMode(GL_MODELVIEW); + glMaterialfv(GL_FRONT, GL_DIFFUSE, ledOnMaterial); + + int x, y, z; + float space = 10.0; + for (z=0; z<3; ++z) // Ebene + for (y=0; y<3; ++y) // Zeile + for (x=0; x<3; ++x) { // Spalte + glPushMatrix(); + glTranslatef(x*space, y*space, z*space); + glutSolidSphere(1.0, 16, 16); + glPopMatrix(); + } +} + +void display() { + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(45.0, WINDOW_WIDTH/WINDOW_HEIGHT, 1.0, 250.0); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + moveCameraPosition(0.0); + gluLookAt(lookX, eyeAngle, lookZ, CUBE_SIZE/2, 6.0, CUBE_SIZE/2, 0, 1, 0); + + drawLEDCube(); + glutSwapBuffers(); +} + diff --git a/editor/src/display.h b/editor/src/display.h new file mode 100644 index 0000000..079f5bc --- /dev/null +++ b/editor/src/display.h @@ -0,0 +1,9 @@ +#ifndef _DISPLAY_H +#define _DISPLAY_H + + +void drawLEDCube(); +void display(); + +#endif + diff --git a/editor/src/input.c b/editor/src/input.c new file mode 100644 index 0000000..5606335 --- /dev/null +++ b/editor/src/input.c @@ -0,0 +1,48 @@ +#include +#include +#include + +#include "config.h" +#include "input.h" + +void moveCameraPosition(float direction) { + eyePos += direction; + if (eyePos > 360.0) eyePos = 0.0; + + lookX = cos(eyePos * PI/180.0)*(CUBE_SIZE/2+50.0) + (CUBE_SIZE/2); + lookZ = sin(eyePos * PI/180.0)*(CUBE_SIZE/2+50.0) + (CUBE_SIZE/2); +} + +void moveCameraAngle(float angle) { + eyeAngle += angle; + if (eyeAngle > 120) eyeAngle = 120; + if (eyeAngle < 0) eyeAngle = 0; +} + + +void keyboard(unsigned char key, int x, int y) { + switch (key) { + case 27: // ESC + exit(0); + break; + } + glutPostRedisplay(); +} + +void keyboard_special(int key, int x, int y) { + switch (key) { + case GLUT_KEY_LEFT: + moveCameraPosition(MOVE_SPEED); + break; + case GLUT_KEY_RIGHT: + moveCameraPosition(MOVE_SPEED*-1); + break; + case GLUT_KEY_UP: + moveCameraAngle(MOVE_SPEED); + break; + case GLUT_KEY_DOWN: + moveCameraAngle(MOVE_SPEED*-1); + } + glutPostRedisplay(); +} + diff --git a/editor/src/input.h b/editor/src/input.h new file mode 100644 index 0000000..d3bc2b9 --- /dev/null +++ b/editor/src/input.h @@ -0,0 +1,11 @@ +#ifndef _INPUT_H +#define _INPUT_H + +void moveCameraPosition(float direction); +void moveCameraAngle(float angle); + +void keyboard(unsigned char key, int x, int y); +void keyboard_special(int key, int x, int y); + +#endif + diff --git a/editor/src/main.c b/editor/src/main.c new file mode 100644 index 0000000..0a90791 --- /dev/null +++ b/editor/src/main.c @@ -0,0 +1,38 @@ + +#include +#include +#include + +#include "config.h" +#include "display.h" +#include "input.h" + +float ledOnMaterial[] = {1.0, 0.0, 0.0, 1.0}; + +float lookX = 0.0, lookZ = 0.0; +float eyePos = 0.0, eyeAngle = 50.0; + +int main(int argc, char* argv[]) { + glutInit(&argc, argv); + + glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); + glutInitWindowSize(WINDOW_WIDTH, WINDOW_HEIGHT); + glutCreateWindow("CTHN LEDCube Editor"); + + glutDisplayFunc(display); + glutKeyboardFunc(keyboard); + glutSpecialFunc(keyboard_special); + + glClearColor(0.0, 0.0, 0.0, 1.0); + glShadeModel(GL_SMOOTH); + + // OpenGL Features + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + + glMatrixMode(GL_MODELVIEW); + glutMainLoop(); + + return 0; +} + From dc6b4346ced5d61de1236e46edb2c78f12e042ce Mon Sep 17 00:00:00 2001 From: Aaron Mueller Date: Thu, 20 Oct 2011 20:28:00 +0200 Subject: [PATCH 11/38] Fix the "zoom" problem and add some wires in between. --- editor/src/config.h | 10 +++++++-- editor/src/display.c | 50 +++++++++++++++++++++++++++++++++----------- editor/src/input.c | 4 ++-- editor/src/main.c | 23 ++++++++++++++++++-- 4 files changed, 69 insertions(+), 18 deletions(-) diff --git a/editor/src/config.h b/editor/src/config.h index 737cde2..6f7c629 100644 --- a/editor/src/config.h +++ b/editor/src/config.h @@ -5,16 +5,22 @@ #define WINDOW_HEIGHT 600 #define CUBE_SIZE 30 -#define MOVE_SPEED 5 +#define MOVE_SPEED 7 +#define ZOOM_LEVEL 25 -#define PI 3.14159265 +#define PI 3.1415926535897932 // Materials extern float ledOnMaterial[]; +extern float wireMaterial[]; +extern float innerWireMaterial[]; // Movement extern float lookX, lookZ; extern float eyePos, eyeAngle; +// Objects +extern GLUquadricObj *quadric; + #endif diff --git a/editor/src/display.c b/editor/src/display.c index 773e278..d2c7e49 100644 --- a/editor/src/display.c +++ b/editor/src/display.c @@ -4,22 +4,49 @@ #include "config.h" #include "display.h" -extern void moveCameraPosition(float direction); void drawLEDCube() { - glMatrixMode(GL_MODELVIEW); - glMaterialfv(GL_FRONT, GL_DIFFUSE, ledOnMaterial); - int x, y, z; - float space = 10.0; - for (z=0; z<3; ++z) // Ebene - for (y=0; y<3; ++y) // Zeile - for (x=0; x<3; ++x) { // Spalte + + // LEDs + glMaterialfv(GL_FRONT, GL_DIFFUSE, ledOnMaterial); + for (z=-10; z<=10; z+=10) // Ebene + for (y=-10; y<=10; y+=10) // Zeile + for (x=-10; x<=10; x+=10) { // Spalte glPushMatrix(); - glTranslatef(x*space, y*space, z*space); + glTranslatef(x, y, z); glutSolidSphere(1.0, 16, 16); + gluCylinder(quadric, 1.0, 1.0, 1.3, 16, 2); + //glTranslatef(x, y, z+0.8); + //gluCylinder(quadric, 1.3, 1.3, 0.2, 16, 2); + //gluDisk( + glPopMatrix(); } + + // Wires + for (y=-10; y<=10; y+=10) + for (x=-10; x<=10; x+=10) { + glMaterialfv(GL_FRONT, GL_DIFFUSE, ((x == 0 || y == 0) ? innerWireMaterial : wireMaterial)); + + // Front + glBegin(GL_LINES); + glVertex3f(x, y, -10); + glVertex3f(x, y, 10); + glEnd(); + + // Side + glBegin(GL_LINES); + glVertex3f(-10, x, y); + glVertex3f(10, x, y); + glEnd(); + + // Top + glBegin(GL_LINES); + glVertex3f(x, -10, y); + glVertex3f(x, 10, y); + glEnd(); + } } void display() { @@ -27,12 +54,11 @@ void display() { glMatrixMode(GL_PROJECTION); glLoadIdentity(); - gluPerspective(45.0, WINDOW_WIDTH/WINDOW_HEIGHT, 1.0, 250.0); + gluPerspective(ZOOM_LEVEL, WINDOW_WIDTH/WINDOW_HEIGHT, 1.0, 350.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); - moveCameraPosition(0.0); - gluLookAt(lookX, eyeAngle, lookZ, CUBE_SIZE/2, 6.0, CUBE_SIZE/2, 0, 1, 0); + gluLookAt(lookX, eyeAngle, lookZ, 0, 0, 0, 0, 1, 0); drawLEDCube(); glutSwapBuffers(); diff --git a/editor/src/input.c b/editor/src/input.c index 5606335..8759e6c 100644 --- a/editor/src/input.c +++ b/editor/src/input.c @@ -9,8 +9,8 @@ void moveCameraPosition(float direction) { eyePos += direction; if (eyePos > 360.0) eyePos = 0.0; - lookX = cos(eyePos * PI/180.0)*(CUBE_SIZE/2+50.0) + (CUBE_SIZE/2); - lookZ = sin(eyePos * PI/180.0)*(CUBE_SIZE/2+50.0) + (CUBE_SIZE/2); + lookX = sin(eyePos * PI/180.0)*70.0; + lookZ = cos(eyePos * PI/180.0)*70.0; } void moveCameraAngle(float angle) { diff --git a/editor/src/main.c b/editor/src/main.c index 0a90791..4ca1c76 100644 --- a/editor/src/main.c +++ b/editor/src/main.c @@ -7,10 +7,20 @@ #include "display.h" #include "input.h" -float ledOnMaterial[] = {1.0, 0.0, 0.0, 1.0}; +float ledOnMaterial[] = {0.0, 0.0, 1.0, 1.0}; +float wireMaterial[] = {0.7, 0.7, 0.7, 1.0}; +float innerWireMaterial[] = {0.2, 0.2, 0.2, 0.3}; + +float light_diffuse[] = {0.0, 0.0, 1.0, 1.0}; +float light_position[] = {1.0, 1.0, 1.0, 0.0}; + float lookX = 0.0, lookZ = 0.0; -float eyePos = 0.0, eyeAngle = 50.0; +float eyePos = 0.0, eyeAngle = 45.0; + +GLUquadricObj *quadric; + +extern void moveCameraPosition(float direction); int main(int argc, char* argv[]) { glutInit(&argc, argv); @@ -30,7 +40,16 @@ int main(int argc, char* argv[]) { glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); + glEnable(GL_DEPTH_TEST); + glMatrixMode(GL_MODELVIEW); + moveCameraPosition(0); // Init the Position + + + quadric = gluNewQuadric(); + gluQuadricNormals(quadric, GLU_SMOOTH); + gluQuadricDrawStyle(quadric, GLU_FILL); + glutMainLoop(); return 0; From fc727bce528df7c975bbef4a770bc603b40434b1 Mon Sep 17 00:00:00 2001 From: Kai Lauterbach Date: Thu, 20 Oct 2011 20:40:45 +0200 Subject: [PATCH 12/38] Copy from master branch. --- .gitignore | 6 ++---- pcb/miniledcube.brd | Bin 26279 -> 26279 bytes pcb/miniledcube.sch | Bin 309421 -> 309422 bytes 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 6f8b53e..2920d97 100644 --- a/.gitignore +++ b/.gitignore @@ -6,7 +6,5 @@ firmware/.dep *.elf *.lst *.lss -*.eep -*.map -*.sym - +*.s#* +*.b#* diff --git a/pcb/miniledcube.brd b/pcb/miniledcube.brd index 759716d0a924bb4020f8a1df2d5b63939344509e..0a4317c62c73673fce2502b96da644daa5f5aa17 100644 GIT binary patch delta 4429 zcmaJ^ZERFk8h+2Y_s%f1;CvL9kD@qK%CysVIxSFbgQ2Y;9Vsl+t=h9Yo_p@|zUO&A&U-#)VoFR*iQcHUj$XEioGQD^ZrYvx#vSbXGJoaH7-e579>28b zH&fAS`o*%Bk1pQu`c%}WGMtRcpL_r52r6VlUG}wA5v#Z>bY0rtpf?m56_NR?BbF;v zQ@lENOhkHBFO$u*4;HS@T~#<=6MssE~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T5MBTRaWWH%K*8uB7@^st)-oRc{}7n-~pD>}kB?qfS)h+d#wGLah?=SITRe zdRejhO=;9ph9-qgjMVEjHO#Qyr}`;!5L~0LO^s9JM9MjB)D&E)C`;R_MT&fla#9C% znWB9H>3W}hrIWfs)qWyhA}@MCbtziMsbDLL(de(@V`)4&oID{AEHf#0byHg@@)%`l zcgm=IW$PZw>cfm@&$ zox;`O!uk?<5sF1Gh*i5Ag%N70qAAni-exK_T0M_%r^(qUMo5g>NowWfL*&$fYA2y3 z%>YNE7`cPUN6350YvR>e`0HvWxHF2;I9P42XiLcR$hIWTf0q0yxo)UhC$xT#fc;U( z{}B4-ht$us@JC_xL@{!cIVfTlI0(f^O;LwS?HTe@QK2H3cs`Y>+`nbG+9OB?_xNOd|d0BNH5=xbKy;n!Ov~@iJ1N$ zr`BFGmAL~cgDL#rhI8g18wnZy`iDFNKQm*sjGY4EH#elt(LasUsGUe%Y)ZMydfN1V zPEv1Je}EHL(AHvUqaRe%p4OlK z(Ju$w4#miN7Z(IMfpS-g>QJ?0>|v?TZfE+N z=qDEF$G=zO<=X)Lz8}(yyKqQJQJvl?(e{6((_;3t8FLrp=FZcD S4#?T^`Q;ysF!Temlk)%6zJ`4O From b8d273667fa51843683b0c7586e3c386ed37d9ad Mon Sep 17 00:00:00 2001 From: Kai Lauterbach Date: Thu, 20 Oct 2011 19:12:26 +0200 Subject: [PATCH 13/38] Formated only. --- doc/aufbauanleitung.txt | 145 +++++++++++++++++++++++++++++----------- 1 file changed, 107 insertions(+), 38 deletions(-) diff --git a/doc/aufbauanleitung.txt b/doc/aufbauanleitung.txt index feb87e8..020b00d 100644 --- a/doc/aufbauanleitung.txt +++ b/doc/aufbauanleitung.txt @@ -6,9 +6,14 @@ Zuvor sollte die Liste der Bauteile mit der in der Verpackung enthaltenen Anzahl Allgemeines zum Aufbau: ----------------------- -Begonnen wird mit dem Bauteil, dass die geringste Höhe nach dem Einlöten besitzt. Dies führt dazu , dass die höheren Bauteile beim Einlöten der anderen nicht im Weg sind. +Begonnen wird mit dem Bauteil, dass die geringste Höhe nach dem Einlöten besitzt. Dies führt dazu , dass die +höheren Bauteile beim Einlöten der anderen nicht im Weg sind. -Warnhinweise! Der Mikrocontroller wird erst nachdem die Schaltung komplett aufgebaut ist und optisch und elektrisch getestet wurde eingesetzt. Bevor der LEDCube an die Schaltung angeschlossen wird, muss der Mikrocontroller konfiguriert (FuseBits gesetzt) und programmiert werden. Zudem muss die Funktion der Firmware zwingend geprüft werden. Sollte ein Fehler in der Schaltung (Bauteile vertauscht, ungewollte Lötbrücken, etc.) oder in der Firmware vorhanden sein, können die LEDs des Cube irreparabel zerstört werden. +Warnhinweise! Der Mikrocontroller wird erst nachdem die Schaltung komplett aufgebaut ist und optisch und +elektrisch getestet wurde eingesetzt. Bevor der LEDCube an die Schaltung angeschlossen wird, muss der Mikrocontroller +konfiguriert (FuseBits gesetzt) und programmiert werden. Zudem muss die Funktion der Firmware zwingend geprüft werden. +Sollte ein Fehler in der Schaltung (Bauteile vertauscht, ungewollte Lötbrücken, etc.) oder in der Firmware vorhanden +sein, können die LEDs des Cube irreparabel zerstört werden. Werkzeuge/Hilfsmittel: ---------------------- @@ -26,22 +31,30 @@ Aufbau: D1,2 - 3V6 Zehner-Diode -Der schwarze Ring an den Zehner-Dioden kennzeichnen die Kathode. Es muss auf die korrekte Polung beim ein löten geachtet werden. Die Bauteile werden liegend eingebaut. +Der schwarze Ring an den Zehner-Dioden kennzeichnen die Kathode. Es muss auf die korrekte Polung beim ein löten +geachtet werden. Die Bauteile werden liegend eingebaut. -In Durchlass-Richtung funktionieren Z-Dioden wie eine normale Diode. In Sperr-Richtung dient sie zur Spannungsbegrenzung. In dieser Schaltung werden die beiden Z-Dioden in Sperr-Richtung betrieben. Sie dienen dazu die Spannungen an den beiden USB-Datenleitungen (D+ und D-) auf 3,3 Volt (von dem 5V Pegel des Mikrocontrollers) herab zu senken. Siehe http://vusb.wikidot.com/hardware (Solution B). +In Durchlass-Richtung funktionieren Z-Dioden wie eine normale Diode. In Sperr-Richtung dient sie zur Spannungsbegrenzung. +In dieser Schaltung werden die beiden Z-Dioden in Sperr-Richtung betrieben. Sie dienen dazu die Spannungen an den beiden +USB-Datenleitungen (D+ und D-) auf 3,3 Volt (von dem 5V Pegel des Mikrocontrollers) herab zu senken. +Siehe http://vusb.wikidot.com/hardware (Solution B). 2. Dioden D3,4 - 1n4148 -Auch hier kennzeichnet der schwarze Ring die Kathode und muss beim Einbau beachtet werden. Auch diese Dioden werden liegend eingebaut. +Auch hier kennzeichnet der schwarze Ring die Kathode und muss beim Einbau beachtet werden. Auch diese Dioden werden +liegend eingebaut. D3 dient als Verpolschutz an der Versorgungsklemme X2. -D4 verbindet den Ausgang des Spannungsreglers IC2 mit dessen Eingang. Hierdurch wird verhindert, dass am Ausgang eine höhere Spannung anliegen kann als am Eingang. Dieser Zustand kann zum zerstören des Spannungsreglers führen. +D4 verbindet den Ausgang des Spannungsreglers IC2 mit dessen Eingang. Hierdurch wird verhindert, dass am Ausgang +eine höhere Spannung anliegen kann als am Eingang. Dieser Zustand kann zum zerstören des Spannungsreglers führen. 3. IC-Sockel -Der Sockel für den IC1 - ATTINY2313. Es muss darauf geachtet werden, dass die Markierung für den ersten und letzten Pin (Ausbuchtung in Form eines Halbkreises am Sockel und Mikrocontroller) korrekt auf der Platine aufgesetzt wird und dass der Sockel eben auf der Platine auf sitzt. +Der Sockel für den IC1 - ATTINY2313. Es muss darauf geachtet werden, dass die Markierung für den ersten und +letzten Pin (Ausbuchtung in Form eines Halbkreises am Sockel und Mikrocontroller) korrekt auf der Platine aufgesetzt +wird und dass der Sockel eben auf der Platine auf sitzt. 4. Kondensatoren @@ -49,15 +62,18 @@ Alle Kondensatoren werden stehend eingel C1,2 - 27pF -Die Kondensatoren C1 und C2 werden dazu verwendet um das Quarz, dass den Mikrocontroller mit seinem Takt versorgt, in Schwingung zu versetzen. +Die Kondensatoren C1 und C2 werden dazu verwendet um das Quarz, dass den Mikrocontroller mit seinem Takt versorgt, +in Schwingung zu versetzen. C3,4,5 - 100nF -Diese sind Pufferkondensatoren und unterdrücken zum einen das rauschen der Versorgungsspannung(en) und stabilisieren diese zusätzlich auf einen möglichst konstanten Wert. +Diese sind Pufferkondensatoren und unterdrücken zum einen das rauschen der Versorgungsspannung(en) +und stabilisieren diese zusätzlich auf einen möglichst konstanten Wert. 5. Widerstände -Die Widerstände müssen alle stehend eingelötet werden. Die Widerstände sollten dabei möglichst so gesetzt werden, dass die sich gegenseitig wenig durch gegenseitiges berühren unter mechanischer Spannung stehen. +Die Widerstände müssen alle stehend eingelötet werden. Die Widerstände sollten dabei möglichst +so gesetzt werden, dass die sich gegenseitig wenig durch gegenseitiges berühren unter mechanischer Spannung stehen. R3,4 - 69 Ohm Farbcode: Blau, Weiß, Schwarz, Gold @@ -65,25 +81,37 @@ Funktionieren mit den Z-Dioden als Spannungsbegrenzung. R2 - 1,5k Ohm Farbcode: Braun,Grün,Rot,Gold -R2 ist ein PullUp-Widerstand, für die D+-Datenleitung. Ein PullUp-Widerstand +R2 ist ein PullUp-Widerstand, für die "D-"-Datenleitung. Ein PullUp-Widerstand hält eine Leitung auf einer konstanten Spannung. Hier auf ca. 3,3V da R2 und D2, wie oben beschrieben, die Spannung von 5V herunter begrenzen. R1 - 10k Ohm Farbcode: Braun,Schwarz,Orange,Gold -Der Widerstand R1 wird dazu verwendet um den RESET-Pin am Mikrocontroller konstant auf 5V zu halten (PullUp). Der RESET-Pin ist ein sogenannter ActiveLow-Pin und setzt den Mikrocontroller zurück sobald die an diesem anliegende Spannung einen bestimmten Grenzwert unterschreitet (Bei 5V TTL-Pegeln ca. 0,8V). TTL = Transistor-Transistor-Logik. +Der Widerstand R1 wird dazu verwendet um den RESET-Pin am Mikrocontroller konstant auf 5V +zu halten (PullUp). Der RESET-Pin ist ein sogenannter ActiveLow-Pin und setzt den Mikrocontroller +zurück sobald die an diesem anliegende Spannung einen bestimmten Grenzwert unterschreitet +(Bei 5V TTL-Pegeln ca. 0,8V). TTL = Transistor-Transistor-Logik. -R5 - 1M Ohm (optional) Farbcode: Braun,Braun,Grün,Gold +Da im ersten Schaltplan ein Fehler enthalten war, muss dieser wie folgt eingebaut werden: -Dieser Widerstand wird als PullDown betrieben. Er ist gegen Masse verbunden (Minus). Die "D-"-Leitung wird hiermit konstant auf 0V gehalten. +Die beiden Enden der Widerstände kommen jeweils in die Bohnung, die näher an der USB Buchse ist. +Die beiden anderen Bohnungen, die weiter von der USB Buchse entfernt sind bleiben leer. + +R5 - 1M Ohm Farbcode: Braun,Braun,Grün,Gold + +Dieser Widerstand darf NICHT eingebaut werden. Er verhindert, dass eine USB-Verbindung korrekt +aufgebaut werden kann. 6. Stecker -Diese Stecker sollten rechtwinklig (eben) auf der Platine aufgelötet werden. Die Stecker müssen so ausgerichtet sein, dass die schwarzen Leitungen alle näher beim Mikrocontroller aufgesteckt werden als die roten. +Diese Stecker sollten rechtwinklig (eben) auf der Platine aufgelötet werden. Die Stecker müssen +so ausgerichtet sein, dass die schwarzen Leitungen alle näher beim Mikrocontroller aufgesteckt +werden als die roten. SV1,2,3,4 - 3-Pin Stecker -Hier wird später der LED-Würfel angeschlossen. Die Einbaurichtung muss beachtet werden, da sonst die LEDs im Würfel nicht korrekt angesteuert werden. +Hier wird später der LED-Würfel angeschlossen. Die Einbaurichtung muss beachtet werden, da sonst +die LEDs im Würfel nicht korrekt angesteuert werden. An SV4 werden die Leitungen A,B,C ausgeführt, an SV1 die Leitungen 1,2,3 usw. @@ -93,7 +121,9 @@ Diese Stecker sollten rechtwinklig (eben) auf der Platine aufgel SV5 - 2x3Pin Stiftleiste -Die 6Pin Stiftleiste muss in 2 gleichgroße Teile getrennt werden. Über diesen 2x3 Pin Anschluss wird später der Mikrocontroller beschrieben. Die 6-Pin Buchse ist bei AVRs der Standard, um den ISP (= In System Programmer) daran anzuschließen. +Die 6Pin Stiftleiste muss in 2 gleichgroße Teile getrennt werden. Über diesen 2x3 Pin Anschluss +wird später der Mikrocontroller beschrieben. Die 6-Pin Buchse ist bei AVRs der Standard, um den +ISP (= In System Programmer) daran anzuschließen. 8. Anschlussklemme @@ -101,54 +131,77 @@ Diese Stecker sollten rechtwinklig (eben) auf der Platine aufgel X2 - Anschlussklemme -Diese Anschlussklemme kann dazu verwendet werden die Schaltung und die LEDs mit Strom zu versorgen. Die maximale Eingangsspannung sollte 5V nicht unterschreiten 12Volt nicht überschreiten. +Diese Anschlussklemme kann dazu verwendet werden die Schaltung und die LEDs mit Strom zu versorgen. +Die maximale Eingangsspannung sollte 5V nicht unterschreiten 12Volt nicht überschreiten. 9. Spannungsregler -Dieses Bauteil wird stehend aufgelötet. Es verbleibt eine Lücke von ca. 5mm zwischen Bauteil und Platine. Sieht man auf die flache Seite des Reglers während die Beine nach unten zeigen, dann entspricht das linke Bein dem Ausgang, das mittlere der Masse und das rechte dem Eingang. +Dieses Bauteil wird stehend aufgelötet. Es verbleibt eine Lücke von ca. 5mm zwischen Bauteil und Platine. +Sieht man auf die flache Seite des Reglers während die Beine nach unten zeigen, dann entspricht das linke +Bein dem Ausgang, das mittlere der Masse und das rechte dem Eingang. IC2 - 78L05 -Der 78L05 ist ein Festspannungsregler. Er wandelt die Eingangsspannung in eine feste Ausgangsspannung von +5V. Er benötigt am Ein- und Ausgang Kondensatoren um eine stabile und möglichst konstante Spannung zu erzeugen. Im Gegenteil zu einem 7805 Festspannungsregler kann der 78L05 einen maximalen Strom von 100mA liefern. +Der 78L05 ist ein Festspannungsregler. Er wandelt die Eingangsspannung in eine feste Ausgangsspannung +von +5V. Er benötigt am Ein- und Ausgang Kondensatoren um eine stabile und möglichst konstante Spannung +zu erzeugen. Im Gegenteil zu einem 7805 Festspannungsregler kann der 78L05 einen maximalen Strom von +100mA liefern. 10. Quarz -Auch dieses Bauteil wird stehend aufgelötet. Hier wird zwischen Bauteil und Platine möglichst kein platz frei gelassen. +Auch dieses Bauteil wird stehend aufgelötet. Hier wird zwischen Bauteil und Platine möglichst kein platz +frei gelassen. Q1 - 12 Mhz Quarz -Das Quarz wird dazu verwendet um den Mikrocontroller mit einem Takt von 12MHz zu betreiben. Der Quarz wird stets dicht am Mikrocontroller angebracht, um so den Takt nicht durch andere Komponenten zu verfälschen. +Das Quarz wird dazu verwendet um den Mikrocontroller mit einem Takt von 12MHz zu betreiben. Der Quarz +wird stets dicht am Mikrocontroller angebracht, um so den Takt nicht durch andere Komponenten zu verfälschen. 11. Elko -Um den Elko aufzubringen, muss bei diesem zunächst die Anschlüsse so umgebogen werden, dass dieser stehend aufgebracht werden kann (nur bei axialen Bauteilen notwendig). Bei einem Elko (Elektrolytkondensator) ist auf die Polung dessen zu achten! Die Kathode (minus) ist hier meist mit einem Streifen, einer Kerbe oder einem oder mehreren "-"-Symbolen gekennzeichnet bzw. einem Pfeil markiert. +Um den Elko aufzubringen, muss bei diesem zunächst die Anschlüsse so umgebogen werden, dass dieser +stehend aufgebracht werden kann (nur bei axialen Bauteilen notwendig). Bei einem Elko (Elektrolytkondensator) +ist auf die Polung dessen zu achten! Die Kathode (minus) ist hier meist mit einem Streifen, einer Kerbe oder +einem oder mehreren "-"-Symbolen gekennzeichnet bzw. einem Pfeil markiert. C6 - 4,7µF -Der Elko dient dazu um die Ausgangsspannung des Spannungsreglers weiter zu stabilisieren, zu filtern und bei Bedarf Stromspitzen auszugleichen. +Der Elko dient dazu um die Ausgangsspannung des Spannungsreglers weiter zu stabilisieren, zu filtern und bei +Bedarf Stromspitzen auszugleichen. 12. USB Buchse -Auch hier ist wieder darauf zu achten, dass die Buchse eben aufliegt. Es müssen alle Pins und die Verlängerungen des Gehäuses aufgelötet werden. Diese dienen dazu die mechanische Festigkeit zu verbessern. +Auch hier ist wieder darauf zu achten, dass die Buchse eben aufliegt. Es müssen alle Pins und die +Verlängerungen des Gehäuses aufgelötet werden. Diese dienen dazu die mechanische Festigkeit zu verbessern. X1 - USB Buchse -Die Schaltung kann auch per USB betrieben/mit Spannung versorgt werden. Die Kommunikation mit dem Mikrocontroller muss jedoch noch implementiert werden. +Die Schaltung kann auch per USB betrieben/mit Spannung versorgt werden. Die Kommunikation mit dem Mikrocontroller +muss jedoch noch implementiert werden. Inbetriebnahme: --------------- -Bevor die Schaltung in Betrieb genommen werden kann muss diese zunächst geprüft werden. Die folgenden Schritte beschreiben diesen Vorgang. Der IC1 (AVR) ist bei diesem Vorgang noch nicht auf der Platine aufgesteckt! +Bevor die Schaltung in Betrieb genommen werden kann muss diese zunächst geprüft werden. Die folgenden Schritte +beschreiben diesen Vorgang. Der IC1 (AVR) ist bei diesem Vorgang noch nicht auf der Platine aufgesteckt! 1. Optisch Prüfen und durchmessen -Die Lötstellen müssen allesamt einzeln darauf geprüft werden ob benachbarte Leiterbahnen unbeabsichtigt mit verbunden sind. Diese Verbindungen können vorsichtig mit dem Lötkolben (in Verbindung mit Entlötlitze oder einer Entlötpumpe) entfernt werden. +Die Lötstellen müssen allesamt einzeln darauf geprüft werden ob benachbarte Leiterbahnen unbeabsichtigt +mit verbunden sind. Diese Verbindungen können vorsichtig mit dem Lötkolben (in Verbindung mit Entlötlitze +oder einer Entlötpumpe) entfernt werden. -Sind keine solchen Verbindungen zu erkennen kann als nächstes mit einem Multimeter der Durchgang der einzelnen Lötstellen zu den im Schaltplan vorgesehenen anderen Lötstellen durchgemessen werden. Es empfiehlt sich auch die Leiterbahnen untereinander zu prüfen, die keine Verbindung haben sollten aber sehr nah beieinander liegen. Achtung, durch die Kondensatoren auf der Schaltung kann das Messgerät unter Umständen, zwischen manchen Leiterbahnen, kurz einen Durchgang anzeigen bzw. einen Ton von sich geben auch wenn keine direkte Verbindung vorhanden ist. +Sind keine solchen Verbindungen zu erkennen kann als nächstes mit einem Multimeter der Durchgang der einzelnen +Lötstellen zu den im Schaltplan vorgesehenen anderen Lötstellen durchgemessen werden. Es empfiehlt sich auch +die Leiterbahnen untereinander zu prüfen, die keine Verbindung haben sollten aber sehr nah beieinander liegen. +Achtung, durch die Kondensatoren auf der Schaltung kann das Messgerät unter Umständen, zwischen manchen +Leiterbahnen, kurz einen Durchgang anzeigen bzw. einen Ton von sich geben auch wenn keine direkte Verbindung vorhanden ist. 2. Testen der Spannungen -Ist die Schaltung geprüft kann nun eine externe Spannungsquelle (nicht USB) an die Schaltung über die Anschlussklemme X2 angeschlossen werden. Es sollte kein Kurzschluss entstehen. Wenn sich ein Kurzschluss abzeichnet muss die Schaltung nochmals geprüft werden. +Ist die Schaltung geprüft kann nun eine externe Spannungsquelle (nicht USB) an die Schaltung über die +Anschlussklemme X2 angeschlossen werden. Es sollte kein Kurzschluss entstehen. Wenn sich ein Kurzschluss +abzeichnet muss die Schaltung nochmals geprüft werden. Zu prüfen sind die folgenden Punkte: @@ -164,30 +217,46 @@ Pin 5 des ISP-Steckers ist mit Pin 1 des IC-Sockels verbunden 3. Mikrocontroller -Wenn die Schaltung erfolgreich getestet wurde, kann der ATTiny2313 eingesetzt werden (Schaltung Spannungsfrei). Darauf wird ein Programmiergerät an den ISP-Stecker angeschlossen und danach erst die Schaltung mit einer Spannungsquelle verbunden. Da die Schaltung bereits geprüft wurde, darf auch der USB-Stecker zur Versorgung verwendet werden. Im Git-Repository befindet sich im "firmware"-Verzeichnis (neben dem Sourcecode) ein Makefile, dass dazu verwendet werden kann um auf den AVR zuzugreifen. +Wenn die Schaltung erfolgreich getestet wurde, kann der ATTiny2313 eingesetzt werden (Schaltung Spannungsfrei). +Darauf wird ein Programmiergerät an den ISP-Stecker angeschlossen und danach erst die Schaltung mit einer Spannungsquelle +verbunden. Da die Schaltung bereits geprüft wurde, darf auch der USB-Stecker zur Versorgung verwendet werden. Im +Git-Repository befindet sich im "firmware"-Verzeichnis (neben dem Sourcecode) ein Makefile, dass dazu verwendet werden +kann um auf den AVR zuzugreifen. 3.1 Fuse-Bits setzen -Über die Fuse-Bits wird das grundlegende Verhalten des AVR festgelegt. Diese Bits werden beim ATTiny2313 durch 3 Byte repräsentiert (wir beachten nur die beiden nieder wertigen). Bei diesem Projekt beinhaltet das Byte mit niederer Wertigkeit (Lowbyte) den Hex-Wert 0xE4 und das höherwertige Byte den Wert 0xDF. -Die Standardeinstellungen des Lowbyte ist der Wert 0x64. Der Unterschied zu unseren Einstellungen ist, dass der Systemtakt durch 8 geteilt wird (es wird der interne 8MHz Oszillator verwendet). Mehr Details zu diesen Einstellungen können hier eingesehen werden. - http://www.engbedded.com/fusecalc/ +Über die Fuse-Bits wird das grundlegende Verhalten des AVR festgelegt. Diese Bits werden beim ATTiny2313 durch 3 Byte +repräsentiert (wir beachten nur die beiden nieder wertigen). Bei diesem Projekt beinhaltet das Byte mit niederer +Wertigkeit (Lowbyte) den Hex-Wert 0xE4 und das höherwertige Byte den Wert 0xDF. Die Standardeinstellungen des +Lowbyte ist der Wert 0x64. Der Unterschied zu unseren Einstellungen ist, dass der Systemtakt durch 8 geteilt wird +(es wird der interne 8MHz Oszillator verwendet). Mehr Details zu diesen Einstellungen können hier eingesehen werden. +- http://www.engbedded.com/fusecalc/ -Die Fuse-Bits können mit "make fuses" im AVR festgelegt werden. ACHTUNG!!! Falsch gesetzte Fuses könne dazu führen, dass der AVR nicht mehr per ISP programmiert und oder konfiguriert werden kann! Die Bits "RSTDISBL" und "SPIEN" sollten in der Standardeinstellung verbleiben. +Die Fuse-Bits können mit "make fuses" im AVR festgelegt werden. ACHTUNG!!! Falsch gesetzte Fuses könne dazu führen, +dass der AVR nicht mehr per ISP programmiert und oder konfiguriert werden kann! Die Bits "RSTDISBL" und "SPIEN" +sollten in der Standardeinstellung verbleiben. 3.2 AVR mit Firmware flashen -Sind die Fuses korrekt übertragen worden, kann die Firmware übertragen werden. Das Makefile beinhaltet bereits die Option "compile" zum kompilieren und "program" zum übertragen. Mit der Option "info" können weitere Informationen zum erzeugten Binary abgerufen werden. +Sind die Fuses korrekt übertragen worden, kann die Firmware übertragen werden. Das Makefile beinhaltet bereits die +Option "compile" zum kompilieren und "program" zum übertragen. Mit der Option "info" können weitere Informationen +zum erzeugten Binary abgerufen werden. Unter Umständen muss noch ein Reset der Schaltung durchgeführt werden, bevor die Firmware aktiv ist. -Achtung, die originale Firmware aus dem Projekt von Mosfetkiller beinhaltet keinen USB-Support und wird daher von keinem System als korrekt funktionierendes USB-Gerät erkannt. Es kann zu diversen Fehlermeldungen kommen, wenn die Schaltung per USB mit Spannung versorgt wird. +Achtung, die originale Firmware aus dem Projekt von Mosfetkiller beinhaltet keinen USB-Support und wird daher +von keinem System als korrekt funktionierendes USB-Gerät erkannt. Es kann zu diversen Fehlermeldungen kommen, +wenn die Schaltung per USB mit Spannung versorgt wird. 3.3 Testen der Fimware -In diesem Schritt soll die Firmware mit einem Multimeter getestet werden. Spannungen an den Steckverbindern SV1-4 geprüft werden. Es müssen die folgenden Eigenschaften geprüft werden: +In diesem Schritt soll die Firmware mit einem Multimeter getestet werden. Spannungen an den Steckverbindern SV1-4 +geprüft werden. Es müssen die folgenden Eigenschaften geprüft werden: die Spannungen zwischen den Pins an SV1-3 und den Pins von SV4 müssen deutlich geringer als 5V sein zwischen den Pins von SV4 zur Masse muss ebenfalls eine geringere Spannung als 5V gemessen werden können -+5V (z.B. dem Ausgang des Spannungsreglers) zu den Pins von SV1-3 muss ebenfalls eine geringere Spannung als +5V angezeigt werden ++5V (z.B. dem Ausgang des Spannungsreglers) zu den Pins von SV1-3 muss ebenfalls eine geringere Spannung als +5V +angezeigt werden Damit ist der Aufbau abgeschlossen und der LEDCube kann mit der Schaltung getestet werden. From db888252300fa9f028e6a6999d84157b81db2aa3 Mon Sep 17 00:00:00 2001 From: Kai Lauterbach Date: Sun, 23 Oct 2011 21:17:01 +0200 Subject: [PATCH 14/38] Unused resistor removed. --- doc/eagle-partlist.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/eagle-partlist.txt b/doc/eagle-partlist.txt index 9258714..c5cbf74 100644 --- a/doc/eagle-partlist.txt +++ b/doc/eagle-partlist.txt @@ -50,7 +50,6 @@ R1 10k R-EU_0204/2V 0204V rcl 1 R2 1k5 R-EU_0204/2V 0204V rcl 1 R3 69 R-EU_0204/2V 0204V rcl 1 R4 69 R-EU_0204/2V 0204V rcl 1 -R5 1M R-EU_0204/2V 0204V rcl 1 SV1 MA03-1 MA03-1 con-lstb 1 SV2 MA03-1 MA03-1 con-lstb 1 SV3 MA03-1 MA03-1 con-lstb 1 From 5335603b151d07df55e4d3650c5c261cd8102995 Mon Sep 17 00:00:00 2001 From: Aaron Mueller Date: Sun, 23 Oct 2011 21:43:54 +0200 Subject: [PATCH 15/38] Correct some lighting and make real LED models. --- editor/src/config.h | 6 +++++- editor/src/display.c | 32 ++++++++++++++++++++++---------- editor/src/main.c | 15 +++++++++------ 3 files changed, 36 insertions(+), 17 deletions(-) diff --git a/editor/src/config.h b/editor/src/config.h index 6f7c629..dfe7447 100644 --- a/editor/src/config.h +++ b/editor/src/config.h @@ -2,7 +2,7 @@ #define _CONFIG_H #define WINDOW_WIDTH 800 -#define WINDOW_HEIGHT 600 +#define WINDOW_HEIGHT 800 #define CUBE_SIZE 30 #define MOVE_SPEED 7 @@ -10,8 +10,12 @@ #define PI 3.1415926535897932 +#define TOP_ORIENTATION 1 +#define SIDE_ORIENTATION 2 + // Materials extern float ledOnMaterial[]; +extern float ledOffMaterial[]; extern float wireMaterial[]; extern float innerWireMaterial[]; diff --git a/editor/src/display.c b/editor/src/display.c index d2c7e49..d5ec987 100644 --- a/editor/src/display.c +++ b/editor/src/display.c @@ -5,21 +5,33 @@ #include "display.h" -void drawLEDCube() { +void drawLEDCube(orientation) { int x, y, z; + if (orientation == TOP_ORIENTATION) { + glRotatef(90, 2, 0, 0); + } + // LEDs - glMaterialfv(GL_FRONT, GL_DIFFUSE, ledOnMaterial); + glMaterialfv(GL_FRONT, GL_AMBIENT, ledOnMaterial); for (z=-10; z<=10; z+=10) // Ebene for (y=-10; y<=10; y+=10) // Zeile for (x=-10; x<=10; x+=10) { // Spalte + + // TODO: Test different colors + glMaterialfv(GL_FRONT, GL_AMBIENT, (z == 0 ? ledOnMaterial : ledOffMaterial)); + glPushMatrix(); - glTranslatef(x, y, z); - glutSolidSphere(1.0, 16, 16); - gluCylinder(quadric, 1.0, 1.0, 1.3, 16, 2); - //glTranslatef(x, y, z+0.8); - //gluCylinder(quadric, 1.3, 1.3, 0.2, 16, 2); - //gluDisk( + glTranslatef(x, y, z-0.8); + glutSolidSphere(1, 16, 16); + gluCylinder(quadric, 1, 1, 1.9, 16, 2); + + glTranslatef(0, 0, 1.9); + gluCylinder(quadric, 1.25, 1.25, 0.35, 16, 2); + + gluDisk(quadric, 0, 1.25, 16, 16); + glTranslatef(0, 0, 0.35); + gluDisk(quadric, 0, 1.25, 16, 16); glPopMatrix(); } @@ -27,7 +39,7 @@ void drawLEDCube() { // Wires for (y=-10; y<=10; y+=10) for (x=-10; x<=10; x+=10) { - glMaterialfv(GL_FRONT, GL_DIFFUSE, ((x == 0 || y == 0) ? innerWireMaterial : wireMaterial)); + glMaterialfv(GL_FRONT, GL_AMBIENT, ((x == 0 || y == 0) ? innerWireMaterial : wireMaterial)); // Front glBegin(GL_LINES); @@ -60,7 +72,7 @@ void display() { glLoadIdentity(); gluLookAt(lookX, eyeAngle, lookZ, 0, 0, 0, 0, 1, 0); - drawLEDCube(); + drawLEDCube(TOP_ORIENTATION); glutSwapBuffers(); } diff --git a/editor/src/main.c b/editor/src/main.c index 4ca1c76..d0f9eaf 100644 --- a/editor/src/main.c +++ b/editor/src/main.c @@ -8,12 +8,13 @@ #include "input.h" float ledOnMaterial[] = {0.0, 0.0, 1.0, 1.0}; +float ledOffMaterial[] = {0.1, 0.1, 0.1, 0.0}; + float wireMaterial[] = {0.7, 0.7, 0.7, 1.0}; float innerWireMaterial[] = {0.2, 0.2, 0.2, 0.3}; -float light_diffuse[] = {0.0, 0.0, 1.0, 1.0}; -float light_position[] = {1.0, 1.0, 1.0, 0.0}; - +float backgroundColor[] = {0.3, 0.3, 0.3, 0.4}; +float light0Pos[] = {70, 70, 70, 0.0}; float lookX = 0.0, lookZ = 0.0; float eyePos = 0.0, eyeAngle = 45.0; @@ -36,12 +37,14 @@ int main(int argc, char* argv[]) { glClearColor(0.0, 0.0, 0.0, 1.0); glShadeModel(GL_SMOOTH); - // OpenGL Features + // Lighting glEnable(GL_LIGHTING); - glEnable(GL_LIGHT0); - glEnable(GL_DEPTH_TEST); + glEnable(GL_LIGHT0); + glLightfv(GL_LIGHT0, GL_POSITION, light0Pos); + glLightfv(GL_LIGHT0, GL_AMBIENT, backgroundColor); + glMatrixMode(GL_MODELVIEW); moveCameraPosition(0); // Init the Position From 963a3e6063e8750cc7353f361daf174baac705dd Mon Sep 17 00:00:00 2001 From: Kai Lauterbach Date: Sat, 29 Oct 2011 21:55:19 +0200 Subject: [PATCH 16/38] Typo fixed. --- pcb/miniledcube.sch | Bin 309422 -> 309422 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/pcb/miniledcube.sch b/pcb/miniledcube.sch index 1eb2fdbf55ff55217c7263014010c30cd44d9894..716a8e920419152cdf56da6281091360befc1279 100644 GIT binary patch delta 10039 zcmZ9S349Ib{>C%&o9Kja#=bNX)E3DkVhJI#*rgGBY}x37D}olqKb*K#MTzCK292Pu z^(vKvQ*ICx4UvdSERERLn>hqk)oA|DFUfmvZ~OW5ywCUfJ?}f)`_4ILvZu7pp3*uk zwUls|k9}QSTx%%7%Jp?LJK>8qWig8v)OP8x*1kJ;#**_|&3!GKRin1YOk2Ndq3VER zrfdxXq*i-m-2rgn|9n%jTqgEXToxacUADMb|MgdY@URO1{9pY>PbJRZ`Ky0(S%v@X zul^423SY{q*e>>4YIY<+264!Jo3=BDqK|*2%|B+vW57k}!*4&V=~{<^o{`x7C#80utM5 zvR0<)hPhw0p;T+NQuu zg0}kT%3RSa$465Z2`KZ?Xf+ZRUtRe|m@&Q@?SVNJ=3!xG`fAE)0VPOWM55eRr((1# zVm)mGbqhU)j@Na1iS`M+Z*_|z|4?<5MY=|{en0_%CTOj3p0*x-7HSPW$WNyZXm7yV z;Ac@nM5i1-jUu>!Ks4H^@t!u_-$LV|L;ZD1LYoI~xxYo3D>`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--;P&A5fp z04|H6$@og&7ij5=w-`s7s!d`X4Q!skBky6{2CV5%xF_co4RnjH$32R%VK5bH?PK6I zkHPRmxQBNvuw^VZo=Ag)_9|lB#{tL0;qp3` z2GF!P7w+i$7*jW5?$1K0{;4jOhFkW61~Q5_V&cD#9=Ne@qvh!FpVeZ>Ov)x?)+2*k z`+*{RBSJCBKE^&?Qrl&ynnSx0!rgs@_9Ik^(9k@D3gx!8Qb-9 z8Pg^c{8?3_JR?Chfmt!jDvu?UniHUy~dc%I1Na%q4Hp`guUoCz#E#<|5%J&O5ib_gn> zgu)amftp!L_&elhDEBh#6g`3}JH_MagD`+L2p_hm$xm&S%$SH5`Rk(@gIvZN74#Zy zK&G;S`jPexXSM*loukoibQXyP7wGf2+uY4!X_JE=d!beEpZ{e)eCqekQStFg?~biE zn+?VwZg`O!@)_(hCSAmahCvixq~AJ>(re-9pZBKzRn+5n_+!$0~078!g+(1 zQUPiMf1&e@=@2acJD84b^6Oj#W!M~NSRXF%xUZv HZPfn*(BP|v From f5e5816444793f539d115fdb05d058c948b6eea4 Mon Sep 17 00:00:00 2001 From: Kai Lauterbach Date: Sun, 30 Oct 2011 19:09:20 +0100 Subject: [PATCH 17/38] iSome typo fixes and revision updates. --- doc/aufbauanleitung.txt | 2 +- pcb/miniledcube.brd | Bin 26279 -> 26796 bytes pcb/miniledcube.sch | Bin 309422 -> 310102 bytes 3 files changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/aufbauanleitung.txt b/doc/aufbauanleitung.txt index 020b00d..decaf09 100644 --- a/doc/aufbauanleitung.txt +++ b/doc/aufbauanleitung.txt @@ -1,4 +1,4 @@ -Mini LEDCube v0.2 cthn.de (Kai Lauterbach, Aaron Müller v0.1 - 02.10.2011) +Mini LEDCube v0.2 cthn.de (Kai Lauterbach, Aaron Müller v0.2 - 30.10.2011) ========================================================================== Zuvor sollte die Liste der Bauteile mit der in der Verpackung enthaltenen Anzahl verglichen werden. diff --git a/pcb/miniledcube.brd b/pcb/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#*BK#I@7VVWG4r?FW%1gn0NdHg6tYf0T zaWj5d{YTz-wu8VWGQQ{_mSS^jM{D0a_|LUKYgus1$wLcty From b2d11488fa1bd10d135581c273a4ac5d759376f7 Mon Sep 17 00:00:00 2001 From: Aaron Mueller Date: Sun, 30 Oct 2011 23:42:46 +0100 Subject: [PATCH 18/38] Strip the resulting binary to redurce some space --- editor/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/editor/Makefile b/editor/Makefile index e9e50d8..ef0f056 100644 --- a/editor/Makefile +++ b/editor/Makefile @@ -12,6 +12,7 @@ all: $(CC) $(CFLAGS) $(LIBS) -o ledcube-edit main.o display.o input.o chmod +x ledcube-edit + strip ledcube-edit clean: rm -f *.o From 37e885f02eae5a2f154b4ec1928803242771ee3d Mon Sep 17 00:00:00 2001 From: Aaron Mueller Date: Sun, 30 Oct 2011 23:55:53 +0100 Subject: [PATCH 19/38] Add the picking feature. We can now select a LED on the screen and get the index of the LED. To get the right index, we use the color picking technique mentioned in the OpenGL RedBook. This works suprisingly pretty well (and fast!). --- editor/src/config.h | 8 ++++++-- editor/src/display.c | 40 ++++++++++++++++++++++++++++++---------- editor/src/display.h | 7 ++++++- editor/src/input.c | 14 ++++++++++++++ editor/src/input.h | 2 ++ editor/src/main.c | 1 + 6 files changed, 59 insertions(+), 13 deletions(-) diff --git a/editor/src/config.h b/editor/src/config.h index dfe7447..6937709 100644 --- a/editor/src/config.h +++ b/editor/src/config.h @@ -10,8 +10,12 @@ #define PI 3.1415926535897932 -#define TOP_ORIENTATION 1 -#define SIDE_ORIENTATION 2 +// Poor Man's enums +#define TOP_ORIENTATION 0x01 +#define SIDE_ORIENTATION 0x02 + +#define RENDER_MODE 0x01 +#define PICKING_MODE 0x02 // Materials extern float ledOnMaterial[]; diff --git a/editor/src/display.c b/editor/src/display.c index d5ec987..11f1cf5 100644 --- a/editor/src/display.c +++ b/editor/src/display.c @@ -5,21 +5,23 @@ #include "display.h" -void drawLEDCube(orientation) { +void drawLEDs(int orientation, int mode) { int x, y, z; + int colorIndex = 0; if (orientation == TOP_ORIENTATION) { glRotatef(90, 2, 0, 0); } - // LEDs - glMaterialfv(GL_FRONT, GL_AMBIENT, ledOnMaterial); for (z=-10; z<=10; z+=10) // Ebene for (y=-10; y<=10; y+=10) // Zeile for (x=-10; x<=10; x+=10) { // Spalte - - // TODO: Test different colors - glMaterialfv(GL_FRONT, GL_AMBIENT, (z == 0 ? ledOnMaterial : ledOffMaterial)); + if (mode == PICKING_MODE) { + glColor3ub(0, 0, colorIndex*8); + colorIndex++; + } else { + glMaterialfv(GL_FRONT, GL_AMBIENT, (z == 0 ? ledOnMaterial : ledOffMaterial)); + } glPushMatrix(); glTranslatef(x, y, z-0.8); @@ -35,8 +37,10 @@ void drawLEDCube(orientation) { glPopMatrix(); } +} - // Wires +void drawWires() { + int x, y; for (y=-10; y<=10; y+=10) for (x=-10; x<=10; x+=10) { glMaterialfv(GL_FRONT, GL_AMBIENT, ((x == 0 || y == 0) ? innerWireMaterial : wireMaterial)); @@ -61,9 +65,8 @@ void drawLEDCube(orientation) { } } -void display() { +void setScene() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(ZOOM_LEVEL, WINDOW_WIDTH/WINDOW_HEIGHT, 1.0, 350.0); @@ -71,8 +74,25 @@ void display() { glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(lookX, eyeAngle, lookZ, 0, 0, 0, 0, 1, 0); +} - drawLEDCube(TOP_ORIENTATION); +// OpenGL Display function +void display() { + setScene(); + drawLEDs(TOP_ORIENTATION, RENDER_MODE); + drawWires(); glutSwapBuffers(); } +// Picking function +void displayPickingObjects() { + setScene(); + glDisable(GL_DITHER); + glDisable(GL_LIGHTING); + + drawLEDs(TOP_ORIENTATION, PICKING_MODE); + + glEnable(GL_LIGHTING); + glEnable(GL_DITHER); +} + diff --git a/editor/src/display.h b/editor/src/display.h index 079f5bc..99de370 100644 --- a/editor/src/display.h +++ b/editor/src/display.h @@ -2,8 +2,13 @@ #define _DISPLAY_H -void drawLEDCube(); +void drawLEDs(int orientation, int mode); +void drawWires(); + void display(); +void displayPickingObjects(); + +void setScene(); #endif diff --git a/editor/src/input.c b/editor/src/input.c index 8759e6c..0632dbb 100644 --- a/editor/src/input.c +++ b/editor/src/input.c @@ -4,6 +4,7 @@ #include "config.h" #include "input.h" +#include "display.h" void moveCameraPosition(float direction) { eyePos += direction; @@ -46,3 +47,16 @@ void keyboard_special(int key, int x, int y) { glutPostRedisplay(); } +void mouse(int button, int state, int x, int y) { + if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN) { + int viewport[4]; + GLubyte pixel[3]; + + displayPickingObjects(); + + glGetIntegerv(GL_VIEWPORT, viewport); + glReadPixels(x, viewport[3]-y, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, (void*)pixel); + printf("%d\n", pixel[2]/8); // Selected LED + } +} + diff --git a/editor/src/input.h b/editor/src/input.h index d3bc2b9..bb48fa1 100644 --- a/editor/src/input.h +++ b/editor/src/input.h @@ -7,5 +7,7 @@ void moveCameraAngle(float angle); void keyboard(unsigned char key, int x, int y); void keyboard_special(int key, int x, int y); +void mouse(int button, int state, int x, int y); + #endif diff --git a/editor/src/main.c b/editor/src/main.c index d0f9eaf..3a1861c 100644 --- a/editor/src/main.c +++ b/editor/src/main.c @@ -33,6 +33,7 @@ int main(int argc, char* argv[]) { glutDisplayFunc(display); glutKeyboardFunc(keyboard); glutSpecialFunc(keyboard_special); + glutMouseFunc(mouse); glClearColor(0.0, 0.0, 0.0, 1.0); glShadeModel(GL_SMOOTH); From 2694d9988f1051106c3fe860c4523dd41c0f1948 Mon Sep 17 00:00:00 2001 From: Aaron Mueller Date: Mon, 31 Oct 2011 00:25:07 +0100 Subject: [PATCH 20/38] Implement the LED voltage switch. LEDs can now be switched on or off with the mouse. The current state of the LEd cube is saved in a array which can be easily printed out to STDOUT. --- editor/src/config.h | 4 ++++ editor/src/display.c | 16 ++++++++-------- editor/src/display.h | 2 +- editor/src/input.c | 11 +++++++++-- editor/src/main.c | 16 +++++++++++----- 5 files changed, 33 insertions(+), 16 deletions(-) diff --git a/editor/src/config.h b/editor/src/config.h index 6937709..ae1ea1b 100644 --- a/editor/src/config.h +++ b/editor/src/config.h @@ -26,9 +26,13 @@ extern float innerWireMaterial[]; // Movement extern float lookX, lookZ; extern float eyePos, eyeAngle; +extern int ledOrientation; // Objects extern GLUquadricObj *quadric; +// LED data +extern int currentFrame[27]; + #endif diff --git a/editor/src/display.c b/editor/src/display.c index 11f1cf5..b009d74 100644 --- a/editor/src/display.c +++ b/editor/src/display.c @@ -5,22 +5,22 @@ #include "display.h" -void drawLEDs(int orientation, int mode) { +void drawLEDs(int mode) { int x, y, z; - int colorIndex = 0; + int ledIndex = 0; - if (orientation == TOP_ORIENTATION) { + if (ledOrientation == TOP_ORIENTATION) { glRotatef(90, 2, 0, 0); } for (z=-10; z<=10; z+=10) // Ebene for (y=-10; y<=10; y+=10) // Zeile for (x=-10; x<=10; x+=10) { // Spalte + ledIndex++; if (mode == PICKING_MODE) { - glColor3ub(0, 0, colorIndex*8); - colorIndex++; + glColor3ub(0, 0, ledIndex*8); } else { - glMaterialfv(GL_FRONT, GL_AMBIENT, (z == 0 ? ledOnMaterial : ledOffMaterial)); + glMaterialfv(GL_FRONT, GL_AMBIENT, (currentFrame[ledIndex-1] == 1 ? ledOnMaterial : ledOffMaterial)); } glPushMatrix(); @@ -79,7 +79,7 @@ void setScene() { // OpenGL Display function void display() { setScene(); - drawLEDs(TOP_ORIENTATION, RENDER_MODE); + drawLEDs(RENDER_MODE); drawWires(); glutSwapBuffers(); } @@ -90,7 +90,7 @@ void displayPickingObjects() { glDisable(GL_DITHER); glDisable(GL_LIGHTING); - drawLEDs(TOP_ORIENTATION, PICKING_MODE); + drawLEDs(PICKING_MODE); glEnable(GL_LIGHTING); glEnable(GL_DITHER); diff --git a/editor/src/display.h b/editor/src/display.h index 99de370..54e4cf2 100644 --- a/editor/src/display.h +++ b/editor/src/display.h @@ -2,7 +2,7 @@ #define _DISPLAY_H -void drawLEDs(int orientation, int mode); +void drawLEDs(int mode); void drawWires(); void display(); diff --git a/editor/src/input.c b/editor/src/input.c index 0632dbb..31cf7b5 100644 --- a/editor/src/input.c +++ b/editor/src/input.c @@ -6,6 +6,7 @@ #include "input.h" #include "display.h" + void moveCameraPosition(float direction) { eyePos += direction; if (eyePos > 360.0) eyePos = 0.0; @@ -49,14 +50,20 @@ void keyboard_special(int key, int x, int y) { void mouse(int button, int state, int x, int y) { if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN) { - int viewport[4]; + int position, viewport[4]; GLubyte pixel[3]; displayPickingObjects(); glGetIntegerv(GL_VIEWPORT, viewport); glReadPixels(x, viewport[3]-y, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, (void*)pixel); - printf("%d\n", pixel[2]/8); // Selected LED + position = ((int)pixel[2]/8)-1; // Selected LED + + printf("%d\n", position); + currentFrame[position] = currentFrame[position] == 0 ? 1 : 0; + printf("%d\n", currentFrame[position]); + + display(); } } diff --git a/editor/src/main.c b/editor/src/main.c index 3a1861c..83c5f2c 100644 --- a/editor/src/main.c +++ b/editor/src/main.c @@ -1,4 +1,3 @@ - #include #include #include @@ -7,28 +6,35 @@ #include "display.h" #include "input.h" + +// Materials float ledOnMaterial[] = {0.0, 0.0, 1.0, 1.0}; float ledOffMaterial[] = {0.1, 0.1, 0.1, 0.0}; - float wireMaterial[] = {0.7, 0.7, 0.7, 1.0}; float innerWireMaterial[] = {0.2, 0.2, 0.2, 0.3}; +// Colors float backgroundColor[] = {0.3, 0.3, 0.3, 0.4}; -float light0Pos[] = {70, 70, 70, 0.0}; +// Positions +float light0Pos[] = {70, 70, 70, 0.0}; float lookX = 0.0, lookZ = 0.0; float eyePos = 0.0, eyeAngle = 45.0; +int ledOrientation = TOP_ORIENTATION; +// Objects GLUquadricObj *quadric; -extern void moveCameraPosition(float direction); +// LED data +int currentFrame[27] = {0}; + int main(int argc, char* argv[]) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); glutInitWindowSize(WINDOW_WIDTH, WINDOW_HEIGHT); - glutCreateWindow("CTHN LEDCube Editor"); + glutCreateWindow("CTHN LEDCube Editor v0.1"); glutDisplayFunc(display); glutKeyboardFunc(keyboard); From 7cd1ac3d2e5f2774e27ddb8cec9d358154342413 Mon Sep 17 00:00:00 2001 From: Kai Lauterbach Date: Sat, 5 Nov 2011 16:49:02 +0100 Subject: [PATCH 21/38] Timer/Counter calculations to configure the new timing requirements. --- doc/timer_counter.ods | Bin 0 -> 13120 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 doc/timer_counter.ods diff --git a/doc/timer_counter.ods b/doc/timer_counter.ods new file mode 100644 index 0000000000000000000000000000000000000000..174281d79dcde4e1004c3938071aca831f24b71e GIT binary patch literal 13120 zcmeHuby$?m_cwxoG>CvmN{hhK9RkwQ-7K98vP(%xiIURN($d`}t#o&Hcjvnpk3P@O z=X-sx>;1j|y#x1h@60)$Ip@qUJNKE-%1Oc9eEyy; znOPY@oNSDMHa3=K20)0JH3(o2GGwp@g3Z7T);2~ULu&&&DMy1T+Mj8W}<4 z{)P#K`KvsF-U(ZSjLl5!Y`>v_nE_x35Ml?`2igL@>)pF|@0%@uDM4?j|DXpnFfg(- zg2Gta0u1bIZEuZmw6cVQk&{BawH*fb_61u0-JFNe)_kKBT%4YQJDpkC(AoY)v4^1*DUJ@+qCqyOwmj7lzs$_8R@C ztlp-)uw9_>a;NU)mc(<~YJo^4iv%bLXg{ZEULynJz4S~e8uBdHDX7~IWpzg7<}hh> z*+3OA)Fx1z(9kT|oMvHJ)^xtRRmGlOhN)C{M!P+J`WP)$8C4zwJNyihh8R}h+=Xe% zP`yYld(fr@*6;M8l5K`RXaSkl>OH_7K~;4qI#d8WTy4_j(A>i~ z*EwaCqsR`FR0~`9ntnGxZl^Q?r;`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{I?U!pC~_V{(ZH* x-IM()1kl6F-*;&L)ck!pxLu8Z6;1koS)1jg;1O=cFrh!}&?Wxx_DeD_{|9Wp`iTGl literal 0 HcmV?d00001 From d5941812cc3b06592d2ac589e81970611802ecd4 Mon Sep 17 00:00:00 2001 From: Kai Lauterbach Date: Sat, 5 Nov 2011 16:52:02 +0100 Subject: [PATCH 22/38] Changes from last meeting. --- firmware/main.c | 45 +++++++++++++++++---------------------------- firmware/main.h | 11 +++++------ 2 files changed, 22 insertions(+), 34 deletions(-) diff --git a/firmware/main.c b/firmware/main.c index bd7e764..8c8b8d3 100644 --- a/firmware/main.c +++ b/firmware/main.c @@ -23,6 +23,9 @@ int main(void) //wdt_reset(); // we are alive, so don't reset the µC usbPoll(); // keep connected + // hier pause einfügen + _delay_ms(50); // beispielsweise 50 ms => muss angepasst werden an usb kommunikation + } } @@ -43,9 +46,11 @@ void init() set_bit(TCCR1B, WGM12); // Animations-Geschwindigkeit + // (vergleichswert bei dem der Interrupt ausgelöst wird) OCR1AH = 0x01; OCR1AL = 0x00; + // anpassen auf reihenweise ausgabe clear_bit(TCCR1B, CS12); // Prescaler 64 set_bit(TCCR1B, CS11); set_bit(TCCR1B, CS10); @@ -54,38 +59,22 @@ void init() } // Interruptvektor von TIMER1 -SIGNAL(SIG_OUTPUT_COMPARE1A) +//SIGNAL(SIG_OUTPUT_COMPARE1A) // alte schreibweise +ISR (TIMER1_COMPA_vect) { - // Pixel multiplexen - for (uint8_t z = 0; z < 3; z++) - { - for (uint8_t y = 0; y < 3; y++) - { - for (uint8_t x = 0; x < 3; x++) - { - uint8_t n = z * 3 + x; + // Alle Pins von PORTD auf LOW setzen + // Höchstes Bit in PORTA auf 0 setzen (Leitung 9 für letzte Reihe) - // LED an - if (cube[x][y][z] == 1) - { - if (n < 8) clear_bit(PORTB, n); else clear_bit(PORTD, 6); - set_bit(PORTD, y + 3); - } - // ON-Time - sleep_nop(PIXEL_TON); + // bei cube_row_offset % 3 eine Ebene weiter schalten (ABC-Leitungen durch rotieren) + // bei Systemstart muss A aktiviert sein. - // LED aus - if (cube[x][y][z] == 1) - { - clear_bit(PORTD, y + 3); - if (n < 8) set_bit(PORTB, n); else set_bit(PORTD, 6); - } - // OFF-Time - sleep_nop(PIXEL_TOFF) - } - } - } + // bits der anzuzeigenden reihe auslesen (cube & (0b00000111 << cube_row_offset)) + // und in PORTD und Pin 8 von PORTA setzen + + // cube_row_offset += 3 // immer um 3 Bits weiter springen in 32Bit Variable + + // cube_row_offset auf 0 setzen wenn maximum überschritten (27-3 = 24) } diff --git a/firmware/main.h b/firmware/main.h index 72cd2ae..243866a 100644 --- a/firmware/main.h +++ b/firmware/main.h @@ -15,15 +15,14 @@ #include #include -//#include +#include //#include //#include -// Cube-Array -uint8_t cube[3][3][3]; -uint8_t buffer[3][3][3]; // Framebuffer - -volatile uint8_t frame_done = 0; +// Cube-Data +volatile uint32_t cube = 0x00000000; +// Bit Offset in Cube-Data +volatile uint8_t cube_row_offset = 0x00; // Prototypen void init(void); From 36e9290611cadc32bffc8d52c9494675836bc857 Mon Sep 17 00:00:00 2001 From: Kai Lauterbach Date: Sat, 5 Nov 2011 16:53:24 +0100 Subject: [PATCH 23/38] Missing description added. --- firmware/main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/firmware/main.c b/firmware/main.c index 8c8b8d3..083c55d 100644 --- a/firmware/main.c +++ b/firmware/main.c @@ -63,6 +63,7 @@ void init() ISR (TIMER1_COMPA_vect) { + // Vorgang für reihenweise Ausgabe. // Alle Pins von PORTD auf LOW setzen // Höchstes Bit in PORTA auf 0 setzen (Leitung 9 für letzte Reihe) From c10808004c50574a473c505fbd1fecec388fe43c Mon Sep 17 00:00:00 2001 From: Aaron Mueller Date: Tue, 8 Nov 2011 22:32:09 +0100 Subject: [PATCH 24/38] Start implementing the GUI for the 3D-LED-Cube --- editor/Makefile | 5 ++ editor/src/main_gui.c | 26 ++++++++++ editor/src/main_gui.ui | 111 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 142 insertions(+) create mode 100644 editor/src/main_gui.c create mode 100644 editor/src/main_gui.ui diff --git a/editor/Makefile b/editor/Makefile index ef0f056..4cc5fc2 100644 --- a/editor/Makefile +++ b/editor/Makefile @@ -2,6 +2,7 @@ CC=gcc CFLAGS=-Wall INCLUDES=-I/usr/include/GL LIBS=-lglut -lGLU -lGL -lm +GTKLIBS=`pkg-config --cflags --libs gtk+-2.0` -export-dynamic SRCDIR=src @@ -14,7 +15,11 @@ all: chmod +x ledcube-edit strip ledcube-edit +gui: + $(CC) $(CFLAGS) $(GTKLIBS) -o gui $(SRCDIR)/main_gui.c + clean: rm -f *.o + rm -f gui #rm -f ledcube-edit diff --git a/editor/src/main_gui.c b/editor/src/main_gui.c new file mode 100644 index 0000000..406f6c2 --- /dev/null +++ b/editor/src/main_gui.c @@ -0,0 +1,26 @@ +#include + +void on_window_destroy(GtkObject *object, gpointer userData) { + gtk_main_quit(); +} + +int main (int argc, char *argv[]) { + GtkBuilder *builder; + GtkWidget *window; + + gtk_set_locale(); + gtk_init(&argc, &argv); + + builder = gtk_builder_new(); + gtk_builder_add_from_file(builder, "src/main_gui.ui", NULL); + gtk_builder_connect_signals(builder, NULL); + window = GTK_WIDGET(gtk_builder_get_object(builder, "main_window")); + + g_object_unref(G_OBJECT(builder)); + + gtk_widget_show_all(window); + gtk_main(); + + return 0; +} + diff --git a/editor/src/main_gui.ui b/editor/src/main_gui.ui new file mode 100644 index 0000000..1e92e31 --- /dev/null +++ b/editor/src/main_gui.ui @@ -0,0 +1,111 @@ + + + + + + True + False + center-always + + + + True + + + True + + + True + both-horiz + + + True + 7 + + + True + + + + + False + True + + + + + True + Connect to cube + True + gtk-connect + + + False + True + + + + + True + + + False + True + + + + + True + toolbutton3 + True + gtk-add + + + False + True + + + + + True + toolbutton3 + True + gtk-delete + + + False + True + + + + + + + False + 0 + + + + + True + True + + + False + 1 + + + + + 500 + 500 + True + + + 2 + + + + + + From 53d8a976bf77df7238489adcc9e4d2c3f71559b8 Mon Sep 17 00:00:00 2001 From: Kai Lauterbach Date: Fri, 11 Nov 2011 19:32:43 +0100 Subject: [PATCH 25/38] Formatted... --- doc/timer_counter.ods | Bin 13120 -> 18759 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/doc/timer_counter.ods b/doc/timer_counter.ods index 174281d79dcde4e1004c3938071aca831f24b71e..cad1f8c5a6202831c49468d9b196480ea05f7906 100644 GIT binary patch delta 16119 zcmb`u19WFi(=Qs^wr$(S#I|ia|Ja!%6WbGGVtZoSwlT48p6A8)e&0Rou5;Hpz1Ch` ztGlaqb?v>oe^tA>$9(7qFubBHC>RmNAhA@?sC3mX_^F;GUrxZQ9~i)SRIHws)Oza$cM4n;IjY_Q#dK(WHH}>*!0VE zR(=bd4fy_}t@Y5}bBx6KxWedGlF>Wt?^(f&uvBV z%z{uQvER5sFQ@=|7@e4R^pPpdGViX~`A8*W<648z-)XAIX*$*rAWyn4+oEvQJb7_48WMJsv0icJeq!hyD4`VwCISh}z>nTB5LftX<*WyozMop7(3x-rM?-fPB&^-q`Iq=%iIy=;IQmArd28jED z@dDuFYfzxxx4Wz?)U4ua2a(g@5scdI<{HQop3*_>PcZ@+HdIb-%C@#Y^9-8mb9?dd zfj&ZiaJ_Sqs<81PoCr)fdXjysui$caN;395dY$tn(E!*5sfde>@ta;G?0;v0ZH zB346fX%xe1OYes_s8KkaZb_mbf@h{N6fujSSYVH}g=w^x<6}#zQVaY-7Mw@i8FuKJ zHXTL(#$JlVPE*y*!-HbHGw{`oR$+im^bOb%#OB_#1W-7dQN98=pXdfdu{9iWh_sm0 zG!Cqq=2^a7{6$rimXgx4^E(^#v>!lv!0O(hhPE3zq&=;AQ6Gq@CRMp=+N4Ou>E&XvSw7I# zz0DFxt3Y`2i%9F9X4w*nf##q5ic?q+ZVfeBe!k%6D5dQhQsUU=kd!?B&uRcp);3sS zo2p(mt91&#u(Us#6@ z1Ao`sPVWGv)2hBC{EFpHhbTZMG?GX;_&9C@h!oo_mG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Yx3^m$O|Wl-SA(*V#L#ecKfB1BXC1 zF&h$3ifQ!Uk-$WfC>z`|=`3*F-;HRHETX?M+N-MNyk0q~_yAbe#4Xc2sefLeoj+EqRWGU^aW@nvZFpGgU;ZzCO@J*$Rf2S1YjO#c{aPbHO(*HZFq_&c%3 zp#y>AByqD7fIcpil{QC ziAI%4{ToTc0lcbT3ks6RfqHm!)QmE$o*o{?8kl(lhP72{z)&flhLaOG$y>-ToF(Lk zP!CG$WBU8wuFJa>{r<#YJ-85xAM$ksCKc4{yWeim;MJdC^PCM>j}{ua-;?83ZGNHd zVi1SIb9H2YxeXX!H9l^s3HLTJ!jy!C${u{gKj!b&7WH0Cd%>}04~pHyL)e}^RmgTx zKsjX9p@y>J1K5jN;dLp2=qY&l-|I&0G_;VtS+49tIMAKHer$bBP-kBI8ABtGEn!ur zy>WCbPmk&Kq62Ev!cA^Iv`v{Z-^G1l{@KPk={=ut*^yj7gRIJh19=5X^vho4R@m*T z?jxMPG9BGL&stijtX%qtbWAPL{xtKV%Hs#3TS+n3d0^_;x}8q1ZkRQ+<(OE)${#B? zd?!l^UHC$f)gsXAr!UVYuMZ!I`2g2-lAEYh*Jpb<+LRW-yp%7gW=~riUICryHm;vi z4#HF4ey&?A%jU}e96_Nl&i=kp5OvL;@zgow-I;E0-NO9zqs2pB(@lx$`KCb9?B{1| zR!`wol`F`m)uxik&3egQP|Uvu{Bud{8jl1_dbogyRVYY_O3Le~02J{vD40D~l}sB7i`D zy}z&Y{iC$tfYss v?O^-^4g!(Bg09Gt{E_8BmK0u(1?nq7M5v;Gg!~r_=l8?&TdU`+f3^M}-%STB From 87535e87e7a814bdda3d550c4f2c243a6c2d3270 Mon Sep 17 00:00:00 2001 From: Kai Lauterbach Date: Tue, 29 Nov 2011 19:35:07 +0100 Subject: [PATCH 26/38] Just code formated. --- client/test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/test.c b/client/test.c index e94047c..493a6ef 100644 --- a/client/test.c +++ b/client/test.c @@ -92,7 +92,7 @@ int cnt, vid, pid; cnt = usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, CUSTOM_RQ_SET_STATUS, v, 0, buffer, 0, 5000); if (cnt < 0) { - if(usbOpenDevice(&handle, vid, vendor, pid, product, NULL, NULL, NULL) != 0){ + if (usbOpenDevice(&handle, vid, vendor, pid, product, NULL, NULL, NULL) != 0){ fprintf(stderr, "Could not find USB device \"%s\" with vid=0x%x pid=0x%x\n", product, vid, pid); exit(1); } From 58a7f128267c36d6bf06243dee752cf03bea3d56 Mon Sep 17 00:00:00 2001 From: klaute Date: Tue, 29 Nov 2011 23:48:54 +0100 Subject: [PATCH 27/38] Timer configured and first implementation of the ISR. --- firmware/main.c | 36 +++++++++++++++++++----------------- firmware/main.h | 4 ++-- firmware/usb.c | 4 ++-- firmware/usb.h | 8 ++++---- 4 files changed, 27 insertions(+), 25 deletions(-) diff --git a/firmware/main.c b/firmware/main.c index 083c55d..5855a1d 100644 --- a/firmware/main.c +++ b/firmware/main.c @@ -42,40 +42,42 @@ void init() // Timer-Interrupt "TIMER1" vorbereiten //cli(); // - set_bit(TIMSK, OCIE1A); - set_bit(TCCR1B, WGM12); + set_bit(TIMSK, OCIE1A); // Interrupt für ISR COMPA + set_bit(TCCR1B, WGM12); // Überlauf // Animations-Geschwindigkeit // (vergleichswert bei dem der Interrupt ausgelöst wird) - OCR1AH = 0x01; - OCR1AL = 0x00; + // 625d = 0x271 = 0b00000010, 0b01110001 + OCR1AH = 0b00000010; + OCR1AL = 0b01110001; // anpassen auf reihenweise ausgabe + // Vorteiler durch 64 (0x011) ----> CS12=0, CS11=1, CS10=1 clear_bit(TCCR1B, CS12); // Prescaler 64 set_bit(TCCR1B, CS11); set_bit(TCCR1B, CS10); - sei(); + + + sei(); // Set enable interrupt bit (Muss gesetzt werden damit es überhaupt aufgerufen wird) } // Interruptvektor von TIMER1 //SIGNAL(SIG_OUTPUT_COMPARE1A) // alte schreibweise ISR (TIMER1_COMPA_vect) { + // PORTD = __, 9, C, B, A,D+,D-,__ + PORTD &= 0b11000111; // Reset durch Bitmaske + PORTD |= ((1 << (cube_level))<< 3); // Level setzen (A=0, B=1, C=2) - // Vorgang für reihenweise Ausgabe. - // Alle Pins von PORTD auf LOW setzen - // Höchstes Bit in PORTA auf 0 setzen (Leitung 9 für letzte Reihe) + // PORTB = 1..8 + // 0 = leuchtet, 1 = leuchtet nicht (invertiert!) + PORTB = ~(cube & (0b11111111 << (cube_level*9))); - // bei cube_row_offset % 3 eine Ebene weiter schalten (ABC-Leitungen durch rotieren) - // bei Systemstart muss A aktiviert sein. - - // bits der anzuzeigenden reihe auslesen (cube & (0b00000111 << cube_row_offset)) - // und in PORTD und Pin 8 von PORTA setzen - - // cube_row_offset += 3 // immer um 3 Bits weiter springen in 32Bit Variable - - // cube_row_offset auf 0 setzen wenn maximum überschritten (27-3 = 24) + PORTD &= 0b10111111; // 7tes Bit löschen (9) + PORTD |= ~((cube & (1 << (cube_level*9+8))) << 6); + //cube_level++; + //if (cube_level > 2) cube_level = 0; } diff --git a/firmware/main.h b/firmware/main.h index 243866a..0cc7dc8 100644 --- a/firmware/main.h +++ b/firmware/main.h @@ -20,9 +20,9 @@ //#include // Cube-Data -volatile uint32_t cube = 0x00000000; +volatile uint32_t cube = 0x0000000F; // Aktuelle Frame // Bit Offset in Cube-Data -volatile uint8_t cube_row_offset = 0x00; +volatile uint8_t cube_level = 0; // Ebene // Prototypen void init(void); diff --git a/firmware/usb.c b/firmware/usb.c index 3915e30..dfaebf5 100644 --- a/firmware/usb.c +++ b/firmware/usb.c @@ -26,7 +26,7 @@ usbMsgLen_t usbFunctionSetup(uchar data[8]) if (rq->wIndex.bytes[0] == 2) cube[0][0][2] = 1; if (rq->wIndex.bytes[0] == 3) - cube[0][1][0] = 1;*/ + cube[0][1][0] = 1; if (rq->wIndex.bytes[0] == 0) x = rq->wValue.bytes[0]; @@ -39,7 +39,7 @@ usbMsgLen_t usbFunctionSetup(uchar data[8]) else if (rq->wIndex.bytes[0] == 3) cube[x][y][z] = rq->wValue.bytes[0]; - +*/ } else if ( rq->bRequest == CUSTOM_RQ_GET_STATUS ) { // Send one byte to the USB host. diff --git a/firmware/usb.h b/firmware/usb.h index f1e4c03..1142f12 100644 --- a/firmware/usb.h +++ b/firmware/usb.h @@ -55,13 +55,13 @@ PROGMEM char usbHidReportDescriptor[22] = { /* USB report descriptor */ void init_usb(void); -volatile uint8_t x; -volatile uint8_t y; -volatile uint8_t z; +//volatile uint8_t x; +//volatile uint8_t y; +//volatile uint8_t z; // usb buffer //extern uint8_t buffer[3][3][3]; // Framebuffer -extern uint8_t cube[3][3][3]; // Framebuffer +//extern uint8_t cube[3][3][3]; // Framebuffer #endif // __usb_h__ From 8a2a2d99edaae394ad16eaabab275b7b98dcd315 Mon Sep 17 00:00:00 2001 From: Kai Lauterbach Date: Tue, 29 Nov 2011 19:39:57 +0100 Subject: [PATCH 28/38] First implementation of the new ISR. --- firmware/main.c | 24 ++++++++++-------------- firmware/main.h | 2 +- firmware/usb.c | 13 +++++++------ firmware/usb.h | 7 ++++--- 4 files changed, 22 insertions(+), 24 deletions(-) diff --git a/firmware/main.c b/firmware/main.c index 083c55d..aec19ac 100644 --- a/firmware/main.c +++ b/firmware/main.c @@ -59,23 +59,19 @@ void init() } // Interruptvektor von TIMER1 -//SIGNAL(SIG_OUTPUT_COMPARE1A) // alte schreibweise ISR (TIMER1_COMPA_vect) { - // Vorgang für reihenweise Ausgabe. - // Alle Pins von PORTD auf LOW setzen - // Höchstes Bit in PORTA auf 0 setzen (Leitung 9 für letzte Reihe) - - // bei cube_row_offset % 3 eine Ebene weiter schalten (ABC-Leitungen durch rotieren) - // bei Systemstart muss A aktiviert sein. - - // bits der anzuzeigenden reihe auslesen (cube & (0b00000111 << cube_row_offset)) - // und in PORTD und Pin 8 von PORTA setzen - - // cube_row_offset += 3 // immer um 3 Bits weiter springen in 32Bit Variable - - // cube_row_offset auf 0 setzen wenn maximum überschritten (27-3 = 24) + PORTD &= 0xC7; // 0b11000111 + PORTD |= (1 << (cube_layer + 3)); // shift "1" to bit 3,4,5 in PortD + PORTB = ~(cube & (0xFF << (cube_layer * 9))); // set the lines 1 to 8 negated to the port b + PORTD = (~(cube & (1 << cube_layer * 9 + 8)) << 6) + | (PORTD & 0x7F); // 0b01111111 keep the ower 7 bits and set the 9. bit from the LEDCube data. + cube_layer++; + + if (cube_layer > 2) + cube_layer = 0; + } diff --git a/firmware/main.h b/firmware/main.h index 243866a..9479473 100644 --- a/firmware/main.h +++ b/firmware/main.h @@ -22,7 +22,7 @@ // Cube-Data volatile uint32_t cube = 0x00000000; // Bit Offset in Cube-Data -volatile uint8_t cube_row_offset = 0x00; +volatile uint8_t cube_layer = 0x00; // Prototypen void init(void); diff --git a/firmware/usb.c b/firmware/usb.c index 3915e30..6c5fddf 100644 --- a/firmware/usb.c +++ b/firmware/usb.c @@ -12,21 +12,22 @@ usbMsgLen_t usbFunctionSetup(uchar data[8]) { - usbRequest_t *rq = (void *)data; + usbRequest_t *rq = (void *)data; if ( (rq->bmRequestType & USBRQ_TYPE_MASK) == USBRQ_TYPE_VENDOR ) { if ( rq->bRequest == CUSTOM_RQ_SET_STATUS ) { - /*if (rq->wIndex.bytes[0] == 0) +/* + if (rq->wIndex.bytes[0] == 0) cube[0][0][0] = 1; if (rq->wIndex.bytes[0] == 1) cube[0][0][1] = 1; if (rq->wIndex.bytes[0] == 2) cube[0][0][2] = 1; if (rq->wIndex.bytes[0] == 3) - cube[0][1][0] = 1;*/ + cube[0][1][0] = 1; if (rq->wIndex.bytes[0] == 0) x = rq->wValue.bytes[0]; @@ -38,7 +39,7 @@ usbMsgLen_t usbFunctionSetup(uchar data[8]) z = rq->wValue.bytes[0]; else if (rq->wIndex.bytes[0] == 3) - cube[x][y][z] = rq->wValue.bytes[0]; + //cube[x][y][z] = rq->wValue.bytes[0]; } else if ( rq->bRequest == CUSTOM_RQ_GET_STATUS ) { // Send one byte to the USB host. @@ -48,7 +49,7 @@ usbMsgLen_t usbFunctionSetup(uchar data[8]) //return 1; // tell the driver to send 1 byte //return 0; // tell the driver to send 0 byte - +*/ } }else{ /* class requests USBRQ_HID_GET_REPORT and USBRQ_HID_SET_REPORT are @@ -69,7 +70,7 @@ void init_usb(void) usbDeviceDisconnect(); /* enforce re-enumeration, do this while interrupts are disabled! */ i = 0; - while(--i){ /* fake USB disconnect for > 250 ms */ + while(--i) { /* fake USB disconnect for > 250 ms */ //wdt_reset(); _delay_ms(1); //sleep_nop(255); diff --git a/firmware/usb.h b/firmware/usb.h index f1e4c03..5db1cec 100644 --- a/firmware/usb.h +++ b/firmware/usb.h @@ -55,13 +55,14 @@ PROGMEM char usbHidReportDescriptor[22] = { /* USB report descriptor */ void init_usb(void); -volatile uint8_t x; +/*volatile uint8_t x; volatile uint8_t y; -volatile uint8_t z; +volatile uint8_t z;*/ // usb buffer //extern uint8_t buffer[3][3][3]; // Framebuffer -extern uint8_t cube[3][3][3]; // Framebuffer +//extern uint8_t cube[3][3][3]; // Framebuffer +extern uint32_t cube; // Framebuffer #endif // __usb_h__ From a0ae46b6c3d140ac5731d93679d8df528863b5c1 Mon Sep 17 00:00:00 2001 From: Kai Lauterbach Date: Wed, 30 Nov 2011 00:16:21 +0100 Subject: [PATCH 29/38] Copied changes from USB branch. --- firmware/main.c | 36 +++++++++++++++++++++--------------- firmware/main.h | 4 ++-- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/firmware/main.c b/firmware/main.c index aec19ac..5855a1d 100644 --- a/firmware/main.c +++ b/firmware/main.c @@ -42,36 +42,42 @@ void init() // Timer-Interrupt "TIMER1" vorbereiten //cli(); // - set_bit(TIMSK, OCIE1A); - set_bit(TCCR1B, WGM12); + set_bit(TIMSK, OCIE1A); // Interrupt für ISR COMPA + set_bit(TCCR1B, WGM12); // Überlauf // Animations-Geschwindigkeit // (vergleichswert bei dem der Interrupt ausgelöst wird) - OCR1AH = 0x01; - OCR1AL = 0x00; + // 625d = 0x271 = 0b00000010, 0b01110001 + OCR1AH = 0b00000010; + OCR1AL = 0b01110001; // anpassen auf reihenweise ausgabe + // Vorteiler durch 64 (0x011) ----> CS12=0, CS11=1, CS10=1 clear_bit(TCCR1B, CS12); // Prescaler 64 set_bit(TCCR1B, CS11); set_bit(TCCR1B, CS10); - sei(); + + + sei(); // Set enable interrupt bit (Muss gesetzt werden damit es überhaupt aufgerufen wird) } // Interruptvektor von TIMER1 +//SIGNAL(SIG_OUTPUT_COMPARE1A) // alte schreibweise ISR (TIMER1_COMPA_vect) { + // PORTD = __, 9, C, B, A,D+,D-,__ + PORTD &= 0b11000111; // Reset durch Bitmaske + PORTD |= ((1 << (cube_level))<< 3); // Level setzen (A=0, B=1, C=2) - PORTD &= 0xC7; // 0b11000111 - PORTD |= (1 << (cube_layer + 3)); // shift "1" to bit 3,4,5 in PortD - PORTB = ~(cube & (0xFF << (cube_layer * 9))); // set the lines 1 to 8 negated to the port b - PORTD = (~(cube & (1 << cube_layer * 9 + 8)) << 6) - | (PORTD & 0x7F); // 0b01111111 keep the ower 7 bits and set the 9. bit from the LEDCube data. + // PORTB = 1..8 + // 0 = leuchtet, 1 = leuchtet nicht (invertiert!) + PORTB = ~(cube & (0b11111111 << (cube_level*9))); - cube_layer++; - - if (cube_layer > 2) - cube_layer = 0; - + PORTD &= 0b10111111; // 7tes Bit löschen (9) + PORTD |= ~((cube & (1 << (cube_level*9+8))) << 6); + + //cube_level++; + //if (cube_level > 2) cube_level = 0; } diff --git a/firmware/main.h b/firmware/main.h index 9479473..0cc7dc8 100644 --- a/firmware/main.h +++ b/firmware/main.h @@ -20,9 +20,9 @@ //#include // Cube-Data -volatile uint32_t cube = 0x00000000; +volatile uint32_t cube = 0x0000000F; // Aktuelle Frame // Bit Offset in Cube-Data -volatile uint8_t cube_layer = 0x00; +volatile uint8_t cube_level = 0; // Ebene // Prototypen void init(void); From 15c681c7e38f762fb416e98f01d3f3aca5b39911 Mon Sep 17 00:00:00 2001 From: Kai Lauterbach Date: Wed, 30 Nov 2011 19:21:11 +0100 Subject: [PATCH 30/38] A simple test program to simulate the bitshifting in the ISR. --- firmware/isr_test.c | 52 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 firmware/isr_test.c diff --git a/firmware/isr_test.c b/firmware/isr_test.c new file mode 100644 index 0000000..c77a6ab --- /dev/null +++ b/firmware/isr_test.c @@ -0,0 +1,52 @@ + +#include +#include +#include + +int main (void) +{ + int PORTD = 0xff; + int PORTB = 0xff; + int cube = 0x000001ff; + int cube_level = 0; + + char test[100]; + + int i = 0; + for (i = 0; i < 3; i++) + { + + printf("-----------------\ncube_level = %d\n",cube_level); + + printf("PORTD = 0x%2x\n", PORTD); + printf("PORTB = 0x%2x\n", PORTB); + + PORTD &= 0x87; // 0x87 = 0b10000111; // 7tes Bit löschen (Leitung 9) und alle Ebenen deaktivieren + + printf("& 0b10000111: PORTD = 0x%2x\n", PORTD); + + PORTD |= ((1 << cube_level)<< 3); // cube_level setzen (Ebene A=0, B=1, C=2) + + printf("Level festlegen: PORTD = 0x%2x\n", PORTD); + + int tmp = cube_level * 9; + + printf("8 Bits aus cube: PORTD = 0x%2x\n", ((~cube & (0xff << tmp)) >> tmp)); + // PORTB = 1..8 + // 0 = leuchtet, 1 = leuchtet nicht (invertiert!) + PORTB = ((~cube & (0xff << tmp)) >> tmp); + + printf("Pins1-8: PORTB = 0x%2x\n", PORTB); + + // PORTD &= 0b10111111; // bereits oben erledigt + PORTD |= (((~cube & (1 << (tmp+8))) >> (tmp+8)) << 6); + + printf("Pin9: PORTD = 0x%2x\n", PORTD); + + cube_level++; + if (cube_level > 2) cube_level = 0; + + } + +} + From 0a316aaed93caae9fcf01dd5be73c690a0f5d4bb Mon Sep 17 00:00:00 2001 From: Kai Lauterbach Date: Wed, 30 Nov 2011 20:45:22 +0100 Subject: [PATCH 31/38] First working version of the ISR to control the LEDs. --- firmware/globals.h | 4 ---- firmware/main.c | 44 +++++++++++++++++++++++++++++++++++--------- firmware/main.h | 4 +++- 3 files changed, 38 insertions(+), 14 deletions(-) diff --git a/firmware/globals.h b/firmware/globals.h index b3827b0..1bb565a 100644 --- a/firmware/globals.h +++ b/firmware/globals.h @@ -8,10 +8,6 @@ #define FALSE 0 #define TRUE 1 -// Definitionen -#define PIXEL_TON 30 -#define PIXEL_TOFF 10 - #define sleep_nop(cnt) for (uint8_t i = 0; i < cnt; i++) { asm volatile("nop"::); } // Pixelmakros diff --git a/firmware/main.c b/firmware/main.c index 5855a1d..e8588e4 100644 --- a/firmware/main.c +++ b/firmware/main.c @@ -16,6 +16,8 @@ int main(void) init(); init_usb(); + uint8_t anim = 0; + // Hauptschleife //while (1) for (;;) @@ -26,6 +28,19 @@ int main(void) // hier pause einfügen _delay_ms(50); // beispielsweise 50 ms => muss angepasst werden an usb kommunikation + anim++; + + if (anim == 40) + { + if (cube == 0xffffffff) + cube = 0x07007007; + else if (cube == 0x07007007) + cube = 0x00000000; + else if (cube == 0x00000000) + cube = 0xffffffff; + anim = 0; + } + } } @@ -36,8 +51,8 @@ void init() DDRB = 0b11111111; // PB0-PB7: LED 1-8 (Kathoden) PORTB = 0b11111111; // HIGH - DDRD = 0b1111000; // PD6: LED 9 (Kathode); PD5-PD3: A-C (Anoden) - PORTD = 0b1000000; + DDRD = 0b01111000; // PD6: LED 9 (Kathode); PD5-PD3: A-C (Anoden) + PORTD = 0b01000000; // Timer-Interrupt "TIMER1" vorbereiten //cli(); // @@ -67,17 +82,28 @@ void init() ISR (TIMER1_COMPA_vect) { // PORTD = __, 9, C, B, A,D+,D-,__ - PORTD &= 0b11000111; // Reset durch Bitmaske - PORTD |= ((1 << (cube_level))<< 3); // Level setzen (A=0, B=1, C=2) + PORTD &= 0b10000111; // 7tes Bit löschen (Leitung 9) und alle Ebenen deaktivieren + PORTD |= ((1 << cube_level) << 3); // cube_level setzen (Ebene A=0, B=1, C=2) + + uint32_t tmp = cube_level * 9; + uint32_t tmp1 = tmp + 8; // PORTB = 1..8 // 0 = leuchtet, 1 = leuchtet nicht (invertiert!) - PORTB = ~(cube & (0b11111111 << (cube_level*9))); + //PORTB = ~((uint32_t)(cube & (0b11111111 << tmp)) >> tmp); + //PORTB = ((uint32_t)(~cube & (uint32_t)(0xff << tmp)) >> tmp); + PORTB = ~((cube >> tmp) & 0xff); - PORTD &= 0b10111111; // 7tes Bit löschen (9) - PORTD |= ~((cube & (1 << (cube_level*9+8))) << 6); + // PORTD &= 0b10111111; // bereits oben erledigt + //PORTD |= ~(((uint32_t)(cube & (1 << (tmp+8))) >> (tmp+8)) << 6); + //PORTD |= (((~cube & (1 << tmp)) >> tmp) << 6); + if ( (((cube >> tmp) >> 8) & 0x01) == 1 ) + PORTD &= ~(1 << 6); + else + PORTD |= (1 << 6); + //PORTD |= (1 << 6); // test to always off - //cube_level++; - //if (cube_level > 2) cube_level = 0; + cube_level++; + if (cube_level > 2) cube_level = 0; } diff --git a/firmware/main.h b/firmware/main.h index 0cc7dc8..b11f28e 100644 --- a/firmware/main.h +++ b/firmware/main.h @@ -20,7 +20,9 @@ //#include // Cube-Data -volatile uint32_t cube = 0x0000000F; // Aktuelle Frame +//volatile uint32_t cube = 0x07007007; // Aktuelles Frame +volatile uint32_t cube = 0xffffffff; // Aktuelles Frame +//volatile uint32_t cube = 0x00000000; // Aktuelles Frame // Bit Offset in Cube-Data volatile uint8_t cube_level = 0; // Ebene From c175dc0ad82040aa569ba32e52549285cd804530 Mon Sep 17 00:00:00 2001 From: Kai Lauterbach Date: Wed, 30 Nov 2011 20:47:37 +0100 Subject: [PATCH 32/38] Some other files to ignore. --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index 2920d97..c84e492 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,7 @@ firmware/.dep *.lss *.s#* *.b#* +*.eep +*.map +*.sym + From 4697706a2c50f121a061434c89d4d9ea78858f0a Mon Sep 17 00:00:00 2001 From: Kai Lauterbach Date: Fri, 2 Dec 2011 10:08:28 +0100 Subject: [PATCH 33/38] First stable usb connection lsusb report. --- doc/lsusb.txt | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 doc/lsusb.txt diff --git a/doc/lsusb.txt b/doc/lsusb.txt new file mode 100644 index 0000000..3516739 --- /dev/null +++ b/doc/lsusb.txt @@ -0,0 +1,59 @@ + +Bus 002 Device 013: ID 16c0:05df VOTI +Device Descriptor: + bLength 18 + bDescriptorType 1 + bcdUSB 1.10 + bDeviceClass 0 (Defined at Interface level) + bDeviceSubClass 0 + bDeviceProtocol 0 + bMaxPacketSize0 8 + idVendor 0x16c0 VOTI + idProduct 0x05df + bcdDevice 1.00 + iManufacturer 1 CTHN.de + iProduct 2 MiniLEDCube + iSerial 0 + bNumConfigurations 1 + Configuration Descriptor: + bLength 9 + bDescriptorType 2 + wTotalLength 34 + bNumInterfaces 1 + bConfigurationValue 1 + iConfiguration 0 + bmAttributes 0x80 + (Bus Powered) + MaxPower 250mA + Interface Descriptor: + bLength 9 + bDescriptorType 4 + bInterfaceNumber 0 + bAlternateSetting 0 + bNumEndpoints 1 + bInterfaceClass 3 Human Interface Device + bInterfaceSubClass 0 No Subclass + bInterfaceProtocol 0 None + iInterface 0 + HID Device Descriptor: + bLength 9 + bDescriptorType 33 + bcdHID 1.01 + bCountryCode 0 Not supported + bNumDescriptors 1 + bDescriptorType 34 Report + wDescriptorLength 22 + Report Descriptors: + ** UNAVAILABLE ** + Endpoint Descriptor: + bLength 7 + bDescriptorType 5 + bEndpointAddress 0x81 EP 1 IN + bmAttributes 3 + Transfer Type Interrupt + Synch Type None + Usage Type Data + wMaxPacketSize 0x0008 1x 8 bytes + bInterval 10 +Device Status: 0x0000 + (Bus Powered) From 9a8082065a6c7cead2b734c908ef31b147848a99 Mon Sep 17 00:00:00 2001 From: Kai Lauterbach Date: Fri, 2 Dec 2011 14:45:07 +0100 Subject: [PATCH 34/38] Simple test. --- client/test.c | 51 +++++++++++++++------------------------------------ 1 file changed, 15 insertions(+), 36 deletions(-) diff --git a/client/test.c b/client/test.c index 493a6ef..15932c6 100644 --- a/client/test.c +++ b/client/test.c @@ -33,7 +33,7 @@ usb_dev_handle *handle = NULL; const unsigned char rawVid[2] = {USB_CFG_VENDOR_ID}, rawPid[2] = {USB_CFG_DEVICE_ID}; char vendor[] = {USB_CFG_VENDOR_NAME, 0}, product[] = {USB_CFG_DEVICE_NAME, 0}; char buffer[4]; -int cnt, vid, pid; +int vid, pid; usb_init(); @@ -67,43 +67,22 @@ int cnt, vid, pid; } #endif - int i,x,y,z,onoff = 0; - while (1) - { - onoff = (onoff == 0) ? 1 : 0; - for (x = 0; x <3; x++) - for (y = 0; y <3; y++) - for (z = 0; z <3; z++) - { - for (i = 0; i < 4; i++) - { - int v = 0; - if (i == 0) - v = x; - if (i == 1) - v = y; - if (i == 2) - v = z; - if (i == 3) - v = onoff; - cnt = -1; - do { - sleep(1); - cnt = usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, CUSTOM_RQ_SET_STATUS, v, 0, buffer, 0, 5000); - if (cnt < 0) - { - if (usbOpenDevice(&handle, vid, vendor, pid, product, NULL, NULL, NULL) != 0){ - fprintf(stderr, "Could not find USB device \"%s\" with vid=0x%x pid=0x%x\n", product, vid, pid); - exit(1); - } - } - } while (cnt < 0); + // int usb_control_msg(usb_dev_handle *dev, int requesttype, int request, int value, int index, char *bytes, int size, int timeout); + // 32 bit in 2 transmission + usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, CUSTOM_RQ_SET_STATUS, 0x7007, 0x1B, buffer, 0, 5000); + sleep(2); + usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, CUSTOM_RQ_SET_STATUS, 0x0700, 0x1C, buffer, 0, 5000); - } + // bitwise set/get + //usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, CUSTOM_RQ_SET_STATUS, 0, 25, buffer, 0, 5000); + sleep(2); - fprintf(stdout, "%d %d %d %d\n",x,y,z,onoff); - } - } + int i = 0; + for (i = 0; i < 27; i++) + usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, CUSTOM_RQ_SET_STATUS, 1, i, buffer, 0, 5000); + + for (i = 26; i >= 0; i--) + usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, CUSTOM_RQ_SET_STATUS, 0, i, buffer, 0, 5000); usb_close(handle); return 0; From 09f600f9e1de4c6f000473843ca42a16684ed646 Mon Sep 17 00:00:00 2001 From: Kai Lauterbach Date: Fri, 2 Dec 2011 14:47:59 +0100 Subject: [PATCH 35/38] First implementation of the USB communication. --- firmware/main.c | 37 ++++++++++++++++++++++++------------- firmware/main.h | 3 --- firmware/usb.c | 43 +++++++++++++++++++------------------------ firmware/usb.h | 6 +----- 4 files changed, 44 insertions(+), 45 deletions(-) diff --git a/firmware/main.c b/firmware/main.c index e8588e4..d6c05c7 100644 --- a/firmware/main.c +++ b/firmware/main.c @@ -16,7 +16,7 @@ int main(void) init(); init_usb(); - uint8_t anim = 0; + //uint8_t anim = 0; // Hauptschleife //while (1) @@ -28,9 +28,9 @@ int main(void) // hier pause einfügen _delay_ms(50); // beispielsweise 50 ms => muss angepasst werden an usb kommunikation - anim++; + /*anim++; - if (anim == 40) + if (anim >= 0) { if (cube == 0xffffffff) cube = 0x07007007; @@ -38,8 +38,18 @@ int main(void) cube = 0x00000000; else if (cube == 0x00000000) cube = 0xffffffff; - anim = 0; - } + + anim = 0; + }*/ + /*if (anim >= 40) + { + cube += 1; + + if (cube > 0x07ffffff) + cube = 0; + + anim = 0; + }*/ } } @@ -58,7 +68,7 @@ void init() //cli(); // set_bit(TIMSK, OCIE1A); // Interrupt für ISR COMPA - set_bit(TCCR1B, WGM12); // Überlauf + //set_bit(TCCR1B, WGM12); // Überlauf // Animations-Geschwindigkeit // (vergleichswert bei dem der Interrupt ausgelöst wird) @@ -68,11 +78,10 @@ void init() // anpassen auf reihenweise ausgabe // Vorteiler durch 64 (0x011) ----> CS12=0, CS11=1, CS10=1 - clear_bit(TCCR1B, CS12); // Prescaler 64 - set_bit(TCCR1B, CS11); - set_bit(TCCR1B, CS10); - - + //clear_bit(TCCR1B, CS12); // Prescaler 64 + //set_bit(TCCR1B, CS11); + //set_bit(TCCR1B, CS10); + TCCR1B |= (1 << CS11) | (1 << CS10) | (1 << WGM12); sei(); // Set enable interrupt bit (Muss gesetzt werden damit es überhaupt aufgerufen wird) } @@ -81,12 +90,12 @@ void init() //SIGNAL(SIG_OUTPUT_COMPARE1A) // alte schreibweise ISR (TIMER1_COMPA_vect) { - // PORTD = __, 9, C, B, A,D+,D-,__ + + // PORTD = __, 9, C, B, A,D+,D-,__ PORTD &= 0b10000111; // 7tes Bit löschen (Leitung 9) und alle Ebenen deaktivieren PORTD |= ((1 << cube_level) << 3); // cube_level setzen (Ebene A=0, B=1, C=2) uint32_t tmp = cube_level * 9; - uint32_t tmp1 = tmp + 8; // PORTB = 1..8 // 0 = leuchtet, 1 = leuchtet nicht (invertiert!) @@ -101,9 +110,11 @@ ISR (TIMER1_COMPA_vect) PORTD &= ~(1 << 6); else PORTD |= (1 << 6); + //PORTD |= (1 << 6); // test to always off cube_level++; if (cube_level > 2) cube_level = 0; + } diff --git a/firmware/main.h b/firmware/main.h index b11f28e..4453228 100644 --- a/firmware/main.h +++ b/firmware/main.h @@ -16,8 +16,6 @@ #include #include #include -//#include -//#include // Cube-Data //volatile uint32_t cube = 0x07007007; // Aktuelles Frame @@ -28,7 +26,6 @@ volatile uint8_t cube_level = 0; // Ebene // Prototypen void init(void); -void loop(uint8_t); extern void init_usb(void); extern void usbPoll(void); diff --git a/firmware/usb.c b/firmware/usb.c index 6c5fddf..045faef 100644 --- a/firmware/usb.c +++ b/firmware/usb.c @@ -19,29 +19,25 @@ usbMsgLen_t usbFunctionSetup(uchar data[8]) if ( rq->bRequest == CUSTOM_RQ_SET_STATUS ) { -/* - if (rq->wIndex.bytes[0] == 0) - cube[0][0][0] = 1; - if (rq->wIndex.bytes[0] == 1) - cube[0][0][1] = 1; - if (rq->wIndex.bytes[0] == 2) - cube[0][0][2] = 1; - if (rq->wIndex.bytes[0] == 3) - cube[0][1][0] = 1; + if ( rq->wIndex.bytes[0] == 27 ) + { + cube = (cube & (uint32_t)0xffff0000) | + rq->wValue.bytes[0] + + (rq->wValue.bytes[1] << 8); + } else if ( rq->wIndex.bytes[0] == 28 ) + { + cube = (cube & (uint32_t)0x0000ffff) | + ((uint32_t)(rq->wValue.bytes[0] + + (rq->wValue.bytes[1] << 8)) << 16); + } else if ( rq->wIndex.bytes[0] < 27 ) + { + if ( rq->wValue.bytes[0] == 1 ) + cube |= ((uint32_t)1 << rq->wIndex.bytes[0]); + else + cube &= ~((uint32_t)1 << rq->wIndex.bytes[0]); + } - if (rq->wIndex.bytes[0] == 0) - x = rq->wValue.bytes[0]; - - else if (rq->wIndex.bytes[0] == 1) - y = rq->wValue.bytes[0]; - - else if (rq->wIndex.bytes[0] == 2) - z = rq->wValue.bytes[0]; - - else if (rq->wIndex.bytes[0] == 3) - //cube[x][y][z] = rq->wValue.bytes[0]; - - } else if ( rq->bRequest == CUSTOM_RQ_GET_STATUS ) { + //} else if ( rq->bRequest == CUSTOM_RQ_GET_STATUS ) { // Send one byte to the USB host. //static uchar dataBuffer[1]; // buffer must stay valid when usbFunctionSetup returns @@ -49,9 +45,8 @@ usbMsgLen_t usbFunctionSetup(uchar data[8]) //return 1; // tell the driver to send 1 byte //return 0; // tell the driver to send 0 byte -*/ } - }else{ + //} else { /* class requests USBRQ_HID_GET_REPORT and USBRQ_HID_SET_REPORT are * not implemented since we never call them. The operating system * won't call them either because our descriptor defines no meaning. diff --git a/firmware/usb.h b/firmware/usb.h index 5db1cec..8e7fb82 100644 --- a/firmware/usb.h +++ b/firmware/usb.h @@ -55,14 +55,10 @@ PROGMEM char usbHidReportDescriptor[22] = { /* USB report descriptor */ void init_usb(void); -/*volatile uint8_t x; -volatile uint8_t y; -volatile uint8_t z;*/ - // usb buffer //extern uint8_t buffer[3][3][3]; // Framebuffer //extern uint8_t cube[3][3][3]; // Framebuffer -extern uint32_t cube; // Framebuffer +extern volatile uint32_t cube; // Framebuffer #endif // __usb_h__ From 28bd57a8fbca088b44cfbb9dc88d988ffc142490 Mon Sep 17 00:00:00 2001 From: Kai Lauterbach Date: Mon, 5 Dec 2011 19:14:06 +0100 Subject: [PATCH 36/38] Timeout reduced. --- client/test.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/client/test.c b/client/test.c index 15932c6..6e03b0b 100644 --- a/client/test.c +++ b/client/test.c @@ -69,20 +69,20 @@ int vid, pid; // int usb_control_msg(usb_dev_handle *dev, int requesttype, int request, int value, int index, char *bytes, int size, int timeout); // 32 bit in 2 transmission - usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, CUSTOM_RQ_SET_STATUS, 0x7007, 0x1B, buffer, 0, 5000); - sleep(2); - usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, CUSTOM_RQ_SET_STATUS, 0x0700, 0x1C, buffer, 0, 5000); + usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, CUSTOM_RQ_SET_STATUS, 0x7007, 0x1B, buffer, 0, 300); + //sleep(2); + usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, CUSTOM_RQ_SET_STATUS, 0x0700, 0x1C, buffer, 0, 300); // bitwise set/get //usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, CUSTOM_RQ_SET_STATUS, 0, 25, buffer, 0, 5000); - sleep(2); + sleep(5); int i = 0; for (i = 0; i < 27; i++) - usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, CUSTOM_RQ_SET_STATUS, 1, i, buffer, 0, 5000); + usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, CUSTOM_RQ_SET_STATUS, 1, i, buffer, 0, 300); for (i = 26; i >= 0; i--) - usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, CUSTOM_RQ_SET_STATUS, 0, i, buffer, 0, 5000); + usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, CUSTOM_RQ_SET_STATUS, 0, i, buffer, 0, 300); usb_close(handle); return 0; From 66c84c6415b2f0527ece8d4e3bfe632810f2e182 Mon Sep 17 00:00:00 2001 From: Kai Lauterbach Date: Mon, 5 Dec 2011 20:37:10 +0100 Subject: [PATCH 37/38] Some sleep call's added. --- client/test.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/client/test.c b/client/test.c index 6e03b0b..2d76f9e 100644 --- a/client/test.c +++ b/client/test.c @@ -79,10 +79,16 @@ int vid, pid; int i = 0; for (i = 0; i < 27; i++) + { usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, CUSTOM_RQ_SET_STATUS, 1, i, buffer, 0, 300); + sleep(1); + } for (i = 26; i >= 0; i--) + { usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, CUSTOM_RQ_SET_STATUS, 0, i, buffer, 0, 300); + sleep(1); + } usb_close(handle); return 0; From f8242b9ae37f97e6c95392d1b449933e9390bcac Mon Sep 17 00:00:00 2001 From: Kai Lauterbach Date: Mon, 5 Dec 2011 22:17:00 +0100 Subject: [PATCH 38/38] Delay call from mainloop removed because of faster usb communication. --- firmware/globals.h | 27 +-------------------------- firmware/main.c | 2 +- 2 files changed, 2 insertions(+), 27 deletions(-) diff --git a/firmware/globals.h b/firmware/globals.h index 1bb565a..cddcba7 100644 --- a/firmware/globals.h +++ b/firmware/globals.h @@ -1,33 +1,8 @@ #define F_CPU 12000000UL -// Bitpopelei +// Bitshifting #define set_bit(var, bit) ((var) |= (1 << (bit))) #define clear_bit(var, bit) ((var) &= (unsigned)~(1 << (bit))) -// Bool -#define FALSE 0 -#define TRUE 1 - #define sleep_nop(cnt) for (uint8_t i = 0; i < cnt; i++) { asm volatile("nop"::); } -// Pixelmakros -#define PSET(x,y,z) (0b01000000 | ((z * 3 + x) + y * 9)) -#define PCLEAR(x,y,z) (0b00000000 | ((z * 3 + x) + y * 9)) - -// Instructions -#define CLEAR 0b10000000 -#define SET 0b10010000 -#define FPS 0b10110000 -#define NEXT 0b11110000 - -// Variablen -#define VAR_FPS 0 - -// Für CLEAR und SET -#define CLEAR_ALL 0 -#define SET_ALL 0 - -// Für NEXT -#define JUMP_FORWARD 1 -#define JUMP_BACKWARD 2 - diff --git a/firmware/main.c b/firmware/main.c index d6c05c7..62ec55c 100644 --- a/firmware/main.c +++ b/firmware/main.c @@ -26,7 +26,7 @@ int main(void) usbPoll(); // keep connected // hier pause einfügen - _delay_ms(50); // beispielsweise 50 ms => muss angepasst werden an usb kommunikation + //_delay_ms(1); // beispielsweise 50 ms => muss angepasst werden an usb kommunikation /*anim++;