initial thingies

This commit is contained in:
Lea 2023-08-25 09:33:25 +02:00
commit 4ad293bd35
Signed by: Lea
GPG key ID: 1BAFFE8347019C42
3 changed files with 94 additions and 0 deletions

32
.vscode/c_cpp_properties.json vendored Normal file
View file

@ -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
}

46
Makefile Normal file
View file

@ -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

16
main.c Normal file
View file

@ -0,0 +1,16 @@
#define __AVR_ATmega2560__
#define F_CPU 16000000UL
#include <avr/io.h>
#include <util/delay.h>
void main() {
DDRB = 0b10000000;
while(1) {
PORTB = 0b10000000;
_delay_ms(500);
PORTB = 0b00000000;
_delay_ms(500);
}
}