#ifndef __USER_CONFIG_H__
#define __USER_CONFIG_H__

#include "define.h"

#ifdef __cplusplus
extern "C" {
#endif

#ifndef DEV_LIC_SIZE
#define DEV_LIC_SIZE			16
#endif

#ifndef DEV_ADDR_SIZE
#define DEV_ADDR_SIZE			6
#endif

#define HEAD_VALUE			0xEFAA
#define UART_BAUD_SIZE			8

#define CALIB_WEIGHT_SIZE		10

#define WEIGHT_RANGE_DEFAULT		350000

typedef enum{
  CAN_BAUD_NULL 	= 0,
  CAN_BAUD_100 	  = 100,
  CAN_BAUD_150 	  = 150,
  CAN_BAUD_200 	  = 200,
  CAN_BAUD_250 	  = 250,
  CAN_BAUD_300 	  = 300,
  CAN_BAUD_400 	  = 400,
  CAN_BAUD_500 	  = 500,
  CAN_BAUD_666 	  = 666,
  CAN_BAUD_800 	  = 800,
  CAN_BAUD_1000 	= 1000
}can_baud_e;

typedef struct{
  uint16_t head;
  can_baud_e can_baud;
}__attribute__((packed)) user_config_param_s;

#define USER_CONFIG_STAT_DEFAULT_CONFIG		\
{						                              \
  .head = HEAD_VALUE,				              \
  .can_baud = CAN_BAUD_1000,              \
}

void User_Config_Read_Config(void);
void User_Config_Write_Config(void);
void user_config_init(void);
bool check_can_baud(uint32_t baud);
void set_user_config_param_init(user_config_param_s *param);
void FLASH_read(uint32_t addr, uint8_t *pData, uint32_t len);
bool user_config_save_can_baud(uint32_t baud);

extern user_config_param_s user_config_param;
extern uint32_t ttl_baud[UART_BAUD_SIZE];

#ifdef __cplusplus
}
#endif

#endif // USER_CONFIG_H__

/** @} */
