UpdatePTUDevCtrl/DCPlugin/include/dcBL.h

103 lines
2.9 KiB
C
Raw Permalink Normal View History

#ifndef DCBL_H
#define DCBL_H
#include <stdint.h>
#include "qbytearray.h"
#include "qstring.h"
#include <QFile>
uint8_t dcBL_prepareDC_BLcmd(uint8_t Cmd, uint8_t SendDataLength, uint8_t *sendData, uint8_t *outBuf);
// make BL protocol, retval = outbuf length (5...133)
// bring data in correct form: start always with 0x02 finish with 0x03 and append checksum
// 0x02 Cmd < ...sendData ..> CRC CRC 0x03
// Data length = 0...64
// special conversion: if data contain 2 or 3 (STX, ETX) then write two bytes: 0x1B (=ESC) and data|0x80
// so maxlength = 5 + 2 x 64 (if all data are 2 or 3) without 2,3: maxlength = 5 + 64
uint8_t dcBL_readBLversion(uint8_t *sendData);
// minimum size of sendData-buffer: 5byte retval: length
uint8_t dcBL_readFWversion(uint8_t *sendData);
// minimum size of sendData-buffer: 5byte retval: length
uint8_t dcBL_exitBL(uint8_t *sendData);
// minimum size of sendData-buffer: 5byte retval: length
uint8_t dcBL_sendFlashStartAddr2BL(uint32_t startAddr, uint8_t *sendData);
// minimum size of sendData-buffer: 13byte retval: length (9...13)
uint8_t dcBL_writeLastPage(uint8_t *sendData);
// minimum size of sendData-buffer: 5byte retval: length
uint8_t dcBL_restartDC(uint8_t *sendData);
// minimum size of sendData-buffer: 20 byte retval: length
uint8_t dcBL_activatBootloader(uint8_t *sendData);
// minimum size of sendData-buffer: 20 byte retval: length
uint8_t dcBL_getResponse(uint8_t *respBuff);
// retval: nr of received bytes
bool dcBL_responseOK();
// retval: 0: response OK (cmd |0x80) 1: response error (cmd or "0xe0")
bool dcBL_importBinFile(QByteArray readBinFile, uint32_t fileSize, char withDispl);
bool dcBL_isTextMemFree(void);
void dcBL_writeText(QString newTxt);
bool dcBL_checkForText(void);
// if pointer at 0 then no more content
QString dcBL_readText(void);
// read from 0...9 (oldest first)
void dcBL_iniChain(void);
uint8_t dcBL_startChain(void);
uint8_t dcBL_runChain(void);
void dcBL_iniLoading(void);
void dcBL_startLoading(void);
uint8_t dcBL_sendHexfile(void);
uint8_t dcBL_getResult(void);
// call after every step to what's going on....
// 1: connected to BL
// 2: transmission started
// 3: transmission successful
#define RAW_BL_DATALEN 150
void gpi_storeRawReceivedData(uint8_t RdDlen, uint8_t *receivedData);
uint8_t epi_getRawReceivedData(uint8_t *receivedData);
// retval=length, will be zeroed after first reading
uint8_t epi_getRawRecLength(void);
// retval=length
QString epi_getRawReceivedString();
void epi_clrRawReceivedString();
uint8_t dcBL_sendSuccess(uint8_t lastCommand);
// return val: 0: no response by now 1:error 10: OK
// lastCommand=0x21 for sendAddr or 0x22 for send data
char dcBL_loadBinary(char withDisplay);
#endif // DCBL_H