Dheeraj Kamath
/
BlinkyUart
Toggles LED and prints debug information
main.cpp@0:19ea743b1bfa, 2019-05-26 (annotated)
- Committer:
- Dheeraj22
- Date:
- Sun May 26 17:16:14 2019 +0000
- Revision:
- 0:19ea743b1bfa
- Child:
- 1:e4d41670a405
Debug information added.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Dheeraj22 | 0:19ea743b1bfa | 1 | /* mbed Microcontroller Library |
Dheeraj22 | 0:19ea743b1bfa | 2 | * Copyright (c) 2018 ARM Limited |
Dheeraj22 | 0:19ea743b1bfa | 3 | * SPDX-License-Identifier: Apache-2.0 |
Dheeraj22 | 0:19ea743b1bfa | 4 | */ |
Dheeraj22 | 0:19ea743b1bfa | 5 | |
Dheeraj22 | 0:19ea743b1bfa | 6 | #include "mbed.h" |
Dheeraj22 | 0:19ea743b1bfa | 7 | |
Dheeraj22 | 0:19ea743b1bfa | 8 | DigitalOut led1(LED1); |
Dheeraj22 | 0:19ea743b1bfa | 9 | RawSerial my_uart(UART_TX, UART_RX); |
Dheeraj22 | 0:19ea743b1bfa | 10 | |
Dheeraj22 | 0:19ea743b1bfa | 11 | #define SLEEP_TIME 500 // (msec) |
Dheeraj22 | 0:19ea743b1bfa | 12 | |
Dheeraj22 | 0:19ea743b1bfa | 13 | // main() runs in its own thread in the OS |
Dheeraj22 | 0:19ea743b1bfa | 14 | int main() |
Dheeraj22 | 0:19ea743b1bfa | 15 | { |
Dheeraj22 | 0:19ea743b1bfa | 16 | //Change Baud Rate |
Dheeraj22 | 0:19ea743b1bfa | 17 | my_uart.baud(115200); |
Dheeraj22 | 0:19ea743b1bfa | 18 | my_uart.printf("%s\n\r", "UART Initialized"); |
Dheeraj22 | 0:19ea743b1bfa | 19 | char* msg = "OFF"; |
Dheeraj22 | 0:19ea743b1bfa | 20 | |
Dheeraj22 | 0:19ea743b1bfa | 21 | while (true) { |
Dheeraj22 | 0:19ea743b1bfa | 22 | // Blink LED and wait 0.5 seconds |
Dheeraj22 | 0:19ea743b1bfa | 23 | led1 = !led1; |
Dheeraj22 | 0:19ea743b1bfa | 24 | led1 ? (msg = "OFF"):(msg = "ON"); |
Dheeraj22 | 0:19ea743b1bfa | 25 | my_uart.printf("LED STATE: %s\n\r", msg); |
Dheeraj22 | 0:19ea743b1bfa | 26 | wait_ms(SLEEP_TIME); |
Dheeraj22 | 0:19ea743b1bfa | 27 | } |
Dheeraj22 | 0:19ea743b1bfa | 28 | } |