forked from Miceuz/i2c-moisture-sensor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add standalone programmer/testrig code
- Loading branch information
miceuz
committed
Feb 16, 2016
1 parent
455abee
commit 0457a59
Showing
6 changed files
with
796 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/usr/bin/python | ||
import sys | ||
|
||
f = open(sys.argv[1]) | ||
lines = f.readlines() | ||
wordCount = 0; | ||
print 'PROGMEM const unsigned int firmware[] = {' | ||
for line in lines: | ||
line = line[9:-4] | ||
while line != '': | ||
print '0x' + line[2:4] + line[0:2] + ',', | ||
line = line[4:] | ||
wordCount += 1 | ||
print '' | ||
print '};' | ||
print '#define FIRMWARE_WORD_COUNT ', wordCount |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
# Name: Makefile | ||
# Project: hid-mouse 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 = attiny44 | ||
F_CPU = 8000000 # in Hz | ||
FUSE_L = 0xE2# see below for fuse values for particular devices | ||
FUSE_H = 0xD6 | ||
AVRDUDE = avrdude -c usbasp -P usb -p $(DEVICE) # edit this line for your programmer | ||
|
||
CFLAGS = -Iusbdrv -I. -DDEBUG_LEVEL=0 -Os | ||
CFLAGS += -ffunction-sections -fdata-sections -save-temps | ||
LDFLAGS += -Wl,--gc-sections,--relax | ||
|
||
OBJECTS = usi_i2c_master.o main.o | ||
|
||
COMPILE = avr-gcc -DF_CPU=$(F_CPU) $(CFLAGS) $(LDFLAGS) -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" | ||
|
||
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 -B 20.96 | ||
|
||
# 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 main.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: | ||
|
||
main.elf: $(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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
#include <avr/pgmspace.h> | ||
|
||
PROGMEM const unsigned int firmware[] = { | ||
0xC01D, 0xC037, 0xC079, 0xC035, 0xC034, 0xC033, 0xC032, 0xC031, | ||
0xC0A8, 0xC02F, 0xC02E, 0xC02D, 0xC02C, 0xC042, 0xC02A, 0xC029, | ||
0xC028, 0xC027, 0xC026, 0xC025, 0xC024, 0xC023, 0xC022, 0xC021, | ||
0xC020, 0xC01F, 0xC01E, 0xC01D, 0xC01C, 0xC1F9, 0x2411, 0xBE1F, | ||
0xEFCF, 0xE0D1, 0xBFDE, 0xBFCD, 0xE011, 0xE0A0, 0xE0B1, 0xEDE8, | ||
0xE0F5, 0xC002, 0x9005, 0x920D, 0x35AA, 0x07B1, 0xF7D9, 0xE011, | ||
0xE5AA, 0xE0B1, 0xC001, 0x921D, 0x38A8, 0x07B1, 0xF7E1, 0xD0AA, | ||
0xC2B1, 0xCFC6, 0xB78B, 0x7E8F, 0xBF8B, 0xBC1E, 0x9891, 0x9878, | ||
0xE081, 0x9380, 0x0100, 0x9508, 0xB785, 0x7E87, 0x6088, 0xBF85, | ||
0xB785, 0x6280, 0xBF85, 0x9588, 0xB785, 0x7D8F, 0xBF85, 0x9508, | ||
0x921F, 0x920F, 0xB60F, 0x920F, 0x2411, 0x900F, 0xBE0F, 0x900F, | ||
0x901F, 0x9518, 0xB989, 0x9A2E, 0xDFE7, 0xB186, 0xB197, 0x9508, | ||
0xE081, 0x9380, 0x0163, 0xE083, 0xDFF5, 0xD15D, 0x9210, 0x0163, | ||
0x01CB, 0x9508, 0x93CF, 0x93DF, 0xE081, 0x9380, 0x0162, 0xE085, | ||
0xDFE9, 0x01EC, 0xE087, 0xDFE6, 0x9210, 0x0162, 0x5F9C, 0x1B8C, | ||
0x0B9D, 0x91DF, 0x91CF, 0x9508, 0x921F, 0x920F, 0xB60F, 0x920F, | ||
0x2411, 0x932F, 0x933F, 0x934F, 0x935F, 0x936F, 0x937F, 0x938F, | ||
0x939F, 0x93AF, 0x93BF, 0x93EF, 0x93FF, 0xB78B, 0x7E8F, 0xBF8B, | ||
0xBC1E, 0xB58C, 0xB59D, 0x9390, 0x0161, 0x9380, 0x0160, 0x9180, | ||
0x0160, 0x9190, 0x0161, 0x9390, 0x015F, 0x9380, 0x015E, 0xDF9A, | ||
0x91FF, 0x91EF, 0x91BF, 0x91AF, 0x919F, 0x918F, 0x917F, 0x916F, | ||
0x915F, 0x914F, 0x913F, 0x912F, 0x900F, 0xBE0F, 0x900F, 0x901F, | ||
0x9518, 0x921F, 0x920F, 0xB60F, 0x920F, 0x2411, 0x932F, 0x933F, | ||
0x934F, 0x935F, 0x936F, 0x937F, 0x938F, 0x939F, 0x93AF, 0x93BF, | ||
0x93EF, 0x93FF, 0xEF8F, 0xEF9F, 0x9390, 0x0161, 0x9380, 0x0160, | ||
0x9180, 0x0160, 0x9190, 0x0161, 0x9390, 0x015F, 0x9380, 0x015E, | ||
0xDF69, 0x91FF, 0x91EF, 0x91BF, 0x91AF, 0x919F, 0x918F, 0x917F, | ||
0x916F, 0x915F, 0x914F, 0x913F, 0x912F, 0x900F, 0xBE0F, 0x900F, | ||
0x901F, 0x9518, 0x93CF, 0x93DF, 0x921F, 0xB7CD, 0xB7DE, 0xBE14, | ||
0xED88, 0x9380, 0x0071, 0xB581, 0x7F87, 0xBD81, 0xE081, 0xE090, | ||
0xD1E3, 0x2F18, 0xD1A3, 0x1181, 0xC001, 0xE210, 0xE78E, 0x9380, | ||
0x0070, 0xE880, 0xB98A, 0xB98C, 0xEA88, 0x9380, 0x0060, 0xB38A, | ||
0x6083, 0xBB8A, 0x98D8, 0x98D9, 0xE885, 0xB985, 0x9A2B, 0xB818, | ||
0x9478, 0x9AD8, 0xDF55, 0x9390, 0x015B, 0x9380, 0x015A, 0xDF5A, | ||
0x9390, 0x015D, 0x9380, 0x015C, 0xEF2F, 0xEE81, 0xE094, 0x5021, | ||
0x4080, 0x4090, 0xF7E1, 0xC000, 0x0000, 0x98D8, 0x2F81, 0xD0F0, | ||
0xE013, 0xD148, 0x2388, 0xF3E9, 0xD14E, 0x1181, 0xC00C, 0x9180, | ||
0x015D, 0xD15C, 0x9180, 0x015C, 0xD159, 0xDF3C, 0x9390, 0x015D, | ||
0x9380, 0x015C, 0xCFEE, 0x3081, 0xF459, 0xD13D, 0x2F68, 0x8369, | ||
0xD15D, 0x8169, 0x2388, 0xF329, 0xE081, 0xE090, 0xD19D, 0xCFE1, | ||
0x3082, 0xF421, 0xE081, 0xE090, 0xD18F, 0xC059, 0x3083, 0xF541, | ||
0x9190, 0x0100, 0x2399, 0xF2A9, 0x9190, 0x0070, 0x7F9B, 0x9390, | ||
0x0070, 0x9A78, 0xB39A, 0x6093, 0xBB9A, 0x98D9, 0x9AD8, 0x9AD9, | ||
0x98D8, 0xE8EF, 0xE0F1, 0x9731, 0xF7F1, 0xC000, 0x0000, 0x98D1, | ||
0xB39B, 0x7F9C, 0xBB9B, 0xBC1D, 0xBC1C, 0xBC1F, 0xBD8E, 0x9A91, | ||
0xB78B, 0x6180, 0xBF8B, 0x9210, 0x0100, 0xB785, 0x7E87, 0xC036, | ||
0x3084, 0xF4A1, 0xB78B, 0x7E8F, 0xBF8B, 0xBC1E, 0x9180, 0x0160, | ||
0x9190, 0x0161, 0x2F89, 0xD10A, 0x9180, 0x0160, 0x9190, 0x0161, | ||
0xD105, 0xB78B, 0x6180, 0xBF8B, 0xBD1E, 0xCF9B, 0x3085, 0xF461, | ||
0x9180, 0x015B, 0xD0FB, 0x9180, 0x015A, 0xD0F8, 0xDED1, 0x9390, | ||
0x015B, 0x9380, 0x015A, 0xCF8D, 0x3086, 0xF431, 0xED88, 0x9380, | ||
0x0071, 0xE088, 0xBD81, 0xCFFF, 0x3087, 0xF419, 0xE283, 0xD0E6, | ||
0xCF80, 0x3088, 0xF461, 0xB785, 0x7E87, 0x6180, 0xBF85, 0xB785, | ||
0x6280, 0xBF85, 0x9588, 0xB785, 0x7D8F, 0xBF85, 0xCF72, 0x3089, | ||
0xF009, 0xCF6F, 0x9180, 0x0162, 0x1181, 0xC00B, 0x9180, 0x0163, | ||
0x1181, 0xC007, 0x9190, 0x0100, 0xE081, 0x2399, 0xF301, 0xE080, | ||
0xCFDE, 0xE081, 0xCFDC, 0x93CF, 0x93DF, 0x378C, 0xE023, 0x0792, | ||
0xF5D8, 0x3882, 0x0591, 0xF1E8, 0xE0A1, 0xE0B1, 0xE0E0, 0x9612, | ||
0x912D, 0x913C, 0x9713, 0x1782, 0x0793, 0xF02C, 0x5FEF, 0x9614, | ||
0x31E6, 0xF7A9, 0xE1E5, 0xE0F0, 0x01DF, 0x0FAA, 0x1FBB, 0x0FAA, | ||
0x1FBB, 0x50A3, 0x4FBF, 0x9612, 0x91CD, 0x91DC, 0x9713, 0x912D, | ||
0x913C, 0x0FEE, 0x1FFF, 0x0FEE, 0x1FFF, 0x5FEF, 0x4FFE, 0x8140, | ||
0x8151, 0x01BC, 0x1B6C, 0x0B7D, 0x01CA, 0x1B82, 0x0B93, 0xD0A4, | ||
0x8162, 0x8173, 0x1B6C, 0x0B7D, 0xD0B0, 0x0F62, 0x1F73, 0x2788, | ||
0xFD77, 0x9580, 0x2F98, 0xC009, 0xE368, 0xEF7F, 0xEF8F, 0xEF9F, | ||
0xC004, 0xE562, 0xE073, 0xE080, 0xE090, 0x91DF, 0x91CF, 0x9508, | ||
0x0F88, 0x9380, 0x00A2, 0xEB8C, 0x9380, 0x00A5, 0x9508, 0x921F, | ||
0x920F, 0xB60F, 0x920F, 0x2411, 0x938F, 0x939F, 0x93EF, 0x93FF, | ||
0x9180, 0x00A3, 0xFF87, 0xC030, 0x9180, 0x00A3, 0xFF81, 0xC018, | ||
0x9190, 0x0165, 0x9180, 0x0164, 0x1798, 0xF069, 0x9180, 0x0164, | ||
0x5F8F, 0x708F, 0x9380, 0x0164, 0x91E0, 0x0164, 0xE0F0, 0x59EA, | ||
0x4FFE, 0x8180, 0xC001, 0xEF8F, 0x9380, 0x00A0, 0xE083, 0xC01F, | ||
0x9180, 0x00A4, 0x6083, 0x9380, 0x00A4, 0x9180, 0x0177, 0x5F8F, | ||
0x708F, 0x9380, 0x0177, 0x91E0, 0x0177, 0x9180, 0x00A0, 0xE0F0, | ||
0x58E8, 0x4FFE, 0x8380, 0xC00D, 0xFF86, 0xC00B, 0x9180, 0x00A3, | ||
0xFD83, 0xC004, 0x9180, 0x00A3, 0xFD80, 0xCFE0, 0xE082, 0x9380, | ||
0x00A4, 0x91FF, 0x91EF, 0x919F, 0x918F, 0x900F, 0xBE0F, 0x900F, | ||
0x901F, 0x9518, 0x9120, 0x0177, 0x9190, 0x0176, 0xE081, 0x1329, | ||
0xC001, 0xE080, 0x9508, 0x9190, 0x0177, 0x9180, 0x0176, 0x1798, | ||
0xF3D1, 0x9180, 0x0176, 0x5F8F, 0x708F, 0x9380, 0x0176, 0x91E0, | ||
0x0176, 0xE0F0, 0x58E8, 0x4FFE, 0x8180, 0x9508, 0x9190, 0x0165, | ||
0x5F9F, 0x709F, 0x9120, 0x0164, 0x1792, 0xF3E1, 0x2FE9, 0xE0F0, | ||
0x59EA, 0x4FFE, 0x8380, 0x9390, 0x0165, 0x9508, 0xE091, 0x1618, | ||
0xF00C, 0xE090, 0x2F89, 0x9508, 0x2400, 0x2755, 0xC004, 0x0E08, | ||
0x1F59, 0x0F88, 0x1F99, 0x9700, 0xF029, 0x9576, 0x9567, 0xF3B8, | ||
0x0571, 0xF7B9, 0x2D80, 0x2F95, 0x9508, 0xFB97, 0x2E07, 0xF416, | ||
0x9400, 0xD006, 0xFD77, 0xD008, 0xD00B, 0xFC07, 0xD005, 0xF43E, | ||
0x9590, 0x9581, 0x4F9F, 0x9508, 0x9570, 0x9561, 0x4F7F, 0x9508, | ||
0x1BAA, 0x1BBB, 0xE151, 0xC007, 0x1FAA, 0x1FBB, 0x17A6, 0x07B7, | ||
0xF010, 0x1BA6, 0x0BB7, 0x1F88, 0x1F99, 0x955A, 0xF7A9, 0x9580, | ||
0x9590, 0x01BC, 0x01CD, 0x9508, 0x99E1, 0xCFFE, 0xBA1F, 0xBB8E, | ||
0x9AE0, 0x2799, 0xB38D, 0x9508, 0x2F26, 0x99E1, 0xCFFE, 0xBA1C, | ||
0xBA1F, 0xBB8E, 0xBB2D, 0xB60F, 0x94F8, 0x9AE2, 0x9AE1, 0xBE0F, | ||
0x9601, 0x9508, 0x94F8, 0xCFFF, | ||
0x5201, 0x8103, 0x2000, 0x9203, 0xEE00, 0xA502, 0xBC00, 0xBA02, | ||
0x8A00, 0xD202, 0x5800, 0xEC02, 0x2600, 0x0B02, 0xF401, 0x2C01, | ||
0xC201, 0x5101, 0x9001, 0x7801, 0x5E01, 0xA301, 0x2C01, 0xD001, | ||
0xC801, 0x2F00, 0xFA02, 0xFF00, 0x9601, 0x6000, 0x6402, 0x9000, | ||
0x3202, 0xBF00, 0x0002, 0xEC00, 0xCE02, 0x15FF, 0x9C03, 0x3CFF, | ||
0x6A03, 0x5EFF, 0x3803, 0x7CFF, 0x0003, | ||
|
||
}; | ||
#define FIRMWARE_WORD_COUNT 793 |
Oops, something went wrong.