My goal is to redirect the stdio
and iostream
to my UART.
My main.cpp
is pretty simple:
#include <uart.h>
#include <iostream>
int main() {
uart_init();
while (true) {
std::cout << "test" << std::endl;
for (int i = 0; i < 180000; ++i);
}
}
I would expect to have to include something like:
#include <stdio.h>
int fputc(int ch, FILE *f)
{
uart_write(static_cast<char>(ch));
return ch;
}
But the project builds without it and not surprisingly doesn’t output anything as it doesn’t know which IO to use.
My platformio.ini
:
[env:disco_f407vg]
platform = ststm32
board = disco_f407vg
framework = cmsis
upload_protocol = jlink
debug_tool = jlink
build_flags = -O0 --specs=nano.specs
build_type = debug