Buffered, bidirectional transfer through the default Serial channel

Dependencies:   mbed BufferedSerial

main.cpp

Committer:
cspista
Date:
2021-12-16
Revision:
0:8c6fe9fb4192

File content as of revision 0:8c6fe9fb4192:


/*
 * Use: BufferedSerial library
 * adopted for STM32F4 series by  Veysel KARADAG
 * https://os.mbed.com/users/veyselka/code/BufferedSerial/
 */
#include "mbed.h"
#include "BufferedSerial.h"

BufferedSerial pc(USBTX, USBRX, 1024);

int main()
{
    pc.printf("\r\nWelcome to NUCLEO-F446RE board!\r\n");
    while(1) {
        if(pc.readable() > 0) {
            char c = pc.getc(); //Read one character
            if((c>32) && (c<128)) {
                pc.printf("received char: %c = %d\r\n",c,c);
            }
        }
    }
}