/*
 * UDSTask.h
 *
 *  Created on: 2022Äê3ÔÂ14ÈÕ
 *      Author: Zhengchao
 */



#ifndef UDSTASK_H_
#define UDSTASK_H_


#include "PlatformTypes.h"
#include "hal_adapter.h"
#include "USER_CONFIG.h"

#define INFO_START_ADDR                 0x20006FF0u
#define REQUEST_ENTER_BOOTLOADER_ADDR   0x20006FF1u
#define DOWNLOAD_APP_SUCCESSFUL_ADDR    0x20006FF0u

#define EN_CRC_SOFTWARE /* Enable CRC module with software */


//#define USE_CAN_EXT_ID

/* TODO Bootloader: #01 CAN RX and TX message ID Configuration */
#if defined (CAN0_MSG_TYPE)
	#if (CAN0_MSG_TYPE == CAN_MSG_STANDARD)
		#define RX_FUN_ADDR_ID       (0x7BFu)    /* FuncReq  - CAN TP RX function ID */
		#define RX_PHY_ADDR_ID       (0x7A1u)    /* PhysReq  - CAN TP RX physical ID */
		#define TX_RESP_ADDR_ID      (0x7A9u)    /* PhysResp - CAN TP TX physical ID */
	#elif (CAN0_MSG_TYPE == CAN_MSG_EXTENDED)
		#define RX_FUN_ADDR_ID       (0x18DA55FFu)    /* FuncReq  - CAN TP RX function ID */
		#define RX_PHY_ADDR_ID       (0x18DA5536u)    /* PhysReq  - CAN TP RX physical ID */
		#define TX_RESP_ADDR_ID      (0x18DA3655u)    /* PhysResp - CAN TP TX physical ID */
	#endif
#else
	#error "please define the CAN MSG Type of can0"
#endif

void RequestEnterBootloader(void);
boolean IsJumptoBootloader(uint32 CanID, uint8 Data[]);
void DoRoutinePositiveAnswer(void);
boolean Boot_CheckDownlaodAPPStatus(void);
#endif /* UDSTASK_H_ */
