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:
Tue Apr 15 22:14:11 2014 +0000
Revision:
0:95297d07b5c6
Child:
1:808e9257d1ea
Example usage of LLAPSerial library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
SomeRandomBloke 0:95297d07b5c6 1 // Demo Ciseco LLAPSerial usage
SomeRandomBloke 0:95297d07b5c6 2 #include "mbed.h"
SomeRandomBloke 0:95297d07b5c6 3 #include "LLAPSerial.h"
SomeRandomBloke 0:95297d07b5c6 4
SomeRandomBloke 0:95297d07b5c6 5 //LLAPSerial srf(PA_11, PA_12);
SomeRandomBloke 0:95297d07b5c6 6 // or
SomeRandomBloke 0:95297d07b5c6 7 LLAPSerial srf(PA_11, PA_12, "MB");
SomeRandomBloke 0:95297d07b5c6 8
SomeRandomBloke 0:95297d07b5c6 9 Serial pc(USBTX, USBRX);
SomeRandomBloke 0:95297d07b5c6 10
SomeRandomBloke 0:95297d07b5c6 11 DigitalOut srfEnable(PA_9);
SomeRandomBloke 0:95297d07b5c6 12
SomeRandomBloke 0:95297d07b5c6 13 int main()
SomeRandomBloke 0:95297d07b5c6 14 {
SomeRandomBloke 0:95297d07b5c6 15 pc.baud(115200);
SomeRandomBloke 0:95297d07b5c6 16 pc.printf("LLAP Test\n");
SomeRandomBloke 0:95297d07b5c6 17
SomeRandomBloke 0:95297d07b5c6 18 srfEnable = 1;
SomeRandomBloke 0:95297d07b5c6 19 srf.sendMessage("STARTED");
SomeRandomBloke 0:95297d07b5c6 20 wait_ms(100);
SomeRandomBloke 0:95297d07b5c6 21 srf.sendMessage("TMPA", "123");
SomeRandomBloke 0:95297d07b5c6 22 wait_ms(100);
SomeRandomBloke 0:95297d07b5c6 23 srf.sendInt("TMPA", 123);
SomeRandomBloke 0:95297d07b5c6 24 wait_ms(100);
SomeRandomBloke 0:95297d07b5c6 25 srf.sendIntWithDP("TMPA", 1230,2);
SomeRandomBloke 0:95297d07b5c6 26 while( 1 ) {
SomeRandomBloke 0:95297d07b5c6 27 if( srf.bMsgReceived ) {
SomeRandomBloke 0:95297d07b5c6 28 myled = !myled;
SomeRandomBloke 0:95297d07b5c6 29 pc.printf("Received: %s\n\r",srf.sMessage );
SomeRandomBloke 0:95297d07b5c6 30 srf.bMsgReceived = false; // Clear flag to indicate msg handled
SomeRandomBloke 0:95297d07b5c6 31 }
SomeRandomBloke 0:95297d07b5c6 32 }
SomeRandomBloke 0:95297d07b5c6 33
SomeRandomBloke 0:95297d07b5c6 34 }