forked from SZV10X_Software/SZV103_FM33A0xxEV_SiZhu

周巍
2024-04-11 91ef77c00ed797b1048c5187f416e351e646a009
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
 
/******************************************************************************
 * Copyright (C) 2014-2015 HangZhou SiZhu Co.,LTD.
 *
 *-----------------------------------------------------------------------------
 * File:                 CFWRRD.c
 * Description:        compressibility factor write into flash or read from flash operation code
 * Author:              Lishoujian (867693272@qq.com)
 * Date:                Jan 8, 2015
 *****************************************************************************/
 
/* ----------------------- Platform includes --------------------------------*/
 
#include "CFWRRD.h"
#include "w25x40bv.h"
#include "pressure.h"
#include "temperature.h"
#include "factortab.h"
#include "delay.h"
 
 
 
 
void Factor_store(void)
{
      uint8 tep_addr,table_addr;
      uint32 wr_address;
    for(table_addr=0;table_addr<Table_Num;table_addr++)
     for(tep_addr=0;tep_addr<3;tep_addr++)
    {  
           wr_address=(table_addr<<14)|((tep_addr)<<8);
      Flash_Write((uint8*)factor_tab1,wr_address,152);
    }
}
 
 
uint32 Factor_read(void)
{
    uint16 tep_vol,pre_vol,pre,tep_addr,pre_addr;
    int16  tep;
    vuint8 tab_addr,tempfactor[2];
    uint32 rd_addr,factor;
    
//  tep_vol = Get_temperature_volt();
 // pre_vol = Get_pressure_volt();
//    pre = Get_pressure(pre_vol);
//    tep = Get_temperature(tep_vol);
    pre_addr=pre-10;
    if(pre%2==1)
        pre_addr = pre_addr-1;
    if((tep+100)%10<5)
        tep_addr = (tep+100)/10;
     else 
         tep_addr = (tep+100)/10+1;
    Flash_Read((uint8*)&tab_addr,0x40000,1);
  rd_addr = (tab_addr<<14) | (tep_addr<<8) | (pre_addr);
    Flash_Read((uint8*)tempfactor,rd_addr,2);
    factor = 90000+tempfactor[0]*100+tempfactor[1];
     
  return factor;
}