Example program for the Ciseco SRF Shield, based on UART serial port connectivity (D0/D1 pins). This program sends SRF messages and prints out the received ones

Dependencies:   LLAPSerial mbed

Fork of Ciseco_LLAP_Test by Andrew Lindsay

Committer:
SomeRandomBloke
Date:
Wed Apr 16 21:05:47 2014 +0000
Revision:
4:530543332ac3
Parent:
3:537d95945591
Child:
5:52fe9a6d9ae9
Updated after solder bridges updated on Nucleo board

Who changed what in which revision?

UserRevisionLine numberNew contents of line
SomeRandomBloke 0:95297d07b5c6 1 // Demo Ciseco LLAPSerial usage
SomeRandomBloke 1:808e9257d1ea 2
SomeRandomBloke 1:808e9257d1ea 3 /**
SomeRandomBloke 1:808e9257d1ea 4 * The MIT License (MIT)
SomeRandomBloke 1:808e9257d1ea 5 *
SomeRandomBloke 1:808e9257d1ea 6 * Copyright (c) 2014 Andrew Lindsay
SomeRandomBloke 1:808e9257d1ea 7 *
SomeRandomBloke 1:808e9257d1ea 8 * Permission is hereby granted, free of charge, to any person obtaining a copy
SomeRandomBloke 1:808e9257d1ea 9 * of this software and associated documentation files (the "Software"), to deal
SomeRandomBloke 1:808e9257d1ea 10 * in the Software without restriction, including without limitation the rights
SomeRandomBloke 1:808e9257d1ea 11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
SomeRandomBloke 1:808e9257d1ea 12 * copies of the Software, and to permit persons to whom the Software is
SomeRandomBloke 1:808e9257d1ea 13 * furnished to do so, subject to the following conditions:
SomeRandomBloke 1:808e9257d1ea 14 *
SomeRandomBloke 1:808e9257d1ea 15 * The above copyright notice and this permission notice shall be included in
SomeRandomBloke 1:808e9257d1ea 16 * all copies or substantial portions of the Software.
SomeRandomBloke 1:808e9257d1ea 17 *
SomeRandomBloke 1:808e9257d1ea 18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
SomeRandomBloke 1:808e9257d1ea 19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
SomeRandomBloke 1:808e9257d1ea 20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
SomeRandomBloke 1:808e9257d1ea 21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
SomeRandomBloke 1:808e9257d1ea 22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
SomeRandomBloke 1:808e9257d1ea 23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
SomeRandomBloke 1:808e9257d1ea 24 * THE SOFTWARE.
SomeRandomBloke 1:808e9257d1ea 25 */
SomeRandomBloke 1:808e9257d1ea 26
SomeRandomBloke 0:95297d07b5c6 27 #include "mbed.h"
SomeRandomBloke 0:95297d07b5c6 28 #include "LLAPSerial.h"
SomeRandomBloke 0:95297d07b5c6 29
SomeRandomBloke 3:537d95945591 30 //LLAPSerial srf(PA_11, PA_12, PA_9);
SomeRandomBloke 0:95297d07b5c6 31 // or
SomeRandomBloke 4:530543332ac3 32 //LLAPSerial srf(PA_11, PA_12, PA_9, false,"MB");
SomeRandomBloke 4:530543332ac3 33 LLAPSerial srf(PA_2, PA_3, PA_9, false,"MB");
SomeRandomBloke 0:95297d07b5c6 34
SomeRandomBloke 4:530543332ac3 35 //Serial pc(USBTX, USBRX);
SomeRandomBloke 4:530543332ac3 36 Serial pc(PA_11, PA_12);
SomeRandomBloke 0:95297d07b5c6 37
SomeRandomBloke 0:95297d07b5c6 38 int main()
SomeRandomBloke 0:95297d07b5c6 39 {
SomeRandomBloke 0:95297d07b5c6 40 pc.baud(115200);
SomeRandomBloke 0:95297d07b5c6 41 pc.printf("LLAP Test\n");
SomeRandomBloke 0:95297d07b5c6 42
SomeRandomBloke 0:95297d07b5c6 43 srf.sendMessage("STARTED");
SomeRandomBloke 0:95297d07b5c6 44 wait_ms(100);
SomeRandomBloke 0:95297d07b5c6 45 srf.sendMessage("TMPA", "123");
SomeRandomBloke 0:95297d07b5c6 46 wait_ms(100);
SomeRandomBloke 0:95297d07b5c6 47 srf.sendInt("TMPA", 123);
SomeRandomBloke 0:95297d07b5c6 48 wait_ms(100);
SomeRandomBloke 0:95297d07b5c6 49 srf.sendIntWithDP("TMPA", 1230,2);
SomeRandomBloke 0:95297d07b5c6 50 while( 1 ) {
SomeRandomBloke 0:95297d07b5c6 51 if( srf.bMsgReceived ) {
SomeRandomBloke 2:d47dac2ce25b 52 //myled = !myled;
SomeRandomBloke 0:95297d07b5c6 53 pc.printf("Received: %s\n\r",srf.sMessage );
SomeRandomBloke 0:95297d07b5c6 54 srf.bMsgReceived = false; // Clear flag to indicate msg handled
SomeRandomBloke 0:95297d07b5c6 55 }
SomeRandomBloke 0:95297d07b5c6 56 }
SomeRandomBloke 0:95297d07b5c6 57
SomeRandomBloke 0:95297d07b5c6 58 }