1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-22 23:48:12 +00:00

chore(core): rework SYSTEMVIEW_DEST_SYSTEMVIEW

to work with ifdef instead of if
This commit is contained in:
Pavol Rusnak 2021-01-26 16:49:09 +01:00
parent b9e8a7c999
commit a11cb11ba3
2 changed files with 9 additions and 4 deletions

View File

@ -158,8 +158,10 @@
#ifdef SYSTEM_VIEW #ifdef SYSTEM_VIEW
#define MP_PLAT_PRINT_STRN(str, len) segger_print(str, len) #define MP_PLAT_PRINT_STRN(str, len) segger_print(str, len)
// set following to 0 if you want to print to RTT instead of SystemView // uncomment DEST_RTT and comment DEST_SYSTEMVIEW
// openocd supports only the RTT output method // if you want to print to RTT instead of SystemView
// OpenOCD supports only the RTT output method
// #define SYSTEMVIEW_DEST_RTT (1)
#define SYSTEMVIEW_DEST_SYSTEMVIEW (1) #define SYSTEMVIEW_DEST_SYSTEMVIEW (1)
#endif #endif

View File

@ -93,17 +93,20 @@ void enable_systemview() {
SYSTICK->CSR = 0x07; // enable systick SYSTICK->CSR = 0x07; // enable systick
} }
#ifdef SYSTEMVIEW_DEST_RTT
size_t _write(int file, const void *ptr, size_t len); size_t _write(int file, const void *ptr, size_t len);
#endif
size_t segger_print(const char *str, size_t len) { size_t segger_print(const char *str, size_t len) {
#if SYSTEMVIEW_DEST_SYSTEMVIEW #ifdef SYSTEMVIEW_DEST_SYSTEMVIEW
static char str_copy[1024]; static char str_copy[1024];
size_t copylen = len > 1023 ? 1023 : len; size_t copylen = len > 1023 ? 1023 : len;
memcpy(str_copy, str, copylen); memcpy(str_copy, str, copylen);
str_copy[copylen] = 0; str_copy[copylen] = 0;
SEGGER_SYSVIEW_Print(str_copy); SEGGER_SYSVIEW_Print(str_copy);
return len; return len;
#else #endif
#ifdef SYSTEMVIEW_DEST_RTT
_write(0, str, len); _write(0, str, len);
return len; return len;
#endif #endif