Compare commits
131 Commits
asciiclean
...
debug
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
50886c58bd | ||
|
|
fc785d3ec8 | ||
|
|
cc54fb9f61 | ||
|
|
daae8ef051 | ||
|
|
811b82616e | ||
|
|
8e6c67db08 | ||
|
|
accdf39f18 | ||
|
|
0b12206f1d | ||
|
|
e4e4beac3a | ||
|
|
36d6899692 | ||
|
|
1f6c710e9e | ||
|
|
b7b35800cc | ||
|
|
a9640af2bf | ||
|
|
b6956c8fbd | ||
|
|
d727e978be | ||
|
|
128c27d441 | ||
|
|
08e6710321 | ||
|
|
bc25723df0 | ||
|
|
ce712477fe | ||
|
|
4a0461987b | ||
|
|
8b10ccc7de | ||
|
|
c24d6ceb81 | ||
|
|
1b2b7ecbed | ||
|
|
465ea1fbfe | ||
|
|
b8bd7acfa3 | ||
|
|
6a8e8e4692 | ||
|
|
6b8a6babb7 | ||
|
|
d65a17184f | ||
|
|
b443d3df2f | ||
|
|
4f8e258710 | ||
|
|
c4631f2991 | ||
|
|
f3cc60e77b | ||
|
|
989b738c49 | ||
|
|
0fc0500cc6 | ||
|
|
086f77b551 | ||
|
|
925c54a9c6 | ||
|
|
b2c644b6e7 | ||
|
|
9991dfa249 | ||
|
|
396729e2e2 | ||
|
|
622841e70a | ||
|
|
1100333487 | ||
|
|
4ea1912318 | ||
|
|
c30e626a3f | ||
|
|
66a592eeff | ||
|
|
a4751edf97 | ||
|
|
7bdc299e61 | ||
|
|
8299d3d581 | ||
|
|
483c89c337 | ||
|
|
f832f0f72b | ||
|
|
8e1e5ea072 | ||
|
|
309e1062b9 | ||
|
|
cb0ea4f8c8 | ||
|
|
c1203c3519 | ||
|
|
4a61063406 | ||
|
|
641903c166 | ||
|
|
f5eb151288 | ||
|
|
74e238bdca | ||
|
|
19cc80e70d | ||
|
|
0b9ed151fa | ||
|
|
c1d066ae3c | ||
|
|
78a799d718 | ||
|
|
1ead73684d | ||
|
|
92c4e4d686 | ||
|
|
69182c85b0 | ||
|
|
53e0a0999e | ||
|
|
0a50554f4a | ||
|
|
3ecc61adf4 | ||
|
|
dfcf4016b1 | ||
|
|
515ed6dd27 | ||
|
|
4419128348 | ||
|
|
551ecb1915 | ||
|
|
ae0f35d746 | ||
|
|
4ec2da3a5c | ||
|
|
6b89029105 | ||
|
|
a64e9ebd7d | ||
|
|
6bab776497 | ||
|
|
7b98ebb480 | ||
|
|
2fd08d0df7 | ||
|
|
d69d2bf398 | ||
|
|
a9df4311b4 | ||
|
|
b6c8135749 | ||
|
|
23a5b777ec | ||
|
|
660767c464 | ||
|
|
0fd42d7b1d | ||
|
|
a6aade11c4 | ||
|
|
ce5d1de968 | ||
|
|
c8afff5630 | ||
|
|
efe6ba19c4 | ||
|
|
8929a96e6e | ||
|
|
5dd4904f9c | ||
|
|
aa649c89ee | ||
|
|
ef69ab4ab3 | ||
|
|
1075795ef4 | ||
|
|
c66828729f | ||
|
|
46a566ce14 | ||
|
|
ca2f62ee62 | ||
|
|
48b15ca792 | ||
|
|
7a878eab39 | ||
|
|
091b82a7ef | ||
|
|
1c30d3db56 | ||
|
|
9cf6eae076 | ||
|
|
67a25941a7 | ||
|
|
aedc6dab5b | ||
|
|
c40b9c32b6 | ||
|
|
59aad4c7a8 | ||
|
|
af48032798 | ||
|
|
d481bd5061 | ||
|
|
96c273fe89 | ||
|
|
25c1f38aed | ||
|
|
0693dbc933 | ||
|
|
500e6326c1 | ||
|
|
d229719d0c | ||
|
|
096ad71b4e | ||
|
|
aa29d483eb | ||
|
|
dc83f998c7 | ||
|
|
369667e154 | ||
|
|
4a083cbea3 | ||
|
|
edf204ac24 | ||
|
|
0c378a9f7c | ||
|
|
55e3468f74 | ||
|
|
78e9dce5ea | ||
|
|
eaf0bda3ee | ||
|
|
d58d3439ec | ||
|
|
b5f111fa41 | ||
|
|
6508530384 | ||
|
|
e4364eedb1 | ||
|
|
74312e08e1 | ||
|
|
09f42acfc8 | ||
|
|
70984ebd00 | ||
|
|
cafe5b8efd | ||
|
|
a1e89d9528 |
4
.ditz-config
Normal file
4
.ditz-config
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
--- !ditz.rubyforge.org,2008-03-06/config
|
||||||
|
name: David
|
||||||
|
email: david@optixx.org
|
||||||
|
issue_dir: bugs
|
||||||
6
.gitignore
vendored
6
.gitignore
vendored
@@ -21,3 +21,9 @@
|
|||||||
*.swc
|
*.swc
|
||||||
*.rom
|
*.rom
|
||||||
*.usage
|
*.usage
|
||||||
|
*.moc
|
||||||
|
*.obj
|
||||||
|
*.TMP
|
||||||
|
*.vfat
|
||||||
|
*.wla*
|
||||||
|
*.rcc
|
||||||
|
|||||||
107
avr/usbload/Makefile
Normal file
107
avr/usbload/Makefile
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
|
||||||
|
TTY = /dev/tty.PL2303-00002126
|
||||||
|
DEVICE = atmega644
|
||||||
|
F_CPU = 20000000 # in Hz
|
||||||
|
FUSE_L = 0xf7
|
||||||
|
FUSE_H = 0xd9
|
||||||
|
AVRDUDE = avrdude -c usbasp -p $(DEVICE)
|
||||||
|
|
||||||
|
CFLAGS = -Iusbdrv -I. -DDEBUG_LEVEL=0
|
||||||
|
#-std=gnu99
|
||||||
|
OBJECTS = usbdrv/usbdrv.o usbdrv/usbdrvasm.o usbdrv/oddebug.o main.o usb_bulk.o uart.o fifo.o sram.o crc.o debug.o dump.o
|
||||||
|
COMPILE = avr-gcc -Wall -Os -DF_CPU=$(F_CPU) $(CFLAGS) -mmcu=$(DEVICE)
|
||||||
|
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
# Fuse values for particular devices
|
||||||
|
##############################################################################
|
||||||
|
# If your device is not listed here, go to
|
||||||
|
# http://palmavr.sourceforge.net/cgi-bin/fc.cgi
|
||||||
|
# and choose options for external crystal clock and no clock divider
|
||||||
|
#
|
||||||
|
################################## ATMega644 ##################################
|
||||||
|
# ATMega644 FUSE_L (Fuse low byte):
|
||||||
|
# 0xf7 = 1 1 1 1 0 1 1 1
|
||||||
|
# ^ ^ \ / \--+--/
|
||||||
|
# | | | +------- CKSEL 3..0 (external >8M crystal)
|
||||||
|
# | | +--------------- SUT 1..0 (crystal osc, BOD enabled)
|
||||||
|
# | +------------------ BODEN (BrownOut Detector enabled)
|
||||||
|
# +-------------------- BODLEVEL (2.7V)
|
||||||
|
|
||||||
|
# ATMega644 FUSE_H (Fuse high byte):
|
||||||
|
# 0xd9 = 1 1 0 1 1 0 0 1
|
||||||
|
# ^ ^ ^ ^ ^ ^ ^------ BOOTSZ0
|
||||||
|
# | | | | | +-------- BOOTSZ1
|
||||||
|
# | | | | + --------- EESAVE (don't preserve EEPROM over chip erase)
|
||||||
|
# | | | +-------------- CKOPT (full output swing)
|
||||||
|
# | | +---------------- SPIEN (allow serial programming)
|
||||||
|
# | +------------------ WDTON (WDT not always on)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# symbolic targets:
|
||||||
|
help:
|
||||||
|
@echo "This Makefile has no default rule. Use one of the following:"
|
||||||
|
@echo "make hex ....... to build main.hex"
|
||||||
|
@echo "make program ... to flash fuses and firmware"
|
||||||
|
@echo "make fuse ...... to flash the fuses"
|
||||||
|
@echo "make flash ..... to flash the firmware (use this on metaboard)"
|
||||||
|
@echo "make clean ..... to delete objects and hex file"
|
||||||
|
|
||||||
|
all: hex
|
||||||
|
|
||||||
|
hex: main.hex
|
||||||
|
|
||||||
|
program: flash fuse
|
||||||
|
|
||||||
|
# rule for programming fuse bits:
|
||||||
|
fuse:
|
||||||
|
@[ "$(FUSE_H)" != "" -a "$(FUSE_L)" != "" ] || \
|
||||||
|
{ echo "*** Edit Makefile and choose values for FUSE_L and FUSE_H!"; exit 1; }
|
||||||
|
$(AVRDUDE) -U hfuse:w:$(FUSE_H):m -U lfuse:w:$(FUSE_L):m
|
||||||
|
|
||||||
|
# rule for uploading firmware:
|
||||||
|
flash: main.hex
|
||||||
|
$(AVRDUDE) -U flash:w:main.hex:i
|
||||||
|
|
||||||
|
# rule for deleting dependent files (those which can be built by Make):
|
||||||
|
clean:
|
||||||
|
rm -f main.hex main.lst main.obj main.cof main.list main.map main.eep.hex main.elf *.o usbdrv/*.o main.s usbdrv/oddebug.s usbdrv/usbdrv.s
|
||||||
|
|
||||||
|
# Generic rule for compiling C files:
|
||||||
|
.c.o:
|
||||||
|
$(COMPILE) -c $< -o $@
|
||||||
|
|
||||||
|
# Generic rule for assembling Assembler source files:
|
||||||
|
.S.o:
|
||||||
|
$(COMPILE) -x assembler-with-cpp -c $< -o $@
|
||||||
|
# "-x assembler-with-cpp" should not be necessary since this is the default
|
||||||
|
# file type for the .S (with capital S) extension. However, upper case
|
||||||
|
# characters are not always preserved on Windows. To ensure WinAVR
|
||||||
|
# compatibility define the file type manually.
|
||||||
|
|
||||||
|
# Generic rule for compiling C to assembler, used for debugging only.
|
||||||
|
.c.s:
|
||||||
|
$(COMPILE) -S $< -o $@
|
||||||
|
|
||||||
|
# file targets:
|
||||||
|
|
||||||
|
# Since we don't want to ship the driver multipe times, we copy it into this project:
|
||||||
|
usbdrv:
|
||||||
|
cp -r ../../../usbdrv .
|
||||||
|
|
||||||
|
main.elf: usbdrv $(OBJECTS) # usbdrv dependency only needed because we copy it
|
||||||
|
$(COMPILE) -o main.elf $(OBJECTS)
|
||||||
|
|
||||||
|
main.hex: main.elf
|
||||||
|
rm -f main.hex main.eep.hex
|
||||||
|
avr-objcopy -j .text -j .data -O ihex main.elf main.hex
|
||||||
|
avr-size main.hex
|
||||||
|
|
||||||
|
# debugging targets:
|
||||||
|
|
||||||
|
disasm: main.elf
|
||||||
|
avr-objdump -d main.elf
|
||||||
|
|
||||||
|
cpp:
|
||||||
|
$(COMPILE) -E main.c
|
||||||
35
avr/usbload/checksize
Normal file
35
avr/usbload/checksize
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Name: checksize
|
||||||
|
# Project: PowerSwitch/AVR-USB
|
||||||
|
# Author: Christian Starkjohann
|
||||||
|
# Creation Date: 2004-12-29
|
||||||
|
# Tabsize: 4
|
||||||
|
# Copyright: (c) 2005 OBJECTIVE DEVELOPMENT Software GmbH.
|
||||||
|
# Revision: $Id: checksize 83 2006-01-05 22:20:53Z cs $
|
||||||
|
|
||||||
|
error=0
|
||||||
|
codelimit=16384 # default value
|
||||||
|
datalimit=992 # default value; leave 32 bytes for stack
|
||||||
|
|
||||||
|
if [ $# -gt 1 ]; then
|
||||||
|
codelimit="$2"
|
||||||
|
fi
|
||||||
|
if [ $# -gt 2 ]; then
|
||||||
|
datalimit="$3"
|
||||||
|
fi
|
||||||
|
|
||||||
|
set -- `avr-size -d "$1" | awk '/[0-9]/ {print $1 + $2, $2 + $3, $2}'`
|
||||||
|
if [ $1 -gt $codelimit ]; then
|
||||||
|
echo "*** code size $1 exceeds limit of $codelimit"
|
||||||
|
error=1
|
||||||
|
else
|
||||||
|
echo "ROM: $1 bytes (data=$3)"
|
||||||
|
fi
|
||||||
|
if [ $2 -gt $datalimit ]; then
|
||||||
|
echo "*** data size $2 exceeds limit of $datalimit"
|
||||||
|
error=1
|
||||||
|
else
|
||||||
|
echo "RAM: $2 bytes"
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit $error
|
||||||
48
avr/usbload/commandline/Makefile
Normal file
48
avr/usbload/commandline/Makefile
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
# Name: Makefile
|
||||||
|
# Project: custom-class 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 = snesuploader
|
||||||
|
|
||||||
|
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)
|
||||||
286
avr/usbload/commandline/opendevice.c
Normal file
286
avr/usbload/commandline/opendevice.c
Normal file
@@ -0,0 +1,286 @@
|
|||||||
|
/*
|
||||||
|
* 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 <stdio.h>
|
||||||
|
#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 < rval; i++) {
|
||||||
|
if (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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* -------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
/* Name: opendevice.h
|
/* Name: opendevice.h
|
||||||
* Project: AVR-USB host-side library
|
* Project: V-USB host-side library
|
||||||
* Author: Christian Starkjohann
|
* Author: Christian Starkjohann
|
||||||
* Creation Date: 2008-04-10
|
* Creation Date: 2008-04-10
|
||||||
* Tabsize: 4
|
* Tabsize: 4
|
||||||
* Copyright: (c) 2008 by OBJECTIVE DEVELOPMENT Software GmbH
|
* Copyright: (c) 2008 by OBJECTIVE DEVELOPMENT Software GmbH
|
||||||
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
|
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
|
||||||
* This Revision: $Id: opendevice.h 692 2008-11-07 15:07:40Z cs $
|
* This Revision: $Id: opendevice.h 740 2009-04-13 18:23:31Z cs $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
BIN
avr/usbload/commandline/snesuploader
Executable file
BIN
avr/usbload/commandline/snesuploader
Executable file
Binary file not shown.
259
avr/usbload/commandline/snesuploader.c
Normal file
259
avr/usbload/commandline/snesuploader.c
Normal file
@@ -0,0 +1,259 @@
|
|||||||
|
/*
|
||||||
|
* Name: set-led.c Project: custom-class, a basic USB 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#define READ_BUFFER_SIZE 1024
|
||||||
|
#define SEND_BUFFER_SIZE 0x200
|
||||||
|
#define BUFFER_CRC (1024 * 32)
|
||||||
|
#define BANK_SIZE (1<<15)
|
||||||
|
#define BANK_SIZE_SHIFT 15
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <usb.h> /* this is libusb */
|
||||||
|
#include "opendevice.h" /* common code moved to separate module */
|
||||||
|
|
||||||
|
#include "../requests.h" /* custom request numbers */
|
||||||
|
#include "../usbconfig.h" /* device's VID/PID and names */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void dump_packet(uint32_t addr, uint32_t len, uint8_t * packet)
|
||||||
|
{
|
||||||
|
uint16_t i,
|
||||||
|
j;
|
||||||
|
uint16_t sum = 0;
|
||||||
|
uint8_t clear = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < len; i += 16) {
|
||||||
|
|
||||||
|
sum = 0;
|
||||||
|
for (j = 0; j < 16; j++) {
|
||||||
|
sum += packet[i + j];
|
||||||
|
}
|
||||||
|
if (!sum) {
|
||||||
|
clear = 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (clear) {
|
||||||
|
printf("*\n");
|
||||||
|
clear = 0;
|
||||||
|
}
|
||||||
|
printf("%08x:", addr + i);
|
||||||
|
for (j = 0; j < 16; j++) {
|
||||||
|
printf(" %02x", packet[i + j]);
|
||||||
|
}
|
||||||
|
printf(" |");
|
||||||
|
for (j = 0; j < 16; j++) {
|
||||||
|
if (packet[i + j] >= 33 && packet[i + j] <= 126)
|
||||||
|
printf("%c", packet[i + j]);
|
||||||
|
else
|
||||||
|
printf(".");
|
||||||
|
}
|
||||||
|
printf("|\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint16_t crc_xmodem_update(uint16_t crc, uint8_t data)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
crc = crc ^ ((uint16_t) data << 8);
|
||||||
|
for (i = 0; i < 8; i++) {
|
||||||
|
if (crc & 0x8000)
|
||||||
|
crc = (crc << 1) ^ 0x1021;
|
||||||
|
else
|
||||||
|
crc <<= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return crc;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t do_crc(uint8_t * data, uint16_t size)
|
||||||
|
{
|
||||||
|
uint16_t crc = 0;
|
||||||
|
uint16_t i;
|
||||||
|
for (i = 0; i < size; i++) {
|
||||||
|
crc = crc_xmodem_update(crc, data[i]);
|
||||||
|
}
|
||||||
|
return crc;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint16_t do_crc_update(uint16_t crc, uint8_t * data, uint16_t size)
|
||||||
|
{
|
||||||
|
uint16_t i;
|
||||||
|
for (i = 0; i < size; i++)
|
||||||
|
crc = crc_xmodem_update(crc, data[i]);
|
||||||
|
return crc;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void usage(char *name)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "usage:\n");
|
||||||
|
fprintf(stderr, " %s upload filename.. upload\n", name);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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};
|
||||||
|
int cnt,
|
||||||
|
vid,
|
||||||
|
pid;
|
||||||
|
int cnt_crc = 0;
|
||||||
|
uint8_t *read_buffer;
|
||||||
|
uint8_t *crc_buffer;
|
||||||
|
uint32_t addr = 0;
|
||||||
|
uint16_t addr_lo = 0;
|
||||||
|
uint16_t addr_hi = 0;
|
||||||
|
uint16_t step = 0;
|
||||||
|
uint16_t crc = 0;
|
||||||
|
uint8_t bank = 0;
|
||||||
|
FILE *fp;
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
printf("Open USB device \"%s\" with vid=0x%x pid=0x%x\n", product, vid,
|
||||||
|
pid);
|
||||||
|
if (strcasecmp(argv[1], "upload") == 0) {
|
||||||
|
if (argc < 3) { /* we need at least one argument */
|
||||||
|
usage(argv[0]);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
fp = fopen(argv[2], "r");
|
||||||
|
if (fp == NULL) {
|
||||||
|
fprintf(stderr, "Cannot open file %s ", argv[2]);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
read_buffer = (unsigned char *) malloc(READ_BUFFER_SIZE);
|
||||||
|
crc_buffer = (unsigned char *) malloc(BUFFER_CRC);
|
||||||
|
memset(crc_buffer, 0, BUFFER_CRC);
|
||||||
|
addr = 0x000000;
|
||||||
|
|
||||||
|
usb_control_msg(handle,
|
||||||
|
USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT,
|
||||||
|
USB_UPLOAD_INIT, BANK_SIZE_SHIFT , 0, NULL, 0, 5000);
|
||||||
|
|
||||||
|
|
||||||
|
while ((cnt = fread(read_buffer, READ_BUFFER_SIZE, 1, fp)) > 0) {
|
||||||
|
for (step = 0; step <= READ_BUFFER_SIZE; step += SEND_BUFFER_SIZE) {
|
||||||
|
addr_lo = addr & 0xffff;
|
||||||
|
addr_hi = (addr >> 16) & 0xff;
|
||||||
|
|
||||||
|
cnt = usb_control_msg(handle,
|
||||||
|
USB_TYPE_VENDOR | USB_RECIP_DEVICE |
|
||||||
|
USB_ENDPOINT_OUT, USB_UPLOAD_ADDR, addr_hi,
|
||||||
|
addr_lo, (char *) read_buffer + step,
|
||||||
|
SEND_BUFFER_SIZE, 5000);
|
||||||
|
if (addr%0x1000==0){
|
||||||
|
printf ("bank=0x%02x addr=0x%08x\n", bank, addr);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cnt < 0) {
|
||||||
|
fprintf(stderr, "USB error: %s\n", usb_strerror());
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
addr += SEND_BUFFER_SIZE;
|
||||||
|
}
|
||||||
|
dump_packet(0x00000,READ_BUFFER_SIZE, read_buffer);
|
||||||
|
memcpy(crc_buffer + cnt_crc, read_buffer, READ_BUFFER_SIZE);
|
||||||
|
cnt_crc += READ_BUFFER_SIZE;
|
||||||
|
if (cnt_crc >= READ_BUFFER_SIZE) {
|
||||||
|
crc = do_crc(crc_buffer, BANK_SIZE);
|
||||||
|
printf ("bank=0x%02x crc=0x%04x\n", bank, crc);
|
||||||
|
memset(crc_buffer, 0, BUFFER_CRC);
|
||||||
|
bank++;
|
||||||
|
cnt_crc = 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
cnt = usb_control_msg(handle,
|
||||||
|
USB_TYPE_VENDOR | USB_RECIP_DEVICE |
|
||||||
|
USB_ENDPOINT_OUT, USB_CRC, addr_hi, addr_lo, NULL,
|
||||||
|
0, 5000);
|
||||||
|
*/
|
||||||
|
cnt = usb_control_msg(handle,
|
||||||
|
USB_TYPE_VENDOR | USB_RECIP_DEVICE |
|
||||||
|
USB_ENDPOINT_OUT, USB_SNES_BOOT, 0, 0, NULL,
|
||||||
|
0, 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 if (strcasecmp(argv[1], "crc") == 0) {
|
||||||
|
/*
|
||||||
|
* if(argc < 2){ usage(argv[0]); exit(1); }
|
||||||
|
*/
|
||||||
|
addr = 0x000000;
|
||||||
|
addr_lo = addr & 0xffff;
|
||||||
|
addr_hi = (addr >> 16) & 0xff;
|
||||||
|
printf("Request CRC for Addr: 0x%06x\n", addr);
|
||||||
|
|
||||||
|
cnt = usb_control_msg(handle,
|
||||||
|
USB_TYPE_VENDOR | USB_RECIP_DEVICE |
|
||||||
|
USB_ENDPOINT_OUT, USB_CRC_ADDR, addr_hi, addr_lo,
|
||||||
|
NULL, (1 << 15) / 4, 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 {
|
||||||
|
usage(argv[0]);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
usb_close(handle);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
809
avr/usbload/commandline/snesuploader.ll
Normal file
809
avr/usbload/commandline/snesuploader.ll
Normal file
@@ -0,0 +1,809 @@
|
|||||||
|
; ModuleID = '/Users/david/Devel/arch/avr/code/snesram/poc/avr_usbload/commandline/snesuploader.c'
|
||||||
|
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
|
||||||
|
target triple = "i386-apple-darwin9"
|
||||||
|
%struct.__sFILE = type <{ i8*, i32, i32, i16, i16, %struct.__sbuf, i32, i8*, i32 (i8*)*, i32 (i8*, i8*, i32)*, i64 (i8*, i64, i32)*, i32 (i8*, i8*, i32)*, %struct.__sbuf, %struct.__sFILEX*, i32, [3 x i8], [1 x i8], %struct.__sbuf, i32, i64 }>
|
||||||
|
%struct.__sFILEX = type opaque
|
||||||
|
%struct.__sbuf = type <{ i8*, i32 }>
|
||||||
|
%struct.usb_dev_handle = type opaque
|
||||||
|
@"\01LC" = internal constant [3 x i8] c"*\0A\00" ; <[3 x i8]*> [#uses=1]
|
||||||
|
@"\01LC1" = internal constant [6 x i8] c"%08x:\00" ; <[6 x i8]*> [#uses=1]
|
||||||
|
@"\01LC2" = internal constant [6 x i8] c" %02x\00" ; <[6 x i8]*> [#uses=1]
|
||||||
|
@"\01LC3" = internal constant [3 x i8] c" |\00" ; <[3 x i8]*> [#uses=1]
|
||||||
|
@"\01LC4" = internal constant [3 x i8] c"%c\00" ; <[3 x i8]*> [#uses=1]
|
||||||
|
@"\01LC5" = internal constant [2 x i8] c".\00" ; <[2 x i8]*> [#uses=1]
|
||||||
|
@"\01LC6" = internal constant [3 x i8] c"|\0A\00" ; <[3 x i8]*> [#uses=1]
|
||||||
|
@__stderrp = external global %struct.__sFILE* ; <%struct.__sFILE**> [#uses=8]
|
||||||
|
@"\01LC7" = internal constant [55 x i8] c"Could not find USB device \22%s\22 with vid=0x%x pid=0x%x\0A\00" ; <[55 x i8]*> [#uses=1]
|
||||||
|
@"\01LC8" = internal constant [45 x i8] c"Open USB device \22%s\22 with vid=0x%x pid=0x%x\0A\00" ; <[45 x i8]*> [#uses=1]
|
||||||
|
@"\01LC9" = internal constant [7 x i8] c"upload\00" ; <[7 x i8]*> [#uses=1]
|
||||||
|
@"\01LC10" = internal constant [2 x i8] c"r\00" ; <[2 x i8]*> [#uses=1]
|
||||||
|
@"\01LC11" = internal constant [21 x i8] c"Cannot open file %s \00" ; <[21 x i8]*> [#uses=1]
|
||||||
|
@"\01LC12" = internal constant [70 x i8] c"Addr: 0x%06x Bank: 0x%02x HiAddr: 0x%02x LoAddr: 0x%04x Crc: 0x%04x\0A\00" ; <[70 x i8]*> [#uses=1]
|
||||||
|
@"\01LC13" = internal constant [15 x i8] c"USB error: %s\0A\00" ; <[15 x i8]*> [#uses=1]
|
||||||
|
@"\01LC14" = internal constant [25 x i8] c"only %d bytes received.\0A\00" ; <[25 x i8]*> [#uses=1]
|
||||||
|
@"\01LC15" = internal constant [4 x i8] c"crc\00" ; <[4 x i8]*> [#uses=1]
|
||||||
|
@"\01LC16" = internal constant [30 x i8] c"Request CRC for Addr: 0x%06x\0A\00" ; <[30 x i8]*> [#uses=1]
|
||||||
|
@"\01LC17" = internal constant [8 x i8] c"usage:\0A\00" ; <[8 x i8]*> [#uses=1]
|
||||||
|
@"\01LC18" = internal constant [31 x i8] c" %s upload filename.. upload\0A\00" ; <[31 x i8]*> [#uses=1]
|
||||||
|
|
||||||
|
define void @dump_packet(i32 %addr, i32 %len, i8* %packet) nounwind {
|
||||||
|
entry:
|
||||||
|
%addr.addr = alloca i32 ; <i32*> [#uses=2]
|
||||||
|
%len.addr = alloca i32 ; <i32*> [#uses=2]
|
||||||
|
%packet.addr = alloca i8* ; <i8**> [#uses=6]
|
||||||
|
%i = alloca i16, align 2 ; <i16*> [#uses=10]
|
||||||
|
%j = alloca i16, align 2 ; <i16*> [#uses=17]
|
||||||
|
%sum = alloca i16, align 2 ; <i16*> [#uses=5]
|
||||||
|
%clear = alloca i8, align 1 ; <i8*> [#uses=4]
|
||||||
|
store i32 %addr, i32* %addr.addr
|
||||||
|
store i32 %len, i32* %len.addr
|
||||||
|
store i8* %packet, i8** %packet.addr
|
||||||
|
store i16 0, i16* %sum
|
||||||
|
store i8 0, i8* %clear
|
||||||
|
store i16 0, i16* %i
|
||||||
|
br label %for.cond
|
||||||
|
|
||||||
|
for.cond: ; preds = %for.inc98, %entry
|
||||||
|
%tmp = load i16* %i ; <i16> [#uses=1]
|
||||||
|
%conv = zext i16 %tmp to i32 ; <i32> [#uses=1]
|
||||||
|
%tmp1 = load i32* %len.addr ; <i32> [#uses=1]
|
||||||
|
%cmp = icmp ult i32 %conv, %tmp1 ; <i1> [#uses=1]
|
||||||
|
br i1 %cmp, label %for.body, label %for.end103
|
||||||
|
|
||||||
|
for.body: ; preds = %for.cond
|
||||||
|
store i16 0, i16* %sum
|
||||||
|
store i16 0, i16* %j
|
||||||
|
br label %for.cond3
|
||||||
|
|
||||||
|
for.cond3: ; preds = %for.inc, %for.body
|
||||||
|
%tmp4 = load i16* %j ; <i16> [#uses=1]
|
||||||
|
%conv5 = zext i16 %tmp4 to i32 ; <i32> [#uses=1]
|
||||||
|
%cmp6 = icmp slt i32 %conv5, 16 ; <i1> [#uses=1]
|
||||||
|
br i1 %cmp6, label %for.body8, label %for.end
|
||||||
|
|
||||||
|
for.body8: ; preds = %for.cond3
|
||||||
|
%tmp9 = load i16* %sum ; <i16> [#uses=1]
|
||||||
|
%conv10 = zext i16 %tmp9 to i32 ; <i32> [#uses=1]
|
||||||
|
%tmp11 = load i16* %i ; <i16> [#uses=1]
|
||||||
|
%conv12 = zext i16 %tmp11 to i32 ; <i32> [#uses=1]
|
||||||
|
%tmp13 = load i16* %j ; <i16> [#uses=1]
|
||||||
|
%conv14 = zext i16 %tmp13 to i32 ; <i32> [#uses=1]
|
||||||
|
%add = add i32 %conv12, %conv14 ; <i32> [#uses=1]
|
||||||
|
%tmp15 = load i8** %packet.addr ; <i8*> [#uses=1]
|
||||||
|
%arrayidx = getelementptr i8* %tmp15, i32 %add ; <i8*> [#uses=1]
|
||||||
|
%tmp16 = load i8* %arrayidx ; <i8> [#uses=1]
|
||||||
|
%conv17 = zext i8 %tmp16 to i32 ; <i32> [#uses=1]
|
||||||
|
%add18 = add i32 %conv10, %conv17 ; <i32> [#uses=1]
|
||||||
|
%conv19 = trunc i32 %add18 to i16 ; <i16> [#uses=1]
|
||||||
|
store i16 %conv19, i16* %sum
|
||||||
|
br label %for.inc
|
||||||
|
|
||||||
|
for.inc: ; preds = %for.body8
|
||||||
|
%tmp20 = load i16* %j ; <i16> [#uses=1]
|
||||||
|
%inc = add i16 %tmp20, 1 ; <i16> [#uses=1]
|
||||||
|
store i16 %inc, i16* %j
|
||||||
|
br label %for.cond3
|
||||||
|
|
||||||
|
for.end: ; preds = %for.cond3
|
||||||
|
%tmp21 = load i16* %sum ; <i16> [#uses=1]
|
||||||
|
%tobool = icmp ne i16 %tmp21, 0 ; <i1> [#uses=1]
|
||||||
|
br i1 %tobool, label %if.end, label %if.then
|
||||||
|
|
||||||
|
if.then: ; preds = %for.end
|
||||||
|
store i8 1, i8* %clear
|
||||||
|
br label %for.inc98
|
||||||
|
|
||||||
|
if.end: ; preds = %for.end
|
||||||
|
%tmp22 = load i8* %clear ; <i8> [#uses=1]
|
||||||
|
%tobool23 = icmp ne i8 %tmp22, 0 ; <i1> [#uses=1]
|
||||||
|
br i1 %tobool23, label %if.then24, label %if.end25
|
||||||
|
|
||||||
|
if.then24: ; preds = %if.end
|
||||||
|
%call = call i32 (i8*, ...)* @printf(i8* getelementptr ([3 x i8]* @"\01LC", i32 0, i32 0)) ; <i32> [#uses=0]
|
||||||
|
store i8 0, i8* %clear
|
||||||
|
br label %if.end25
|
||||||
|
|
||||||
|
if.end25: ; preds = %if.then24, %if.end
|
||||||
|
%tmp26 = load i32* %addr.addr ; <i32> [#uses=1]
|
||||||
|
%tmp27 = load i16* %i ; <i16> [#uses=1]
|
||||||
|
%conv28 = zext i16 %tmp27 to i32 ; <i32> [#uses=1]
|
||||||
|
%add29 = add i32 %tmp26, %conv28 ; <i32> [#uses=1]
|
||||||
|
%call30 = call i32 (i8*, ...)* @printf(i8* getelementptr ([6 x i8]* @"\01LC1", i32 0, i32 0), i32 %add29) ; <i32> [#uses=0]
|
||||||
|
store i16 0, i16* %j
|
||||||
|
br label %for.cond31
|
||||||
|
|
||||||
|
for.cond31: ; preds = %for.inc47, %if.end25
|
||||||
|
%tmp32 = load i16* %j ; <i16> [#uses=1]
|
||||||
|
%conv33 = zext i16 %tmp32 to i32 ; <i32> [#uses=1]
|
||||||
|
%cmp34 = icmp slt i32 %conv33, 16 ; <i1> [#uses=1]
|
||||||
|
br i1 %cmp34, label %for.body36, label %for.end50
|
||||||
|
|
||||||
|
for.body36: ; preds = %for.cond31
|
||||||
|
%tmp37 = load i16* %i ; <i16> [#uses=1]
|
||||||
|
%conv38 = zext i16 %tmp37 to i32 ; <i32> [#uses=1]
|
||||||
|
%tmp39 = load i16* %j ; <i16> [#uses=1]
|
||||||
|
%conv40 = zext i16 %tmp39 to i32 ; <i32> [#uses=1]
|
||||||
|
%add41 = add i32 %conv38, %conv40 ; <i32> [#uses=1]
|
||||||
|
%tmp42 = load i8** %packet.addr ; <i8*> [#uses=1]
|
||||||
|
%arrayidx43 = getelementptr i8* %tmp42, i32 %add41 ; <i8*> [#uses=1]
|
||||||
|
%tmp44 = load i8* %arrayidx43 ; <i8> [#uses=1]
|
||||||
|
%conv45 = zext i8 %tmp44 to i32 ; <i32> [#uses=1]
|
||||||
|
%call46 = call i32 (i8*, ...)* @printf(i8* getelementptr ([6 x i8]* @"\01LC2", i32 0, i32 0), i32 %conv45) ; <i32> [#uses=0]
|
||||||
|
br label %for.inc47
|
||||||
|
|
||||||
|
for.inc47: ; preds = %for.body36
|
||||||
|
%tmp48 = load i16* %j ; <i16> [#uses=1]
|
||||||
|
%inc49 = add i16 %tmp48, 1 ; <i16> [#uses=1]
|
||||||
|
store i16 %inc49, i16* %j
|
||||||
|
br label %for.cond31
|
||||||
|
|
||||||
|
for.end50: ; preds = %for.cond31
|
||||||
|
%call51 = call i32 (i8*, ...)* @printf(i8* getelementptr ([3 x i8]* @"\01LC3", i32 0, i32 0)) ; <i32> [#uses=0]
|
||||||
|
store i16 0, i16* %j
|
||||||
|
br label %for.cond52
|
||||||
|
|
||||||
|
for.cond52: ; preds = %for.inc93, %for.end50
|
||||||
|
%tmp53 = load i16* %j ; <i16> [#uses=1]
|
||||||
|
%conv54 = zext i16 %tmp53 to i32 ; <i32> [#uses=1]
|
||||||
|
%cmp55 = icmp slt i32 %conv54, 16 ; <i1> [#uses=1]
|
||||||
|
br i1 %cmp55, label %for.body57, label %for.end96
|
||||||
|
|
||||||
|
for.body57: ; preds = %for.cond52
|
||||||
|
%tmp58 = load i16* %i ; <i16> [#uses=1]
|
||||||
|
%conv59 = zext i16 %tmp58 to i32 ; <i32> [#uses=1]
|
||||||
|
%tmp60 = load i16* %j ; <i16> [#uses=1]
|
||||||
|
%conv61 = zext i16 %tmp60 to i32 ; <i32> [#uses=1]
|
||||||
|
%add62 = add i32 %conv59, %conv61 ; <i32> [#uses=1]
|
||||||
|
%tmp63 = load i8** %packet.addr ; <i8*> [#uses=1]
|
||||||
|
%arrayidx64 = getelementptr i8* %tmp63, i32 %add62 ; <i8*> [#uses=1]
|
||||||
|
%tmp65 = load i8* %arrayidx64 ; <i8> [#uses=1]
|
||||||
|
%conv66 = zext i8 %tmp65 to i32 ; <i32> [#uses=1]
|
||||||
|
%cmp67 = icmp sge i32 %conv66, 33 ; <i1> [#uses=1]
|
||||||
|
br i1 %cmp67, label %land.lhs.true, label %if.else
|
||||||
|
|
||||||
|
land.lhs.true: ; preds = %for.body57
|
||||||
|
%tmp69 = load i16* %i ; <i16> [#uses=1]
|
||||||
|
%conv70 = zext i16 %tmp69 to i32 ; <i32> [#uses=1]
|
||||||
|
%tmp71 = load i16* %j ; <i16> [#uses=1]
|
||||||
|
%conv72 = zext i16 %tmp71 to i32 ; <i32> [#uses=1]
|
||||||
|
%add73 = add i32 %conv70, %conv72 ; <i32> [#uses=1]
|
||||||
|
%tmp74 = load i8** %packet.addr ; <i8*> [#uses=1]
|
||||||
|
%arrayidx75 = getelementptr i8* %tmp74, i32 %add73 ; <i8*> [#uses=1]
|
||||||
|
%tmp76 = load i8* %arrayidx75 ; <i8> [#uses=1]
|
||||||
|
%conv77 = zext i8 %tmp76 to i32 ; <i32> [#uses=1]
|
||||||
|
%cmp78 = icmp sle i32 %conv77, 126 ; <i1> [#uses=1]
|
||||||
|
br i1 %cmp78, label %if.then80, label %if.else
|
||||||
|
|
||||||
|
if.then80: ; preds = %land.lhs.true
|
||||||
|
%tmp81 = load i16* %i ; <i16> [#uses=1]
|
||||||
|
%conv82 = zext i16 %tmp81 to i32 ; <i32> [#uses=1]
|
||||||
|
%tmp83 = load i16* %j ; <i16> [#uses=1]
|
||||||
|
%conv84 = zext i16 %tmp83 to i32 ; <i32> [#uses=1]
|
||||||
|
%add85 = add i32 %conv82, %conv84 ; <i32> [#uses=1]
|
||||||
|
%tmp86 = load i8** %packet.addr ; <i8*> [#uses=1]
|
||||||
|
%arrayidx87 = getelementptr i8* %tmp86, i32 %add85 ; <i8*> [#uses=1]
|
||||||
|
%tmp88 = load i8* %arrayidx87 ; <i8> [#uses=1]
|
||||||
|
%conv89 = zext i8 %tmp88 to i32 ; <i32> [#uses=1]
|
||||||
|
%call90 = call i32 (i8*, ...)* @printf(i8* getelementptr ([3 x i8]* @"\01LC4", i32 0, i32 0), i32 %conv89) ; <i32> [#uses=0]
|
||||||
|
br label %if.end92
|
||||||
|
|
||||||
|
if.else: ; preds = %land.lhs.true, %for.body57
|
||||||
|
%call91 = call i32 (i8*, ...)* @printf(i8* getelementptr ([2 x i8]* @"\01LC5", i32 0, i32 0)) ; <i32> [#uses=0]
|
||||||
|
br label %if.end92
|
||||||
|
|
||||||
|
if.end92: ; preds = %if.else, %if.then80
|
||||||
|
br label %for.inc93
|
||||||
|
|
||||||
|
for.inc93: ; preds = %if.end92
|
||||||
|
%tmp94 = load i16* %j ; <i16> [#uses=1]
|
||||||
|
%inc95 = add i16 %tmp94, 1 ; <i16> [#uses=1]
|
||||||
|
store i16 %inc95, i16* %j
|
||||||
|
br label %for.cond52
|
||||||
|
|
||||||
|
for.end96: ; preds = %for.cond52
|
||||||
|
%call97 = call i32 (i8*, ...)* @printf(i8* getelementptr ([3 x i8]* @"\01LC6", i32 0, i32 0)) ; <i32> [#uses=0]
|
||||||
|
br label %for.inc98
|
||||||
|
|
||||||
|
for.inc98: ; preds = %for.end96, %if.then
|
||||||
|
%tmp99 = load i16* %i ; <i16> [#uses=1]
|
||||||
|
%conv100 = zext i16 %tmp99 to i32 ; <i32> [#uses=1]
|
||||||
|
%add101 = add i32 %conv100, 16 ; <i32> [#uses=1]
|
||||||
|
%conv102 = trunc i32 %add101 to i16 ; <i16> [#uses=1]
|
||||||
|
store i16 %conv102, i16* %i
|
||||||
|
br label %for.cond
|
||||||
|
|
||||||
|
for.end103: ; preds = %for.cond
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
declare i32 @printf(i8*, ...)
|
||||||
|
|
||||||
|
define zeroext i16 @crc_xmodem_update(i16 zeroext %crc, i8 zeroext %data) nounwind {
|
||||||
|
entry:
|
||||||
|
%retval = alloca i16 ; <i16*> [#uses=2]
|
||||||
|
%crc.addr = alloca i16 ; <i16*> [#uses=9]
|
||||||
|
%data.addr = alloca i8 ; <i8*> [#uses=2]
|
||||||
|
%i = alloca i32, align 4 ; <i32*> [#uses=4]
|
||||||
|
store i16 %crc, i16* %crc.addr
|
||||||
|
store i8 %data, i8* %data.addr
|
||||||
|
%tmp = load i16* %crc.addr ; <i16> [#uses=1]
|
||||||
|
%conv = zext i16 %tmp to i32 ; <i32> [#uses=1]
|
||||||
|
%tmp1 = load i8* %data.addr ; <i8> [#uses=1]
|
||||||
|
%conv2 = zext i8 %tmp1 to i32 ; <i32> [#uses=1]
|
||||||
|
%conv3 = trunc i32 %conv2 to i16 ; <i16> [#uses=1]
|
||||||
|
%conv4 = zext i16 %conv3 to i32 ; <i32> [#uses=1]
|
||||||
|
%shl = shl i32 %conv4, 8 ; <i32> [#uses=1]
|
||||||
|
%xor = xor i32 %conv, %shl ; <i32> [#uses=1]
|
||||||
|
%conv5 = trunc i32 %xor to i16 ; <i16> [#uses=1]
|
||||||
|
store i16 %conv5, i16* %crc.addr
|
||||||
|
store i32 0, i32* %i
|
||||||
|
br label %for.cond
|
||||||
|
|
||||||
|
for.cond: ; preds = %for.inc, %entry
|
||||||
|
%tmp6 = load i32* %i ; <i32> [#uses=1]
|
||||||
|
%cmp = icmp slt i32 %tmp6, 8 ; <i1> [#uses=1]
|
||||||
|
br i1 %cmp, label %for.body, label %for.end
|
||||||
|
|
||||||
|
for.body: ; preds = %for.cond
|
||||||
|
%tmp8 = load i16* %crc.addr ; <i16> [#uses=1]
|
||||||
|
%conv9 = zext i16 %tmp8 to i32 ; <i32> [#uses=1]
|
||||||
|
%and = and i32 %conv9, 32768 ; <i32> [#uses=1]
|
||||||
|
%tobool = icmp ne i32 %and, 0 ; <i1> [#uses=1]
|
||||||
|
br i1 %tobool, label %if.then, label %if.else
|
||||||
|
|
||||||
|
if.then: ; preds = %for.body
|
||||||
|
%tmp10 = load i16* %crc.addr ; <i16> [#uses=1]
|
||||||
|
%conv11 = zext i16 %tmp10 to i32 ; <i32> [#uses=1]
|
||||||
|
%shl12 = shl i32 %conv11, 1 ; <i32> [#uses=1]
|
||||||
|
%xor13 = xor i32 %shl12, 4129 ; <i32> [#uses=1]
|
||||||
|
%conv14 = trunc i32 %xor13 to i16 ; <i16> [#uses=1]
|
||||||
|
store i16 %conv14, i16* %crc.addr
|
||||||
|
br label %if.end
|
||||||
|
|
||||||
|
if.else: ; preds = %for.body
|
||||||
|
%tmp15 = load i16* %crc.addr ; <i16> [#uses=1]
|
||||||
|
%conv16 = zext i16 %tmp15 to i32 ; <i32> [#uses=1]
|
||||||
|
%shl17 = shl i32 %conv16, 1 ; <i32> [#uses=1]
|
||||||
|
%conv18 = trunc i32 %shl17 to i16 ; <i16> [#uses=1]
|
||||||
|
store i16 %conv18, i16* %crc.addr
|
||||||
|
br label %if.end
|
||||||
|
|
||||||
|
if.end: ; preds = %if.else, %if.then
|
||||||
|
br label %for.inc
|
||||||
|
|
||||||
|
for.inc: ; preds = %if.end
|
||||||
|
%tmp19 = load i32* %i ; <i32> [#uses=1]
|
||||||
|
%inc = add i32 %tmp19, 1 ; <i32> [#uses=1]
|
||||||
|
store i32 %inc, i32* %i
|
||||||
|
br label %for.cond
|
||||||
|
|
||||||
|
for.end: ; preds = %for.cond
|
||||||
|
%tmp20 = load i16* %crc.addr ; <i16> [#uses=1]
|
||||||
|
store i16 %tmp20, i16* %retval
|
||||||
|
%0 = load i16* %retval ; <i16> [#uses=1]
|
||||||
|
ret i16 %0
|
||||||
|
}
|
||||||
|
|
||||||
|
define zeroext i16 @do_crc(i8* %data, i16 zeroext %size) nounwind {
|
||||||
|
entry:
|
||||||
|
%retval = alloca i16 ; <i16*> [#uses=2]
|
||||||
|
%data.addr = alloca i8* ; <i8**> [#uses=2]
|
||||||
|
%size.addr = alloca i16 ; <i16*> [#uses=2]
|
||||||
|
%crc = alloca i16, align 2 ; <i16*> [#uses=4]
|
||||||
|
%i = alloca i16, align 2 ; <i16*> [#uses=5]
|
||||||
|
store i8* %data, i8** %data.addr
|
||||||
|
store i16 %size, i16* %size.addr
|
||||||
|
store i16 0, i16* %crc
|
||||||
|
store i16 0, i16* %i
|
||||||
|
br label %for.cond
|
||||||
|
|
||||||
|
for.cond: ; preds = %for.inc, %entry
|
||||||
|
%tmp = load i16* %i ; <i16> [#uses=1]
|
||||||
|
%conv = zext i16 %tmp to i32 ; <i32> [#uses=1]
|
||||||
|
%tmp1 = load i16* %size.addr ; <i16> [#uses=1]
|
||||||
|
%conv2 = zext i16 %tmp1 to i32 ; <i32> [#uses=1]
|
||||||
|
%cmp = icmp slt i32 %conv, %conv2 ; <i1> [#uses=1]
|
||||||
|
br i1 %cmp, label %for.body, label %for.end
|
||||||
|
|
||||||
|
for.body: ; preds = %for.cond
|
||||||
|
%tmp4 = load i16* %crc ; <i16> [#uses=1]
|
||||||
|
%tmp5 = load i16* %i ; <i16> [#uses=1]
|
||||||
|
%tmp6 = load i8** %data.addr ; <i8*> [#uses=1]
|
||||||
|
%idxprom = zext i16 %tmp5 to i32 ; <i32> [#uses=1]
|
||||||
|
%arrayidx = getelementptr i8* %tmp6, i32 %idxprom ; <i8*> [#uses=1]
|
||||||
|
%tmp7 = load i8* %arrayidx ; <i8> [#uses=1]
|
||||||
|
%call = call zeroext i16 @crc_xmodem_update(i16 zeroext %tmp4, i8 zeroext %tmp7) ; <i16> [#uses=1]
|
||||||
|
store i16 %call, i16* %crc
|
||||||
|
br label %for.inc
|
||||||
|
|
||||||
|
for.inc: ; preds = %for.body
|
||||||
|
%tmp8 = load i16* %i ; <i16> [#uses=1]
|
||||||
|
%inc = add i16 %tmp8, 1 ; <i16> [#uses=1]
|
||||||
|
store i16 %inc, i16* %i
|
||||||
|
br label %for.cond
|
||||||
|
|
||||||
|
for.end: ; preds = %for.cond
|
||||||
|
%tmp9 = load i16* %crc ; <i16> [#uses=1]
|
||||||
|
store i16 %tmp9, i16* %retval
|
||||||
|
%0 = load i16* %retval ; <i16> [#uses=1]
|
||||||
|
ret i16 %0
|
||||||
|
}
|
||||||
|
|
||||||
|
define zeroext i16 @do_crc_update(i16 zeroext %crc, i8* %data, i16 zeroext %size) nounwind {
|
||||||
|
entry:
|
||||||
|
%retval = alloca i16 ; <i16*> [#uses=2]
|
||||||
|
%crc.addr = alloca i16 ; <i16*> [#uses=4]
|
||||||
|
%data.addr = alloca i8* ; <i8**> [#uses=2]
|
||||||
|
%size.addr = alloca i16 ; <i16*> [#uses=2]
|
||||||
|
%i = alloca i16, align 2 ; <i16*> [#uses=5]
|
||||||
|
store i16 %crc, i16* %crc.addr
|
||||||
|
store i8* %data, i8** %data.addr
|
||||||
|
store i16 %size, i16* %size.addr
|
||||||
|
store i16 0, i16* %i
|
||||||
|
br label %for.cond
|
||||||
|
|
||||||
|
for.cond: ; preds = %for.inc, %entry
|
||||||
|
%tmp = load i16* %i ; <i16> [#uses=1]
|
||||||
|
%conv = zext i16 %tmp to i32 ; <i32> [#uses=1]
|
||||||
|
%tmp1 = load i16* %size.addr ; <i16> [#uses=1]
|
||||||
|
%conv2 = zext i16 %tmp1 to i32 ; <i32> [#uses=1]
|
||||||
|
%cmp = icmp slt i32 %conv, %conv2 ; <i1> [#uses=1]
|
||||||
|
br i1 %cmp, label %for.body, label %for.end
|
||||||
|
|
||||||
|
for.body: ; preds = %for.cond
|
||||||
|
%tmp4 = load i16* %crc.addr ; <i16> [#uses=1]
|
||||||
|
%tmp5 = load i16* %i ; <i16> [#uses=1]
|
||||||
|
%tmp6 = load i8** %data.addr ; <i8*> [#uses=1]
|
||||||
|
%idxprom = zext i16 %tmp5 to i32 ; <i32> [#uses=1]
|
||||||
|
%arrayidx = getelementptr i8* %tmp6, i32 %idxprom ; <i8*> [#uses=1]
|
||||||
|
%tmp7 = load i8* %arrayidx ; <i8> [#uses=1]
|
||||||
|
%call = call zeroext i16 @crc_xmodem_update(i16 zeroext %tmp4, i8 zeroext %tmp7) ; <i16> [#uses=1]
|
||||||
|
store i16 %call, i16* %crc.addr
|
||||||
|
br label %for.inc
|
||||||
|
|
||||||
|
for.inc: ; preds = %for.body
|
||||||
|
%tmp8 = load i16* %i ; <i16> [#uses=1]
|
||||||
|
%inc = add i16 %tmp8, 1 ; <i16> [#uses=1]
|
||||||
|
store i16 %inc, i16* %i
|
||||||
|
br label %for.cond
|
||||||
|
|
||||||
|
for.end: ; preds = %for.cond
|
||||||
|
%tmp9 = load i16* %crc.addr ; <i16> [#uses=1]
|
||||||
|
store i16 %tmp9, i16* %retval
|
||||||
|
%0 = load i16* %retval ; <i16> [#uses=1]
|
||||||
|
ret i16 %0
|
||||||
|
}
|
||||||
|
|
||||||
|
define i32 @main(i32 %argc, i8** %argv) nounwind {
|
||||||
|
entry:
|
||||||
|
%retval = alloca i32 ; <i32*> [#uses=2]
|
||||||
|
%argc.addr = alloca i32 ; <i32*> [#uses=3]
|
||||||
|
%argv.addr = alloca i8** ; <i8***> [#uses=8]
|
||||||
|
%handle = alloca %struct.usb_dev_handle*, align 4 ; <%struct.usb_dev_handle**> [#uses=7]
|
||||||
|
%rawVid = alloca [2 x i8], align 1 ; <[2 x i8]*> [#uses=4]
|
||||||
|
%rawPid = alloca [2 x i8], align 1 ; <[2 x i8]*> [#uses=4]
|
||||||
|
%vendor = alloca [11 x i8], align 1 ; <[11 x i8]*> [#uses=12]
|
||||||
|
%product = alloca [8 x i8], align 1 ; <[8 x i8]*> [#uses=11]
|
||||||
|
%cnt = alloca i32, align 4 ; <i32*> [#uses=9]
|
||||||
|
%vid = alloca i32, align 4 ; <i32*> [#uses=4]
|
||||||
|
%pid = alloca i32, align 4 ; <i32*> [#uses=4]
|
||||||
|
%cnt_crc = alloca i32, align 4 ; <i32*> [#uses=6]
|
||||||
|
%read_buffer = alloca i8*, align 4 ; <i8**> [#uses=4]
|
||||||
|
%crc_buffer = alloca i8*, align 4 ; <i8**> [#uses=5]
|
||||||
|
%addr = alloca i32, align 4 ; <i32*> [#uses=11]
|
||||||
|
%addr_lo = alloca i16, align 2 ; <i16*> [#uses=7]
|
||||||
|
%addr_hi = alloca i16, align 2 ; <i16*> [#uses=7]
|
||||||
|
%step = alloca i16, align 2 ; <i16*> [#uses=6]
|
||||||
|
%crc = alloca i16, align 2 ; <i16*> [#uses=3]
|
||||||
|
%bank = alloca i8, align 1 ; <i8*> [#uses=4]
|
||||||
|
%fp = alloca %struct.__sFILE*, align 4 ; <%struct.__sFILE**> [#uses=3]
|
||||||
|
store i32 %argc, i32* %argc.addr
|
||||||
|
store i8** %argv, i8*** %argv.addr
|
||||||
|
store %struct.usb_dev_handle* null, %struct.usb_dev_handle** %handle
|
||||||
|
%.array = getelementptr [2 x i8]* %rawVid, i32 0, i32 0 ; <i8*> [#uses=1]
|
||||||
|
store i8 -64, i8* %.array
|
||||||
|
%.array1 = getelementptr [2 x i8]* %rawVid, i32 0, i32 1 ; <i8*> [#uses=1]
|
||||||
|
store i8 22, i8* %.array1
|
||||||
|
%.array2 = getelementptr [2 x i8]* %rawPid, i32 0, i32 0 ; <i8*> [#uses=1]
|
||||||
|
store i8 -36, i8* %.array2
|
||||||
|
%.array3 = getelementptr [2 x i8]* %rawPid, i32 0, i32 1 ; <i8*> [#uses=1]
|
||||||
|
store i8 5, i8* %.array3
|
||||||
|
%.array4 = getelementptr [11 x i8]* %vendor, i32 0, i32 0 ; <i8*> [#uses=1]
|
||||||
|
store i8 111, i8* %.array4
|
||||||
|
%.array5 = getelementptr [11 x i8]* %vendor, i32 0, i32 1 ; <i8*> [#uses=1]
|
||||||
|
store i8 112, i8* %.array5
|
||||||
|
%.array6 = getelementptr [11 x i8]* %vendor, i32 0, i32 2 ; <i8*> [#uses=1]
|
||||||
|
store i8 116, i8* %.array6
|
||||||
|
%.array7 = getelementptr [11 x i8]* %vendor, i32 0, i32 3 ; <i8*> [#uses=1]
|
||||||
|
store i8 105, i8* %.array7
|
||||||
|
%.array8 = getelementptr [11 x i8]* %vendor, i32 0, i32 4 ; <i8*> [#uses=1]
|
||||||
|
store i8 120, i8* %.array8
|
||||||
|
%.array9 = getelementptr [11 x i8]* %vendor, i32 0, i32 5 ; <i8*> [#uses=1]
|
||||||
|
store i8 120, i8* %.array9
|
||||||
|
%.array10 = getelementptr [11 x i8]* %vendor, i32 0, i32 6 ; <i8*> [#uses=1]
|
||||||
|
store i8 46, i8* %.array10
|
||||||
|
%.array11 = getelementptr [11 x i8]* %vendor, i32 0, i32 7 ; <i8*> [#uses=1]
|
||||||
|
store i8 111, i8* %.array11
|
||||||
|
%.array12 = getelementptr [11 x i8]* %vendor, i32 0, i32 8 ; <i8*> [#uses=1]
|
||||||
|
store i8 114, i8* %.array12
|
||||||
|
%.array13 = getelementptr [11 x i8]* %vendor, i32 0, i32 9 ; <i8*> [#uses=1]
|
||||||
|
store i8 103, i8* %.array13
|
||||||
|
%.array14 = getelementptr [11 x i8]* %vendor, i32 0, i32 10 ; <i8*> [#uses=1]
|
||||||
|
store i8 0, i8* %.array14
|
||||||
|
%.array15 = getelementptr [8 x i8]* %product, i32 0, i32 0 ; <i8*> [#uses=1]
|
||||||
|
store i8 83, i8* %.array15
|
||||||
|
%.array16 = getelementptr [8 x i8]* %product, i32 0, i32 1 ; <i8*> [#uses=1]
|
||||||
|
store i8 78, i8* %.array16
|
||||||
|
%.array17 = getelementptr [8 x i8]* %product, i32 0, i32 2 ; <i8*> [#uses=1]
|
||||||
|
store i8 69, i8* %.array17
|
||||||
|
%.array18 = getelementptr [8 x i8]* %product, i32 0, i32 3 ; <i8*> [#uses=1]
|
||||||
|
store i8 83, i8* %.array18
|
||||||
|
%.array19 = getelementptr [8 x i8]* %product, i32 0, i32 4 ; <i8*> [#uses=1]
|
||||||
|
store i8 82, i8* %.array19
|
||||||
|
%.array20 = getelementptr [8 x i8]* %product, i32 0, i32 5 ; <i8*> [#uses=1]
|
||||||
|
store i8 65, i8* %.array20
|
||||||
|
%.array21 = getelementptr [8 x i8]* %product, i32 0, i32 6 ; <i8*> [#uses=1]
|
||||||
|
store i8 77, i8* %.array21
|
||||||
|
%.array22 = getelementptr [8 x i8]* %product, i32 0, i32 7 ; <i8*> [#uses=1]
|
||||||
|
store i8 0, i8* %.array22
|
||||||
|
store i32 0, i32* %cnt_crc
|
||||||
|
store i32 0, i32* %addr
|
||||||
|
store i16 0, i16* %addr_lo
|
||||||
|
store i16 0, i16* %addr_hi
|
||||||
|
store i16 0, i16* %step
|
||||||
|
store i16 0, i16* %crc
|
||||||
|
store i8 0, i8* %bank
|
||||||
|
call void @usb_init()
|
||||||
|
%tmp = load i32* %argc.addr ; <i32> [#uses=1]
|
||||||
|
%cmp = icmp slt i32 %tmp, 2 ; <i1> [#uses=1]
|
||||||
|
br i1 %cmp, label %if.then, label %if.end
|
||||||
|
|
||||||
|
if.then: ; preds = %entry
|
||||||
|
%tmp23 = load i8*** %argv.addr ; <i8**> [#uses=1]
|
||||||
|
%arrayidx = getelementptr i8** %tmp23, i32 0 ; <i8**> [#uses=1]
|
||||||
|
%tmp24 = load i8** %arrayidx ; <i8*> [#uses=1]
|
||||||
|
call void @usage(i8* %tmp24)
|
||||||
|
call void @exit(i32 1) noreturn
|
||||||
|
unreachable
|
||||||
|
; No predecessors!
|
||||||
|
br label %if.end
|
||||||
|
|
||||||
|
if.end: ; preds = %0, %entry
|
||||||
|
%arraydecay = getelementptr [2 x i8]* %rawVid, i32 0, i32 0 ; <i8*> [#uses=1]
|
||||||
|
%arrayidx25 = getelementptr i8* %arraydecay, i32 1 ; <i8*> [#uses=1]
|
||||||
|
%tmp26 = load i8* %arrayidx25 ; <i8> [#uses=1]
|
||||||
|
%conv = zext i8 %tmp26 to i32 ; <i32> [#uses=1]
|
||||||
|
%mul = mul i32 %conv, 256 ; <i32> [#uses=1]
|
||||||
|
%arraydecay27 = getelementptr [2 x i8]* %rawVid, i32 0, i32 0 ; <i8*> [#uses=1]
|
||||||
|
%arrayidx28 = getelementptr i8* %arraydecay27, i32 0 ; <i8*> [#uses=1]
|
||||||
|
%tmp29 = load i8* %arrayidx28 ; <i8> [#uses=1]
|
||||||
|
%conv30 = zext i8 %tmp29 to i32 ; <i32> [#uses=1]
|
||||||
|
%add = add i32 %mul, %conv30 ; <i32> [#uses=1]
|
||||||
|
store i32 %add, i32* %vid
|
||||||
|
%arraydecay31 = getelementptr [2 x i8]* %rawPid, i32 0, i32 0 ; <i8*> [#uses=1]
|
||||||
|
%arrayidx32 = getelementptr i8* %arraydecay31, i32 1 ; <i8*> [#uses=1]
|
||||||
|
%tmp33 = load i8* %arrayidx32 ; <i8> [#uses=1]
|
||||||
|
%conv34 = zext i8 %tmp33 to i32 ; <i32> [#uses=1]
|
||||||
|
%mul35 = mul i32 %conv34, 256 ; <i32> [#uses=1]
|
||||||
|
%arraydecay36 = getelementptr [2 x i8]* %rawPid, i32 0, i32 0 ; <i8*> [#uses=1]
|
||||||
|
%arrayidx37 = getelementptr i8* %arraydecay36, i32 0 ; <i8*> [#uses=1]
|
||||||
|
%tmp38 = load i8* %arrayidx37 ; <i8> [#uses=1]
|
||||||
|
%conv39 = zext i8 %tmp38 to i32 ; <i32> [#uses=1]
|
||||||
|
%add40 = add i32 %mul35, %conv39 ; <i32> [#uses=1]
|
||||||
|
store i32 %add40, i32* %pid
|
||||||
|
%tmp41 = load i32* %vid ; <i32> [#uses=1]
|
||||||
|
%arraydecay42 = getelementptr [11 x i8]* %vendor, i32 0, i32 0 ; <i8*> [#uses=1]
|
||||||
|
%tmp43 = load i32* %pid ; <i32> [#uses=1]
|
||||||
|
%arraydecay44 = getelementptr [8 x i8]* %product, i32 0, i32 0 ; <i8*> [#uses=1]
|
||||||
|
%call = call i32 @usbOpenDevice(%struct.usb_dev_handle** %handle, i32 %tmp41, i8* %arraydecay42, i32 %tmp43, i8* %arraydecay44, i8* null, %struct.__sFILE* null, %struct.__sFILE* null) ; <i32> [#uses=1]
|
||||||
|
%cmp45 = icmp ne i32 %call, 0 ; <i1> [#uses=1]
|
||||||
|
br i1 %cmp45, label %if.then47, label %if.end53
|
||||||
|
|
||||||
|
if.then47: ; preds = %if.end
|
||||||
|
%tmp48 = load %struct.__sFILE** @__stderrp ; <%struct.__sFILE*> [#uses=1]
|
||||||
|
%arraydecay49 = getelementptr [8 x i8]* %product, i32 0, i32 0 ; <i8*> [#uses=1]
|
||||||
|
%tmp50 = load i32* %vid ; <i32> [#uses=1]
|
||||||
|
%tmp51 = load i32* %pid ; <i32> [#uses=1]
|
||||||
|
%call52 = call i32 (%struct.__sFILE*, i8*, ...)* @fprintf(%struct.__sFILE* %tmp48, i8* getelementptr ([55 x i8]* @"\01LC7", i32 0, i32 0), i8* %arraydecay49, i32 %tmp50, i32 %tmp51) ; <i32> [#uses=0]
|
||||||
|
call void @exit(i32 1) noreturn
|
||||||
|
unreachable
|
||||||
|
; No predecessors!
|
||||||
|
br label %if.end53
|
||||||
|
|
||||||
|
if.end53: ; preds = %1, %if.end
|
||||||
|
%arraydecay54 = getelementptr [8 x i8]* %product, i32 0, i32 0 ; <i8*> [#uses=1]
|
||||||
|
%tmp55 = load i32* %vid ; <i32> [#uses=1]
|
||||||
|
%tmp56 = load i32* %pid ; <i32> [#uses=1]
|
||||||
|
%call57 = call i32 (i8*, ...)* @printf(i8* getelementptr ([45 x i8]* @"\01LC8", i32 0, i32 0), i8* %arraydecay54, i32 %tmp55, i32 %tmp56) ; <i32> [#uses=0]
|
||||||
|
%tmp58 = load i8*** %argv.addr ; <i8**> [#uses=1]
|
||||||
|
%arrayidx59 = getelementptr i8** %tmp58, i32 1 ; <i8**> [#uses=1]
|
||||||
|
%tmp60 = load i8** %arrayidx59 ; <i8*> [#uses=1]
|
||||||
|
%call61 = call i32 @strcasecmp(i8* %tmp60, i8* getelementptr ([7 x i8]* @"\01LC9", i32 0, i32 0)) ; <i32> [#uses=1]
|
||||||
|
%cmp62 = icmp eq i32 %call61, 0 ; <i1> [#uses=1]
|
||||||
|
br i1 %cmp62, label %if.then64, label %if.else171
|
||||||
|
|
||||||
|
if.then64: ; preds = %if.end53
|
||||||
|
%tmp65 = load i32* %argc.addr ; <i32> [#uses=1]
|
||||||
|
%cmp66 = icmp slt i32 %tmp65, 3 ; <i1> [#uses=1]
|
||||||
|
br i1 %cmp66, label %if.then68, label %if.end72
|
||||||
|
|
||||||
|
if.then68: ; preds = %if.then64
|
||||||
|
%tmp69 = load i8*** %argv.addr ; <i8**> [#uses=1]
|
||||||
|
%arrayidx70 = getelementptr i8** %tmp69, i32 0 ; <i8**> [#uses=1]
|
||||||
|
%tmp71 = load i8** %arrayidx70 ; <i8*> [#uses=1]
|
||||||
|
call void @usage(i8* %tmp71)
|
||||||
|
call void @exit(i32 1) noreturn
|
||||||
|
unreachable
|
||||||
|
; No predecessors!
|
||||||
|
br label %if.end72
|
||||||
|
|
||||||
|
if.end72: ; preds = %2, %if.then64
|
||||||
|
%tmp73 = load i8*** %argv.addr ; <i8**> [#uses=1]
|
||||||
|
%arrayidx74 = getelementptr i8** %tmp73, i32 2 ; <i8**> [#uses=1]
|
||||||
|
%tmp75 = load i8** %arrayidx74 ; <i8*> [#uses=1]
|
||||||
|
%call76 = call %struct.__sFILE* @fopen(i8* %tmp75, i8* getelementptr ([2 x i8]* @"\01LC10", i32 0, i32 0)) ; <%struct.__sFILE*> [#uses=1]
|
||||||
|
store %struct.__sFILE* %call76, %struct.__sFILE** %fp
|
||||||
|
%tmp77 = load %struct.__sFILE** %fp ; <%struct.__sFILE*> [#uses=1]
|
||||||
|
%cmp78 = icmp eq %struct.__sFILE* %tmp77, null ; <i1> [#uses=1]
|
||||||
|
br i1 %cmp78, label %if.then80, label %if.end86
|
||||||
|
|
||||||
|
if.then80: ; preds = %if.end72
|
||||||
|
%tmp81 = load %struct.__sFILE** @__stderrp ; <%struct.__sFILE*> [#uses=1]
|
||||||
|
%tmp82 = load i8*** %argv.addr ; <i8**> [#uses=1]
|
||||||
|
%arrayidx83 = getelementptr i8** %tmp82, i32 2 ; <i8**> [#uses=1]
|
||||||
|
%tmp84 = load i8** %arrayidx83 ; <i8*> [#uses=1]
|
||||||
|
%call85 = call i32 (%struct.__sFILE*, i8*, ...)* @fprintf(%struct.__sFILE* %tmp81, i8* getelementptr ([21 x i8]* @"\01LC11", i32 0, i32 0), i8* %tmp84) ; <i32> [#uses=0]
|
||||||
|
call void @exit(i32 1) noreturn
|
||||||
|
unreachable
|
||||||
|
; No predecessors!
|
||||||
|
br label %if.end86
|
||||||
|
|
||||||
|
if.end86: ; preds = %3, %if.end72
|
||||||
|
%call87 = call i8* @malloc(i32 1024) ; <i8*> [#uses=1]
|
||||||
|
store i8* %call87, i8** %read_buffer
|
||||||
|
%call88 = call i8* @malloc(i32 32768) ; <i8*> [#uses=1]
|
||||||
|
store i8* %call88, i8** %crc_buffer
|
||||||
|
%tmp89 = load i8** %crc_buffer ; <i8*> [#uses=1]
|
||||||
|
%call90 = call i8* @memset(i8* %tmp89, i32 0, i32 32768) ; <i8*> [#uses=0]
|
||||||
|
store i32 0, i32* %addr
|
||||||
|
%tmp91 = load %struct.usb_dev_handle** %handle ; <%struct.usb_dev_handle*> [#uses=1]
|
||||||
|
%call92 = call i32 @usb_control_msg(%struct.usb_dev_handle* %tmp91, i32 64, i32 0, i32 0, i32 0, i8* null, i32 0, i32 5000) ; <i32> [#uses=0]
|
||||||
|
br label %while.cond
|
||||||
|
|
||||||
|
while.cond: ; preds = %if.end148, %if.end86
|
||||||
|
%tmp93 = load i8** %read_buffer ; <i8*> [#uses=1]
|
||||||
|
%tmp94 = load %struct.__sFILE** %fp ; <%struct.__sFILE*> [#uses=1]
|
||||||
|
%call95 = call i32 @fread(i8* %tmp93, i32 1024, i32 1, %struct.__sFILE* %tmp94) ; <i32> [#uses=2]
|
||||||
|
store i32 %call95, i32* %cnt
|
||||||
|
%cmp96 = icmp sgt i32 %call95, 0 ; <i1> [#uses=1]
|
||||||
|
br i1 %cmp96, label %while.body, label %while.end
|
||||||
|
|
||||||
|
while.body: ; preds = %while.cond
|
||||||
|
store i16 0, i16* %step
|
||||||
|
br label %for.cond
|
||||||
|
|
||||||
|
for.cond: ; preds = %for.inc, %while.body
|
||||||
|
%tmp98 = load i16* %step ; <i16> [#uses=1]
|
||||||
|
%conv99 = zext i16 %tmp98 to i32 ; <i32> [#uses=1]
|
||||||
|
%cmp100 = icmp slt i32 %conv99, 1024 ; <i1> [#uses=1]
|
||||||
|
br i1 %cmp100, label %for.body, label %for.end
|
||||||
|
|
||||||
|
for.body: ; preds = %for.cond
|
||||||
|
%tmp102 = load i32* %addr ; <i32> [#uses=1]
|
||||||
|
%and = and i32 %tmp102, 65535 ; <i32> [#uses=1]
|
||||||
|
%conv103 = trunc i32 %and to i16 ; <i16> [#uses=1]
|
||||||
|
store i16 %conv103, i16* %addr_lo
|
||||||
|
%tmp104 = load i32* %addr ; <i32> [#uses=1]
|
||||||
|
%shr = lshr i32 %tmp104, 16 ; <i32> [#uses=1]
|
||||||
|
%and105 = and i32 %shr, 255 ; <i32> [#uses=1]
|
||||||
|
%conv106 = trunc i32 %and105 to i16 ; <i16> [#uses=1]
|
||||||
|
store i16 %conv106, i16* %addr_hi
|
||||||
|
%tmp107 = load %struct.usb_dev_handle** %handle ; <%struct.usb_dev_handle*> [#uses=1]
|
||||||
|
%tmp108 = load i16* %addr_hi ; <i16> [#uses=1]
|
||||||
|
%conv109 = zext i16 %tmp108 to i32 ; <i32> [#uses=1]
|
||||||
|
%tmp110 = load i16* %addr_lo ; <i16> [#uses=1]
|
||||||
|
%conv111 = zext i16 %tmp110 to i32 ; <i32> [#uses=1]
|
||||||
|
%tmp112 = load i8** %read_buffer ; <i8*> [#uses=1]
|
||||||
|
%tmp113 = load i16* %step ; <i16> [#uses=1]
|
||||||
|
%conv114 = zext i16 %tmp113 to i32 ; <i32> [#uses=1]
|
||||||
|
%add.ptr = getelementptr i8* %tmp112, i32 %conv114 ; <i8*> [#uses=1]
|
||||||
|
%call115 = call i32 @usb_control_msg(%struct.usb_dev_handle* %tmp107, i32 64, i32 1, i32 %conv109, i32 %conv111, i8* %add.ptr, i32 128, i32 5000) ; <i32> [#uses=0]
|
||||||
|
%tmp116 = load i32* %addr ; <i32> [#uses=1]
|
||||||
|
%add117 = add i32 %tmp116, 128 ; <i32> [#uses=1]
|
||||||
|
store i32 %add117, i32* %addr
|
||||||
|
br label %for.inc
|
||||||
|
|
||||||
|
for.inc: ; preds = %for.body
|
||||||
|
%tmp118 = load i16* %step ; <i16> [#uses=1]
|
||||||
|
%conv119 = zext i16 %tmp118 to i32 ; <i32> [#uses=1]
|
||||||
|
%add120 = add i32 %conv119, 128 ; <i32> [#uses=1]
|
||||||
|
%conv121 = trunc i32 %add120 to i16 ; <i16> [#uses=1]
|
||||||
|
store i16 %conv121, i16* %step
|
||||||
|
br label %for.cond
|
||||||
|
|
||||||
|
for.end: ; preds = %for.cond
|
||||||
|
%tmp122 = load i8** %crc_buffer ; <i8*> [#uses=1]
|
||||||
|
%tmp123 = load i32* %cnt_crc ; <i32> [#uses=1]
|
||||||
|
%add.ptr124 = getelementptr i8* %tmp122, i32 %tmp123 ; <i8*> [#uses=1]
|
||||||
|
%tmp125 = load i8** %read_buffer ; <i8*> [#uses=1]
|
||||||
|
%call126 = call i8* @memcpy(i8* %add.ptr124, i8* %tmp125, i32 1024) ; <i8*> [#uses=0]
|
||||||
|
%tmp127 = load i32* %cnt_crc ; <i32> [#uses=1]
|
||||||
|
%add128 = add i32 %tmp127, 1024 ; <i32> [#uses=1]
|
||||||
|
store i32 %add128, i32* %cnt_crc
|
||||||
|
%tmp129 = load i32* %cnt_crc ; <i32> [#uses=1]
|
||||||
|
%cmp130 = icmp sge i32 %tmp129, 32768 ; <i1> [#uses=1]
|
||||||
|
br i1 %cmp130, label %if.then132, label %if.end148
|
||||||
|
|
||||||
|
if.then132: ; preds = %for.end
|
||||||
|
%tmp133 = load i8** %crc_buffer ; <i8*> [#uses=1]
|
||||||
|
%call134 = call zeroext i16 @do_crc(i8* %tmp133, i16 zeroext -32768) ; <i16> [#uses=1]
|
||||||
|
store i16 %call134, i16* %crc
|
||||||
|
%tmp135 = load i32* %addr ; <i32> [#uses=1]
|
||||||
|
%tmp136 = load i8* %bank ; <i8> [#uses=1]
|
||||||
|
%conv137 = zext i8 %tmp136 to i32 ; <i32> [#uses=1]
|
||||||
|
%tmp138 = load i16* %addr_hi ; <i16> [#uses=1]
|
||||||
|
%conv139 = zext i16 %tmp138 to i32 ; <i32> [#uses=1]
|
||||||
|
%tmp140 = load i16* %addr_lo ; <i16> [#uses=1]
|
||||||
|
%conv141 = zext i16 %tmp140 to i32 ; <i32> [#uses=1]
|
||||||
|
%tmp142 = load i16* %crc ; <i16> [#uses=1]
|
||||||
|
%conv143 = zext i16 %tmp142 to i32 ; <i32> [#uses=1]
|
||||||
|
%call144 = call i32 (i8*, ...)* @printf(i8* getelementptr ([70 x i8]* @"\01LC12", i32 0, i32 0), i32 %tmp135, i32 %conv137, i32 %conv139, i32 %conv141, i32 %conv143) ; <i32> [#uses=0]
|
||||||
|
%tmp145 = load i8** %crc_buffer ; <i8*> [#uses=1]
|
||||||
|
%call146 = call i8* @memset(i8* %tmp145, i32 0, i32 32768) ; <i8*> [#uses=0]
|
||||||
|
%tmp147 = load i8* %bank ; <i8> [#uses=1]
|
||||||
|
%inc = add i8 %tmp147, 1 ; <i8> [#uses=1]
|
||||||
|
store i8 %inc, i8* %bank
|
||||||
|
store i32 0, i32* %cnt_crc
|
||||||
|
br label %if.end148
|
||||||
|
|
||||||
|
if.end148: ; preds = %if.then132, %for.end
|
||||||
|
br label %while.cond
|
||||||
|
|
||||||
|
while.end: ; preds = %while.cond
|
||||||
|
%tmp149 = load %struct.usb_dev_handle** %handle ; <%struct.usb_dev_handle*> [#uses=1]
|
||||||
|
%tmp150 = load i16* %addr_hi ; <i16> [#uses=1]
|
||||||
|
%conv151 = zext i16 %tmp150 to i32 ; <i32> [#uses=1]
|
||||||
|
%tmp152 = load i16* %addr_lo ; <i16> [#uses=1]
|
||||||
|
%conv153 = zext i16 %tmp152 to i32 ; <i32> [#uses=1]
|
||||||
|
%call154 = call i32 @usb_control_msg(%struct.usb_dev_handle* %tmp149, i32 64, i32 4, i32 %conv151, i32 %conv153, i8* null, i32 0, i32 5000) ; <i32> [#uses=1]
|
||||||
|
store i32 %call154, i32* %cnt
|
||||||
|
%tmp155 = load i32* %cnt ; <i32> [#uses=1]
|
||||||
|
%cmp156 = icmp slt i32 %tmp155, 1 ; <i1> [#uses=1]
|
||||||
|
br i1 %cmp156, label %if.then158, label %if.end170
|
||||||
|
|
||||||
|
if.then158: ; preds = %while.end
|
||||||
|
%tmp159 = load i32* %cnt ; <i32> [#uses=1]
|
||||||
|
%cmp160 = icmp slt i32 %tmp159, 0 ; <i1> [#uses=1]
|
||||||
|
br i1 %cmp160, label %if.then162, label %if.else
|
||||||
|
|
||||||
|
if.then162: ; preds = %if.then158
|
||||||
|
%tmp163 = load %struct.__sFILE** @__stderrp ; <%struct.__sFILE*> [#uses=1]
|
||||||
|
%call164 = call i8* @usb_strerror() ; <i8*> [#uses=1]
|
||||||
|
%call165 = call i32 (%struct.__sFILE*, i8*, ...)* @fprintf(%struct.__sFILE* %tmp163, i8* getelementptr ([15 x i8]* @"\01LC13", i32 0, i32 0), i8* %call164) ; <i32> [#uses=0]
|
||||||
|
br label %if.end169
|
||||||
|
|
||||||
|
if.else: ; preds = %if.then158
|
||||||
|
%tmp166 = load %struct.__sFILE** @__stderrp ; <%struct.__sFILE*> [#uses=1]
|
||||||
|
%tmp167 = load i32* %cnt ; <i32> [#uses=1]
|
||||||
|
%call168 = call i32 (%struct.__sFILE*, i8*, ...)* @fprintf(%struct.__sFILE* %tmp166, i8* getelementptr ([25 x i8]* @"\01LC14", i32 0, i32 0), i32 %tmp167) ; <i32> [#uses=0]
|
||||||
|
br label %if.end169
|
||||||
|
|
||||||
|
if.end169: ; preds = %if.else, %if.then162
|
||||||
|
br label %if.end170
|
||||||
|
|
||||||
|
if.end170: ; preds = %if.end169, %while.end
|
||||||
|
br label %if.end216
|
||||||
|
|
||||||
|
if.else171: ; preds = %if.end53
|
||||||
|
%tmp172 = load i8*** %argv.addr ; <i8**> [#uses=1]
|
||||||
|
%arrayidx173 = getelementptr i8** %tmp172, i32 1 ; <i8**> [#uses=1]
|
||||||
|
%tmp174 = load i8** %arrayidx173 ; <i8*> [#uses=1]
|
||||||
|
%call175 = call i32 @strcasecmp(i8* %tmp174, i8* getelementptr ([4 x i8]* @"\01LC15", i32 0, i32 0)) ; <i32> [#uses=1]
|
||||||
|
%cmp176 = icmp eq i32 %call175, 0 ; <i1> [#uses=1]
|
||||||
|
br i1 %cmp176, label %if.then178, label %if.else211
|
||||||
|
|
||||||
|
if.then178: ; preds = %if.else171
|
||||||
|
store i32 0, i32* %addr
|
||||||
|
%tmp179 = load i32* %addr ; <i32> [#uses=1]
|
||||||
|
%and180 = and i32 %tmp179, 65535 ; <i32> [#uses=1]
|
||||||
|
%conv181 = trunc i32 %and180 to i16 ; <i16> [#uses=1]
|
||||||
|
store i16 %conv181, i16* %addr_lo
|
||||||
|
%tmp182 = load i32* %addr ; <i32> [#uses=1]
|
||||||
|
%shr183 = lshr i32 %tmp182, 16 ; <i32> [#uses=1]
|
||||||
|
%and184 = and i32 %shr183, 255 ; <i32> [#uses=1]
|
||||||
|
%conv185 = trunc i32 %and184 to i16 ; <i16> [#uses=1]
|
||||||
|
store i16 %conv185, i16* %addr_hi
|
||||||
|
%tmp186 = load i32* %addr ; <i32> [#uses=1]
|
||||||
|
%call187 = call i32 (i8*, ...)* @printf(i8* getelementptr ([30 x i8]* @"\01LC16", i32 0, i32 0), i32 %tmp186) ; <i32> [#uses=0]
|
||||||
|
%tmp188 = load %struct.usb_dev_handle** %handle ; <%struct.usb_dev_handle*> [#uses=1]
|
||||||
|
%tmp189 = load i16* %addr_hi ; <i16> [#uses=1]
|
||||||
|
%conv190 = zext i16 %tmp189 to i32 ; <i32> [#uses=1]
|
||||||
|
%tmp191 = load i16* %addr_lo ; <i16> [#uses=1]
|
||||||
|
%conv192 = zext i16 %tmp191 to i32 ; <i32> [#uses=1]
|
||||||
|
%call193 = call i32 @usb_control_msg(%struct.usb_dev_handle* %tmp188, i32 64, i32 5, i32 %conv190, i32 %conv192, i8* null, i32 8192, i32 5000) ; <i32> [#uses=1]
|
||||||
|
store i32 %call193, i32* %cnt
|
||||||
|
%tmp194 = load i32* %cnt ; <i32> [#uses=1]
|
||||||
|
%cmp195 = icmp slt i32 %tmp194, 1 ; <i1> [#uses=1]
|
||||||
|
br i1 %cmp195, label %if.then197, label %if.end210
|
||||||
|
|
||||||
|
if.then197: ; preds = %if.then178
|
||||||
|
%tmp198 = load i32* %cnt ; <i32> [#uses=1]
|
||||||
|
%cmp199 = icmp slt i32 %tmp198, 0 ; <i1> [#uses=1]
|
||||||
|
br i1 %cmp199, label %if.then201, label %if.else205
|
||||||
|
|
||||||
|
if.then201: ; preds = %if.then197
|
||||||
|
%tmp202 = load %struct.__sFILE** @__stderrp ; <%struct.__sFILE*> [#uses=1]
|
||||||
|
%call203 = call i8* @usb_strerror() ; <i8*> [#uses=1]
|
||||||
|
%call204 = call i32 (%struct.__sFILE*, i8*, ...)* @fprintf(%struct.__sFILE* %tmp202, i8* getelementptr ([15 x i8]* @"\01LC13", i32 0, i32 0), i8* %call203) ; <i32> [#uses=0]
|
||||||
|
br label %if.end209
|
||||||
|
|
||||||
|
if.else205: ; preds = %if.then197
|
||||||
|
%tmp206 = load %struct.__sFILE** @__stderrp ; <%struct.__sFILE*> [#uses=1]
|
||||||
|
%tmp207 = load i32* %cnt ; <i32> [#uses=1]
|
||||||
|
%call208 = call i32 (%struct.__sFILE*, i8*, ...)* @fprintf(%struct.__sFILE* %tmp206, i8* getelementptr ([25 x i8]* @"\01LC14", i32 0, i32 0), i32 %tmp207) ; <i32> [#uses=0]
|
||||||
|
br label %if.end209
|
||||||
|
|
||||||
|
if.end209: ; preds = %if.else205, %if.then201
|
||||||
|
br label %if.end210
|
||||||
|
|
||||||
|
if.end210: ; preds = %if.end209, %if.then178
|
||||||
|
br label %if.end215
|
||||||
|
|
||||||
|
if.else211: ; preds = %if.else171
|
||||||
|
%tmp212 = load i8*** %argv.addr ; <i8**> [#uses=1]
|
||||||
|
%arrayidx213 = getelementptr i8** %tmp212, i32 0 ; <i8**> [#uses=1]
|
||||||
|
%tmp214 = load i8** %arrayidx213 ; <i8*> [#uses=1]
|
||||||
|
call void @usage(i8* %tmp214)
|
||||||
|
call void @exit(i32 1) noreturn
|
||||||
|
unreachable
|
||||||
|
; No predecessors!
|
||||||
|
br label %if.end215
|
||||||
|
|
||||||
|
if.end215: ; preds = %4, %if.end210
|
||||||
|
br label %if.end216
|
||||||
|
|
||||||
|
if.end216: ; preds = %if.end215, %if.end170
|
||||||
|
%tmp217 = load %struct.usb_dev_handle** %handle ; <%struct.usb_dev_handle*> [#uses=1]
|
||||||
|
%call218 = call i32 @usb_close(%struct.usb_dev_handle* %tmp217) ; <i32> [#uses=0]
|
||||||
|
store i32 0, i32* %retval
|
||||||
|
%5 = load i32* %retval ; <i32> [#uses=1]
|
||||||
|
ret i32 %5
|
||||||
|
}
|
||||||
|
|
||||||
|
declare void @usb_init()
|
||||||
|
|
||||||
|
define internal void @usage(i8* %name) nounwind {
|
||||||
|
entry:
|
||||||
|
%name.addr = alloca i8* ; <i8**> [#uses=2]
|
||||||
|
store i8* %name, i8** %name.addr
|
||||||
|
%tmp = load %struct.__sFILE** @__stderrp ; <%struct.__sFILE*> [#uses=1]
|
||||||
|
%call = call i32 (%struct.__sFILE*, i8*, ...)* @fprintf(%struct.__sFILE* %tmp, i8* getelementptr ([8 x i8]* @"\01LC17", i32 0, i32 0)) ; <i32> [#uses=0]
|
||||||
|
%tmp1 = load %struct.__sFILE** @__stderrp ; <%struct.__sFILE*> [#uses=1]
|
||||||
|
%tmp2 = load i8** %name.addr ; <i8*> [#uses=1]
|
||||||
|
%call3 = call i32 (%struct.__sFILE*, i8*, ...)* @fprintf(%struct.__sFILE* %tmp1, i8* getelementptr ([31 x i8]* @"\01LC18", i32 0, i32 0), i8* %tmp2) ; <i32> [#uses=0]
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
declare void @exit(i32) noreturn
|
||||||
|
|
||||||
|
declare i32 @usbOpenDevice(%struct.usb_dev_handle**, i32, i8*, i32, i8*, i8*, %struct.__sFILE*, %struct.__sFILE*)
|
||||||
|
|
||||||
|
declare i32 @fprintf(%struct.__sFILE*, i8*, ...)
|
||||||
|
|
||||||
|
declare i32 @strcasecmp(i8*, i8*)
|
||||||
|
|
||||||
|
declare %struct.__sFILE* @fopen(i8*, i8*)
|
||||||
|
|
||||||
|
declare i8* @malloc(i32)
|
||||||
|
|
||||||
|
declare i8* @memset(i8*, i32, i32)
|
||||||
|
|
||||||
|
declare i32 @usb_control_msg(%struct.usb_dev_handle*, i32, i32, i32, i32, i8*, i32, i32)
|
||||||
|
|
||||||
|
declare i32 @fread(i8*, i32, i32, %struct.__sFILE*)
|
||||||
|
|
||||||
|
declare i8* @memcpy(i8*, i8*, i32)
|
||||||
|
|
||||||
|
declare i8* @usb_strerror()
|
||||||
|
|
||||||
|
declare i32 @usb_close(%struct.usb_dev_handle*)
|
||||||
25
avr/usbload/config.h
Normal file
25
avr/usbload/config.h
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
|
||||||
|
#ifndef __CONFIH_H__
|
||||||
|
#define __CONFIH_H__
|
||||||
|
|
||||||
|
#define DEBUG 1
|
||||||
|
#define DEBUG_USB 2
|
||||||
|
#define DEBUG_USB_TRANS 4
|
||||||
|
#define DEBUG_SRAM 8
|
||||||
|
#define DEBUG_SRAM_RAW 16
|
||||||
|
#define DEBUG_SREG 32
|
||||||
|
|
||||||
|
#define REQ_STATUS_IDLE 0x01
|
||||||
|
#define REQ_STATUS_UPLOAD 0x02
|
||||||
|
#define REQ_STATUS_BULK_UPLOAD 0x03
|
||||||
|
#define REQ_STATUS_BULK_NEXT 0x04
|
||||||
|
#define REQ_STATUS_CRC 0x05
|
||||||
|
#define REQ_STATUS_BOOT 0x06
|
||||||
|
|
||||||
|
#define USB_MAX_TRANS 0xff
|
||||||
|
#define USB_CRC_CHECK 0x01
|
||||||
|
|
||||||
|
#define TRANSFER_BUFFER_SIZE 0x200
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
97
avr/usbload/crc.c
Normal file
97
avr/usbload/crc.c
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "crc.h"
|
||||||
|
#include "uart.h"
|
||||||
|
#include "config.h"
|
||||||
|
#include "sram.h"
|
||||||
|
|
||||||
|
extern FILE uart_stdout;
|
||||||
|
|
||||||
|
uint16_t crc_xmodem_update(uint16_t crc, uint8_t data)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
crc = crc ^ ((uint16_t) data << 8);
|
||||||
|
for (i = 0; i < 8; i++) {
|
||||||
|
if (crc & 0x8000)
|
||||||
|
crc = (crc << 1) ^ 0x1021;
|
||||||
|
else
|
||||||
|
crc <<= 1;
|
||||||
|
}
|
||||||
|
return crc;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t do_crc(uint8_t * data, uint16_t size)
|
||||||
|
{
|
||||||
|
uint16_t crc = 0;
|
||||||
|
uint16_t i;
|
||||||
|
for (i = 0; i < size; i++) {
|
||||||
|
crc = crc_xmodem_update(crc, data[i]);
|
||||||
|
}
|
||||||
|
return crc;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint16_t do_crc_update(uint16_t crc, uint8_t * data, uint16_t size)
|
||||||
|
{
|
||||||
|
uint16_t i;
|
||||||
|
for (i = 0; i < size; i++)
|
||||||
|
crc = crc_xmodem_update(crc, data[i]);
|
||||||
|
return crc;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void crc_check_bulk_memory(uint32_t bottom_addr,uint32_t top_addr)
|
||||||
|
{
|
||||||
|
uint16_t crc = 0;
|
||||||
|
uint32_t addr = 0;
|
||||||
|
uint8_t req_bank = 0;
|
||||||
|
sram_bulk_read_start(bottom_addr);
|
||||||
|
for (addr = bottom_addr; addr < top_addr; addr++) {
|
||||||
|
if (addr && addr % 0x8000 == 0) {
|
||||||
|
printf("crc_check_bulk: bank=0x%02x addr=0x%08lx crc=0x%04x\n",
|
||||||
|
req_bank,addr,crc);
|
||||||
|
req_bank++;
|
||||||
|
crc = 0;
|
||||||
|
}
|
||||||
|
crc = crc_xmodem_update(crc, sram_bulk_read());
|
||||||
|
sram_bulk_read_next();
|
||||||
|
}
|
||||||
|
sram_bulk_read_end();
|
||||||
|
if (addr % 0x8000 == 0)
|
||||||
|
printf("crc_check_bulk: bank=0x%02x addr=0x%08lx crc=0x%04x\n",
|
||||||
|
req_bank,addr,crc);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void crc_check_memory(uint32_t bottom_addr,uint32_t top_addr,uint8_t *buffer)
|
||||||
|
{
|
||||||
|
uint16_t crc = 0;
|
||||||
|
uint32_t addr;
|
||||||
|
uint8_t req_bank = 0;
|
||||||
|
for (addr = bottom_addr; addr < top_addr; addr += TRANSFER_BUFFER_SIZE) {
|
||||||
|
if (addr && addr % 0x8000 == 0) {
|
||||||
|
printf("crc_check_memory: bank=0x%02x addr=0x%08lx crc=0x%04x\n",
|
||||||
|
req_bank,addr,crc);
|
||||||
|
req_bank++;
|
||||||
|
crc = 0;
|
||||||
|
}
|
||||||
|
sram_read_buffer(addr, buffer, TRANSFER_BUFFER_SIZE);
|
||||||
|
crc = do_crc_update(crc, buffer, TRANSFER_BUFFER_SIZE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
uint16_t crc_check_memory_range(uint32_t start_addr, uint32_t size,uint8_t *buffer)
|
||||||
|
{
|
||||||
|
uint16_t crc = 0;
|
||||||
|
uint32_t addr;
|
||||||
|
for (addr = start_addr; addr < start_addr + size; addr += TRANSFER_BUFFER_SIZE) {
|
||||||
|
sram_read_buffer(addr, buffer, TRANSFER_BUFFER_SIZE);
|
||||||
|
crc = do_crc_update(crc, buffer, TRANSFER_BUFFER_SIZE);
|
||||||
|
}
|
||||||
|
return crc;
|
||||||
|
}
|
||||||
16
avr/usbload/crc.h
Normal file
16
avr/usbload/crc.h
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
|
||||||
|
#ifndef __CRC_H__
|
||||||
|
#define __CRC_H__
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
|
||||||
|
uint16_t crc_xmodem_update(uint16_t crc, uint8_t data);
|
||||||
|
uint16_t do_crc(uint8_t * data,uint16_t size);
|
||||||
|
uint16_t do_crc_update(uint16_t crc,uint8_t * data,uint16_t size);
|
||||||
|
void crc_check_memory(uint32_t bottom_addr,uint32_t top_addr,uint8_t *buffer);
|
||||||
|
uint16_t crc_check_memory_range(uint32_t start_addr, uint32_t size,uint8_t *buffer);
|
||||||
|
void crc_check_bulk_memory(uint32_t bottom_addr,uint32_t top_addr);
|
||||||
|
|
||||||
|
#endif
|
||||||
29
avr/usbload/debug.c
Normal file
29
avr/usbload/debug.c
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "debug.h"
|
||||||
|
#include "uart.h"
|
||||||
|
|
||||||
|
|
||||||
|
extern FILE uart_stdout;
|
||||||
|
|
||||||
|
extern int debug_level; /* the higher, the more messages... */
|
||||||
|
|
||||||
|
#if defined(NO_DEBUG) && defined(__GNUC__)
|
||||||
|
/* Nothing. debug has been "defined away" in debug.h already. */
|
||||||
|
#else
|
||||||
|
void debug(int level, char* format, ...) {
|
||||||
|
#ifdef NO_DEBUG
|
||||||
|
/* Empty body, so a good compiler will optimise calls
|
||||||
|
to pmesg away */
|
||||||
|
#else
|
||||||
|
va_list args;
|
||||||
|
if (!(debug_level & level))
|
||||||
|
return;
|
||||||
|
va_start(args, format);
|
||||||
|
printf(format, args);
|
||||||
|
va_end(args);
|
||||||
|
#endif /* NDEBUG */
|
||||||
|
#endif /* NDEBUG && __GNUC__ */
|
||||||
|
}
|
||||||
|
|
||||||
21
avr/usbload/debug.h
Normal file
21
avr/usbload/debug.h
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
#ifndef __DEBUG_H__
|
||||||
|
#define __DEBUG_H__
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(NO_DEBUG) && defined(__GNUC__)
|
||||||
|
/* gcc's cpp has extensions; it allows for macros with a variable number of
|
||||||
|
arguments. We use this extension here to preprocess pmesg away. */
|
||||||
|
#define debug(level, format, args...) ((void)0)
|
||||||
|
#else
|
||||||
|
void debug(int level, char *format, ...);
|
||||||
|
/* print a message, if it is considered significant enough.
|
||||||
|
Adapted from [K&R2], p. 174 */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* DEBUG_H */
|
||||||
|
|
||||||
60
avr/usbload/dump.c
Normal file
60
avr/usbload/dump.c
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "debug.h"
|
||||||
|
#include "uart.h"
|
||||||
|
#include "sram.h"
|
||||||
|
|
||||||
|
|
||||||
|
extern FILE uart_stdout;
|
||||||
|
|
||||||
|
void dump_packet(uint32_t addr, uint32_t len, uint8_t * packet)
|
||||||
|
{
|
||||||
|
uint16_t i,j;
|
||||||
|
uint16_t sum = 0;
|
||||||
|
uint8_t clear = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < len; i += 16) {
|
||||||
|
|
||||||
|
sum = 0;
|
||||||
|
for (j = 0; j < 16; j++) {
|
||||||
|
sum += packet[i + j];
|
||||||
|
}
|
||||||
|
if (!sum) {
|
||||||
|
clear = 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (clear) {
|
||||||
|
printf("*\n");
|
||||||
|
clear = 0;
|
||||||
|
}
|
||||||
|
printf("%08lx:", addr + i);
|
||||||
|
for (j = 0; j < 16; j++) {
|
||||||
|
printf(" %02x", packet[i + j]);
|
||||||
|
}
|
||||||
|
printf(" |");
|
||||||
|
for (j = 0; j < 16; j++) {
|
||||||
|
if (packet[i + j] >= 33 && packet[i + j] <= 126)
|
||||||
|
printf("%c", packet[i + j]);
|
||||||
|
else
|
||||||
|
printf(".");
|
||||||
|
}
|
||||||
|
printf("|\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void dump_memoryt(uint32_t bottom_addr, uint32_t top_addr)
|
||||||
|
{
|
||||||
|
uint32_t addr;
|
||||||
|
uint8_t byte;
|
||||||
|
sram_bulk_read_start(bottom_addr);
|
||||||
|
printf("%08lx:", bottom_addr);
|
||||||
|
for ( addr = bottom_addr; addr < top_addr; addr++) {
|
||||||
|
if (addr%0x16 == 0)
|
||||||
|
printf("\n%08lx:", bottom_addr);
|
||||||
|
byte = sram_bulk_read();
|
||||||
|
sram_bulk_read_next();
|
||||||
|
printf(" %02x", byte);
|
||||||
|
}
|
||||||
|
sram_bulk_read_end();
|
||||||
|
}
|
||||||
12
avr/usbload/dump.h
Normal file
12
avr/usbload/dump.h
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
#ifndef __DUMP_H__
|
||||||
|
#define __DUMP_H__
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
void dump_packet(uint32_t addr,uint32_t len,uint8_t *packet);
|
||||||
|
void dump_memoryt(uint32_t bottom_addr, uint32_t top_addr);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
28
avr/usbload/fifo.c
Normal file
28
avr/usbload/fifo.c
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
#include "fifo.h"
|
||||||
|
|
||||||
|
void fifo_init(fifo_t * f, uint8_t * buffer, const uint8_t size)
|
||||||
|
{
|
||||||
|
f->count = 0;
|
||||||
|
f->pread = f->pwrite = buffer;
|
||||||
|
f->read2end = f->write2end = f->size = size;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t fifo_put(fifo_t * f, const uint8_t data)
|
||||||
|
{
|
||||||
|
return _inline_fifo_put(f, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t fifo_get_wait(fifo_t * f)
|
||||||
|
{
|
||||||
|
while (!f->count);
|
||||||
|
|
||||||
|
return _inline_fifo_get(f);
|
||||||
|
}
|
||||||
|
|
||||||
|
int fifo_get_nowait(fifo_t * f)
|
||||||
|
{
|
||||||
|
if (!f->count)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return (int) _inline_fifo_get(f);
|
||||||
|
}
|
||||||
69
avr/usbload/fifo.h
Normal file
69
avr/usbload/fifo.h
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
#ifndef __FIFO_H__
|
||||||
|
#define __FIFO_H__
|
||||||
|
|
||||||
|
#include <avr/io.h>
|
||||||
|
#include <avr/interrupt.h>
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint8_t volatile count; // # Zeichen im Puffer
|
||||||
|
uint8_t size; // Puffer-Größe
|
||||||
|
uint8_t *pread; // Lesezeiger
|
||||||
|
uint8_t *pwrite; // Schreibzeiger
|
||||||
|
uint8_t read2end, write2end; // # Zeichen bis zum Überlauf Lese-/Schreibzeiger
|
||||||
|
} fifo_t;
|
||||||
|
|
||||||
|
extern void fifo_init(fifo_t *, uint8_t * buf, const uint8_t size);
|
||||||
|
extern uint8_t fifo_put(fifo_t *, const uint8_t data);
|
||||||
|
extern uint8_t fifo_get_wait(fifo_t *);
|
||||||
|
extern int fifo_get_nowait(fifo_t *);
|
||||||
|
|
||||||
|
static inline uint8_t _inline_fifo_put(fifo_t * f, const uint8_t data)
|
||||||
|
{
|
||||||
|
if (f->count >= f->size)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
uint8_t *pwrite = f->pwrite;
|
||||||
|
|
||||||
|
*(pwrite++) = data;
|
||||||
|
|
||||||
|
uint8_t write2end = f->write2end;
|
||||||
|
|
||||||
|
if (--write2end == 0) {
|
||||||
|
write2end = f->size;
|
||||||
|
pwrite -= write2end;
|
||||||
|
}
|
||||||
|
|
||||||
|
f->write2end = write2end;
|
||||||
|
f->pwrite = pwrite;
|
||||||
|
|
||||||
|
uint8_t sreg = SREG;
|
||||||
|
cli();
|
||||||
|
f->count++;
|
||||||
|
SREG = sreg;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline uint8_t _inline_fifo_get(fifo_t * f)
|
||||||
|
{
|
||||||
|
uint8_t *pread = f->pread;
|
||||||
|
uint8_t data = *(pread++);
|
||||||
|
uint8_t read2end = f->read2end;
|
||||||
|
|
||||||
|
if (--read2end == 0) {
|
||||||
|
read2end = f->size;
|
||||||
|
pread -= read2end;
|
||||||
|
}
|
||||||
|
|
||||||
|
f->pread = pread;
|
||||||
|
f->read2end = read2end;
|
||||||
|
|
||||||
|
uint8_t sreg = SREG;
|
||||||
|
cli();
|
||||||
|
f->count--;
|
||||||
|
SREG = sreg;
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* _FIFO_H_ */
|
||||||
334
avr/usbload/main.c
Normal file
334
avr/usbload/main.c
Normal file
@@ -0,0 +1,334 @@
|
|||||||
|
#include <avr/io.h>
|
||||||
|
#include <avr/interrupt.h> /* for sei() */
|
||||||
|
#include <util/delay.h> /* for _delay_ms() */
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <avr/pgmspace.h> /* required by usbdrv.h */
|
||||||
|
|
||||||
|
#include "usbdrv.h"
|
||||||
|
#include "oddebug.h" /* This is also an example for using debug
|
||||||
|
* macros */
|
||||||
|
#include "config.h"
|
||||||
|
#include "requests.h" /* The custom request numbers we use */
|
||||||
|
#include "uart.h"
|
||||||
|
#include "sram.h"
|
||||||
|
#include "debug.h"
|
||||||
|
#include "crc.h"
|
||||||
|
#include "usb_bulk.h"
|
||||||
|
|
||||||
|
extern FILE uart_stdout;
|
||||||
|
|
||||||
|
uint8_t debug_level = ( DEBUG | DEBUG_USB );
|
||||||
|
|
||||||
|
uint8_t read_buffer[TRANSFER_BUFFER_SIZE];
|
||||||
|
uint32_t req_addr = 0;
|
||||||
|
uint32_t req_size;
|
||||||
|
uint8_t req_bank;
|
||||||
|
uint16_t req_bank_size;
|
||||||
|
uint8_t req_state = REQ_STATUS_IDLE;
|
||||||
|
uint8_t rx_remaining = 0;
|
||||||
|
uint8_t tx_remaining = 0;
|
||||||
|
uint16_t sync_errors = 0;
|
||||||
|
uint8_t tx_buffer[32];
|
||||||
|
uint8_t data_buffer[4];
|
||||||
|
uint32_t addr;
|
||||||
|
uint16_t crc = 0;
|
||||||
|
|
||||||
|
usbMsgLen_t usbFunctionSetup(uchar data[8])
|
||||||
|
{
|
||||||
|
|
||||||
|
usbRequest_t *rq = (void *) data;
|
||||||
|
uint8_t ret_len = 0;
|
||||||
|
/*
|
||||||
|
* -------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
if (rq->bRequest == USB_UPLOAD_INIT) {
|
||||||
|
|
||||||
|
if (req_state != REQ_STATUS_IDLE){
|
||||||
|
debug(DEBUG_USB,"USB_UPLOAD_INIT: ERROR state is not REQ_STATUS_IDLE\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
req_bank = 0;
|
||||||
|
rx_remaining = 0;
|
||||||
|
req_bank_size = 1 << rq->wValue.word;
|
||||||
|
sync_errors = 0;
|
||||||
|
crc = 0;
|
||||||
|
debug(DEBUG_USB,"USB_UPLOAD_INIT: bank_size=0x%x\n", req_bank_size);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* -------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
} else if (rq->bRequest == USB_UPLOAD_ADDR) {
|
||||||
|
|
||||||
|
req_state = REQ_STATUS_UPLOAD;
|
||||||
|
req_addr = rq->wValue.word;
|
||||||
|
req_addr = req_addr << 16;
|
||||||
|
req_addr = req_addr | rq->wIndex.word;
|
||||||
|
if (rx_remaining) {
|
||||||
|
sync_errors++;
|
||||||
|
debug
|
||||||
|
(DEBUG_USB,"USB_UPLOAD_ADDR: Out of sync addr=0x%lx remain=%i packet=%i sync_error=%i\n",
|
||||||
|
req_addr, rx_remaining, rq->wLength.word, sync_errors);
|
||||||
|
ret_len = 0;
|
||||||
|
}
|
||||||
|
rx_remaining = rq->wLength.word;
|
||||||
|
ret_len = USB_MAX_TRANS;
|
||||||
|
|
||||||
|
if (req_addr && (req_addr % 0x1000) == 0) {
|
||||||
|
debug(DEBUG_USB,"USB_UPLOAD_ADDR: bank=0x%02x addr=0x%08lx\n",
|
||||||
|
req_bank, req_addr);
|
||||||
|
crc_check_bulk_memory(req_addr - 0x1000,req_addr);
|
||||||
|
|
||||||
|
}
|
||||||
|
if (req_addr && req_addr % req_bank_size == 0) {
|
||||||
|
debug(DEBUG_USB,"USB_UPLOAD_ADDR: req_bank=0x%02x addr=0x%08lx\n",
|
||||||
|
req_bank, req_addr);
|
||||||
|
|
||||||
|
req_bank++;
|
||||||
|
}
|
||||||
|
ret_len = USB_MAX_TRANS;
|
||||||
|
/*
|
||||||
|
* -------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
} else if (rq->bRequest == USB_DOWNLOAD_INIT) {
|
||||||
|
debug(DEBUG_USB,"USB_DOWNLOAD_INIT\n");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* -------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
} else if (rq->bRequest == USB_DOWNLOAD_ADDR) {
|
||||||
|
debug(DEBUG_USB,"USB_DOWNLOAD_ADDR\n");
|
||||||
|
/*
|
||||||
|
* -------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
} else if (rq->bRequest == USB_BULK_UPLOAD_INIT) {
|
||||||
|
if (req_state != REQ_STATUS_IDLE){
|
||||||
|
debug(DEBUG_USB,"USB_BULK_UPLOAD_INIT: ERROR state is not REQ_STATUS_IDLE\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
req_bank = 0;
|
||||||
|
rx_remaining = 0;
|
||||||
|
req_bank_size = (1 << rq->wValue.word) & 0xffff;
|
||||||
|
sync_errors = 0;
|
||||||
|
debug(DEBUG_USB,"USB_BULK_UPLOAD_INIT: bank_size=0x%x\n", req_bank_size);
|
||||||
|
/*
|
||||||
|
* -------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
} else if (rq->bRequest == USB_BULK_UPLOAD_ADDR) {
|
||||||
|
|
||||||
|
if (req_state != REQ_STATUS_IDLE){
|
||||||
|
debug(DEBUG_USB,"USB_BULK_UPLOAD_ADDR: ERROR state is not REQ_STATUS_IDLE\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
req_state = REQ_STATUS_BULK_UPLOAD;
|
||||||
|
req_addr = rq->wValue.word;
|
||||||
|
req_addr = req_addr << 16;
|
||||||
|
req_addr = req_addr | rq->wIndex.word;
|
||||||
|
debug(DEBUG_USB,"USB_BULK_UPLOAD_ADDR: req_bank=0x%02x addr=0x%08lx \n",req_bank,req_addr);
|
||||||
|
ret_len = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* -------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
} else if (rq->bRequest == USB_BULK_UPLOAD_NEXT) {
|
||||||
|
|
||||||
|
if (req_state != REQ_STATUS_BULK_UPLOAD){
|
||||||
|
debug(DEBUG_USB,"USB_BULK_UPLOAD_NEXT: ERROR state is not REQ_STATUS_BULK_UPLOAD\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (rx_remaining) {
|
||||||
|
sync_errors++;
|
||||||
|
debug(DEBUG_USB,
|
||||||
|
"USB_BULK_UPLOAD_NEXT: Out of sync addr=0x%lx remain=%i packet=%i sync_error=%i\n",
|
||||||
|
req_addr, rx_remaining, rq->wLength.word, sync_errors);
|
||||||
|
ret_len = 0;
|
||||||
|
}
|
||||||
|
rx_remaining = rq->wLength.word;
|
||||||
|
ret_len = USB_MAX_TRANS;
|
||||||
|
if (req_addr && req_addr % req_bank_size == 0) {
|
||||||
|
debug(DEBUG_USB,"USB_BULK_UPLOAD_NEXT: req_bank=0x%02x addr= 0x%08lx \n",
|
||||||
|
req_bank, req_addr);
|
||||||
|
req_bank++;
|
||||||
|
}
|
||||||
|
ret_len = USB_MAX_TRANS;
|
||||||
|
/*
|
||||||
|
* -------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
} else if (rq->bRequest == USB_BULK_UPLOAD_END) {
|
||||||
|
if (req_state != REQ_STATUS_BULK_UPLOAD){
|
||||||
|
debug(DEBUG_USB,"USB_BULK_UPLOAD_END: ERROR state is not REQ_STATUS_BULK_UPLOAD\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
debug(DEBUG_USB,"USB_BULK_UPLOAD_END:\n");
|
||||||
|
req_state = REQ_STATUS_IDLE;
|
||||||
|
sram_bulk_write_end();
|
||||||
|
ret_len = 0;
|
||||||
|
/*
|
||||||
|
* -------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
} else if (rq->bRequest == USB_CRC) {
|
||||||
|
req_addr = rq->wValue.word;
|
||||||
|
req_addr = req_addr << 16;
|
||||||
|
req_addr = req_addr | rq->wIndex.word;
|
||||||
|
debug(DEBUG_USB,"USB_CRC: addr=0x%08lx \n", req_addr);
|
||||||
|
crc_check_bulk_memory(0x000000,req_addr);
|
||||||
|
ret_len = 0;
|
||||||
|
/*
|
||||||
|
* -------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
} else if (rq->bRequest == USB_SNES_BOOT) {
|
||||||
|
req_state = REQ_STATUS_BOOT;
|
||||||
|
debug(DEBUG_USB,"USB_SNES_BOOT: ");
|
||||||
|
ret_len = 0;
|
||||||
|
/*
|
||||||
|
* -------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
} else if (rq->bRequest == USB_CRC_ADDR) {
|
||||||
|
req_state = REQ_STATUS_CRC;
|
||||||
|
req_addr = rq->wValue.word;
|
||||||
|
req_addr = req_addr << 16;
|
||||||
|
req_addr = req_addr | rq->wIndex.word;
|
||||||
|
debug(DEBUG_USB,"USB_CRC_ADDR: addr=0x%lx size=%i\n", req_addr,
|
||||||
|
rq->wLength.word);
|
||||||
|
req_size = rq->wLength.word;
|
||||||
|
req_size = req_size << 2;
|
||||||
|
tx_remaining = 2;
|
||||||
|
debug(DEBUG_USB,"USB_CRC_ADDR: addr=0x%lx size=%li\n", req_addr, req_size);
|
||||||
|
|
||||||
|
crc = crc_check_memory_range(req_addr,req_size,read_buffer);
|
||||||
|
tx_buffer[0] = crc & 0xff;
|
||||||
|
tx_buffer[1] = (crc >> 8) & 0xff;
|
||||||
|
ret_len = 2;
|
||||||
|
req_state = REQ_STATUS_IDLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
usbMsgPtr = data_buffer;
|
||||||
|
return ret_len; /* default for not implemented requests: return
|
||||||
|
* no data back to host */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* -------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
void test_read_write(){
|
||||||
|
|
||||||
|
uint8_t i;
|
||||||
|
uint32_t addr;
|
||||||
|
avr_bus_active();
|
||||||
|
addr = 0x000000;
|
||||||
|
i = 1;
|
||||||
|
while (addr++ <= 0x0000ff){
|
||||||
|
sram_write(addr,i++);
|
||||||
|
}
|
||||||
|
addr = 0x000000;
|
||||||
|
while (addr++ <= 0x0000ff){
|
||||||
|
printf("read addr=0x%08lx %x\n",addr,sram_read(addr));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void test_bulk_read_write(){
|
||||||
|
|
||||||
|
uint8_t i;
|
||||||
|
uint32_t addr;
|
||||||
|
avr_bus_active();
|
||||||
|
addr = 0x000000;
|
||||||
|
i = 0;
|
||||||
|
sram_bulk_write_start(addr);
|
||||||
|
while (addr++ <= 0x3fffff){
|
||||||
|
sram_bulk_write(i++);
|
||||||
|
sram_bulk_write_next();
|
||||||
|
}
|
||||||
|
sram_bulk_write_end();
|
||||||
|
|
||||||
|
addr = 0x000000;
|
||||||
|
sram_bulk_read_start(addr);
|
||||||
|
while (addr <= 0x3fffff){
|
||||||
|
printf("addr=0x%08lx %x\n",addr,sram_bulk_read());
|
||||||
|
sram_bulk_read_next();
|
||||||
|
addr ++;
|
||||||
|
}
|
||||||
|
sram_bulk_read_end();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void test_non_zero_memory(uint32_t bottom_addr,uint32_t top_addr)
|
||||||
|
{
|
||||||
|
uint32_t addr = 0;
|
||||||
|
uint8_t c;
|
||||||
|
sram_bulk_read_start(bottom_addr);
|
||||||
|
for (addr = bottom_addr; addr < top_addr; addr++) {
|
||||||
|
c = sram_bulk_read();
|
||||||
|
if (c!=0xff)
|
||||||
|
printf("addr=0x%08lx c=0x%x\n",addr,c);
|
||||||
|
sram_bulk_read_next();
|
||||||
|
}
|
||||||
|
sram_bulk_read_end();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void test_crc(){
|
||||||
|
printf("test_crc: clear\n");
|
||||||
|
avr_bus_active();
|
||||||
|
sram_bulk_set(0x000000,0x10000,0xff);
|
||||||
|
printf("test_crc: crc\n");
|
||||||
|
crc_check_bulk_memory(0x000000,0x10000);
|
||||||
|
printf("test_crc: check\n");
|
||||||
|
test_non_zero_memory(0x000000,0x10000);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
uint8_t i;
|
||||||
|
|
||||||
|
uart_init();
|
||||||
|
stdout = &uart_stdout;
|
||||||
|
|
||||||
|
system_init();
|
||||||
|
printf("Sytem Init\n");
|
||||||
|
|
||||||
|
avr_bus_active();
|
||||||
|
usbInit();
|
||||||
|
printf("USB Init\n");
|
||||||
|
usbDeviceDisconnect(); /* enforce re-enumeration, do this while
|
||||||
|
* interrupts are disabled! */
|
||||||
|
cli();
|
||||||
|
printf("USB disconnect\n");
|
||||||
|
i = 10;
|
||||||
|
while (--i) { /* fake USB disconnect for > 250 ms */
|
||||||
|
led_on();
|
||||||
|
_delay_ms(35);
|
||||||
|
led_off();
|
||||||
|
_delay_ms(65);
|
||||||
|
|
||||||
|
}
|
||||||
|
led_on();
|
||||||
|
usbDeviceConnect();
|
||||||
|
printf("USB connect\n");
|
||||||
|
sei();
|
||||||
|
printf("USB poll\n");
|
||||||
|
while (req_state != REQ_STATUS_BOOT){
|
||||||
|
usbPoll();
|
||||||
|
}
|
||||||
|
printf("USB poll done\n");
|
||||||
|
usbDeviceDisconnect();
|
||||||
|
printf("USB disconnect\n");
|
||||||
|
crc_check_bulk_memory(0x000000,0x1000);
|
||||||
|
|
||||||
|
printf("Disable snes WR\n");
|
||||||
|
snes_wr_disable();
|
||||||
|
printf("Use Snes lowrom\n");
|
||||||
|
snes_lorom();
|
||||||
|
printf("Activate Snes bus\n");
|
||||||
|
snes_bus_active();
|
||||||
|
|
||||||
|
|
||||||
|
while(1);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
34
avr/usbload/requests.h
Normal file
34
avr/usbload/requests.h
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
/* 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__
|
||||||
|
#define __REQUESTS_H__
|
||||||
|
|
||||||
|
#define USB_UPLOAD_INIT 0
|
||||||
|
#define USB_UPLOAD_ADDR 1
|
||||||
|
|
||||||
|
#define USB_DOWNLOAD_INIT 2
|
||||||
|
#define USB_DOWNLOAD_ADDR 3
|
||||||
|
|
||||||
|
#define USB_CRC 4
|
||||||
|
#define USB_CRC_ADDR 5
|
||||||
|
|
||||||
|
#define USB_BULK_UPLOAD_INIT 6
|
||||||
|
#define USB_BULK_UPLOAD_ADDR 7
|
||||||
|
#define USB_BULK_UPLOAD_NEXT 8
|
||||||
|
#define USB_BULK_UPLOAD_END 9
|
||||||
|
#define USB_SNES_BOOT 10
|
||||||
|
|
||||||
|
#endif /* __REQUESTS_H_INCLUDED__ */
|
||||||
318
avr/usbload/sram.c
Normal file
318
avr/usbload/sram.c
Normal file
@@ -0,0 +1,318 @@
|
|||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <avr/io.h>
|
||||||
|
#include <util/delay.h> /* for _delay_ms() */
|
||||||
|
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
#include "sram.h"
|
||||||
|
#include "uart.h"
|
||||||
|
#include "debug.h"
|
||||||
|
|
||||||
|
void system_init(void)
|
||||||
|
{
|
||||||
|
/*-------------------------------------------------*/
|
||||||
|
|
||||||
|
DDRA = 0x00;
|
||||||
|
PORTA = 0x00;
|
||||||
|
|
||||||
|
/*-------------------------------------------------*/
|
||||||
|
|
||||||
|
DDRC |= ( (1 << AVR_ADDR_LATCH_PIN)
|
||||||
|
| (1 << AVR_ADDR_SCK_PIN)
|
||||||
|
| (1 << AVR_ADDR_SER_PIN)
|
||||||
|
| (1 << AVR_ADDR_LOAD_PIN)
|
||||||
|
| (1 << AVR_ADDR_DOWN_PIN)
|
||||||
|
| (1 << AVR_ADDR_UP_PIN));
|
||||||
|
|
||||||
|
DDRC &= ~ (1 << SNES_WR_PIN);
|
||||||
|
|
||||||
|
PORTC &= ~((1 << AVR_ADDR_LATCH_PIN)
|
||||||
|
| (1 << AVR_ADDR_SCK_PIN));
|
||||||
|
|
||||||
|
|
||||||
|
PORTC |= ( (1 << AVR_ADDR_DOWN_PIN)
|
||||||
|
| (1 << AVR_ADDR_UP_PIN)
|
||||||
|
| (1 << AVR_ADDR_LOAD_PIN)
|
||||||
|
| (1 << SNES_WR_PIN));
|
||||||
|
/*-------------------------------------------------*/
|
||||||
|
|
||||||
|
DDRB |= ( (1 << AVR_RD_PIN)
|
||||||
|
| (1 << AVR_WR_PIN)
|
||||||
|
| (1 << AVR_CS_PIN)
|
||||||
|
| (1 << SNES_IRQ_PIN));
|
||||||
|
|
||||||
|
PORTB |= ( (1 << AVR_RD_PIN)
|
||||||
|
| (1 << AVR_WR_PIN)
|
||||||
|
| (1 << AVR_CS_PIN)
|
||||||
|
| (1 << SNES_IRQ_PIN));
|
||||||
|
/*-------------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
|
DDRD |= ( (1 << AVR_SNES_SW_PIN)
|
||||||
|
| (1 << HI_LOROM_SW_PIN)
|
||||||
|
| (1 << SNES_WR_EN_PIN));
|
||||||
|
|
||||||
|
PORTD |= (1 << HI_LOROM_SW_PIN);
|
||||||
|
|
||||||
|
PORTD &= ~((1 << AVR_SNES_SW_PIN)
|
||||||
|
| (1 << SNES_WR_EN_PIN));
|
||||||
|
|
||||||
|
/*-------------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void sreg_set(uint32_t addr)
|
||||||
|
{
|
||||||
|
uint8_t i = 24;
|
||||||
|
debug(DEBUG_SREG,"sreg_set: addr=0x%08lx",addr);
|
||||||
|
while(i--) {
|
||||||
|
if ((addr & ( 1L << i))){
|
||||||
|
debug(DEBUG_SREG,"1");
|
||||||
|
AVR_ADDR_SER_PORT |= ( 1 << AVR_ADDR_SER_PIN);
|
||||||
|
} else {
|
||||||
|
AVR_ADDR_SER_PORT &= ~( 1 << AVR_ADDR_SER_PIN);
|
||||||
|
debug(DEBUG_SREG,"0");
|
||||||
|
}
|
||||||
|
AVR_ADDR_SCK_PORT |= (1 << AVR_ADDR_SCK_PIN);
|
||||||
|
AVR_ADDR_SCK_PORT &= ~(1 << AVR_ADDR_SCK_PIN);
|
||||||
|
}
|
||||||
|
debug(DEBUG_SREG,"\n");
|
||||||
|
AVR_ADDR_LATCH_PORT |= (1 << AVR_ADDR_LATCH_PIN);
|
||||||
|
AVR_ADDR_LATCH_PORT &= ~(1 << AVR_ADDR_LATCH_PIN);
|
||||||
|
|
||||||
|
counter_load();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void sram_bulk_read_start(uint32_t addr)
|
||||||
|
{
|
||||||
|
debug(DEBUG_SRAM,"sram_bulk_read_start: addr=0x%08lx\n\r", addr);
|
||||||
|
avr_data_in();
|
||||||
|
|
||||||
|
AVR_CS_PORT &= ~(1 << AVR_CS_PIN);
|
||||||
|
AVR_WR_PORT |= (1 << AVR_WR_PIN);
|
||||||
|
AVR_RD_PORT |= (1 << AVR_RD_PIN);
|
||||||
|
|
||||||
|
sreg_set(addr);
|
||||||
|
|
||||||
|
AVR_RD_PORT &= ~(1 << AVR_RD_PIN);
|
||||||
|
asm volatile ("nop");
|
||||||
|
asm volatile ("nop");
|
||||||
|
asm volatile ("nop");
|
||||||
|
asm volatile ("nop");
|
||||||
|
asm volatile ("nop");
|
||||||
|
asm volatile ("nop");
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void sram_bulk_read_next(void)
|
||||||
|
{
|
||||||
|
AVR_RD_PORT |= (1 << AVR_RD_PIN);
|
||||||
|
counter_up();
|
||||||
|
AVR_RD_PORT &= ~(1 << AVR_RD_PIN);
|
||||||
|
|
||||||
|
asm volatile ("nop");
|
||||||
|
asm volatile ("nop");
|
||||||
|
asm volatile ("nop");
|
||||||
|
asm volatile ("nop");
|
||||||
|
asm volatile ("nop");
|
||||||
|
asm volatile ("nop");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline uint8_t sram_bulk_read(void)
|
||||||
|
{
|
||||||
|
return AVR_DATA_PIN;
|
||||||
|
}
|
||||||
|
|
||||||
|
void sram_bulk_read_end(void)
|
||||||
|
{
|
||||||
|
debug(DEBUG_SRAM,"sram_bulk_read_end:");
|
||||||
|
|
||||||
|
AVR_RD_PORT |= (1 << AVR_RD_PIN);
|
||||||
|
AVR_CS_PORT |= (1 << AVR_CS_PIN);
|
||||||
|
avr_data_in();
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t sram_read(uint32_t addr)
|
||||||
|
{
|
||||||
|
uint8_t byte;
|
||||||
|
debug(DEBUG_SRAM_RAW,"sram_read: addr=0x%08lx\n\r", addr);
|
||||||
|
|
||||||
|
avr_data_in();
|
||||||
|
|
||||||
|
AVR_CS_PORT &= ~(1 << AVR_CS_PIN);
|
||||||
|
|
||||||
|
AVR_WR_PORT |= (1 << AVR_WR_PIN);
|
||||||
|
AVR_RD_PORT |= (1 << AVR_RD_PIN);
|
||||||
|
|
||||||
|
sreg_set(addr);
|
||||||
|
|
||||||
|
AVR_RD_PORT &= ~(1 << AVR_RD_PIN);
|
||||||
|
|
||||||
|
asm volatile ("nop");
|
||||||
|
asm volatile ("nop");
|
||||||
|
asm volatile ("nop");
|
||||||
|
asm volatile ("nop");
|
||||||
|
asm volatile ("nop");
|
||||||
|
asm volatile ("nop");
|
||||||
|
|
||||||
|
byte = AVR_DATA_PIN;
|
||||||
|
|
||||||
|
AVR_RD_PORT |= (1 << AVR_RD_PIN);
|
||||||
|
AVR_CS_PORT |= (1 << AVR_CS_PIN);
|
||||||
|
|
||||||
|
avr_data_in();
|
||||||
|
return byte;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void sram_bulk_write_start(uint32_t addr)
|
||||||
|
{
|
||||||
|
debug(DEBUG_SRAM,"sram_bulk_write_start: addr=0x%08lx\n\r", addr);
|
||||||
|
|
||||||
|
avr_data_out();
|
||||||
|
|
||||||
|
AVR_CS_PORT &= ~(1 << AVR_CS_PIN);
|
||||||
|
AVR_WR_PORT |= (1 << AVR_WR_PIN);
|
||||||
|
AVR_RD_PORT |= (1 << AVR_RD_PIN);
|
||||||
|
|
||||||
|
sreg_set(addr);
|
||||||
|
|
||||||
|
AVR_WR_PORT &= ~(1 << AVR_WR_PIN);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void sram_bulk_write_next(void)
|
||||||
|
{
|
||||||
|
AVR_RD_PORT |= (1 << AVR_RD_PIN);
|
||||||
|
counter_up();
|
||||||
|
AVR_WR_PORT &= ~(1 << AVR_WR_PIN);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void sram_bulk_write( uint8_t data)
|
||||||
|
{
|
||||||
|
AVR_DATA_PORT = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
void sram_bulk_write_end(void)
|
||||||
|
{
|
||||||
|
debug(DEBUG_SRAM,"sram_bulk_write_end:");
|
||||||
|
AVR_WR_PORT |= (1 << AVR_WR_PIN);
|
||||||
|
AVR_CS_PORT |= (1 << AVR_CS_PIN);
|
||||||
|
avr_data_in();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void sram_write(uint32_t addr, uint8_t data)
|
||||||
|
{
|
||||||
|
debug(DEBUG_SRAM_RAW,"sram_write: addr=0x%08lx data=%x\n\r", addr, data);
|
||||||
|
|
||||||
|
avr_data_out();
|
||||||
|
|
||||||
|
AVR_CS_PORT &= ~(1 << AVR_CS_PIN);
|
||||||
|
AVR_WR_PORT |= (1 << AVR_WR_PIN);
|
||||||
|
AVR_RD_PORT |= (1 << AVR_RD_PIN);
|
||||||
|
|
||||||
|
sreg_set(addr);
|
||||||
|
|
||||||
|
AVR_WR_PORT &= ~(1 << AVR_WR_PIN);
|
||||||
|
AVR_DATA_PORT = data;
|
||||||
|
|
||||||
|
AVR_WR_PORT |= (1 << AVR_WR_PIN);
|
||||||
|
AVR_CS_PORT |= (1 << AVR_CS_PIN);
|
||||||
|
|
||||||
|
avr_data_in();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void sram_bulk_copy(uint32_t addr, uint8_t * src, uint32_t len)
|
||||||
|
{
|
||||||
|
|
||||||
|
uint32_t i;
|
||||||
|
uint8_t *ptr = src;
|
||||||
|
debug(DEBUG_SRAM,"sram_copy: addr=0x%08lx src=0x%p len=%li\n\r", addr,src,len);
|
||||||
|
sram_bulk_write_start(addr);
|
||||||
|
for (i = addr; i < (addr + len); i++){
|
||||||
|
sram_bulk_write(*ptr++);
|
||||||
|
sram_bulk_write_next();
|
||||||
|
}
|
||||||
|
sram_bulk_write_end();
|
||||||
|
}
|
||||||
|
|
||||||
|
void sram_bulk_read_buffer(uint32_t addr, uint8_t * dst, uint32_t len)
|
||||||
|
{
|
||||||
|
|
||||||
|
uint32_t i;
|
||||||
|
uint8_t *ptr = dst;
|
||||||
|
debug(DEBUG_SRAM,"sram_bulk_read_buffer: addr=0x%08lx dst=0x%p len=%li\n\r", addr,dst,len);
|
||||||
|
sram_bulk_read_start(addr);
|
||||||
|
for (i = addr; i < (addr + len); i++) {
|
||||||
|
*ptr = sram_bulk_read();
|
||||||
|
sram_bulk_read_next();
|
||||||
|
ptr++;
|
||||||
|
}
|
||||||
|
sram_bulk_read_end();
|
||||||
|
}
|
||||||
|
|
||||||
|
void sram_bulk_set(uint32_t addr, uint32_t len,uint8_t value){
|
||||||
|
uint32_t i;
|
||||||
|
debug(DEBUG_SRAM,"sram_bulk_set: addr=0x%08lx len=%li\n\r", addr,len);
|
||||||
|
sram_bulk_write_start(addr);
|
||||||
|
for (i = addr; i < (addr + len); i++) {
|
||||||
|
if (0 == i % 0xfff)
|
||||||
|
debug(DEBUG_SRAM,"sram_bulk_set: addr=0x%08lx\n\r", i);
|
||||||
|
sram_bulk_write(value);
|
||||||
|
sram_bulk_write_next();
|
||||||
|
}
|
||||||
|
sram_bulk_write_end();
|
||||||
|
}
|
||||||
|
|
||||||
|
void sram_setr(uint32_t addr, uint32_t len,uint8_t value)
|
||||||
|
{
|
||||||
|
uint32_t i;
|
||||||
|
debug(DEBUG_SRAM,"sram_clear: addr=0x%08lx len=%li\n\r", addr,len);
|
||||||
|
for (i = addr; i < (addr + len); i++) {
|
||||||
|
if (0 == i % 0xfff)
|
||||||
|
debug(DEBUG_SRAM,"sram_clear: addr=0x%08lx\n\r", i);
|
||||||
|
sram_write(i, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void sram_copy(uint32_t addr, uint8_t * src, uint32_t len)
|
||||||
|
{
|
||||||
|
|
||||||
|
uint32_t i;
|
||||||
|
uint8_t *ptr = src;
|
||||||
|
debug(DEBUG_SRAM,"sram_copy: addr=0x%08lx src=0x%p len=%li\n\r", addr,src,len);
|
||||||
|
for (i = addr; i < (addr + len); i++)
|
||||||
|
sram_write(i, *ptr++);
|
||||||
|
}
|
||||||
|
|
||||||
|
void sram_read_buffer(uint32_t addr, uint8_t * dst, uint32_t len)
|
||||||
|
{
|
||||||
|
|
||||||
|
uint32_t i;
|
||||||
|
uint8_t *ptr = dst;
|
||||||
|
debug(DEBUG_SRAM,"sram_read_buffer: addr=0x%08lx dst=0x%p len=%li\n\r", addr,dst,len);
|
||||||
|
for (i = addr; i < (addr + len); i++) {
|
||||||
|
*ptr = sram_read(i);
|
||||||
|
ptr++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint8_t sram_check(uint8_t * buffer, uint32_t len)
|
||||||
|
{
|
||||||
|
uint16_t cnt;
|
||||||
|
debug(DEBUG_SRAM,"sram_check: len=%li\n\r",len);
|
||||||
|
for (cnt = 0; cnt < len; cnt++)
|
||||||
|
if (buffer[cnt])
|
||||||
|
return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
168
avr/usbload/sram.h
Normal file
168
avr/usbload/sram.h
Normal file
@@ -0,0 +1,168 @@
|
|||||||
|
#ifndef __SRAM_H__
|
||||||
|
#define __SRAM_H__
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <avr/io.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* ---------------------------- PORT A ---------------------------- */
|
||||||
|
|
||||||
|
#define AVR_DATA_PORT PORTA
|
||||||
|
#define AVR_DATA_DIR DDRA
|
||||||
|
#define AVR_DATA_PIN PINA
|
||||||
|
|
||||||
|
#define avr_data_in() ((AVR_DATA_DIR = 0x00),\
|
||||||
|
(AVR_DATA_PORT = 0x00))
|
||||||
|
|
||||||
|
#define avr_data_out() (AVR_DATA_DIR = 0xff)
|
||||||
|
|
||||||
|
#define LED_PORT PORTC
|
||||||
|
#define LED_DIR DDRC
|
||||||
|
#define LED_PIN PC7
|
||||||
|
|
||||||
|
#define led_on() ((LED_PORT &=~ (1 << LED_PIN)),\
|
||||||
|
(LED_DIR &=~ (1 << LED_PIN)))
|
||||||
|
#define led_off() ((LED_PORT &=~ (1 << LED_PIN)),\
|
||||||
|
(LED_DIR |= (1 << LED_PIN)))
|
||||||
|
|
||||||
|
/* ---------------------------- PORT B ---------------------------- */
|
||||||
|
|
||||||
|
#define AVR_PORT PORTB
|
||||||
|
#define AVR_DIR DDRB
|
||||||
|
#define AVR_RD_PORT PORTB
|
||||||
|
#define AVR_RD_DIR DDRB
|
||||||
|
#define AVR_RD_PIN PB2
|
||||||
|
|
||||||
|
#define avr_rd_hi() (AVR_RD_PORT |= (1 << AVR_RD_PIN))
|
||||||
|
#define avr_rd_lo() (AVR_RD_PORT &= ~(1 << AVR_RD_PIN))
|
||||||
|
|
||||||
|
#define AVR_WR_PORT PORTB
|
||||||
|
#define AVR_WR_DIR DDRB
|
||||||
|
#define AVR_WR_PIN PB1
|
||||||
|
|
||||||
|
#define avr_wr_hi() (AVR_WR_PORT |= (1 << AVR_WR_PIN))
|
||||||
|
#define avr_wr_lo() (AVR_WR_PORT &= ~(1 << AVR_WR_PIN))
|
||||||
|
|
||||||
|
#define AVR_CS_PORT PORTB
|
||||||
|
#define AVR_CS_DIR DDRB
|
||||||
|
#define AVR_CS_PIN PB0
|
||||||
|
|
||||||
|
#define avr_cs_hi() (AVR_CS_PORT |= (1 << AVR_CS_PIN))
|
||||||
|
#define avr_cs_lo() (AVR_CS_PORT &= ~(1 << AVR_CS_PIN))
|
||||||
|
|
||||||
|
#define SNES_IRQ_PORT PORTB
|
||||||
|
#define SNES_IRQ_DIR DDRB
|
||||||
|
#define SNES_IRQ_PIN PB3
|
||||||
|
|
||||||
|
#define snes_irq_off() (SNES_IRQ_PORT |= (1 << SNES_IRQ_PIN))
|
||||||
|
#define snes_irq_on() (SNES_IRQ_PORT &= ~(1 << SNES_IRQ_PIN))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* ---------------------------- PORT C ---------------------------- */
|
||||||
|
|
||||||
|
#define AVR_ADDR_PORT PORTC
|
||||||
|
#define AVR_ADDR_DIR DDRC
|
||||||
|
#define AVR_ADDR_LATCH_PORT PORTC
|
||||||
|
#define AVR_ADDR_LATCH_DIR DDRC
|
||||||
|
#define AVR_ADDR_LATCH_PIN PC6
|
||||||
|
|
||||||
|
#define avr_addr_latch_hi() (AVR_ADDR_LATCH_PORT |= (1 << AVR_ADDR_LATCH_PIN)))
|
||||||
|
#define avr_addr_latch_lo() (AVR_ADDR_LATCH_PORT &= ~(1 << AVR_ADDR_LATCH_PIN)))
|
||||||
|
|
||||||
|
#define AVR_ADDR_SCK_PORT PORTC
|
||||||
|
#define AVR_ADDR_SCK_DIR DDRC
|
||||||
|
#define AVR_ADDR_SCK_PIN PC5
|
||||||
|
|
||||||
|
#define avr_addr_sck_hi() (AVR_ADDR_SCK_PORT |= (1 << AVR_ADDR_SCK_PIN)))
|
||||||
|
#define avr_addr_sck_lo() (AVR_ADDR_SCK_PORT &= ~(1 << AVR_ADDR_SCK_PIN)))
|
||||||
|
|
||||||
|
#define AVR_ADDR_SER_PORT PORTC
|
||||||
|
#define AVR_ADDR_SER_DIR DDRC
|
||||||
|
#define AVR_ADDR_SER_PIN PC4
|
||||||
|
|
||||||
|
#define avr_addr_ser_hi() (AVR_ADDR_SER_PORT |= (1 << AVR_ADDR_SER_PIN)))
|
||||||
|
#define avr_addr_ser_lo() (AVR_ADDR_SER_PORT &= ~(1 << AVR_ADDR_SER_PIN)))
|
||||||
|
|
||||||
|
#define AVR_ADDR_LOAD_PORT PORTC
|
||||||
|
#define AVR_ADDR_LOAD_DIR DDRC
|
||||||
|
#define AVR_ADDR_LOAD_PIN PC2
|
||||||
|
|
||||||
|
#define counter_load() ((AVR_ADDR_LOAD_PORT &= ~(1 << AVR_ADDR_LOAD_PIN)),\
|
||||||
|
(AVR_ADDR_LOAD_PORT |= (1 << AVR_ADDR_LOAD_PIN)))
|
||||||
|
|
||||||
|
#define AVR_ADDR_DOWN_PORT PORTC
|
||||||
|
#define AVR_ADDR_DOWN_DIR DDRC
|
||||||
|
#define AVR_ADDR_DOWN_PIN PC1
|
||||||
|
|
||||||
|
#define counter_down() ((AVR_ADDR_DOWN_PORT &= ~(1 << AVR_ADDR_DOWN_PIN)),\
|
||||||
|
(AVR_ADDR_DOWN_PORT |= (1 << AVR_ADDR_DOWN_PIN)))
|
||||||
|
|
||||||
|
#define AVR_ADDR_UP_PORT PORTC
|
||||||
|
#define AVR_ADDR_UP_DIR DDRC
|
||||||
|
#define AVR_ADDR_UP_PIN PC0
|
||||||
|
|
||||||
|
#define counter_up() ((AVR_ADDR_UP_PORT &= ~(1 << AVR_ADDR_UP_PIN)),\
|
||||||
|
(AVR_ADDR_UP_PORT |= (1 << AVR_ADDR_UP_PIN)))
|
||||||
|
|
||||||
|
#define SNES_WR_PORT PORTC
|
||||||
|
#define SNES_WR_DIR DDRC
|
||||||
|
#define SNES_WR_PIN PC3
|
||||||
|
|
||||||
|
/* ---------------------------- PORT D ---------------------------- */
|
||||||
|
|
||||||
|
#define AVR_SNES_PORT PORTD
|
||||||
|
#define AVR_SNES_DIR DDRD
|
||||||
|
#define AVR_SNES_SW_PORT PORTD
|
||||||
|
#define AVR_SNES_SW_DIR DDRD
|
||||||
|
#define AVR_SNES_SW_PIN PD5
|
||||||
|
|
||||||
|
#define avr_bus_active() ((AVR_SNES_SW_PORT &= ~(1 << AVR_SNES_SW_PIN)),\
|
||||||
|
(HI_LOROM_SW_PORT |= (1 << HI_LOROM_SW_PIN)))
|
||||||
|
|
||||||
|
#define snes_bus_active() (AVR_SNES_SW_PORT |= (1 << AVR_SNES_SW_PIN))
|
||||||
|
|
||||||
|
#define HI_LOROM_SW_PORT PORTD
|
||||||
|
#define HI_LOROM_SW_DIR DDRD
|
||||||
|
#define HI_LOROM_SW_PIN PD6
|
||||||
|
|
||||||
|
#define snes_hirom() (HI_LOROM_SW_PORT &= ~(1 << HI_LOROM_SW_PIN))
|
||||||
|
#define snes_lorom() (HI_LOROM_SW_PORT |= (1 << HI_LOROM_SW_PIN))
|
||||||
|
|
||||||
|
#define SNES_WR_EN_PORT PORTD
|
||||||
|
#define SNES_WR_EN_DIR DDRD
|
||||||
|
#define SNES_WR_EN_PIN PD7
|
||||||
|
|
||||||
|
#define snes_wr_disable() (SNES_WR_EN_PORT &= ~(1 << SNES_WR_EN_PIN))
|
||||||
|
#define snes_wr_enable() (SNES_WR_EN_PORT |= (1 << SNES_WR_EN_PIN))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void system_init(void);
|
||||||
|
void sreg_set(uint32_t addr);
|
||||||
|
|
||||||
|
uint8_t sram_read(uint32_t addr);
|
||||||
|
void sram_write(uint32_t addr, uint8_t data);
|
||||||
|
void sram_set(uint32_t addr, uint32_t len, uint8_t value);
|
||||||
|
void sram_copy(uint32_t addr,uint8_t *src, uint32_t len);
|
||||||
|
void sram_read_buffer(uint32_t addr,uint8_t *dst, uint32_t len);
|
||||||
|
|
||||||
|
void sram_bulk_read_start(uint32_t addr);
|
||||||
|
inline void sram_bulk_read_next(void);
|
||||||
|
inline void sram_bulk_read_end(void);
|
||||||
|
uint8_t sram_bulk_read(void);
|
||||||
|
|
||||||
|
void sram_bulk_write_start(uint32_t addr);
|
||||||
|
inline void sram_bulk_write_next(void);
|
||||||
|
inline void sram_bulk_write_end(void);
|
||||||
|
void sram_bulk_write(uint8_t data);
|
||||||
|
|
||||||
|
void sram_bulk_copy(uint32_t addr, uint8_t * src, uint32_t len);
|
||||||
|
void sram_bulk_read_buffer(uint32_t addr, uint8_t * dst, uint32_t len);
|
||||||
|
void sram_bulk_set(uint32_t addr, uint32_t len,uint8_t value);
|
||||||
|
|
||||||
|
#endif
|
||||||
78
avr/usbload/uart.c
Normal file
78
avr/usbload/uart.c
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
#include <avr/io.h>
|
||||||
|
#include <avr/interrupt.h>
|
||||||
|
#include <avr/pgmspace.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "uart.h"
|
||||||
|
#include "fifo.h"
|
||||||
|
|
||||||
|
volatile struct {
|
||||||
|
uint8_t tmr_int:1;
|
||||||
|
uint8_t adc_int:1;
|
||||||
|
uint8_t rx_int:1;
|
||||||
|
} intflags;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* * Last character read from the UART.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
volatile char rxbuff;
|
||||||
|
|
||||||
|
|
||||||
|
FILE uart_stdout = FDEV_SETUP_STREAM(uart_stream, NULL, _FDEV_SETUP_WRITE);
|
||||||
|
|
||||||
|
void uart_init(void)
|
||||||
|
{
|
||||||
|
UCSR0A = _BV(U2X0); /* improves baud rate error @ F_CPU = 1 MHz */
|
||||||
|
UCSR0B = _BV(TXEN0) | _BV(RXEN0) | _BV(RXCIE0); /* tx/rx enable, rx complete
|
||||||
|
* intr */
|
||||||
|
UBRR0L = (F_CPU / (8 * 115200UL)) - 1;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ISR(USART0_RX_vect)
|
||||||
|
{
|
||||||
|
uint8_t c;
|
||||||
|
c = UDR0;
|
||||||
|
if (bit_is_clear(UCSR0A, FE0)) {
|
||||||
|
rxbuff = c;
|
||||||
|
intflags.rx_int = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void uart_putc(uint8_t c)
|
||||||
|
{
|
||||||
|
loop_until_bit_is_set(UCSR0A, UDRE0);
|
||||||
|
UDR0 = c;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void uart_puts(const char *s)
|
||||||
|
{
|
||||||
|
do {
|
||||||
|
uart_putc(*s);
|
||||||
|
}
|
||||||
|
while (*s++);
|
||||||
|
}
|
||||||
|
|
||||||
|
void uart_puts_P(PGM_P s)
|
||||||
|
{
|
||||||
|
while (1) {
|
||||||
|
unsigned char c = pgm_read_byte(s);
|
||||||
|
s++;
|
||||||
|
if ('\0' == c)
|
||||||
|
break;
|
||||||
|
uart_putc(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int uart_stream(char c, FILE * stream)
|
||||||
|
{
|
||||||
|
if (c == '\n')
|
||||||
|
uart_putc('\r');
|
||||||
|
loop_until_bit_is_set(UCSR0A, UDRE0);
|
||||||
|
UDR0 = c;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
18
avr/usbload/uart.h
Normal file
18
avr/usbload/uart.h
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
#ifndef __UART_H__
|
||||||
|
#define __UART_H__
|
||||||
|
|
||||||
|
#define CR "\r\n"
|
||||||
|
|
||||||
|
#include <avr/io.h>
|
||||||
|
#include <avr/pgmspace.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
void uart_init(void);
|
||||||
|
void uart_putc(const uint8_t);
|
||||||
|
void uart_puts(const char *s);
|
||||||
|
void uart_puts_P(PGM_P s);
|
||||||
|
static int uart_stream(char c, FILE *stream);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
75
avr/usbload/usb_bulk.c
Normal file
75
avr/usbload/usb_bulk.c
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
|
||||||
|
#include <avr/io.h>
|
||||||
|
#include <avr/pgmspace.h> /* required by usbdrv.h */
|
||||||
|
#include <avr/interrupt.h> /* for sei() */
|
||||||
|
#include <util/delay.h> /* for _delay_ms() */
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "usbdrv.h"
|
||||||
|
#include "oddebug.h" /* This is also an example for using debug
|
||||||
|
* macros */
|
||||||
|
#include "config.h"
|
||||||
|
#include "requests.h" /* The custom request numbers we use */
|
||||||
|
#include "uart.h"
|
||||||
|
#include "sram.h"
|
||||||
|
#include "debug.h"
|
||||||
|
#include "crc.h"
|
||||||
|
#include "usb_bulk.h"
|
||||||
|
|
||||||
|
extern uint8_t read_buffer[TRANSFER_BUFFER_SIZE];
|
||||||
|
extern uint32_t req_addr;
|
||||||
|
extern uint32_t req_size;
|
||||||
|
extern uint8_t req_bank;
|
||||||
|
extern uint32_t req_bank_size;
|
||||||
|
extern uint8_t req_state;
|
||||||
|
extern uint8_t rx_remaining;
|
||||||
|
extern uint8_t tx_remaining;
|
||||||
|
extern uint8_t tx_buffer[32];
|
||||||
|
extern uint16_t crc;
|
||||||
|
|
||||||
|
uint8_t usbFunctionWrite(uint8_t * data, uint8_t len)
|
||||||
|
{
|
||||||
|
uint8_t *ptr;
|
||||||
|
uint8_t i;
|
||||||
|
if (len > rx_remaining) {
|
||||||
|
printf("ERROR:usbFunctionWrite more data than expected remain: %i len: %i\n",
|
||||||
|
rx_remaining, len);
|
||||||
|
len = rx_remaining;
|
||||||
|
}
|
||||||
|
if (req_state == REQ_STATUS_UPLOAD) {
|
||||||
|
|
||||||
|
rx_remaining -= len;
|
||||||
|
debug(DEBUG_USB_TRANS,"usbFunctionWrite REQ_STATUS_UPLOAD addr: 0x%08lx len: %i rx_remaining=%i\n",
|
||||||
|
req_addr, len, rx_remaining);
|
||||||
|
sram_copy(req_addr, data, len);
|
||||||
|
req_addr += len;
|
||||||
|
} else if (req_state == REQ_STATUS_BULK_UPLOAD) {
|
||||||
|
|
||||||
|
rx_remaining -= len;
|
||||||
|
debug(DEBUG_USB_TRANS,"usbFunctionWrite REQ_STATUS_BULK_UPLOAD addr: 0x%08lx len: %i rx_remaining=%i\n",
|
||||||
|
req_addr, len, rx_remaining);
|
||||||
|
ptr = data;
|
||||||
|
i = len;
|
||||||
|
while(i--){
|
||||||
|
sram_bulk_write(*ptr++);
|
||||||
|
counter_up();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t usbFunctionRead(uint8_t * data, uint8_t len)
|
||||||
|
{
|
||||||
|
uint8_t i;
|
||||||
|
if (len > tx_remaining)
|
||||||
|
len = tx_remaining;
|
||||||
|
tx_remaining -= len;
|
||||||
|
debug(DEBUG_USB_TRANS,"usbFunctionRead len=%i tx_remaining=%i \n", len, tx_remaining);
|
||||||
|
|
||||||
|
for (i = 0; i < len; i++) {
|
||||||
|
*data = tx_buffer[len];
|
||||||
|
data++;
|
||||||
|
}
|
||||||
|
return len;
|
||||||
|
}
|
||||||
4
avr/usbload/usb_bulk.h
Normal file
4
avr/usbload/usb_bulk.h
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
|
||||||
|
uint8_t usbFunctionWrite(uint8_t * data, uint8_t len);
|
||||||
|
uint8_t usbFunctionRead(uint8_t * data, uint8_t len);
|
||||||
|
|
||||||
351
avr/usbload/usbconfig.h
Normal file
351
avr/usbload/usbconfig.h
Normal file
@@ -0,0 +1,351 @@
|
|||||||
|
/* 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 740 2009-04-13 18:23:31Z 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 4
|
||||||
|
/* 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 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
|
||||||
|
* "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 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!
|
||||||
|
* Default if not specified: 12 MHz
|
||||||
|
*/
|
||||||
|
#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 6
|
||||||
|
/* 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 0
|
||||||
|
/* 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 1
|
||||||
|
/* 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 300
|
||||||
|
/* 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 1
|
||||||
|
/* 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_LONG_TRANSFERS 1
|
||||||
|
/* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* -------------------------- Device Description --------------------------- */
|
||||||
|
|
||||||
|
#define USB_CFG_VENDOR_ID 0xc0, 0x16
|
||||||
|
/* USB vendor ID for the device, low byte first. If you have registered your
|
||||||
|
* own Vendor ID, define it here. Otherwise you use one of obdev's free shared
|
||||||
|
* VID/PID pairs. Be sure to read USBID-License.txt for rules!
|
||||||
|
*/
|
||||||
|
#define USB_CFG_DEVICE_ID 0xdd, 0x05
|
||||||
|
/* 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 use obdev's free shared VID/PID pair. Be sure to read the rules in
|
||||||
|
* USBID-License.txt!
|
||||||
|
*/
|
||||||
|
#define USB_CFG_DEVICE_VERSION 0x00, 0x01
|
||||||
|
/* Version number of the device: Minor number first, then major number.
|
||||||
|
*/
|
||||||
|
#define USB_CFG_VENDOR_NAME 'o', 'p', 't', 'i', 'x', 'x', '.', 'o', 'r', 'g'
|
||||||
|
#define USB_CFG_VENDOR_NAME_LEN 10
|
||||||
|
/* 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 USBID-License.txt for
|
||||||
|
* details.
|
||||||
|
*/
|
||||||
|
#define USB_CFG_DEVICE_NAME 'S', 'N', 'E', 'S', 'R', 'A', 'M'
|
||||||
|
#define USB_CFG_DEVICE_NAME_LEN 7
|
||||||
|
/* Same as above for the device name. If you don't want a device name, undefine
|
||||||
|
* the macros. See the file USBID-License.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 0xff /* set to 0 if deferred to interface */
|
||||||
|
#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 0 /* define class here if not at device level */
|
||||||
|
#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 0
|
||||||
|
|
||||||
|
/* 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 SIG_INTERRUPT0 */
|
||||||
|
|
||||||
|
#endif /* __usbconfig_h_included__ */
|
||||||
@@ -268,3 +268,10 @@ Scroll down to the bottom to see the most recent changes.
|
|||||||
- Integrated a module with CRC checks at 18 MHz by Lukas Schrittwieser.
|
- Integrated a module with CRC checks at 18 MHz by Lukas Schrittwieser.
|
||||||
|
|
||||||
* Release 2009-03-23
|
* 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
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
AVR-USB Driver Software License Agreement
|
V-USB Driver Software License Agreement
|
||||||
Version 2008-10-07
|
Version 2009-04-14
|
||||||
|
|
||||||
THIS LICENSE AGREEMENT GRANTS YOU CERTAIN RIGHTS IN A SOFTWARE. YOU CAN
|
THIS LICENSE AGREEMENT GRANTS YOU CERTAIN RIGHTS IN A SOFTWARE. YOU CAN
|
||||||
ENTER INTO THIS AGREEMENT AND ACQUIRE THE RIGHTS OUTLINED BELOW BY PAYING
|
ENTER INTO THIS AGREEMENT AND ACQUIRE THE RIGHTS OUTLINED BELOW BY PAYING
|
||||||
@@ -13,8 +13,8 @@ Grosse Schiffgasse 1A/7, 1020 Wien, AUSTRIA.
|
|||||||
|
|
||||||
1.2 "You" shall mean the Licensee.
|
1.2 "You" shall mean the Licensee.
|
||||||
|
|
||||||
1.3 "AVR-USB" shall mean all files included in the package distributed under
|
1.3 "V-USB" shall mean all files included in the package distributed under
|
||||||
the name "avrusb" by OBJECTIVE DEVELOPMENT (http://www.obdev.at/avrusb/)
|
the name "vusb" by OBJECTIVE DEVELOPMENT (http://www.obdev.at/vusb/)
|
||||||
unless otherwise noted. This includes the firmware-only USB device
|
unless otherwise noted. This includes the firmware-only USB device
|
||||||
implementation for Atmel AVR microcontrollers, some simple device examples
|
implementation for Atmel AVR microcontrollers, some simple device examples
|
||||||
and host side software examples and libraries.
|
and host side software examples and libraries.
|
||||||
@@ -23,21 +23,22 @@ and host side software examples and libraries.
|
|||||||
2 LICENSE GRANTS
|
2 LICENSE GRANTS
|
||||||
|
|
||||||
2.1 Source Code. OBJECTIVE DEVELOPMENT shall furnish you with the source
|
2.1 Source Code. OBJECTIVE DEVELOPMENT shall furnish you with the source
|
||||||
code of AVR-USB.
|
code of V-USB.
|
||||||
|
|
||||||
2.2 Distribution and Use. OBJECTIVE DEVELOPMENT grants you the
|
2.2 Distribution and Use. OBJECTIVE DEVELOPMENT grants you the
|
||||||
non-exclusive right to use, copy and distribute AVR-USB with your hardware
|
non-exclusive right to use, copy and distribute V-USB with your hardware
|
||||||
product(s), restricted by the limitations in section 3 below.
|
product(s), restricted by the limitations in section 3 below.
|
||||||
|
|
||||||
2.3 Modifications. OBJECTIVE DEVELOPMENT grants you the right to modify
|
2.3 Modifications. OBJECTIVE DEVELOPMENT grants you the right to modify
|
||||||
the source code and your copy of AVR-USB according to your needs.
|
the source code and your copy of V-USB according to your needs.
|
||||||
|
|
||||||
2.4 USB IDs. OBJECTIVE DEVELOPMENT grants you the exclusive rights to use
|
2.4 USB IDs. OBJECTIVE DEVELOPMENT furnishes you with one or two USB Product
|
||||||
USB Product ID(s) sent to you in e-mail after receiving your payment in
|
ID(s), sent to you in e-mail. These Product IDs are reserved exclusively for
|
||||||
conjunction with USB Vendor ID 5824. OBJECTIVE DEVELOPMENT has acquired an
|
you. They have been obtained from Wouter van Ooijen (www.voti.nl), who has
|
||||||
exclusive license for this pair of USB identifiers from Wouter van Ooijen
|
reserved the Vendor ID 5824 (decimal) at the USB Implementers Forum, Inc.
|
||||||
(www.voti.nl), who has licensed the VID from the USB Implementers Forum,
|
(www.usb.org). This mechanism ensures that there are no Product ID conflicts,
|
||||||
Inc. (www.usb.org).
|
but you cannot become USB certified (enter into the USB-IF Trademark License
|
||||||
|
Agreement) as you would need your own Vendor ID for that.
|
||||||
|
|
||||||
|
|
||||||
3 LICENSE RESTRICTIONS
|
3 LICENSE RESTRICTIONS
|
||||||
@@ -46,21 +47,21 @@ Inc. (www.usb.org).
|
|||||||
applicable. Which one is determined by the amount you pay to OBJECTIVE
|
applicable. Which one is determined by the amount you pay to OBJECTIVE
|
||||||
DEVELOPMENT, see section 4 ("Payment") below.
|
DEVELOPMENT, see section 4 ("Payment") below.
|
||||||
|
|
||||||
Hobby License: You may use AVR-USB according to section 2 above in no more
|
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.
|
than 5 hardware units. These units must not be sold for profit.
|
||||||
|
|
||||||
Entry Level License: You may use AVR-USB according to section 2 above in no
|
Entry Level License: You may use V-USB according to section 2 above in no
|
||||||
more than 150 hardware units.
|
more than 150 hardware units.
|
||||||
|
|
||||||
Professional License: You may use AVR-USB according to section 2 above in
|
Professional License: You may use V-USB according to section 2 above in
|
||||||
any number of hardware units, except for large scale production ("unlimited
|
any number of hardware units, except for large scale production ("unlimited
|
||||||
fair use"). Quantities below 10,000 units are not considered large scale
|
fair use"). Quantities below 10,000 units are not considered large scale
|
||||||
production. If your reach quantities which are obviously 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
|
production, you must pay a license fee of 0.10 EUR per unit for all units
|
||||||
above 10,000.
|
above 10,000.
|
||||||
|
|
||||||
3.2 Rental. You may not rent, lease, or lend AVR-USB or otherwise encumber
|
3.2 Rental. You may not rent, lease, or lend V-USB or otherwise encumber
|
||||||
any copy of AVR-USB, or any of the rights granted herein.
|
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
|
3.3 Transfer. You may not transfer your rights under this Agreement to
|
||||||
another party without OBJECTIVE DEVELOPMENT's prior written consent. If
|
another party without OBJECTIVE DEVELOPMENT's prior written consent. If
|
||||||
@@ -78,7 +79,7 @@ non-exclusive.
|
|||||||
by third parties. In particular, you are not allowed to use the USB logo or
|
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
|
other trademarks owned by the USB Implementers Forum, Inc. without their
|
||||||
consent. Since such consent depends on USB certification, it should be
|
consent. Since such consent depends on USB certification, it should be
|
||||||
noted that AVR-USB will not pass certification because it does not
|
noted that V-USB will not pass certification because it does not
|
||||||
implement checksum verification and the microcontroller ports do not meet
|
implement checksum verification and the microcontroller ports do not meet
|
||||||
the electrical specifications.
|
the electrical specifications.
|
||||||
|
|
||||||
@@ -88,15 +89,15 @@ the electrical specifications.
|
|||||||
The payment amount depends on the variation of this agreement (according to
|
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
|
section 3.1) into which you want to enter. Concrete prices are listed on
|
||||||
OBJECTIVE DEVELOPMENT's web site, usually at
|
OBJECTIVE DEVELOPMENT's web site, usually at
|
||||||
http://www.obdev.at/avrusb/license.html. You agree to pay the amount listed
|
http://www.obdev.at/vusb/license.html. You agree to pay the amount listed
|
||||||
there to OBJECTIVE DEVELOPMENT or OBJECTIVE DEVELOPMENT's payment processor
|
there to OBJECTIVE DEVELOPMENT or OBJECTIVE DEVELOPMENT's payment processor
|
||||||
or reseller.
|
or reseller.
|
||||||
|
|
||||||
|
|
||||||
5 COPYRIGHT AND OWNERSHIP
|
5 COPYRIGHT AND OWNERSHIP
|
||||||
|
|
||||||
AVR-USB is protected by copyright laws and international copyright
|
V-USB is protected by copyright laws and international copyright
|
||||||
treaties, as well as other intellectual property laws and treaties. AVR-USB
|
treaties, as well as other intellectual property laws and treaties. V-USB
|
||||||
is licensed, not sold.
|
is licensed, not sold.
|
||||||
|
|
||||||
|
|
||||||
@@ -112,12 +113,12 @@ and limitation of liability shall survive termination of this agreement.
|
|||||||
|
|
||||||
7 DISCLAIMER OF WARRANTY AND LIABILITY
|
7 DISCLAIMER OF WARRANTY AND LIABILITY
|
||||||
|
|
||||||
LIMITED WARRANTY. AVR-USB IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
|
LIMITED WARRANTY. V-USB IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
|
||||||
KIND. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, OBJECTIVE
|
KIND. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, OBJECTIVE
|
||||||
DEVELOPMENT AND ITS SUPPLIERS HEREBY DISCLAIM ALL WARRANTIES, EITHER
|
DEVELOPMENT AND ITS SUPPLIERS HEREBY DISCLAIM ALL WARRANTIES, EITHER
|
||||||
EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE, AND
|
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE, AND
|
||||||
NON-INFRINGEMENT, WITH REGARD TO AVR-USB, AND THE PROVISION OF OR FAILURE
|
NON-INFRINGEMENT, WITH REGARD TO V-USB, AND THE PROVISION OF OR FAILURE
|
||||||
TO PROVIDE SUPPORT SERVICES. THIS LIMITED WARRANTY GIVES YOU SPECIFIC LEGAL
|
TO PROVIDE SUPPORT SERVICES. THIS LIMITED WARRANTY GIVES YOU SPECIFIC LEGAL
|
||||||
RIGHTS. YOU MAY HAVE OTHERS, WHICH VARY FROM STATE/JURISDICTION TO
|
RIGHTS. YOU MAY HAVE OTHERS, WHICH VARY FROM STATE/JURISDICTION TO
|
||||||
STATE/JURISDICTION.
|
STATE/JURISDICTION.
|
||||||
@@ -127,11 +128,11 @@ IN NO EVENT SHALL OBJECTIVE DEVELOPMENT OR ITS SUPPLIERS BE LIABLE FOR ANY
|
|||||||
SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER
|
SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER
|
||||||
(INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS,
|
(INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS,
|
||||||
BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR ANY OTHER PECUNIARY
|
BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR ANY OTHER PECUNIARY
|
||||||
LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE AVR-USB OR THE
|
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
|
PROVISION OF OR FAILURE TO PROVIDE SUPPORT SERVICES, EVEN IF OBJECTIVE
|
||||||
DEVELOPMENT HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. IN ANY
|
DEVELOPMENT HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. IN ANY
|
||||||
CASE, OBJECTIVE DEVELOPMENT'S ENTIRE LIABILITY UNDER ANY PROVISION OF THIS
|
CASE, OBJECTIVE DEVELOPMENT'S ENTIRE LIABILITY UNDER ANY PROVISION OF THIS
|
||||||
AGREEMENT SHALL BE LIMITED TO THE AMOUNT ACTUALLY PAID BY YOU FOR AVR-USB.
|
AGREEMENT SHALL BE LIMITED TO THE AMOUNT ACTUALLY PAID BY YOU FOR V-USB.
|
||||||
|
|
||||||
|
|
||||||
8 MISCELLANEOUS TERMS
|
8 MISCELLANEOUS TERMS
|
||||||
@@ -1,18 +1,18 @@
|
|||||||
OBJECTIVE DEVELOPMENT GmbH's AVR-USB driver software is distributed under the
|
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
|
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
|
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,
|
text of GPLv2 is included below. In addition to the requirements in the GPL,
|
||||||
we STRONGLY ENCOURAGE you to do the following:
|
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.
|
(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/avrusb/feedback.html for your submission.
|
Use the form at http://www.obdev.at/vusb/feedback.html for your submission.
|
||||||
|
|
||||||
(2) Adhere to minimum publication standards. Please include AT LEAST:
|
(2) Adhere to minimum publication standards. Please include AT LEAST:
|
||||||
- a circuit diagram in PDF, PNG or GIF format
|
- a circuit diagram in PDF, PNG or GIF format
|
||||||
- full source code for the host software
|
- full source code for the host software
|
||||||
- a Readme.txt file in ASCII format which describes the purpose of the
|
- 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
|
project and what can be found in which directories and which files
|
||||||
- a reference to http://www.obdev.at/avrusb/
|
- a reference to http://www.obdev.at/vusb/
|
||||||
|
|
||||||
(3) If you improve the driver firmware itself, please give us a free license
|
(3) If you improve the driver firmware itself, please give us a free license
|
||||||
to your modifications for our commercial license offerings.
|
to your modifications for our commercial license offerings.
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
This is the Readme file to Objective Development's firmware-only USB driver
|
This is the Readme file to Objective Development's firmware-only USB driver
|
||||||
for Atmel AVR microcontrollers. For more information please visit
|
for Atmel AVR microcontrollers. For more information please visit
|
||||||
http://www.obdev.at/avrusb/
|
http://www.obdev.at/vusb/
|
||||||
|
|
||||||
This directory contains the USB firmware only. Copy it as-is to your own
|
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
|
project and add all .c and .S files to your project (these files are marked
|
||||||
@@ -53,7 +53,7 @@ actual clock rate must be configured in usbdrv.h unless you use the default
|
|||||||
12 MHz.
|
12 MHz.
|
||||||
|
|
||||||
12 MHz Clock
|
12 MHz Clock
|
||||||
This is the traditional clock rate of AVR-USB because it's the lowest 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.
|
rate where the timing constraints of the USB spec can be met.
|
||||||
|
|
||||||
15 MHz Clock
|
15 MHz Clock
|
||||||
@@ -78,7 +78,7 @@ 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
|
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.
|
all AVRs can reach 12.8 MHz, although this is outside the specified range.
|
||||||
|
|
||||||
See the EasyLogger example at http://www.obdev.at/avrusb/easylogger.html for
|
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.
|
code which calibrates the RC oscillator based on the USB frame clock.
|
||||||
|
|
||||||
18 MHz Clock
|
18 MHz Clock
|
||||||
@@ -108,14 +108,14 @@ and hobbyists, we provide some VID/PID pairs for free. See the file
|
|||||||
USBID-License.txt for details.
|
USBID-License.txt for details.
|
||||||
|
|
||||||
Objective Development also has some license offerings which include product
|
Objective Development also has some license offerings which include product
|
||||||
IDs. See http://www.obdev.at/avrusb/ for details.
|
IDs. See http://www.obdev.at/vusb/ for details.
|
||||||
|
|
||||||
|
|
||||||
DEVELOPMENT SYSTEM
|
DEVELOPMENT SYSTEM
|
||||||
==================
|
==================
|
||||||
This driver has been developed and optimized for the GNU compiler version 3
|
This driver has been developed and optimized for the GNU compiler version 3
|
||||||
(gcc 3). It does work well with gcc 4, but with bigger code size. We recommend
|
(gcc 3). It does work well with gcc 4, but with bigger code size. We recommend
|
||||||
that you use the GNU compiler suite because it is freely available. AVR-USB
|
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
|
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"
|
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
|
memory model. Not every release is tested with IAR CC and the driver may
|
||||||
@@ -123,8 +123,8 @@ 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.
|
usbdrv.c because this module has been deliberately optimized for gcc.
|
||||||
|
|
||||||
|
|
||||||
USING AVR-USB FOR FREE
|
USING V-USB FOR FREE
|
||||||
======================
|
====================
|
||||||
The AVR firmware driver is published under the GNU General Public License
|
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
|
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.
|
your choice whether you apply the terms of version 2 or version 3.
|
||||||
@@ -133,26 +133,26 @@ 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:
|
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.
|
(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/avrusb/feedback.html for your submission.
|
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
|
If you don't have a web site, you can publish the project in obdev's
|
||||||
documentation wiki at
|
documentation wiki at
|
||||||
http://www.obdev.at/goto.php?t=avrusb-wiki&p=hosted-projects.
|
http://www.obdev.at/goto.php?t=vusb-wiki&p=hosted-projects.
|
||||||
|
|
||||||
(2) Adhere to minimum publication standards. Please include AT LEAST:
|
(2) Adhere to minimum publication standards. Please include AT LEAST:
|
||||||
- a circuit diagram in PDF, PNG or GIF format
|
- a circuit diagram in PDF, PNG or GIF format
|
||||||
- full source code for the host software
|
- full source code for the host software
|
||||||
- a Readme.txt file in ASCII format which describes the purpose of the
|
- 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
|
project and what can be found in which directories and which files
|
||||||
- a reference to http://www.obdev.at/avrusb/
|
- a reference to http://www.obdev.at/vusb/
|
||||||
|
|
||||||
(3) If you improve the driver firmware itself, please give us a free license
|
(3) If you improve the driver firmware itself, please give us a free license
|
||||||
to your modifications for our commercial license offerings.
|
to your modifications for our commercial license offerings.
|
||||||
|
|
||||||
|
|
||||||
COMMERCIAL LICENSES FOR AVR-USB
|
COMMERCIAL LICENSES FOR V-USB
|
||||||
===============================
|
=============================
|
||||||
If you don't want to publish your source code under the terms of the GPL,
|
If you don't want to publish your source code under the terms of the GPL,
|
||||||
you can simply pay money for AVR-USB. As an additional benefit you get
|
you can simply pay money for V-USB. As an additional benefit you get
|
||||||
USB PIDs for free, licensed exclusively to you. See the file
|
USB PIDs for free, reserved exclusively to you. See the file
|
||||||
"CommercialLicense.txt" for details.
|
"CommercialLicense.txt" for details.
|
||||||
|
|
||||||
@@ -1,10 +1,17 @@
|
|||||||
Royalty-Free Non-Exclusive License USB Product-ID
|
Royalty-Free Non-Exclusive Use of USB Product-IDs
|
||||||
=================================================
|
=================================================
|
||||||
|
|
||||||
Version 2008-04-07
|
Version 2009-04-13
|
||||||
|
|
||||||
|
Strictly speaking, this is not a license. You can't give a license to use
|
||||||
|
a simple number (such as e.g. 1500) for any purpose. This is a set of rules
|
||||||
|
which should make it possible to build USB devices without the requirement
|
||||||
|
for individual USB IDs. If you break one of the rules, you will run into
|
||||||
|
technical problems sooner or later, but you don't risk legal trouble.
|
||||||
|
|
||||||
|
|
||||||
OBJECTIVE DEVELOPMENT Software GmbH hereby grants you the non-exclusive
|
OBJECTIVE DEVELOPMENT Software GmbH hereby grants you the non-exclusive
|
||||||
right to use three USB.org vendor-ID (VID) / product-ID (PID) pairs with
|
right to use four USB.org vendor-ID (VID) / product-ID (PID) pairs with
|
||||||
products based on Objective Development's firmware-only USB driver for
|
products based on Objective Development's firmware-only USB driver for
|
||||||
Atmel AVR microcontrollers:
|
Atmel AVR microcontrollers:
|
||||||
|
|
||||||
@@ -27,10 +34,11 @@ used by many companies and individuals for different products. To avoid
|
|||||||
conflicts, your device and host driver software MUST adhere to the rules
|
conflicts, your device and host driver software MUST adhere to the rules
|
||||||
outlined below.
|
outlined below.
|
||||||
|
|
||||||
OBJECTIVE DEVELOPMENT Software GmbH has licensed these VID/PID pairs from
|
OBJECTIVE DEVELOPMENT Software GmbH has obtained these VID/PID pairs from
|
||||||
Wouter van Ooijen (see www.voti.nl), who has licensed the VID from the USB
|
Wouter van Ooijen (see www.voti.nl) for exclusive disposition. Wouter van
|
||||||
Implementers Forum, Inc. (see www.usb.org). The VID is registered for the
|
Ooijen has obtained the VID from the USB Implementers Forum, Inc.
|
||||||
company name "Van Ooijen Technische Informatica".
|
(see www.usb.org). The VID is registered for the company name
|
||||||
|
"Van Ooijen Technische Informatica".
|
||||||
|
|
||||||
|
|
||||||
RULES AND RESTRICTIONS
|
RULES AND RESTRICTIONS
|
||||||
@@ -44,7 +52,7 @@ MUST be available at least in USB language 0x0409 (English/US).
|
|||||||
domain name (e.g. "mycompany.com") registered and owned by you, or an
|
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
|
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
|
the domain name or e-mail address in any string you like, e.g. "Objective
|
||||||
Development http://www.obdev.at/avrusb/".
|
Development http://www.obdev.at/vusb/".
|
||||||
|
|
||||||
(3) You are responsible for retaining ownership of the domain or e-mail
|
(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.
|
address for as long as any of your products are in use.
|
||||||
@@ -142,5 +150,5 @@ violates the USB specification. If you do it, you do it at your own risk.
|
|||||||
|
|
||||||
To avoid possible incompatibilities, we highly recommend that you get your
|
To avoid possible incompatibilities, we highly recommend that you get your
|
||||||
own VID/PID pair if you intend to sell your product. Objective
|
own VID/PID pair if you intend to sell your product. Objective
|
||||||
Development's commercial licenses for AVR-USB include a PID for
|
Development's commercial licenses for V-USB include a PID for
|
||||||
unrestricted exclusive use.
|
unrestricted exclusive use.
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/* Name: asmcommon.inc
|
/* Name: asmcommon.inc
|
||||||
* Project: AVR USB driver
|
* Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers
|
||||||
* Author: Christian Starkjohann
|
* Author: Christian Starkjohann
|
||||||
* Creation Date: 2007-11-05
|
* Creation Date: 2007-11-05
|
||||||
* Tabsize: 4
|
* Tabsize: 4
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
/* Name: usbconfig.h
|
/* Name: usbconfig.h
|
||||||
* Project: AVR USB driver
|
* Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers
|
||||||
* Author: Christian Starkjohann
|
* Author: Christian Starkjohann
|
||||||
* Creation Date: 2005-04-01
|
* Creation Date: 2005-04-01
|
||||||
* Tabsize: 4
|
* Tabsize: 4
|
||||||
* Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH
|
* Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH
|
||||||
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
|
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
|
||||||
* This Revision: $Id: usbconfig-prototype.h 734 2009-03-23 11:10:07Z cs $
|
* This Revision: $Id: usbconfig-prototype.h 740 2009-04-13 18:23:31Z cs $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __usbconfig_h_included__
|
#ifndef __usbconfig_h_included__
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
/*
|
/*
|
||||||
General Description:
|
General Description:
|
||||||
This file is an example configuration (with inline documentation) for the USB
|
This file is an example configuration (with inline documentation) for the USB
|
||||||
driver. It configures AVR-USB for USB D+ connected to Port D bit 2 (which is
|
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
|
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
|
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
|
other hardware interrupt, as long as it is the highest level interrupt, see
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
/* Name: usbdrv.c
|
/* Name: usbdrv.c
|
||||||
* Project: AVR USB driver
|
* Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers
|
||||||
* Author: Christian Starkjohann
|
* Author: Christian Starkjohann
|
||||||
* Creation Date: 2004-12-29
|
* Creation Date: 2004-12-29
|
||||||
* Tabsize: 4
|
* Tabsize: 4
|
||||||
* Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH
|
* Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH
|
||||||
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
|
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
|
||||||
* This Revision: $Id: usbdrv.c 721 2009-03-16 19:03:19Z cs $
|
* This Revision: $Id: usbdrv.c 740 2009-04-13 18:23:31Z cs $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "usbportability.h"
|
#include "usbportability.h"
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
/* Name: usbdrv.h
|
/* Name: usbdrv.h
|
||||||
* Project: AVR USB driver
|
* Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers
|
||||||
* Author: Christian Starkjohann
|
* Author: Christian Starkjohann
|
||||||
* Creation Date: 2004-12-29
|
* Creation Date: 2004-12-29
|
||||||
* Tabsize: 4
|
* Tabsize: 4
|
||||||
* Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH
|
* Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH
|
||||||
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
|
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
|
||||||
* This Revision: $Id: usbdrv.h 738 2009-03-23 11:13:24Z cs $
|
* This Revision: $Id: usbdrv.h 748 2009-04-15 15:05:07Z cs $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __usbdrv_h_included__
|
#ifndef __usbdrv_h_included__
|
||||||
@@ -122,7 +122,7 @@ USB messages, even if they address another (low-speed) device on the same bus.
|
|||||||
/* --------------------------- Module Interface ---------------------------- */
|
/* --------------------------- Module Interface ---------------------------- */
|
||||||
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
||||||
|
|
||||||
#define USBDRV_VERSION 20090323
|
#define USBDRV_VERSION 20090415
|
||||||
/* This define uniquely identifies a driver version. It is a decimal number
|
/* 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
|
* 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
|
* driver's behavior or interface changes, you can use this constant to
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
/* Name: usbdrvasm.S
|
/* Name: usbdrvasm.S
|
||||||
* Project: AVR USB driver
|
* Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers
|
||||||
* Author: Christian Starkjohann
|
* Author: Christian Starkjohann
|
||||||
* Creation Date: 2007-06-13
|
* Creation Date: 2007-06-13
|
||||||
* Tabsize: 4
|
* Tabsize: 4
|
||||||
* Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH
|
* Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH
|
||||||
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
|
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
|
||||||
* Revision: $Id: usbdrvasm.S 722 2009-03-16 19:03:57Z cs $
|
* Revision: $Id: usbdrvasm.S 740 2009-04-13 18:23:31Z cs $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/* Name: usbdrvasm.asm
|
/* Name: usbdrvasm.asm
|
||||||
* Project: AVR USB driver
|
* Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers
|
||||||
* Author: Christian Starkjohann
|
* Author: Christian Starkjohann
|
||||||
* Creation Date: 2006-03-01
|
* Creation Date: 2006-03-01
|
||||||
* Tabsize: 4
|
* Tabsize: 4
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
/* Name: usbdrvasm12.inc
|
/* Name: usbdrvasm12.inc
|
||||||
* Project: AVR USB driver
|
* Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers
|
||||||
* Author: Christian Starkjohann
|
* Author: Christian Starkjohann
|
||||||
* Creation Date: 2004-12-29
|
* Creation Date: 2004-12-29
|
||||||
* Tabsize: 4
|
* Tabsize: 4
|
||||||
* Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH
|
* Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH
|
||||||
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
|
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
|
||||||
* This Revision: $Id: usbdrvasm12.inc 692 2008-11-07 15:07:40Z cs $
|
* 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
|
/* Do not link this file! Link usbdrvasm.S instead, which includes the
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
/* Name: usbdrvasm128.inc
|
/* Name: usbdrvasm128.inc
|
||||||
* Project: AVR USB driver
|
* Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers
|
||||||
* Author: Christian Starkjohann
|
* Author: Christian Starkjohann
|
||||||
* Creation Date: 2008-10-11
|
* Creation Date: 2008-10-11
|
||||||
* Tabsize: 4
|
* Tabsize: 4
|
||||||
* Copyright: (c) 2008 by OBJECTIVE DEVELOPMENT Software GmbH
|
* Copyright: (c) 2008 by OBJECTIVE DEVELOPMENT Software GmbH
|
||||||
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
|
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
|
||||||
* This Revision: $Id: usbdrvasm128.inc 692 2008-11-07 15:07:40Z cs $
|
* This Revision: $Id: usbdrvasm128.inc 740 2009-04-13 18:23:31Z cs $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Do not link this file! Link usbdrvasm.S instead, which includes the
|
/* Do not link this file! Link usbdrvasm.S instead, which includes the
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
/* Name: usbdrvasm15.inc
|
/* Name: usbdrvasm15.inc
|
||||||
* Project: AVR USB driver
|
* Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers
|
||||||
* Author: contributed by V. Bosch
|
* Author: contributed by V. Bosch
|
||||||
* Creation Date: 2007-08-06
|
* Creation Date: 2007-08-06
|
||||||
* Tabsize: 4
|
* Tabsize: 4
|
||||||
* Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH
|
* Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH
|
||||||
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
|
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
|
||||||
* Revision: $Id: usbdrvasm15.inc 692 2008-11-07 15:07:40Z cs $
|
* Revision: $Id: usbdrvasm15.inc 740 2009-04-13 18:23:31Z cs $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Do not link this file! Link usbdrvasm.S instead, which includes the
|
/* Do not link this file! Link usbdrvasm.S instead, which includes the
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
/* Name: usbdrvasm16.inc
|
/* Name: usbdrvasm16.inc
|
||||||
* Project: AVR USB driver
|
* Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers
|
||||||
* Author: Christian Starkjohann
|
* Author: Christian Starkjohann
|
||||||
* Creation Date: 2007-06-15
|
* Creation Date: 2007-06-15
|
||||||
* Tabsize: 4
|
* Tabsize: 4
|
||||||
* Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH
|
* Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH
|
||||||
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
|
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
|
||||||
* Revision: $Id: usbdrvasm16.inc 692 2008-11-07 15:07:40Z cs $
|
* Revision: $Id: usbdrvasm16.inc 740 2009-04-13 18:23:31Z cs $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Do not link this file! Link usbdrvasm.S instead, which includes the
|
/* Do not link this file! Link usbdrvasm.S instead, which includes the
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
/* Name: usbdrvasm165.inc
|
/* Name: usbdrvasm165.inc
|
||||||
* Project: AVR USB driver
|
* Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers
|
||||||
* Author: Christian Starkjohann
|
* Author: Christian Starkjohann
|
||||||
* Creation Date: 2007-04-22
|
* Creation Date: 2007-04-22
|
||||||
* Tabsize: 4
|
* Tabsize: 4
|
||||||
* Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH
|
* Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH
|
||||||
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
|
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
|
||||||
* Revision: $Id: usbdrvasm165.inc 692 2008-11-07 15:07:40Z cs $
|
* Revision: $Id: usbdrvasm165.inc 740 2009-04-13 18:23:31Z cs $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Do not link this file! Link usbdrvasm.S instead, which includes the
|
/* Do not link this file! Link usbdrvasm.S instead, which includes the
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
/* Name: usbdrvasm18.inc
|
/* Name: usbdrvasm18.inc
|
||||||
* Project: AVR USB driver
|
* Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers
|
||||||
* Author: Lukas Schrittwieser (based on 20 MHz usbdrvasm20.inc by Jeroen Benschop)
|
* Author: Lukas Schrittwieser (based on 20 MHz usbdrvasm20.inc by Jeroen Benschop)
|
||||||
* Creation Date: 2009-01-20
|
* Creation Date: 2009-01-20
|
||||||
* Tabsize: 4
|
* Tabsize: 4
|
||||||
* Copyright: (c) 2008 by Lukas Schrittwieser and OBJECTIVE DEVELOPMENT Software GmbH
|
* Copyright: (c) 2008 by Lukas Schrittwieser and OBJECTIVE DEVELOPMENT Software GmbH
|
||||||
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
|
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
|
||||||
* Revision: $Id: usbdrvasm18-crc.inc 734 2009-03-23 11:10:07Z cs $
|
* Revision: $Id: usbdrvasm18-crc.inc 740 2009-04-13 18:23:31Z cs $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Do not link this file! Link usbdrvasm.S instead, which includes the
|
/* Do not link this file! Link usbdrvasm.S instead, which includes the
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
/* Name: usbdrvasm20.inc
|
/* Name: usbdrvasm20.inc
|
||||||
* Project: AVR USB driver
|
* Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers
|
||||||
* Author: Jeroen Benschop
|
* Author: Jeroen Benschop
|
||||||
* Based on usbdrvasm16.inc from Christian Starkjohann
|
* Based on usbdrvasm16.inc from Christian Starkjohann
|
||||||
* Creation Date: 2008-03-05
|
* Creation Date: 2008-03-05
|
||||||
* Tabsize: 4
|
* Tabsize: 4
|
||||||
* Copyright: (c) 2008 by Jeroen Benschop and OBJECTIVE DEVELOPMENT Software GmbH
|
* 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)
|
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
|
||||||
* Revision: $Id: usbdrvasm20.inc 692 2008-11-07 15:07:40Z cs $
|
* Revision: $Id: usbdrvasm20.inc 740 2009-04-13 18:23:31Z cs $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Do not link this file! Link usbdrvasm.S instead, which includes the
|
/* Do not link this file! Link usbdrvasm.S instead, which includes the
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
/* Name: usbportability.h
|
/* Name: usbportability.h
|
||||||
* Project: AVR USB driver
|
* Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers
|
||||||
* Author: Christian Starkjohann
|
* Author: Christian Starkjohann
|
||||||
* Creation Date: 2008-06-17
|
* Creation Date: 2008-06-17
|
||||||
* Tabsize: 4
|
* Tabsize: 4
|
||||||
* Copyright: (c) 2008 by OBJECTIVE DEVELOPMENT Software GmbH
|
* Copyright: (c) 2008 by OBJECTIVE DEVELOPMENT Software GmbH
|
||||||
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
|
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
|
||||||
* This Revision: $Id: usbportability.h 692 2008-11-07 15:07:40Z cs $
|
* This Revision: $Id: usbportability.h 740 2009-04-13 18:23:31Z cs $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Binary file not shown.
Binary file not shown.
22
bugs/issue-032fab33a68ffbeb19f1e9fa4856101996759255.yaml
Normal file
22
bugs/issue-032fab33a68ffbeb19f1e9fa4856101996759255.yaml
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
--- !ditz.rubyforge.org,2008-03-06/issue
|
||||||
|
title: relocate code
|
||||||
|
desc: |-
|
||||||
|
move main code to upper page like 0xe4 and use 0x4f as shared mem window
|
||||||
|
or even combine this
|
||||||
|
code seems to reloacte and start, but ram doesn't seem accessable. broked
|
||||||
|
sprintfs
|
||||||
|
type: :bugfix
|
||||||
|
component: fatfs
|
||||||
|
release:
|
||||||
|
reporter: David <david@optixx.org>
|
||||||
|
status: :unstarted
|
||||||
|
disposition:
|
||||||
|
creation_time: 2009-06-10 14:22:10.400739 Z
|
||||||
|
references: []
|
||||||
|
|
||||||
|
id: 032fab33a68ffbeb19f1e9fa4856101996759255
|
||||||
|
log_events:
|
||||||
|
- - 2009-06-10 14:22:11.288638 Z
|
||||||
|
- David <david@optixx.org>
|
||||||
|
- created
|
||||||
|
- ""
|
||||||
21
bugs/issue-6498cae9de5e51829e5dbb6b8fcaa20c7a647aa6.yaml
Normal file
21
bugs/issue-6498cae9de5e51829e5dbb6b8fcaa20c7a647aa6.yaml
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
--- !ditz.rubyforge.org,2008-03-06/issue
|
||||||
|
title: "debug ram mapping "
|
||||||
|
desc: |-
|
||||||
|
global vars seem to be borked or miss used. seems all kind of buffers are overlapping
|
||||||
|
just reordering global var order renders the code unusable.
|
||||||
|
also the strange sprintf buffer conflicts seem to related to this issue
|
||||||
|
type: :bugfix
|
||||||
|
component: fatfs
|
||||||
|
release:
|
||||||
|
reporter: David <david@optixx.org>
|
||||||
|
status: :unstarted
|
||||||
|
disposition:
|
||||||
|
creation_time: 2009-06-10 14:23:44.121219 Z
|
||||||
|
references: []
|
||||||
|
|
||||||
|
id: 6498cae9de5e51829e5dbb6b8fcaa20c7a647aa6
|
||||||
|
log_events:
|
||||||
|
- - 2009-06-10 14:23:45.632999 Z
|
||||||
|
- David <david@optixx.org>
|
||||||
|
- created
|
||||||
|
- ""
|
||||||
20
bugs/issue-99ae09d1da472e76501325424bc586f78980199e.yaml
Normal file
20
bugs/issue-99ae09d1da472e76501325424bc586f78980199e.yaml
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
--- !ditz.rubyforge.org,2008-03-06/issue
|
||||||
|
title: debug sta return val
|
||||||
|
desc: |-
|
||||||
|
debug the sta value in diskio.c
|
||||||
|
never seems to take the correct value, looks like global,local scope problem
|
||||||
|
type: :bugfix
|
||||||
|
component: fatfs
|
||||||
|
release:
|
||||||
|
reporter: David <david@optixx.org>
|
||||||
|
status: :unstarted
|
||||||
|
disposition:
|
||||||
|
creation_time: 2009-06-10 14:20:20.608109 Z
|
||||||
|
references: []
|
||||||
|
|
||||||
|
id: 99ae09d1da472e76501325424bc586f78980199e
|
||||||
|
log_events:
|
||||||
|
- - 2009-06-10 14:20:24.343929 Z
|
||||||
|
- David <david@optixx.org>
|
||||||
|
- created
|
||||||
|
- ""
|
||||||
10
bugs/project.yaml
Normal file
10
bugs/project.yaml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
--- !ditz.rubyforge.org,2008-03-06/project
|
||||||
|
name: snesram
|
||||||
|
version: "0.5"
|
||||||
|
components:
|
||||||
|
- !ditz.rubyforge.org,2008-03-06/component
|
||||||
|
name: snesram
|
||||||
|
- !ditz.rubyforge.org,2008-03-06/component
|
||||||
|
name: fatfs
|
||||||
|
releases: []
|
||||||
|
|
||||||
438
poc/avr_iotest/Makefile
Normal file
438
poc/avr_iotest/Makefile
Normal file
@@ -0,0 +1,438 @@
|
|||||||
|
# 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".
|
||||||
|
#
|
||||||
|
|
||||||
|
# mth 2004/09
|
||||||
|
# Differences from WinAVR 20040720 sample:
|
||||||
|
# - DEPFLAGS according to Eric Weddingtion's fix (avrfreaks/gcc-forum)
|
||||||
|
# - F_OSC Define in CFLAGS and AFLAGS
|
||||||
|
|
||||||
|
|
||||||
|
# MCU name
|
||||||
|
MCU = atmega16
|
||||||
|
|
||||||
|
# Main Oscillator Frequency
|
||||||
|
# This is only used to define F_OSC in all assembler and c-sources.
|
||||||
|
F_OSC = 16000000
|
||||||
|
|
||||||
|
# Output format. (can be srec, ihex, binary)
|
||||||
|
FORMAT = ihex
|
||||||
|
|
||||||
|
# Target file name (without extension).
|
||||||
|
TARGET = main
|
||||||
|
|
||||||
|
|
||||||
|
# List C source files here. (C dependencies are automatically generated.)
|
||||||
|
SRC = $(TARGET).c uart.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 =
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# 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 =
|
||||||
|
|
||||||
|
|
||||||
|
# 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 -funsigned-bitfields -fpack-struct -fshort-enums
|
||||||
|
CFLAGS += -Wall -Wstrict-prototypes
|
||||||
|
CFLAGS += -Wa,-adhlns=$(<:.c=.lst)
|
||||||
|
CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
||||||
|
CFLAGS += $(CSTANDARD)
|
||||||
|
CFLAGS += -DF_OSC=$(F_OSC)
|
||||||
|
CFLAGS += -DF_CPU=16000000UL
|
||||||
|
#CFLAGS += -DF_CPU=3686400UL
|
||||||
|
|
||||||
|
|
||||||
|
# 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_OSC=$(F_OSC)
|
||||||
|
|
||||||
|
|
||||||
|
#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 =
|
||||||
|
|
||||||
|
# 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 =
|
||||||
|
|
||||||
|
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_MIN) $(SCANF_LIB) $(MATH_LIB)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# 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 = stk500v2
|
||||||
|
|
||||||
|
# com1 = serial port. Use lpt1 to connect to parallel port.
|
||||||
|
|
||||||
|
AVRDUDE_PORT = /dev/tty.PL2303-00002126
|
||||||
|
|
||||||
|
AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
|
||||||
|
|
||||||
|
# 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 <http://savannah.nongnu.org/projects/avrdude>
|
||||||
|
# to submit bug reports.
|
||||||
|
AVRDUDE_VERBOSE = -v -v
|
||||||
|
|
||||||
|
AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
|
||||||
|
AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY)
|
||||||
|
AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE)
|
||||||
|
AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER)
|
||||||
|
|
||||||
|
#flash_fuse:
|
||||||
|
# avrdude -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) -U lfuse:w:0xfe:m
|
||||||
|
# avrdude -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) -U hfuse:w:0xd9:m
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# 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 $(MSG_BEGIN)
|
||||||
|
|
||||||
|
finished:
|
||||||
|
@echo $(MSG_ERRORS_NONE)
|
||||||
|
|
||||||
|
end:
|
||||||
|
@echo $(MSG_END)
|
||||||
|
@echo
|
||||||
|
|
||||||
|
|
||||||
|
# Display size of file.
|
||||||
|
HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
|
||||||
|
ELFSIZE = $(SIZE) -A $(TARGET).elf
|
||||||
|
sizebefore:
|
||||||
|
@if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); echo; fi
|
||||||
|
|
||||||
|
sizeafter:
|
||||||
|
@if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Display compiler version information.
|
||||||
|
gccversion :
|
||||||
|
@$(CC) --version
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Program the device.
|
||||||
|
|
||||||
|
|
||||||
|
flash: $(TARGET).hex $(TARGET).eep
|
||||||
|
sudo $(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/*
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
35
poc/avr_iotest/checksize
Normal file
35
poc/avr_iotest/checksize
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Name: checksize
|
||||||
|
# Project: PowerSwitch/AVR-USB
|
||||||
|
# Author: Christian Starkjohann
|
||||||
|
# Creation Date: 2004-12-29
|
||||||
|
# Tabsize: 4
|
||||||
|
# Copyright: (c) 2005 OBJECTIVE DEVELOPMENT Software GmbH.
|
||||||
|
# Revision: $Id: checksize 83 2006-01-05 22:20:53Z cs $
|
||||||
|
|
||||||
|
error=0
|
||||||
|
codelimit=2048 # default value
|
||||||
|
datalimit=96 # default value; leave 32 bytes for stack
|
||||||
|
|
||||||
|
if [ $# -gt 1 ]; then
|
||||||
|
codelimit="$2"
|
||||||
|
fi
|
||||||
|
if [ $# -gt 2 ]; then
|
||||||
|
datalimit="$3"
|
||||||
|
fi
|
||||||
|
|
||||||
|
set -- `avr-size -d "$1" | awk '/[0-9]/ {print $1 + $2, $2 + $3, $2}'`
|
||||||
|
if [ $1 -gt $codelimit ]; then
|
||||||
|
echo "*** code size $1 exceeds limit of $codelimit"
|
||||||
|
error=1
|
||||||
|
else
|
||||||
|
echo "ROM: $1 bytes (data=$3)"
|
||||||
|
fi
|
||||||
|
if [ $2 -gt $datalimit ]; then
|
||||||
|
echo "*** data size $2 exceeds limit of $datalimit"
|
||||||
|
error=1
|
||||||
|
else
|
||||||
|
echo "RAM: $2 bytes"
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit $error
|
||||||
28
poc/avr_iotest/fifo.c
Normal file
28
poc/avr_iotest/fifo.c
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
#include "fifo.h"
|
||||||
|
|
||||||
|
void fifo_init(fifo_t * f, uint8_t * buffer, const uint8_t size)
|
||||||
|
{
|
||||||
|
f->count = 0;
|
||||||
|
f->pread = f->pwrite = buffer;
|
||||||
|
f->read2end = f->write2end = f->size = size;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t fifo_put(fifo_t * f, const uint8_t data)
|
||||||
|
{
|
||||||
|
return _inline_fifo_put(f, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t fifo_get_wait(fifo_t * f)
|
||||||
|
{
|
||||||
|
while (!f->count);
|
||||||
|
|
||||||
|
return _inline_fifo_get(f);
|
||||||
|
}
|
||||||
|
|
||||||
|
int fifo_get_nowait(fifo_t * f)
|
||||||
|
{
|
||||||
|
if (!f->count)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return (int) _inline_fifo_get(f);
|
||||||
|
}
|
||||||
69
poc/avr_iotest/fifo.h
Normal file
69
poc/avr_iotest/fifo.h
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
#ifndef _FIFO_H_
|
||||||
|
#define _FIFO_H_
|
||||||
|
|
||||||
|
#include <avr/io.h>
|
||||||
|
#include <avr/interrupt.h>
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint8_t volatile count; // # Zeichen im Puffer
|
||||||
|
uint8_t size; // Puffer-Größe
|
||||||
|
uint8_t *pread; // Lesezeiger
|
||||||
|
uint8_t *pwrite; // Schreibzeiger
|
||||||
|
uint8_t read2end, write2end; // # Zeichen bis zum Überlauf Lese-/Schreibzeiger
|
||||||
|
} fifo_t;
|
||||||
|
|
||||||
|
extern void fifo_init(fifo_t *, uint8_t * buf, const uint8_t size);
|
||||||
|
extern uint8_t fifo_put(fifo_t *, const uint8_t data);
|
||||||
|
extern uint8_t fifo_get_wait(fifo_t *);
|
||||||
|
extern int fifo_get_nowait(fifo_t *);
|
||||||
|
|
||||||
|
static inline uint8_t _inline_fifo_put(fifo_t * f, const uint8_t data)
|
||||||
|
{
|
||||||
|
if (f->count >= f->size)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
uint8_t *pwrite = f->pwrite;
|
||||||
|
|
||||||
|
*(pwrite++) = data;
|
||||||
|
|
||||||
|
uint8_t write2end = f->write2end;
|
||||||
|
|
||||||
|
if (--write2end == 0) {
|
||||||
|
write2end = f->size;
|
||||||
|
pwrite -= write2end;
|
||||||
|
}
|
||||||
|
|
||||||
|
f->write2end = write2end;
|
||||||
|
f->pwrite = pwrite;
|
||||||
|
|
||||||
|
uint8_t sreg = SREG;
|
||||||
|
cli();
|
||||||
|
f->count++;
|
||||||
|
SREG = sreg;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline uint8_t _inline_fifo_get(fifo_t * f)
|
||||||
|
{
|
||||||
|
uint8_t *pread = f->pread;
|
||||||
|
uint8_t data = *(pread++);
|
||||||
|
uint8_t read2end = f->read2end;
|
||||||
|
|
||||||
|
if (--read2end == 0) {
|
||||||
|
read2end = f->size;
|
||||||
|
pread -= read2end;
|
||||||
|
}
|
||||||
|
|
||||||
|
f->pread = pread;
|
||||||
|
f->read2end = read2end;
|
||||||
|
|
||||||
|
uint8_t sreg = SREG;
|
||||||
|
cli();
|
||||||
|
f->count--;
|
||||||
|
SREG = sreg;
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* _FIFO_H_ */
|
||||||
35
poc/avr_iotest/main.c
Normal file
35
poc/avr_iotest/main.c
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
|
||||||
|
#include <avr/io.h>
|
||||||
|
#include <util/delay.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "uart.h"
|
||||||
|
extern FILE uart_stdout;
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
uart_init();
|
||||||
|
stdout = &uart_stdout;
|
||||||
|
printf("Init done\n");
|
||||||
|
|
||||||
|
DDRD |= (1 << PD7);
|
||||||
|
|
||||||
|
while(1){
|
||||||
|
|
||||||
|
/*
|
||||||
|
PORTD |= (1 << PD7);
|
||||||
|
PORTD &= ~(1 << PD7);
|
||||||
|
*/
|
||||||
|
PORTD ^= (1 << PD7);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0 ;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
79
poc/avr_iotest/uart.c
Normal file
79
poc/avr_iotest/uart.c
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
#include <avr/io.h>
|
||||||
|
#include <avr/interrupt.h>
|
||||||
|
#include <avr/pgmspace.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "uart.h"
|
||||||
|
#include "fifo.h"
|
||||||
|
|
||||||
|
volatile struct
|
||||||
|
{
|
||||||
|
uint8_t tmr_int: 1;
|
||||||
|
uint8_t adc_int: 1;
|
||||||
|
uint8_t rx_int: 1;
|
||||||
|
}
|
||||||
|
intflags;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* * Last character read from the UART.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
volatile char rxbuff;
|
||||||
|
|
||||||
|
|
||||||
|
FILE uart_stdout = FDEV_SETUP_STREAM(uart_stream, NULL, _FDEV_SETUP_WRITE);
|
||||||
|
|
||||||
|
void uart_init(void)
|
||||||
|
{
|
||||||
|
UCSRA = _BV(U2X); /* improves baud rate error @ F_CPU = 1 MHz */
|
||||||
|
UCSRB = _BV(TXEN)|_BV(RXEN)|_BV(RXCIE); /* tx/rx enable, rx complete intr */
|
||||||
|
UBRRL = (F_CPU / (8 * 115200UL)) - 1; /* 9600 Bd */
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ISR(USART_RXC_vect)
|
||||||
|
{
|
||||||
|
uint8_t c;
|
||||||
|
c = UDR;
|
||||||
|
if (bit_is_clear(UCSRA, FE)){
|
||||||
|
rxbuff = c;
|
||||||
|
intflags.rx_int = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void uart_putc(uint8_t c)
|
||||||
|
{
|
||||||
|
loop_until_bit_is_set(UCSRA, UDRE);
|
||||||
|
UDR = c;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void uart_puts(const char *s)
|
||||||
|
{
|
||||||
|
do {
|
||||||
|
uart_putc(*s);
|
||||||
|
}
|
||||||
|
while (*s++);
|
||||||
|
}
|
||||||
|
|
||||||
|
void uart_puts_P(PGM_P s)
|
||||||
|
{
|
||||||
|
while (1) {
|
||||||
|
unsigned char c = pgm_read_byte(s);
|
||||||
|
s++;
|
||||||
|
if ('\0' == c)
|
||||||
|
break;
|
||||||
|
uart_putc(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int uart_stream(char c, FILE *stream)
|
||||||
|
{
|
||||||
|
if (c == '\n')
|
||||||
|
uart_putc('\r');
|
||||||
|
loop_until_bit_is_set(UCSRA, UDRE);
|
||||||
|
UDR = c;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
18
poc/avr_iotest/uart.h
Normal file
18
poc/avr_iotest/uart.h
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
#ifndef _UART_H_
|
||||||
|
#define _UART_H_
|
||||||
|
|
||||||
|
#define CR "\r\n"
|
||||||
|
|
||||||
|
|
||||||
|
#include <avr/io.h>
|
||||||
|
#include <avr/pgmspace.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
void uart_init(void);
|
||||||
|
void uart_putc(const uint8_t);
|
||||||
|
void uart_puts(const char *s);
|
||||||
|
void uart_puts_P(PGM_P s);
|
||||||
|
static int uart_stream(char c, FILE *stream);
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* _UART_H_ */
|
||||||
@@ -182,7 +182,7 @@ AVRDUDE_PROGRAMMER = stk500v2
|
|||||||
|
|
||||||
# com1 = serial port. Use lpt1 to connect to parallel port.
|
# com1 = serial port. Use lpt1 to connect to parallel port.
|
||||||
|
|
||||||
AVRDUDE_PORT = /dev/tty.PL2303-00002006
|
AVRDUDE_PORT = /dev/tty.PL2303-00002126
|
||||||
|
|
||||||
AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
|
AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
|
||||||
|
|
||||||
|
|||||||
@@ -8,8 +8,8 @@
|
|||||||
# Revision: $Id: checksize 83 2006-01-05 22:20:53Z cs $
|
# Revision: $Id: checksize 83 2006-01-05 22:20:53Z cs $
|
||||||
|
|
||||||
error=0
|
error=0
|
||||||
codelimit=8192 # default value
|
codelimit=2048 # default value
|
||||||
datalimit=992 # default value; leave 32 bytes for stack
|
datalimit=96 # default value; leave 32 bytes for stack
|
||||||
|
|
||||||
if [ $# -gt 1 ]; then
|
if [ $# -gt 1 ]; then
|
||||||
codelimit="$2"
|
codelimit="$2"
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ extern FILE uart_stdout;
|
|||||||
#define RAM_REG PINA
|
#define RAM_REG PINA
|
||||||
|
|
||||||
#define CTRL_PORT PORTB
|
#define CTRL_PORT PORTB
|
||||||
#define CTR_DIR DDRB
|
#define CTRL_DIR DDRB
|
||||||
#define LATCH_PORT PORTB
|
#define LATCH_PORT PORTB
|
||||||
#define LATCH_DIR DDRB
|
#define LATCH_DIR DDRB
|
||||||
|
|
||||||
@@ -39,14 +39,78 @@ extern FILE uart_stdout;
|
|||||||
#define LED_PORT PORTD
|
#define LED_PORT PORTD
|
||||||
#define LED_DIR DDRD
|
#define LED_DIR DDRD
|
||||||
|
|
||||||
#define FILENAME "sprite.raw"
|
//#define FILENAME "sprite.raw" //ok
|
||||||
|
//#define FILENAME "ascii.smc" //ok
|
||||||
|
//#define FILENAME "rom.smc" //ok
|
||||||
|
//#define FILENAME "supert.smc" //ok
|
||||||
|
//#define FILENAME "vortex.smc" //failed
|
||||||
|
//#define FILENAME "mrdo.smc" //failed
|
||||||
|
//#define FILENAME "spacei.smc" //ok ntsc
|
||||||
|
//#define FILENAME "bank01.smc" //ok
|
||||||
|
//#define FILENAME "bank02.smc" //ok
|
||||||
|
//#define FILENAME "bank03.smc" //ok
|
||||||
|
//#define FILENAME "bank04.smc" //ok
|
||||||
|
//#define FILENAME "bank05.smc" //ok
|
||||||
|
//#define FILENAME "bank06.smc" //ok
|
||||||
|
//#define FILENAME "bank07.smc" //ok
|
||||||
|
//#define FILENAME "banklo.smc" //ok
|
||||||
|
//#define FILENAME "bankhi.smc" //ok
|
||||||
|
//#define FILENAME "vram2.smc" //ok
|
||||||
|
//#define FILENAME "super02.smc" //ok
|
||||||
|
//#define FILENAME "super01.smc"//ok
|
||||||
|
#define FILENAME "crc.smc" //ok
|
||||||
|
//#define FILENAME "banks.smc" //ok
|
||||||
|
//#define FILENAME "hungry.smc" //ok
|
||||||
|
//#define FILENAME "arkanoid.smc"//ok
|
||||||
|
//#define FILENAME "eric.smc"
|
||||||
|
//#define FILENAME "super01.smc"
|
||||||
|
|
||||||
|
#define ROMSIZE 2 // 4 == 4mbit == 512kb
|
||||||
|
// 2 == 2mbit == 256kb
|
||||||
|
#define DUMPNAME "dump256.smc"
|
||||||
#define BUFFER_SIZE 512
|
#define BUFFER_SIZE 512
|
||||||
#define BLOCKS 512
|
#define BLOCKS (ROMSIZE << 8)
|
||||||
#define MEMSIZE 0x80000
|
#define MEMSIZE 0x80000
|
||||||
|
|
||||||
uint8_t read_buffer[BUFFER_SIZE];
|
uint8_t read_buffer[BUFFER_SIZE];
|
||||||
|
|
||||||
|
|
||||||
|
uint16_t crc_xmodem_update (uint16_t crc, uint8_t data)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
crc = crc ^ ((uint16_t)data << 8);
|
||||||
|
for (i=0; i<8; i++)
|
||||||
|
{
|
||||||
|
if (crc & 0x8000)
|
||||||
|
crc = (crc << 1) ^ 0x1021;
|
||||||
|
else
|
||||||
|
crc <<= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return crc;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t do_crc(uint8_t * data,uint16_t size)
|
||||||
|
{
|
||||||
|
uint16_t crc =0;
|
||||||
|
uint16_t i;
|
||||||
|
for (i=0; i<size; i++){
|
||||||
|
crc = crc_xmodem_update(crc,data[i]);
|
||||||
|
//printf("%x : %x\n",crc,data[i]);
|
||||||
|
}
|
||||||
|
return crc;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint16_t do_crc_update(uint16_t crc,uint8_t * data,uint16_t size)
|
||||||
|
{
|
||||||
|
uint16_t i;
|
||||||
|
for (i=0; i<size; i++)
|
||||||
|
crc = crc_xmodem_update(crc,data[i]);
|
||||||
|
return crc;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void dump_packet(uint32_t addr,uint32_t len,uint8_t *packet){
|
void dump_packet(uint32_t addr,uint32_t len,uint8_t *packet){
|
||||||
uint16_t i,j;
|
uint16_t i,j;
|
||||||
uint16_t sum = 0;
|
uint16_t sum = 0;
|
||||||
@@ -101,6 +165,17 @@ void spi_master_transmit(unsigned char cData)
|
|||||||
while(!(SPSR & (1<<SPIF)));
|
while(!(SPSR & (1<<SPIF)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void sram_set_addr(uint32_t addr)
|
||||||
|
{
|
||||||
|
spi_master_transmit((uint8_t)(addr>>16));
|
||||||
|
spi_master_transmit((uint8_t)(addr>>8));
|
||||||
|
spi_master_transmit((uint8_t)(addr>>0));
|
||||||
|
|
||||||
|
LATCH_PORT |= (1<<S_LATCH);
|
||||||
|
LATCH_PORT &= ~(1<<S_LATCH);
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t sram_read(uint32_t addr)
|
uint8_t sram_read(uint32_t addr)
|
||||||
{
|
{
|
||||||
uint8_t byte;
|
uint8_t byte;
|
||||||
@@ -139,20 +214,29 @@ void sram_write(uint32_t addr, uint8_t data)
|
|||||||
{
|
{
|
||||||
RAM_DIR = 0xff;
|
RAM_DIR = 0xff;
|
||||||
|
|
||||||
|
/* deactive RD and WR on ram */
|
||||||
CTRL_PORT |= (1<<R_RD);
|
CTRL_PORT |= (1<<R_RD);
|
||||||
CTRL_PORT |= (1<<R_WR);
|
CTRL_PORT |= (1<<R_WR);
|
||||||
|
|
||||||
|
/* setup address */
|
||||||
spi_master_transmit((uint8_t)(addr>>16));
|
spi_master_transmit((uint8_t)(addr>>16));
|
||||||
spi_master_transmit((uint8_t)(addr>>8));
|
spi_master_transmit((uint8_t)(addr>>8));
|
||||||
spi_master_transmit((uint8_t)(addr>>0));
|
spi_master_transmit((uint8_t)(addr>>0));
|
||||||
|
|
||||||
|
/* passthru address in sreg */
|
||||||
LATCH_PORT |= (1<<S_LATCH);
|
LATCH_PORT |= (1<<S_LATCH);
|
||||||
LATCH_PORT &= ~(1<<S_LATCH);
|
LATCH_PORT &= ~(1<<S_LATCH);
|
||||||
|
|
||||||
|
/* write enable */
|
||||||
CTRL_PORT &= ~(1<<R_WR);
|
CTRL_PORT &= ~(1<<R_WR);
|
||||||
|
|
||||||
|
/* busdriver toggle */
|
||||||
|
|
||||||
|
|
||||||
|
/* write data */
|
||||||
RAM_PORT = data;
|
RAM_PORT = data;
|
||||||
|
|
||||||
|
/* disable write */
|
||||||
CTRL_PORT |= (1<<R_WR);
|
CTRL_PORT |= (1<<R_WR);
|
||||||
|
|
||||||
RAM_DIR = 0x00;
|
RAM_DIR = 0x00;
|
||||||
@@ -164,18 +248,28 @@ void sram_init(void){
|
|||||||
RAM_DIR = 0x00;
|
RAM_DIR = 0x00;
|
||||||
RAM_PORT = 0x00;
|
RAM_PORT = 0x00;
|
||||||
|
|
||||||
CTR_DIR |= ((1<<R_WR) | (1<<R_RD));
|
CTRL_DIR |= ((1<<R_WR) | (1<<R_RD));
|
||||||
CTRL_PORT |= (1<<R_RD);
|
CTRL_PORT |= (1<<R_RD);
|
||||||
CTRL_PORT |= (1<<R_WR);
|
CTRL_PORT |= (1<<R_WR);
|
||||||
|
|
||||||
LED_PORT |= (1<<D_LED0);
|
LED_PORT |= (1<<D_LED0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void sram_snes_mode(void){
|
void sram_snes_mode01(void){
|
||||||
CTRL_PORT |= (1<<R_WR);
|
CTRL_PORT |= (1<<R_WR);
|
||||||
CTRL_PORT &= ~(1<<R_RD);
|
CTRL_PORT &= ~(1<<R_RD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void sram_snes_mode02(void){
|
||||||
|
CTRL_DIR |= (1<<R_WR);
|
||||||
|
CTRL_PORT |= (1<<R_WR);
|
||||||
|
//CTRL_PORT &= ~(1<<R_RD);
|
||||||
|
CTRL_DIR &= ~(1<<R_RD);
|
||||||
|
CTRL_PORT &= ~(1<<R_RD);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void sram_clear(uint32_t addr, uint32_t len){
|
void sram_clear(uint32_t addr, uint32_t len){
|
||||||
|
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
@@ -217,8 +311,9 @@ int main(void)
|
|||||||
uint8_t fat_attrib = 0;
|
uint8_t fat_attrib = 0;
|
||||||
uint32_t fat_size = 0;
|
uint32_t fat_size = 0;
|
||||||
uint32_t rom_addr = 0;
|
uint32_t rom_addr = 0;
|
||||||
uint32_t skip_block = 0;
|
uint8_t bank_cnt = 0;
|
||||||
|
uint16_t crc = 0;
|
||||||
|
uint16_t block_cnt;
|
||||||
uart_init();
|
uart_init();
|
||||||
stdout = &uart_stdout;
|
stdout = &uart_stdout;
|
||||||
|
|
||||||
@@ -228,19 +323,37 @@ int main(void)
|
|||||||
spi_init();
|
spi_init();
|
||||||
printf("SPI Init\n");
|
printf("SPI Init\n");
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
uint8_t t[] = "david";
|
||||||
|
printf("Test CRC %x\n",do_crc(t,5));
|
||||||
|
while(1);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
sram_clear(0x000000, 0x80000);
|
||||||
|
printf("sram_clear\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
printf("read 0x0f0f\n");
|
||||||
|
sram_read(0x0f0f);
|
||||||
|
printf("write 0x0f0f\n");
|
||||||
|
sram_write(0x0f0f,0xaa);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
rom_addr = 0x4aaaa;
|
||||||
|
printf("write %lx\n",rom_addr);
|
||||||
|
sram_set_addr(rom_addr);
|
||||||
|
while(1);
|
||||||
|
#endif
|
||||||
|
|
||||||
//sram_clear(0x000000, 0x400000);
|
|
||||||
//printf("sram_clear\n");
|
|
||||||
|
|
||||||
//printf("read 0x0f0f\n");
|
|
||||||
//sram_read(0x0f0f);
|
|
||||||
//printf("write 0x0f0f\n");
|
|
||||||
//sram_write(0x0f0f,0xaa);
|
|
||||||
//while(1);
|
|
||||||
while ( mmc_init() !=0) {
|
while ( mmc_init() !=0) {
|
||||||
printf("No sdcard...\n");
|
printf("No sdcard...\n");
|
||||||
}
|
}
|
||||||
printf("MMC Init sone\n");
|
printf("MMC Init done\n");
|
||||||
fat_init(read_buffer);
|
fat_init(read_buffer);
|
||||||
printf("FAT Init done.\n");
|
printf("FAT Init done.\n");
|
||||||
rom_addr = 0x000000;
|
rom_addr = 0x000000;
|
||||||
@@ -253,29 +366,102 @@ int main(void)
|
|||||||
read_buffer) == 1) {
|
read_buffer) == 1) {
|
||||||
|
|
||||||
|
|
||||||
for (uint16_t block_cnt=0; block_cnt<BLOCKS; block_cnt++) {
|
for (block_cnt=0; block_cnt<BLOCKS; block_cnt++) {
|
||||||
fat_read_file (fat_cluster,read_buffer,block_cnt);
|
fat_read_file (fat_cluster,read_buffer,block_cnt);
|
||||||
if (block_cnt % 16 == 0)
|
|
||||||
printf("Write Ram 0x%lx Skipped %li\n",rom_addr,skip_block);
|
|
||||||
|
|
||||||
if (sram_check(read_buffer,512))
|
if (block_cnt && block_cnt % 64 == 0){
|
||||||
sram_copy(rom_addr,read_buffer,512);
|
printf("Write Ram Bank: 0x%x Addr: 0x%lx Block: %x CRC: %x\n",bank_cnt,rom_addr,block_cnt,crc);
|
||||||
else
|
bank_cnt++;
|
||||||
skip_block +=1;
|
crc = 0;
|
||||||
|
}
|
||||||
|
crc = do_crc_update(crc,read_buffer,512);
|
||||||
|
sram_copy(rom_addr,read_buffer,512);
|
||||||
rom_addr += 512;
|
rom_addr += 512;
|
||||||
}
|
}
|
||||||
printf("Done 0x%lx Skipped %li\n",rom_addr,skip_block);
|
printf("Write Ram Bank: 0x%x Addr: 0x%lx Block: %x CRC: %x\n",bank_cnt,rom_addr,block_cnt,crc);
|
||||||
|
printf("Done\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
printf("Dump Headern\r");
|
||||||
|
rom_addr = 0x8000-512;
|
||||||
|
sram_read_buffer(rom_addr,read_buffer,512);
|
||||||
|
dump_packet(rom_addr,512,read_buffer);
|
||||||
|
|
||||||
|
#if 0
|
||||||
printf("Dump Memory\n\r");
|
printf("Dump Memory\n\r");
|
||||||
rom_addr = 0x000000;
|
rom_addr = 0x000000;
|
||||||
for (uint16_t block_cnt=0; block_cnt<BLOCKS; block_cnt++) {
|
for (uint16_t block_cnt=0; block_cnt < 64; block_cnt++) {
|
||||||
sram_read_buffer(rom_addr,read_buffer,512);
|
sram_read_buffer(rom_addr,read_buffer,512);
|
||||||
dump_packet(rom_addr,512,read_buffer);
|
dump_packet(rom_addr,512,read_buffer);
|
||||||
rom_addr += 512;
|
rom_addr += 512;
|
||||||
}
|
}
|
||||||
printf("\nDone 0x%lx\n",rom_addr);
|
printf("\nDone 0x%lx\n",rom_addr);
|
||||||
sram_snes_mode();
|
#endif
|
||||||
printf("\nEnter Snes mode\n");
|
|
||||||
|
#if 1
|
||||||
|
block_cnt = 0;
|
||||||
|
crc = 0;
|
||||||
|
bank_cnt=0x00;
|
||||||
|
rom_addr = 0x000000;
|
||||||
|
for (block_cnt=0; block_cnt<BLOCKS; block_cnt++) {
|
||||||
|
sram_read_buffer(rom_addr,read_buffer,512);
|
||||||
|
if (block_cnt && block_cnt % 64 == 0){
|
||||||
|
printf("Read Ram Bank: 0x%x Addr: 0x%lx Block: %x CRC: %x\n",bank_cnt,rom_addr,block_cnt,crc);
|
||||||
|
bank_cnt++;
|
||||||
|
crc = 0;
|
||||||
|
}
|
||||||
|
crc = do_crc_update(crc,read_buffer,512);
|
||||||
|
rom_addr += 512;
|
||||||
|
}
|
||||||
|
printf("Read Ram Bank: 0x%x Addr: 0x%lx Block: %x CRC: %x\n",bank_cnt,rom_addr,block_cnt,crc);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
|
||||||
|
printf("Look for %s\n",DUMPNAME);
|
||||||
|
|
||||||
|
fat_cluster = 0;
|
||||||
|
fat_attrib = 0;
|
||||||
|
fat_size = 0;
|
||||||
|
|
||||||
|
if (fat_search_file((uint8_t*)DUMPNAME,
|
||||||
|
&fat_cluster,
|
||||||
|
&fat_size,
|
||||||
|
&fat_attrib,
|
||||||
|
read_buffer) == 1) {
|
||||||
|
|
||||||
|
|
||||||
|
printf("Found %s\n",DUMPNAME);
|
||||||
|
rom_addr = 0x000000;
|
||||||
|
bank_cnt =0;
|
||||||
|
for (uint16_t block_cnt=0; block_cnt<BLOCKS; block_cnt++) {
|
||||||
|
printf("Write 1");
|
||||||
|
sram_read_buffer(rom_addr,read_buffer,512);
|
||||||
|
printf("Write 2");
|
||||||
|
fat_write_file (fat_cluster,read_buffer,block_cnt);
|
||||||
|
if (block_cnt % 64 == 0){
|
||||||
|
bank_cnt++;
|
||||||
|
}
|
||||||
|
printf("Write File Bank: 0x%x Addr: 0x%lx Skipped: %li\n",bank_cnt,rom_addr,skip_block);
|
||||||
|
rom_addr += 512;
|
||||||
|
}
|
||||||
|
printf("Done 0x%lx Skipped %li\n",rom_addr,skip_block);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
sram_snes_mode01();
|
||||||
|
printf("\nEnter Snes mode 02\n");
|
||||||
|
#endif
|
||||||
|
#if 0
|
||||||
|
sram_snes_mode02();
|
||||||
|
printf("\nEnter Snes mode 02\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
printf("\nUpload done.\n");
|
||||||
|
|
||||||
while(1);
|
while(1);
|
||||||
return 0 ;
|
return 0 ;
|
||||||
|
|
||||||
|
|||||||
168
poc/avr_usbload/Makefile
Normal file
168
poc/avr_usbload/Makefile
Normal file
@@ -0,0 +1,168 @@
|
|||||||
|
# Name: Makefile
|
||||||
|
# Project: custom-class example
|
||||||
|
# Author: Christian Starkjohann
|
||||||
|
# Creation Date: 2008-04-07
|
||||||
|
# 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 $
|
||||||
|
|
||||||
|
DEVICE = atmega16
|
||||||
|
F_CPU = 16000000 # in Hz
|
||||||
|
FUSE_L = # see below for fuse values for particular devices
|
||||||
|
FUSE_H =
|
||||||
|
#AVRDUDE = avrdude -c stk500v2 -p $(DEVICE) -P /dev/tty.PL2303-00002006
|
||||||
|
AVRDUDE = sudo avrdude -c stk500v2 -p $(DEVICE) -P /dev/tty.PL2303-00002126
|
||||||
|
|
||||||
|
CFLAGS = -Iusbdrv -I. -DDEBUG_LEVEL=0
|
||||||
|
#-std=gnu99
|
||||||
|
OBJECTS = usbdrv/usbdrv.o usbdrv/usbdrvasm.o usbdrv/oddebug.o main.o uart.o fifo.o sram.o crc.o debug.o
|
||||||
|
|
||||||
|
COMPILE = avr-gcc -Wall -Os -DF_CPU=$(F_CPU) $(CFLAGS) -mmcu=$(DEVICE)
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
# Fuse values for particular devices
|
||||||
|
##############################################################################
|
||||||
|
# If your device is not listed here, go to
|
||||||
|
# http://palmavr.sourceforge.net/cgi-bin/fc.cgi
|
||||||
|
# and choose options for external crystal clock and no clock divider
|
||||||
|
#
|
||||||
|
################################## ATMega8 ##################################
|
||||||
|
# ATMega8 FUSE_L (Fuse low byte):
|
||||||
|
# 0x9f = 1 0 0 1 1 1 1 1
|
||||||
|
# ^ ^ \ / \--+--/
|
||||||
|
# | | | +------- CKSEL 3..0 (external >8M crystal)
|
||||||
|
# | | +--------------- SUT 1..0 (crystal osc, BOD enabled)
|
||||||
|
# | +------------------ BODEN (BrownOut Detector enabled)
|
||||||
|
# +-------------------- BODLEVEL (2.7V)
|
||||||
|
# ATMega8 FUSE_H (Fuse high byte):
|
||||||
|
# 0xc9 = 1 1 0 0 1 0 0 1 <-- BOOTRST (boot reset vector at 0x0000)
|
||||||
|
# ^ ^ ^ ^ ^ ^ ^------ BOOTSZ0
|
||||||
|
# | | | | | +-------- BOOTSZ1
|
||||||
|
# | | | | + --------- EESAVE (don't preserve EEPROM over chip erase)
|
||||||
|
# | | | +-------------- CKOPT (full output swing)
|
||||||
|
# | | +---------------- SPIEN (allow serial programming)
|
||||||
|
# | +------------------ WDTON (WDT not always on)
|
||||||
|
# +-------------------- RSTDISBL (reset pin is enabled)
|
||||||
|
#
|
||||||
|
############################## ATMega48/88/168 ##############################
|
||||||
|
# ATMega*8 FUSE_L (Fuse low byte):
|
||||||
|
# 0xdf = 1 1 0 1 1 1 1 1
|
||||||
|
# ^ ^ \ / \--+--/
|
||||||
|
# | | | +------- CKSEL 3..0 (external >8M crystal)
|
||||||
|
# | | +--------------- SUT 1..0 (crystal osc, BOD enabled)
|
||||||
|
# | +------------------ CKOUT (if 0: Clock output enabled)
|
||||||
|
# +-------------------- CKDIV8 (if 0: divide by 8)
|
||||||
|
# ATMega*8 FUSE_H (Fuse high byte):
|
||||||
|
# 0xde = 1 1 0 1 1 1 1 0
|
||||||
|
# ^ ^ ^ ^ ^ \-+-/
|
||||||
|
# | | | | | +------ BODLEVEL 0..2 (110 = 1.8 V)
|
||||||
|
# | | | | + --------- EESAVE (preserve EEPROM over chip erase)
|
||||||
|
# | | | +-------------- WDTON (if 0: watchdog always on)
|
||||||
|
# | | +---------------- SPIEN (allow serial programming)
|
||||||
|
# | +------------------ DWEN (debug wire enable)
|
||||||
|
# +-------------------- RSTDISBL (reset pin is enabled)
|
||||||
|
#
|
||||||
|
############################## ATTiny25/45/85 ###############################
|
||||||
|
# ATMega*5 FUSE_L (Fuse low byte):
|
||||||
|
# 0xef = 1 1 1 0 1 1 1 1
|
||||||
|
# ^ ^ \+/ \--+--/
|
||||||
|
# | | | +------- CKSEL 3..0 (clock selection -> crystal @ 12 MHz)
|
||||||
|
# | | +--------------- SUT 1..0 (BOD enabled, fast rising power)
|
||||||
|
# | +------------------ CKOUT (clock output on CKOUT pin -> disabled)
|
||||||
|
# +-------------------- CKDIV8 (divide clock by 8 -> don't divide)
|
||||||
|
# ATMega*5 FUSE_H (Fuse high byte):
|
||||||
|
# 0xdd = 1 1 0 1 1 1 0 1
|
||||||
|
# ^ ^ ^ ^ ^ \-+-/
|
||||||
|
# | | | | | +------ BODLEVEL 2..0 (brownout trigger level -> 2.7V)
|
||||||
|
# | | | | +---------- EESAVE (preserve EEPROM on Chip Erase -> not preserved)
|
||||||
|
# | | | +-------------- WDTON (watchdog timer always on -> disable)
|
||||||
|
# | | +---------------- SPIEN (enable serial programming -> enabled)
|
||||||
|
# | +------------------ DWEN (debug wire enable)
|
||||||
|
# +-------------------- RSTDISBL (disable external reset -> enabled)
|
||||||
|
#
|
||||||
|
################################ ATTiny2313 #################################
|
||||||
|
# ATTiny2313 FUSE_L (Fuse low byte):
|
||||||
|
# 0xef = 1 1 1 0 1 1 1 1
|
||||||
|
# ^ ^ \+/ \--+--/
|
||||||
|
# | | | +------- CKSEL 3..0 (clock selection -> crystal @ 12 MHz)
|
||||||
|
# | | +--------------- SUT 1..0 (BOD enabled, fast rising power)
|
||||||
|
# | +------------------ CKOUT (clock output on CKOUT pin -> disabled)
|
||||||
|
# +-------------------- CKDIV8 (divide clock by 8 -> don't divide)
|
||||||
|
# ATTiny2313 FUSE_H (Fuse high byte):
|
||||||
|
# 0xdb = 1 1 0 1 1 0 1 1
|
||||||
|
# ^ ^ ^ ^ \-+-/ ^
|
||||||
|
# | | | | | +---- RSTDISBL (disable external reset -> enabled)
|
||||||
|
# | | | | +-------- BODLEVEL 2..0 (brownout trigger level -> 2.7V)
|
||||||
|
# | | | +-------------- WDTON (watchdog timer always on -> disable)
|
||||||
|
# | | +---------------- SPIEN (enable serial programming -> enabled)
|
||||||
|
# | +------------------ EESAVE (preserve EEPROM on Chip Erase -> not preserved)
|
||||||
|
# +-------------------- DWEN (debug wire enable)
|
||||||
|
|
||||||
|
|
||||||
|
# symbolic targets:
|
||||||
|
help:
|
||||||
|
@echo "This Makefile has no default rule. Use one of the following:"
|
||||||
|
@echo "make hex ....... to build main.hex"
|
||||||
|
@echo "make program ... to flash fuses and firmware"
|
||||||
|
@echo "make fuse ...... to flash the fuses"
|
||||||
|
@echo "make flash ..... to flash the firmware (use this on metaboard)"
|
||||||
|
@echo "make clean ..... to delete objects and hex file"
|
||||||
|
|
||||||
|
all: hex
|
||||||
|
|
||||||
|
hex: main.hex
|
||||||
|
|
||||||
|
program: flash fuse
|
||||||
|
|
||||||
|
# rule for programming fuse bits:
|
||||||
|
fuse:
|
||||||
|
@[ "$(FUSE_H)" != "" -a "$(FUSE_L)" != "" ] || \
|
||||||
|
{ echo "*** Edit Makefile and choose values for FUSE_L and FUSE_H!"; exit 1; }
|
||||||
|
$(AVRDUDE) -U hfuse:w:$(FUSE_H):m -U lfuse:w:$(FUSE_L):m
|
||||||
|
|
||||||
|
# rule for uploading firmware:
|
||||||
|
flash: main.hex
|
||||||
|
$(AVRDUDE) -U flash:w:main.hex:i
|
||||||
|
|
||||||
|
# rule for deleting dependent files (those which can be built by Make):
|
||||||
|
clean:
|
||||||
|
rm -f main.hex main.lst main.obj main.cof main.list main.map main.eep.hex main.elf *.o usbdrv/*.o main.s usbdrv/oddebug.s usbdrv/usbdrv.s
|
||||||
|
|
||||||
|
# Generic rule for compiling C files:
|
||||||
|
.c.o:
|
||||||
|
$(COMPILE) -c $< -o $@
|
||||||
|
|
||||||
|
# Generic rule for assembling Assembler source files:
|
||||||
|
.S.o:
|
||||||
|
$(COMPILE) -x assembler-with-cpp -c $< -o $@
|
||||||
|
# "-x assembler-with-cpp" should not be necessary since this is the default
|
||||||
|
# file type for the .S (with capital S) extension. However, upper case
|
||||||
|
# characters are not always preserved on Windows. To ensure WinAVR
|
||||||
|
# compatibility define the file type manually.
|
||||||
|
|
||||||
|
# Generic rule for compiling C to assembler, used for debugging only.
|
||||||
|
.c.s:
|
||||||
|
$(COMPILE) -S $< -o $@
|
||||||
|
|
||||||
|
# file targets:
|
||||||
|
|
||||||
|
# Since we don't want to ship the driver multipe times, we copy it into this project:
|
||||||
|
usbdrv:
|
||||||
|
cp -r ../../../usbdrv .
|
||||||
|
|
||||||
|
main.elf: usbdrv $(OBJECTS) # usbdrv dependency only needed because we copy it
|
||||||
|
$(COMPILE) -o main.elf $(OBJECTS)
|
||||||
|
|
||||||
|
main.hex: main.elf
|
||||||
|
rm -f main.hex main.eep.hex
|
||||||
|
avr-objcopy -j .text -j .data -O ihex main.elf main.hex
|
||||||
|
avr-size main.hex
|
||||||
|
|
||||||
|
# debugging targets:
|
||||||
|
|
||||||
|
disasm: main.elf
|
||||||
|
avr-objdump -d main.elf
|
||||||
|
|
||||||
|
cpp:
|
||||||
|
$(COMPILE) -E main.c
|
||||||
35
poc/avr_usbload/checksize
Normal file
35
poc/avr_usbload/checksize
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Name: checksize
|
||||||
|
# Project: PowerSwitch/AVR-USB
|
||||||
|
# Author: Christian Starkjohann
|
||||||
|
# Creation Date: 2004-12-29
|
||||||
|
# Tabsize: 4
|
||||||
|
# Copyright: (c) 2005 OBJECTIVE DEVELOPMENT Software GmbH.
|
||||||
|
# Revision: $Id: checksize 83 2006-01-05 22:20:53Z cs $
|
||||||
|
|
||||||
|
error=0
|
||||||
|
codelimit=16384 # default value
|
||||||
|
datalimit=992 # default value; leave 32 bytes for stack
|
||||||
|
|
||||||
|
if [ $# -gt 1 ]; then
|
||||||
|
codelimit="$2"
|
||||||
|
fi
|
||||||
|
if [ $# -gt 2 ]; then
|
||||||
|
datalimit="$3"
|
||||||
|
fi
|
||||||
|
|
||||||
|
set -- `avr-size -d "$1" | awk '/[0-9]/ {print $1 + $2, $2 + $3, $2}'`
|
||||||
|
if [ $1 -gt $codelimit ]; then
|
||||||
|
echo "*** code size $1 exceeds limit of $codelimit"
|
||||||
|
error=1
|
||||||
|
else
|
||||||
|
echo "ROM: $1 bytes (data=$3)"
|
||||||
|
fi
|
||||||
|
if [ $2 -gt $datalimit ]; then
|
||||||
|
echo "*** data size $2 exceeds limit of $datalimit"
|
||||||
|
error=1
|
||||||
|
else
|
||||||
|
echo "RAM: $2 bytes"
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit $error
|
||||||
48
poc/avr_usbload/commandline/Makefile
Normal file
48
poc/avr_usbload/commandline/Makefile
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
# Name: Makefile
|
||||||
|
# Project: custom-class 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 = snesuploader
|
||||||
|
|
||||||
|
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)
|
||||||
285
poc/avr_usbload/commandline/opendevice.c
Normal file
285
poc/avr_usbload/commandline/opendevice.c
Normal file
@@ -0,0 +1,285 @@
|
|||||||
|
/*
|
||||||
|
* 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 <stdio.h>
|
||||||
|
#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 < rval; i++) {
|
||||||
|
if (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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* -------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
/* Name: opendevice.h
|
/* Name: opendevice.h
|
||||||
* Project: AVR-USB host-side library
|
* Project: V-USB host-side library
|
||||||
* Author: Christian Starkjohann
|
* Author: Christian Starkjohann
|
||||||
* Creation Date: 2008-04-10
|
* Creation Date: 2008-04-10
|
||||||
* Tabsize: 4
|
* Tabsize: 4
|
||||||
* Copyright: (c) 2008 by OBJECTIVE DEVELOPMENT Software GmbH
|
* Copyright: (c) 2008 by OBJECTIVE DEVELOPMENT Software GmbH
|
||||||
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
|
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
|
||||||
* This Revision: $Id: opendevice.h 692 2008-11-07 15:07:40Z cs $
|
* This Revision: $Id: opendevice.h 740 2009-04-13 18:23:31Z cs $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
249
poc/avr_usbload/commandline/snesuploader.c
Normal file
249
poc/avr_usbload/commandline/snesuploader.c
Normal file
@@ -0,0 +1,249 @@
|
|||||||
|
/*
|
||||||
|
* Name: set-led.c Project: custom-class, a basic USB 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#define READ_BUFFER_SIZE 1024
|
||||||
|
#define SEND_BUFFER_SIZE 128
|
||||||
|
#define BUFFER_CRC (1024 * 32)
|
||||||
|
#define BANK_SIZE (1<<15)
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <usb.h> /* this is libusb */
|
||||||
|
#include "opendevice.h" /* common code moved to separate module */
|
||||||
|
|
||||||
|
#include "../requests.h" /* custom request numbers */
|
||||||
|
#include "../usbconfig.h" /* device's VID/PID and names */
|
||||||
|
|
||||||
|
|
||||||
|
void dump_packet(uint32_t addr, uint32_t len, uint8_t * packet)
|
||||||
|
{
|
||||||
|
uint16_t i,
|
||||||
|
j;
|
||||||
|
uint16_t sum = 0;
|
||||||
|
uint8_t clear = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < len; i += 16) {
|
||||||
|
|
||||||
|
sum = 0;
|
||||||
|
for (j = 0; j < 16; j++) {
|
||||||
|
sum += packet[i + j];
|
||||||
|
}
|
||||||
|
if (!sum) {
|
||||||
|
clear = 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (clear) {
|
||||||
|
printf("*\n");
|
||||||
|
clear = 0;
|
||||||
|
}
|
||||||
|
printf("%08x:", addr + i);
|
||||||
|
for (j = 0; j < 16; j++) {
|
||||||
|
printf(" %02x", packet[i + j]);
|
||||||
|
}
|
||||||
|
printf(" |");
|
||||||
|
for (j = 0; j < 16; j++) {
|
||||||
|
if (packet[i + j] >= 33 && packet[i + j] <= 126)
|
||||||
|
printf("%c", packet[i + j]);
|
||||||
|
else
|
||||||
|
printf(".");
|
||||||
|
}
|
||||||
|
printf("|\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint16_t crc_xmodem_update(uint16_t crc, uint8_t data)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
crc = crc ^ ((uint16_t) data << 8);
|
||||||
|
for (i = 0; i < 8; i++) {
|
||||||
|
if (crc & 0x8000)
|
||||||
|
crc = (crc << 1) ^ 0x1021;
|
||||||
|
else
|
||||||
|
crc <<= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return crc;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t do_crc(uint8_t * data, uint16_t size)
|
||||||
|
{
|
||||||
|
uint16_t crc = 0;
|
||||||
|
uint16_t i;
|
||||||
|
for (i = 0; i < size; i++) {
|
||||||
|
crc = crc_xmodem_update(crc, data[i]);
|
||||||
|
}
|
||||||
|
return crc;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint16_t do_crc_update(uint16_t crc, uint8_t * data, uint16_t size)
|
||||||
|
{
|
||||||
|
uint16_t i;
|
||||||
|
for (i = 0; i < size; i++)
|
||||||
|
crc = crc_xmodem_update(crc, data[i]);
|
||||||
|
return crc;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void usage(char *name)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "usage:\n");
|
||||||
|
fprintf(stderr, " %s upload filename.. upload\n", name);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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};
|
||||||
|
int cnt,
|
||||||
|
vid,
|
||||||
|
pid;
|
||||||
|
int cnt_crc = 0;
|
||||||
|
uint8_t *read_buffer;
|
||||||
|
uint8_t *crc_buffer;
|
||||||
|
uint32_t addr = 0;
|
||||||
|
uint16_t addr_lo = 0;
|
||||||
|
uint16_t addr_hi = 0;
|
||||||
|
uint16_t step = 0;
|
||||||
|
uint16_t crc = 0;
|
||||||
|
uint8_t bank = 0;
|
||||||
|
FILE *fp;
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
printf("Open USB device \"%s\" with vid=0x%x pid=0x%x\n", product, vid,
|
||||||
|
pid);
|
||||||
|
if (strcasecmp(argv[1], "upload") == 0) {
|
||||||
|
if (argc < 3) { /* we need at least one argument */
|
||||||
|
usage(argv[0]);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
fp = fopen(argv[2], "r");
|
||||||
|
if (fp == NULL) {
|
||||||
|
fprintf(stderr, "Cannot open file %s ", argv[2]);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
read_buffer = (unsigned char *) malloc(READ_BUFFER_SIZE);
|
||||||
|
crc_buffer = (unsigned char *) malloc(BUFFER_CRC);
|
||||||
|
memset(crc_buffer, 0, BUFFER_CRC);
|
||||||
|
addr = 0x000000;
|
||||||
|
|
||||||
|
usb_control_msg(handle,
|
||||||
|
USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT,
|
||||||
|
USB_UPLOAD_INIT, 0, 0, NULL, 0, 5000);
|
||||||
|
|
||||||
|
|
||||||
|
while ((cnt = fread(read_buffer, READ_BUFFER_SIZE, 1, fp)) > 0) {
|
||||||
|
for (step = 0; step < READ_BUFFER_SIZE; step += SEND_BUFFER_SIZE) {
|
||||||
|
addr_lo = addr & 0xffff;
|
||||||
|
addr_hi = (addr >> 16) & 0xff;
|
||||||
|
cnt = usb_control_msg(handle,
|
||||||
|
USB_TYPE_VENDOR | USB_RECIP_DEVICE |
|
||||||
|
USB_ENDPOINT_OUT, USB_UPLOAD_ADDR, addr_hi,
|
||||||
|
addr_lo, (char *) read_buffer + step,
|
||||||
|
SEND_BUFFER_SIZE, 5000);
|
||||||
|
|
||||||
|
if (cnt < 0) {
|
||||||
|
fprintf(stderr, "USB error: %s\n", usb_strerror());
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
#if 0
|
||||||
|
dump_packet(addr, SEND_BUFFER_SIZE, read_buffer + step);
|
||||||
|
#endif
|
||||||
|
addr += SEND_BUFFER_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(crc_buffer + cnt_crc, read_buffer, READ_BUFFER_SIZE);
|
||||||
|
cnt_crc += READ_BUFFER_SIZE;
|
||||||
|
if (cnt_crc >= BANK_SIZE) {
|
||||||
|
crc = do_crc(crc_buffer, BANK_SIZE);
|
||||||
|
printf
|
||||||
|
("Addr: 0x%06x Bank: 0x%02x HiAddr: 0x%02x LoAddr: 0x%04x Crc: 0x%04x\n",
|
||||||
|
addr, bank, addr_hi, addr_lo, crc);
|
||||||
|
memset(crc_buffer, 0, BUFFER_CRC);
|
||||||
|
bank++;
|
||||||
|
cnt_crc = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cnt = usb_control_msg(handle,
|
||||||
|
USB_TYPE_VENDOR | USB_RECIP_DEVICE |
|
||||||
|
USB_ENDPOINT_OUT, USB_CRC, addr_hi, addr_lo, NULL,
|
||||||
|
0, 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 if (strcasecmp(argv[1], "crc") == 0) {
|
||||||
|
/*
|
||||||
|
* if(argc < 2){ usage(argv[0]); exit(1); }
|
||||||
|
*/
|
||||||
|
addr = 0x000000;
|
||||||
|
addr_lo = addr & 0xffff;
|
||||||
|
addr_hi = (addr >> 16) & 0xff;
|
||||||
|
printf("Request CRC for Addr: 0x%06x\n", addr);
|
||||||
|
|
||||||
|
cnt = usb_control_msg(handle,
|
||||||
|
USB_TYPE_VENDOR | USB_RECIP_DEVICE |
|
||||||
|
USB_ENDPOINT_OUT, USB_CRC_ADDR, addr_hi, addr_lo,
|
||||||
|
NULL, (1 << 15) / 4, 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 {
|
||||||
|
usage(argv[0]);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
usb_close(handle);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
41
poc/avr_usbload/crc.c
Normal file
41
poc/avr_usbload/crc.c
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "crc.h"
|
||||||
|
#include "uart.h"
|
||||||
|
|
||||||
|
extern FILE uart_stdout;
|
||||||
|
|
||||||
|
uint16_t crc_xmodem_update(uint16_t crc, uint8_t data)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
crc = crc ^ ((uint16_t) data << 8);
|
||||||
|
for (i = 0; i < 8; i++) {
|
||||||
|
if (crc & 0x8000)
|
||||||
|
crc = (crc << 1) ^ 0x1021;
|
||||||
|
else
|
||||||
|
crc <<= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return crc;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t do_crc(uint8_t * data, uint16_t size)
|
||||||
|
{
|
||||||
|
uint16_t crc = 0;
|
||||||
|
uint16_t i;
|
||||||
|
for (i = 0; i < size; i++) {
|
||||||
|
crc = crc_xmodem_update(crc, data[i]);
|
||||||
|
// printf("%x : %x\n",crc,data[i]);
|
||||||
|
}
|
||||||
|
return crc;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint16_t do_crc_update(uint16_t crc, uint8_t * data, uint16_t size)
|
||||||
|
{
|
||||||
|
uint16_t i;
|
||||||
|
for (i = 0; i < size; i++)
|
||||||
|
crc = crc_xmodem_update(crc, data[i]);
|
||||||
|
return crc;
|
||||||
|
}
|
||||||
7
poc/avr_usbload/crc.h
Normal file
7
poc/avr_usbload/crc.h
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
|
||||||
|
uint16_t crc_xmodem_update (uint16_t crc, uint8_t data);
|
||||||
|
uint16_t do_crc(uint8_t * data,uint16_t size);
|
||||||
|
uint16_t do_crc_update(uint16_t crc,uint8_t * data,uint16_t size);
|
||||||
44
poc/avr_usbload/debug.c
Normal file
44
poc/avr_usbload/debug.c
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "debug.h"
|
||||||
|
#include "uart.h"
|
||||||
|
|
||||||
|
|
||||||
|
extern FILE uart_stdout;
|
||||||
|
|
||||||
|
void dump_packet(uint32_t addr, uint32_t len, uint8_t * packet)
|
||||||
|
{
|
||||||
|
uint16_t i,
|
||||||
|
j;
|
||||||
|
uint16_t sum = 0;
|
||||||
|
uint8_t clear = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < len; i += 16) {
|
||||||
|
|
||||||
|
sum = 0;
|
||||||
|
for (j = 0; j < 16; j++) {
|
||||||
|
sum += packet[i + j];
|
||||||
|
}
|
||||||
|
if (!sum) {
|
||||||
|
clear = 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (clear) {
|
||||||
|
printf("*\n");
|
||||||
|
clear = 0;
|
||||||
|
}
|
||||||
|
printf("%08lx:", addr + i);
|
||||||
|
for (j = 0; j < 16; j++) {
|
||||||
|
printf(" %02x", packet[i + j]);
|
||||||
|
}
|
||||||
|
printf(" |");
|
||||||
|
for (j = 0; j < 16; j++) {
|
||||||
|
if (packet[i + j] >= 33 && packet[i + j] <= 126)
|
||||||
|
printf("%c", packet[i + j]);
|
||||||
|
else
|
||||||
|
printf(".");
|
||||||
|
}
|
||||||
|
printf("|\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
5
poc/avr_usbload/debug.h
Normal file
5
poc/avr_usbload/debug.h
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
void dump_packet(uint32_t addr,uint32_t len,uint8_t *packet);
|
||||||
|
|
||||||
28
poc/avr_usbload/fifo.c
Normal file
28
poc/avr_usbload/fifo.c
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
#include "fifo.h"
|
||||||
|
|
||||||
|
void fifo_init(fifo_t * f, uint8_t * buffer, const uint8_t size)
|
||||||
|
{
|
||||||
|
f->count = 0;
|
||||||
|
f->pread = f->pwrite = buffer;
|
||||||
|
f->read2end = f->write2end = f->size = size;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t fifo_put(fifo_t * f, const uint8_t data)
|
||||||
|
{
|
||||||
|
return _inline_fifo_put(f, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t fifo_get_wait(fifo_t * f)
|
||||||
|
{
|
||||||
|
while (!f->count);
|
||||||
|
|
||||||
|
return _inline_fifo_get(f);
|
||||||
|
}
|
||||||
|
|
||||||
|
int fifo_get_nowait(fifo_t * f)
|
||||||
|
{
|
||||||
|
if (!f->count)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return (int) _inline_fifo_get(f);
|
||||||
|
}
|
||||||
69
poc/avr_usbload/fifo.h
Normal file
69
poc/avr_usbload/fifo.h
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
#ifndef _FIFO_H_
|
||||||
|
#define _FIFO_H_
|
||||||
|
|
||||||
|
#include <avr/io.h>
|
||||||
|
#include <avr/interrupt.h>
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint8_t volatile count; // # Zeichen im Puffer
|
||||||
|
uint8_t size; // Puffer-Größe
|
||||||
|
uint8_t *pread; // Lesezeiger
|
||||||
|
uint8_t *pwrite; // Schreibzeiger
|
||||||
|
uint8_t read2end, write2end; // # Zeichen bis zum Überlauf Lese-/Schreibzeiger
|
||||||
|
} fifo_t;
|
||||||
|
|
||||||
|
extern void fifo_init(fifo_t *, uint8_t * buf, const uint8_t size);
|
||||||
|
extern uint8_t fifo_put(fifo_t *, const uint8_t data);
|
||||||
|
extern uint8_t fifo_get_wait(fifo_t *);
|
||||||
|
extern int fifo_get_nowait(fifo_t *);
|
||||||
|
|
||||||
|
static inline uint8_t _inline_fifo_put(fifo_t * f, const uint8_t data)
|
||||||
|
{
|
||||||
|
if (f->count >= f->size)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
uint8_t *pwrite = f->pwrite;
|
||||||
|
|
||||||
|
*(pwrite++) = data;
|
||||||
|
|
||||||
|
uint8_t write2end = f->write2end;
|
||||||
|
|
||||||
|
if (--write2end == 0) {
|
||||||
|
write2end = f->size;
|
||||||
|
pwrite -= write2end;
|
||||||
|
}
|
||||||
|
|
||||||
|
f->write2end = write2end;
|
||||||
|
f->pwrite = pwrite;
|
||||||
|
|
||||||
|
uint8_t sreg = SREG;
|
||||||
|
cli();
|
||||||
|
f->count++;
|
||||||
|
SREG = sreg;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline uint8_t _inline_fifo_get(fifo_t * f)
|
||||||
|
{
|
||||||
|
uint8_t *pread = f->pread;
|
||||||
|
uint8_t data = *(pread++);
|
||||||
|
uint8_t read2end = f->read2end;
|
||||||
|
|
||||||
|
if (--read2end == 0) {
|
||||||
|
read2end = f->size;
|
||||||
|
pread -= read2end;
|
||||||
|
}
|
||||||
|
|
||||||
|
f->pread = pread;
|
||||||
|
f->read2end = read2end;
|
||||||
|
|
||||||
|
uint8_t sreg = SREG;
|
||||||
|
cli();
|
||||||
|
f->count--;
|
||||||
|
SREG = sreg;
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* _FIFO_H_ */
|
||||||
212
poc/avr_usbload/main.c
Normal file
212
poc/avr_usbload/main.c
Normal file
@@ -0,0 +1,212 @@
|
|||||||
|
#include <avr/io.h>
|
||||||
|
#include <avr/wdt.h>
|
||||||
|
#include <avr/interrupt.h> /* for sei() */
|
||||||
|
#include <util/delay.h> /* for _delay_ms() */
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <avr/pgmspace.h> /* required by usbdrv.h */
|
||||||
|
|
||||||
|
#include "usbdrv.h"
|
||||||
|
#include "oddebug.h" /* This is also an example for using debug
|
||||||
|
* macros */
|
||||||
|
#include "requests.h" /* The custom request numbers we use */
|
||||||
|
#include "uart.h"
|
||||||
|
#include "sram.h"
|
||||||
|
#include "debug.h"
|
||||||
|
#include "crc.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define REQ_IDLE 0
|
||||||
|
#define REQ_UPLOAD 1
|
||||||
|
#define RES_CRC 2
|
||||||
|
#define BUFFER_SIZE 256
|
||||||
|
|
||||||
|
extern FILE uart_stdout;
|
||||||
|
|
||||||
|
uint8_t read_buffer[BUFFER_SIZE];
|
||||||
|
uint32_t req_addr = 0;
|
||||||
|
uint32_t req_size;
|
||||||
|
uint8_t req_bank;
|
||||||
|
uint32_t req_bank_size;
|
||||||
|
uint8_t req_state = REQ_IDLE;
|
||||||
|
uint8_t rx_remaining = 0;
|
||||||
|
uint8_t tx_remaining = 0;
|
||||||
|
uint16_t sync_errors = 0;
|
||||||
|
uint8_t tx_buffer[32];
|
||||||
|
uint8_t data_buffer[4];
|
||||||
|
uint32_t addr;
|
||||||
|
|
||||||
|
void crc_check_memory(uint32_t top_addr)
|
||||||
|
{
|
||||||
|
uint16_t crc = 0;
|
||||||
|
uint32_t addr;
|
||||||
|
req_bank = 0;
|
||||||
|
for (addr = 0x000000; addr < top_addr; addr += BUFFER_SIZE) {
|
||||||
|
sram_read_buffer(addr, read_buffer, BUFFER_SIZE);
|
||||||
|
crc = do_crc_update(crc, read_buffer, BUFFER_SIZE);
|
||||||
|
if (addr && addr % 32768 == 0) {
|
||||||
|
printf("crc_check_memory: req_bank: 0x%x Addr: 0x%lx CRC: %x\n",
|
||||||
|
req_bank, addr, crc);
|
||||||
|
req_bank++;
|
||||||
|
crc = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void crc_check_memory_range(uint32_t start_addr, uint32_t size)
|
||||||
|
{
|
||||||
|
uint16_t crc = 0;
|
||||||
|
uint32_t addr;
|
||||||
|
req_bank = 0;
|
||||||
|
for (addr = start_addr; addr < start_addr + size; addr += BUFFER_SIZE) {
|
||||||
|
sram_read_buffer(addr, read_buffer, BUFFER_SIZE);
|
||||||
|
crc = do_crc_update(crc, read_buffer, BUFFER_SIZE);
|
||||||
|
}
|
||||||
|
tx_buffer[0] = crc & 0xff;
|
||||||
|
tx_buffer[1] = (crc >> 8) & 0xff;
|
||||||
|
printf("crc_check_memory_range: Addr: 0x%lx CRC: %x\n", addr, crc);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
usbMsgLen_t usbFunctionSetup(uchar data[8])
|
||||||
|
{
|
||||||
|
|
||||||
|
usbRequest_t *rq = (void *) data;
|
||||||
|
uint8_t ret_len = 0;
|
||||||
|
if (rq->bRequest == USB_UPLOAD_INIT) {
|
||||||
|
req_bank = 0;
|
||||||
|
rx_remaining = 0;
|
||||||
|
req_bank_size = 1 << rq->wValue.word;
|
||||||
|
sync_errors = 0;
|
||||||
|
printf("USB_UPLOAD_INIT: bank size %li\n", req_bank_size);
|
||||||
|
} else if (rq->bRequest == USB_UPLOAD_ADDR) { /* echo -- used for
|
||||||
|
* reliability tests */
|
||||||
|
req_state = REQ_UPLOAD;
|
||||||
|
req_addr = rq->wValue.word;
|
||||||
|
req_addr = req_addr << 16;
|
||||||
|
req_addr = req_addr | rq->wIndex.word;
|
||||||
|
if (rx_remaining) {
|
||||||
|
sync_errors++;
|
||||||
|
printf
|
||||||
|
("USB_UPLOAD_ADDR: Out of sync Addr=0x%lx remain=%i packet=%i sync_error=%i\n",
|
||||||
|
req_addr, rx_remaining, rq->wLength.word, sync_errors);
|
||||||
|
ret_len = 0;
|
||||||
|
}
|
||||||
|
rx_remaining = rq->wLength.word;
|
||||||
|
ret_len = 0xff;
|
||||||
|
if (req_addr && req_addr % req_bank_size == 0) {
|
||||||
|
printf("USB_UPLOAD_ADDR: req_bank: 0x%x Addr: 0x%08lx \n",
|
||||||
|
req_bank, req_addr);
|
||||||
|
req_bank++;
|
||||||
|
}
|
||||||
|
ret_len = 0xff;
|
||||||
|
} else if (rq->bRequest == USB_DOWNLOAD_INIT) {
|
||||||
|
printf("USB_DOWNLOAD_INIT\n");
|
||||||
|
} else if (rq->bRequest == USB_DOWNLOAD_ADDR) {
|
||||||
|
printf("USB_DOWNLOAD_ADDR\n");
|
||||||
|
} else if (rq->bRequest == USB_CRC) {
|
||||||
|
req_addr = rq->wValue.word;
|
||||||
|
req_addr = req_addr << 16;
|
||||||
|
req_addr = req_addr | rq->wIndex.word;
|
||||||
|
printf("USB_CRC: Addr 0x%lx \n", req_addr);
|
||||||
|
cli();
|
||||||
|
crc_check_memory(req_addr);
|
||||||
|
sei();
|
||||||
|
} else if (rq->bRequest == USB_CRC_ADDR) {
|
||||||
|
req_addr = rq->wValue.word;
|
||||||
|
req_addr = req_addr << 16;
|
||||||
|
req_addr = req_addr | rq->wIndex.word;
|
||||||
|
printf("USB_CRC_ADDR: Addr: 0x%lx Size: %i\n", req_addr,
|
||||||
|
rq->wLength.word);
|
||||||
|
req_size = rq->wLength.word;
|
||||||
|
req_size = req_size << 2;
|
||||||
|
tx_remaining = 2;
|
||||||
|
printf("USB_CRC_ADDR: Addr: 0x%lx Size: %li\n", req_addr, req_size);
|
||||||
|
cli();
|
||||||
|
// crc_check_memory_range(req_addr,req_size);
|
||||||
|
sei();
|
||||||
|
ret_len = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
usbMsgPtr = data_buffer;
|
||||||
|
return ret_len; /* default for not implemented requests: return
|
||||||
|
* no data back to host */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint8_t usbFunctionWrite(uint8_t * data, uint8_t len)
|
||||||
|
{
|
||||||
|
if (len > rx_remaining) {
|
||||||
|
printf("usbFunctionWrite more data than expected remain: %i len: %i\n",
|
||||||
|
rx_remaining, len);
|
||||||
|
len = rx_remaining;
|
||||||
|
}
|
||||||
|
if (req_state == REQ_UPLOAD) {
|
||||||
|
|
||||||
|
rx_remaining -= len;
|
||||||
|
#if 1
|
||||||
|
printf("usbFunctionWrite addr: 0x%08lx len: %i rx_remaining=%i\n",
|
||||||
|
req_addr, len, rx_remaining);
|
||||||
|
#endif
|
||||||
|
cli();
|
||||||
|
sram_copy(req_addr, data, len);
|
||||||
|
sei();
|
||||||
|
req_addr += len;
|
||||||
|
}
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t usbFunctionRead(uint8_t * data, uint8_t len)
|
||||||
|
{
|
||||||
|
uint8_t i;
|
||||||
|
if (len > tx_remaining)
|
||||||
|
len = tx_remaining;
|
||||||
|
tx_remaining -= len;
|
||||||
|
#if 1
|
||||||
|
printf("usbFunctionRead len=%i tx_remaining=%i \n", len, tx_remaining);
|
||||||
|
#endif
|
||||||
|
for (i = 0; i < len; i++) {
|
||||||
|
*data = tx_buffer[len];
|
||||||
|
data++;
|
||||||
|
}
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* -------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
uint8_t i;
|
||||||
|
//wdt_enable(WDTO_1S);
|
||||||
|
uart_init();
|
||||||
|
stdout = &uart_stdout;
|
||||||
|
sram_init();
|
||||||
|
printf("SRAM Init\n");
|
||||||
|
spi_init();
|
||||||
|
printf("SPI Init\n");
|
||||||
|
usbInit();
|
||||||
|
printf("USB Init\n");
|
||||||
|
usbDeviceDisconnect(); /* enforce re-enumeration, do this while
|
||||||
|
* interrupts are disabled! */
|
||||||
|
printf("USB disconnect\n");
|
||||||
|
i = 10;
|
||||||
|
while (--i) { /* fake USB disconnect for > 250 ms */
|
||||||
|
wdt_reset();
|
||||||
|
_delay_ms(1);
|
||||||
|
}
|
||||||
|
usbDeviceConnect();
|
||||||
|
printf("USB connect\n");
|
||||||
|
sei();
|
||||||
|
printf("USB poll\n");
|
||||||
|
for (;;) { /* main event loop */
|
||||||
|
wdt_reset();
|
||||||
|
usbPoll();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* -------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
26
poc/avr_usbload/requests.h
Normal file
26
poc/avr_usbload/requests.h
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
/* 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 USB_UPLOAD_INIT 0
|
||||||
|
#define USB_UPLOAD_ADDR 1
|
||||||
|
#define USB_DOWNLOAD_INIT 2
|
||||||
|
#define USB_DOWNLOAD_ADDR 3
|
||||||
|
#define USB_CRC 4
|
||||||
|
#define USB_CRC_ADDR 5
|
||||||
|
|
||||||
|
#endif /* __REQUESTS_H_INCLUDED__ */
|
||||||
172
poc/avr_usbload/sram.c
Normal file
172
poc/avr_usbload/sram.c
Normal file
@@ -0,0 +1,172 @@
|
|||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <avr/io.h>
|
||||||
|
|
||||||
|
#include "sram.h"
|
||||||
|
#include "uart.h"
|
||||||
|
#include "debug.h"
|
||||||
|
|
||||||
|
void spi_init(void)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Set MOSI and SCK output, all others input
|
||||||
|
*/
|
||||||
|
SPI_DIR |= ((1 << S_MOSI) | (1 << S_SCK) | (1 << S_LATCH));
|
||||||
|
SPI_DIR &= ~(1 << S_MISO);
|
||||||
|
SPI_PORT |= (1 << S_MISO);
|
||||||
|
/*
|
||||||
|
* Enable SPI, Master
|
||||||
|
*/
|
||||||
|
SPCR = ((1 << SPE) | (1 << MSTR));
|
||||||
|
}
|
||||||
|
|
||||||
|
void spi_master_transmit(unsigned char cData)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Start transmission
|
||||||
|
*/
|
||||||
|
SPDR = cData;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Wait for transmission complete
|
||||||
|
*/
|
||||||
|
while (!(SPSR & (1 << SPIF)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void sram_set_addr(uint32_t addr)
|
||||||
|
{
|
||||||
|
spi_master_transmit((uint8_t) (addr >> 16));
|
||||||
|
spi_master_transmit((uint8_t) (addr >> 8));
|
||||||
|
spi_master_transmit((uint8_t) (addr >> 0));
|
||||||
|
|
||||||
|
LATCH_PORT |= (1 << S_LATCH);
|
||||||
|
LATCH_PORT &= ~(1 << S_LATCH);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t sram_read(uint32_t addr)
|
||||||
|
{
|
||||||
|
uint8_t byte;
|
||||||
|
|
||||||
|
RAM_DIR = 0x00;
|
||||||
|
RAM_PORT = 0xff;
|
||||||
|
|
||||||
|
CTRL_PORT |= (1 << R_RD);
|
||||||
|
CTRL_PORT |= (1 << R_WR);
|
||||||
|
|
||||||
|
spi_master_transmit((uint8_t) (addr >> 16));
|
||||||
|
spi_master_transmit((uint8_t) (addr >> 8));
|
||||||
|
spi_master_transmit((uint8_t) (addr >> 0));
|
||||||
|
|
||||||
|
LATCH_PORT |= (1 << S_LATCH);
|
||||||
|
LATCH_PORT &= ~(1 << S_LATCH);
|
||||||
|
CTRL_PORT &= ~(1 << R_RD);
|
||||||
|
|
||||||
|
asm volatile ("nop");
|
||||||
|
asm volatile ("nop");
|
||||||
|
asm volatile ("nop");
|
||||||
|
asm volatile ("nop");
|
||||||
|
asm volatile ("nop");
|
||||||
|
asm volatile ("nop");
|
||||||
|
asm volatile ("nop");
|
||||||
|
asm volatile ("nop");
|
||||||
|
|
||||||
|
byte = RAM_REG;
|
||||||
|
CTRL_PORT |= (1 << R_RD);
|
||||||
|
RAM_DIR = 0x00;
|
||||||
|
RAM_PORT = 0x00;
|
||||||
|
return byte;
|
||||||
|
}
|
||||||
|
|
||||||
|
void sram_write(uint32_t addr, uint8_t data)
|
||||||
|
{
|
||||||
|
RAM_DIR = 0xff;
|
||||||
|
|
||||||
|
CTRL_PORT |= (1 << R_RD);
|
||||||
|
CTRL_PORT |= (1 << R_WR);
|
||||||
|
|
||||||
|
spi_master_transmit((uint8_t) (addr >> 16));
|
||||||
|
spi_master_transmit((uint8_t) (addr >> 8));
|
||||||
|
spi_master_transmit((uint8_t) (addr >> 0));
|
||||||
|
|
||||||
|
LATCH_PORT |= (1 << S_LATCH);
|
||||||
|
LATCH_PORT &= ~(1 << S_LATCH);
|
||||||
|
|
||||||
|
|
||||||
|
CTRL_PORT &= ~(1 << R_WR);
|
||||||
|
|
||||||
|
RAM_PORT = data;
|
||||||
|
CTRL_PORT |= (1 << R_WR);
|
||||||
|
|
||||||
|
RAM_DIR = 0x00;
|
||||||
|
RAM_PORT = 0x00;
|
||||||
|
}
|
||||||
|
|
||||||
|
void sram_init(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
RAM_DIR = 0x00;
|
||||||
|
RAM_PORT = 0x00;
|
||||||
|
|
||||||
|
CTRL_DIR |= ((1 << R_WR) | (1 << R_RD));
|
||||||
|
CTRL_PORT |= (1 << R_RD);
|
||||||
|
CTRL_PORT |= (1 << R_WR);
|
||||||
|
|
||||||
|
LED_PORT |= (1 << D_LED0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void sram_snes_mode01(void)
|
||||||
|
{
|
||||||
|
CTRL_PORT |= (1 << R_WR);
|
||||||
|
CTRL_PORT &= ~(1 << R_RD);
|
||||||
|
}
|
||||||
|
|
||||||
|
void sram_snes_mode02(void)
|
||||||
|
{
|
||||||
|
CTRL_DIR |= (1 << R_WR);
|
||||||
|
CTRL_PORT |= (1 << R_WR);
|
||||||
|
// CTRL_PORT &= ~(1<<R_RD);
|
||||||
|
CTRL_DIR &= ~(1 << R_RD);
|
||||||
|
CTRL_PORT &= ~(1 << R_RD);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void sram_clear(uint32_t addr, uint32_t len)
|
||||||
|
{
|
||||||
|
|
||||||
|
uint32_t i;
|
||||||
|
for (i = addr; i < (addr + len); i++) {
|
||||||
|
if (0 == i % 0xfff)
|
||||||
|
printf("sram_clear %lx\n\r", i);
|
||||||
|
sram_write(i, 0x00);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void sram_copy(uint32_t addr, uint8_t * src, uint32_t len)
|
||||||
|
{
|
||||||
|
|
||||||
|
uint32_t i;
|
||||||
|
uint8_t *ptr = src;
|
||||||
|
for (i = addr; i < (addr + len); i++)
|
||||||
|
sram_write(i, *ptr++);
|
||||||
|
}
|
||||||
|
|
||||||
|
void sram_read_buffer(uint32_t addr, uint8_t * dst, uint32_t len)
|
||||||
|
{
|
||||||
|
|
||||||
|
uint32_t i;
|
||||||
|
uint8_t *ptr = dst;
|
||||||
|
for (i = addr; i < (addr + len); i++) {
|
||||||
|
*ptr = sram_read(i);
|
||||||
|
ptr++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
uint8_t sram_check(uint8_t * buffer, uint32_t len)
|
||||||
|
{
|
||||||
|
uint16_t cnt;
|
||||||
|
for (cnt = 0; cnt < len; cnt++)
|
||||||
|
if (buffer[cnt])
|
||||||
|
return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
51
poc/avr_usbload/sram.h
Normal file
51
poc/avr_usbload/sram.h
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <avr/io.h>
|
||||||
|
|
||||||
|
|
||||||
|
//SREG defines
|
||||||
|
#define S_MOSI PB5
|
||||||
|
#define S_MISO PB6
|
||||||
|
#define S_SCK PB7
|
||||||
|
#define S_LATCH PB4
|
||||||
|
|
||||||
|
//DEBUG defines
|
||||||
|
#define D_LED0 PD6
|
||||||
|
|
||||||
|
//SRAM defines
|
||||||
|
#define R_WR PB1
|
||||||
|
#define R_RD PB0
|
||||||
|
|
||||||
|
#define RAM_PORT PORTA
|
||||||
|
#define RAM_DIR DDRA
|
||||||
|
#define RAM_REG PINA
|
||||||
|
|
||||||
|
#define CTRL_PORT PORTB
|
||||||
|
#define CTRL_DIR DDRB
|
||||||
|
#define LATCH_PORT PORTB
|
||||||
|
#define LATCH_DIR DDRB
|
||||||
|
|
||||||
|
#define SPI_PORT PORTB
|
||||||
|
#define SPI_DIR DDRB
|
||||||
|
|
||||||
|
#define LED_PORT PORTD
|
||||||
|
#define LED_DIR DDRD
|
||||||
|
|
||||||
|
#define ROMSIZE 4
|
||||||
|
#define BLOCKS (ROMSIZE << 8)
|
||||||
|
#define MEMSIZE 0x80000
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void spi_init(void);
|
||||||
|
void spi_master_transmit(unsigned char cData);
|
||||||
|
void sram_set_addr(uint32_t addr);
|
||||||
|
uint8_t sram_read(uint32_t addr);
|
||||||
|
void sram_write(uint32_t addr, uint8_t data);
|
||||||
|
void sram_init(void);
|
||||||
|
void sram_snes_mode01(void);
|
||||||
|
void sram_snes_mode02(void);
|
||||||
|
void sram_clear(uint32_t addr, uint32_t len);
|
||||||
|
void sram_copy(uint32_t addr,uint8_t *src, uint32_t len);
|
||||||
|
void sram_read_buffer(uint32_t addr,uint8_t *dst, uint32_t len);
|
||||||
|
uint8_t sram_check(uint8_t *buffer, uint32_t len);
|
||||||
78
poc/avr_usbload/uart.c
Normal file
78
poc/avr_usbload/uart.c
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
#include <avr/io.h>
|
||||||
|
#include <avr/interrupt.h>
|
||||||
|
#include <avr/pgmspace.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "uart.h"
|
||||||
|
#include "fifo.h"
|
||||||
|
|
||||||
|
volatile struct {
|
||||||
|
uint8_t tmr_int:1;
|
||||||
|
uint8_t adc_int:1;
|
||||||
|
uint8_t rx_int:1;
|
||||||
|
} intflags;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* * Last character read from the UART.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
volatile char rxbuff;
|
||||||
|
|
||||||
|
|
||||||
|
FILE uart_stdout = FDEV_SETUP_STREAM(uart_stream, NULL, _FDEV_SETUP_WRITE);
|
||||||
|
|
||||||
|
void uart_init(void)
|
||||||
|
{
|
||||||
|
UCSRA = _BV(U2X); /* improves baud rate error @ F_CPU = 1 MHz */
|
||||||
|
UCSRB = _BV(TXEN) | _BV(RXEN) | _BV(RXCIE); /* tx/rx enable, rx complete
|
||||||
|
* intr */
|
||||||
|
UBRRL = (F_CPU / (8 * 115200UL)) - 1; /* 9600 Bd */
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ISR(USART_RXC_vect)
|
||||||
|
{
|
||||||
|
uint8_t c;
|
||||||
|
c = UDR;
|
||||||
|
if (bit_is_clear(UCSRA, FE)) {
|
||||||
|
rxbuff = c;
|
||||||
|
intflags.rx_int = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void uart_putc(uint8_t c)
|
||||||
|
{
|
||||||
|
loop_until_bit_is_set(UCSRA, UDRE);
|
||||||
|
UDR = c;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void uart_puts(const char *s)
|
||||||
|
{
|
||||||
|
do {
|
||||||
|
uart_putc(*s);
|
||||||
|
}
|
||||||
|
while (*s++);
|
||||||
|
}
|
||||||
|
|
||||||
|
void uart_puts_P(PGM_P s)
|
||||||
|
{
|
||||||
|
while (1) {
|
||||||
|
unsigned char c = pgm_read_byte(s);
|
||||||
|
s++;
|
||||||
|
if ('\0' == c)
|
||||||
|
break;
|
||||||
|
uart_putc(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int uart_stream(char c, FILE * stream)
|
||||||
|
{
|
||||||
|
if (c == '\n')
|
||||||
|
uart_putc('\r');
|
||||||
|
loop_until_bit_is_set(UCSRA, UDRE);
|
||||||
|
UDR = c;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
18
poc/avr_usbload/uart.h
Normal file
18
poc/avr_usbload/uart.h
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
#ifndef _UART_H_
|
||||||
|
#define _UART_H_
|
||||||
|
|
||||||
|
#define CR "\r\n"
|
||||||
|
|
||||||
|
|
||||||
|
#include <avr/io.h>
|
||||||
|
#include <avr/pgmspace.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
void uart_init(void);
|
||||||
|
void uart_putc(const uint8_t);
|
||||||
|
void uart_puts(const char *s);
|
||||||
|
void uart_puts_P(PGM_P s);
|
||||||
|
static int uart_stream(char c, FILE *stream);
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* _UART_H_ */
|
||||||
351
poc/avr_usbload/usbconfig.h
Normal file
351
poc/avr_usbload/usbconfig.h
Normal file
@@ -0,0 +1,351 @@
|
|||||||
|
/* 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 740 2009-04-13 18:23:31Z 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 4
|
||||||
|
/* 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 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
|
||||||
|
* "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 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!
|
||||||
|
* Default if not specified: 12 MHz
|
||||||
|
*/
|
||||||
|
#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 6
|
||||||
|
/* 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 0
|
||||||
|
/* 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 1
|
||||||
|
/* 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 40
|
||||||
|
/* 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 1
|
||||||
|
/* 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_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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* -------------------------- Device Description --------------------------- */
|
||||||
|
|
||||||
|
#define USB_CFG_VENDOR_ID 0xc0, 0x16
|
||||||
|
/* USB vendor ID for the device, low byte first. If you have registered your
|
||||||
|
* own Vendor ID, define it here. Otherwise you use one of obdev's free shared
|
||||||
|
* VID/PID pairs. Be sure to read USBID-License.txt for rules!
|
||||||
|
*/
|
||||||
|
#define USB_CFG_DEVICE_ID 0xdc, 0x05
|
||||||
|
/* 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 use obdev's free shared VID/PID pair. Be sure to read the rules in
|
||||||
|
* USBID-License.txt!
|
||||||
|
*/
|
||||||
|
#define USB_CFG_DEVICE_VERSION 0x00, 0x01
|
||||||
|
/* Version number of the device: Minor number first, then major number.
|
||||||
|
*/
|
||||||
|
#define USB_CFG_VENDOR_NAME 'o', 'p', 't', 'i', 'x', 'x', '.', 'o', 'r', 'g'
|
||||||
|
#define USB_CFG_VENDOR_NAME_LEN 10
|
||||||
|
/* 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 USBID-License.txt for
|
||||||
|
* details.
|
||||||
|
*/
|
||||||
|
#define USB_CFG_DEVICE_NAME 'S', 'N', 'E', 'S', 'R', 'A', 'M'
|
||||||
|
#define USB_CFG_DEVICE_NAME_LEN 7
|
||||||
|
/* Same as above for the device name. If you don't want a device name, undefine
|
||||||
|
* the macros. See the file USBID-License.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 0xff /* set to 0 if deferred to interface */
|
||||||
|
#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 0 /* define class here if not at device level */
|
||||||
|
#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 0
|
||||||
|
|
||||||
|
/* 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 SIG_INTERRUPT0 */
|
||||||
|
|
||||||
|
#endif /* __usbconfig_h_included__ */
|
||||||
@@ -268,3 +268,10 @@ Scroll down to the bottom to see the most recent changes.
|
|||||||
- Integrated a module with CRC checks at 18 MHz by Lukas Schrittwieser.
|
- Integrated a module with CRC checks at 18 MHz by Lukas Schrittwieser.
|
||||||
|
|
||||||
* Release 2009-03-23
|
* 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
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
AVR-USB Driver Software License Agreement
|
V-USB Driver Software License Agreement
|
||||||
Version 2008-10-07
|
Version 2009-04-14
|
||||||
|
|
||||||
THIS LICENSE AGREEMENT GRANTS YOU CERTAIN RIGHTS IN A SOFTWARE. YOU CAN
|
THIS LICENSE AGREEMENT GRANTS YOU CERTAIN RIGHTS IN A SOFTWARE. YOU CAN
|
||||||
ENTER INTO THIS AGREEMENT AND ACQUIRE THE RIGHTS OUTLINED BELOW BY PAYING
|
ENTER INTO THIS AGREEMENT AND ACQUIRE THE RIGHTS OUTLINED BELOW BY PAYING
|
||||||
@@ -13,8 +13,8 @@ Grosse Schiffgasse 1A/7, 1020 Wien, AUSTRIA.
|
|||||||
|
|
||||||
1.2 "You" shall mean the Licensee.
|
1.2 "You" shall mean the Licensee.
|
||||||
|
|
||||||
1.3 "AVR-USB" shall mean all files included in the package distributed under
|
1.3 "V-USB" shall mean all files included in the package distributed under
|
||||||
the name "avrusb" by OBJECTIVE DEVELOPMENT (http://www.obdev.at/avrusb/)
|
the name "vusb" by OBJECTIVE DEVELOPMENT (http://www.obdev.at/vusb/)
|
||||||
unless otherwise noted. This includes the firmware-only USB device
|
unless otherwise noted. This includes the firmware-only USB device
|
||||||
implementation for Atmel AVR microcontrollers, some simple device examples
|
implementation for Atmel AVR microcontrollers, some simple device examples
|
||||||
and host side software examples and libraries.
|
and host side software examples and libraries.
|
||||||
@@ -23,21 +23,22 @@ and host side software examples and libraries.
|
|||||||
2 LICENSE GRANTS
|
2 LICENSE GRANTS
|
||||||
|
|
||||||
2.1 Source Code. OBJECTIVE DEVELOPMENT shall furnish you with the source
|
2.1 Source Code. OBJECTIVE DEVELOPMENT shall furnish you with the source
|
||||||
code of AVR-USB.
|
code of V-USB.
|
||||||
|
|
||||||
2.2 Distribution and Use. OBJECTIVE DEVELOPMENT grants you the
|
2.2 Distribution and Use. OBJECTIVE DEVELOPMENT grants you the
|
||||||
non-exclusive right to use, copy and distribute AVR-USB with your hardware
|
non-exclusive right to use, copy and distribute V-USB with your hardware
|
||||||
product(s), restricted by the limitations in section 3 below.
|
product(s), restricted by the limitations in section 3 below.
|
||||||
|
|
||||||
2.3 Modifications. OBJECTIVE DEVELOPMENT grants you the right to modify
|
2.3 Modifications. OBJECTIVE DEVELOPMENT grants you the right to modify
|
||||||
the source code and your copy of AVR-USB according to your needs.
|
the source code and your copy of V-USB according to your needs.
|
||||||
|
|
||||||
2.4 USB IDs. OBJECTIVE DEVELOPMENT grants you the exclusive rights to use
|
2.4 USB IDs. OBJECTIVE DEVELOPMENT furnishes you with one or two USB Product
|
||||||
USB Product ID(s) sent to you in e-mail after receiving your payment in
|
ID(s), sent to you in e-mail. These Product IDs are reserved exclusively for
|
||||||
conjunction with USB Vendor ID 5824. OBJECTIVE DEVELOPMENT has acquired an
|
you. They have been obtained from Wouter van Ooijen (www.voti.nl), who has
|
||||||
exclusive license for this pair of USB identifiers from Wouter van Ooijen
|
reserved the Vendor ID 5824 (decimal) at the USB Implementers Forum, Inc.
|
||||||
(www.voti.nl), who has licensed the VID from the USB Implementers Forum,
|
(www.usb.org). This mechanism ensures that there are no Product ID conflicts,
|
||||||
Inc. (www.usb.org).
|
but you cannot become USB certified (enter into the USB-IF Trademark License
|
||||||
|
Agreement) as you would need your own Vendor ID for that.
|
||||||
|
|
||||||
|
|
||||||
3 LICENSE RESTRICTIONS
|
3 LICENSE RESTRICTIONS
|
||||||
@@ -46,21 +47,21 @@ Inc. (www.usb.org).
|
|||||||
applicable. Which one is determined by the amount you pay to OBJECTIVE
|
applicable. Which one is determined by the amount you pay to OBJECTIVE
|
||||||
DEVELOPMENT, see section 4 ("Payment") below.
|
DEVELOPMENT, see section 4 ("Payment") below.
|
||||||
|
|
||||||
Hobby License: You may use AVR-USB according to section 2 above in no more
|
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.
|
than 5 hardware units. These units must not be sold for profit.
|
||||||
|
|
||||||
Entry Level License: You may use AVR-USB according to section 2 above in no
|
Entry Level License: You may use V-USB according to section 2 above in no
|
||||||
more than 150 hardware units.
|
more than 150 hardware units.
|
||||||
|
|
||||||
Professional License: You may use AVR-USB according to section 2 above in
|
Professional License: You may use V-USB according to section 2 above in
|
||||||
any number of hardware units, except for large scale production ("unlimited
|
any number of hardware units, except for large scale production ("unlimited
|
||||||
fair use"). Quantities below 10,000 units are not considered large scale
|
fair use"). Quantities below 10,000 units are not considered large scale
|
||||||
production. If your reach quantities which are obviously 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
|
production, you must pay a license fee of 0.10 EUR per unit for all units
|
||||||
above 10,000.
|
above 10,000.
|
||||||
|
|
||||||
3.2 Rental. You may not rent, lease, or lend AVR-USB or otherwise encumber
|
3.2 Rental. You may not rent, lease, or lend V-USB or otherwise encumber
|
||||||
any copy of AVR-USB, or any of the rights granted herein.
|
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
|
3.3 Transfer. You may not transfer your rights under this Agreement to
|
||||||
another party without OBJECTIVE DEVELOPMENT's prior written consent. If
|
another party without OBJECTIVE DEVELOPMENT's prior written consent. If
|
||||||
@@ -78,7 +79,7 @@ non-exclusive.
|
|||||||
by third parties. In particular, you are not allowed to use the USB logo or
|
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
|
other trademarks owned by the USB Implementers Forum, Inc. without their
|
||||||
consent. Since such consent depends on USB certification, it should be
|
consent. Since such consent depends on USB certification, it should be
|
||||||
noted that AVR-USB will not pass certification because it does not
|
noted that V-USB will not pass certification because it does not
|
||||||
implement checksum verification and the microcontroller ports do not meet
|
implement checksum verification and the microcontroller ports do not meet
|
||||||
the electrical specifications.
|
the electrical specifications.
|
||||||
|
|
||||||
@@ -88,15 +89,15 @@ the electrical specifications.
|
|||||||
The payment amount depends on the variation of this agreement (according to
|
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
|
section 3.1) into which you want to enter. Concrete prices are listed on
|
||||||
OBJECTIVE DEVELOPMENT's web site, usually at
|
OBJECTIVE DEVELOPMENT's web site, usually at
|
||||||
http://www.obdev.at/avrusb/license.html. You agree to pay the amount listed
|
http://www.obdev.at/vusb/license.html. You agree to pay the amount listed
|
||||||
there to OBJECTIVE DEVELOPMENT or OBJECTIVE DEVELOPMENT's payment processor
|
there to OBJECTIVE DEVELOPMENT or OBJECTIVE DEVELOPMENT's payment processor
|
||||||
or reseller.
|
or reseller.
|
||||||
|
|
||||||
|
|
||||||
5 COPYRIGHT AND OWNERSHIP
|
5 COPYRIGHT AND OWNERSHIP
|
||||||
|
|
||||||
AVR-USB is protected by copyright laws and international copyright
|
V-USB is protected by copyright laws and international copyright
|
||||||
treaties, as well as other intellectual property laws and treaties. AVR-USB
|
treaties, as well as other intellectual property laws and treaties. V-USB
|
||||||
is licensed, not sold.
|
is licensed, not sold.
|
||||||
|
|
||||||
|
|
||||||
@@ -112,12 +113,12 @@ and limitation of liability shall survive termination of this agreement.
|
|||||||
|
|
||||||
7 DISCLAIMER OF WARRANTY AND LIABILITY
|
7 DISCLAIMER OF WARRANTY AND LIABILITY
|
||||||
|
|
||||||
LIMITED WARRANTY. AVR-USB IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
|
LIMITED WARRANTY. V-USB IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
|
||||||
KIND. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, OBJECTIVE
|
KIND. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, OBJECTIVE
|
||||||
DEVELOPMENT AND ITS SUPPLIERS HEREBY DISCLAIM ALL WARRANTIES, EITHER
|
DEVELOPMENT AND ITS SUPPLIERS HEREBY DISCLAIM ALL WARRANTIES, EITHER
|
||||||
EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE, AND
|
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE, AND
|
||||||
NON-INFRINGEMENT, WITH REGARD TO AVR-USB, AND THE PROVISION OF OR FAILURE
|
NON-INFRINGEMENT, WITH REGARD TO V-USB, AND THE PROVISION OF OR FAILURE
|
||||||
TO PROVIDE SUPPORT SERVICES. THIS LIMITED WARRANTY GIVES YOU SPECIFIC LEGAL
|
TO PROVIDE SUPPORT SERVICES. THIS LIMITED WARRANTY GIVES YOU SPECIFIC LEGAL
|
||||||
RIGHTS. YOU MAY HAVE OTHERS, WHICH VARY FROM STATE/JURISDICTION TO
|
RIGHTS. YOU MAY HAVE OTHERS, WHICH VARY FROM STATE/JURISDICTION TO
|
||||||
STATE/JURISDICTION.
|
STATE/JURISDICTION.
|
||||||
@@ -127,11 +128,11 @@ IN NO EVENT SHALL OBJECTIVE DEVELOPMENT OR ITS SUPPLIERS BE LIABLE FOR ANY
|
|||||||
SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER
|
SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER
|
||||||
(INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS,
|
(INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS,
|
||||||
BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR ANY OTHER PECUNIARY
|
BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR ANY OTHER PECUNIARY
|
||||||
LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE AVR-USB OR THE
|
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
|
PROVISION OF OR FAILURE TO PROVIDE SUPPORT SERVICES, EVEN IF OBJECTIVE
|
||||||
DEVELOPMENT HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. IN ANY
|
DEVELOPMENT HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. IN ANY
|
||||||
CASE, OBJECTIVE DEVELOPMENT'S ENTIRE LIABILITY UNDER ANY PROVISION OF THIS
|
CASE, OBJECTIVE DEVELOPMENT'S ENTIRE LIABILITY UNDER ANY PROVISION OF THIS
|
||||||
AGREEMENT SHALL BE LIMITED TO THE AMOUNT ACTUALLY PAID BY YOU FOR AVR-USB.
|
AGREEMENT SHALL BE LIMITED TO THE AMOUNT ACTUALLY PAID BY YOU FOR V-USB.
|
||||||
|
|
||||||
|
|
||||||
8 MISCELLANEOUS TERMS
|
8 MISCELLANEOUS TERMS
|
||||||
@@ -1,18 +1,18 @@
|
|||||||
OBJECTIVE DEVELOPMENT GmbH's AVR-USB driver software is distributed under the
|
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
|
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
|
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,
|
text of GPLv2 is included below. In addition to the requirements in the GPL,
|
||||||
we STRONGLY ENCOURAGE you to do the following:
|
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.
|
(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/avrusb/feedback.html for your submission.
|
Use the form at http://www.obdev.at/vusb/feedback.html for your submission.
|
||||||
|
|
||||||
(2) Adhere to minimum publication standards. Please include AT LEAST:
|
(2) Adhere to minimum publication standards. Please include AT LEAST:
|
||||||
- a circuit diagram in PDF, PNG or GIF format
|
- a circuit diagram in PDF, PNG or GIF format
|
||||||
- full source code for the host software
|
- full source code for the host software
|
||||||
- a Readme.txt file in ASCII format which describes the purpose of the
|
- 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
|
project and what can be found in which directories and which files
|
||||||
- a reference to http://www.obdev.at/avrusb/
|
- a reference to http://www.obdev.at/vusb/
|
||||||
|
|
||||||
(3) If you improve the driver firmware itself, please give us a free license
|
(3) If you improve the driver firmware itself, please give us a free license
|
||||||
to your modifications for our commercial license offerings.
|
to your modifications for our commercial license offerings.
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
This is the Readme file to Objective Development's firmware-only USB driver
|
This is the Readme file to Objective Development's firmware-only USB driver
|
||||||
for Atmel AVR microcontrollers. For more information please visit
|
for Atmel AVR microcontrollers. For more information please visit
|
||||||
http://www.obdev.at/avrusb/
|
http://www.obdev.at/vusb/
|
||||||
|
|
||||||
This directory contains the USB firmware only. Copy it as-is to your own
|
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
|
project and add all .c and .S files to your project (these files are marked
|
||||||
@@ -53,7 +53,7 @@ actual clock rate must be configured in usbdrv.h unless you use the default
|
|||||||
12 MHz.
|
12 MHz.
|
||||||
|
|
||||||
12 MHz Clock
|
12 MHz Clock
|
||||||
This is the traditional clock rate of AVR-USB because it's the lowest 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.
|
rate where the timing constraints of the USB spec can be met.
|
||||||
|
|
||||||
15 MHz Clock
|
15 MHz Clock
|
||||||
@@ -78,7 +78,7 @@ 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
|
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.
|
all AVRs can reach 12.8 MHz, although this is outside the specified range.
|
||||||
|
|
||||||
See the EasyLogger example at http://www.obdev.at/avrusb/easylogger.html for
|
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.
|
code which calibrates the RC oscillator based on the USB frame clock.
|
||||||
|
|
||||||
18 MHz Clock
|
18 MHz Clock
|
||||||
@@ -108,14 +108,14 @@ and hobbyists, we provide some VID/PID pairs for free. See the file
|
|||||||
USBID-License.txt for details.
|
USBID-License.txt for details.
|
||||||
|
|
||||||
Objective Development also has some license offerings which include product
|
Objective Development also has some license offerings which include product
|
||||||
IDs. See http://www.obdev.at/avrusb/ for details.
|
IDs. See http://www.obdev.at/vusb/ for details.
|
||||||
|
|
||||||
|
|
||||||
DEVELOPMENT SYSTEM
|
DEVELOPMENT SYSTEM
|
||||||
==================
|
==================
|
||||||
This driver has been developed and optimized for the GNU compiler version 3
|
This driver has been developed and optimized for the GNU compiler version 3
|
||||||
(gcc 3). It does work well with gcc 4, but with bigger code size. We recommend
|
(gcc 3). It does work well with gcc 4, but with bigger code size. We recommend
|
||||||
that you use the GNU compiler suite because it is freely available. AVR-USB
|
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
|
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"
|
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
|
memory model. Not every release is tested with IAR CC and the driver may
|
||||||
@@ -123,8 +123,8 @@ 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.
|
usbdrv.c because this module has been deliberately optimized for gcc.
|
||||||
|
|
||||||
|
|
||||||
USING AVR-USB FOR FREE
|
USING V-USB FOR FREE
|
||||||
======================
|
====================
|
||||||
The AVR firmware driver is published under the GNU General Public License
|
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
|
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.
|
your choice whether you apply the terms of version 2 or version 3.
|
||||||
@@ -133,26 +133,26 @@ 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:
|
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.
|
(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/avrusb/feedback.html for your submission.
|
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
|
If you don't have a web site, you can publish the project in obdev's
|
||||||
documentation wiki at
|
documentation wiki at
|
||||||
http://www.obdev.at/goto.php?t=avrusb-wiki&p=hosted-projects.
|
http://www.obdev.at/goto.php?t=vusb-wiki&p=hosted-projects.
|
||||||
|
|
||||||
(2) Adhere to minimum publication standards. Please include AT LEAST:
|
(2) Adhere to minimum publication standards. Please include AT LEAST:
|
||||||
- a circuit diagram in PDF, PNG or GIF format
|
- a circuit diagram in PDF, PNG or GIF format
|
||||||
- full source code for the host software
|
- full source code for the host software
|
||||||
- a Readme.txt file in ASCII format which describes the purpose of the
|
- 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
|
project and what can be found in which directories and which files
|
||||||
- a reference to http://www.obdev.at/avrusb/
|
- a reference to http://www.obdev.at/vusb/
|
||||||
|
|
||||||
(3) If you improve the driver firmware itself, please give us a free license
|
(3) If you improve the driver firmware itself, please give us a free license
|
||||||
to your modifications for our commercial license offerings.
|
to your modifications for our commercial license offerings.
|
||||||
|
|
||||||
|
|
||||||
COMMERCIAL LICENSES FOR AVR-USB
|
COMMERCIAL LICENSES FOR V-USB
|
||||||
===============================
|
=============================
|
||||||
If you don't want to publish your source code under the terms of the GPL,
|
If you don't want to publish your source code under the terms of the GPL,
|
||||||
you can simply pay money for AVR-USB. As an additional benefit you get
|
you can simply pay money for V-USB. As an additional benefit you get
|
||||||
USB PIDs for free, licensed exclusively to you. See the file
|
USB PIDs for free, reserved exclusively to you. See the file
|
||||||
"CommercialLicense.txt" for details.
|
"CommercialLicense.txt" for details.
|
||||||
|
|
||||||
@@ -1,10 +1,17 @@
|
|||||||
Royalty-Free Non-Exclusive License USB Product-ID
|
Royalty-Free Non-Exclusive Use of USB Product-IDs
|
||||||
=================================================
|
=================================================
|
||||||
|
|
||||||
Version 2008-04-07
|
Version 2009-04-13
|
||||||
|
|
||||||
|
Strictly speaking, this is not a license. You can't give a license to use
|
||||||
|
a simple number (such as e.g. 1500) for any purpose. This is a set of rules
|
||||||
|
which should make it possible to build USB devices without the requirement
|
||||||
|
for individual USB IDs. If you break one of the rules, you will run into
|
||||||
|
technical problems sooner or later, but you don't risk legal trouble.
|
||||||
|
|
||||||
|
|
||||||
OBJECTIVE DEVELOPMENT Software GmbH hereby grants you the non-exclusive
|
OBJECTIVE DEVELOPMENT Software GmbH hereby grants you the non-exclusive
|
||||||
right to use three USB.org vendor-ID (VID) / product-ID (PID) pairs with
|
right to use four USB.org vendor-ID (VID) / product-ID (PID) pairs with
|
||||||
products based on Objective Development's firmware-only USB driver for
|
products based on Objective Development's firmware-only USB driver for
|
||||||
Atmel AVR microcontrollers:
|
Atmel AVR microcontrollers:
|
||||||
|
|
||||||
@@ -27,10 +34,11 @@ used by many companies and individuals for different products. To avoid
|
|||||||
conflicts, your device and host driver software MUST adhere to the rules
|
conflicts, your device and host driver software MUST adhere to the rules
|
||||||
outlined below.
|
outlined below.
|
||||||
|
|
||||||
OBJECTIVE DEVELOPMENT Software GmbH has licensed these VID/PID pairs from
|
OBJECTIVE DEVELOPMENT Software GmbH has obtained these VID/PID pairs from
|
||||||
Wouter van Ooijen (see www.voti.nl), who has licensed the VID from the USB
|
Wouter van Ooijen (see www.voti.nl) for exclusive disposition. Wouter van
|
||||||
Implementers Forum, Inc. (see www.usb.org). The VID is registered for the
|
Ooijen has obtained the VID from the USB Implementers Forum, Inc.
|
||||||
company name "Van Ooijen Technische Informatica".
|
(see www.usb.org). The VID is registered for the company name
|
||||||
|
"Van Ooijen Technische Informatica".
|
||||||
|
|
||||||
|
|
||||||
RULES AND RESTRICTIONS
|
RULES AND RESTRICTIONS
|
||||||
@@ -44,7 +52,7 @@ MUST be available at least in USB language 0x0409 (English/US).
|
|||||||
domain name (e.g. "mycompany.com") registered and owned by you, or an
|
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
|
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
|
the domain name or e-mail address in any string you like, e.g. "Objective
|
||||||
Development http://www.obdev.at/avrusb/".
|
Development http://www.obdev.at/vusb/".
|
||||||
|
|
||||||
(3) You are responsible for retaining ownership of the domain or e-mail
|
(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.
|
address for as long as any of your products are in use.
|
||||||
@@ -142,5 +150,5 @@ violates the USB specification. If you do it, you do it at your own risk.
|
|||||||
|
|
||||||
To avoid possible incompatibilities, we highly recommend that you get your
|
To avoid possible incompatibilities, we highly recommend that you get your
|
||||||
own VID/PID pair if you intend to sell your product. Objective
|
own VID/PID pair if you intend to sell your product. Objective
|
||||||
Development's commercial licenses for AVR-USB include a PID for
|
Development's commercial licenses for V-USB include a PID for
|
||||||
unrestricted exclusive use.
|
unrestricted exclusive use.
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/* Name: asmcommon.inc
|
/* Name: asmcommon.inc
|
||||||
* Project: AVR USB driver
|
* Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers
|
||||||
* Author: Christian Starkjohann
|
* Author: Christian Starkjohann
|
||||||
* Creation Date: 2007-11-05
|
* Creation Date: 2007-11-05
|
||||||
* Tabsize: 4
|
* Tabsize: 4
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
/* Name: usbconfig.h
|
/* Name: usbconfig.h
|
||||||
* Project: AVR USB driver
|
* Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers
|
||||||
* Author: Christian Starkjohann
|
* Author: Christian Starkjohann
|
||||||
* Creation Date: 2005-04-01
|
* Creation Date: 2005-04-01
|
||||||
* Tabsize: 4
|
* Tabsize: 4
|
||||||
* Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH
|
* Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH
|
||||||
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
|
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
|
||||||
* This Revision: $Id: usbconfig-prototype.h 734 2009-03-23 11:10:07Z cs $
|
* This Revision: $Id: usbconfig-prototype.h 740 2009-04-13 18:23:31Z cs $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __usbconfig_h_included__
|
#ifndef __usbconfig_h_included__
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
/*
|
/*
|
||||||
General Description:
|
General Description:
|
||||||
This file is an example configuration (with inline documentation) for the USB
|
This file is an example configuration (with inline documentation) for the USB
|
||||||
driver. It configures AVR-USB for USB D+ connected to Port D bit 2 (which is
|
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
|
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
|
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
|
other hardware interrupt, as long as it is the highest level interrupt, see
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
/* Name: usbdrv.c
|
/* Name: usbdrv.c
|
||||||
* Project: AVR USB driver
|
* Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers
|
||||||
* Author: Christian Starkjohann
|
* Author: Christian Starkjohann
|
||||||
* Creation Date: 2004-12-29
|
* Creation Date: 2004-12-29
|
||||||
* Tabsize: 4
|
* Tabsize: 4
|
||||||
* Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH
|
* Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH
|
||||||
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
|
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
|
||||||
* This Revision: $Id: usbdrv.c 721 2009-03-16 19:03:19Z cs $
|
* This Revision: $Id: usbdrv.c 740 2009-04-13 18:23:31Z cs $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "usbportability.h"
|
#include "usbportability.h"
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
/* Name: usbdrv.h
|
/* Name: usbdrv.h
|
||||||
* Project: AVR USB driver
|
* Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers
|
||||||
* Author: Christian Starkjohann
|
* Author: Christian Starkjohann
|
||||||
* Creation Date: 2004-12-29
|
* Creation Date: 2004-12-29
|
||||||
* Tabsize: 4
|
* Tabsize: 4
|
||||||
* Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH
|
* Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH
|
||||||
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
|
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
|
||||||
* This Revision: $Id: usbdrv.h 738 2009-03-23 11:13:24Z cs $
|
* This Revision: $Id: usbdrv.h 748 2009-04-15 15:05:07Z cs $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __usbdrv_h_included__
|
#ifndef __usbdrv_h_included__
|
||||||
@@ -122,7 +122,7 @@ USB messages, even if they address another (low-speed) device on the same bus.
|
|||||||
/* --------------------------- Module Interface ---------------------------- */
|
/* --------------------------- Module Interface ---------------------------- */
|
||||||
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
||||||
|
|
||||||
#define USBDRV_VERSION 20090323
|
#define USBDRV_VERSION 20090415
|
||||||
/* This define uniquely identifies a driver version. It is a decimal number
|
/* 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
|
* 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
|
* driver's behavior or interface changes, you can use this constant to
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
/* Name: usbdrvasm.S
|
/* Name: usbdrvasm.S
|
||||||
* Project: AVR USB driver
|
* Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers
|
||||||
* Author: Christian Starkjohann
|
* Author: Christian Starkjohann
|
||||||
* Creation Date: 2007-06-13
|
* Creation Date: 2007-06-13
|
||||||
* Tabsize: 4
|
* Tabsize: 4
|
||||||
* Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH
|
* Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH
|
||||||
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
|
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
|
||||||
* Revision: $Id: usbdrvasm.S 722 2009-03-16 19:03:57Z cs $
|
* Revision: $Id: usbdrvasm.S 740 2009-04-13 18:23:31Z cs $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/* Name: usbdrvasm.asm
|
/* Name: usbdrvasm.asm
|
||||||
* Project: AVR USB driver
|
* Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers
|
||||||
* Author: Christian Starkjohann
|
* Author: Christian Starkjohann
|
||||||
* Creation Date: 2006-03-01
|
* Creation Date: 2006-03-01
|
||||||
* Tabsize: 4
|
* Tabsize: 4
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
/* Name: usbdrvasm12.inc
|
/* Name: usbdrvasm12.inc
|
||||||
* Project: AVR USB driver
|
* Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers
|
||||||
* Author: Christian Starkjohann
|
* Author: Christian Starkjohann
|
||||||
* Creation Date: 2004-12-29
|
* Creation Date: 2004-12-29
|
||||||
* Tabsize: 4
|
* Tabsize: 4
|
||||||
* Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH
|
* Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH
|
||||||
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
|
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
|
||||||
* This Revision: $Id: usbdrvasm12.inc 692 2008-11-07 15:07:40Z cs $
|
* 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
|
/* Do not link this file! Link usbdrvasm.S instead, which includes the
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
/* Name: usbdrvasm128.inc
|
/* Name: usbdrvasm128.inc
|
||||||
* Project: AVR USB driver
|
* Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers
|
||||||
* Author: Christian Starkjohann
|
* Author: Christian Starkjohann
|
||||||
* Creation Date: 2008-10-11
|
* Creation Date: 2008-10-11
|
||||||
* Tabsize: 4
|
* Tabsize: 4
|
||||||
* Copyright: (c) 2008 by OBJECTIVE DEVELOPMENT Software GmbH
|
* Copyright: (c) 2008 by OBJECTIVE DEVELOPMENT Software GmbH
|
||||||
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
|
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
|
||||||
* This Revision: $Id: usbdrvasm128.inc 692 2008-11-07 15:07:40Z cs $
|
* This Revision: $Id: usbdrvasm128.inc 740 2009-04-13 18:23:31Z cs $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Do not link this file! Link usbdrvasm.S instead, which includes the
|
/* Do not link this file! Link usbdrvasm.S instead, which includes the
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
/* Name: usbdrvasm15.inc
|
/* Name: usbdrvasm15.inc
|
||||||
* Project: AVR USB driver
|
* Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers
|
||||||
* Author: contributed by V. Bosch
|
* Author: contributed by V. Bosch
|
||||||
* Creation Date: 2007-08-06
|
* Creation Date: 2007-08-06
|
||||||
* Tabsize: 4
|
* Tabsize: 4
|
||||||
* Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH
|
* Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH
|
||||||
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
|
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
|
||||||
* Revision: $Id: usbdrvasm15.inc 692 2008-11-07 15:07:40Z cs $
|
* Revision: $Id: usbdrvasm15.inc 740 2009-04-13 18:23:31Z cs $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Do not link this file! Link usbdrvasm.S instead, which includes the
|
/* Do not link this file! Link usbdrvasm.S instead, which includes the
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user