478 lines
19 KiB
C
478 lines
19 KiB
C
|
|
#ifndef __D9V2FR_DP2006V1000_h__
|
|||
|
|
#define __D9V2FR_DP2006V1000_h__
|
|||
|
|
|
|||
|
|
//File Start--------------------------------------------------------------------
|
|||
|
|
#if (DP2006_VM1000)
|
|||
|
|
//**************************************************************************
|
|||
|
|
|
|||
|
|
// for flow compute
|
|||
|
|
//==============================================================================
|
|||
|
|
#define LED_PIN GPIO_PIN_5
|
|||
|
|
#define LED_PIN_PINPOS GPIO_PinPos_5
|
|||
|
|
#define LED_PIN_GPIO GPIO0
|
|||
|
|
#define LED_PIN_OUT() EnableOutput(LED_PIN_GPIO, LED_PIN)
|
|||
|
|
#define SET_LED_PIN() SET_PIN(LED_PIN_GPIO,LED_PIN)
|
|||
|
|
#define CLR_LED_PIN() CLR_PIN(LED_PIN_GPIO,LED_PIN)
|
|||
|
|
//==============================================================================
|
|||
|
|
//// key_pin select pin
|
|||
|
|
// <20><><EFBFBD>Ŷ<EFBFBD><C5B6><EFBFBD>
|
|||
|
|
#define KEY1_PIN GPIO_PIN_1 // PA0<41><30>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>ػ<EFBFBD><D8BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
#define KEY1_PORT pGPIO1
|
|||
|
|
#define POWER_CTRL_PIN GPIO_PIN_0 // PA1<41><31><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD>ƽ<EFBFBD>
|
|||
|
|
#define POWER_CTRL_PORT pGPIO1
|
|||
|
|
#define UnitKEY_PIN GPIO_PIN_0 // <20><>λ<EFBFBD>л<EFBFBD><D0BB><EFBFBD>
|
|||
|
|
#define UnitKEY_PORT pGPIO0
|
|||
|
|
//------------------------------------------------------------------------------
|
|||
|
|
// OLED I2C<32>ӿ<EFBFBD><D3BF><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
|
|||
|
|
#define I2C_SDA GPIO_PIN_4
|
|||
|
|
#define I2C_SDA_PINPOS GPIO_PinPos_4
|
|||
|
|
#define I2C_SDA_GPIO GPIO1
|
|||
|
|
#define I2C_SCL GPIO_PIN_0
|
|||
|
|
#define I2C_SCL_PINPOS GPIO_PinPos_0
|
|||
|
|
#define I2C_SCL_GPIO GPIO2
|
|||
|
|
|
|||
|
|
#define I2C_RES GPIO_PIN_6
|
|||
|
|
#define I2C_RES_PINPOS GPIO_PinPos_1
|
|||
|
|
#define I2C_RES_GPIO GPIO1
|
|||
|
|
//------------------------------------------------------------------------------
|
|||
|
|
// for eeprom
|
|||
|
|
#define EEPROM_WP_PIN GPIO_PIN_5
|
|||
|
|
#define EEPROM_WP_PINPOS GPIO_PinPos_5
|
|||
|
|
#define EEPROM_WP_GPIO GPIO1
|
|||
|
|
#define PARA_EEPROM BIT1
|
|||
|
|
#define DATA_EEPROM BIT2
|
|||
|
|
#define FROCK_EEPROM BIT1+BIT2+BIT3
|
|||
|
|
//------------------------------------------------------------------------------
|
|||
|
|
// for BLE
|
|||
|
|
#define BLE_CTS_PIN GPIO_PIN_3
|
|||
|
|
#define BLE_CTS_GPIO pGPIO0
|
|||
|
|
#define BLE_RST_PIN GPIO_PIN_4
|
|||
|
|
#define BLE_RST_GPIO pGPIO0
|
|||
|
|
//------------------------------------------------------------------------------
|
|||
|
|
// for SPI
|
|||
|
|
//#define SCLK_PIN GPIO_PIN_5
|
|||
|
|
//#define SCLK_PINPOS GPIO_PinPos_5
|
|||
|
|
//#define SCLK_PIN_SOURCE GPIO_PinSource5
|
|||
|
|
//#define SCLK_PIN_CONFIG GPIO1_5_AF_SCLK
|
|||
|
|
//#define SCLK_GPIO GPIO1
|
|||
|
|
|
|||
|
|
//#define SOMI_PIN GPIO_PIN_4
|
|||
|
|
//#define SOMI_PINPOS GPIO_PinPos_4
|
|||
|
|
//#define SOMI_PIN_SOURCE GPIO_PinSource4
|
|||
|
|
//#define SOMI_PIN_CONFIG GPIO1_4_AF_MISO
|
|||
|
|
//#define SOMI_GPIO GPIO1
|
|||
|
|
|
|||
|
|
//#define SIMO_PIN GPIO_PIN_6
|
|||
|
|
//#define SIMO_PINPOS GPIO_PinPos_6
|
|||
|
|
//#define SIMO_PIN_SOURCE GPIO_PinSource6
|
|||
|
|
//#define SIMO_PIN_CONFIG GPIO1_6_AF_MOSI
|
|||
|
|
//#define SIMO_GPIO GPIO1
|
|||
|
|
////------------------------------------------------------------------------------
|
|||
|
|
//#define EXT_CALIB_PIN GPIO_PIN_7
|
|||
|
|
//#define EXT_CALIB_PINPOS GPIO_PinPos_7
|
|||
|
|
//#define EXT_CALIB_GPIO GPIO1
|
|||
|
|
|
|||
|
|
//#define RS485DE_PIN GPIO_PIN_1
|
|||
|
|
//#define RS485DE_PINPOS GPIO_PinPos_1
|
|||
|
|
//#define RS485DE_GPIO GPIO1
|
|||
|
|
//#define RS485DE_OUTPUT() EnableOutput(RS485DE_GPIO, RS485DE_PINPOS)
|
|||
|
|
//#define ENABLE_TXD() SET_PIN(RS485DE_GPIO, RS485DE_PIN)
|
|||
|
|
//#define ENABLE_RXD() CLR_PIN(RS485DE_GPIO, RS485DE_PIN)
|
|||
|
|
// *****************************************************************************
|
|||
|
|
// 'X' <20><><EFBFBD><D7BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
// *****************************************************************************
|
|||
|
|
#define CTYPE_FR CURVE_1ST
|
|||
|
|
#define ATYPE_VH CURVE_2ND
|
|||
|
|
#define MICRO_FR CURVE_3RD
|
|||
|
|
|
|||
|
|
#define FRIDX CTYPE_FR // 0
|
|||
|
|
#define RGIDX ATYPE_VH // 1
|
|||
|
|
#define GAINX MICRO_FR // 2
|
|||
|
|
#define VDUX 3 //
|
|||
|
|
#define VDUGX 4 //
|
|||
|
|
#define RIDX 5 //
|
|||
|
|
#define NIDX 6 // NORMAL_VL - LOW_VL (TD INDEX)
|
|||
|
|
#define TPCB 7 // PCB temperature
|
|||
|
|
#define TGAS 8 // GAS temperature
|
|||
|
|
#define TRH 9 // RH temperature
|
|||
|
|
#define BATT 10 // Battery volatge
|
|||
|
|
#define IVHDX 11 // IRH CODE test VHH By TD Control
|
|||
|
|
#define VRHX 12 // VRH CODE
|
|||
|
|
#define IVHUX 13 // IRH CODE test VHH By TU Control
|
|||
|
|
#define VRRX 14 // VRR CODE
|
|||
|
|
#define RHVOL 15 // RH VOLATAGE
|
|||
|
|
#define RRVOL 16 // RR VOLATAGE
|
|||
|
|
#define RHRES 17 // RH resistance
|
|||
|
|
#define RRRES 18 // RR resistance
|
|||
|
|
#define PORH 19 // RH Power
|
|||
|
|
#define PDRH 20 // RH current Power
|
|||
|
|
#define CVHHX 21 //
|
|||
|
|
#define DVHHX 22 //
|
|||
|
|
#define VHPA 23 //
|
|||
|
|
#define RATO 24 // RR:RH
|
|||
|
|
#define SDT 25 // ATYPE OFFSET
|
|||
|
|
#define DIVHX 26 // IVHH(TD) - IVHH(TU)
|
|||
|
|
#define TCOE 27 //
|
|||
|
|
#define TVDUX 28 //
|
|||
|
|
#define TVDUGX 29 //
|
|||
|
|
#define FR_H 30 //
|
|||
|
|
#define FR_L 31 //
|
|||
|
|
#define ANX 32 //
|
|||
|
|
#define ANX_MASK (ANX-1)
|
|||
|
|
//------------------------------------------------------------------------------
|
|||
|
|
#define NRH RRRES
|
|||
|
|
#define NVHH IVHDX
|
|||
|
|
#define CVHH CVHHX //
|
|||
|
|
#define DVHH DVHHX //
|
|||
|
|
#define NVDU VDUX
|
|||
|
|
|
|||
|
|
#define LRH RHRES
|
|||
|
|
#define LVOL RHVOL
|
|||
|
|
#define LVHH IVHDX
|
|||
|
|
//------------------------------------------------------------------------------
|
|||
|
|
#define GCFX NVDU //
|
|||
|
|
#define GIDX LCDE //
|
|||
|
|
#define FIDX FRIDX
|
|||
|
|
#define RAOOM RATO
|
|||
|
|
|
|||
|
|
#define ATYPE_FR CURVE_2ND
|
|||
|
|
#define REG_INDEX RGIDX
|
|||
|
|
//------------------------------------------------------------------------------
|
|||
|
|
#define CODE1 FR_H // 8300 FIDX
|
|||
|
|
#define CODE2 FR_L // 8301 FIDX
|
|||
|
|
#define CODE3 FRIDX // 8302 FIDX
|
|||
|
|
|
|||
|
|
#define CODE4 NIDX // 8303
|
|||
|
|
#define CODE5 VRHX // 8304
|
|||
|
|
#define CODE6 IVHDX // 8305
|
|||
|
|
#define CODE7 RHVOL // 8306
|
|||
|
|
#define CODE8 VDUGX // 8307
|
|||
|
|
#define CODE9 TPCB // 8308
|
|||
|
|
|
|||
|
|
#define CODE10 RHVOL // 8309
|
|||
|
|
#define CODE11 VDUX // 830A
|
|||
|
|
#define CODE12 VDUGX // 830B
|
|||
|
|
#define CODE13 NIDX // 830C
|
|||
|
|
#define CODE14 BATT // 830D
|
|||
|
|
#define CODE15 IVHDX // 830E
|
|||
|
|
#define CODE16 VRHX // 830F
|
|||
|
|
// *****************************************************************************
|
|||
|
|
// 1S = 16384
|
|||
|
|
// Circuit preparation process
|
|||
|
|
#define START_SAMPLING_STAGE_0 0
|
|||
|
|
#define START_SAMPLING_STAGE_1 1
|
|||
|
|
#define START_SAMPLING_STAGE_2 2
|
|||
|
|
#define START_SAMPLING_STAGE_3 3
|
|||
|
|
//------------------------------------------------------------------------------
|
|||
|
|
#define FR_UPDATE 0x0A
|
|||
|
|
#define FR_UPDATE_PULSE_TIME 16 // 1ms
|
|||
|
|
//------------------------------------------------------------------------------
|
|||
|
|
#define CIRCUIT_SETUP_TIME 82 // 5ms
|
|||
|
|
//------------------------------------------------------------------------------
|
|||
|
|
#define SET_UP_TIME_FROM_DETECT_TO_1ST_STAGE 1638 // 100ms
|
|||
|
|
//------------------------------------------------------------------------------
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̣<EFBFBD>
|
|||
|
|
//------------------------------------------------------------------------------
|
|||
|
|
#define COUNT_VALUE_PER_MS 16 //10
|
|||
|
|
#define SET_UP_TIME_OF_DETECT_STAGE (20 * COUNT_VALUE_PER_MS) ///20ms
|
|||
|
|
#define SAMPLING_TIMES_IN_DETECT_STAGE 16 //
|
|||
|
|
#define SHIFT_IN_DETECT_STAGE 4 //
|
|||
|
|
//
|
|||
|
|
#define SET_UP_TIME_OF_1ST_STAGE (40 * COUNT_VALUE_PER_MS) //40ms <20><>Ӧ<EFBFBD><D3A6><EFBFBD><CEA2><EFBFBD><EFBFBD>ADC 977SRS DMA<4D><41><EFBFBD><EFBFBD>32<33><32>ʱ<EFBFBD><CAB1>
|
|||
|
|
#define PRESAMPLING_TIMES_IN_1ST_STAGE 32 //
|
|||
|
|
#define SHIFT_IN_PRESAMPLING_1ST_STAGE 5 //
|
|||
|
|
//
|
|||
|
|
#define SAMPLING_TIME_OF_1ST_STAGE (70 * COUNT_VALUE_PER_MS) //70ms <20><>Ӧ<EFBFBD><D3A6><EFBFBD><CEA2><EFBFBD><EFBFBD>ADC 977SRS DMA<4D><41><EFBFBD><EFBFBD>64<36><34>ʱ<EFBFBD><CAB1>
|
|||
|
|
#define SAMPLING_TIMES_IN_1ST_STAGE 64 //
|
|||
|
|
#define SHIFT_IN_1ST_STAGE 6 //
|
|||
|
|
|
|||
|
|
//******************************************************************************
|
|||
|
|
#define STATIC_HIGH_CODE 50
|
|||
|
|
#define STATIC_LOW_CODE 50
|
|||
|
|
// *****************************************************************************
|
|||
|
|
//#define VHH_GAIN GAIN16
|
|||
|
|
#define NIDX_GAIN GAIN32
|
|||
|
|
#define GIDX_GAIN GAIN128 //GAIN_64
|
|||
|
|
#define GIDX_SHIFT 4
|
|||
|
|
//#define VRR_GAIN GAIN16
|
|||
|
|
//#define VRH_GAIN GAIN1
|
|||
|
|
|
|||
|
|
#define SAMPLE_NORMOL_MODE 0
|
|||
|
|
#define SAMPLE_TRACK_ZERO_MODE 1
|
|||
|
|
#define SAMPLE_FAST_MODE 2
|
|||
|
|
#define SAMPLE_MODE_MAX SAMPLE_TRACK_ZERO_MODE //SAMPLE_VDU_VRH_MODE
|
|||
|
|
#define SAMPLE_DEFAULT_MODE SAMPLE_NORMOL_MODE //SAMPLE_VDU_VRR_MODE
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ÿ<><C3BF>4λ
|
|||
|
|
#define SAMPLE_VDU 0
|
|||
|
|
#define SAMPLE_GVDU 1
|
|||
|
|
|
|||
|
|
#define SAMPLE_VRH 0
|
|||
|
|
#define SAMPLE_IRH 1
|
|||
|
|
|
|||
|
|
#define SWITCH_GAIN_THRESHOLD 0x36768
|
|||
|
|
|
|||
|
|
#define CAL_VDUX CTYPE_FR
|
|||
|
|
#define CAL_ATYPE ATYPE_VH
|
|||
|
|
#define CAL_VDUGX MICRO_FR
|
|||
|
|
|
|||
|
|
// *****************************************************************************
|
|||
|
|
#if (DP2006_VM1000)
|
|||
|
|
//---------------------------------------------------------------------------------
|
|||
|
|
#define VCOM 0.0
|
|||
|
|
#define VREF_PER_CODE (ADC_VREF/32768)
|
|||
|
|
#define VRR_BRIDGE_VOL (ADC_VREF - VCOM)
|
|||
|
|
|
|||
|
|
#define VRR_RA 33000.0
|
|||
|
|
#define VRR_RB 2800.0
|
|||
|
|
#define VRR_RDC (VRR_RB/(VRR_RA + VRR_RB))
|
|||
|
|
#define VRR_VDC (VRR_BRIDGE_VOL*VRR_RDC)
|
|||
|
|
|
|||
|
|
#define VRR_ADC_GAIN 16.0
|
|||
|
|
#define VRR_VREF ( VREF_PER_CODE/VRR_ADC_GAIN )
|
|||
|
|
#define VRR_PER_CODE ( ADC_VREF/((ADC_VREF-VCOM)*GAIN*32768))
|
|||
|
|
|
|||
|
|
#define SampingADCInit() ADC_REF_Init(REF_INTERNAL_2P5V, REF_INTERNAL_1P25V)
|
|||
|
|
#define SetupRHChannle() ADC_Init(ADC_0, SPS_977, GAIN1,ADC0_AIN3,ADC0_AVSS) //VRH
|
|||
|
|
#define SetupIRHypeChannle() ADC_Init(ADC_1, SPS_977, GAIN1,ADC1_AIN0,ADC1_AVSS)//IRH
|
|||
|
|
#define SetupBLChannle() ADC_Init(ADC_0, SPS_977, GAIN1,ADC0_AIN7,ADC0_AVSS)//<2F><><EFBFBD>ص<EFBFBD><D8B5><EFBFBD>
|
|||
|
|
#define SetupRDChannle() ADC_Init(ADC_1, SPS_977, GAIN1,ADC1_AIN2,ADC1_AVSS)//VRU
|
|||
|
|
#endif
|
|||
|
|
//---------------------------------------------------------------------------------
|
|||
|
|
|
|||
|
|
//---------------------------------------------------------------------------------------
|
|||
|
|
#define StartSamplingADC() { \
|
|||
|
|
ADC_SyncCmd(ENABLE); \
|
|||
|
|
DMA_ADC_Init(ADC_0, sampleProcess.ADC0Buffer, sampleProcess.CounterMax); \
|
|||
|
|
DMA_ADC_Init(ADC_1, sampleProcess.ADC1Buffer, sampleProcess.CounterMax); \
|
|||
|
|
DMA_StartADC(ADC_0); \
|
|||
|
|
DMA_StartADC(ADC_1); \
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#define StopSamplingADC() { \
|
|||
|
|
DMA_StopADC(ADC_0); \
|
|||
|
|
DMA_StopADC(ADC_1); \
|
|||
|
|
}
|
|||
|
|
//---------------------------------------------------------------------------------------
|
|||
|
|
#define sampleCTypeValue sampleProcess.ADC0Result
|
|||
|
|
#define sampleATypeValue sampleProcess.ADC1Result
|
|||
|
|
#define sampleRTypeValue sampleProcess.ADC1Result
|
|||
|
|
#define ReadADCData()
|
|||
|
|
//---------------------------------------------------------------------------------------
|
|||
|
|
// 125ms/250ms/500ms/1000ms/2000ms/4000ms <20><><EFBFBD>ڶ<EFBFBD>ʱ uploadCounter: <20><><EFBFBD><EFBFBD>ֵ(>32.768)<29><><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>ֵ=(32768/1000)*t t(ms)Ϊ<><CEAA><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
|||
|
|
//#define USE_LPTIMER0
|
|||
|
|
#define PrimaryTimer LPTIM1
|
|||
|
|
#define StartPrimaryTimer( uploadCounter ) StartLPTimer1( uploadCounter )
|
|||
|
|
#define ResetPrimaryTimer( uploadCounter ) ResetLPTimer1( uploadCounter )
|
|||
|
|
#define EnablePrimaryTimerInterrupt() EnableLPTimer1Interrupt()
|
|||
|
|
#define DisablePrimaryTimerInterrupt() DisableTimer1Interrupt()
|
|||
|
|
#define StopPrimaryTimer() StopLPTimer1()
|
|||
|
|
//#define PrimaryTimer_IRQ_Callback PrimaryTimer_IRQ_Callback// ManagePrimaryTimeInterval
|
|||
|
|
|
|||
|
|
//---------------------------------------------------------------------------------------
|
|||
|
|
// 1ms<6D><73><EFBFBD><D7BC>ʱ uploadCounter: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>Χ:(1~4000)
|
|||
|
|
//#define USE_TIMER2
|
|||
|
|
#define ProcessTimer TIM1
|
|||
|
|
#define ProcessTimerIT TIM_IT_CC1
|
|||
|
|
#define StartProcessTimer(uploadCounter) StartTimer1_CC1(uploadCounter)
|
|||
|
|
#define ResetProcessTimer(uploadCounter) ResetTimer1_CC1(uploadCounter)
|
|||
|
|
#define StopProcessTimer() StopTimer1()
|
|||
|
|
#define EnableProcessTimerInterrupt() NVIC_EnableIRQ(TIM1_IRQn); // EnableTimer2Interrupt()
|
|||
|
|
#define DisableProcessTimerInterrupt() NVIC_DisableIRQ(TIM1_IRQn); // DisableTimer2Interrupt()
|
|||
|
|
//#define Timer2InterruptCallBack()
|
|||
|
|
//#define ProcessTimer_IRQ_Callback ProcessTimerInterruptCallBack
|
|||
|
|
|
|||
|
|
//---------------------------------------------------------------------------------------
|
|||
|
|
//<2F>Ƚ϶<C8BD>ʱ uploadCounter: <20><><EFBFBD><EFBFBD>ֵ(1~65535)<29><><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>ֵ=(65535/4000)*t t(ms)Ϊ<><CEAA><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
|||
|
|
//#define USE_TIMER1
|
|||
|
|
//#define SamplingTimer TIM1
|
|||
|
|
//#define StartSamplingTimer(uploadCounter) StartTimer1_CC1(uploadCounter)
|
|||
|
|
//#define ResetSamplingTimer(uploadCounter) ResetTimer1_CC1(uploadCounter)
|
|||
|
|
//#define StopSamplingTimer() StopTimer1()
|
|||
|
|
//#define EnableSamplingInterrupt() NVIC_EnableIRQ(TIM1_IRQn); // EnableTimer1Interrupt()
|
|||
|
|
//#define DisableSamplingInterrupt() NVIC_DisableIRQ(TIM1_IRQn); // DisableTimer1Interrupt()
|
|||
|
|
//#define SamplingTimer_IRQ_Callback ProcessTimerInterruptCallBack
|
|||
|
|
|
|||
|
|
#define TEMP_SENSOR_RESULT RESULT_0_25_BIT
|
|||
|
|
|
|||
|
|
// *****************************************************************************
|
|||
|
|
// <20>ӱ<EFBFBD><EFBFBD><D7BC>λ <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ
|
|||
|
|
#define ONE_PA_TO_MBAR 0.01f // 1 Pa = 0.01 mbar
|
|||
|
|
#define ONE_PA_TO_TORR (1.0f / 133.322f) // 1 Pa = 1 / 133.322 Torr
|
|||
|
|
#define ONE_PA_TO_MICRONS (1000.0f / 133.322f) // 1 Pa = 1000 / 133.322 Microns
|
|||
|
|
|
|||
|
|
// <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ <20><> <20><><EFBFBD><D7BC>λ
|
|||
|
|
#define ONE_MBAR_TO_PA 100.0f // 1 mbar = 100 Pa
|
|||
|
|
#define ONE_TORR_TO_PA 133.322f // 1 Torr = 133.322 Pa
|
|||
|
|
#define ONE_MICRONS_TO_PA (133.322f / 1000.0f) // 1 Microns = 133.322 / 1000 Pa
|
|||
|
|
|
|||
|
|
// ѹ<><D1B9><EFBFBD><EFBFBD>λö<CEBB><C3B6>
|
|||
|
|
typedef enum {
|
|||
|
|
PRESSURE_UNIT_PA, // <20><>˹<EFBFBD><CBB9>
|
|||
|
|
PRESSURE_UNIT_MICRONS, // <><EFBFBD><D7B9><EFBFBD> (<28><>mHg)
|
|||
|
|
PRESSURE_UNIT_TORR, // <20><>
|
|||
|
|
PRESSURE_UNIT_MBAR // <20><><EFBFBD><EFBFBD>
|
|||
|
|
} PressureUnitType;
|
|||
|
|
// ѹ<><D1B9>ֵ<EFBFBD><D6B5> (<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Pa Ϊ<><CEAA>λ<EFBFBD>洢)
|
|||
|
|
typedef struct
|
|||
|
|
{
|
|||
|
|
u16 DisplayZero : 1; // 1
|
|||
|
|
u16 Mode: 2; // 3
|
|||
|
|
u16 CType: 1; // 5
|
|||
|
|
u16 AType: 2; // 7
|
|||
|
|
u16 PreSampling: 1; // 10
|
|||
|
|
u16 AutoDetectOffset: 1; // 11
|
|||
|
|
u16 AutoDetectProcess: 2; // 13
|
|||
|
|
u16 EnableRHTest : 1; // 14
|
|||
|
|
u16 EnableRoughTest: 1; // 15
|
|||
|
|
} __SAMPLE_STATUS_BIT_TypeDef;
|
|||
|
|
|
|||
|
|
typedef struct
|
|||
|
|
{
|
|||
|
|
__SAMPLE_STATUS_BIT_TypeDef State;
|
|||
|
|
u16 NextRun;
|
|||
|
|
u16 NextTime;
|
|||
|
|
u16 Counter;
|
|||
|
|
u16 CounterMax;
|
|||
|
|
u16 CTypeGain;
|
|||
|
|
u32 BLypeResult;//<2F><><EFBFBD>ص<EFBFBD><D8B5><EFBFBD>
|
|||
|
|
u32 RDResult;//VRD
|
|||
|
|
u32 RHypeResult;//VRH
|
|||
|
|
u32 IRHResult;//IRH
|
|||
|
|
u32 ADC0Result;
|
|||
|
|
u32 ADC1Result;
|
|||
|
|
u32 ADC0Buffer[70];
|
|||
|
|
u32 ADC1Buffer[70];
|
|||
|
|
} TypeSample;
|
|||
|
|
|
|||
|
|
|
|||
|
|
typedef struct
|
|||
|
|
{
|
|||
|
|
unsigned int CalTA;
|
|||
|
|
unsigned int Value[3];
|
|||
|
|
unsigned int DeltaVHH;
|
|||
|
|
unsigned int TUVHH;
|
|||
|
|
unsigned int TDVHH;
|
|||
|
|
unsigned int TUIndex;
|
|||
|
|
unsigned int TDIndex;
|
|||
|
|
} TypeCalibOffset;
|
|||
|
|
|
|||
|
|
// *****************************************************************************
|
|||
|
|
extern unsigned short int FRType;
|
|||
|
|
|
|||
|
|
//==========================================================
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̿<EFBFBD><CCBF><EFBFBD>
|
|||
|
|
//==========================================================
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӳ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
*/
|
|||
|
|
void FlowRateDealAndOuputSub(void);
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>벢ת<EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
*/
|
|||
|
|
void ComputeFlowRateIndexAndFlowRate(void);
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* @brief <EFBFBD>ּ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
*/
|
|||
|
|
u16 WordSubFunction(u16 minuend, u16 subtractor);
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD>жϻص<EFBFBD>
|
|||
|
|
*/
|
|||
|
|
void SamplingTimer_IRQ_Callback(void);
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (125ms<EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
|
|||
|
|
*/
|
|||
|
|
void StartNormolFlowMeasurement(void);
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
*/
|
|||
|
|
static void SetNextProcess(void);
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ADC<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
* @param sampleNum <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
*/
|
|||
|
|
void SetSystemForADCSample(u16 sampleNum);
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƽ<EFBFBD><EFBFBD>ֵ
|
|||
|
|
* @param sampleNum <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
* @param sampleShift <EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD> (<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƽ<EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD>)
|
|||
|
|
*/
|
|||
|
|
void ComputeSampleData(u16 sampleNum, u16 sampleShift);
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* @brief <EFBFBD>ر<EFBFBD>ģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>·
|
|||
|
|
*/
|
|||
|
|
void TurnOffAnalogCircuit(void);
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̹<EFBFBD><EFBFBD><EFBFBD>״̬<EFBFBD><EFBFBD>
|
|||
|
|
*/
|
|||
|
|
void FlowProcessManagement(void);
|
|||
|
|
|
|||
|
|
//==========================================================
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - ϵͳ<CFB5><CDB3>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
|||
|
|
//==========================================================
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>
|
|||
|
|
*/
|
|||
|
|
void CoreInit(void);
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD>жϻص<EFBFBD>
|
|||
|
|
*/
|
|||
|
|
void PrimaryTimer_IRQ_Callback(void);
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* @brief Timer2 <EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD> (<EFBFBD>ػ<EFBFBD><EFBFBD><EFBFBD>/<EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
|
|||
|
|
*/
|
|||
|
|
void My_Timer2_Callback(void);
|
|||
|
|
|
|||
|
|
//==========================================================
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><>ʾ<EFBFBD><CABE>UI
|
|||
|
|
//==========================================================
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* @brief <EFBFBD>л<EFBFBD>ѹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ
|
|||
|
|
*/
|
|||
|
|
void SwitchPressureUnit(void);
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* @brief ѹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>λת<EFBFBD><EFBFBD>
|
|||
|
|
* @param value ԭʼֵ
|
|||
|
|
* @param targetUnit Ŀ<EFBFBD>굥λ
|
|||
|
|
* @param originalUnit ԭʼ<EFBFBD><EFBFBD>λ
|
|||
|
|
* @return ת<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
|||
|
|
*/
|
|||
|
|
double ConvertPressure(double value, PressureUnitType targetUnit, PressureUnitType originalUnit);
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
*/
|
|||
|
|
void Update_Pressure_Display(void);
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* @brief <EFBFBD><EFBFBD><EFBFBD>ƾ<EFBFBD><EFBFBD>α߿<EFBFBD> (<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ)
|
|||
|
|
*/
|
|||
|
|
void OLED_DrawRect_Cache(u8 x, u8 y, u8 w, u8 h);
|
|||
|
|
|
|||
|
|
//==========================================================
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><>ѭ<EFBFBD><D1AD>
|
|||
|
|
//==========================================================
|
|||
|
|
/**
|
|||
|
|
* @brief ϵͳ<EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD>ѭ<EFBFBD><EFBFBD>
|
|||
|
|
*/
|
|||
|
|
void SystemPolling(void);
|
|||
|
|
//File End------------------------------------------------------------------
|
|||
|
|
#endif
|
|||
|
|
//.h End--------------------------------------------------------------------
|
|||
|
|
#endif
|