comparison src/cs/drivers/drv_app/pwr/pwr_cust.h @ 145:246f4a7dd92b

src/cs/drivers/drv_app/pwr: import from MV100 source
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 09 Oct 2016 05:59:14 +0000
parents
children fb95e3f83dc5
comparison
equal deleted inserted replaced
144:fd8227e3047d 145:246f4a7dd92b
1 /*******************************************************************************
2 *
3 * pwr_cust.h
4 *
5 * Purpose: This file contains definitions for battery management.
6 * These definitions can be modified by the customer.
7 *
8 * Author Candice Bazanegue (c-brille@ti.com)
9 *
10 *
11 * (C) Texas Instruments 2001
12 *
13 ******************************************************************************/
14
15 #ifndef __PWR_CUST_H__
16 #define __PWR_CUST_H__
17
18 #include "pwr_api.h"
19
20
21 /* Constants relative to the battery type */
22
23 #define BAT_TYPE_LI_ION_MIN 0x400
24 #define BAT_TYPE_LI_ION_MAX 0x450
25
26
27 /* Constants relative to the charging process */
28
29 #define CONSTANT_VOLTAGE_VALUE 4200 // (mV) /* for CV charge */
30 #define CONSTANT_CURRENT_VALUE 500 // (mA) /* for CI charge */
31 #define END_OF_CHARGE_I 150 // (mA) /* for CV charge */
32 #define END_OF_CHARGE_V 4200 // (mV) /* for CI charge */
33
34 #define CHARGE_START_AGAIN_CAPACITY 75 /* capacity threshold under which */
35 /* the charge is started again if */
36 /* the charger has been left plugged. */
37 /* the chosen value must be part of the */
38 /* a_pwr_thresholds array. */
39
40
41 /* Constants relative to the battery temperature */
42
43 #define BAT_TEMPERATURE_MAX_LI_ION (50) /* Celsius degrees */
44 #define BAT_TEMPERATURE_MIN_LI_ION (0) /* Celsius degrees */
45
46 #define BAT_TEMPERATURE_MAX BAT_TEMPERATURE_MAX_LI_ION
47 #define BAT_TEMPERATURE_MIN BAT_TEMPERATURE_MIN_LI_ION
48
49
50 #define THEN_10uA 0x0041 /* THSENS0 , THSENS1, THSENS2 = 0, 0, 0 MESBAT = 1 */
51 #define THEN_30uA 0x0051 /* THSENS0 , THSENS1, THSENS2 = 0, 1, 0 MESBAT = 1 */
52 #define THEN_50uA 0x0061 /* THSENS0 , THSENS1, THSENS2 = 0, 0, 1 MESBAT = 1 */
53 #define THEN_80uA 0x0079 /* THSENS0 , THSENS1, THSENS2 = 1, 1, 1 MESBAT = 1 */
54 #define MESBAT 0x0001 /* Resistive divider connected to main battery */
55
56
57 /* Constants relative to the timers duration */
58 #define PWR_BAT_TEST_TIME_1 (10) /* 10 ms */
59 #define PWR_BAT_TEST_TIME_2 (5000) /* 5s */
60 #define PWR_CALIBRATION_TIME_1 (10) /* 10 ms */
61 #define PWR_CALIBRATION_TIME_2 (5000) /* 5s */
62 #define PWR_CI_CHECKING_TIME (4000) /* 4s */
63 #define PWR_CV_CHECKING_TIME (4000) /* 4s */
64 #define PWR_DISCHARGE_CHECKING_TIME_1 (60000) /* 1 minute */
65 #define PWR_DISCHARGE_CHECKING_TIME_2 (10000) /* 10s */
66
67
68 typedef struct {
69 UINT16 bat_voltage;
70 T_PWR_PERCENT remain_capa;
71 }T_PWR_THRESHOLDS;
72
73
74 typedef enum {
75 LI_ION,
76 UNKNOWN
77 } T_PWR_BATTERY_TYPE;
78
79
80 #define NB_THRESHOLDS (6) /* number of elements in the a_pwr_thresholds array */
81 extern const T_PWR_THRESHOLDS a_pwr_thresholds[NB_THRESHOLDS];
82
83
84
85
86
87 /* Prototypes */
88
89 UINT16 pwr_adc_to_mvolt(UINT16 bat_voltage_madc);
90 UINT16 pwr_adc_to_mA(UINT16 current_madc);
91 UINT8 pwr_bat_temp_within_limits(INT16 battery_temperature);
92 UINT8 pwr_madc_to_Celsius_conv(UINT8 bias_current, UINT16 madc_temp, INT16 *celsius_temp);
93 void pwr_get_battery_type(void);
94 void pwr_get_battery_temperature(void);
95 T_PWR_PERCENT pwr_get_capacity_vs_voltage(UINT16 bat_voltage);
96 void pwr_bat_50uA_temp_test_timer_process(void);
97 void pwr_bat_10uA_temp_test_timer_process(void);
98 void pwr_type_test_timer_process(void);
99
100 #endif /* __PWR_CUST_H__ */