#riot_os: stdio on an #STM32F411

OK, so I’ve finally figured out how to read stdin using the Riot OS. I’m using a Nucleo STM32 board.

In your Makefile:

USEMODULE += stdio_uart_rx

Then your C file might look something like this:

#include <periph/uart.h>

int main(void)
        puts("I will now echo characters to screen");
        int count = 0;
        while(1) {
                int c = getchar();
                if(c<0) puts("received char is negative. Hmmm");
                printf("Count:%d, '%c', dec:%d\n", count++, c, c);

Calls to getchar() are blocking, which is fine for now. There appears to be a way to do non-blocking reads, too.

Everything seems to work. Note that pushing non-standard keys like arrow keys will generate several characters. You will see them printed out. This may be useful to know.

You can find the code here.

I wish the documentation to Riot was a bit better, to be honest.

About mcturra2000

Computer programmer living in Scotland.
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s