/*
 * Bootloader.h
 *
 *  Created on: Jul 10, 2019
 *      Author: parkyj
 */

#ifndef BOOTLOADER_H_
#define BOOTLOADER_H_
#include "main.h"

extern uint8_t * UpdateFiledata;

typedef struct{
	uint8_t bluecell_header01;
	uint8_t bluecell_header02;
	uint8_t bluecell_header03;
	uint8_t bluecell_header04;
	uint8_t bluecell_type;
	uint8_t bluecell_length_h;
	uint8_t bluecell_length_l;
	uint8_t bluecell_data[2048];
}Blueprotocol_t;
typedef enum {
	BLUECELL_HEADER00 = 0,
	BLUECELL_HEADER01,
	BLUECELL_HEADER02,
	BLUECELL_HEADER03,
	BLUECELL_TYPE,
	BLUECELL_LENGTH_H,
	BLUECELL_LENGTH_L,
	BLUECELL_UPDATACNT_H,
	BLUECELL_UPDATACNT_L,
	BLUECELL_DATA,
}Bluenum;
typedef enum {
	BLUECELL_RESET = 0,
	BLUECELL_START,
	BLUECELL_SENDING,
	BLUECELL_END,
}updateseq;
typedef enum updateseqok
{
    UpdateResetOK = 0,
    UpdateStartOK,
    UpdateSendingOK,
    UpdateEndOK,
};
typedef enum{
    bluecell_stx = 0,
    bluecell_type = 1,
    bluecell_length,
	bluecell_CrcIndex,
    bluecell_crc,
    bluecell_ext,   
}FirmwareUpdate_t;

/*bluecell Header*/
#define Bluecell_Header0  0x42//ASCII : B
#define Bluecell_Header1  0x4C//ASCII : L
#define Bluecell_Header2  0x55//ASCII : U
#define Bluecell_Header3  0x45//ASCII : E
/*bluecell type*/
#define Bluecell_Reset  0x0A//ASCII : R
#define Bluecell_Firmupdate_start     0x55//ASCII : U
#define Bluecell_Firmupdate_sending   0x53//ASCII : S
#define Bluecell_Firmupdate_end       0x65//ASCII : e
#define Bluecell_Endbyte 0xED

#define bluecell_Firmupdate_sendlength  1024

#define bluecell_Firmupdate_Ackbytelength 12

extern void FirmwareUpdate_Boot(void);


extern void Firmware_BootStart_Signal();
#endif /* BOOTLOADER_H_ */
