Setup stdio to use RTT for debug purposes
This commit is contained in:
parent
f7b10dd6d6
commit
84c5da36ba
3
.gitmodules
vendored
3
.gitmodules
vendored
|
@ -1,3 +1,6 @@
|
|||
[submodule "lib/pico-sdk"]
|
||||
path = lib/pico-sdk
|
||||
url = https://github.com/raspberrypi/pico-sdk
|
||||
[submodule "lib/rtt"]
|
||||
path = lib/rtt
|
||||
url = https://github.com/adfernandes/segger-rtt
|
||||
|
|
|
@ -7,7 +7,13 @@ project(vibe-check)
|
|||
|
||||
pico_sdk_init()
|
||||
|
||||
include_directories(
|
||||
${CMAKE_SOURCE_DIR}/lib/rtt/RTT
|
||||
)
|
||||
|
||||
add_executable(vibe-check
|
||||
lib/rtt/RTT/SEGGER_RTT.c
|
||||
src/stdio_rtt.c
|
||||
src/main.c
|
||||
)
|
||||
|
||||
|
|
1
lib/rtt
Submodule
1
lib/rtt
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit 660fa2589a67cc87c9a112e405531c53b77504ad
|
|
@ -1,7 +1,7 @@
|
|||
{ pkgs ? import <nixpkgs> {} }:
|
||||
pkgs.mkShell {
|
||||
buildInputs = with pkgs; [
|
||||
cmake ninja python3 gcc-arm-embedded
|
||||
cmake cmakeCurses ninja python3 gcc-arm-embedded
|
||||
picotool
|
||||
];
|
||||
}
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
#include <stdio.h>
|
||||
#include "pico/stdlib.h"
|
||||
#include "pico/cyw43_arch.h"
|
||||
#include "btstack.h"
|
||||
#include "stdio_rtt.h"
|
||||
|
||||
// #include "btstack.h"
|
||||
|
||||
#ifndef CYW43_WL_GPIO_LED_PIN
|
||||
#error no WiFi LED on board, wrong -DPICO_BOARD?
|
||||
|
@ -11,7 +13,9 @@
|
|||
// https://github.com/buttplugio/buttplug/blob/master/buttplug/src/server/device/protocol/sakuraneko.rs
|
||||
|
||||
int main() {
|
||||
stdio_init_all();
|
||||
// stdio_init_all();
|
||||
stdio_rtt_init();
|
||||
|
||||
if (cyw43_arch_init()) {
|
||||
printf("WiFi init failed");
|
||||
return -1;
|
||||
|
|
20
src/stdio_rtt.c
Normal file
20
src/stdio_rtt.c
Normal file
|
@ -0,0 +1,20 @@
|
|||
#include "pico/stdio/driver.h"
|
||||
#include "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,
|
||||
};
|
8
src/stdio_rtt.h
Normal file
8
src/stdio_rtt.h
Normal file
|
@ -0,0 +1,8 @@
|
|||
#ifndef STDIO_RTT_H
|
||||
#define STDIO_RTT_H
|
||||
#include "pico/stdio.h"
|
||||
|
||||
extern stdio_driver_t stdio_rtt;
|
||||
void stdio_rtt_init(void);
|
||||
|
||||
#endif
|
Loading…
Reference in a new issue