2024-10-15 14:43:24 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the Trezor project, https://trezor.io/
|
|
|
|
*
|
|
|
|
* Copyright (c) SatoshiLabs
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2020-11-27 10:32:29 +00:00
|
|
|
#ifdef SYSTEM_VIEW
|
|
|
|
|
2020-12-07 03:45:29 +00:00
|
|
|
#include "systemview.h"
|
2020-12-11 15:45:10 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include "mpconfigport.h"
|
2020-11-27 10:32:29 +00:00
|
|
|
|
|
|
|
#include "SEGGER_SYSVIEW.h"
|
2020-12-08 15:02:55 +00:00
|
|
|
#include "SEGGER_SYSVIEW_Conf.h"
|
2020-11-27 10:32:29 +00:00
|
|
|
|
|
|
|
void enable_systemview() {
|
2020-12-08 15:02:55 +00:00
|
|
|
SEGGER_SYSVIEW_Conf();
|
|
|
|
SEGGER_SYSVIEW_Start();
|
2020-11-27 10:32:29 +00:00
|
|
|
}
|
|
|
|
|
2021-01-26 15:49:09 +00:00
|
|
|
#ifdef SYSTEMVIEW_DEST_RTT
|
2020-12-11 15:45:10 +00:00
|
|
|
size_t _write(int file, const void *ptr, size_t len);
|
2021-01-26 15:49:09 +00:00
|
|
|
#endif
|
2020-12-11 15:45:10 +00:00
|
|
|
|
|
|
|
size_t segger_print(const char *str, size_t len) {
|
2021-01-26 15:49:09 +00:00
|
|
|
#ifdef SYSTEMVIEW_DEST_SYSTEMVIEW
|
2020-12-11 15:45:10 +00:00
|
|
|
static char str_copy[1024];
|
|
|
|
size_t copylen = len > 1023 ? 1023 : len;
|
|
|
|
memcpy(str_copy, str, copylen);
|
|
|
|
str_copy[copylen] = 0;
|
|
|
|
SEGGER_SYSVIEW_Print(str_copy);
|
|
|
|
return len;
|
2021-01-26 15:49:09 +00:00
|
|
|
#endif
|
|
|
|
#ifdef SYSTEMVIEW_DEST_RTT
|
2020-12-11 15:45:10 +00:00
|
|
|
_write(0, str, len);
|
|
|
|
return len;
|
|
|
|
#endif
|
|
|
|
}
|
2020-11-27 10:32:29 +00:00
|
|
|
#endif
|