Demo code minor BioRobotics 2016 University of Twente, Enschede, NL Verify that MODSERIAL is working again.
main.cpp@0:d777b0d1b461, 2016-09-12 (annotated)
- Committer:
- megrootens
- Date:
- Mon Sep 12 15:00:59 2016 +0000
- Revision:
- 0:d777b0d1b461
Verify that MODSERIAL is working again.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
megrootens | 0:d777b0d1b461 | 1 | /** |
megrootens | 0:d777b0d1b461 | 2 | * Quick check to verify that indeed MODSERIAL is working again. |
megrootens | 0:d777b0d1b461 | 3 | */ |
megrootens | 0:d777b0d1b461 | 4 | |
megrootens | 0:d777b0d1b461 | 5 | #include "mbed.h" |
megrootens | 0:d777b0d1b461 | 6 | #include "MODSERIAL.h" |
megrootens | 0:d777b0d1b461 | 7 | |
megrootens | 0:d777b0d1b461 | 8 | #define SERIAL_BAUD 115200 |
megrootens | 0:d777b0d1b461 | 9 | |
megrootens | 0:d777b0d1b461 | 10 | MODSERIAL pc(USBTX,USBRX); |
megrootens | 0:d777b0d1b461 | 11 | DigitalOut led(LED_RED); |
megrootens | 0:d777b0d1b461 | 12 | |
megrootens | 0:d777b0d1b461 | 13 | // period with which Foo() is to be called |
megrootens | 0:d777b0d1b461 | 14 | const float kPeriodFoo = 1.0f; |
megrootens | 0:d777b0d1b461 | 15 | |
megrootens | 0:d777b0d1b461 | 16 | /** |
megrootens | 0:d777b0d1b461 | 17 | * Foo function. |
megrootens | 0:d777b0d1b461 | 18 | * @ensure foobar. |
megrootens | 0:d777b0d1b461 | 19 | */ |
megrootens | 0:d777b0d1b461 | 20 | void Foo() |
megrootens | 0:d777b0d1b461 | 21 | { |
megrootens | 0:d777b0d1b461 | 22 | led = !led; |
megrootens | 0:d777b0d1b461 | 23 | pc.printf("led is %s\r\n",led?"OFF":"ON"); |
megrootens | 0:d777b0d1b461 | 24 | } |
megrootens | 0:d777b0d1b461 | 25 | |
megrootens | 0:d777b0d1b461 | 26 | /** |
megrootens | 0:d777b0d1b461 | 27 | * Main function. |
megrootens | 0:d777b0d1b461 | 28 | */ |
megrootens | 0:d777b0d1b461 | 29 | int main() |
megrootens | 0:d777b0d1b461 | 30 | { |
megrootens | 0:d777b0d1b461 | 31 | pc.baud(SERIAL_BAUD); |
megrootens | 0:d777b0d1b461 | 32 | pc.printf("\r\n**RESET**\r\n"); |
megrootens | 0:d777b0d1b461 | 33 | |
megrootens | 0:d777b0d1b461 | 34 | Ticker tick_foo; |
megrootens | 0:d777b0d1b461 | 35 | tick_foo.attach(&Foo,kPeriodFoo); |
megrootens | 0:d777b0d1b461 | 36 | |
megrootens | 0:d777b0d1b461 | 37 | while (true); |
megrootens | 0:d777b0d1b461 | 38 | } |