Echo characters on a serial port using the MultiTech Dragonfly.
Dependencies: mbed
main.cpp@1:ded5da421bd0, 2016-02-26 (annotated)
- Committer:
- mfiore
- Date:
- Fri Feb 26 16:56:54 2016 +0000
- Revision:
- 1:ded5da421bd0
- Parent:
- 0:d88fbcdff4fb
Updated mbed library to revision 112, disable regulator's battery charger
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mfiore | 0:d88fbcdff4fb | 1 | /** Dragonfly Serial Example Program |
mfiore | 0:d88fbcdff4fb | 2 | * |
mfiore | 0:d88fbcdff4fb | 3 | * This program demonstrates how to do handle a serial port |
mfiore | 0:d88fbcdff4fb | 4 | * using the MultiTech Dragonfly and MultiTech UDK2 hardware. |
mfiore | 0:d88fbcdff4fb | 5 | * |
mfiore | 0:d88fbcdff4fb | 6 | * This program echos characters on the debug serial port. |
mfiore | 0:d88fbcdff4fb | 7 | * The debug serial port is operated at the default baud, 9600. |
mfiore | 0:d88fbcdff4fb | 8 | * Connect your terminal application to the appropriate COM/tty |
mfiore | 0:d88fbcdff4fb | 9 | * port on your PC. See https://developer.mbed.org/handbook/SerialPC |
mfiore | 0:d88fbcdff4fb | 10 | * for details. |
mfiore | 0:d88fbcdff4fb | 11 | */ |
mfiore | 0:d88fbcdff4fb | 12 | |
mfiore | 0:d88fbcdff4fb | 13 | #include "mbed.h" |
mfiore | 1:ded5da421bd0 | 14 | |
mfiore | 1:ded5da421bd0 | 15 | // This line controls the regulator's battery charger. |
mfiore | 1:ded5da421bd0 | 16 | // BC_NCE = 0 enables the battery charger |
mfiore | 1:ded5da421bd0 | 17 | // BC_NCE = 1 disables the battery charger |
mfiore | 1:ded5da421bd0 | 18 | DigitalOut bc_nce(PB_2); |
mfiore | 0:d88fbcdff4fb | 19 | |
mfiore | 0:d88fbcdff4fb | 20 | int main() { |
mfiore | 1:ded5da421bd0 | 21 | // Disable the battery charger unless a battery is attached. |
mfiore | 1:ded5da421bd0 | 22 | bc_nce = 1; |
mfiore | 1:ded5da421bd0 | 23 | |
mfiore | 0:d88fbcdff4fb | 24 | Serial pc(USBTX, USBRX); |
mfiore | 0:d88fbcdff4fb | 25 | |
mfiore | 0:d88fbcdff4fb | 26 | while (true) |
mfiore | 0:d88fbcdff4fb | 27 | if (pc.readable()) |
mfiore | 0:d88fbcdff4fb | 28 | pc.putc(pc.getc()); |
mfiore | 0:d88fbcdff4fb | 29 | } |