From 1f3c9ed69dce91841a4b82541d334562fccbe82b Mon Sep 17 00:00:00 2001 From: hathach Date: Thu, 27 Dec 2012 17:28:53 +0700 Subject: [PATCH] start add makefile for keyboard demo --- .cproject | 258 ++++++++++++++++++++++++++++++++- demos/device/keyboard/makefile | 100 +++++++++++++ tests/.cproject | 8 +- tests/project.yml | 4 +- tinyusb/common/errors.c | 1 + tinyusb/common/errors.h | 1 + 6 files changed, 359 insertions(+), 13 deletions(-) create mode 100644 demos/device/keyboard/makefile diff --git a/.cproject b/.cproject index 93870fc27..63193e701 100644 --- a/.cproject +++ b/.cproject @@ -27,6 +27,11 @@ + @@ -267,9 +272,252 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + make + + all + true + true + true + + + make + + clean + true + true + true + + @@ -280,10 +528,7 @@ <?xml version="1.0" encoding="UTF-8"?> <TargetConfig> <Properties property_0="" property_3="NXP" property_4="LPC1343" property_count="5" version="1"/> -<infoList vendor="NXP"> -<info chip="LPC1343" match_id="0x3d00002b" name="LPC1343" stub="crt_emu_lpc11_13_nxp"> -<chip> -<name>LPC1343</name> +<infoList vendor="NXP"><info chip="LPC1343" match_id="0x3d00002b" name="LPC1343" stub="crt_emu_lpc11_13_nxp"><chip><name>LPC1343</name> <family>LPC13xx</family> <vendor>NXP (formerly Philips)</vendor> <reset board="None" core="Real" sys="Real"/> @@ -315,8 +560,7 @@ <peripheralInstance derived_from="CM3_DCR" determined="infoFile" id="DCR" location="0xe000edf0"/> <peripheralInstance derived_from="LPC11U_FMC" determined="infoFile" id="FMC" location="0x4003c000"/> </chip> -<processor> -<name gcc_name="cortex-m3">Cortex-M3</name> +<processor><name gcc_name="cortex-m3">Cortex-M3</name> <family>Cortex-M</family> </processor> <link href="nxp_lpc11_13_peripheral.xme" show="embed" type="simple"/> diff --git a/demos/device/keyboard/makefile b/demos/device/keyboard/makefile new file mode 100644 index 000000000..4b1c6cb13 --- /dev/null +++ b/demos/device/keyboard/makefile @@ -0,0 +1,100 @@ +####################################################################################### +# Software License Agreement (BSD License) +# Copyright (c) 2012, hathach (tinyusb.net) +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# 3. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT +# SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +# OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY +# OF SUCH DAMAGE. +####################################################################################### + +################################################## +# Keyboard makefile +################################################## + +############ Toolchain ############ +toolchain := lpcxpresso +CC := arm-none-eabi-gcc +RM := rm -rf +#AR LD + +toolchain_def = __REDLIB__ __CODE_RED __USE_CMSIS=CMSISv2p00_LPC11Uxx +mcu = lpc11uxx +build_path = ../build/ + +#helper function +rel2abs = $(shell cd $(1); pwd) + +#path +tinyusb_path = ../../../tinyusb +bsp_path = ../../bsp +cmsis_path = ../../../../CMSISv2p00_LPC11Uxx + +build_path_abs = $(CURDIR)/$(build_path_relative) +tinyusb_path_abs = $(CURDIR)/$(tinyusb_path) +bsp_path_abs = $(CURDIR)/$(bsp_path) +cmsis_path_abs = $(CURDIR)/$(cmsis_path) + +# Source +src = $(shell find -type f -name "*.c") $(tinyusb_src) $(bsp_src) +objects = $(subst .c,.o,$(src)) +dependencies = $(subst .c,.d,$(src)) + +############ CFLAGS C Compiler Flag ############## +#CFLAGS = $(addprefix -D,$(toolchain_def) $(macros_def)) $(addprefix -I,$(inc_path)) + +############ LDFLAGS Linker Flag ############## +#LDFLAGS + +############ CPPFLAGS C Preprocessor Flag ############## +CPPFLAGS = $(addprefix -D,$(toolchain_def) $(macros_def)) $(addprefix -I,$(inc_path)) + +macros_def += BOARD=BOARD_AT86RF2XX +macros_def += MCU=MCU_LPC11UXX + +inc_path = $(tinyusb_path_abs) $(bsp_path_abs) $(cmsis_path_abs)/inc $(call rel2abs, ./) + +tinyusb_src = $(shell find $(tinyusb_path_abs) \( ! -name "*hal*" \) -type f -name "*.c") $(tinyusb_path)/hal/hal_$(mcu).c +bsp_src = $(shell find $(bsp_path_abs)/boards -type f -name "*.c") $(shell find $(bsp_path)/$(mcu) -type f -name "*.c") +cmsis_src = $(shell find $(cmsis_path) -type f -name "*.c") + +############ Compile Rules ############## +#%.o : %.c + +############ Target ############## +all: keyboard.axf + +keyboard.axf : $(objects) + +clean: + -$(RM) $(objects) $(dependencies) keyboard.axf + +.PHONY: all clean + +############ Dependencies Generate and Inlcude ############ +ifneq ($(MAKECMDGOALS),clean) +include $(dependencies) +endif + +%.d: %.c + $(CC) -M $(CPPFLAGS) $< > $@.$$$$; \ + sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ + rm -f $@.$$$$ diff --git a/tests/.cproject b/tests/.cproject index e86cdee98..7df6ab672 100644 --- a/tests/.cproject +++ b/tests/.cproject @@ -158,15 +158,15 @@ - + rake.bat - default + release true false true - + rake.bat test:all @@ -176,6 +176,7 @@ rake.bat + test:delta true false @@ -183,7 +184,6 @@ rake.bat - clean true false diff --git a/tests/project.yml b/tests/project.yml index f09d1facd..2d770b58f 100644 --- a/tests/project.yml +++ b/tests/project.yml @@ -29,8 +29,8 @@ - -:test/support :source: - src/** - - ../../tinyusb/** - - ../../../CMSISv2p10_LPC43xx_DriverLib/inc + - ../tinyusb/** + - ../../CMSISv2p10_LPC43xx_DriverLib/inc :support: - test/support diff --git a/tinyusb/common/errors.c b/tinyusb/common/errors.c index 4c60e5e47..65e4c4e28 100644 --- a/tinyusb/common/errors.c +++ b/tinyusb/common/errors.c @@ -39,6 +39,7 @@ #if TUSB_CFG_DEBUG == 3 +// TODO X macro to remove define/undefine char const* const TUSB_ErrorStr[] = { # define ERROR_ENUM(x) #x, # include "errors_def" diff --git a/tinyusb/common/errors.h b/tinyusb/common/errors.h index 53c9379c3..d5c372368 100644 --- a/tinyusb/common/errors.h +++ b/tinyusb/common/errors.h @@ -59,6 +59,7 @@ * \brief Error Code returned */ +// TODO X macro to remove define/undefine typedef enum { # define ERROR_ENUM(x) x, # include "errors_def"