#ifndef __CONFIG_H_
#define __CONFIG_H_
#include "main.h" 
#include "stm32f4xx.h"
struct config_uart
{
    uint32_t baudrate;
	uint16_t databits;
    uint16_t parity;
    uint16_t stopbits;
};

struct config_protocol
{
    uint16_t type;        /*  0:rtu 1:hex 2:ascii*/
    char  pre_command[32];  /*  run 0103000000044409*/
    uint16_t pre_timeout;
    char command[32];   /*  run 0103000000044409*/
    uint16_t timeout;  
    uint16_t parser;   /*  float  int ascii*/
	uint16_t endian;
    uint16_t validation;
    char sign[6];

    /*  校验方法 ，开始标记，结束标记 */
};

struct config_output
{
    uint16_t begin_byte;
    uint16_t length;
    uint16_t end_byte;
	uint16_t place;  /* 输出位置 */
	uint16_t number; /* 输出参数数量*/
    uint16_t coeff; /* int 系数 */
    uint16_t retension; /* 保留位数*/
};

struct config
{

    uint16_t device_id;
    uint16_t version_max ;
    uint16_t version_min ;
    uint16_t samp_interval_s;

    struct config_uart uart;
    struct config_protocol protocol;
    struct config_output output;

    struct config_uart menu;
    struct config_uart modbus;

};

extern struct config config;
int Config_Init(void);
// int Config_Read(void);
// int Config_Write(void);
int config_reset(void);
int config_check(void);
int config_get_cfg(void);

#endif