From afc4042375f7fa283cf912f019e832aaf659e314 Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 22 Apr 2020 17:08:41 +0700 Subject: add LOGGER option to use rtt update example readme for debug log. Update bug template to ask for LOG as well. --- hw/bsp/board.c | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) (limited to 'hw') 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 -- cgit v1.3.1