blob: 482b4b5cf3267d58b1f34c99d509e8afb729ecc3 (
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
|
/**
* @filename uG31xx_API_Measurement.h
*
* Header for uG31xx measurement API
*
* @author AllenTeng <allen_teng@upi-semi.com>
*/
typedef signed char _meas_s8_;
typedef unsigned char _meas_u8_;
typedef signed short _meas_s16_;
typedef unsigned short _meas_u16_;
typedef signed long _meas_s32_;
typedef unsigned long _meas_u32_;
typedef signed long long _meas_s64_;
typedef char _meas_bool_;
#define UG31XX_MEAS_VERSION (9)
#define BOARD_FACTOR_CONST (1000)
#define BOARD_FACTOR_VOLTAGE_GAIN (1000) ///< [AT-PM] : VBat1 board factor - gain ; 01/25/2013
#define BOARD_FACTOR_VOLTAGE_OFFSET (0) ///< [AT-PM] : VBat1 board factor - offset ; 01/25/2013
#define BOARD_FACTOR_CURR_GAIN (1014) ///< [AT-PM] : Current board factor - gain ; 01/25/2013
#define BOARD_FACTOR_CURR_OFFSET (-7) ///< [AT-PM] : Current board factor - offset ; 01/25/2013
#define BOARD_FACTOR_INTT_OFFSET (-23) ///< [AT-PM] : Internal Temperature board factor - offset ; 01/25/2013
#define BOARD_FACTOR_EXTT_OFFSET (13) ///< [AT-PM] : External Temperature board factor - offset ; 01/25/2013
#define CALIBRATION_FACTOR_CONST (1000)
#define COULOMB_COUNTER_RESET_THRESHOLD_COUNTER (10000)
#define COULOMB_COUNTER_RESET_THRESHOLD_CHARGE_CHG (30000)
#define COULOMB_COUNTER_RESET_THREDHOLD_CHARGE_DSG (-30000)
typedef enum _MEAS_RTN_CODE {
MEAS_RTN_PASS = 0,
MEAS_RTN_BATTERY_REMOVED,
MEAS_RTN_ADC_ABNORMAL,
MEAS_RTN_NTC_SHORT,
} MEAS_RTN_CODE;
typedef struct MeasDataST {
/// [AT-PM] : System data ; 04/08/2013
SystemDataType *sysData;
/// [AT-PM] : OTP data ; 01/23/2013
OtpDataType *otp;
/// [AT-PM] : Physical value ; 01/23/2013
_meas_u16_ bat1Voltage;
_meas_s16_ curr;
_meas_s16_ intTemperature;
_meas_s16_ extTemperature;
_meas_s16_ deltaCap;
_meas_s16_ stepCap;
_meas_u32_ deltaTime;
/// [AT-PM] : ADC code ; 01/23/2013
_meas_u16_ codeBat1;
_meas_s16_ codeCurrent;
_meas_u16_ codeIntTemperature;
_meas_u16_ codeExtTemperature;
_meas_s32_ codeCharge;
/// [AT-PM] : Coulomb counter offset ; 01/23/2013
_meas_s16_ ccOffset;
/// [AT-PM] : ADC1 characteristic ; 01/23/2013
_meas_u16_ adc1ConvertTime;
_meas_s32_ adc1Gain;
_meas_s32_ adc1GainSlope;
_meas_s32_ adc1GainFactorB;
_meas_s32_ adc1Offset;
_meas_s32_ adc1OffsetSlope;
_meas_s32_ adc1OffsetFactorO;
/// [AT-PM] : ADC2 characteristic ; 01/23/2013
_meas_s32_ adc2Gain;
_meas_s32_ adc2GainSlope;
_meas_s32_ adc2GainFactorB;
_meas_s32_ adc2Offset;
_meas_s32_ adc2OffsetSlope;
_meas_s32_ adc2OffsetFactorO;
/// [AT-PM] : Previous information ; 01/25/2013
_meas_u16_ lastCounter;
_meas_u32_ lastTimeTick;
_meas_s16_ lastDeltaCap;
/// [AT-PM] : In suspend mode operation ; 06/11/2013
_meas_bool_ inSuspendMode;
#if defined(uG31xx_OS_ANDROID)
} __attribute__ ((aligned(4))) MeasDataType;
#else ///< else of defined(uG31xx_OS_ANDROID)
} MeasDataType;
#endif ///< end of defined(uG31xx_OS_ANDROID)
/**
* @brief UpiResetCoulombCounter
*
* Reset coulomb counter
*
* @para data address of MeasDataType
* @return _UPI_NULL_
*/
extern void UpiResetCoulombCounter(MeasDataType *data);
/**
* @brief UpiMeasurement
*
* Measurement routine
*
* @para data address of MeasDataType
* @return MEAS_RTN_CODE
*/
extern MEAS_RTN_CODE UpiMeasurement(MeasDataType *data);
/**
* @brief UpiMeasAlarmThreshold
*
* Get alarm threshold
*
* @para data address of MeasDataType
* @return MEAS_RTN_CODE
*/
extern MEAS_RTN_CODE UpiMeasAlarmThreshold(MeasDataType *data);
|