From cf65f859be27d71fb64c1c0bca07585f4df37f75 Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 25 Sep 2013 11:23:53 +0700 Subject: [PATCH] working on fatfs integration fix retarget input for lpcxpresso --- demos/bsp/boards/board.c | 1 + demos/bsp/boards/printf_retarget.c | 35 +++--- demos/host/host_os_none/.cproject | 1 + demos/host/host_os_none/.project | 9 +- demos/host/host_os_none/host_os_none.uvopt | 132 +++++++++++++++----- demos/host/host_os_none/host_os_none.uvproj | 32 ++++- demos/host/src/msc_app.c | 13 ++ vendor/fatfs/diskio.c | 116 +++++++++++++++++ vendor/fatfs/diskio.h | 29 +++-- vendor/fatfs/ffconf.h | 2 +- vendor/fatfs/integer.h | 3 + 11 files changed, 308 insertions(+), 65 deletions(-) create mode 100644 vendor/fatfs/diskio.c diff --git a/demos/bsp/boards/board.c b/demos/bsp/boards/board.c index c411176da..4a423c5d2 100644 --- a/demos/bsp/boards/board.c +++ b/demos/bsp/boards/board.c @@ -46,6 +46,7 @@ void SysTick_Handler (void) system_ticks++; tusb_tick_tock(); // TODO temporarily } + #endif #if 0 diff --git a/demos/bsp/boards/printf_retarget.c b/demos/bsp/boards/printf_retarget.c index 12303c89e..f940836fd 100644 --- a/demos/bsp/boards/printf_retarget.c +++ b/demos/bsp/boards/printf_retarget.c @@ -38,11 +38,19 @@ #include "board.h" -//-------------------------------------------------------------------- + -// LPCXpresso printf redirection + -//-------------------------------------------------------------------- + #if CFG_PRINTF_TARGET != PRINTF_TARGET_DEBUG_CONSOLE +#if CFG_PRINTF_TARGET == PRINTF_TARGET_UART + #define retarget_getchar() board_uart_getchar() +#elif CFG_PRINTF_TARGET == PRINTF_TARGET_SWO + #define retarget_getchar() ITM_ReceiveChar() +#else + #error Target is not implemented yet +#endif + +//--------------------------------------------------------------------+ +// LPCXPRESSO / RED SUITE +//--------------------------------------------------------------------+ #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 @@ -87,33 +95,20 @@ int __sys_write (int iFileHandle, char *pcBuffer, int iLength) // the character from the UART. int __sys_readc (void) { - uint8_t c; - -#if CFG_PRINTF_TARGET == PRINTF_TARGET_UART - board_uart_recv(&c, 1); -#elif CFG_PRINTF_TARGET == PRINTF_TARGET_SWO - c = ITM_ReceiveChar(); -#else - #error Thach, did you forget something -#endif - - return (int)c; + return (int) retarget_getchar(); } +//--------------------------------------------------------------------+ +// KEIL +//--------------------------------------------------------------------+ #elif defined __CC_ARM // keil #if CFG_PRINTF_TARGET == PRINTF_TARGET_UART #define retarget_putc(c) board_uart_send( (uint8_t*) &c, 1); - #define retarget_getchar() board_uart_getchar() #elif CFG_PRINTF_TARGET == PRINTF_TARGET_SWO #define retarget_putc(c) ITM_SendChar(c) - #define retarget_getchar() ITM_ReceiveChar() -#else - #error Thach, did you forget something #endif - - struct __FILE { uint32_t handle; }; diff --git a/demos/host/host_os_none/.cproject b/demos/host/host_os_none/.cproject index e7a18e701..2f9eb024a 100644 --- a/demos/host/host_os_none/.cproject +++ b/demos/host/host_os_none/.cproject @@ -1150,6 +1150,7 @@