Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9f7b342
commit af164a2
Showing
12 changed files
with
86 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
[submodule "sam0"] | ||
path = sam0 | ||
path = deps/sam0 | ||
url = https://github.com/avrxml/sam0.git | ||
[submodule "deps/usb"] | ||
path = deps/usb | ||
url = https://github.com/nonolith/USB-XMEGA/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,111 +1,38 @@ | ||
############################################################################## | ||
CONFIG = Debug | ||
#CONFIG = Release | ||
TARGETS = firmware | ||
BUILD = build | ||
|
||
############################################################################## | ||
.PHONY: all directory clean size | ||
all: $(TARGETS) | ||
.PHONY: all clean | ||
|
||
AT_PATH = sam0/ | ||
CMSIS_PATH = sam0/cmsis/samr21 | ||
DRIVERS_PATH = sam0/drivers | ||
SRC_PATH = src | ||
|
||
USB_PATH=usb | ||
include usb/samd/makefile | ||
ATMEL_PATH = deps/sam0 | ||
CMSIS_PATH = $(ATMEL_PATH)/cmsis/samr21 | ||
DRIVERS_PATH = $(ATMEL_PATH)/drivers | ||
|
||
CC = arm-none-eabi-gcc | ||
OBJCOPY = arm-none-eabi-objcopy | ||
SIZE = arm-none-eabi-size | ||
LD = arm-none-eabi-gcc | ||
|
||
CFLAGS += -W -Wall --std=gnu99 -Os | ||
CFLAGS += -fdata-sections -ffunction-sections | ||
CFLAGS += -funsigned-char -funsigned-bitfields | ||
CFLAGS += -mcpu=cortex-m0plus -mthumb | ||
CFLAGS += -MD -MP -MT $(CONFIG)/$(*F).o -MF $(CONFIG)/$(@F).d | ||
|
||
ifeq ($(CONFIG), Debug) | ||
CFLAGS += -g | ||
endif | ||
|
||
LDFLAGS += -mcpu=cortex-m0plus -mthumb | ||
LDFLAGS += -Wl,--gc-sections --specs=nano.specs | ||
LDFLAGS += -Wl,--script=sam0/linker_scripts/samr21/gcc/samr21g18a_flash.ld | ||
|
||
INCLUDES += \ | ||
-I$(SRC_PATH) \ | ||
-I$(CMSIS_PATH)/.. \ | ||
-I$(CMSIS_PATH)/include \ | ||
-I$(CMSIS_PATH)/source \ | ||
-I$(DRIVERS_PATH)/interrupt \ | ||
-I$(DRIVERS_PATH)/port \ | ||
-I$(DRIVERS_PATH)/sercom \ | ||
-I$(DRIVERS_PATH)/sercom/usart \ | ||
-I$(DRIVERS_PATH)/sercom/i2c \ | ||
-I$(DRIVERS_PATH)/sercom/spi \ | ||
-I$(DRIVERS_PATH)/sercom/spi/module_config \ | ||
-I$(DRIVERS_PATH)/system \ | ||
-I$(DRIVERS_PATH)/system/clock \ | ||
-I$(DRIVERS_PATH)/system/clock/clock_samd21_r21 \ | ||
-I$(DRIVERS_PATH)/system/clock/clock_samd21_r21/module_config \ | ||
-I$(DRIVERS_PATH)/system/interrupt \ | ||
-I$(DRIVERS_PATH)/system/interrupt/system_interrupt_samr21 \ | ||
-I$(DRIVERS_PATH)/system/pinmux \ | ||
-I$(AT_PATH)/include \ | ||
-I$(SRC_PATH)/radio \ | ||
$(USB_OPTS) | ||
|
||
SRCS += \ | ||
$(CMSIS_PATH)/source/gcc/startup_samr21.c \ | ||
$(CMSIS_PATH)/source/system_samr21.c \ | ||
$(DRIVERS_PATH)/system/interrupt/interrupt_sam_nvic.c \ | ||
$(DRIVERS_PATH)/system/clock/clock_samd21_r21/clock.c \ | ||
$(DRIVERS_PATH)/system/clock/clock_samd21_r21/gclk.c \ | ||
$(DRIVERS_PATH)/system/pinmux/pinmux.c \ | ||
$(DRIVERS_PATH)/system/interrupt/system_interrupt.c \ | ||
$(DRIVERS_PATH)/system/system.c \ | ||
$(SRC_USB) \ | ||
$(SRC_PATH)/main.c \ | ||
$(SRC_PATH)/usb.c | ||
|
||
DEFINES += \ | ||
-DPHY_AT86RF233 \ | ||
-DHAL_ATSAMD21J18 \ | ||
-DPLATFORM_XPLAINED_PRO_SAMR21 \ | ||
-DF_CPU=8000000 \ | ||
-BOARD=SAMR21_XPLAINED_PRO \ | ||
-D __SAMR21G18A__ | ||
|
||
CFLAGS += $(INCLUDES) $(DEFINES) | ||
|
||
OBJS = $(addprefix $(CONFIG)/, $(notdir %/$(subst .c,.o, $(SRCS)))) | ||
|
||
all: directory $(CONFIG)/firmware.elf $(CONFIG)/firmware.hex $(CONFIG)/firmware.bin size | ||
|
||
$(CONFIG)/firmware.elf: | ||
$(Q)$(LD) $(LDFLAGS) $(CFLAGS) $(obj-y) $(libflags-gnu-y) $(SRCS) -o $@ | ||
@echo $(MSG_SIZE) | ||
$(Q)$(SIZE) -Ax $@ | ||
$(Q)$(SIZE) -Bx $@ | ||
include $(addsuffix .mk,$(TARGETS)) | ||
|
||
define each_target | ||
$(1): $(BUILD)/$(1).elf $(BUILD)/$(1).bin | ||
.PHONY: $(1) | ||
|
||
$(CONFIG)/firmware.hex: $(CONFIG)/firmware.elf | ||
@echo OBJCOPY $@ | ||
@$(OBJCOPY) -O ihex -R .eeprom $^ $@ | ||
$(1)_OBJS := $$(addprefix $(BUILD)/$(1)/, $$(subst .c,.o, $$($(1)_SRC))) | ||
-include $$($(1)_OBJS:.o=.d) | ||
|
||
$(CONFIG)/firmware.bin: $(CONFIG)/firmware.elf | ||
@echo OBJCOPY $@ | ||
@$(OBJCOPY) -O binary -R .eeprom $^ $@ | ||
$$($(1)_OBJS): $(BUILD)/$(1)/%.o: %.c | ||
@mkdir -p $$(shell dirname $$@) | ||
$(Q)$(CC) $$($(1)_CFLAGS) $$($(1)_INCLUDE) $$($(1)_DEFINE) -c $$< -o $$@ -MMD -MP -MF $$(patsubst %.o,%.d,$$@) | ||
|
||
directory: | ||
@mkdir -p $(CONFIG) | ||
$(BUILD)/$(1).bin $(BUILD)/$(1).elf: $$($(1)_OBJS) | ||
$(Q)$(CC) $$($(1)_CFLAGS) $$($(1)_LDFLAGS) $$($(1)_OBJS) -o $(BUILD)/$(1).elf | ||
$(Q)$(OBJCOPY) -O binary -R .eeprom $(BUILD)/$(1).elf $(BUILD)/$(1).bin | ||
endef | ||
|
||
size: $(CONFIG)/firmware.elf | ||
@echo size: | ||
@$(SIZE) -t $^ | ||
$(foreach t,$(TARGETS),$(eval $(call each_target,$(t)))) | ||
|
||
clean: | ||
@echo clean | ||
@-rm -rf $(CONFIG) | ||
@-rm -rf $(BUILD) | ||
|
||
-include $(wildcard $(CONFIG)/*.d) | ||
print-% : ; @echo $* = $($*) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
$(TARGET)_INCLUDE += \ | ||
-I$(CMSIS_PATH)/.. \ | ||
-I$(CMSIS_PATH)/include \ | ||
-I$(CMSIS_PATH)/source \ | ||
-I$(ATMEL_PATH)/include \ | ||
|
||
$(TARGET)_SRC += \ | ||
$(CMSIS_PATH)/source/gcc/startup_samr21.c \ | ||
$(CMSIS_PATH)/source/system_samr21.c \ | ||
|
||
$(TARGET)_CFLAGS += -Wall --std=gnu99 -Os -g | ||
$(TARGET)_CFLAGS += -fdata-sections -ffunction-sections | ||
$(TARGET)_CFLAGS += -funsigned-char -funsigned-bitfields | ||
$(TARGET)_CFLAGS += -mcpu=cortex-m0plus -mthumb | ||
|
||
$(TARGET)_LDFLAGS += -mcpu=cortex-m0plus -mthumb | ||
$(TARGET)_LDFLAGS += -Wl,--gc-sections --specs=nano.specs | ||
$(TARGET)_LDFLAGS += -Wl,--script=deps/sam0/linker_scripts/samr21/gcc/samr21g18a_flash.ld | ||
|
||
$(TARGET)_DEFINE += \ | ||
-DPHY_AT86RF233 \ | ||
-DHAL_ATSAMD21J18 \ | ||
-DPLATFORM_XPLAINED_PRO_SAMR21 \ | ||
-DF_CPU=8000000 \ | ||
-BOARD=SAMR21_XPLAINED_PRO \ | ||
-D __SAMR21G18A__ |
Submodule sam0
updated
from 000000 to ae470d
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
TARGET := firmware | ||
|
||
include common.mk | ||
include usb.mk | ||
|
||
$(TARGET)_INCLUDE += \ | ||
-I$(DRIVERS_PATH)/interrupt \ | ||
-I$(DRIVERS_PATH)/port \ | ||
-I$(DRIVERS_PATH)/system \ | ||
-I$(DRIVERS_PATH)/system/clock \ | ||
-I$(DRIVERS_PATH)/system/clock/clock_samd21_r21 \ | ||
-I$(DRIVERS_PATH)/system/clock/clock_samd21_r21/module_config \ | ||
-I$(DRIVERS_PATH)/system/interrupt \ | ||
-I$(DRIVERS_PATH)/system/interrupt/system_interrupt_samr21 \ | ||
-I$(DRIVERS_PATH)/system/pinmux \ | ||
|
||
$(TARGET)_SRC += \ | ||
firmware/main.c \ | ||
firmware/usb.c \ | ||
$(DRIVERS_PATH)/system/interrupt/interrupt_sam_nvic.c \ | ||
$(DRIVERS_PATH)/system/clock/clock_samd21_r21/clock.c \ | ||
$(DRIVERS_PATH)/system/clock/clock_samd21_r21/gclk.c \ | ||
$(DRIVERS_PATH)/system/pinmux/pinmux.c \ | ||
$(DRIVERS_PATH)/system/interrupt/system_interrupt.c \ | ||
$(DRIVERS_PATH)/system/system.c \ | ||
$(USB_PATH)/class/dfu/dfu.c |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
USB_PATH := deps/usb | ||
|
||
$(TARGET)_SRC += $(USB_PATH)/samd/usb_samd.c | ||
$(TARGET)_SRC += $(USB_PATH)/usb_requests.c | ||
$(TARGET)_INCLUDE += -I $(USB_PATH) |