143 lines
3.9 KiB
C
143 lines
3.9 KiB
C
|
#ifndef _LIB_FZSB_
|
|||
|
#define _LIB_FZSB_
|
|||
|
|
|||
|
|
|||
|
#include "typedef.h"
|
|||
|
#define ADC_SIZE 420
|
|||
|
#define ADC_BOLCK_SIZE 140
|
|||
|
#define LED0_ON() HT_GPIOD->PTDAT|=0x2000
|
|||
|
#define LED1_OFF() HT_GPIOD->PTDAT&=0xDFFF
|
|||
|
#define PEAK_NUM 5
|
|||
|
#define P_SAMPLE 128
|
|||
|
#define TWACS_INTV_CNT_MIN 21
|
|||
|
#define TWACS_INTV_CNT_MAX 32
|
|||
|
|
|||
|
#define TWACS_VAILED_DIFF_MAX_VAL (40)
|
|||
|
|
|||
|
#define JFG_MODE_MIN_VALUE 21
|
|||
|
#define JFG_MODE_MAX_VALUE 29
|
|||
|
|
|||
|
#define JQ_MODE_MIN_VALUE 25
|
|||
|
#define JQ_MODE_MAX_VALUE 32
|
|||
|
|
|||
|
#define AUTO_MODE (0)
|
|||
|
#define JFG_MODE (1)
|
|||
|
#define JQ_MODE (2)
|
|||
|
#define TWACS_MODE AUTO_MODE
|
|||
|
#define THRD_FIX 0x00100000 //U 0x70000
|
|||
|
#define I_THRD_FIX 0x00500000
|
|||
|
#define U_THRD_FIX 0x70000
|
|||
|
|
|||
|
#define SYCN_WINDOW_VALUE 2560
|
|||
|
#define OUT_TIME 4224
|
|||
|
|
|||
|
#define ITF_IDLE (0)
|
|||
|
#define ITF_RX_DAT (1)
|
|||
|
#define ITF_RX485_DAT (2)
|
|||
|
|
|||
|
#define ADC_CHANNEL I_ADC_ADD
|
|||
|
#define U_ADC_ADD 0x40013008
|
|||
|
#define I_ADC_ADD 0x40013000
|
|||
|
#define I2_ADC_ADD 0x40013004
|
|||
|
|
|||
|
|
|||
|
typedef enum{
|
|||
|
PEAK_INIT,
|
|||
|
PEAK_ONE,
|
|||
|
PEAK_MAX,
|
|||
|
} twacs_peak_status_t;
|
|||
|
|
|||
|
typedef struct
|
|||
|
{
|
|||
|
sby_uint8_t cmd; // <20>ɿ⺯<C9BF><E2BAAF><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD><C3A3><EFBFBD>Ҫ<EFBFBD>ϲ<EFBFBD><CFB2><EFBFBD><EFBFBD>㣬<EFBFBD><E3A3AC><EFBFBD>ϲ㲻<CFB2><E3B2BB><EFBFBD>㣬<EFBFBD><E3A3AC><EFBFBD><EFBFBD>һֱ<D2BB><D6B1><EFBFBD>֣<EFBFBD><D6A3><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD><C2B5><EFBFBD><EFBFBD>ݡ<EFBFBD>
|
|||
|
sby_uint8_t mode; //
|
|||
|
sby_uint8_t chip_reset_flag; // <20><><EFBFBD>ñ<EFBFBD>־λ<D6BE><CEBB>1<EFBFBD><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>ϲ<EFBFBD><CFB2><EFBFBD><EFBFBD>ø<EFBFBD>λоƬ<D0BE><C6AC>ָ<EFBFBD><D6B8>
|
|||
|
sby_uint8_t debug_mode; // <20><><EFBFBD>Խӿڣ<D3BF><DAA3><EFBFBD><EFBFBD>ò<EFBFBD>ͬ<EFBFBD>ĵ<EFBFBD><C4B5>Եȼ<D4B5><C8BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0<EFBFBD><30>ӡ<EFBFBD><D3A1>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>ϸ<EFBFBD>ο<EFBFBD>debug_mode_t
|
|||
|
sby_uint8_t rx_dat[50];
|
|||
|
sby_uint8_t rx_busy; // 1:<3A><>ʾ<EFBFBD><CABE>ǰ<EFBFBD>н<EFBFBD><D0BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD><DDA3><EFBFBD><EFBFBD>ϲ㽫CMD<4D><44><EFBFBD><EFBFBD><EFBFBD>ñ<F3A3ACB8>־λ<D6BE>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
} twacs_itf_t;
|
|||
|
|
|||
|
|
|||
|
typedef struct
|
|||
|
{
|
|||
|
sby_uint8_t ADC_Flag;
|
|||
|
sby_uint8_t ADC_First;
|
|||
|
sby_uint8_t ADC_Ready;
|
|||
|
|
|||
|
}adc_staus_t;
|
|||
|
|
|||
|
//typedef struct
|
|||
|
//{
|
|||
|
|
|||
|
//}auto_thrd_t;
|
|||
|
|
|||
|
typedef struct
|
|||
|
{
|
|||
|
sby_uint32_t thrd;
|
|||
|
sby_uint32_t peak_index[PEAK_NUM];
|
|||
|
sby_uint32_t peak_value[PEAK_NUM];
|
|||
|
sby_uint8_t twacs_staus;
|
|||
|
sby_uint16_t sync_window;
|
|||
|
sby_uint8_t mode;
|
|||
|
sby_uint8_t peak_staus;
|
|||
|
sby_uint32_t adc_index;
|
|||
|
sby_uint16_t sync_window_index;
|
|||
|
sby_uint8_t peak_num;
|
|||
|
sby_uint8_t peak_max;
|
|||
|
sby_uint16_t out_index;
|
|||
|
// sby_uint16_t raw_data[20];
|
|||
|
sby_uint8_t rx_finish_flag;
|
|||
|
sby_uint8_t bak_intv_info[6];
|
|||
|
sby_uint16_t rx_finish_val;
|
|||
|
sby_uint8_t max_idx;
|
|||
|
sby_uint32_t fix_thrd;
|
|||
|
sby_uint8_t bitwide;
|
|||
|
} twacs_vars_t;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
void Data_Process(sby_int32_t *indata,sby_int32_t *outdata,adc_staus_t *adc_staus,twacs_vars_t *twacs_vars_data);
|
|||
|
sby_int32_t Data2int32(sby_int32_t Data);
|
|||
|
void Sub_abs(sby_int32_t *indata,sby_int32_t *outdata,sby_uint16_t index,sby_uint16_t offset);
|
|||
|
sby_int32_t add_pwr(sby_int32_t *indata,sby_uint16_t index,sby_uint16_t offset,sby_uint8_t bitwide);
|
|||
|
void GPIO_switch(void);
|
|||
|
void Twacs_Phy(sby_uint32_t data,twacs_vars_t *twacs_vars_data);
|
|||
|
sby_uint32_t Thrd_Cal(sby_uint32_t *data);
|
|||
|
void Twacs_Decode(twacs_vars_t *twacs_vars);
|
|||
|
void Rest_Twacs_var(twacs_vars_t *twacs_vars_data);
|
|||
|
sby_uint16_t Data2mod(sby_uint16_t data1,sby_uint16_t data2);
|
|||
|
sby_uint8_t cs_get (sby_uint8_t * dat, sby_uint16_t datlen);
|
|||
|
void jfg_proto_decode (twacs_vars_t *twacs_vars_data);
|
|||
|
void jq_proto_decode (twacs_vars_t *twacs_vars_data);
|
|||
|
void twacs_background_rx_data(twacs_vars_t *twacs_vars_data,twacs_itf_t *twacs_itf_data);
|
|||
|
|
|||
|
|
|||
|
extern sby_uint16_t Timer0_S,Timer0_E,Timer0_sub1,Timer0_sub2;
|
|||
|
|
|||
|
|
|||
|
extern sby_int32_t Ubuffer[ADC_SIZE];
|
|||
|
extern sby_int32_t U_Pro_Buffer[ADC_SIZE];
|
|||
|
|
|||
|
extern sby_int32_t Ibuffer[ADC_SIZE];
|
|||
|
extern sby_int32_t I_Pro_Buffer[ADC_SIZE];
|
|||
|
|
|||
|
extern sby_int32_t I2buffer[ADC_SIZE];
|
|||
|
extern sby_int32_t I2_Pro_Buffer[ADC_SIZE];
|
|||
|
|
|||
|
extern adc_staus_t U_ADC_STAUS;
|
|||
|
extern adc_staus_t I_ADC_STAUS;
|
|||
|
extern adc_staus_t I2_ADC_STAUS;
|
|||
|
|
|||
|
|
|||
|
extern twacs_vars_t u_twacs_vars;
|
|||
|
extern twacs_vars_t i_twacs_vars;
|
|||
|
extern twacs_vars_t i2_twacs_vars;
|
|||
|
|
|||
|
extern twacs_itf_t u_twacs_itf;
|
|||
|
extern twacs_itf_t i_twacs_itf;
|
|||
|
extern twacs_itf_t i2_twacs_itf;
|
|||
|
#endif
|
|||
|
|
|||
|
|