Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of C027_ModemTransparentSerial by
main.cpp@5:1141d3cfd1ef, 2013-12-19 (annotated)
- Committer:
- mazgch
- Date:
- Thu Dec 19 17:31:35 2013 +0000
- Revision:
- 5:1141d3cfd1ef
- Parent:
- 4:fafdcaf842ee
- Child:
- 6:1e5c9b6b2e90
use hw flow control on MDM serial port
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mazgch | 0:53fc79c7af10 | 1 | #include "mbed.h" |
mazgch | 2:1970ac045983 | 2 | #include "C027.h" |
mazgch | 0:53fc79c7af10 | 3 | |
mazgch | 0:53fc79c7af10 | 4 | int main() |
mazgch | 0:53fc79c7af10 | 5 | { |
mazgch | 2:1970ac045983 | 6 | C027 c027; |
mazgch | 2:1970ac045983 | 7 | c027.mdmPower(true); |
mazgch | 2:1970ac045983 | 8 | |
mazgch | 0:53fc79c7af10 | 9 | // open the mdm serial port |
mazgch | 0:53fc79c7af10 | 10 | Serial mdm(MDMTXD, MDMRXD); |
mazgch | 0:53fc79c7af10 | 11 | mdm.baud(MDMBAUD); |
mazgch | 5:1141d3cfd1ef | 12 | // use hardware flow control to make the connection more reliable |
mazgch | 5:1141d3cfd1ef | 13 | mdm.set_flow_control(SerialBase::RTSCTS, MDMRTS, MDMCTS); |
mazgch | 0:53fc79c7af10 | 14 | |
mazgch | 0:53fc79c7af10 | 15 | // open the PC serial port and (use the same baudrate) |
mazgch | 0:53fc79c7af10 | 16 | Serial pc(USBTX, USBRX); |
mazgch | 0:53fc79c7af10 | 17 | pc.baud(MDMBAUD); |
mazgch | 0:53fc79c7af10 | 18 | |
mazgch | 0:53fc79c7af10 | 19 | while (1) |
mazgch | 0:53fc79c7af10 | 20 | { |
mazgch | 0:53fc79c7af10 | 21 | // transfer data from pc to modem |
mazgch | 0:53fc79c7af10 | 22 | if (pc.readable() && mdm.writeable()) |
mazgch | 0:53fc79c7af10 | 23 | mdm.putc(pc.getc()); |
mazgch | 0:53fc79c7af10 | 24 | // transfer data from modem to pc |
mazgch | 0:53fc79c7af10 | 25 | if (mdm.readable() && pc.writeable()) |
mazgch | 0:53fc79c7af10 | 26 | pc.putc(mdm.getc()); |
mazgch | 0:53fc79c7af10 | 27 | } |
mazgch | 0:53fc79c7af10 | 28 | } |