This program just echos back characters from the PC Console Interface. It does no further testing outside the M3 processor.
main.cpp@0:cd857d770d29, 2013-12-14 (annotated)
- Committer:
- dixter1
- Date:
- Sat Dec 14 01:22:44 2013 +0000
- Revision:
- 0:cd857d770d29
First pass this program. Simple serial echo.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dixter1 | 0:cd857d770d29 | 1 | #include "mbed.h" |
dixter1 | 0:cd857d770d29 | 2 | #include "C027.h" |
dixter1 | 0:cd857d770d29 | 3 | |
dixter1 | 0:cd857d770d29 | 4 | DigitalOut mdm_activity(LED); |
dixter1 | 0:cd857d770d29 | 5 | |
dixter1 | 0:cd857d770d29 | 6 | int main() |
dixter1 | 0:cd857d770d29 | 7 | { |
dixter1 | 0:cd857d770d29 | 8 | int led_toggle_count = 5; |
dixter1 | 0:cd857d770d29 | 9 | |
dixter1 | 0:cd857d770d29 | 10 | C027 c027; |
dixter1 | 0:cd857d770d29 | 11 | c027.mdmPower(true,false); |
dixter1 | 0:cd857d770d29 | 12 | |
dixter1 | 0:cd857d770d29 | 13 | #if 0 |
dixter1 | 0:cd857d770d29 | 14 | while(1) { |
dixter1 | 0:cd857d770d29 | 15 | mdm_activity = !mdm_activity; |
dixter1 | 0:cd857d770d29 | 16 | wait(0.2); |
dixter1 | 0:cd857d770d29 | 17 | } |
dixter1 | 0:cd857d770d29 | 18 | #else |
dixter1 | 0:cd857d770d29 | 19 | while( led_toggle_count-- > 0 ) |
dixter1 | 0:cd857d770d29 | 20 | { |
dixter1 | 0:cd857d770d29 | 21 | mdm_activity = !mdm_activity; |
dixter1 | 0:cd857d770d29 | 22 | wait(0.2); |
dixter1 | 0:cd857d770d29 | 23 | } |
dixter1 | 0:cd857d770d29 | 24 | #endif |
dixter1 | 0:cd857d770d29 | 25 | |
dixter1 | 0:cd857d770d29 | 26 | // open the mdm serial port |
dixter1 | 0:cd857d770d29 | 27 | Serial mdm(MDMTXD, MDMRXD); |
dixter1 | 0:cd857d770d29 | 28 | mdm.baud(MDMBAUD); |
dixter1 | 0:cd857d770d29 | 29 | // tell the modem that we can always receive data |
dixter1 | 0:cd857d770d29 | 30 | DigitalOut mdmRts(MDMRTS); |
dixter1 | 0:cd857d770d29 | 31 | mdmRts = 0; // (not using flow control) |
dixter1 | 0:cd857d770d29 | 32 | |
dixter1 | 0:cd857d770d29 | 33 | // open the PC serial port and (use the same baudrate) |
dixter1 | 0:cd857d770d29 | 34 | Serial pc(USBTX, USBRX); |
dixter1 | 0:cd857d770d29 | 35 | pc.baud(MDMBAUD); |
dixter1 | 0:cd857d770d29 | 36 | |
dixter1 | 0:cd857d770d29 | 37 | while (1) |
dixter1 | 0:cd857d770d29 | 38 | { |
dixter1 | 0:cd857d770d29 | 39 | // transfer data from pc to modem |
dixter1 | 0:cd857d770d29 | 40 | if (pc.readable() && pc.writeable()) |
dixter1 | 0:cd857d770d29 | 41 | pc.putc(pc.getc()); |
dixter1 | 0:cd857d770d29 | 42 | } |
dixter1 | 0:cd857d770d29 | 43 | } |