commit 4ad293bd358162b6a26344d84478c76fdadbdf3c Author: Lea Date: Fri Aug 25 09:33:25 2023 +0200 initial thingies diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..26a98d3 --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,32 @@ +{ + "configurations": [ + { + "includePath": [ + "/usr/avr/include" + ], + "intelliSenseMode": "linux-gcc-x64", + "compilerPath": "/usr/lib64/ccache/clang", + "cStandard": "c17", + "cppStandard": "c++17" + }, + { + "name": "AVR", + "intelliSenseMode": "${default}", + "compilerPath": "", + "cStandard": "${default}", + "cppStandard": "${default}", + "includePath": [], + "compilerArgs": [ + "-g", + "-Os", + "-Wall", + "-Wextra", + "-fpermissive", + "-fno-exceptions", + "-fno-threadsafe-statics", + "-pipe" + ] + } + ], + "version": 4 +} \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..ee81501 --- /dev/null +++ b/Makefile @@ -0,0 +1,46 @@ +TARGET=main +MCU=atmega2560 +SOURCES=main.c + +PORT=/dev/ttyACM0 +BAUD=115200 + +OBJECTS=$(SOURCES:.c=.o) +CFLAGS=-c -Os +LDFLAGS= + +LIB=-L/usr/avr/lib +INC=-I/usr/avr/include + +yeet: hex eeprom program clean + +hex: $(TARGET).hex + +eeprom: $(TARGET)_eeprom.hex + +$(TARGET).hex: $(TARGET).elf + avr-objcopy -O ihex -j .data -j .text $(TARGET).elf $(TARGET).hex + +$(TARGET)_eeprom.hex: $(TARGET).elf + avr-objcopy -O ihex -j .eeprom --change-section-lma .eeprom=1 $(TARGET).elf $(TARGET)_eeprom.hex + +$(TARGET).elf: $(OBJECTS) + avr-gcc $(LDFLAGS) $(INC) $(LIB) -mmcu=$(MCU) $(OBJECTS) -o $(TARGET).elf + +.c.o: + avr-gcc $(CFLAGS) $(INC) $(LIB) -mmcu=$(MCU) $< -o $@ + +size: + avr-size --mcu=$(MCU) -C $(TARGET).elf + +program: + avrdude -p$(MCU) -P$(PORT) -b$(BAUD) -v -V -cwiring -D "-Uflash:w:$(TARGET).hex:i" + +clean_tmp: + rm -rf *.o + rm -rf *.elf + +clean: + rm -rf *.o + rm -rf *.elf + rm -rf *.hex diff --git a/main.c b/main.c new file mode 100644 index 0000000..76aa668 --- /dev/null +++ b/main.c @@ -0,0 +1,16 @@ +#define __AVR_ATmega2560__ +#define F_CPU 16000000UL + +#include +#include + +void main() { + DDRB = 0b10000000; + + while(1) { + PORTB = 0b10000000; + _delay_ms(500); + PORTB = 0b00000000; + _delay_ms(500); + } +}