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
Diff: main.cpp
- Revision:
- 5:52fe9a6d9ae9
- Parent:
- 4:530543332ac3
- Child:
- 6:cd32a801b8de
--- a/main.cpp Wed Apr 16 21:05:47 2014 +0000 +++ b/main.cpp Fri May 30 13:54:10 2014 +0000 @@ -1,5 +1,3 @@ -// Demo Ciseco LLAPSerial usage - /** * The MIT License (MIT) * @@ -27,18 +25,23 @@ #include "mbed.h" #include "LLAPSerial.h" -//LLAPSerial srf(PA_11, PA_12, PA_9); -// or -//LLAPSerial srf(PA_11, PA_12, PA_9, false,"MB"); -LLAPSerial srf(PA_2, PA_3, PA_9, false,"MB"); +/** On many platforms USBTX/USBRX overlap with serial on D1/D0 pins and enabling the below will interrupt the communication. + * You can use an LCD display to print the values or store them on an SD card etc. + */ +//Serial pc(USBTX, USBRX); -//Serial pc(USBTX, USBRX); -Serial pc(PA_11, PA_12); +/** + * D1 - TX pin (RX on the shield side) + * D0 - RX pin (TX on the shield side) + * D8 - Pin name for the SRF enable + * false - Check the incoming Device ID and ignore if it doesnt match + * "MB" - ID for device, used in sending messages and if checkNodeID is true then only messages for this ID are accepted + */ +LLAPSerial srf(D1, D0, D8, false, "MB"); int main() { - pc.baud(115200); - pc.printf("LLAP Test\n"); + printf("LLAP Test\n"); srf.sendMessage("STARTED"); wait_ms(100); @@ -46,11 +49,11 @@ wait_ms(100); srf.sendInt("TMPA", 123); wait_ms(100); - srf.sendIntWithDP("TMPA", 1230,2); - while( 1 ) { - if( srf.bMsgReceived ) { + srf.sendIntWithDP("TMPA", 1230, 2); + while (1) { + if (srf.bMsgReceived) { //myled = !myled; - pc.printf("Received: %s\n\r",srf.sMessage ); + printf("Received: %s\n\r", srf.sMessage); srf.bMsgReceived = false; // Clear flag to indicate msg handled } }