#ifndef BMS_TAG_H_
#define BMS_TAG_H_

#ifdef __cplusplus
extern "C" {
#endif 

#include <stdint.h>
#include <stdbool.h>

#include "bsp_number.h"

typedef enum
{
    kAppArea_I, //一体机
    kAppArea_P, //保护板
    kAppArea_U, //二级架构
    kAppArea_T, //三级架构
    kAppArea_End,
}AppArea;

#define TAG_PROJECT_ID_ADDR           APP_CFG_E_TAG_ADDR
#define TAG_UUID_ADDR                 (TAG_PROJECT_ID_ADDR + 4)
#define TAG_SOFTWARE_VER_ADDR         (TAG_UUID_ADDR + 6)
#define TAG_BOOT_VER_ADDR             (TAG_SOFTWARE_VER_ADDR + 2)
#define TAG_HARDWARE_VER_ADDR         (TAG_BOOT_VER_ADDR + 2)
#define TAG_DEVICE_MODE_ADDR          (TAG_HARDWARE_VER_ADDR + 2)
#define TAG_COMPANY_NAME_ADDR         (TAG_DEVICE_MODE_ADDR + 10)
#define TAG_PROJECT_NAME_ADDR         (TAG_COMPANY_NAME_ADDR + 100)
#define TAG_ORDER_ID_ADDR             (TAG_PROJECT_NAME_ADDR + 100)
#define TAG_TEST_RESULT_ADDR          (TAG_ORDER_ID_ADDR + 20)
#define TAG_DEVICE_TYPE_ADDR          (TAG_TEST_RESULT_ADDR + 20)
#define TAG_CRC_ADDR                  (TAG_DEVICE_TYPE_ADDR + 2)


//5+5+6 16位
/*******************************硬件设备版本号***********************************/
#define DEVICE_HW_MAJOR_VER     (1u) //5
#define DEVICE_HW_MINOR_VER     (0u) //5
#define DEVICE_HW_BUILD_VER     (0u) //6
//#define DEVICE_HW_VERSION       (((DEVICE_HW_MAJOR_VER&0x1f)<<11)+((DEVICE_HW_MINOR_VER&0x1f)<<6)+(DEVICE_HW_BUILD_VER&0x3f))

/*********************************软件版本号*************************************/
#define DEVICE_V_MAJOR_VER     (2u) //4
#define DEVICE_V_MINOR_VER     (1u) //4
#define DEVICE_V_APPL_VER      (kAppArea_U) //4
#define DEVICE_R_MAJOR_VER     (1u) //4  
#define DEVICE_R_MINOR_VER     (0u) //6
#define DEVICE_C_MAJOR_VER     (1u) //8
#define DEVICE_C_MINOR_VER     (3u) //4

//主干默认版本B0 上述记录即可
//#define DEVICE_SW_BUILD_VER    (1u) 

//#define DEVICE_SW_VERSION      ((DEVICE_V_MAJOR_VER << 8) | (DEVICE_V_MINOR_VER))
#define DEVICE_SW_VERSION      1
#define DEVICE_SW_BUILD_VER    (0u) 
#define DEVICE_HW_VERSION       1

#define DEVICE_R_VERSION       ((DEVICE_R_MAJOR_VER << 8) | (DEVICE_R_MINOR_VER))
#define DEVICE_C_VERSION       ((DEVICE_C_MAJOR_VER << 8) | (DEVICE_C_MINOR_VER))
typedef enum
{
	kSoftType_Boot,
	kSoftType_Test,
	kSoftType_App,
    kSoftType_End,
}SoftType;

typedef enum
{
    kTagData_DevAddr,
	kTagData_DevType,
	kTagData_SoftVer,
	kTagData_HardVer,
    kTagData_BootVer,
    kTagData_ProductNumber,
    kTagData_ProductTime,
    kTagData_GateIdx,
    kTagData_End,
}TagData;


void     bms_init_tag(void);
uint64_t bms_get_uuid(void);
uint32_t bms_get_tag_data(TagData idx);
void     bms_set_tag_data(TagData idx, uint32_t data);

#ifdef __cplusplus
}
#endif

#endif
