From d7bda89e596d43e5a9920269612f992e92d5ada3 Mon Sep 17 00:00:00 2001 From: Michael Gernoth Date: Sun, 22 Aug 2010 12:10:14 +0200 Subject: [PATCH 1/1] first bits for AVR BMC firmware --- bmc/Makefile | 26 ++++++++++++++++++++++++++ bmc/bmc.c | 24 ++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 bmc/Makefile create mode 100644 bmc/bmc.c diff --git a/bmc/Makefile b/bmc/Makefile new file mode 100644 index 0000000..85ecb0b --- /dev/null +++ b/bmc/Makefile @@ -0,0 +1,26 @@ +CC=avr-gcc +CFLAGS=-mmcu=atmega16 -g +OBJCOPY=avr-objcopy +PROG=dragon_jtag +PORT=usb +PMCU=m16 + +all: bmc.bin + +bmc: bmc.o + +bmc.bin: bmc + $(OBJCOPY) -j .text -j .data -O binary $^ $@ + +flash: bmc.bin + avrdude -v -c $(PROG) -P $(PORT) -p $(PMCU) -U flash:w:$^ + +debug: bmc bmc.bin + setsid avarice -g -D :4242 + -avr-gdb -ex 'target remote localhost:4242' bmc + -pkill avarice + +clean: + -rm -f *.o bmc bmc.bin + +.PHONY: all clean flash debug diff --git a/bmc/bmc.c b/bmc/bmc.c new file mode 100644 index 0000000..06a3829 --- /dev/null +++ b/bmc/bmc.c @@ -0,0 +1,24 @@ +#define F_CPU 1000000UL + +#include + +int main(void) +{ + uint8_t pb = 0x00; + int8_t dir = 1; + volatile uint16_t i; + + DDRB = 0xff; + + while(1) { + pb += dir; + PORTB = pb; + + for (i = 0; i < (pb<<5); i++) {} + + if ((pb == 0) || (pb == 0xff)) + dir = -dir; + } + + return 0; +} -- 2.39.5