78 lines
1.5 KiB
C++
78 lines
1.5 KiB
C++
#ifndef BOOTLOADERPROTOCOL_H
|
|
#define BOOTLOADERPROTOCOL_H
|
|
|
|
#include <QObject>
|
|
#include "ProtocolDefs.h"
|
|
#include "CRC32.h"
|
|
|
|
class CPICUploader;
|
|
|
|
#define BOOTLOADER_FRAME_HEADER 0xDEADBEEF
|
|
#define BOOTLOADER_FRAME_HEADER_1 0xDE
|
|
#define BOOTLOADER_FRAME_HEADER_2 0xAD
|
|
#define BOOTLOADER_FRAME_HEADER_3 0xBE
|
|
#define BOOTLOADER_FRAME_HEADER_4 0xEF
|
|
#define MAX_BOOTLOADER_PAYLOAD_SIZE 200
|
|
|
|
|
|
|
|
enum eProtocolBootloaderStates
|
|
{
|
|
Initialization,
|
|
RxHeader1,
|
|
RxHeader2,
|
|
RxHeader3,
|
|
RxHeader4,
|
|
RxCmd,
|
|
RxPayloadSize1,
|
|
RxPayloadSize2,
|
|
RxPayloadSize3,
|
|
RxPayloadSize4,
|
|
RxPayload,
|
|
RxCRC1,
|
|
RxCRC2,
|
|
RxCRC3,
|
|
RxCRC4
|
|
};
|
|
|
|
class CBootloaderProtocol : public QObject
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit CBootloaderProtocol(QObject *parent = 0);
|
|
~CBootloaderProtocol();
|
|
|
|
int BootloaderProtocolInit();
|
|
int BootloaderProtocolResetStateMachine();
|
|
|
|
int BooloaderProtocolRxFrame(QByteArray Frame);
|
|
void BootloaderProtocolStateMachine(unsigned char data);
|
|
|
|
QByteArray BootloaderProtocolGetFrame(char Cmd, QByteArray Data);
|
|
|
|
|
|
|
|
|
|
CPICUploader *mProgramHandle;
|
|
|
|
|
|
private:
|
|
unsigned int mBootloaderHeader;
|
|
unsigned int mBootloaderDataSize;
|
|
unsigned int mBootloaderDataCtr;
|
|
unsigned int mBootloaderBufPtr;
|
|
unsigned int mBootloaderCRC;
|
|
unsigned int mBootloaderComputedCRC;
|
|
QByteArray mBootloaderDataBuffer;
|
|
unsigned char mBootloaderCommand;
|
|
unsigned char mBootloaderState;
|
|
|
|
CCRC32 mCRCEngine;
|
|
|
|
signals:
|
|
|
|
public slots:
|
|
};
|
|
|
|
#endif // BOOTLOADERPROTOCOL_H
|