Stephen Dickey / Mbed 2 deprecated C027_M3_SerialEcho

Dependencies:   C027-REVB mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "C027.h"
00003 
00004 DigitalOut mdm_activity(LED);
00005 
00006 int main() 
00007 {
00008     int led_toggle_count = 5;
00009 
00010     C027 c027;
00011     c027.mdmPower(true,false);
00012     
00013 #if 0
00014     while(1) {
00015         mdm_activity = !mdm_activity;
00016         wait(0.2);
00017     }
00018 #else
00019     while( led_toggle_count-- > 0 )
00020     {
00021         mdm_activity = !mdm_activity;
00022         wait(0.2);
00023     }
00024 #endif
00025 
00026     // open the mdm serial port
00027     Serial mdm(MDMTXD, MDMRXD);
00028     mdm.baud(MDMBAUD);
00029     // tell the modem that we can always receive data
00030     DigitalOut mdmRts(MDMRTS);
00031     mdmRts = 0; // (not using flow control)
00032     
00033     // open the PC serial port and (use the same baudrate)
00034     Serial pc(USBTX, USBRX);
00035     pc.baud(MDMBAUD);
00036     
00037     while (1)
00038     {
00039         // transfer data from pc to modem
00040         if (pc.readable() && pc.writeable())
00041             pc.putc(pc.getc());
00042     }
00043 }