// /****************************************************************************** // * Copyright (C) 2014-2015 HangZhou SiZhu Co.,LTD. // * // *----------------------------------------------------------------------------- // * File: pressure.c // * Description: get pressure of now and display it on OLED code // * Author: Lishoujian (867693272@qq.com) // * Date: Jan 8, 2015 // *****************************************************************************/ #include "pressure.h" #include "adc.h" #include "para.h" #include "devicegpioinit.h" #include "regdefine.h" #include "ads1120.h" float Get_pressure(float pre_vol); #define AD_REF_VOL 3000 #define AD_PRESSURE_CH 10 #define AD_CNT 40 /****************************************** * func: Get_pressure_volt * desc: get average voltage from pressure sensor. * input: none * output: none * return: average voltage:eg 1000 means voltage equal to 1.000v *****************************************/ float get_pressure(void) { // float vol; float tmp; /* vol = pressure_ad_value();//10 - channel 3300 - 3.3v vref if((vol > 0.095)||(vol < 0.001)) { return 0; } else { vol = vol * 1000; tmp = Get_pressure(vol); }*/ return tmp; } /****************************************** * func: Get_pressure * desc: transform the voltage of sampling to pressure * input: pre_vol - the voltage of sampling eg:(pre_vol max = 0.100v) 0.100v => 100 * output: none * return: bar - pressure of now:eg 160 means 16.0bar *****************************************/ float Get_kb_pressure(float pre_vol) { //pre_vol max <= 3300 float kpa; // kpa = pre_vol*system_para_control_run_g.pressure_para_k + system_para_control_run_g.pressure_para_b; return kpa; }