DCLibraries/include/dcBL.h

123 lines
3.4 KiB
C
Raw Normal View History

2023-11-08 13:02:26 +01:00
#ifndef DCBL_H
#define DCBL_H
#include "qbytearray.h"
#include "qstring.h"
#include <QFile>
#include "storeINdata.h"
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
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);
char dcBL_loadBinSafe(QString fileName);
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)
uint16_t dcBL_getNrOfBlocks(void);
// size of the loaded bin file in 64byte blocks
uint16_t dcBL_getFileCrc(void);
// checksum of the loaded bin file
uint32_t dcBL_getFileSize(void);
// length of the loaded bin file in byte
uint8_t dcBL_getSizeOfLastBlock(void);
bool dcBL_sendOneBlockCpl(uint16_t blockNumber);
int8_t dcBL_getBlockResult(void);
char dcBL_cycle(void);
// to be called cyclic every 100ms
/*
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 see what's going on....
// 1: connected to BL
// 2: transmission started
// 3: transmission successful
*/
/* move to storeINdata and use shared mem as ptu-updater uses CAslave Lib 6.9.23TS
#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();
// not used
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