/*
 * 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                 0x2000EFF0u
#define REQUEST_ENTER_BOOTLOADER_ADDR   0x2000EFF1u
#define DOWNLOAD_APP_SUCCESSFUL_ADDR    0x2000EFF0u

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


/* TODO Bootloader: #01 CAN RX and TX message ID Configuration */
#if defined (CAN1_MSG_TYPE)
	#if (CAN1_MSG_TYPE == CAN_MSG_STANDARD)
		#define RX_FUN_ADDR_ID       (0x7BFu)    /* FuncReq  - CAN TP RX function ID */
		#define RX_PHY_ADDR_ID       (0x7A0u)    /* PhysReq  - CAN TP RX physical ID */
		#define TX_RESP_ADDR_ID      (0x7A8u)    /* PhysResp - CAN TP TX physical ID */
	#elif (CAN1_MSG_TYPE == CAN_MSG_EXTENDED)
		#define RX_FUN_ADDR_ID       (0x18DA55FFu)    /* FuncReq  - CAN TP RX function ID */
		#define RX_PHY_ADDR_ID       (0x18DA5535u)    /* PhysReq  - CAN TP RX physical ID */
		#define TX_RESP_ADDR_ID      (0x18DA3555u)    /* PhysResp - CAN TP TX physical ID */
	#endif
#else
	#error "please define the CAN MSG Type of can1"
#endif


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