summaryrefslogtreecommitdiff
path: root/board/wmt/wmt_battery/gauge/upi/uG31xx_API_Capacity.h
blob: aa888caf698f3c6b606a0ffe01321e9581ab56b7 (plain)
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/**
 * @filename  uG31xx_API_Capacity.h
 *
 *  Header of uG31xx capacity algorithm
 *
 * @author  AllenTeng <allen_teng@upi-semi.com>
 */

typedef _upi_bool_            _cap_bool_;
typedef unsigned char   _cap_u8_;
typedef signed char     _cap_s8_;
typedef unsigned short  _cap_u16_;
typedef signed short    _cap_s16_;
typedef unsigned long   _cap_u32_;
typedef signed long     _cap_s32_;

#define CAP_FC_RELEASE_RSOC     (99)
#define UG31XX_CAP_VERSION      (36)
#define CAP_ENCRIPT_TABLE_SIZE  (TEMPERATURE_NUMS*C_RATE_NUMS*(SOV_NUMS - 1))

typedef struct CapacityDataST {

  /// [AT-PM] : Data from GGB file ; 01/25/2013
  CELL_PARAMETER *ggbParameter;
  CELL_TABLE *ggbTable;
  
  /// [AT-PM] : Measurement data ; 01/25/2013
  MeasDataType *measurement;

  /// [AT-PM] : Data for table backup ; 01/31/2013
  TableBackupType tableBackup[SOV_NUMS];
  _cap_u8_ encriptTable[CAP_ENCRIPT_TABLE_SIZE];

  /// [AT-PM] : Capacity information ; 01/25/2013
  _cap_u16_ rm;
  _cap_u16_ fcc;
  _cap_u16_ fccBackup;
  _cap_u8_ rsoc;

  /// [AT-PM] : Capacity operation variables ; 01/25/2013
  _cap_u32_ status;

  _cap_u32_ selfDsgMilliSec;
  _cap_u8_ selfDsgSec;
  _cap_u8_ selfDsgMin;
  _cap_u8_ selfDsgHour;
  _cap_u8_ selfDsgResidual;

  _cap_u8_ lastRsoc;

  _cap_u32_ tpTime;

  _cap_s32_ dsgCharge;
  _cap_s32_ dsgChargeStart;
  _cap_u32_ dsgChargeTime;
  _cap_s32_ preDsgCharge;

  _cap_u8_ tableUpdateIdx;
  _cap_u32_ tableUpdateDisqTime;
  _cap_u8_ tableUpdateDelayCnt;

  _cap_s8_ parseRMResidual;

  _cap_s16_ reverseCap;
  _cap_u8_ avgCRate;  

  _cap_s16_ ccRecord[SOV_NUMS];
#if defined(uG31xx_OS_ANDROID)
  } __attribute__ ((aligned(4))) CapacityDataType;
#else   ///< else of defined(uG31xx_OS_ANDROID)	      
  } CapacityDataType;
#endif  ///< end of defined(uG31xx_OS_ANDROID)

/**
 * @brief UpiInitCapacity
 *
 *  Initial capacity algorithm
 *
 * @para  data  address of CapacityDataType
 * @return  _UPI_NULL_
 */
extern void UpiInitCapacity(CapacityDataType *data);

/**
 * @brief UpiReadCapacity
 *
 *  Read capacity information
 *
 * @para  data  address of CapacityDataType
 * @return  _UPI_NULL_
 */
extern void UpiReadCapacity(CapacityDataType *data);

/**
 * @brief UpiTableCapacity
 *
 *  Look up capacity from table
 *
 * @para  data  address of CapacityDataType
 * @return  _UPI_NULL_
 */
extern void UpiTableCapacity(CapacityDataType *data);

/**
 * @brief UpiInitDsgCharge
 *
 *  Initialize data->dsgCharge value
 *
 * @para  data  address of CapacityDataType
 * @return  _UPI_NULL_
 */
extern void UpiInitDsgCharge(CapacityDataType *data);

/**
 * @brief UpiInitNacTable
 *
 *  Initialize NAC table
 *
 * @para  data  address of CapacityDataType
 * @return  _UPI_NULL_
 */
extern void UpiInitNacTable(CapacityDataType *data);

/**
 * @brief UpiSaveNacTable
 *
 *  Save NAC table to IC
 *
 * @para  data  address of CapacityDataType
 * @return  _UPI_NULL_
 */
extern void UpiSaveNacTable(CapacityDataType *data);