From 70e3a139515fe88597b7c6dc28de6b6145d8720a Mon Sep 17 00:00:00 2001 From: hathach Date: Fri, 7 Dec 2012 17:59:46 +0700 Subject: [PATCH] change building process yes, again --- demos/bsp/boards/board.h | 11 +- ...rd_at86rf2xx_11uxx.c => board_at86rf2xx.c} | 4 +- ...cxpresso13uxx.c => board_lpcxpresso1347.c} | 7 +- .../startup_xpresso/cr_startup_lpc11u.c | 5 - demos/demos.mk | 19 +- demos/device/keyboard/.cproject | 952 +++++++++++++++++- demos/device/keyboard/.project | 12 + demos/device/keyboard/main.c | 20 +- demos/device/keyboard/makefile.defs | 4 +- tinyusb/.cproject | 237 ++++- tinyusb/common/common.h | 7 +- tinyusb/common/mcu/mcu.h | 4 - 12 files changed, 1180 insertions(+), 102 deletions(-) rename demos/bsp/boards/{board_at86rf2xx_11uxx.c => board_at86rf2xx.c} (97%) rename demos/bsp/boards/{board_lpcxpresso13uxx.c => board_lpcxpresso1347.c} (91%) diff --git a/demos/bsp/boards/board.h b/demos/bsp/boards/board.h index 76c2b6314..11e4a2bc1 100644 --- a/demos/bsp/boards/board.h +++ b/demos/bsp/boards/board.h @@ -57,17 +57,22 @@ #include +#define TICKS_PER_SECOND 1000 + /// n-th Bit #ifndef BIT #define BIT(n) (1 << (n)) #endif #define BOARD_NGX43XX 1 -#define BOARD_LPCXPRESSOUXX 2 +#define BOARD_LPCXPRESSO1347 2 +#define BOARD_AT86RF2XX 3 #if BOARD == BOARD_NGX43XX -//#include "board_ngx4330.h" -#elif BOARD == BOARD_LPCXPRESSO13UXX + +#elif BOARD == BOARD_LPCXPRESSO1347 + +#elif BOARD == BOARD_AT86RF2XX #else #error BOARD is not defined or supported yet diff --git a/demos/bsp/boards/board_at86rf2xx_11uxx.c b/demos/bsp/boards/board_at86rf2xx.c similarity index 97% rename from demos/bsp/boards/board_at86rf2xx_11uxx.c rename to demos/bsp/boards/board_at86rf2xx.c index 379950705..90e5cc957 100644 --- a/demos/bsp/boards/board_at86rf2xx_11uxx.c +++ b/demos/bsp/boards/board_at86rf2xx.c @@ -1,5 +1,5 @@ /* - * board_at86rf2xx_11uxx.c + * board_at86rf2xx.c * * Created on: Dec 7, 2012 * Author: hathach @@ -37,7 +37,7 @@ #include "board.h" -#if BOARD == BOARD_AT86RF2XX_11UXX +#if BOARD == BOARD_AT86RF2XX #include "LPC11Uxx.h" #include "gpio.h" diff --git a/demos/bsp/boards/board_lpcxpresso13uxx.c b/demos/bsp/boards/board_lpcxpresso1347.c similarity index 91% rename from demos/bsp/boards/board_lpcxpresso13uxx.c rename to demos/bsp/boards/board_lpcxpresso1347.c index caad73d14..206f5b69c 100644 --- a/demos/bsp/boards/board_lpcxpresso13uxx.c +++ b/demos/bsp/boards/board_lpcxpresso1347.c @@ -37,9 +37,10 @@ #include "board.h" -#if BOARD == BOARD_LPCXPRESSO13UXX +#if BOARD == BOARD_LPCXPRESSO1347 #include "LPC13Uxx.h" +#include "gpio.h" #define CFG_LED_PORT (0) #define CFG_LED_PIN (7) @@ -49,7 +50,7 @@ void board_init(void) { SystemInit(); - systickInit(1); + SysTick_Config(SystemCoreClock / TICKS_PER_SECOND); // 1 msec tick timer GPIOInit(); GPIOSetDir(CFG_LED_PORT, CFG_LED_PIN, 1); LPC_GPIO->CLR[CFG_LED_PORT] = (1 << CFG_LED_PIN); @@ -58,7 +59,7 @@ void board_init(void) void board_leds(uint32_t mask, uint32_t state) { if (mask) - GPIOSetBitValue(CFG_LED_PORT, CFG_LED_PIN, state); + GPIOSetBitValue(CFG_LED_PORT, CFG_LED_PIN, mask & state); } #endif diff --git a/demos/bsp/lpc11uxx/startup_xpresso/cr_startup_lpc11u.c b/demos/bsp/lpc11uxx/startup_xpresso/cr_startup_lpc11u.c index f8e421e1c..6865b0721 100644 --- a/demos/bsp/lpc11uxx/startup_xpresso/cr_startup_lpc11u.c +++ b/demos/bsp/lpc11uxx/startup_xpresso/cr_startup_lpc11u.c @@ -1,5 +1,3 @@ -#ifdef __LPC11UXX__ - //***************************************************************************** // +--+ // | ++----+ @@ -47,8 +45,6 @@ extern "C" { #define WEAK __attribute__ ((weak)) #define ALIAS(f) __attribute__ ((weak, alias (#f))) -#define __USE_CMSIS // Added by nxpUSBlib - // Code Red - if CMSIS is being used, then SystemInit() routine // will be called by startup code rather than in application's main() #if defined (__USE_CMSIS) @@ -383,4 +379,3 @@ void IntDefaultHandler(void) } } -#endif /* __LPC11UXX__ */ diff --git a/demos/demos.mk b/demos/demos.mk index fe8eb0ff3..5538127ab 100644 --- a/demos/demos.mk +++ b/demos/demos.mk @@ -5,11 +5,11 @@ CFLAGS = $(MACROS_DEF) $(INC_PATH) MACROS_DEF += -DBOARD=$(board) -DMCU=MCU_$(MCU) #MCU currently supported -mcu_support = 13UXX +mcu_support = 13UXX 11UXX ################ Board and MCU determination ################ #all configuration build's name must be named after the macro BOARD_NAME defined in the tinyusb/demos/boards/board.h -buildname := $(shell echo $(notdir $(build_dir)) | tr a-z A-Z) +buildname = $(shell echo $(notdir $(build_dir)) | tr a-z A-Z) board = $(buildname) mcu = $(shell echo $(MCU) | tr A-Z a-z) @@ -19,12 +19,14 @@ ifeq (,$(findstring BOARD_,$(board))) $(error build's name must be name exactly the same as the macro BOARD_NAME defined in the tinyusb/demos/boards/board.h) endif -MCU := LPC$(findstring $(mcu_support),$(board)) +MCU := $(strip $(foreach supported_chip, $(mcu_support), $(findstring $(supported_chip),$(board)))) ifeq (,$(MCU)) $(error build name must contain one of supported mcu: $(mcu_support)) endif +MCU := LPC$(MCU) + $(warning MCU $(MCU) $(mcu)) ################ Build Manipulate ################ @@ -36,20 +38,19 @@ toolchain = xpresso OBJS := $(filter-out ./bsp/$(mcu)/startup%,$(OBJS)) $(filter ./bsp/$(mcu)/startup_$(toolchain)%,$(OBJS)) #CMSIS include path & lib path -cmsis_proj = CMSISv2p10_$(shell echo $(MCU) | tr X x) +cmsis_proj = $(shell cd $(workspace_dir); ls | grep -i "CMSIS.*$(MCU)") rel_include += $(cmsis_proj)/inc rel_include += demos/bsp/boards rel_include += demos/bsp/$(mcu)/inc INC_PATH = $(addprefix -I"$(workspace_dir)/, $(addsuffix ",$(rel_include))) LIBS += -l$(cmsis_proj) -L"$(workspace_dir)/$(cmsis_proj)/Debug" -#$(warning $(OBJS)) +#$(error $(OBJS)) #generate makefiles.def containing MCU define for tinyusb lib -$(shell echo CFLAGS = -DMCU=MCU_$(MCU) > $(workspace_dir)/tinyusb/makefile.defs) - - - +#tinyusb_CFLAGS = -DMCU=MCU_$(MCU) -I\"$(workspace_dir)/$(cmsis_proj)/inc\" +#$(shell echo CFLAGS = $(tinyusb_CFLAGS) > $(workspace_dir)/tinyusb/makefile.defs) +#$(shell echo $$\(warning MCU = MCU_$(MCU)\) >> $(workspace_dir)/tinyusb/makefile.defs) diff --git a/demos/device/keyboard/.cproject b/demos/device/keyboard/.cproject index 24eb5751f..bebbfb04c 100644 --- a/demos/device/keyboard/.cproject +++ b/demos/device/keyboard/.cproject @@ -4,7 +4,7 @@ - + @@ -18,7 +18,7 @@ - + @@ -29,11 +29,16 @@ - + + @@ -190,6 +198,119 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -416,8 +537,769 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -426,49 +1308,45 @@ <?xml version="1.0" encoding="UTF-8"?> <TargetConfig> -<Properties property_0="" property_3="NXP" property_4="LPC1347" property_count="5" version="1"/> -<infoList vendor="NXP"><info chip="LPC1347" match_id="0x08020543" name="LPC1347" stub="crt_emu_lpc11_13_nxp"><chip><name>LPC1347</name> -<family>LPC13xx (12bit ADC)</family> +<Properties property_0="" property_3="NXP" property_4="LPC11U37/401" property_count="5" version="1"/> +<infoList vendor="NXP"><info chip="LPC11U37/401" match_id="0x00017C40" name="LPC11U37/401" stub="crt_emu_lpc11_13_nxp"><chip><name>LPC11U37/401</name> +<family>LPC11Uxx</family> <vendor>NXP (formerly Philips)</vendor> <reset board="None" core="Real" sys="Real"/> <clock changeable="TRUE" freq="12MHz" is_accurate="TRUE"/> <memory can_program="true" id="Flash" is_ro="true" type="Flash"/> <memory id="RAM" type="RAM"/> <memory id="Periph" is_volatile="true" type="Peripheral"/> -<memoryInstance derived_from="Flash" id="MFlash64" location="0x0" size="0x10000"/> +<memoryInstance derived_from="Flash" id="MFlash128" location="0x0" size="0x20000"/> <memoryInstance derived_from="RAM" id="RamLoc8" location="0x10000000" size="0x2000"/> <memoryInstance derived_from="RAM" id="RamUsb2" location="0x20004000" size="0x800"/> -<memoryInstance derived_from="RAM" id="RamPeriph2" location="0x20000000" size="0x800"/> -<prog_flash blocksz="0x1000" location="0x0" maxprgbuff="0x400" progwithcode="TRUE" size="0x10000"/> -<peripheralInstance derived_from="V7M_MPU" id="MPU" location="0xe000ed90"/> -<peripheralInstance derived_from="V7M_NVIC" id="NVIC" location="0xe000e000"/> -<peripheralInstance derived_from="V7M_DCR" id="DCR" location="0xe000edf0"/> -<peripheralInstance derived_from="V7M_ITM" id="ITM" location="0xe0000000"/> -<peripheralInstance derived_from="I2C" id="I2C" location="0x40000000"/> -<peripheralInstance derived_from="WWDT" id="WWDT" location="0x40004000"/> -<peripheralInstance derived_from="USART" id="USART" location="0x40008000"/> -<peripheralInstance derived_from="CT16B0" id="CT16B0" location="0x4000c000"/> -<peripheralInstance derived_from="CT16B1" id="CT16B1" location="0x40010000"/> -<peripheralInstance derived_from="CT32B0" id="CT32B0" location="0x40014000"/> -<peripheralInstance derived_from="CT32B1" id="CT32B1" location="0x40018000"/> -<peripheralInstance derived_from="ADC" id="ADC" location="0x4001c000"/> -<peripheralInstance derived_from="PMU" id="PMU" location="0x40038000"/> -<peripheralInstance derived_from="FLASHCTRL" id="FLASHCTRL" location="0x4003c000"/> -<peripheralInstance derived_from="SSP0" id="SSP0" location="0x40040000"/> -<peripheralInstance derived_from="IOCON" id="IOCON" location="0x40044000"/> -<peripheralInstance derived_from="SYSCON" id="SYSCON" location="0x40048000"/> -<peripheralInstance derived_from="GPIO-PIN-INT" id="GPIO-PIN-INT" location="0x4004c000"/> -<peripheralInstance derived_from="SSP1" id="SSP1" location="0x40058000"/> -<peripheralInstance derived_from="GPIO-GROUP-INT0" id="GPIO-GROUP-INT0" location="0x4005c000"/> -<peripheralInstance derived_from="GPIO-GROUP-INT1" id="GPIO-GROUP-INT1" location="0x40060000"/> -<peripheralInstance derived_from="RITIMER" id="RITIMER" location="0x40064000"/> -<peripheralInstance derived_from="USB" id="USB" location="0x40080000"/> -<peripheralInstance derived_from="GPIO-PORT" id="GPIO-PORT" location="0x50000000"/> +<prog_flash blocksz="0x1000" location="0x0" maxprgbuff="0x400" progwithcode="TRUE" size="0x20000"/> +<peripheralInstance derived_from="CM0_NVIC" id="NVIC" location="0xe000e000"/> +<peripheralInstance derived_from="LPC11U_GPIO" id="GPIO" location="0x50000000"/> +<peripheralInstance derived_from="LPC11U_USBDEV" id="USB" location="0x40080000"/> +<peripheralInstance derived_from="CM0_DCR" id="DCR" location="0xe000edf0"/> +<peripheralInstance derived_from="LPC11U_GPIO_GROUP_INT" id="GPIOGROUP0INT" location="0x40060000"/> +<peripheralInstance derived_from="LPC11U_GPIO_GROUP_INT" id="GPIOGROUP1INT" location="0x4005c000"/> +<peripheralInstance derived_from="LPC11U_GPIO_INT" id="GPIOINT" location="0x4004c000"/> +<peripheralInstance derived_from="LPC11_13_SSP" id="SSP1" location="0x40058000"/> +<peripheralInstance derived_from="LPC11U_FMC" id="FMC" location="0x4003c000"/> +<peripheralInstance derived_from="LPC11U_SYSCTL" id="SYSCTL" location="0x40048000"/> +<peripheralInstance derived_from="LPC11U_IOCON" id="IOCON" location="0x40044000"/> +<peripheralInstance derived_from="LPC11_13_SSP" id="SSP0" location="0x40040000"/> +<peripheralInstance derived_from="LPC11_13_PMU" id="PMU" location="0x40038000"/> +<peripheralInstance derived_from="LPC11_13_ADC" id="ADC" location="0x4001c000"/> +<peripheralInstance derived_from="LPC11_13_TIMER32" id="TIMER1" location="0x40018000"/> +<peripheralInstance derived_from="LPC11_13_TIMER32" id="TIMER0" location="0x40014000"/> +<peripheralInstance derived_from="LPC11_13_TIMER16" id="TMR161" location="0x40010000"/> +<peripheralInstance derived_from="LPC11_13_TIMER16" id="TMR160" location="0x4000c000"/> +<peripheralInstance derived_from="LPC1xxx_UART_MODEM" id="UART0" location="0x40008000"/> +<peripheralInstance derived_from="LPC11_13_WDT" id="WDT" location="0x40004000"/> +<peripheralInstance derived_from="LPC11_13_I2C" id="I2C0" location="0x40000000"/> </chip> -<processor><name gcc_name="cortex-m3">Cortex-M3</name> +<processor><name gcc_name="cortex-m0">Cortex-M0</name> <family>Cortex-M</family> </processor> -<link href="nxp_lpc13Uxx_peripheral.xme" show="embed" type="simple"/> +<link href="nxp_lpc11_13_peripheral.xme" show="embed" type="simple"/> </info> </infoList> </TargetConfig> diff --git a/demos/device/keyboard/.project b/demos/device/keyboard/.project index 3e0b7059b..4eb78ff4f 100644 --- a/demos/device/keyboard/.project +++ b/demos/device/keyboard/.project @@ -3,6 +3,7 @@ device_keyboard + tinyusb @@ -86,4 +87,15 @@ C:/Users/hathach/Dropbox/tinyusb/tinyusb/demos/bsp + + + 1354876380300 + + 26 + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-false-false-startup_keil + + + diff --git a/demos/device/keyboard/main.c b/demos/device/keyboard/main.c index e792d36ab..411217664 100644 --- a/demos/device/keyboard/main.c +++ b/demos/device/keyboard/main.c @@ -4,7 +4,7 @@ #include #include -#include "board.h" +#include "boards/board.h" #include "tusb.h" // Variable to store CRP value in. Will be placed automatically @@ -12,22 +12,26 @@ // See crp.h header for more information __CRP const unsigned int CRP_WORD = CRP_NO_CRP ; +volatile uint32_t system_tick = 0; + +void SysTick_Handler (void) +{ + system_tick++; +} + int main(void) { - uint32_t currentSecond, lastSecond; - currentSecond = lastSecond = 0; + uint32_t current_tick = system_tick; board_init(); tusb_init(); while (1) { - currentSecond = systickGetSecondsActive(); - if (currentSecond != lastSecond) + if (current_tick + 1000 < system_tick) { - /* Toggle LED once per second */ - lastSecond = currentSecond; - board_leds(0x01, lastSecond%2); + current_tick += 1000; + board_leds(0x01, (current_tick/1000)%2); /* Toggle LED once per second */ #ifndef CFG_CLASS_CDC if (usb_isConfigured()) diff --git a/demos/device/keyboard/makefile.defs b/demos/device/keyboard/makefile.defs index 8532b57e8..bf691d5f0 100644 --- a/demos/device/keyboard/makefile.defs +++ b/demos/device/keyboard/makefile.defs @@ -5,6 +5,6 @@ proj_path = $(build_dir)/.. #get workspace absolute path workspace_dir = $(shell cd $(proj_path)/../../.. ; pwd) #workspace_dir = $(proj_path)/../../../ -$(warning workspace $(workspace_dir)) +#$(warning workspace $(workspace_dir)) -include $(workspace_dir)/demos/demos.mk +#include $(workspace_dir)/demos/demos.mk diff --git a/tinyusb/.cproject b/tinyusb/.cproject index 5fcf530ff..ea359c017 100644 --- a/tinyusb/.cproject +++ b/tinyusb/.cproject @@ -24,14 +24,14 @@ - + - -