.
Dependencies: L432KC_SPI_Pey_Lal
Diff: protocol.cpp
- Revision:
- 111:f11575e7c79b
- Parent:
- 110:a6d1d3525014
- Child:
- 115:156b8234f2de
--- a/protocol.cpp Thu Apr 07 12:13:04 2022 +0000 +++ b/protocol.cpp Thu Apr 07 12:30:01 2022 +0000 @@ -2,6 +2,7 @@ char newDataAvailable = 0; +//Bytewise XOR char calculateChecksum(uint32_t propulsion, uint32_t direction) { char checksum = 0xff; @@ -21,6 +22,7 @@ uint32_t verifiedPropulsion = 1500; uint32_t verifiedDirection = 1150; +//Decode the bytes received according to their order of reception. void decodeMessage(char c) { switch(receiveState) @@ -61,7 +63,7 @@ //Checksum if (c == calculateChecksum(receivedPropulsion, receivedDirection)) { - //Le message recu est correct, on peut exploiter ses données + //The frame is correct, we can use the values retrieved. verifiedPropulsion = receivedPropulsion; verifiedDirection = receivedDirection; newDataAvailable = 1; @@ -75,6 +77,7 @@ } } +//Return the values decoded void getVerifiedPWMValues(uint32_t *pwmPropulsion, uint32_t *pwmDirection) { *pwmPropulsion = verifiedPropulsion; @@ -82,6 +85,7 @@ newDataAvailable = 0; } +//Return a value telling if new informations are available. char isDataAvailable() { return newDataAvailable;