Zhengyang Gu / Mbed 2 deprecated C027_ModemTransparentSerial_BBB

Dependencies:   mbed

Fork of C027_ModemTransparentSerial by u-blox

main.cpp

Committer:
mazgch
Date:
2013-10-25
Revision:
2:1970ac045983
Parent:
1:7334dcb895d0
Child:
4:fafdcaf842ee

File content as of revision 2:1970ac045983:

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

int main() 
{
    C027 c027;
    c027.mdmPower(true);
    
    // open the mdm serial port
    Serial mdm(MDMTXD, MDMRXD);
    mdm.baud(MDMBAUD);
    // tell the modem that we can always receive data
    DigitalOut mdmRts(MDMRTS);
    mdmRts = 0; // (not using flow control)
    
    // open the PC serial port and (use the same baudrate)
    Serial pc(USBTX, USBRX);
    pc.baud(MDMBAUD);
    
    while (1)
    {
        // transfer data from pc to modem
        if (pc.readable() && mdm.writeable())
            mdm.putc(pc.getc());
        // transfer data from modem to pc
        if (mdm.readable() && pc.writeable())
            pc.putc(mdm.getc());
    }
}