From 14a8e266977874de387b096ce43b45d7a3363041 Mon Sep 17 00:00:00 2001 From: hathach Date: Tue, 10 Sep 2013 10:43:24 +0700 Subject: [PATCH] able to get blinky + greeting --- demos/bsp/boards/printf_retarget.c | 46 +++- .../src/lpc43xx_cgu.c | 11 +- demos/host/host_os_none/host_os_none.uvopt | 207 +++++++++++++----- demos/host/host_os_none/host_os_none.uvproj | 55 +++-- tinyusb/osal/osal_none.h | 4 +- 5 files changed, 248 insertions(+), 75 deletions(-) diff --git a/demos/bsp/boards/printf_retarget.c b/demos/bsp/boards/printf_retarget.c index 49a2150e..b00f2b91 100644 --- a/demos/bsp/boards/printf_retarget.c +++ b/demos/bsp/boards/printf_retarget.c @@ -41,7 +41,9 @@ //-------------------------------------------------------------------- + // LPCXpresso printf redirection + //-------------------------------------------------------------------- + -#if (defined __CODE_RED) && (CFG_PRINTF_TARGET != PRINTF_TARGET_DEBUG_CONSOLE) +#if CFG_PRINTF_TARGET != PRINTF_TARGET_DEBUG_CONSOLE + +#if defined __CODE_RED // Called by bottom level of printf routine within RedLib C library to write // a character. With the default semihosting stub, this would write the character // to the debugger console window . But this version writes @@ -67,7 +69,7 @@ int __sys_write (int iFileHandle, char *pcBuffer, int iLength) p_newline_pos = memchr(pcBuffer, '\n', length); } - board_uart_send((uint8_t*)pcBuffer, length); + board_uart_send((uint8_t*)pcBuffer, length); return iLength; @@ -103,4 +105,44 @@ int __sys_readc (void) return (int)c; } +#elif defined __CC_ARM // keil + +struct __FILE { + uint32_t handle; +}; + +int fputc(int ch, FILE *f) +{ + if (//CFG_PRINTF_NEWLINE[0] == '\r' && + ch == '\n') + { + const uint8_t carry = '\r'; + board_uart_send(&carry, 1); + } + + //board_uart_send( (uint8_t*) &ch, 1); + + uint8_t c = (uint8_t) ch; + board_uart_send( (uint8_t*) &c, 1); + + return ch; +} + +void _ttywrch(int ch) +{ + if (//CFG_PRINTF_NEWLINE[0] == '\r' && + ch == '\n') + { + const uint8_t carry = '\r'; + board_uart_send(&carry, 1); + } + + //board_uart_send( (uint8_t*) &ch, 1); + + uint8_t c = (uint8_t) ch; + board_uart_send( (uint8_t*) &c, 1); +} + #endif + +#endif // CFG_PRINTF_TARGET != PRINTF_TARGET_DEBUG_CONSOLE diff --git a/demos/bsp/lpc43xx/CMSISv2p10_LPC43xx_DriverLib/src/lpc43xx_cgu.c b/demos/bsp/lpc43xx/CMSISv2p10_LPC43xx_DriverLib/src/lpc43xx_cgu.c index 41c249ce..8ee04fd4 100644 --- a/demos/bsp/lpc43xx/CMSISv2p10_LPC43xx_DriverLib/src/lpc43xx_cgu.c +++ b/demos/bsp/lpc43xx/CMSISv2p10_LPC43xx_DriverLib/src/lpc43xx_cgu.c @@ -23,7 +23,7 @@ * warranty that such application will be suitable for the specified * use without further testing or modification. * Permission to use, copy, modify, and distribute this software and its -* documentation is hereby granted, under NXP Semiconductors� +* documentation is hereby granted, under NXP Semiconductors’ * relevant copyright in the software, without fee, provided that it * is used in conjunction with NXP Semiconductors microcontrollers. This * copyright, permission, and disclaimer notice must appear in all copies of @@ -179,11 +179,11 @@ uint32_t CGU_ClockSourceFrequency[CGU_CLKSRC_NUM] = {0,12000000,0,0,0,0, 0, 4800 #define CGU_CGU_ADDR ((uint32_t)LPC_CGU) #define CGU_REG_BASE_CTRL(x) (*(uint32_t*)(CGU_CGU_ADDR+CGU_Entity_ControlReg_Offset[CGU_PERIPHERAL_Info[x].RegBaseEntity])) #define CGU_REG_BRANCH_CTRL(x) (*(uint32_t*)(CGU_CGU_ADDR+CGU_PERIPHERAL_Info[x].RegBranchOffset)) -#define CGU_REG_BRANCH_STATUS(x) (*(uint32_t*)(CGU_CGU_ADDR+CGU_PERIPHERAL_Info[x].RegBranchOffset+4)) +#define CGU_REG_BRANCH_STATUS(x) (*(volatile uint32_t*)(CGU_CGU_ADDR+CGU_PERIPHERAL_Info[x].RegBranchOffset+4)) #define CGU_PER_BASE_CTRL(x) (*(uint32_t*)(CGU_CGU_ADDR+CGU_Entity_ControlReg_Offset[CGU_PERIPHERAL_Info[x].PerBaseEntity])) #define CGU_PER_BRANCH_CTRL(x) (*(uint32_t*)(CGU_CGU_ADDR+CGU_PERIPHERAL_Info[x].PerBranchOffset)) -#define CGU_PER_BRANCH_STATUS(x) (*(uint32_t*)(CGU_CGU_ADDR+CGU_PERIPHERAL_Info[x].PerBranchOffset+4)) +#define CGU_PER_BRANCH_STATUS(x) (*(volatile uint32_t*)(CGU_CGU_ADDR+CGU_PERIPHERAL_Info[x].PerBranchOffset+4)) /*********************************************************************//** @@ -199,10 +199,11 @@ uint32_t CGU_Init(void){ CGU_EntityConnect(CGU_CLKSRC_XTAL_OSC, CGU_CLKSRC_PLL1); // Disable PLL1 CPU hang??? //CGU_EnableEntity(CGU_CLKSRC_PLL1, DISABLE); - CGU_SetPLL1(5); + CGU_SetPLL1(6); CGU_EnableEntity(CGU_CLKSRC_PLL1, ENABLE); CGU_EntityConnect(CGU_CLKSRC_PLL1, CGU_BASE_M4); CGU_UpdateClock(); + SystemCoreClock = 6*12000000; return 0; } @@ -400,7 +401,7 @@ void CGU_UpdateClock(void){ CGU_ClockSourceFrequency[CGU_CLKSRC_32KHZ_OSC] = 0; /*PLL0*/ /* PLL1 */ - if(ISBITCLR(LPC_CGU->PLL1_CTRL,1) /* Enabled */ + if(ISBITCLR(LPC_CGU->PLL1_CTRL,0) /* Enabled */ /* EA ANDLI: Original code tested bit 1 which is BYPASS, not PD */ && (LPC_CGU->PLL1_STAT&1)){ /* Locked? */ ClkSrc = (LPC_CGU->PLL1_CTRL & CGU_CTRL_SRC_MASK)>>24; CGU_ClockSourceFrequency[CGU_CLKSRC_PLL1] = CGU_ClockSourceFrequency[ClkSrc] * diff --git a/demos/host/host_os_none/host_os_none.uvopt b/demos/host/host_os_none/host_os_none.uvopt index d74952ed..21bc9750 100644 --- a/demos/host/host_os_none/host_os_none.uvopt +++ b/demos/host/host_os_none/host_os_none.uvopt @@ -145,7 +145,7 @@ 0 DLGUARM - (106=-1,-1,-1,-1,0)(107=-1,-1,-1,-1,0) + ¾ 0 @@ -158,11 +158,44 @@ -O975 -S0 -C0 -FO7 -FD10000000 -FC800 -FN2 -FF0LPC18xx43xx_512_BA -FS01A000000 -FL080000 -FF1LPC18xx43xx_512_BB -FS11B000000 -FL180000) - + + + 0 + 0 + 126 + 1 +
0
+ 0 + 0 + 0 + 0 + 0 + 0 + C:\Users\hathach\Dropbox\tinyusb\workspace\tinyusb\demos\bsp\boards\printf_retarget.c + + +
+ + 1 + 0 + 143 + 1 +
0
+ 0 + 0 + 0 + 0 + 0 + 0 + C:\Users\hathach\Dropbox\tinyusb\workspace\tinyusb\demos\bsp\boards\printf_retarget.c + + +
+
0 1 - 1 + 0 0 0 0 @@ -205,32 +238,16 @@ 1 0 0 - 0 + 21 0 1 - 7 + 8 0 ..\src\main.c main.c 0 0 - - 1 - 2 - 1 - 0 - 0 - 22 - 0 - 20 - 27 - 0 - ..\src\main2.c - main2.c - 0 - 0 - @@ -241,7 +258,7 @@ 0 2 - 3 + 2 2 0 0 @@ -250,27 +267,11 @@ 0 0 0 - .\startup_LPC43xx.s + ..\..\bsp\lpc43xx\startup_keil\startup_LPC43xx.s startup_LPC43xx.s 0 0 - - 2 - 4 - 1 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - .\system_LPC43xx.c - system_LPC43xx.c - 0 - 0 - @@ -281,14 +282,14 @@ 0 3 - 5 + 3 1 0 0 0 0 - 0 - 0 + 1 + 1 0 ..\..\bsp\lpc43xx\CMSISv2p10_LPC43xx_DriverLib\src\lpc43xx_uart.c lpc43xx_uart.c @@ -297,7 +298,7 @@ 3 - 6 + 4 1 0 0 @@ -313,7 +314,7 @@ 3 - 7 + 5 1 0 0 @@ -329,7 +330,7 @@ 3 - 8 + 6 1 0 0 @@ -343,6 +344,38 @@ 0 0 + + 3 + 7 + 1 + 0 + 0 + 0 + 0 + 29 + 37 + 0 + ..\..\bsp\lpc43xx\CMSISv2p10_LPC43xx_DriverLib\src\system_LPC43xx.c + system_LPC43xx.c + 0 + 0 + + + 3 + 8 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + ..\..\bsp\lpc43xx\CMSISv2p10_LPC43xx_DriverLib\src\lpc43xx_i2c.c + lpc43xx_i2c.c + 0 + 0 + @@ -357,10 +390,10 @@ 1 0 0 - 14 + 0 0 - 34 - 54 + 1 + 1 0 ..\..\bsp\boards\board.c board.c @@ -373,16 +406,88 @@ 1 0 0 - 21 + 0 0 - 17 - 39 + 1 + 1 0 ..\..\bsp\boards\embedded_artists\board_ea4357.c board_ea4357.c 0 0 + + 4 + 11 + 1 + 0 + 0 + 27 + 0 + 112 + 125 + 0 + ..\..\bsp\boards\printf_retarget.c + printf_retarget.c + 0 + 0 + + + 4 + 12 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + ..\..\bsp\boards\embedded_artists\oem_base_board\pca9532.c + pca9532.c + 0 + 0 + + + + + tinyusb + 1 + 0 + 0 + 0 + + 5 + 13 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + ..\..\..\tinyusb\tusb.c + tusb.c + 0 + 0 + + + 5 + 14 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + ..\..\..\tinyusb\osal\osal_none.c + osal_none.c + 0 + 0 + diff --git a/demos/host/host_os_none/host_os_none.uvproj b/demos/host/host_os_none/host_os_none.uvproj index 66688f86..de815611 100644 --- a/demos/host/host_os_none/host_os_none.uvproj +++ b/demos/host/host_os_none/host_os_none.uvproj @@ -211,7 +211,7 @@ 1 1 8 - 0 + 1 0 0 3 @@ -402,7 +402,7 @@ 0 0 0 - 0 + 1 2 2 2 @@ -436,11 +436,6 @@ - - main2.c - 1 - ..\src\main2.c - @@ -449,12 +444,7 @@ startup_LPC43xx.s 2 - .\startup_LPC43xx.s - - - system_LPC43xx.c - 1 - .\system_LPC43xx.c + ..\..\bsp\lpc43xx\startup_keil\startup_LPC43xx.s @@ -481,6 +471,16 @@ 1 ..\..\bsp\lpc43xx\CMSISv2p10_LPC43xx_DriverLib\src\lpc43xx_cgu.c + + system_LPC43xx.c + 1 + ..\..\bsp\lpc43xx\CMSISv2p10_LPC43xx_DriverLib\src\system_LPC43xx.c + + + lpc43xx_i2c.c + 1 + ..\..\bsp\lpc43xx\CMSISv2p10_LPC43xx_DriverLib\src\lpc43xx_i2c.c + @@ -490,6 +490,31 @@ board.c 1 ..\..\bsp\boards\board.c + + + board_ea4357.c + 1 + ..\..\bsp\boards\embedded_artists\board_ea4357.c + + + printf_retarget.c + 1 + ..\..\bsp\boards\printf_retarget.c + + + pca9532.c + 1 + ..\..\bsp\boards\embedded_artists\oem_base_board\pca9532.c + + + + + tinyusb + + + tusb.c + 1 + ..\..\..\tinyusb\tusb.c 2 @@ -532,9 +557,9 @@ - board_ea4357.c + osal_none.c 1 - ..\..\bsp\boards\embedded_artists\board_ea4357.c + ..\..\..\tinyusb\osal\osal_none.c diff --git a/tinyusb/osal/osal_none.h b/tinyusb/osal/osal_none.h index 4eddffd1..acc5bdb0 100644 --- a/tinyusb/osal/osal_none.h +++ b/tinyusb/osal/osal_none.h @@ -68,8 +68,8 @@ static inline void osal_tick_tock(void) osal_tick_current++; } -static inline volatile uint32_t osal_tick_get(void) ATTR_ALWAYS_INLINE; -static inline volatile uint32_t osal_tick_get(void) +static inline uint32_t osal_tick_get(void) ATTR_ALWAYS_INLINE; +static inline uint32_t osal_tick_get(void) { return osal_tick_current; }