#ifndef BMS_FDB_H_
#define BMS_FDB_H_

#ifdef __cplusplus
extern "C" {
#endif

#include "bsp_modbus.h"
#include "kit_macro.h"

typedef enum
{
    kFdbData_HardFault,
    kFdbData_TaskTimeout,
    kFdbData_SystemEvent,
    kFdbData_Reserved1,
    kFdbData_Reserved2,
    kFdbData_Reserved3,
    kFdbData_Reserved4,
    kFdbData_Reserved5,
    kFdbData_FaultEvent,
    
    kFdbData_Architecture,
    kFdbData_ModbusCfg,
    kFdbData_End,
}FdbData;


void bms_init_fdb(void);
void bms_analyse_net_protocol(void);

uint16_t bms_read_modbus_model(uint8_t *buf);
bool     bms_write_modbus_model(uint8_t *buf, uint16_t len);
uint16_t bms_get_modbus_model_task_num(uint8_t idx);
ModbusHead * bms_get_modbus_model_head_addr(uint8_t mb_idx, uint16_t task_idx);

bool bms_write_hardfault_data(uint8_t *buf, uint16_t len);
void bms_write_task_timeout_data(uint32_t task_id);
uint32_t hmi_fill_modbus_cfg(uint8_t *buf);

uint16_t hmi_write_modbus_cfg(uint16_t offset_addr, uint16_t data);
#ifdef __cplusplus
}
#endif

#endif
