I messed up the merge, so pushing it over to another repo so I don't lose it. Will tidy up and remove later
Dependencies: BufferedSerial FatFileSystemCpp mbed
Diff: FreeD.h
- Revision:
- 20:ce1d8fbff68f
- Child:
- 25:7002be632308
diff -r 08e6a2283d58 -r ce1d8fbff68f FreeD.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/FreeD.h Thu Jul 01 10:35:20 2021 +0000 @@ -0,0 +1,36 @@ +#ifndef __FreeD_h__ +#define __FreeD_h__ + +#include "mbed.h" +#include <cstdint> + +struct D1MsgFormat_s { + uint8_t header; //0xD1, annoying it cant be set as default value here! + uint8_t id; //camera ID, use 255 minus Rover ID + uint32_t yaw : 24; + uint32_t pitch : 24; + uint32_t roll : 24; + uint32_t x : 24; + uint32_t y : 24; + uint32_t z : 24; + uint32_t zoom : 24; + uint32_t focus : 24; + uint16_t spare; + uint8_t checksum; +} __attribute__((packed)) ; + +inline int GetFdCRC(void *data) { + uint8_t *dataPtr = (uint8_t *)data; + //uint8_t *crcPtr = (uint8_t *)checksum; + int len = sizeof(D1MsgFormat_s) -1; + uint8_t sum =0; + int byteCount = 0; + + while ((len--) > 0) {sum += dataPtr[byteCount++];} + + //crcPtr[0] = 0x40 - sum; + return 0x40 - sum; +} + + +#endif \ No newline at end of file