
A trivial example of a UART comm. Works on all Nucleos.
Dependencies: mbed
main.cpp
- Committer:
- Foxnec
- Date:
- 2015-03-05
- Revision:
- 0:389db7a2ed7f
- Child:
- 1:a149bb0c3d05
File content as of revision 0:389db7a2ed7f:
#include "mbed.h" //------------------------------------ // Hyperterminal configuration // 9600 bauds, 8-bit data, no parity //------------------------------------ void flushSerialPort(Serial* port); Serial pc(SERIAL_TX, SERIAL_RX); DigitalOut myled(LED1); int main() { pc.baud(115200); int i = 1; int q; pc.printf("Hello World !\n"); while(1) { wait(5); pc.printf("This program runs since %d seconds.\n", i++); myled = !myled; flushSerialPort(&pc); if (pc.scanf("%d", &q)) pc.printf("%d\n", q); } } void flushSerialPort(Serial* port) { while((*port).readable()) { (*port).getc(); } return; }