#ifndef  _SOFT_FLOW_H
#define  _SOFT_FLOW_H
#include "stdint.h"
#include "stdbool.h"
#include "gpio.h"
#include "common.h"

#define MAXPUMPCLIB_NUM 38
#define CLIB_SPRAY_SPEED 500
#define FlOW_KP 22
#define EXTI_FALL 1
#define EXTI_UP   2

float flow_dete2(void);
float flow_dete3(void);
float flow_dete4(void);
void flow_count_add(uint8_t flow_num,uint8_t exti_status);
void flow_function(void);
void write_flash_function(void);
void L1L2_GPIO_check(void);
void can_recv_mimor_flow_function(uint32_t CanID, uint8_t data[], uint8_t len);




//extern bool L1_status;
//extern bool L2_status;

#pragma pack(1)
typedef struct
{
    uint8_t ch;
    uint16_t flow_speed;
    uint16_t total_ml;
    uint8_t status;
    uint8_t circu_time;
    uint8_t signal_str;

    uint8_t get_k_count;
    uint8_t send_k_count;
    uint16_t flow_k; //当前K
    uint16_t flow_calk;//校准K

    char soft_version[2];
    char sn[14];
    uint16_t last_total_ml;
    uint8_t overturn_count;

}mimo_flow;
extern mimo_flow flow_mimo1;
extern mimo_flow flow_mimo2;

#pragma pack()


//霍尔流量计
#pragma pack(1)
typedef struct
{
    bool count_flag;
    uint32_t time;
    uint32_t last_time;
    uint32_t irq_count;  //单位时间内经过的液体体积      
    uint32_t irq_last_count;
    bool exti_error;
    int speed;
    bool rising_delay_flag;
    bool falling_delay_falg;
    uint32_t cal_delay_time;
    uint8_t  irq_flag;
    bool sem_flag;

    uint32_t rising_delay_time;
    uint32_t falling_delay_time;
}flow_hl;
extern flow_hl flow_dev1;
extern flow_hl flow_dev2;
#pragma pack()

typedef struct
{
    uint16_t speed;
    uint32_t flow_ml;
    uint16_t warn;
}vk_flow;
extern vk_flow flow_vkdev1;
extern vk_flow flow_vkdev2;

extern GPIO_PinState L3_status;
extern GPIO_PinState L4_status;
#endif 
