diff --git a/sw/in_progress/blitzer/Makefile b/sw/in_progress/blitzer/Makefile new file mode 100644 index 0000000000..a21164bf95 --- /dev/null +++ b/sw/in_progress/blitzer/Makefile @@ -0,0 +1,56 @@ + +MCU = attiny45 + +PROG = dragon_isp +DEV = usb +#PROG = stk200 +#DEV = /dev/parport0 + +APPNAME = blitzer + +CC = avr-gcc +OBJCOPY = avr-objcopy +RM = rm + +CFLAGS = -Wall -g -mmcu=$(MCU) -Os -fpack-struct -fshort-enums -Wall -Wstrict-prototypes + +SOURCES = blitzer.c + +all: $(APPNAME) + +clean: + $(RM) -f core $(APPNAME).o $(APPNAME) $(APPNAME).elf $(APPNAME).hex + +app: $(APPNAME) + +$(APPNAME): $(SOURCES) Makefile + $(CC) $(CFLAGS) $(SOURCES) -o $(APPNAME).elf + $(OBJCOPY) -O ihex -R .eeprom $(APPNAME).elf $(APPNAME).hex + +flash: $(APPNAME) + avrdude -c $(PROG) -P $(DEV) -p $(MCU) -B 10 -U flash:w:$(APPNAME).hex + +flash_fuses: + avrdude -c $(PROG) -P $(DEV) -p $(MCU) -B 10 -U hfuse:w:0xdf:m + sleep 2 + avrdude -c $(PROG) -P $(DEV) -p $(MCU) -B 10 -U lfuse:w:0x62:m + +# (this is the default on new chips) +# +# Fuse high byte: +# 0xdf = 1 1 0 1 1 1 1 1 <-- BODLEVEL0 (Brown out trigger level bit 0) +# ^ ^ ^ ^ ^ ^ ^------ BODLEVEL1 (Brown out trigger level bit 1) +# | | | | | +-------- BODLEVEL2 (Brown out trigger level bit 2) +# | | | | + --------- EESAVE (don't preserve EEPROM over chip erase) +# | | | +-------------- WDTON (WDT not always on) +# | | +---------------- SPIEN (allow serial programming) +# | +------------------ DWEN (debug wire is enabled) +# +-------------------- RSTDISBL (reset pin is enabled) +# Fuse low byte: +# 0x62 = 0 1 1 0 0 0 1 0 +# ^ ^ \ / \--+--/ +# | | | +------- CKSEL 3..0 (internal calibrated osc) +# | | +--------------- SUT 1..0 (slowly rising power) +# | +------------------ CKOUT (clock output disabled) +# +-------------------- CKDIV8 (divide clock by eight enabled) + diff --git a/sw/in_progress/blitzer/blitzer.c b/sw/in_progress/blitzer/blitzer.c new file mode 100644 index 0000000000..c007eaac21 --- /dev/null +++ b/sw/in_progress/blitzer/blitzer.c @@ -0,0 +1,65 @@ +/* + * $Id$ + * + * Copyright (C) 2009 Martin Mueller + * + * This file is part of paparazzi. + * + * paparazzi is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * paparazzi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with paparazzi; see the file COPYING. If not, write to + * the Free Software Foundation, 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + */ + +/** \file blitzer.c + * \brief LED flasher + * + * Flashes a LED connected to PB1 (pin 6) of an ATTINY45 through + * an IRML2502 transistor, PB1 low -> LED off. + * + * fuse high byte: 0xdf, fuse low byte: 0x62 + * + */ + +#include + +void wait(int msec_time) +{ + volatile unsigned short cnta, cntb; + + /* roughly based on internal oscillator with divider by 8 enabled */ + for (cnta = 0; cnta < msec_time; cnta++) { + for (cntb = 0; cntb < 38;cntb++) cntb=cntb; + } +} + +int main(void) +{ + DDRB |= (1 << PB1); // PB1 output + DDRB &= ~(1 << PB0); // PB0 input + + while (1) + { + PORTB |= (1 << PB1); + wait(25); + PORTB &= ~(1 << PB1); + wait(110); + PORTB |= (1 << PB1); + wait(25); + PORTB &= ~(1 << PB1); + wait(780); + } + + return(0); +}