Initial commit.

This commit is contained in:
redxef 2022-07-12 20:14:59 +02:00
commit 67debd24e3
Signed by: redxef
GPG key ID: 7DAC3AA211CBD921
4 changed files with 51 additions and 0 deletions

5
.gitignore vendored Normal file
View file

@ -0,0 +1,5 @@
.cache/
*.hex
*.elf
*.o
compile_commands.json

32
Makefile Normal file
View file

@ -0,0 +1,32 @@
PREFIX := avr-
CFLAGS_COMMON := -I/usr/avr/include/
CFLAGS_CPU := -DF_CPU=20000000UL -mmcu=atmega328p -Os
CFLAGS := $(CFLAGS_COMMON) $(CFLAGS_CPU)
LDFLAGS_COMMON := -I/usr/avr/include/
LDFLAGS_CPU := -mmcu=atmega328p
LDFLAGS := $(LDFLAGS_COMMON) $(LDFLAGS_CPU)
CC := $(PREFIX)gcc
build: main.hex
flash: main.hex
sudo avrdude -FV -c arduino -p ATmega328p -P /dev/ttyUSB0 -b 57600 -U flash:w:$<
clean:
$(RM) *.hex *.elf *.o
bear: compile_commands.json
compile_commands.json: clean
bear -- make build
main.hex: main.elf
$(PREFIX)objcopy -O ihex -R .eeprom $< $@
main.elf: main.o
$(CC) -w $(LDFLAGS) -o $@ $<
%.o: %.c %.h
$(CC) $(CFLAGS) -c -o $@ $<
.PHONY: build flash clean bear

14
main.c Normal file
View file

@ -0,0 +1,14 @@
#include <avr/io.h>
#include <util/delay.h>
int main(void) {
DDRD = 255;
while (1) {
PORTD = 0b00001000;
_delay_ms(100);
PORTD = 0;
_delay_ms(100);
}
return 0;
}

0
main.h Normal file
View file