annotate src/cs/drivers/drv_app/pwr/pwr_liion_cha.c @ 640:16eb1b9640dc

target gtm900 renamed to gtm900mgc2 This change reflects the fact that the build target in question supports MGC2GSMT hardware only, and will NOT work on other hw that confusing bears the same end user name of GTM900, neither the LoCosto-based GTM900-C nor the Calypso-based MG01GSMT that has a different and incompatible RFFE. If we ever get our hands on a piece of MG01GSMT hw and add support for it, that other target will be named gtm900mg01.
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 31 Jan 2020 00:46:07 +0000
parents c93a236e0d50
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
145
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*******************************************************************************
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 *
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * pwr_liion_cha.c
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 *
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 * Purpose: This file contains functions for managing the Li-ion batteries
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 * charging process.
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 *
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 * Author Candice Bazanegue (c-brille@ti.com)
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 *
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 *
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 * (C) Texas Instruments 2001
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 *
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 ******************************************************************************/
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14
151
c93a236e0d50 PWR SWE compiles
Mychaela Falconia <falcon@freecalypso.org>
parents: 146
diff changeset
15 #include "rv/rv_defined_swe.h" // for RVM_PWR_SWE
145
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 #ifdef RVM_PWR_SWE
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18
151
c93a236e0d50 PWR SWE compiles
Mychaela Falconia <falcon@freecalypso.org>
parents: 146
diff changeset
19 #include "rvm/rvm_use_id_list.h"
c93a236e0d50 PWR SWE compiles
Mychaela Falconia <falcon@freecalypso.org>
parents: 146
diff changeset
20 #include "spi/spi_task.h"
c93a236e0d50 PWR SWE compiles
Mychaela Falconia <falcon@freecalypso.org>
parents: 146
diff changeset
21 #include "spi/spi_api.h"
c93a236e0d50 PWR SWE compiles
Mychaela Falconia <falcon@freecalypso.org>
parents: 146
diff changeset
22 #include "pwr/pwr_cust.h"
c93a236e0d50 PWR SWE compiles
Mychaela Falconia <falcon@freecalypso.org>
parents: 146
diff changeset
23 #include "pwr/pwr_liion_cha.h"
c93a236e0d50 PWR SWE compiles
Mychaela Falconia <falcon@freecalypso.org>
parents: 146
diff changeset
24 #include "pwr/pwr_disch.h"
c93a236e0d50 PWR SWE compiles
Mychaela Falconia <falcon@freecalypso.org>
parents: 146
diff changeset
25 #include "spi/spi_env.h"
c93a236e0d50 PWR SWE compiles
Mychaela Falconia <falcon@freecalypso.org>
parents: 146
diff changeset
26 #include "rvf/rvf_api.h"
c93a236e0d50 PWR SWE compiles
Mychaela Falconia <falcon@freecalypso.org>
parents: 146
diff changeset
27 #include "pwr/pwr_analog_dev.h"
c93a236e0d50 PWR SWE compiles
Mychaela Falconia <falcon@freecalypso.org>
parents: 146
diff changeset
28 #include "pwr/pwr_messages.h"
145
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 /* Global variable */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 extern T_SPI_GBL_INFO *SPI_GBL_INFO_PTR;
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 /*******************************************************************************
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 ** Function pwr_start_CI_charging
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 **
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 ** Description This function is used to start the constant current
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 ** battery charging.
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 **
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 *******************************************************************************/
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 void pwr_start_CI_charging(unsigned short charging_current)
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 {
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 volatile unsigned short dac_current_code;
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 rvf_send_trace("Start CI charging",17, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, PWR_USE_ID);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 dac_current_code = (unsigned int)((1000 * charging_current)/DAC_CURRENT_STEP);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 /* Select constant current charging. The charger is disabled */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 ABB_Write_Register_on_page(PAGE0, BCICTL2, 0x0002);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 /* Program the DAC with the constant current value */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 ABB_Write_Register_on_page(PAGE0, CHGREG, dac_current_code);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 /* Enable the charger */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 ABB_Write_Register_on_page(PAGE0, BCICTL2, 0x0003);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 pwr_env_ctrl_blk->charging_state = CI_CHARGE_STARTED;
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 /*******************************************************************************
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 ** Function pwr_start_CV_charging
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 **
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 ** Description This function is used to start the constant voltage
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 ** battery charging.
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 **
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 *******************************************************************************/
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 void pwr_start_CV_charging(unsigned short charging_voltage)
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 {
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 volatile unsigned short dac_voltage_code;
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 unsigned short dac_voltage;
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 rvf_send_trace("Start CV charging",17, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, PWR_USE_ID);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 dac_voltage = charging_voltage + VOLTAGE_LOOP_OFFSET;
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 dac_voltage_code = (unsigned int)((1000 * ((dac_voltage /4) - DAC_THRESHOLD))/DAC_VOLTAGE_STEP);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 rvf_send_trace("Voltage (DAC code) ", 19, dac_voltage_code, RV_TRACE_LEVEL_DEBUG_LOW, PWR_USE_ID);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83 /* Select constant voltage charging. The charger is disabled */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84 ABB_Write_Register_on_page(PAGE0, BCICTL2, 0);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 /* Program the DAC with the constant voltage value */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87 ABB_Write_Register_on_page(PAGE0, CHGREG, dac_voltage_code);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89 /* Enable the charger */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90 ABB_Write_Register_on_page(PAGE0, BCICTL2, 0x0001);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92 pwr_env_ctrl_blk->charging_state = CV_CHARGE_STARTED;
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98 /*******************************************************************************
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99 ** Function pwr_stop_charging
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100 **
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
101 ** Description This function is used to stop the battery charging process.
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
102 **
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
103 *******************************************************************************/
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
104 void pwr_stop_charging(void)
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
105 {
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
106
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
107 rvf_send_trace("Stop charging process",21, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, PWR_USE_ID);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
108 ABB_Write_Register_on_page(PAGE0, BCICTL2, 0);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
109 pwr_env_ctrl_blk->charging_state = CHARGE_STOPPED;
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
110 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
111
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
112
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
113
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
114
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
115 /*******************************************************************************
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
116 ** Function pwr_current_loop_cal
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
117 **
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
118 ** Description This function is used to evaluate the offset introduced
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
119 ** by the current to voltage converter in the current loop.
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
120 **
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
121 **
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
122 *******************************************************************************/
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
123 void pwr_current_loop_cal(void)
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
124 {
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
125 rvf_send_trace("Current loop calibration",24, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, PWR_USE_ID);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
126
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
127 /* Set the CHDISPA bit */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
128 /* And start the zero calibration routine of the I to V converter */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
129 ABB_Write_Register_on_page(PAGE0, BCICTL2, 0x0010);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
130 ABB_Write_Register_on_page(PAGE0, BCICTL2, 0x0019);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
131
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
132 if (SPI_GBL_INFO_PTR->is_adc_on == FALSE)
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
133 {
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
134 /* start ICHG channel conversion by writing in the result register */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
135 ABB_Write_Register_on_page(PAGE0, ICHGREG, 0x0000);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
136
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
137 rvf_start_timer (SPI_TIMER0,
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
138 RVF_MS_TO_TICKS (SPI_TIMER0_INTERVAL_3),
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
139 FALSE);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
140 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
141 else /* The L1 asks for ADC conversions */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
142 {
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
143 rvf_start_timer (SPI_TIMER0,
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
144 RVF_MS_TO_TICKS (SPI_TIMER0_INTERVAL_4),
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
145 FALSE);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
146 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
147
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
148 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
149
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
150
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
151
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
152 /*******************************************************************************
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
153 ** Function pwr_calibration_process
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
154 **
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
155 ** Description
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
156 **
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
157 *******************************************************************************/
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
158 void pwr_calibration_process(void)
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
159 {
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
160 if (pwr_bat_temp_within_limits(pwr_env_ctrl_blk->bat_celsius_temp))
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
161 {
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
162 pwr_env_ctrl_blk->timer0_state = BATTERY_CALIBRATION;
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
163 pwr_current_loop_cal();
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
164 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
165 else
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
166 {
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
167 /* informs the upper layer that the battery temperature is not correct */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
168 pwr_send_charge_not_possible_event(BAT_TEMP_OUTSIDE_LIMITS);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
169 if (SPI_GBL_INFO_PTR->is_gsm_on == FALSE) /* GSM OFF */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
170 {
146
fb95e3f83dc5 imported PWR source: s/ANALOG/ANLG_FAM/ for TCS211 environment
Mychaela Falconia <falcon@freecalypso.org>
parents: 145
diff changeset
171 #if (ANLG_FAM == 1)
145
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
172 ABB_Write_Register_on_page(PAGE0, VRPCCTL2, 0x00EE);
146
fb95e3f83dc5 imported PWR source: s/ANALOG/ANLG_FAM/ for TCS211 environment
Mychaela Falconia <falcon@freecalypso.org>
parents: 145
diff changeset
173 #elif (ANLG_FAM == 2)
145
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
174 ABB_Write_Register_on_page(PAGE0, VRPCDEV, 0x0001);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
175 #endif
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
176 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
177 else
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
178 {
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
179 pwr_handle_discharge();
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
180 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
181 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
182 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
183
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
184
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
185
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
186
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
187 /*******************************************************************************
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
188 ** Function pwr_battery_qualification
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
189 **
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
190 ** Description Battery open and short tests
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
191 **
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
192 *******************************************************************************/
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
193 void pwr_battery_qualification(void)
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
194 {
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
195 rvf_send_trace("Battery qualification",21, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, PWR_USE_ID);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
196
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
197 pwr_env_ctrl_blk->timer0_state = BATTERY_SHORT_TEST;
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
198
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
199 /* Short test */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
200 pwr_start_CI_charging(CONSTANT_CURRENT_VALUE);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
201 if (SPI_GBL_INFO_PTR->is_adc_on == FALSE)
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
202 {
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
203 /* Start VBAT channel conversion by writing in the result register */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
204 ABB_Write_Register_on_page(PAGE0, VBATREG, 0x0000);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
205 rvf_start_timer (SPI_TIMER0,
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
206 RVF_MS_TO_TICKS (SPI_TIMER0_INTERVAL_1),
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
207 FALSE);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
208 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
209 else
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
210 {
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
211 /* Let time for the L1 to ask for new AD conversions */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
212 rvf_start_timer (SPI_TIMER0,
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
213 RVF_MS_TO_TICKS (SPI_TIMER0_INTERVAL_2),
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
214 FALSE);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
215 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
216
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
217 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
218
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
219
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
220
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
221 /********************************************************************************/
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
222 /* */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
223 /* Function Name: pwr_start_fast_charge */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
224 /* */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
225 /* Purpose: Starts the fast charging process for Li-ion batteries */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
226 /* */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
227 /* */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
228 /********************************************************************************/
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
229 void pwr_start_fast_charge(void)
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
230 {
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
231 UINT16 i2v_dac_offset_mA;
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
232
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
233 /* Informs the upper layer that the charging process has started */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
234 pwr_send_CI_charge_start_event();
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
235
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
236 /* Connect resistive bridge to main battery */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
237 ABB_Write_Register_on_page(PAGE0, BCICTL1, MESBAT);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
238
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
239 /* Start the constant current charging */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
240 i2v_dac_offset_mA = (UINT16)((MADC_CURRENT_STEP*pwr_env_ctrl_blk->i2v_madc_offset)/1000);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
241
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
242 pwr_start_CI_charging((unsigned short)(CONSTANT_CURRENT_VALUE + i2v_dac_offset_mA));
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
243
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
244 rvf_start_timer (SPI_TIMER1,
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
245 RVF_MS_TO_TICKS (SPI_TIMER1_INTERVAL),
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
246 FALSE);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
247 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
248
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
249
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
250
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
251 /********************************************************************************/
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
252 /* */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
253 /* Function Name: pwr_short_test_timer_process */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
254 /* */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
255 /* Purpose: */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
256 /* */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
257 /* */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
258 /********************************************************************************/
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
259 void pwr_short_test_timer_process(void)
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
260 {
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
261 UINT16 Vbat_test;
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
262
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
263 rvf_send_trace("TIMER0: Battery short test",26, NULL_PARAM, RV_TRACE_LEVEL_WARNING, PWR_USE_ID);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
264
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
265 /* Read ADC result */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
266 Vbat_test = ABB_Read_Register_on_page(PAGE0, VBATREG);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
267 rvf_send_trace("Vbat (MADC code) ",17, Vbat_test, RV_TRACE_LEVEL_WARNING, PWR_USE_ID);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
268
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
269 pwr_stop_charging();
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
270
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
271 if (Vbat_test > 0)
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
272 {
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
273 pwr_env_ctrl_blk->timer0_state = BATTERY_OPEN_TEST;
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
274
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
275 /* Start open test */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
276 pwr_start_CV_charging(CONSTANT_VOLTAGE_VALUE);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
277 rvf_delay(RVF_MS_TO_TICKS(5));
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
278
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
279 if (SPI_GBL_INFO_PTR->is_adc_on == FALSE)
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
280 {
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
281 /* start ICHG channel conversion by writing in the result register */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
282 ABB_Write_Register_on_page(PAGE0, ICHGREG, 0x0000);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
283 rvf_start_timer (SPI_TIMER0,
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
284 RVF_MS_TO_TICKS (SPI_TIMER0_INTERVAL_1),
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
285 FALSE);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
286 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
287 else
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
288 {
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
289 /* Let time for the L1 to ask for new AD conversions */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
290 rvf_start_timer (SPI_TIMER0,
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
291 RVF_MS_TO_TICKS (SPI_TIMER0_INTERVAL_2),
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
292 FALSE);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
293 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
294 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
295 else
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
296 {
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
297 rvf_send_trace("Short battery",13, NULL_PARAM, RV_TRACE_LEVEL_WARNING, PWR_USE_ID);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
298
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
299 /* informs the upper layer that the short test has failed */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
300 pwr_send_charge_not_possible_event(BAT_SHORT_TEST_FAILED);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
301 if (SPI_GBL_INFO_PTR->is_gsm_on == FALSE) /* GSM OFF */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
302 {
146
fb95e3f83dc5 imported PWR source: s/ANALOG/ANLG_FAM/ for TCS211 environment
Mychaela Falconia <falcon@freecalypso.org>
parents: 145
diff changeset
303 #if (ANLG_FAM == 1)
145
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
304 ABB_Write_Register_on_page(PAGE0, VRPCCTL2, 0x00EE);
146
fb95e3f83dc5 imported PWR source: s/ANALOG/ANLG_FAM/ for TCS211 environment
Mychaela Falconia <falcon@freecalypso.org>
parents: 145
diff changeset
305 #elif (ANLG_FAM == 2)
145
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
306 ABB_Write_Register_on_page(PAGE0, VRPCDEV, 0x0001);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
307 #endif
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
308 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
309 else
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
310 {
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
311 pwr_handle_discharge();
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
312 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
313 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
314 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
315
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
316
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
317
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
318 /********************************************************************************/
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
319 /* */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
320 /* Function Name: pwr_open_test_timer_process */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
321 /* */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
322 /* Purpose: */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
323 /* */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
324 /* */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
325 /********************************************************************************/
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
326 void pwr_open_test_timer_process(void)
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
327 {
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
328 UINT16 Ichg_test;
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
329
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
330 rvf_send_trace("TIMER0: Battery open test",25, NULL_PARAM, RV_TRACE_LEVEL_WARNING, PWR_USE_ID);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
331
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
332 /* Read ADC result */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
333 Ichg_test = ABB_Read_Register_on_page(PAGE0, ICHGREG);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
334 rvf_send_trace("Charge current (MADC code) ",27, Ichg_test, RV_TRACE_LEVEL_DEBUG_LOW, PWR_USE_ID);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
335
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
336 pwr_stop_charging();
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
337
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
338 if (Ichg_test > 0) /* Battery OK */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
339 {
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
340 rvf_send_trace("Battery OK",10, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, PWR_USE_ID);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
341
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
342 /* Check if the initial battery temperature is correct */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
343 pwr_env_ctrl_blk->charging_state = TESTING_BATTERY;
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
344 pwr_get_battery_temperature();
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
345 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
346
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
347 else /* Open battery */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
348 {
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
349 rvf_send_trace("Open battery",12, NULL_PARAM, RV_TRACE_LEVEL_WARNING, PWR_USE_ID);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
350
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
351 /* informs the upper layer that the open test has failed */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
352 pwr_send_charge_not_possible_event(BAT_OPEN_TEST_FAILED);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
353 if (SPI_GBL_INFO_PTR->is_gsm_on == FALSE) /* GSM OFF */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
354 {
146
fb95e3f83dc5 imported PWR source: s/ANALOG/ANLG_FAM/ for TCS211 environment
Mychaela Falconia <falcon@freecalypso.org>
parents: 145
diff changeset
355 #if (ANLG_FAM == 1)
145
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
356 ABB_Write_Register_on_page(PAGE0, VRPCCTL2, 0x00EE);
146
fb95e3f83dc5 imported PWR source: s/ANALOG/ANLG_FAM/ for TCS211 environment
Mychaela Falconia <falcon@freecalypso.org>
parents: 145
diff changeset
357 #elif (ANLG_FAM == 2)
145
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
358 ABB_Write_Register_on_page(PAGE0, VRPCDEV, 0x0001);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
359 #endif
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
360 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
361 else
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
362 {
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
363 pwr_handle_discharge();
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
364 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
365 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
366 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
367
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
368
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
369
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
370 /********************************************************************************/
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
371 /* */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
372 /* Function Name: pwr_cal_timer_process */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
373 /* */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
374 /* Purpose: */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
375 /* */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
376 /* */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
377 /********************************************************************************/
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
378 void pwr_cal_timer_process(void)
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
379 {
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
380 rvf_send_trace("TIMER0: Battery calibration",27, NULL_PARAM, RV_TRACE_LEVEL_WARNING, PWR_USE_ID);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
381
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
382 pwr_env_ctrl_blk->i2v_madc_offset = ABB_Read_Register_on_page(PAGE0, ICHGREG);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
383
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
384 rvf_send_trace("i2v offset (MADC code) ", 23, pwr_env_ctrl_blk->i2v_madc_offset, RV_TRACE_LEVEL_DEBUG_LOW, PWR_USE_ID);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
385 pwr_stop_charging();
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
386
146
fb95e3f83dc5 imported PWR source: s/ANALOG/ANLG_FAM/ for TCS211 environment
Mychaela Falconia <falcon@freecalypso.org>
parents: 145
diff changeset
387 #if (ANLG_FAM == 2)
145
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
388 if (pwr_env_ctrl_blk->i2v_madc_offset == 0)
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
389 {
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
390 /* IOTA: the offset can be made positive and minimized programming */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
391 /* the OFFEN and OFFSN bits in the BCICONF register */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
392 ABB_Write_Register_on_page(PAGE1, BCICONF, 0x001F);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
393 pwr_current_loop_cal();
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
394 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
395 else
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
396 {
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
397 /* the i2v calibration must be done before this initialization */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
398 pwr_env_ctrl_blk->madc_eoc_current_code = (UINT16)(1000 * END_OF_CHARGE_I / MADC_CURRENT_STEP) + pwr_env_ctrl_blk->i2v_madc_offset;
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
399
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
400 rvf_send_trace("End of charge current (MADC code) ", 34, pwr_env_ctrl_blk->madc_eoc_current_code, RV_TRACE_LEVEL_DEBUG_LOW, PWR_USE_ID);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
401
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
402 /* Start the fast charging cycle */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
403 pwr_start_fast_charge();
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
404 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
405
146
fb95e3f83dc5 imported PWR source: s/ANALOG/ANLG_FAM/ for TCS211 environment
Mychaela Falconia <falcon@freecalypso.org>
parents: 145
diff changeset
406 #elif (ANLG_FAM == 1)
145
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
407 /* the i2v calibration must be done before this initialization */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
408 pwr_env_ctrl_blk->madc_eoc_current_code = (UINT16)(1000 * END_OF_CHARGE_I / MADC_CURRENT_STEP) + pwr_env_ctrl_blk->i2v_madc_offset;
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
409
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
410 rvf_send_trace("End of charge current (MADC code) ", 34, pwr_env_ctrl_blk->madc_eoc_current_code, RV_TRACE_LEVEL_DEBUG_LOW, PWR_USE_ID);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
411
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
412 /* Start the fast charging cycle */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
413 pwr_start_fast_charge();
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
414
146
fb95e3f83dc5 imported PWR source: s/ANALOG/ANLG_FAM/ for TCS211 environment
Mychaela Falconia <falcon@freecalypso.org>
parents: 145
diff changeset
415 #endif /* #if (ANLG_FAM == 2) */
145
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
416 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
417
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
418
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
419
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
420
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
421 /********************************************************************************/
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
422 /* */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
423 /* Function Name: pwr_CI_charge_process */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
424 /* */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
425 /* Purpose: */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
426 /* */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
427 /* */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
428 /********************************************************************************/
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
429 void pwr_CI_charge_process(void)
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
430 {
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
431 UINT16 vbat;
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
432 UINT16 ichg;
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
433
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
434 /* Check if the battery temperature is still correct */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
435 if (pwr_bat_temp_within_limits(pwr_env_ctrl_blk->bat_celsius_temp))
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
436 {
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
437 if (SPI_GBL_INFO_PTR->is_adc_on == FALSE)
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
438 {
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
439 /* start VBAT channel conversion by writing in the result register */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
440 ABB_Write_Register_on_page(PAGE0, VBATREG, 0x0000);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
441 rvf_delay(RVF_MS_TO_TICKS(5));
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
442 vbat = ABB_Read_Register_on_page(PAGE0, VBATREG);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
443 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
444 else
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
445 {
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
446 /* Use the ADC conversions results from the L1 */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
447 vbat = SPI_GBL_INFO_PTR->adc_result[0];
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
448 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
449
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
450 rvf_send_trace("TIMER1", 6, NULL_PARAM, RV_TRACE_LEVEL_WARNING, PWR_USE_ID);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
451 rvf_send_trace("Vbat (MADC code) ", 17, vbat, RV_TRACE_LEVEL_DEBUG_LOW, PWR_USE_ID);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
452
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
453 if (vbat < pwr_env_ctrl_blk->max_voltage_code)
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
454 {
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
455 rvf_start_timer (SPI_TIMER1, RVF_MS_TO_TICKS (SPI_TIMER1_INTERVAL), FALSE);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
456 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
457 else
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
458 {
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
459 pwr_stop_charging();
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
460 pwr_send_CV_charge_start_event();
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
461 pwr_start_CV_charging(CONSTANT_VOLTAGE_VALUE);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
462 rvf_start_timer (SPI_TIMER2, RVF_MS_TO_TICKS (SPI_TIMER2_INTERVAL), FALSE);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
463 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
464
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
465 if (SPI_GBL_INFO_PTR->is_adc_on == FALSE)
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
466 {
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
467 /* start ICHG channel conversion by writing in the result register */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
468 ABB_Write_Register_on_page(PAGE0, ICHGREG, 0x0000);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
469 rvf_delay(RVF_MS_TO_TICKS(5));
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
470 ichg = ABB_Read_Register_on_page(PAGE0, ICHGREG);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
471 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
472 else
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
473 {
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
474 ichg = SPI_GBL_INFO_PTR->adc_result[2];
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
475 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
476
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
477 rvf_send_trace("Ichg (MADC code) ", 17, ichg, RV_TRACE_LEVEL_DEBUG_LOW, PWR_USE_ID);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
478 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
479
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
480 else /* battery temperature not correct !!! */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
481 {
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
482 pwr_stop_charging();
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
483 rvf_send_trace("Battery temperature not correct! ",33, NULL_PARAM, RV_TRACE_LEVEL_WARNING, PWR_USE_ID);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
484
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
485 /* informs the upper layer that the battery temperature is not correct */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
486 pwr_send_charge_not_possible_event(BAT_TEMP_OUTSIDE_LIMITS);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
487
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
488 if (SPI_GBL_INFO_PTR->is_gsm_on == FALSE) /* GSM OFF */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
489 {
146
fb95e3f83dc5 imported PWR source: s/ANALOG/ANLG_FAM/ for TCS211 environment
Mychaela Falconia <falcon@freecalypso.org>
parents: 145
diff changeset
490 #if (ANLG_FAM == 1)
145
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
491 ABB_Write_Register_on_page(PAGE0, VRPCCTL2, 0x00EE);
146
fb95e3f83dc5 imported PWR source: s/ANALOG/ANLG_FAM/ for TCS211 environment
Mychaela Falconia <falcon@freecalypso.org>
parents: 145
diff changeset
492 #elif (ANLG_FAM == 2)
145
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
493 ABB_Write_Register_on_page(PAGE0, VRPCDEV, 0x0001);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
494 #endif
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
495 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
496 else
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
497 {
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
498 pwr_handle_discharge();
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
499 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
500 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
501 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
502
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
503
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
504
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
505
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
506 /********************************************************************************/
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
507 /* */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
508 /* Function Name: pwr_CI_charge_timer_process */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
509 /* */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
510 /* Purpose: */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
511 /* */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
512 /* */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
513 /********************************************************************************/
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
514 void pwr_CI_charge_timer_process(void)
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
515 {
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
516 UINT16 status_value;
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
517
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
518 status_value = ABB_Read_Status();
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
519 if (status_value & CHGPRES) /* if the charger is still plugged */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
520 {
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
521 pwr_get_battery_temperature();
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
522 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
523 else
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
524 {
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
525 /* informs the upper layer that the charging process has stopped */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
526 pwr_send_charge_stop_event();
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
527 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
528 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
529
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
530
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
531
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
532
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
533 /********************************************************************************/
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
534 /* */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
535 /* Function Name: pwr_CV_charge_process */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
536 /* */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
537 /* Purpose: */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
538 /* */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
539 /* */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
540 /********************************************************************************/
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
541 void pwr_CV_charge_process(void)
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
542 {
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
543 UINT16 vbat;
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
544 UINT16 ichg;
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
545
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
546 /* Check if the battery temperature is still correct */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
547 if (pwr_bat_temp_within_limits(pwr_env_ctrl_blk->bat_celsius_temp))
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
548 {
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
549 if (SPI_GBL_INFO_PTR->is_adc_on == FALSE)
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
550 {
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
551 /* start ICHG channel conversion by writing in the result register */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
552 ABB_Write_Register_on_page(PAGE0, ICHGREG, 0x0000);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
553 rvf_delay(RVF_MS_TO_TICKS(5));
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
554 ichg = ABB_Read_Register_on_page(PAGE0, ICHGREG);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
555 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
556 else
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
557 {
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
558 ichg = SPI_GBL_INFO_PTR->adc_result[2];
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
559 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
560
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
561 rvf_send_trace("TIMER2",6, NULL_PARAM, RV_TRACE_LEVEL_WARNING, PWR_USE_ID);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
562 rvf_send_trace("Ichg (MADC code) ", 17, ichg, RV_TRACE_LEVEL_DEBUG_LOW, PWR_USE_ID);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
563
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
564 if (SPI_GBL_INFO_PTR->is_adc_on == FALSE)
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
565 {
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
566 /* start VBAT channel conversion by writing in the result register */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
567 ABB_Write_Register_on_page(PAGE0, VBATREG, 0x0000);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
568 rvf_delay(RVF_MS_TO_TICKS(5));
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
569 vbat = ABB_Read_Register_on_page(PAGE0, VBATREG);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
570 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
571 else
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
572 {
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
573 /* Use the ADC results asked for by the layer 1 */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
574 vbat = SPI_GBL_INFO_PTR->adc_result[0];
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
575 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
576
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
577 rvf_send_trace("Vbat (MADC code) ", 17, vbat, RV_TRACE_LEVEL_DEBUG_LOW, PWR_USE_ID);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
578 if (ichg > pwr_env_ctrl_blk->madc_eoc_current_code)
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
579 {
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
580 rvf_start_timer (SPI_TIMER2, RVF_MS_TO_TICKS (SPI_TIMER2_INTERVAL), FALSE);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
581 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
582 else
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
583 {
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
584 pwr_stop_charging();
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
585 /* informs the upper layer that the charging process has stopped */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
586 pwr_send_charge_stop_event();
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
587 rvf_send_trace("Fast charge termination criterion",33, NULL_PARAM,
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
588 RV_TRACE_LEVEL_DEBUG_LOW, PWR_USE_ID);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
589
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
590 if (SPI_GBL_INFO_PTR->is_gsm_on == FALSE) /* GSM OFF */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
591 {
146
fb95e3f83dc5 imported PWR source: s/ANALOG/ANLG_FAM/ for TCS211 environment
Mychaela Falconia <falcon@freecalypso.org>
parents: 145
diff changeset
592 #if (ANLG_FAM == 1)
145
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
593 ABB_Write_Register_on_page(PAGE0, VRPCCTL2, 0x00EE);
146
fb95e3f83dc5 imported PWR source: s/ANALOG/ANLG_FAM/ for TCS211 environment
Mychaela Falconia <falcon@freecalypso.org>
parents: 145
diff changeset
594 #elif (ANLG_FAM == 2)
145
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
595 ABB_Write_Register_on_page(PAGE0, VRPCDEV, 0x0001);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
596 #endif
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
597 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
598 else
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
599 {
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
600 pwr_handle_discharge();
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
601 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
602 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
603 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
604
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
605 else /* Battery temperature not correct !!! */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
606 {
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
607 pwr_stop_charging();
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
608 rvf_send_trace("Battery temperature not correct! ",33, NULL_PARAM, RV_TRACE_LEVEL_WARNING, PWR_USE_ID);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
609
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
610 /* informs the upper layer that the battery temperature is not correct */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
611 pwr_send_charge_not_possible_event(BAT_TEMP_OUTSIDE_LIMITS);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
612
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
613 if (SPI_GBL_INFO_PTR->is_gsm_on == FALSE) /* GSM OFF */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
614 {
146
fb95e3f83dc5 imported PWR source: s/ANALOG/ANLG_FAM/ for TCS211 environment
Mychaela Falconia <falcon@freecalypso.org>
parents: 145
diff changeset
615 #if (ANLG_FAM == 1)
145
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
616 ABB_Write_Register_on_page(PAGE0, VRPCCTL2, 0x00EE);
146
fb95e3f83dc5 imported PWR source: s/ANALOG/ANLG_FAM/ for TCS211 environment
Mychaela Falconia <falcon@freecalypso.org>
parents: 145
diff changeset
617 #elif (ANLG_FAM == 2)
145
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
618 ABB_Write_Register_on_page(PAGE0, VRPCDEV, 0x0001);
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
619 #endif
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
620 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
621 else
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
622 {
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
623 pwr_handle_discharge();
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
624 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
625 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
626 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
627
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
628
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
629
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
630
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
631 /********************************************************************************/
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
632 /* */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
633 /* Function Name: pwr_CV_charge_timer_process */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
634 /* */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
635 /* Purpose: */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
636 /* */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
637 /* */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
638 /********************************************************************************/
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
639 void pwr_CV_charge_timer_process(void)
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
640 {
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
641 UINT16 status_value;
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
642
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
643 status_value = ABB_Read_Status();
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
644 if (status_value & CHGPRES) /* if the charger is still plugged */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
645 {
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
646 /* Control the battery temperature */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
647 pwr_get_battery_temperature();
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
648 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
649 else
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
650 {
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
651 /* informs the upper layer that the charging process has stopped */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
652 pwr_send_charge_stop_event();
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
653 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
654 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
655
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
656
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
657
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
658
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
659 /********************************************************************************/
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
660 /* */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
661 /* Function Name: pwr_bat_test_timer_process */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
662 /* */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
663 /* Purpose: */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
664 /* */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
665 /* */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
666 /********************************************************************************/
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
667 void pwr_bat_test_timer_process(void)
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
668 {
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
669 if (pwr_env_ctrl_blk->timer0_state == BATTERY_TYPE_TEST)
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
670 {
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
671 pwr_type_test_timer_process();
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
672 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
673 else if (pwr_env_ctrl_blk->timer0_state == BATTERY_SHORT_TEST)
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
674 {
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
675 pwr_short_test_timer_process();
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
676 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
677 else if (pwr_env_ctrl_blk->timer0_state == BATTERY_OPEN_TEST)
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
678 {
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
679 pwr_open_test_timer_process();
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
680 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
681 else if (pwr_env_ctrl_blk->timer0_state == BATTERY_50UA_TEMP_TEST)
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
682 {
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
683 pwr_bat_50uA_temp_test_timer_process();
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
684 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
685 else if (pwr_env_ctrl_blk->timer0_state == BATTERY_10UA_TEMP_TEST)
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
686 {
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
687 pwr_bat_10uA_temp_test_timer_process();
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
688 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
689 else if (pwr_env_ctrl_blk->timer0_state == BATTERY_CALIBRATION)
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
690 {
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
691 /* end of current loop calibration */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
692 pwr_cal_timer_process();
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
693 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
694 }
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
695
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
696 #endif /* #ifdef RVM_PWR_SWE */
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
697
246f4a7dd92b src/cs/drivers/drv_app/pwr: import from MV100 source
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
698