Simple program to echo serial commands between debug uart and Skywire Modem

Dependencies:   mbed

Committer:
kholland
Date:
Tue Jan 20 20:11:52 2015 +0000
Revision:
1:bbc6c30d55e2
Parent:
0:b7473c389910
Added license

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kholland 1:bbc6c30d55e2 1 /* main.cpp */
kholland 1:bbc6c30d55e2 2 /* Copyright (C) 2015 nimbelink.com, MIT License
kholland 1:bbc6c30d55e2 3 *
kholland 1:bbc6c30d55e2 4 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
kholland 1:bbc6c30d55e2 5 * and associated documentation files (the "Software"), to deal in the Software without restriction,
kholland 1:bbc6c30d55e2 6 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
kholland 1:bbc6c30d55e2 7 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
kholland 1:bbc6c30d55e2 8 * furnished to do so, subject to the following conditions:
kholland 1:bbc6c30d55e2 9 *
kholland 1:bbc6c30d55e2 10 * The above copyright notice and this permission notice shall be included in all copies or
kholland 1:bbc6c30d55e2 11 * substantial portions of the Software.
kholland 1:bbc6c30d55e2 12 *
kholland 1:bbc6c30d55e2 13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
kholland 1:bbc6c30d55e2 14 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
kholland 1:bbc6c30d55e2 15 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
kholland 1:bbc6c30d55e2 16 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
kholland 1:bbc6c30d55e2 17 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
kholland 1:bbc6c30d55e2 18 */
kholland 1:bbc6c30d55e2 19
kholland 0:b7473c389910 20 #include "mbed.h"
kholland 0:b7473c389910 21
kholland 0:b7473c389910 22 //------------------------------------
kholland 0:b7473c389910 23 // Hyperterminal configuration
kholland 0:b7473c389910 24 // 115200 bauds, 8-bit data, no parity
kholland 0:b7473c389910 25 //------------------------------------
kholland 0:b7473c389910 26
kholland 0:b7473c389910 27 Serial pc(USBTX, USBRX);
kholland 0:b7473c389910 28 Serial skywire(PA_9, PA_10); //Nucleo Boards
kholland 0:b7473c389910 29 //Serial skywire(PTC17, PTC16); //K64 FRDM
kholland 0:b7473c389910 30
kholland 0:b7473c389910 31 DigitalOut myled(LED1);
kholland 0:b7473c389910 32
kholland 0:b7473c389910 33 DigitalOut skywire_en(PA_6); //Nucleo
kholland 0:b7473c389910 34 DigitalOut skywire_rts(PA_7);
kholland 0:b7473c389910 35
kholland 0:b7473c389910 36 //DigitalOut skywire_en(PTD3); //K64 FRDM
kholland 0:b7473c389910 37 //DigitalOut skywire_rts(PTD2);
kholland 0:b7473c389910 38
kholland 0:b7473c389910 39 char c;
kholland 0:b7473c389910 40
kholland 0:b7473c389910 41 int main()
kholland 0:b7473c389910 42 {
kholland 0:b7473c389910 43 skywire.baud(115200);
kholland 0:b7473c389910 44 pc.baud(115200);
kholland 0:b7473c389910 45 skywire_rts=0;
kholland 0:b7473c389910 46 pc.printf("Hello World !\n");
kholland 0:b7473c389910 47 myled=0;
kholland 0:b7473c389910 48 skywire_en=0;
kholland 0:b7473c389910 49 wait(1);
kholland 0:b7473c389910 50 skywire_en=1;
kholland 0:b7473c389910 51 wait(1);
kholland 0:b7473c389910 52
kholland 0:b7473c389910 53 myled=1;
kholland 0:b7473c389910 54 while(1) {
kholland 0:b7473c389910 55 if(skywire.readable()) {
kholland 0:b7473c389910 56 c = skywire.getc();
kholland 0:b7473c389910 57 //skywire.putc(c);
kholland 0:b7473c389910 58 pc.putc(c);
kholland 0:b7473c389910 59 }
kholland 0:b7473c389910 60 if(pc.readable()) {
kholland 0:b7473c389910 61 c = pc.getc();
kholland 0:b7473c389910 62 skywire.putc(c);
kholland 0:b7473c389910 63 //pc.putc(c);
kholland 0:b7473c389910 64 }
kholland 0:b7473c389910 65 }
kholland 0:b7473c389910 66 }
kholland 0:b7473c389910 67
kholland 0:b7473c389910 68