forked from raspberrypi/pico-sdk
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use RTT as a module, rebased from raspberrypi#775, with compiler fixes
- Loading branch information
1 parent
5d47872
commit e93adc6
Showing
10 changed files
with
125 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,6 @@ | |
[submodule "lib/btstack"] | ||
path = lib/btstack | ||
url = https://github.com/bluekitchen/btstack.git | ||
[submodule "lib/rtt"] | ||
path = lib/rtt | ||
url = [email protected]:adfernandes/segger-rtt.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
pico_add_library(pico_stdio_rtt) | ||
|
||
target_sources(pico_stdio_rtt | ||
INTERFACE | ||
stdio_rtt.c | ||
segger_rtt.c | ||
) | ||
|
||
if (CMAKE_C_COMPILER_ID STREQUAL "GNU") | ||
set_source_files_properties(segger_rtt.c PROPERTIES COMPILE_OPTIONS "-Wno-cast-align;-Wno-cast-qual") | ||
endif() | ||
|
||
target_include_directories(pico_stdio_rtt_headers | ||
INTERFACE | ||
./include | ||
../../../lib/rtt/RTT | ||
) | ||
|
||
pico_mirrored_target_link_libraries(pico_stdio_rtt INTERFACE pico_stdio) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright (c) 2020 Raspberry Pi (Trading) Ltd. | ||
* | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
*/ | ||
|
||
#ifndef _PICO_STDIO_RTT_H | ||
#define _PICO_STDIO_RTT_H | ||
|
||
#include "pico/stdio.h" | ||
|
||
/** \brief Support for stdin/stdout using SEGGER RTT | ||
* \defgroup pico_stdio_rtt pico_stdio_rtt | ||
* \ingroup pico_stdio | ||
* | ||
* Linking this library or calling `pico_enable_stdio_rtt(TARGET)` in the CMake (which | ||
* achieves the same thing) will add RTT to the drivers used for standard output | ||
*/ | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
extern stdio_driver_t stdio_rtt; | ||
|
||
/*! \brief Explicitly initialize stdin/stdout over RTT and add it to the current set of stdin/stdout drivers | ||
* \ingroup pico_stdio_rtt | ||
* | ||
* \note this method is automatically called by \ref stdio_init_all() if `pico_stdio_rtt` is included in the build | ||
*/ | ||
void stdio_rtt_init(void); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* | ||
We use this round-about way of including the Segger RTT source file | ||
because we need to suppress the "cast-align" and "cast-qual" warnings, | ||
and cmake will not let us change the COMPILE_OPTIONS for a single | ||
source file if the target has one source file in the current directory tree | ||
and another source file in a directory outside the current directory tree. | ||
See https://gitlab.kitware.com/cmake/cmake/-/issues/20128 for more details. | ||
*/ | ||
#include "../../../lib/rtt/RTT/SEGGER_RTT.c" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright (c) 2020 Raspberry Pi (Trading) Ltd. | ||
* | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
*/ | ||
|
||
#include "pico/stdio/driver.h" | ||
#include "pico/stdio_rtt.h" | ||
#include "SEGGER_RTT.h" | ||
|
||
void stdio_rtt_init(void) { | ||
stdio_set_driver_enabled(&stdio_rtt, true); | ||
} | ||
|
||
static void stdio_rtt_out_chars(const char *buf, int length) { | ||
SEGGER_RTT_Write(0, buf, length); | ||
} | ||
|
||
static int stdio_rtt_in_chars(char *buf, int length) { | ||
return SEGGER_RTT_Read(0, buf, length); | ||
} | ||
|
||
stdio_driver_t stdio_rtt = { | ||
.out_chars = stdio_rtt_out_chars, | ||
.in_chars = stdio_rtt_in_chars, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters