diff options
| author | Scott Shawcroft <[email protected]> | 2018-11-24 10:55:51 -0800 |
|---|---|---|
| committer | Scott Shawcroft <[email protected]> | 2018-11-25 11:46:06 -0800 |
| commit | bf70f89240de82b6a1a64909d96f582041db1148 (patch) | |
| tree | 67cc01324cc69f5a4f68e98a3da986fda828c3b0 /examples/device | |
| parent | 3bb53273cd3770328f55ba317af3df0cce4333c1 (diff) | |
Introduce a Makefile for the OS_NONE device example
It currently supports the SAMD21 and SAMD51 only. More will be
added later.
Diffstat (limited to 'examples/device')
| -rw-r--r-- | examples/device/cdc_msc_hid/Makefile | 122 | ||||
| -rw-r--r-- | examples/device/cdc_msc_hid/src/main.c | 5 | ||||
| -rw-r--r-- | examples/device/cdc_msc_hid/src/tusb_config.h | 2 |
3 files changed, 127 insertions, 2 deletions
diff --git a/examples/device/cdc_msc_hid/Makefile b/examples/device/cdc_msc_hid/Makefile new file mode 100644 index 000000000..4fddc1a14 --- /dev/null +++ b/examples/device/cdc_msc_hid/Makefile @@ -0,0 +1,122 @@ +include ../../../tools/top.mk + +# Select the board to build for. +ifeq ($(BOARD),) + $(error You must provide a BOARD parameter) +else + ifeq ($(wildcard $(TOP)/hw/bsp/$(BOARD)/.),) + $(error Invalid BOARD specified) + endif +endif + +# If the build directory is not given, make it reflect the board name. +BUILD ?= build-$(BOARD) + +CROSS_COMPILE = arm-none-eabi- + +include $(TOP)/hw/bsp/$(BOARD)/board.mk + +CC = $(CROSS_COMPILE)gcc +CXX = $(CROSS_COMPILE)g++ +LD = $(CROSS_COMPILE)ld +OBJCOPY = $(CROSS_COMPILE)objcopy +MKDIR = mkdir +SED = sed +CP = cp +RM = rm + +INC += -Isrc \ + -I$(TOP)/hw \ + -I$(TOP)/src + +CFLAGS += \ + -fsingle-precision-constant \ + -fno-strict-aliasing \ + -Wdouble-promotion \ + -Wno-endif-labels \ + -Wstrict-prototypes \ + -Werror-implicit-function-declaration \ + -Wfloat-equal \ + -Wundef \ + -Wshadow \ + -Wwrite-strings \ + -Wsign-compare \ + -Wmissing-format-attribute \ + -Wno-deprecated-declarations \ + -Wnested-externs \ + -Wunreachable-code \ + -Wcast-align \ + -Wno-error=lto-type-mismatch \ + -ffunction-sections \ + -fdata-sections + +#Debugging/Optimization +ifeq ($(DEBUG), 1) + CFLAGS += -O0 -ggdb +else + CFLAGS += -flto -Os +endif + +CFLAGS += $(INC) -Wall -Werror -std=gnu11 -nostdlib -DBOARD_$(shell echo $(BOARD) | tr a-z A-Z) + +LDFLAGS += $(CFLAGS) -nostartfiles -fshort-enums -Wl,-T,$(TOP)/$(LD_FILE) -Wl,[email protected] -Wl,-cref -Wl,-gc-sections -specs=nosys.specs -specs=nano.specs +LIBS := -lgcc -lc -lm -lnosys + +EXAMPLE_SOURCE += \ + src/main.c \ + src/msc_app.c \ + src/msc_disk_ram.c \ + src/tusb_descriptors.c + +SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE)) + +LIB_SOURCE += \ + hw/bsp/$(BOARD)/board_$(BOARD).c \ + src/common/tusb_fifo.c \ + src/device/usbd.c \ + src/device/usbd_auto_desc.c \ + src/device/usbd_control.c \ + src/class/msc/msc_device.c \ + src/class/cdc/cdc_device.c \ + src/class/hid/hid_device.c \ + src/tusb.c \ + src/portable/$(VENDOR)/$(CHIP_FAMILY)/dcd_$(CHIP_FAMILY).c \ + src/portable/$(VENDOR)/$(CHIP_FAMILY)/hal_$(CHIP_FAMILY).c + +SRC_C += $(LIB_SOURCE) + +OBJ = $(addprefix $(BUILD)/obj/, $(SRC_C:.c=.o)) +OBJ += $(addprefix $(BUILD)/obj/, $(SRC_S:.s=.o)) + +all: $(BUILD)/$(BOARD)-firmware.bin + +OBJ_DIRS = $(sort $(dir $(OBJ))) +$(OBJ): | $(OBJ_DIRS) +$(OBJ_DIRS): + @$(MKDIR) -p $@ + +$(BUILD)/$(BOARD)-firmware.elf: $(OBJ) + @echo LINK $@ + @$(CC) -o $@ $(LDFLAGS) $^ -Wl,--start-group $(LIBS) -Wl,--end-group + +$(BUILD)/$(BOARD)-firmware.bin: $(BUILD)/$(BOARD)-firmware.elf + @echo CREATE $@ + $(OBJCOPY) -O binary -j .vectors -j .text -j .data $^ $@ + +# We set vpath to point to the top of the tree so that the source files +# can be located. By following this scheme, it allows a single build rule +# to be used to compile all .c files. +vpath %.c . $(TOP) +$(BUILD)/obj/%.o: %.c + @echo CC $@ + @$(CC) $(CFLAGS) -c -MD -o $@ $< + @# The following fixes the dependency file. + @# See http://make.paulandlesley.org/autodep.html for details. + @# Regex adjusted from the above to play better with Windows paths, etc. + @$(CP) $(@:.o=.d) $(@:.o=.P); \ + $(SED) -e 's/#.*//' -e 's/^.*: *//' -e 's/ *\\$$//' \ + -e '/^$$/ d' -e 's/$$/ :/' < $(@:.o=.d) >> $(@:.o=.P); \ + $(RM) $(@:.o=.d) + +clean: + rm -rf build-$(BOARD) diff --git a/examples/device/cdc_msc_hid/src/main.c b/examples/device/cdc_msc_hid/src/main.c index 4c8730242..9d3e088cf 100644 --- a/examples/device/cdc_msc_hid/src/main.c +++ b/examples/device/cdc_msc_hid/src/main.c @@ -49,6 +49,9 @@ void print_greeting(void); void led_blinking_task(void); +extern void virtual_com_task(void); +extern void usb_hid_task(void); + /*------------- MAIN -------------*/ int main(void) { @@ -64,12 +67,10 @@ int main(void) led_blinking_task(); #if CFG_TUD_CDC - extern void virtual_com_task(void); virtual_com_task(); #endif #if CFG_TUD_HID - extern void usb_hid_task(void); usb_hid_task(); #endif } diff --git a/examples/device/cdc_msc_hid/src/tusb_config.h b/examples/device/cdc_msc_hid/src/tusb_config.h index 9bc97ecff..0aa023352 100644 --- a/examples/device/cdc_msc_hid/src/tusb_config.h +++ b/examples/device/cdc_msc_hid/src/tusb_config.h @@ -39,6 +39,7 @@ #ifndef _TUSB_CONFIG_H_ #define _TUSB_CONFIG_H_ +#include "tusb_option.h" #include "bsp/board.h" #ifdef __cplusplus @@ -96,6 +97,7 @@ //------------- CLASS -------------// #define CFG_TUD_CDC 1 #define CFG_TUD_MSC 1 +#define CFG_TUD_CUSTOM_CLASS 0 #define CFG_TUD_HID 0 #define CFG_TUD_HID_KEYBOARD 0 |
