An ANT Shared Bidirectional Slave sample implementation.
see http://mbed.org/users/MRSa/notebook/bc-ant_receiver/ .
Revision 2:691ccdef6f1e, committed 2013-05-26
- Comitter:
- MRSa
- Date:
- Sun May 26 13:39:31 2013 +0000
- Parent:
- 1:05e9a83b721c
- Child:
- 3:ce23e131fdbd
- Commit message:
- add led control.
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Sun May 26 13:25:39 2013 +0000 +++ b/main.cpp Sun May 26 13:39:31 2013 +0000 @@ -74,6 +74,36 @@ } /** + * + */ +void executeAction(uint8_t commandType, uint8_t channel, uint8_t command) +{ + if (commandType != 0x4e) + { + // do nothing! + return; + } + // execute! + if ((command & 0x40) != 0) + { + led0 = 1; + } + else + { + led0 = 0; + } + if ((command & 0x08) != 0) + { + led1 = 1; + } + else + { + led1 = 0; + } + +} + +/** * Recieved a message from ANT port. */ void receivedFromAnt() @@ -82,6 +112,8 @@ uint8_t receivedBuffer[MAX_BUFSIZE]; receivedLength = antPort.BC_ANT_RecvPacket(receivedBuffer, MAX_BUFSIZE); + executeAction(receivedBuffer[2], receivedBuffer[4], receivedBuffer[6]); + printf("RX(%3d):", receivedLength); for (int index = 0; index < receivedLength; index++) { @@ -135,12 +167,8 @@ while(1) { myLeds = statusLamp; - led0 = 1; - led1 = 1; wait(0.5); myLeds = 0; - led0 = 0; - led1 = 0; wait(0.5); } }