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
- Loading branch information
1 parent
5d47872
commit b777b0a
Showing
9 changed files
with
107 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,13 @@ | ||
pico_add_impl_library(pico_stdio_rtt) | ||
|
||
target_sources(pico_stdio_rtt INTERFACE | ||
${CMAKE_CURRENT_LIST_DIR}/stdio_rtt.c | ||
${CMAKE_CURRENT_LIST_DIR}/../../../lib/SEGGER_RTT/RTT/SEGGER_RTT.c | ||
) | ||
|
||
target_include_directories(pico_stdio_rtt INTERFACE | ||
${CMAKE_CURRENT_LIST_DIR}/include | ||
${CMAKE_CURRENT_LIST_DIR}/../../../lib/SEGGER_RTT/RTT | ||
) | ||
|
||
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,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