Skip to content

Commit 0996a9e

Browse files
authored
Add support for SEGGER RTT STDIO (updated) (#1411)
1 parent c93c3f4 commit 0996a9e

File tree

11 files changed

+3158
-7
lines changed

11 files changed

+3158
-7
lines changed

src/rp2_common/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ if (NOT PICO_BARE_METAL)
5555
pico_add_subdirectory(pico_stdio)
5656
pico_add_subdirectory(pico_stdio_semihosting)
5757
pico_add_subdirectory(pico_stdio_uart)
58+
pico_add_subdirectory(pico_stdio_rtt)
5859

5960
pico_add_subdirectory(cmsis)
6061
pico_add_subdirectory(tinyusb)
@@ -85,4 +86,4 @@ set(CMAKE_EXECUTABLE_SUFFIX "${CMAKE_EXECUTABLE_SUFFIX}" PARENT_SCOPE)
8586
pico_add_doxygen(${CMAKE_CURRENT_LIST_DIR})
8687
pico_add_doxygen_exclude(${CMAKE_CURRENT_LIST_DIR}/cmsis)
8788

88-
pico_promote_common_scope_vars()
89+
pico_promote_common_scope_vars()

src/rp2_common/pico_stdio/include/pico/stdio.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ typedef struct stdio_driver stdio_driver_t;
5151
/*! \brief Initialize all of the present standard stdio types that are linked into the binary.
5252
* \ingroup pico_stdio
5353
*
54-
* Call this method once you have set up your clocks to enable the stdio support for UART, USB
55-
* and semihosting based on the presence of the respective libraries in the binary.
54+
* Call this method once you have set up your clocks to enable the stdio support for UART, USB,
55+
* semihosting, and RTT based on the presence of the respective libraries in the binary.
5656
*
5757
* When stdio_usb is configured, this method can be optionally made to block, waiting for a connection
5858
* via the variables specified in \ref stdio_usb_init (i.e. \ref PICO_STDIO_USB_CONNECT_WAIT_TIMEOUT_MS)
5959
*
6060
* \return true if at least one output was successfully initialized, false otherwise.
61-
* \see stdio_uart, stdio_usb, stdio_semihosting
61+
* \see stdio_uart, stdio_usb, stdio_semihosting, stdio_rtt
6262
*/
6363
bool stdio_init_all(void);
6464

src/rp2_common/pico_stdio/stdio.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@
3232
#include "pico/stdio_semihosting.h"
3333
#endif
3434

35+
#if LIB_PICO_STDIO_RTT
36+
#include "pico/stdio_rtt.h"
37+
#endif
38+
3539
#define STDIO_HANDLE_STDIN 0
3640
#define STDIO_HANDLE_STDOUT 1
3741
#define STDIO_HANDLE_STDERR 2
@@ -295,6 +299,11 @@ bool stdio_init_all(void) {
295299
rc = true;
296300
#endif
297301

302+
#if LIB_PICO_STDIO_RTT
303+
stdio_rtt_init();
304+
rc = true;
305+
#endif
306+
298307
#if LIB_PICO_STDIO_USB
299308
rc |= stdio_usb_init();
300309
#endif
@@ -331,7 +340,7 @@ void stdio_set_translate_crlf(stdio_driver_t *driver, bool enabled) {
331340
// Suppress -Wunused-parameter
332341
(void)driver;
333342
(void)enabled;
334-
343+
335344
panic_unsupported();
336345
#endif
337346
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
pico_add_library(pico_stdio_rtt)
2+
3+
target_sources(pico_stdio_rtt INTERFACE
4+
${CMAKE_CURRENT_LIST_DIR}/stdio_rtt.c
5+
${CMAKE_CURRENT_LIST_DIR}/SEGGER/RTT/SEGGER_RTT.c)
6+
7+
set_source_files_properties(${CMAKE_CURRENT_LIST_DIR}/SEGGER/RTT/SEGGER_RTT.c
8+
PROPERTIES COMPILE_OPTIONS "-Wno-cast-qual;-Wno-cast-align")
9+
10+
target_include_directories(pico_stdio_rtt_headers INTERFACE
11+
${CMAKE_CURRENT_LIST_DIR}/include
12+
${CMAKE_CURRENT_LIST_DIR}/SEGGER/RTT
13+
${CMAKE_CURRENT_LIST_DIR}/SEGGER/Config)
14+
15+
pico_mirrored_target_link_libraries(pico_stdio_rtt INTERFACE pico_stdio)

src/rp2_common/pico_stdio_rtt/SEGGER/Config/SEGGER_RTT_Conf.h

Lines changed: 429 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)