Paul Jeon
/
serial-port-check
:D
serialPortCheck.cpp@0:e341ea4101e9, 2020-02-21 (annotated)
- Committer:
- mjoun
- Date:
- Fri Feb 21 18:57:13 2020 +0000
- Revision:
- 0:e341ea4101e9
good one;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mjoun | 0:e341ea4101e9 | 1 | /* mbed Microcontroller Library |
mjoun | 0:e341ea4101e9 | 2 | * Copyright (c) 2019 ARM Limited |
mjoun | 0:e341ea4101e9 | 3 | * SPDX-License-Identifier: Apache-2.0 |
mjoun | 0:e341ea4101e9 | 4 | */ |
mjoun | 0:e341ea4101e9 | 5 | |
mjoun | 0:e341ea4101e9 | 6 | #include "mbed.h" |
mjoun | 0:e341ea4101e9 | 7 | #include "USBSerial.h" |
mjoun | 0:e341ea4101e9 | 8 | |
mjoun | 0:e341ea4101e9 | 9 | // Blinking rate in milliseconds |
mjoun | 0:e341ea4101e9 | 10 | #define BLINKING_RATE_MS 500 |
mjoun | 0:e341ea4101e9 | 11 | |
mjoun | 0:e341ea4101e9 | 12 | // Virtual serial port over USB |
mjoun | 0:e341ea4101e9 | 13 | USBSerial microUSB; |
mjoun | 0:e341ea4101e9 | 14 | //Serial pc(USBTX, USBRX); |
mjoun | 0:e341ea4101e9 | 15 | char buf[40]; |
mjoun | 0:e341ea4101e9 | 16 | int main() |
mjoun | 0:e341ea4101e9 | 17 | { |
mjoun | 0:e341ea4101e9 | 18 | // Initialise the digital pin LED1 as an output |
mjoun | 0:e341ea4101e9 | 19 | DigitalOut led(LED1); |
mjoun | 0:e341ea4101e9 | 20 | |
mjoun | 0:e341ea4101e9 | 21 | while (true) { |
mjoun | 0:e341ea4101e9 | 22 | microUSB.scanf("%s", buf); |
mjoun | 0:e341ea4101e9 | 23 | led = !led; |
mjoun | 0:e341ea4101e9 | 24 | // pc.printf("regular serial communication works!"); |
mjoun | 0:e341ea4101e9 | 25 | microUSB.printf("you typed: %s\r\n",buf); |
mjoun | 0:e341ea4101e9 | 26 | //microUSB.printf("\x1B[2J"); //clear terminal program screen |
mjoun | 0:e341ea4101e9 | 27 | } |
mjoun | 0:e341ea4101e9 | 28 | } |