summaryrefslogtreecommitdiff
path: root/hw/bsp/board.c
diff options
context:
space:
mode:
Diffstat (limited to 'hw/bsp/board.c')
-rw-r--r--hw/bsp/board.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/hw/bsp/board.c b/hw/bsp/board.c
index 5bcdb7f15..1ba5a1b9d 100644
--- a/hw/bsp/board.c
+++ b/hw/bsp/board.c
@@ -60,19 +60,29 @@ int sys_read(int fhdl, char *buf, size_t count) {
int rd = (int) SEGGER_RTT_Read(0, buf, count);
return (rd > 0) ? rd : -1;
}
-
#endif
#elif defined(LOGGER_SWO)
-// Logging with SWO for ARM Cortex
-#include "board_mcu.h"
+#define ITM_BASE 0xE0000000
+#define ITM_STIM0 (*((volatile uint8_t*)(ITM_BASE + 0)))
+#define ITM_TER *((volatile uint32_t*)(ITM_BASE + 0xE00))
+#define ITM_TCR *((volatile uint32_t*)(ITM_BASE + 0xE80))
+
+#define ITM_TCR_ITMENA (1 << 0)
+
+// Logging with SWO for ARM Cortex-M
int sys_write (int fhdl, const char *buf, size_t count) {
(void) fhdl;
uint8_t const* buf8 = (uint8_t const*) buf;
- for(size_t i=0; i<count; i++) {
- ITM_SendChar(buf8[i]);
+ if ((ITM_TCR & ITM_TCR_ITMENA) && (ITM_TER & 1ul)) {
+ for(size_t i=0; i < count; i++) {
+ while (!(ITM_STIM0 & 1ul)) {
+ asm("nop");
+ }
+ ITM_STIM0 = buf8[i];
+ }
}
return (int) count;
@@ -138,6 +148,9 @@ int board_getchar(void) {
return (sys_read(0, &c, 1) > 0) ? (int) c : (-1);
}
+void board_putchar(int c) {
+ sys_write(0, (const char*)&c, 1);
+}
uint32_t tusb_time_millis_api(void) {
return board_millis();
@@ -146,7 +159,7 @@ uint32_t tusb_time_millis_api(void) {
//--------------------------------------------------------------------
// FreeRTOS hooks
//--------------------------------------------------------------------
-#if CFG_TUSB_OS == OPT_OS_FREERTOS && !TUSB_MCU_VENDOR_ESPRESSIF
+#if CFG_TUSB_OS == OPT_OS_FREERTOS && !defined(ESP_PLATFORM)
#include "FreeRTOS.h"
#include "task.h"
@@ -228,5 +241,4 @@ void vApplicationSetupTimerInterrupt(void) {
}
#endif
-
#endif