With this test, you can tie external TXD and RXD together, and on the USB console, see the characters entered be echo'd back. This is effectively a loopback test verifying the external hardware interface, through the USB console interface.

Dependencies:   C027-REVB mbed

Committer:
dixter1
Date:
Sun Dec 15 21:42:43 2013 +0000
Revision:
1:ce52702074c2
Parent:
0:7ac9848b2e4b
Library Update Only.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dixter1 0:7ac9848b2e4b 1 #include "mbed.h"
dixter1 0:7ac9848b2e4b 2 #include "C027.h"
dixter1 0:7ac9848b2e4b 3
dixter1 0:7ac9848b2e4b 4 DigitalOut mdm_activity(LED);
dixter1 0:7ac9848b2e4b 5
dixter1 0:7ac9848b2e4b 6 int main()
dixter1 0:7ac9848b2e4b 7 {
dixter1 0:7ac9848b2e4b 8 int led_toggle_count = 5;
dixter1 0:7ac9848b2e4b 9
dixter1 0:7ac9848b2e4b 10 #if 0
dixter1 0:7ac9848b2e4b 11 while(1) {
dixter1 0:7ac9848b2e4b 12 mdm_activity = !mdm_activity;
dixter1 0:7ac9848b2e4b 13 wait(0.2);
dixter1 0:7ac9848b2e4b 14 }
dixter1 0:7ac9848b2e4b 15 #else
dixter1 0:7ac9848b2e4b 16 while( led_toggle_count-- > 0 )
dixter1 0:7ac9848b2e4b 17 {
dixter1 0:7ac9848b2e4b 18 mdm_activity = !mdm_activity;
dixter1 0:7ac9848b2e4b 19 wait(0.2);
dixter1 0:7ac9848b2e4b 20 }
dixter1 0:7ac9848b2e4b 21 #endif
dixter1 0:7ac9848b2e4b 22
dixter1 0:7ac9848b2e4b 23 // open the external serial port
dixter1 0:7ac9848b2e4b 24 Serial m3(D1, D0);
dixter1 0:7ac9848b2e4b 25 m3.baud(MDMBAUD);
dixter1 0:7ac9848b2e4b 26
dixter1 0:7ac9848b2e4b 27 // open the USB console port and (use the same baudrate)
dixter1 0:7ac9848b2e4b 28 Serial pc(USBTX, USBRX);
dixter1 0:7ac9848b2e4b 29 pc.baud(MDMBAUD);
dixter1 0:7ac9848b2e4b 30
dixter1 0:7ac9848b2e4b 31 if ( m3.writeable() ) pc.printf("m3 is writable\r\n");
dixter1 0:7ac9848b2e4b 32 if ( m3.readable() ) pc.printf("m3 is readable\r\n");
dixter1 0:7ac9848b2e4b 33
dixter1 0:7ac9848b2e4b 34 pc.printf( "M3->EXT UART connection ready\r\n");
dixter1 0:7ac9848b2e4b 35
dixter1 0:7ac9848b2e4b 36 m3.printf( "TESTING\r\n");
dixter1 0:7ac9848b2e4b 37
dixter1 0:7ac9848b2e4b 38 while (1)
dixter1 0:7ac9848b2e4b 39 {
dixter1 0:7ac9848b2e4b 40 // transfer data from pc to modem
dixter1 0:7ac9848b2e4b 41 if (pc.readable() && m3.writeable())
dixter1 0:7ac9848b2e4b 42 m3.putc(pc.getc());
dixter1 0:7ac9848b2e4b 43 // transfer data from modem to pc
dixter1 0:7ac9848b2e4b 44 if (m3.readable() && pc.writeable())
dixter1 0:7ac9848b2e4b 45 pc.putc(m3.getc());
dixter1 0:7ac9848b2e4b 46 }
dixter1 0:7ac9848b2e4b 47 }