diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..69ae0f2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.hex +*.elf diff --git a/final_project/Makefile b/final_project/Makefile new file mode 100644 index 0000000..362cb30 --- /dev/null +++ b/final_project/Makefile @@ -0,0 +1,79 @@ +# Stolen from github +# +# Name: Makefile +# Author: +# Copyright: +# License: + +# DEVICE ....... The AVR device you compile for +# CLOCK ........ Target AVR clock rate in Hertz +# OBJECTS ...... The object files created from your source files. This list is +# usually the same as the list of source files with suffix ".o". +# PROGRAMMER ... Options to avrdude which define the hardware you use for +# uploading to the AVR and the interface where this hardware +# is connected. +# FUSES ........ Parameters for avrdude to flash the fuses appropriately. + +DEVICE = attiny2313 +CLOCK = 8000000 +PROGRAMMER = -c arduino -P /dev/tty.usb* -b 19200 +OBJECTS = main.o thing.o +FUSES = -U lfuse:w:0x64:m -U hfuse:w:0xdd:m -U efuse:w:0xff:m +BUILD_DIR = _build + + +###################################################################### +###################################################################### + +# Tune the lines below only if you know what you are doing: + +AVRDUDE = avrdude $(PROGRAMMER) -p $(DEVICE) +COMPILE = avr-gcc -Wall -Os -DF_CPU=$(CLOCK) -mmcu=$(DEVICE) + +# symbolic targets: +all: main.hex + +.c.o: + $(COMPILE) -c $< -o $@ + +.S.o: + $(COMPILE) -x assembler-with-cpp -c $< -o $@ +# "-x assembler-with-cpp" should not be necessary since this is the default +# file type for the .S (with capital S) extension. However, upper case +# characters are not always preserved on Windows. To ensure WinAVR +# compatibility define the file type manually. + +.c.s: + $(COMPILE) -S $< -o $@ + +flash: all + $(AVRDUDE) -U flash:w:main.hex:i + +fuse: + $(AVRDUDE) $(FUSES) + +install: flash fuse + +# if you use a bootloader, change the command below appropriately: +load: all + bootloadHID main.hex + +clean: + rm -f main.hex main.elf $(OBJECTS) + +# file targets: +main.elf: $(OBJECTS) + $(COMPILE) -o main.elf $(OBJECTS) + +main.hex: main.elf + rm -f main.hex $(OBJECTS) + avr-objcopy -j .text -j .data -O ihex main.elf main.hex +# If you have an EEPROM section, you must also create a hex file for the +# EEPROM and add it to the "flash" target. + +# Targets for code debugging and analysis: +disasm: main.elf + avr-objdump -d main.elf + +cpp: + $(COMPILE) -E main.c diff --git a/final_project/main.c b/final_project/main.c new file mode 100644 index 0000000..fb3e1e6 --- /dev/null +++ b/final_project/main.c @@ -0,0 +1,16 @@ +#include + +// Set up GPIO here +void pin_setup() { + +} + + +int main() { + pin_setup() + + while (1) { + + } + +} diff --git a/lab_1/Makefile b/lab_1/Makefile new file mode 100644 index 0000000..362cb30 --- /dev/null +++ b/lab_1/Makefile @@ -0,0 +1,79 @@ +# Stolen from github +# +# Name: Makefile +# Author: +# Copyright: +# License: + +# DEVICE ....... The AVR device you compile for +# CLOCK ........ Target AVR clock rate in Hertz +# OBJECTS ...... The object files created from your source files. This list is +# usually the same as the list of source files with suffix ".o". +# PROGRAMMER ... Options to avrdude which define the hardware you use for +# uploading to the AVR and the interface where this hardware +# is connected. +# FUSES ........ Parameters for avrdude to flash the fuses appropriately. + +DEVICE = attiny2313 +CLOCK = 8000000 +PROGRAMMER = -c arduino -P /dev/tty.usb* -b 19200 +OBJECTS = main.o thing.o +FUSES = -U lfuse:w:0x64:m -U hfuse:w:0xdd:m -U efuse:w:0xff:m +BUILD_DIR = _build + + +###################################################################### +###################################################################### + +# Tune the lines below only if you know what you are doing: + +AVRDUDE = avrdude $(PROGRAMMER) -p $(DEVICE) +COMPILE = avr-gcc -Wall -Os -DF_CPU=$(CLOCK) -mmcu=$(DEVICE) + +# symbolic targets: +all: main.hex + +.c.o: + $(COMPILE) -c $< -o $@ + +.S.o: + $(COMPILE) -x assembler-with-cpp -c $< -o $@ +# "-x assembler-with-cpp" should not be necessary since this is the default +# file type for the .S (with capital S) extension. However, upper case +# characters are not always preserved on Windows. To ensure WinAVR +# compatibility define the file type manually. + +.c.s: + $(COMPILE) -S $< -o $@ + +flash: all + $(AVRDUDE) -U flash:w:main.hex:i + +fuse: + $(AVRDUDE) $(FUSES) + +install: flash fuse + +# if you use a bootloader, change the command below appropriately: +load: all + bootloadHID main.hex + +clean: + rm -f main.hex main.elf $(OBJECTS) + +# file targets: +main.elf: $(OBJECTS) + $(COMPILE) -o main.elf $(OBJECTS) + +main.hex: main.elf + rm -f main.hex $(OBJECTS) + avr-objcopy -j .text -j .data -O ihex main.elf main.hex +# If you have an EEPROM section, you must also create a hex file for the +# EEPROM and add it to the "flash" target. + +# Targets for code debugging and analysis: +disasm: main.elf + avr-objdump -d main.elf + +cpp: + $(COMPILE) -E main.c diff --git a/lab_1/main.c b/lab_1/main.c new file mode 100644 index 0000000..fb3e1e6 --- /dev/null +++ b/lab_1/main.c @@ -0,0 +1,16 @@ +#include + +// Set up GPIO here +void pin_setup() { + +} + + +int main() { + pin_setup() + + while (1) { + + } + +} diff --git a/lab_2/main.c b/lab_2/main.c new file mode 100644 index 0000000..fb3e1e6 --- /dev/null +++ b/lab_2/main.c @@ -0,0 +1,16 @@ +#include + +// Set up GPIO here +void pin_setup() { + +} + + +int main() { + pin_setup() + + while (1) { + + } + +} diff --git a/lab_3/Makefile b/lab_3/Makefile new file mode 100644 index 0000000..362cb30 --- /dev/null +++ b/lab_3/Makefile @@ -0,0 +1,79 @@ +# Stolen from github +# +# Name: Makefile +# Author: +# Copyright: +# License: + +# DEVICE ....... The AVR device you compile for +# CLOCK ........ Target AVR clock rate in Hertz +# OBJECTS ...... The object files created from your source files. This list is +# usually the same as the list of source files with suffix ".o". +# PROGRAMMER ... Options to avrdude which define the hardware you use for +# uploading to the AVR and the interface where this hardware +# is connected. +# FUSES ........ Parameters for avrdude to flash the fuses appropriately. + +DEVICE = attiny2313 +CLOCK = 8000000 +PROGRAMMER = -c arduino -P /dev/tty.usb* -b 19200 +OBJECTS = main.o thing.o +FUSES = -U lfuse:w:0x64:m -U hfuse:w:0xdd:m -U efuse:w:0xff:m +BUILD_DIR = _build + + +###################################################################### +###################################################################### + +# Tune the lines below only if you know what you are doing: + +AVRDUDE = avrdude $(PROGRAMMER) -p $(DEVICE) +COMPILE = avr-gcc -Wall -Os -DF_CPU=$(CLOCK) -mmcu=$(DEVICE) + +# symbolic targets: +all: main.hex + +.c.o: + $(COMPILE) -c $< -o $@ + +.S.o: + $(COMPILE) -x assembler-with-cpp -c $< -o $@ +# "-x assembler-with-cpp" should not be necessary since this is the default +# file type for the .S (with capital S) extension. However, upper case +# characters are not always preserved on Windows. To ensure WinAVR +# compatibility define the file type manually. + +.c.s: + $(COMPILE) -S $< -o $@ + +flash: all + $(AVRDUDE) -U flash:w:main.hex:i + +fuse: + $(AVRDUDE) $(FUSES) + +install: flash fuse + +# if you use a bootloader, change the command below appropriately: +load: all + bootloadHID main.hex + +clean: + rm -f main.hex main.elf $(OBJECTS) + +# file targets: +main.elf: $(OBJECTS) + $(COMPILE) -o main.elf $(OBJECTS) + +main.hex: main.elf + rm -f main.hex $(OBJECTS) + avr-objcopy -j .text -j .data -O ihex main.elf main.hex +# If you have an EEPROM section, you must also create a hex file for the +# EEPROM and add it to the "flash" target. + +# Targets for code debugging and analysis: +disasm: main.elf + avr-objdump -d main.elf + +cpp: + $(COMPILE) -E main.c diff --git a/lab_3/main.c b/lab_3/main.c new file mode 100644 index 0000000..fb3e1e6 --- /dev/null +++ b/lab_3/main.c @@ -0,0 +1,16 @@ +#include + +// Set up GPIO here +void pin_setup() { + +} + + +int main() { + pin_setup() + + while (1) { + + } + +} diff --git a/lab_4/Makefile b/lab_4/Makefile new file mode 100644 index 0000000..362cb30 --- /dev/null +++ b/lab_4/Makefile @@ -0,0 +1,79 @@ +# Stolen from github +# +# Name: Makefile +# Author: +# Copyright: +# License: + +# DEVICE ....... The AVR device you compile for +# CLOCK ........ Target AVR clock rate in Hertz +# OBJECTS ...... The object files created from your source files. This list is +# usually the same as the list of source files with suffix ".o". +# PROGRAMMER ... Options to avrdude which define the hardware you use for +# uploading to the AVR and the interface where this hardware +# is connected. +# FUSES ........ Parameters for avrdude to flash the fuses appropriately. + +DEVICE = attiny2313 +CLOCK = 8000000 +PROGRAMMER = -c arduino -P /dev/tty.usb* -b 19200 +OBJECTS = main.o thing.o +FUSES = -U lfuse:w:0x64:m -U hfuse:w:0xdd:m -U efuse:w:0xff:m +BUILD_DIR = _build + + +###################################################################### +###################################################################### + +# Tune the lines below only if you know what you are doing: + +AVRDUDE = avrdude $(PROGRAMMER) -p $(DEVICE) +COMPILE = avr-gcc -Wall -Os -DF_CPU=$(CLOCK) -mmcu=$(DEVICE) + +# symbolic targets: +all: main.hex + +.c.o: + $(COMPILE) -c $< -o $@ + +.S.o: + $(COMPILE) -x assembler-with-cpp -c $< -o $@ +# "-x assembler-with-cpp" should not be necessary since this is the default +# file type for the .S (with capital S) extension. However, upper case +# characters are not always preserved on Windows. To ensure WinAVR +# compatibility define the file type manually. + +.c.s: + $(COMPILE) -S $< -o $@ + +flash: all + $(AVRDUDE) -U flash:w:main.hex:i + +fuse: + $(AVRDUDE) $(FUSES) + +install: flash fuse + +# if you use a bootloader, change the command below appropriately: +load: all + bootloadHID main.hex + +clean: + rm -f main.hex main.elf $(OBJECTS) + +# file targets: +main.elf: $(OBJECTS) + $(COMPILE) -o main.elf $(OBJECTS) + +main.hex: main.elf + rm -f main.hex $(OBJECTS) + avr-objcopy -j .text -j .data -O ihex main.elf main.hex +# If you have an EEPROM section, you must also create a hex file for the +# EEPROM and add it to the "flash" target. + +# Targets for code debugging and analysis: +disasm: main.elf + avr-objdump -d main.elf + +cpp: + $(COMPILE) -E main.c diff --git a/lab_4/main.c b/lab_4/main.c new file mode 100644 index 0000000..fb3e1e6 --- /dev/null +++ b/lab_4/main.c @@ -0,0 +1,16 @@ +#include + +// Set up GPIO here +void pin_setup() { + +} + + +int main() { + pin_setup() + + while (1) { + + } + +} diff --git a/main.c b/main.c index 6dd3802..fb3e1e6 100644 --- a/main.c +++ b/main.c @@ -1,5 +1,16 @@ #include -int main() { - // do nothing +// Set up GPIO here +void pin_setup() { + +} + + +int main() { + pin_setup() + + while (1) { + + } + } diff --git a/main.elf b/main.elf deleted file mode 100755 index 7223aa0..0000000 Binary files a/main.elf and /dev/null differ diff --git a/main.hex b/main.hex deleted file mode 100644 index 1b938cc..0000000 --- a/main.hex +++ /dev/null @@ -1,5 +0,0 @@ -:1000000012C017C016C015C014C013C012C011C052 -:1000100010C00FC00EC00DC00CC00BC00AC009C07C -:1000200008C007C006C011241FBECFEDCDBF03D04E -:1000300005C0E6CF089580E090E00895F894FFCFE2 -:00000001FF diff --git a/thing.c b/thing.c deleted file mode 100644 index c85a152..0000000 --- a/thing.c +++ /dev/null @@ -1,3 +0,0 @@ -int thingie() { - -} diff --git a/thing.mk b/thing.mk deleted file mode 100644 index f84ccc3..0000000 --- a/thing.mk +++ /dev/null @@ -1,189 +0,0 @@ -###### -# Makefile based on STM32Cube auto-generated makefile -# -# TODO: -# - clean up, maybe optimize builds more -# - add windows support -# - add *proper* retargeting (this is mostly restructuring some files and adding make variables) -# -# Mediocre stuff about how I'm doing this: -# - First build times are loooooong. make -j4 will help, but we're still compiling lots we do't need. -# This is mostly because I don't want people to have to specifiy which source files they need. - -#################### -# Common directories -# -# These variables need to be defined in your makefile: -# TARGET - the name of your project -# COMMON_DIR - the common/ folder, where everything not for a specific project is held -# PROJ_DIR - Location of the current project -# MCU_SERIES - f0, f3, etc... the series for STM32 you are using -# MCU_PARTNO - Full partno you are using, in the HAL style, e.g. STM32F303xC -# -# SOURCE_DIRS - project specific sources, can be empty -# LDSCRIPT - The locaton of your linker script. -# -# -# CPU, see example makefile -# FPU, see example makefile -# FLOAT-ABI - see example makefile -# - -TARGET = testing - -PROJ_DIR := ./ -SOURCE_DIRS := - -SOURCE_DIRS += \ - $(PROJ_DIR)/src \ - - -# Find C sources: -C_SOURCES := $(shell find $(SOURCE_DIRS) -maxdepth 1 ! -name "*template.c" -name "*.c") -# DSDL compiled sources need to be treated differently -C_SOURCES += $(shell find $(CANARD_DSDL_COMPILED_DIR) -name "*.c") - -# Find C++ sources -CPP_SOURCES := $(shell find $(SOURCE_DIRS) -maxdepth 1 -name "*.cpp") - -ASM_SOURCES := - - -############## -# Build tools -############## -PREFIX = avr- -# The gcc compiler bin path can be either defined in make command via GCC_PATH variable (> make GCC_PATH=xxx) -# either it can be added to the PATH environment variable. -ifdef GCC_PATH -CC = $(GCC_PATH)/$(PREFIX)gcc$(POSTFIX) -CXX = $(GCC_PATH)/$(PREFIX)g++$(POSTFIX) -AS = $(GCC_PATH)/$(PREFIX)gcc -x assembler-with-cpp$(POSTFIX) -CP = $(GCC_PATH)/$(PREFIX)objcopy$(POSTFIX) -SZ = $(GCC_PATH)/$(PREFIX)size$(POSTFIX) -else -CC = $(PREFIX)gcc$(POSTFIX) -CXX = $(PREFIX)g++$(POSTFIX) -AS = $(PREFIX)gcc -x assembler-with-cpp$(POSTFIX) -CP = $(PREFIX)objcopy$(POSTFIX) -SZ = $(PREFIX)size$(POSTFIX) -endif -HEX = $(CP) -O ihex -BIN = $(CP) -O binary -S - - -# mcu -MCU = atmega168 - - -# Definitions to be called when compiling -AS_DEFS := - -# Common to C and C++ -C_DEFS := \ - -# Includes for compiling -AS_INCLUDES := - -# Common to C and C++ -C_INCLUDES := \ - -# compile gcc flags -ASFLAGS = -mmcu=$(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections - -CFLAGS = -mmcu=$(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -std=gnu99 -CXXFLAGS = -mmcu=$(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections - -ifeq ($(DEBUG), 1) -CFLAGS += -g -CXXFLAGS += -g -endif - - -# Generate dependency information -# As far as I understand, this makes it so you can recompile correctly when header files change -CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)" -CXXFLAGS += -MMD -MP -MF"$(@:%.o=%.d)" - - -################# -# Building! -################# -BUILD_DIR := $(PROJ_DIR)/build - -# default action: build all -all: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin - - -####################################### -# build the application -####################################### -# list of objects -OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o))) -vpath %.c $(sort $(dir $(C_SOURCES))) -# C++ objects -OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(CPP_SOURCES:.cpp=.o))) -vpath %.cpp $(sort $(dir $(CPP_SOURCES))) -# list of ASM program objects -OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o))) -vpath %.s $(sort $(dir $(ASM_SOURCES))) - -$(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR) - $(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@ - -$(BUILD_DIR)/%.o: %.cpp Makefile | $(BUILD_DIR) - $(CXX) -c $(CXXFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.cpp=.lst)) $< -o $@ - -$(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR) - $(AS) -c $(CFLAGS) $< -o $@ - -$(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile - $(CXX) $(OBJECTS) $(LDFLAGS) -o $@ - $(SZ) $@ - -$(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR) - $(HEX) $< $@ - -$(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR) - $(BIN) $< $@ - -$(BUILD_DIR): - mkdir $@ - - -.PHONY: clean flash debug help - -####################################### -# clean up -####################################### -clean: - -rm -fR $(BUILD_DIR) - - -#################### -# Flashing/Debugging -#################### - -flash: $(BUILD_DIR)/$(TARGET).elf - openocd -f $(COMMON_DIR)/$(MCU_SERIES)_openocd.cfg \ - -c "program $(BUILD_DIR)/$(TARGET).elf verify reset exit" \ - -debug: $(BUILD_DIR)/$(TARGET).elf - openocd -f $(COMMON_DIR)/$(MCU_SERIES)_openocd.cfg - -################ -# Printing Stuff -################ -help: - @echo "Targets:" - @echo " - ${TARGET}: build project" - @echo " - clean: clean up build folder" - @echo " - flash: flash project to microcontroller with OpenOCD" - @echo " - debug: launch an OpenOCD debug session" - @echo " - help: print this message" - - -####################################### -# dependencies -####################################### --include $(wildcard $(BUILD_DIR)/*.d)