Export for MBed Studio

Dependencies:   mbed BufferedSerial

Committer:
sng_hws
Date:
Wed May 19 15:42:21 2021 +0000
Revision:
2:1b1e6624f699
Parent:
1:4240ddc51d40
Export for MBed Studio

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sng_hws 0:470c515449a7 1 #include "mbed.h"
sng_hws 2:1b1e6624f699 2 #include "BufferedSerial.h"
sng_hws 2:1b1e6624f699 3
sng_hws 2:1b1e6624f699 4 BufferedSerial pc(USBTX, USBRX);
sng_hws 2:1b1e6624f699 5
sng_hws 2:1b1e6624f699 6 int main()
sng_hws 2:1b1e6624f699 7 {
sng_hws 2:1b1e6624f699 8 pc.baud(115200);
sng_hws 2:1b1e6624f699 9
sng_hws 2:1b1e6624f699 10 while(1)
sng_hws 2:1b1e6624f699 11 {
sng_hws 2:1b1e6624f699 12 Timer s;
sng_hws 2:1b1e6624f699 13
sng_hws 2:1b1e6624f699 14 s.start();
sng_hws 2:1b1e6624f699 15 pc.printf("Hello World - buff\n");
sng_hws 2:1b1e6624f699 16 int buffered_time = s.read_us();
sng_hws 2:1b1e6624f699 17 wait(0.1f); // give time for the buffer to empty
sng_hws 2:1b1e6624f699 18
sng_hws 2:1b1e6624f699 19 s.reset();
sng_hws 2:1b1e6624f699 20 printf("Hello World - poll\n");
sng_hws 2:1b1e6624f699 21 int polled_time = s.read_us();
sng_hws 2:1b1e6624f699 22 s.stop();
sng_hws 2:1b1e6624f699 23 wait(0.1f); // give time for the buffer to empty
sng_hws 2:1b1e6624f699 24
sng_hws 2:1b1e6624f699 25 pc.printf("printf buffered took %d us\n", buffered_time);
sng_hws 2:1b1e6624f699 26 pc.printf("printf polled took %d us\n", polled_time);
sng_hws 2:1b1e6624f699 27 wait(0.5f);
sng_hws 2:1b1e6624f699 28 }
sng_hws 2:1b1e6624f699 29 }