| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- #ifndef __TDC_TOF_H__
- #define __TDC_TOF_H__
- #include "board.h"
- #define TDC_CFG_DO_CKENA (0x00000001u)
- #define TDC_CFG_DO_CKDIS (0x00000002u)
- #define TDC_CFG_DO_WREG (0x00000008u)
- #define TDC_CFG_FIRE_UP (0x00000010u)
- #define TDC_CFG_FIRE_DOWN (0x00000020u)
- #define TOF_ST_INIT (0x0001u)
- #define TOF_ST_CALIB (0x0002u)
- #define TOF_ST_TEST (0x0004u)
- #define TOF_ST_METER (0x0008u)
- #define TOF_ST_VOID (0x0010u)
- #define TOF_FLAG_BLANK_PIPE (0x00000001u)
- #define TOF_FLAG_UNPAIR_WAVE (0x00000002u)
- #define TOF_FLAG_UP_EARLY (0x00000004u)
- #define TOF_FLAG_UNALGND_CHOP (0x00000008u)
- #define TOF_FLAG_VALID_FLOW (0x00000010u)
- #define TOF_FLAG_CALIB_FLOW (0x00000020u)
- #define TOF_FLAG_CALIB_FALL (0x00000040u)
- #define TOF_FLAG_CALIB_DONE (0x00000080u)
- #define TOF_FLAG_TDC_FAULT (0x40000000u)
- #define CALIB_TIME_LTH (10)
- #define RTC_CNTMSK_VOID (0x3u)
- #define RTC_CNTMSK_CAL (0x7u)
- #define RTC_CNTMSK_TEMP (0x7u)
- //modified by yuewei 20260520 start
- /*
- typedef struct {
- float SpdLvl; // start SpdLvl for this Quad
- float Coe[4]; // m0, m1, m2, m3 for this Quad
- } Quad_Cell_t;
- */
- typedef struct {
- float m; // 常数
- float k; // 系数
- } Coeff_t;
- typedef struct {
- float value; // 温度值 / 流速等级
- Coeff_t coe; // 补偿系数 {m, k}
- } Quad_Cell_t;
- //modified by yuewei 20260520 end
- extern uint32_t RTC_CntInt;
- extern uint16_t tof_state;
- extern uint32_t tof_flag;
- extern uint8_t TdcIntStep;
- extern uint16_t TdcStatus;
- extern uint16_t TdcUPwFw;
- extern uint16_t TdcUPwHw;
- extern uint16_t TdcDPwFw;
- extern uint16_t TdcDPwHw;
- extern uint32_t TdcUToF[9];
- extern uint32_t TdcDToF[9];
- extern float WaterPrmt[2];
- extern float TdcScale;
- #define WaterTemp (WaterPrmt[0])
- #define UsonicSpd (WaterPrmt[1])
- extern float UToFAvg;
- extern float DToFAvg;
- extern float DiffToF;
- extern float DiffToFAvg;
- extern float DiffToFAvg128;
- extern uint8_t TdcFwOfst;
- extern double CumFlow;
- extern double FwCumFlow;
- extern double BwCumFlow;
- extern double FlowVol;
- extern float RefFlow;
- extern uint16_t CalibTime;
- extern float CalibSpdLvl;
- extern float CalibTemp;
- extern float DiffTofThres[4];
- typedef void (*flow_vol_itf)(double flow_vol, float tmp_float);
- typedef void (*pipe_blank_itf)(uint8_t ch);
- typedef void (*check_flow_itf)(double cum_flow, float spdLvl, float temp);
- typedef struct {
- uint8_t bw_flow_flag;
- uint32_t ch_bit_map;
- uint32_t blank_flag;
- float pipe_coe;
- float path_skew[MUX_CH_NUM];
- uint32_t ch_num;
- uint8_t mux_ch_no[MUX_CH_NUM];
- uint32_t mux_switch;
- uint16_t ntc_num;
- const uint16_t *ntc_ohm_ary;
- const float *ntc_slp_ary;
- uint16_t row_num;
- uint16_t col_num;
- const float *row_temp_ary;
- //modified by yuewei 20260409
- //const Quad_Cell_t *quad_cell_ary;
- Quad_Cell_t *quad_cell_ary;
- pipe_blank_itf set_blank;
- pipe_blank_itf clr_blank;
- flow_vol_itf flow_vol;
- check_flow_itf check_flow;
- }tdc_itf_t;
- extern tdc_itf_t TdcItf;
- extern tdc_itf_t *pTdcItf;
- extern const uint16_t Quad_Cell_NUM;//wxl2026-4-14
- extern Quad_Cell_t Quad_Cell_Ary[];//wxl2026-4-14
- void tdc_tof_init(void);
- void tdc_start_tof(uint32_t cfg);
- void tdc_read_tof(uint32_t cfg);
- void tdc_start_cal(uint32_t cfg);
- void tdc_read_cal(uint32_t cfg);
- void tdc_start_temp(uint32_t cfg);
- void tdc_read_temp(uint32_t cfg);
- void Ohm2Dgr2USSpd(uint16_t ohmX10, float *p);
- float bilinear_quad_apsr(float WatSpdLvl, float WatTemp);
- // tdc_itf.c
- void tdc_flow_itf(double flow_vol, float tmp_float);
- void set_pipe_blank(uint8_t ch);
- void clr_pipe_blank(uint8_t ch);
- void set_tdc_itf(tdc_itf_t *itf);
- uint32_t get_tof_flag(void);
- void set_tof_flag(uint32_t flag);
- uint16_t get_tof_state(void);
- void set_tof_state(uint16_t state);
- float get_diff_tof(void);
- uint8_t get_tdc_fw_ofst(void);
- void set_tdc_fw_ofst(uint8_t fw_ofst);
- uint8_t get_tdc_int_step(void);
- void set_tdc_int_step(uint8_t int_step);
- #endif
|