summaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorHa Thach <[email protected]>2020-04-22 17:40:14 +0700
committerGitHub <[email protected]>2020-04-22 17:40:14 +0700
commit894a09f2ae7082fd9e850b76febed12dafecdcd4 (patch)
treef611ce0a18301169bae433886de1febcbcb754e4 /hw
parente23206821f6b060f384962cfb71f8cbb65b45c0f (diff)
parent7784b9c48f9e77d740ccc7e4929c5e944cdb1afd (diff)
Merge pull request #372 from hathach/add-rtt
Add rtt as logger option
Diffstat (limited to 'hw')
-rw-r--r--hw/bsp/board.c34
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