From 7346cfaad4d969db060f3c7ae242ea93f4fff5c0 Mon Sep 17 00:00:00 2001 From: VG Date: Wed, 26 Aug 2015 18:45:01 +0200 Subject: first commit --- avr-blinkled-atmega328p/Makefile | 35 +++++++++++++++++++++++++++++++++++ avr-blinkled-atmega328p/main.c | 17 +++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 avr-blinkled-atmega328p/Makefile create mode 100644 avr-blinkled-atmega328p/main.c (limited to 'avr-blinkled-atmega328p') diff --git a/avr-blinkled-atmega328p/Makefile b/avr-blinkled-atmega328p/Makefile new file mode 100644 index 0000000..864e2ec --- /dev/null +++ b/avr-blinkled-atmega328p/Makefile @@ -0,0 +1,35 @@ +# settings for arduino uno +DEVICE = atmega328p +CLOCK = 16000000 + +# buspirate programmer +PORT=/dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A400XJSH-if00-port0 +AVRDUDE=avrdude -p $(DEVICE) -c buspirate -P $(PORT) + +DEFS = -DF_CPU=$(CLOCK)UL +LIBS = -Wl,--relax,--gc-sections,--print-gc-sections,--entry=main +LIBS = -Wl,--entry=main,--gc-sections,--rela +CFLAGS = -Wall -Werror -pedantic -std=c99 +CFLAGS += -Os -funsigned-bitfields -fpack-struct -fshort-enums +CFLAGS += -mmcu=$(DEVICE) $(DEFS) +#LDFLAGS = $(LIBS) + +all: main.hex size + +main.hex: main.c + avr-gcc -o main.elf $? $(CFLAGS) $(LDFLAGS) + avr-objcopy -j .text -j .data -O ihex main.elf main.hex + +f: flash +flash: all + $(AVRDUDE) -U flash:w:main.hex:i + +clean: + rm -f *.o *.elf *.hex + +size: + avr-size --mcu=$(DEVICE) -t -A main.elf + avr-size --mcu=$(DEVICE) -C main.elf + avr-nm --size-sort main.elf + + diff --git a/avr-blinkled-atmega328p/main.c b/avr-blinkled-atmega328p/main.c new file mode 100644 index 0000000..8d9e288 --- /dev/null +++ b/avr-blinkled-atmega328p/main.c @@ -0,0 +1,17 @@ +#include +#include + +int main(void) +{ + /* PB4 output */ + DDRD |= _BV(PB4); + PORTB &= ~_BV(PB4); + + for (;;) + { + _delay_ms(1000); + PORTB ^= _BV(PB4); + } + + return 0; +} -- cgit v1.2.3