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

FreeD.h

Committer:
JamieB
Date:
2021-07-01
Revision:
20:ce1d8fbff68f
Child:
25:7002be632308

File content as of revision 20:ce1d8fbff68f:

#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