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

main.cpp

Committer:
dixter1
Date:
2013-12-15
Revision:
1:ce52702074c2
Parent:
0:7ac9848b2e4b

File content as of revision 1:ce52702074c2:

#include "mbed.h"
#include "C027.h"

DigitalOut mdm_activity(LED);

int main() 
{
    int led_toggle_count = 5;
   
#if 0
    while(1) {
        mdm_activity = !mdm_activity;
        wait(0.2);
    }
#else
    while( led_toggle_count-- > 0 )
    {
        mdm_activity = !mdm_activity;
        wait(0.2);
    }
#endif

    // open the external serial port
    Serial m3(D1, D0);
    m3.baud(MDMBAUD);
    
    // open the USB console port and (use the same baudrate)
    Serial pc(USBTX, USBRX);
    pc.baud(MDMBAUD);
    
    if ( m3.writeable() ) pc.printf("m3 is writable\r\n");
    if ( m3.readable() ) pc.printf("m3 is readable\r\n");
    
    pc.printf( "M3->EXT UART connection ready\r\n");
    
    m3.printf( "TESTING\r\n");
    
    while (1)
    {
        // transfer data from pc to modem
        if (pc.readable() && m3.writeable())
            m3.putc(pc.getc());
        // transfer data from modem to pc
        if (m3.readable() && pc.writeable()) 
            pc.putc(m3.getc());
    }
}