Zhengyang Gu / Mbed 2 deprecated C027_ModemTransparentSerial_BBB

Dependencies:   mbed

Fork of C027_ModemTransparentSerial by u-blox

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "C027_api.h"
00003 
00004 
00005 /* This example is establishing a transparent link between 
00006    the mbed serial port and the serial communication interface 
00007    of the Modem(MDM). 
00008    
00009    For a more advanced driver for the GPS or Modem(MDM) please 
00010    look at the follwing library and example:
00011    C027_Support Library 
00012      http://mbed.org/teams/ublox/code/C027_Support/
00013    C027_Support Example
00014      http://mbed.org/teams/ublox/code/C027_SupportTest/
00015 */
00016 int main() 
00017 {
00018     // setting the power on pin low while powering the device will turn it on
00019     DigitalOut pin(MDMPWRON, 0);
00020     wait_ms(10);
00021     c027_mdm_powerOn(false);
00022     
00023     // open the mdm serial port
00024     Serial mdm(MDMTXD,MDMRXD);
00025     mdm.baud(MDMBAUD);
00026     mdm.set_flow_control(SerialBase::RTSCTS, MDMRTS,MDMCTS);
00027     
00028     // open the PC serial port and (use the same baudrate)
00029     Serial pc(P4_28, P4_29);
00030     pc.baud(MDMBAUD);
00031     while (1)
00032     {
00033         // transfer data from pc to modem
00034         if (pc.readable() && mdm.writeable())
00035         {
00036             mdm.putc(pc.getc());
00037         }
00038         // transfer data from modem to pc
00039         if (mdm.readable() && pc.writeable())
00040         {
00041             pc.putc(mdm.getc());
00042         }
00043     }
00044 }