diff options
Diffstat (limited to 'hw')
| -rw-r--r-- | hw/bsp/board.c | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/hw/bsp/board.c b/hw/bsp/board.c index 364027d58..55236668f 100644 --- a/hw/bsp/board.c +++ b/hw/bsp/board.c @@ -32,25 +32,31 @@ #define sys_write _write #define sys_read _read #endif + //--------------------------------------------------------------------+ -// MACRO TYPEDEF CONSTANT ENUM DECLARATION +// newlib read()/write() retarget //--------------------------------------------------------------------+ -//#if CFG_PRINTF_TARGET == PRINTF_TARGET_UART -// #define retarget_getchar board_uart_getchar -// #define retarget_putchar board_uart_putchar -//#elif CFG_PRINTF_TARGET == PRINTF_TARGET_SWO -// volatile int32_t ITM_RxBuffer; // keil variable to read from SWO -// #define retarget_getchar ITM_ReceiveChar -// #define retarget_putchar ITM_SendChar -//#else -// #error Target is not implemented yet -//#endif +#ifdef LOGGER_RTT -//------------- IMPLEMENTATION -------------// +#include "SEGGER_RTT.h" -// newlib read()/write() retarget +TU_ATTR_USED int sys_write (int fhdl, const void *buf, size_t count) +{ + (void) fhdl; + SEGGER_RTT_Write(0, (char*) buf, (int) count); + return count; +} + +TU_ATTR_USED int sys_read (int fhdl, char *buf, size_t count) +{ + (void) fhdl; + return SEGGER_RTT_Read(0, buf, count); +} +#else + +// Default logger is on-board UART TU_ATTR_USED int sys_write (int fhdl, const void *buf, size_t count) { (void) fhdl; @@ -62,3 +68,5 @@ TU_ATTR_USED int sys_read (int fhdl, char *buf, size_t count) (void) fhdl; return board_uart_read((uint8_t*) buf, count); } + +#endif |
