Buffered, bidirectional transfer through the default Serial channel
Dependencies: mbed BufferedSerial
main.cpp@0:8c6fe9fb4192, 2021-12-16 (annotated)
- Committer:
- cspista
- Date:
- Thu Dec 16 12:37:54 2021 +0000
- Revision:
- 0:8c6fe9fb4192
Final version
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
cspista | 0:8c6fe9fb4192 | 1 | |
cspista | 0:8c6fe9fb4192 | 2 | /* |
cspista | 0:8c6fe9fb4192 | 3 | * Use: BufferedSerial library |
cspista | 0:8c6fe9fb4192 | 4 | * adopted for STM32F4 series by Veysel KARADAG |
cspista | 0:8c6fe9fb4192 | 5 | * https://os.mbed.com/users/veyselka/code/BufferedSerial/ |
cspista | 0:8c6fe9fb4192 | 6 | */ |
cspista | 0:8c6fe9fb4192 | 7 | #include "mbed.h" |
cspista | 0:8c6fe9fb4192 | 8 | #include "BufferedSerial.h" |
cspista | 0:8c6fe9fb4192 | 9 | |
cspista | 0:8c6fe9fb4192 | 10 | BufferedSerial pc(USBTX, USBRX, 1024); |
cspista | 0:8c6fe9fb4192 | 11 | |
cspista | 0:8c6fe9fb4192 | 12 | int main() |
cspista | 0:8c6fe9fb4192 | 13 | { |
cspista | 0:8c6fe9fb4192 | 14 | pc.printf("\r\nWelcome to NUCLEO-F446RE board!\r\n"); |
cspista | 0:8c6fe9fb4192 | 15 | while(1) { |
cspista | 0:8c6fe9fb4192 | 16 | if(pc.readable() > 0) { |
cspista | 0:8c6fe9fb4192 | 17 | char c = pc.getc(); //Read one character |
cspista | 0:8c6fe9fb4192 | 18 | if((c>32) && (c<128)) { |
cspista | 0:8c6fe9fb4192 | 19 | pc.printf("received char: %c = %d\r\n",c,c); |
cspista | 0:8c6fe9fb4192 | 20 | } |
cspista | 0:8c6fe9fb4192 | 21 | } |
cspista | 0:8c6fe9fb4192 | 22 | } |
cspista | 0:8c6fe9fb4192 | 23 | } |