FreeCalypso > hg > fc-magnetite
annotate src/cs/drivers/drv_app/fchg/fchg_process.c @ 596:e4d46979846f
FCHG: turn on the charging LED on C155 and J100 targets
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 18 Mar 2019 17:56:04 +0000 |
parents | 65d53dede3b2 |
children | 92dbfa906f66 |
rev | line source |
---|---|
331
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * In this module we are going to implement the main process functions |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * for FCHG. |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 */ |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include "fchg/fchg_env.h" |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include "fchg/fchg_func_i.h" |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include "rv/rv_general.h" |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include "rvf/rvf_api.h" |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include "rvm/rvm_use_id_list.h" |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include "abb/abb.h" |
596
e4d46979846f
FCHG: turn on the charging LED on C155 and J100 targets
Mychaela Falconia <falcon@freecalypso.org>
parents:
369
diff
changeset
|
12 #include "fc-target.cfg" |
331
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 #include <string.h> |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 #include <stdio.h> |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 extern UINT16 madc_vbat_2_physical(UINT16 adc_val); |
362
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
17 extern UINT16 madc_vbat_inverse(UINT16 mv); |
331
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 |
596
e4d46979846f
FCHG: turn on the charging LED on C155 and J100 targets
Mychaela Falconia <falcon@freecalypso.org>
parents:
369
diff
changeset
|
19 #if defined(CONFIG_TARGET_C155) || defined(CONFIG_TARGET_J100) |
e4d46979846f
FCHG: turn on the charging LED on C155 and J100 targets
Mychaela Falconia <falcon@freecalypso.org>
parents:
369
diff
changeset
|
20 #define LEDC 0x20 |
e4d46979846f
FCHG: turn on the charging LED on C155 and J100 targets
Mychaela Falconia <falcon@freecalypso.org>
parents:
369
diff
changeset
|
21 #else |
e4d46979846f
FCHG: turn on the charging LED on C155 and J100 targets
Mychaela Falconia <falcon@freecalypso.org>
parents:
369
diff
changeset
|
22 #define LEDC 0 |
e4d46979846f
FCHG: turn on the charging LED on C155 and J100 targets
Mychaela Falconia <falcon@freecalypso.org>
parents:
369
diff
changeset
|
23 #endif |
e4d46979846f
FCHG: turn on the charging LED on C155 and J100 targets
Mychaela Falconia <falcon@freecalypso.org>
parents:
369
diff
changeset
|
24 |
331
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 void pwr_init_discharge(void) |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 { |
333
8a90038c0173
FCHG: store discharge state as threshold index rather than percentage
Mychaela Falconia <falcon@freecalypso.org>
parents:
331
diff
changeset
|
27 pwr_ctrl->curr_disch_thresh = 0; |
331
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 } |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 static void handle_discharge(void) |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 { |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 UINT16 i; |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 char trace[64]; |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 /* first we need to find the current threshold we are at */ |
333
8a90038c0173
FCHG: store discharge state as threshold index rather than percentage
Mychaela Falconia <falcon@freecalypso.org>
parents:
331
diff
changeset
|
36 i = pwr_ctrl->curr_disch_thresh; |
331
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 /* is there one below? */ |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 if (++i == pwr_ctrl->nb_thresholds) |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 return; |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 /* are we crossing it? */ |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 if (pwr_ctrl->batt_mv >= pwr_ctrl->batt_thresholds[i].bat_voltage) |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 return; |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 /* yes, we crossed it - see if we fell even further down */ |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 while (i < pwr_ctrl->nb_thresholds && |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 pwr_ctrl->batt_mv < pwr_ctrl->batt_thresholds[i].bat_voltage) |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 i++; |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 /* the last one was it */ |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 i--; |
333
8a90038c0173
FCHG: store discharge state as threshold index rather than percentage
Mychaela Falconia <falcon@freecalypso.org>
parents:
331
diff
changeset
|
49 pwr_ctrl->curr_disch_thresh = i; |
331
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 sprintf(trace, "Battery fell through %u%% mark", |
333
8a90038c0173
FCHG: store discharge state as threshold index rather than percentage
Mychaela Falconia <falcon@freecalypso.org>
parents:
331
diff
changeset
|
51 pwr_ctrl->batt_thresholds[i].remain_capa); |
331
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 rvf_send_trace(trace, strlen(trace), NULL_PARAM, |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 RV_TRACE_LEVEL_WARNING, FCHG_USE_ID); |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 } |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 static void start_i2v_cal(void) |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 { |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 UINT16 bciconf; |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 rvf_send_trace("Calibrating i2v offset", 22, NULL_PARAM, |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 RV_TRACE_LEVEL_DEBUG_HIGH, FCHG_USE_ID); |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 pwr_ctrl->state = FCHG_STATE_I2V_CAL_2; |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 bciconf = ABB_Read_Register_on_page(PAGE1, BCICONF); |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 bciconf &= 0x3E0; |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 bciconf |= pwr_ctrl->config.bciconf; |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 ABB_Write_Register_on_page(PAGE1, BCICONF, bciconf); |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 /* |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 * Set the CHDISPA bit and start the zero calibration routine |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 * of the I to V converter |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 */ |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 ABB_Write_Register_on_page(PAGE0, BCICTL2, 0x0010); |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 ABB_Write_Register_on_page(PAGE0, BCICTL2, 0x0019); |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 } |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 static void start_ci_charging(void) |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 { |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 rvf_send_trace("Start CI charging", 17, NULL_PARAM, |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 RV_TRACE_LEVEL_DEBUG_HIGH, FCHG_USE_ID); |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 pwr_ctrl->state = FCHG_STATE_CI_CHARGING; |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 /* Select constant current charging. The charger is disabled */ |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 ABB_Write_Register_on_page(PAGE0, BCICTL2, 0x0002); |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 /* Program the DAC with the constant current value */ |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 ABB_Write_Register_on_page(PAGE0, CHGREG, |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 pwr_ctrl->config.ci_current + pwr_ctrl->i2v_offset); |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 /* Enable the charger */ |
596
e4d46979846f
FCHG: turn on the charging LED on C155 and J100 targets
Mychaela Falconia <falcon@freecalypso.org>
parents:
369
diff
changeset
|
86 ABB_Write_Register_on_page(PAGE0, BCICTL2, 0x0003 | LEDC); |
369
65d53dede3b2
FCHG: charging time limit implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
87 /* The total charging time starts now */ |
65d53dede3b2
FCHG: charging time limit implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
88 pwr_ctrl->start_time = rvf_get_tick_count(); |
331
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 } |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 |
362
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
91 static void start_cv_charging(void) |
331
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 { |
362
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
93 UINT16 code; |
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
94 |
331
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 rvf_send_trace("Start CV charging", 17, NULL_PARAM, |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 RV_TRACE_LEVEL_DEBUG_HIGH, FCHG_USE_ID); |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 pwr_ctrl->state = FCHG_STATE_CV_CHARGING; |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 /* Select constant voltage charging. The charger is disabled */ |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 ABB_Write_Register_on_page(PAGE0, BCICTL2, 0); |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 /* figure out the DAC code */ |
362
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
101 code = madc_vbat_inverse(pwr_ctrl->config.cv_init_set); |
331
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 rvf_send_trace("Voltage (DAC code) ", 19, code, |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 RV_TRACE_LEVEL_DEBUG_LOW, FCHG_USE_ID); |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 /* Program the DAC with the constant voltage value */ |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 ABB_Write_Register_on_page(PAGE0, CHGREG, code); |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 /* Enable the charger */ |
596
e4d46979846f
FCHG: turn on the charging LED on C155 and J100 targets
Mychaela Falconia <falcon@freecalypso.org>
parents:
369
diff
changeset
|
107 ABB_Write_Register_on_page(PAGE0, BCICTL2, 0x0001 | LEDC); |
362
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
108 /* CV control loop state init */ |
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
109 pwr_ctrl->cv_dac_init = code; |
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
110 pwr_ctrl->cv_dac_curr = code; |
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
111 pwr_ctrl->cv_high_vbat_count = 0; |
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
112 pwr_ctrl->cv_low_vbat_count = 0; |
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
113 /* Ichg averaging state init */ |
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
114 pwr_ctrl->ichg_fill_level = 0; |
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
115 pwr_ctrl->ichg_ring_ptr = 0; |
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
116 pwr_ctrl->ichg_low_count = 0; |
331
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
117 } |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
118 |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
119 static void start_charge_condition_met(void) |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
120 { |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
121 rvf_send_trace("Charge start condition met", 26, NULL_PARAM, |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
122 RV_TRACE_LEVEL_DEBUG_HIGH, FCHG_USE_ID); |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
123 if (pwr_ctrl->config.bciconf) |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
124 start_i2v_cal(); |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
125 else { |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
126 pwr_ctrl->i2v_offset = 0; |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
127 start_ci_charging(); |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
128 } |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
129 } |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
130 |
362
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
131 static void ci_progress_trace(UINT16 ichg) |
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
132 { |
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
133 char trace[64]; |
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
134 |
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
135 sprintf(trace, "CI charging: Vbat=%u Ichg=%u i2v=%u", |
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
136 pwr_ctrl->batt_mv, ichg, pwr_ctrl->i2v_offset); |
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
137 rvf_send_trace(trace, strlen(trace), NULL_PARAM, |
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
138 RV_TRACE_LEVEL_DEBUG_LOW, FCHG_USE_ID); |
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
139 } |
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
140 |
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
141 static int cv_ichg_process(UINT16 ichg_new) |
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
142 { |
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
143 UINT16 ichg_clip, ichg_entry; |
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
144 UINT32 ichg_accum; |
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
145 UINT16 i; |
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
146 char trace[64]; |
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
147 |
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
148 if (pwr_ctrl->ichg_fill_level < ICHG_AVG_WINDOW) |
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
149 pwr_ctrl->ichg_avg_buf[pwr_ctrl->ichg_fill_level++] = ichg_new; |
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
150 else { |
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
151 ichg_clip = pwr_ctrl->ichg_average + |
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
152 pwr_ctrl->config.ichg_max_spike; |
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
153 if (ichg_new > ichg_clip) |
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
154 ichg_entry = ichg_clip; |
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
155 else |
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
156 ichg_entry = ichg_new; |
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
157 pwr_ctrl->ichg_avg_buf[pwr_ctrl->ichg_ring_ptr++] = ichg_entry; |
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
158 if (pwr_ctrl->ichg_ring_ptr >= ICHG_AVG_WINDOW) |
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
159 pwr_ctrl->ichg_ring_ptr = 0; |
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
160 } |
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
161 ichg_accum = 0; |
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
162 for (i = 0; i < pwr_ctrl->ichg_fill_level; i++) |
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
163 ichg_accum += pwr_ctrl->ichg_avg_buf[i]; |
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
164 pwr_ctrl->ichg_average = ichg_accum / pwr_ctrl->ichg_fill_level; |
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
165 sprintf(trace, "CV charging: Vbat=%u Ichg=%u Ichg_avg=%u i2v=%u", |
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
166 pwr_ctrl->batt_mv, ichg_new, pwr_ctrl->ichg_average, |
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
167 pwr_ctrl->i2v_offset); |
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
168 rvf_send_trace(trace, strlen(trace), NULL_PARAM, |
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
169 RV_TRACE_LEVEL_DEBUG_LOW, FCHG_USE_ID); |
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
170 if (pwr_ctrl->ichg_average > |
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
171 (pwr_ctrl->config.end_current + pwr_ctrl->i2v_offset)) { |
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
172 pwr_ctrl->ichg_low_count = 0; |
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
173 return 0; |
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
174 } |
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
175 pwr_ctrl->ichg_low_count++; |
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
176 if (pwr_ctrl->ichg_low_count < pwr_ctrl->config.ichg_samples_needed) |
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
177 return 0; |
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
178 rvf_send_trace("Stopping charge by low current condition", 40, |
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
179 NULL_PARAM, RV_TRACE_LEVEL_DEBUG_HIGH, FCHG_USE_ID); |
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
180 ABB_Write_Register_on_page(PAGE0, BCICTL2, 0); |
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
181 pwr_init_discharge(); |
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
182 pwr_ctrl->state = FCHG_STATE_READY_TO_RECHARGE; |
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
183 return 1; |
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
184 } |
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
185 |
331
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
186 static int overvoltage_end_charge_check(void) |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
187 { |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
188 if (pwr_ctrl->batt_mv < pwr_ctrl->config.overvoltage) |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
189 return 0; |
363
cce24b9de6db
FCHG: CV control loop implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
362
diff
changeset
|
190 if (pwr_ctrl->cv_dac_curr != |
cce24b9de6db
FCHG: CV control loop implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
362
diff
changeset
|
191 (pwr_ctrl->cv_dac_init - pwr_ctrl->config.cv_dac_max_decr)) |
364
44795dbadbae
FCHG: bug in CV process caused the control loop to be skipped
Mychaela Falconia <falcon@freecalypso.org>
parents:
363
diff
changeset
|
192 return 0; |
331
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
193 rvf_send_trace("Stopping charge by overvoltage condition", 40, |
369
65d53dede3b2
FCHG: charging time limit implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
194 NULL_PARAM, RV_TRACE_LEVEL_WARNING, FCHG_USE_ID); |
331
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
195 ABB_Write_Register_on_page(PAGE0, BCICTL2, 0); |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
196 pwr_init_discharge(); |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
197 pwr_ctrl->state = FCHG_STATE_READY_TO_RECHARGE; |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
198 return 1; |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
199 } |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
200 |
363
cce24b9de6db
FCHG: CV control loop implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
362
diff
changeset
|
201 static void cv_ctrl_loop_high_check(void) |
cce24b9de6db
FCHG: CV control loop implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
362
diff
changeset
|
202 { |
cce24b9de6db
FCHG: CV control loop implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
362
diff
changeset
|
203 if (pwr_ctrl->batt_mv < pwr_ctrl->config.cv_ctrl_loop_high) { |
cce24b9de6db
FCHG: CV control loop implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
362
diff
changeset
|
204 pwr_ctrl->cv_high_vbat_count = 0; |
cce24b9de6db
FCHG: CV control loop implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
362
diff
changeset
|
205 return; |
cce24b9de6db
FCHG: CV control loop implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
362
diff
changeset
|
206 } |
cce24b9de6db
FCHG: CV control loop implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
362
diff
changeset
|
207 pwr_ctrl->cv_high_vbat_count++; |
cce24b9de6db
FCHG: CV control loop implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
362
diff
changeset
|
208 if (pwr_ctrl->cv_high_vbat_count < pwr_ctrl->config.cv_samples_needed) |
cce24b9de6db
FCHG: CV control loop implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
362
diff
changeset
|
209 return; |
cce24b9de6db
FCHG: CV control loop implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
362
diff
changeset
|
210 if (pwr_ctrl->cv_dac_curr == |
cce24b9de6db
FCHG: CV control loop implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
362
diff
changeset
|
211 (pwr_ctrl->cv_dac_init - pwr_ctrl->config.cv_dac_max_decr)) |
cce24b9de6db
FCHG: CV control loop implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
362
diff
changeset
|
212 return; |
cce24b9de6db
FCHG: CV control loop implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
362
diff
changeset
|
213 pwr_ctrl->cv_dac_curr--; |
cce24b9de6db
FCHG: CV control loop implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
362
diff
changeset
|
214 ABB_Write_Register_on_page(PAGE0, CHGREG, pwr_ctrl->cv_dac_curr); |
cce24b9de6db
FCHG: CV control loop implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
362
diff
changeset
|
215 rvf_send_trace("Sub CV DAC", 10, pwr_ctrl->cv_dac_curr, |
cce24b9de6db
FCHG: CV control loop implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
362
diff
changeset
|
216 RV_TRACE_LEVEL_DEBUG_MEDIUM, FCHG_USE_ID); |
cce24b9de6db
FCHG: CV control loop implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
362
diff
changeset
|
217 pwr_ctrl->cv_high_vbat_count = 0; |
cce24b9de6db
FCHG: CV control loop implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
362
diff
changeset
|
218 } |
cce24b9de6db
FCHG: CV control loop implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
362
diff
changeset
|
219 |
cce24b9de6db
FCHG: CV control loop implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
362
diff
changeset
|
220 static void cv_ctrl_loop_low_check(void) |
cce24b9de6db
FCHG: CV control loop implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
362
diff
changeset
|
221 { |
cce24b9de6db
FCHG: CV control loop implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
362
diff
changeset
|
222 if (pwr_ctrl->batt_mv >= pwr_ctrl->config.cv_ctrl_loop_low) { |
cce24b9de6db
FCHG: CV control loop implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
362
diff
changeset
|
223 pwr_ctrl->cv_low_vbat_count = 0; |
cce24b9de6db
FCHG: CV control loop implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
362
diff
changeset
|
224 return; |
cce24b9de6db
FCHG: CV control loop implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
362
diff
changeset
|
225 } |
cce24b9de6db
FCHG: CV control loop implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
362
diff
changeset
|
226 pwr_ctrl->cv_low_vbat_count++; |
cce24b9de6db
FCHG: CV control loop implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
362
diff
changeset
|
227 if (pwr_ctrl->cv_low_vbat_count < pwr_ctrl->config.cv_samples_needed) |
cce24b9de6db
FCHG: CV control loop implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
362
diff
changeset
|
228 return; |
cce24b9de6db
FCHG: CV control loop implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
362
diff
changeset
|
229 if (pwr_ctrl->cv_dac_curr == |
cce24b9de6db
FCHG: CV control loop implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
362
diff
changeset
|
230 (pwr_ctrl->cv_dac_init + pwr_ctrl->config.cv_dac_max_incr)) |
cce24b9de6db
FCHG: CV control loop implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
362
diff
changeset
|
231 return; |
cce24b9de6db
FCHG: CV control loop implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
362
diff
changeset
|
232 pwr_ctrl->cv_dac_curr++; |
cce24b9de6db
FCHG: CV control loop implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
362
diff
changeset
|
233 ABB_Write_Register_on_page(PAGE0, CHGREG, pwr_ctrl->cv_dac_curr); |
cce24b9de6db
FCHG: CV control loop implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
362
diff
changeset
|
234 rvf_send_trace("Add CV DAC", 10, pwr_ctrl->cv_dac_curr, |
cce24b9de6db
FCHG: CV control loop implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
362
diff
changeset
|
235 RV_TRACE_LEVEL_DEBUG_MEDIUM, FCHG_USE_ID); |
cce24b9de6db
FCHG: CV control loop implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
362
diff
changeset
|
236 pwr_ctrl->cv_low_vbat_count = 0; |
cce24b9de6db
FCHG: CV control loop implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
362
diff
changeset
|
237 } |
cce24b9de6db
FCHG: CV control loop implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
362
diff
changeset
|
238 |
369
65d53dede3b2
FCHG: charging time limit implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
239 static int charging_time_limit_check(void) |
65d53dede3b2
FCHG: charging time limit implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
240 { |
65d53dede3b2
FCHG: charging time limit implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
241 if ((rvf_get_tick_count() - pwr_ctrl->start_time) < |
65d53dede3b2
FCHG: charging time limit implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
242 RVF_SECS_TO_TICKS(pwr_ctrl->config.charge_time_limit)) |
65d53dede3b2
FCHG: charging time limit implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
243 return 0; |
65d53dede3b2
FCHG: charging time limit implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
244 rvf_send_trace("Stopping charge by time exceeded condition", 42, |
65d53dede3b2
FCHG: charging time limit implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
245 NULL_PARAM, RV_TRACE_LEVEL_WARNING, FCHG_USE_ID); |
65d53dede3b2
FCHG: charging time limit implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
246 ABB_Write_Register_on_page(PAGE0, BCICTL2, 0); |
65d53dede3b2
FCHG: charging time limit implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
247 pwr_init_discharge(); |
65d53dede3b2
FCHG: charging time limit implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
248 pwr_ctrl->state = FCHG_STATE_RECHARGE_TIMER; |
65d53dede3b2
FCHG: charging time limit implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
249 pwr_ctrl->start_time = rvf_get_tick_count(); |
65d53dede3b2
FCHG: charging time limit implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
250 return 1; |
65d53dede3b2
FCHG: charging time limit implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
251 } |
65d53dede3b2
FCHG: charging time limit implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
252 |
331
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
253 void pwr_process_adc(struct pwr_adc_ind_s *msg) |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
254 { |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
255 pwr_ctrl->batt_mv = madc_vbat_2_physical(msg->data[0]); |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
256 |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
257 switch (pwr_ctrl->state) { |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
258 case FCHG_STATE_NO_EXT_PWR: |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
259 case FCHG_STATE_PWR_PLUG_TIMER: |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
260 case FCHG_STATE_NO_CHARGING: |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
261 handle_discharge(); |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
262 return; |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
263 case FCHG_STATE_READY_TO_CHARGE: |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
264 handle_discharge(); |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
265 if (!(msg->data[9] & CHGPRES)) { |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
266 pwr_ctrl->state = FCHG_STATE_NO_EXT_PWR; |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
267 return; |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
268 } |
340
2f41f7883261
FCHG: logic error in the charge (re)start condition
Mychaela Falconia <falcon@freecalypso.org>
parents:
335
diff
changeset
|
269 if (pwr_ctrl->batt_mv < pwr_ctrl->config.start_thresh) |
331
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
270 start_charge_condition_met(); |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
271 return; |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
272 case FCHG_STATE_READY_TO_RECHARGE: |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
273 handle_discharge(); |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
274 if (!(msg->data[9] & CHGPRES)) { |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
275 pwr_ctrl->state = FCHG_STATE_NO_EXT_PWR; |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
276 return; |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
277 } |
340
2f41f7883261
FCHG: logic error in the charge (re)start condition
Mychaela Falconia <falcon@freecalypso.org>
parents:
335
diff
changeset
|
278 if (pwr_ctrl->batt_mv < pwr_ctrl->config.restart_thresh) |
331
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
279 start_charge_condition_met(); |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
280 return; |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
281 case FCHG_STATE_I2V_CAL_1: |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
282 if (!(msg->data[9] & CHGPRES)) { |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
283 pwr_ctrl->state = FCHG_STATE_NO_EXT_PWR; |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
284 return; |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
285 } |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
286 if (pwr_ctrl->config.bciconf) |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
287 start_i2v_cal(); |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
288 else { |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
289 pwr_ctrl->i2v_offset = 0; |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
290 start_ci_charging(); |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
291 } |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
292 return; |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
293 case FCHG_STATE_I2V_CAL_2: |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
294 pwr_ctrl->i2v_offset = msg->data[2]; |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
295 ABB_Write_Register_on_page(PAGE0, BCICTL2, 0); |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
296 rvf_send_trace("i2v offset (MADC code) ", 23, |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
297 pwr_ctrl->i2v_offset, |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
298 RV_TRACE_LEVEL_DEBUG_LOW, FCHG_USE_ID); |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
299 if (!(msg->data[9] & CHGPRES)) { |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
300 pwr_ctrl->state = FCHG_STATE_NO_EXT_PWR; |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
301 return; |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
302 } |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
303 start_ci_charging(); |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
304 return; |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
305 case FCHG_STATE_CI_CHARGING: |
362
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
306 ci_progress_trace(msg->data[2]); |
331
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
307 if (!(msg->data[9] & CHGPRES)) { |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
308 ABB_Write_Register_on_page(PAGE0, BCICTL2, 0); |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
309 pwr_ctrl->state = FCHG_STATE_NO_EXT_PWR; |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
310 return; |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
311 } |
369
65d53dede3b2
FCHG: charging time limit implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
312 if (charging_time_limit_check()) |
65d53dede3b2
FCHG: charging time limit implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
313 return; |
360
ce6d71349af0
FCHG: data structure changes in preparation for the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
340
diff
changeset
|
314 if (pwr_ctrl->batt_mv >= pwr_ctrl->config.ci2cv_thresh) |
362
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
315 start_cv_charging(); |
331
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
316 return; |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
317 case FCHG_STATE_CV_CHARGING: |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
318 if (!(msg->data[9] & CHGPRES)) { |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
319 ABB_Write_Register_on_page(PAGE0, BCICTL2, 0); |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
320 pwr_ctrl->state = FCHG_STATE_NO_EXT_PWR; |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
321 return; |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
322 } |
362
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
323 if (cv_ichg_process(msg->data[2])) |
4c3d05866531
FCHG: beginning of the new version
Mychaela Falconia <falcon@freecalypso.org>
parents:
360
diff
changeset
|
324 return; |
331
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
325 if (overvoltage_end_charge_check()) |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
326 return; |
369
65d53dede3b2
FCHG: charging time limit implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
327 if (charging_time_limit_check()) |
65d53dede3b2
FCHG: charging time limit implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
328 return; |
363
cce24b9de6db
FCHG: CV control loop implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
362
diff
changeset
|
329 cv_ctrl_loop_high_check(); |
cce24b9de6db
FCHG: CV control loop implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
362
diff
changeset
|
330 cv_ctrl_loop_low_check(); |
331
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
331 return; |
369
65d53dede3b2
FCHG: charging time limit implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
332 case FCHG_STATE_RECHARGE_TIMER: |
65d53dede3b2
FCHG: charging time limit implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
333 handle_discharge(); |
65d53dede3b2
FCHG: charging time limit implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
334 if ((rvf_get_tick_count() - pwr_ctrl->start_time) < |
65d53dede3b2
FCHG: charging time limit implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
335 RVF_SECS_TO_TICKS(pwr_ctrl->config.recharge_delay)) |
65d53dede3b2
FCHG: charging time limit implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
336 return; |
65d53dede3b2
FCHG: charging time limit implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
337 rvf_send_trace("Restart time met, allowing new charging", 39, |
65d53dede3b2
FCHG: charging time limit implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
338 NULL_PARAM, RV_TRACE_LEVEL_DEBUG_HIGH, |
65d53dede3b2
FCHG: charging time limit implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
339 FCHG_USE_ID); |
65d53dede3b2
FCHG: charging time limit implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
340 pwr_ctrl->state = FCHG_STATE_READY_TO_RECHARGE; |
65d53dede3b2
FCHG: charging time limit implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
341 return; |
331
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
342 default: |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
343 rvf_send_trace("Invalid state in pwr_process_adc()", 32, |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
344 pwr_ctrl->state, RV_TRACE_LEVEL_ERROR, |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
345 FCHG_USE_ID); |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
346 } |
8166b0afcf8c
FCHG: main ADC process implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
347 } |
334
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
348 |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
349 void pwr_handle_timer(void) |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
350 { |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
351 if (pwr_ctrl->state != FCHG_STATE_PWR_PLUG_TIMER) |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
352 return; |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
353 rvf_send_trace("Timer expired, ready to charge", 30, NULL_PARAM, |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
354 RV_TRACE_LEVEL_DEBUG_LOW, FCHG_USE_ID); |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
355 pwr_ctrl->state = FCHG_STATE_READY_TO_CHARGE; |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
356 } |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
357 |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
358 void pwr_charger_plug(void) |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
359 { |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
360 if (pwr_ctrl->state != FCHG_STATE_NO_EXT_PWR) { |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
361 rvf_send_trace("Charger plug event in unexpected state", 38, |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
362 pwr_ctrl->state, RV_TRACE_LEVEL_ERROR, |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
363 FCHG_USE_ID); |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
364 return; |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
365 } |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
366 if (!pwr_ctrl->config_present) { |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
367 rvf_send_trace( |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
368 "Charger plugged in, but no config: won't charge", 47, |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
369 NULL_PARAM, RV_TRACE_LEVEL_ERROR, FCHG_USE_ID); |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
370 pwr_ctrl->state = FCHG_STATE_NO_CHARGING; |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
371 return; |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
372 } |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
373 if (pwr_ctrl->config.start_delay) { |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
374 rvf_send_trace("Charger plug, starting timer", 28, NULL_PARAM, |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
375 RV_TRACE_LEVEL_DEBUG_HIGH, FCHG_USE_ID); |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
376 rvf_start_timer(FCHG_TIMER, |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
377 RVF_MS_TO_TICKS(pwr_ctrl->config.start_delay), |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
378 FALSE); |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
379 pwr_ctrl->state = FCHG_STATE_PWR_PLUG_TIMER; |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
380 } else { |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
381 rvf_send_trace("Charger plug, ready to charge", 29, NULL_PARAM, |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
382 RV_TRACE_LEVEL_DEBUG_HIGH, FCHG_USE_ID); |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
383 pwr_ctrl->state = FCHG_STATE_READY_TO_CHARGE; |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
384 } |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
385 } |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
386 |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
387 void pwr_charger_unplug(void) |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
388 { |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
389 switch (pwr_ctrl->state) { |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
390 case FCHG_STATE_NO_EXT_PWR: |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
391 rvf_send_trace("Charger unplug, already handled", 31, |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
392 NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
393 FCHG_USE_ID); |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
394 /* nothing to do */ |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
395 return; |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
396 case FCHG_STATE_PWR_PLUG_TIMER: |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
397 case FCHG_STATE_READY_TO_CHARGE: |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
398 case FCHG_STATE_READY_TO_RECHARGE: |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
399 case FCHG_STATE_I2V_CAL_1: |
369
65d53dede3b2
FCHG: charging time limit implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
400 case FCHG_STATE_RECHARGE_TIMER: |
334
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
401 case FCHG_STATE_NO_CHARGING: |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
402 rvf_send_trace("Charger unplug", 14, NULL_PARAM, |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
403 RV_TRACE_LEVEL_DEBUG_LOW, FCHG_USE_ID); |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
404 pwr_ctrl->state = FCHG_STATE_NO_EXT_PWR; |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
405 return; |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
406 case FCHG_STATE_I2V_CAL_2: |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
407 case FCHG_STATE_CI_CHARGING: |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
408 case FCHG_STATE_CV_CHARGING: |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
409 ABB_Write_Register_on_page(PAGE0, BCICTL2, 0); |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
410 rvf_send_trace("Charger unplug, charging stopped", 32, |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
411 NULL_PARAM, RV_TRACE_LEVEL_DEBUG_HIGH, |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
412 FCHG_USE_ID); |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
413 pwr_ctrl->state = FCHG_STATE_NO_EXT_PWR; |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
414 pwr_init_discharge(); |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
415 return; |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
416 default: |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
417 rvf_send_trace("Invalid state in pwr_charger_unplug()", 35, |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
418 pwr_ctrl->state, RV_TRACE_LEVEL_ERROR, |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
419 FCHG_USE_ID); |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
420 } |
d583a1f5bd6a
FCHG: charger plug and unplug functions implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
333
diff
changeset
|
421 } |
335
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
422 |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
423 void pwr_charge_start_req(void) |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
424 { |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
425 switch (pwr_ctrl->state) { |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
426 case FCHG_STATE_NO_EXT_PWR: |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
427 rvf_send_trace("Cannot charge without a power source", 36, |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
428 NULL_PARAM, RV_TRACE_LEVEL_ERROR, FCHG_USE_ID); |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
429 return; |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
430 case FCHG_STATE_NO_CHARGING: |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
431 if (!pwr_ctrl->config_present) { |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
432 rvf_send_trace("No config set, cannot charge", 28, |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
433 NULL_PARAM, RV_TRACE_LEVEL_ERROR, |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
434 FCHG_USE_ID); |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
435 return; |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
436 } |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
437 /* FALL THRU */ |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
438 case FCHG_STATE_PWR_PLUG_TIMER: |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
439 case FCHG_STATE_READY_TO_CHARGE: |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
440 case FCHG_STATE_READY_TO_RECHARGE: |
369
65d53dede3b2
FCHG: charging time limit implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
441 case FCHG_STATE_RECHARGE_TIMER: |
335
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
442 rvf_send_trace("Starting charge on user request", 31, |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
443 NULL_PARAM, RV_TRACE_LEVEL_DEBUG_HIGH, |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
444 FCHG_USE_ID); |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
445 pwr_ctrl->state = FCHG_STATE_I2V_CAL_1; |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
446 return; |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
447 case FCHG_STATE_I2V_CAL_1: |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
448 case FCHG_STATE_I2V_CAL_2: |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
449 case FCHG_STATE_CI_CHARGING: |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
450 case FCHG_STATE_CV_CHARGING: |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
451 rvf_send_trace( |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
452 "Charging already in progress, start request ignored", |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
453 51, NULL_PARAM, RV_TRACE_LEVEL_WARNING, FCHG_USE_ID); |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
454 return; |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
455 default: |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
456 rvf_send_trace("Invalid state in pwr_charge_start_req()", 37, |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
457 pwr_ctrl->state, RV_TRACE_LEVEL_ERROR, |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
458 FCHG_USE_ID); |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
459 } |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
460 } |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
461 |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
462 void pwr_charge_stop_req(void) |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
463 { |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
464 switch (pwr_ctrl->state) { |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
465 case FCHG_STATE_NO_EXT_PWR: |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
466 case FCHG_STATE_NO_CHARGING: |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
467 /* nothing to do */ |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
468 return; |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
469 case FCHG_STATE_PWR_PLUG_TIMER: |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
470 case FCHG_STATE_READY_TO_CHARGE: |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
471 case FCHG_STATE_READY_TO_RECHARGE: |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
472 case FCHG_STATE_I2V_CAL_1: |
369
65d53dede3b2
FCHG: charging time limit implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
364
diff
changeset
|
473 case FCHG_STATE_RECHARGE_TIMER: |
335
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
474 rvf_send_trace("Charging disabled by user request", 33, |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
475 NULL_PARAM, RV_TRACE_LEVEL_DEBUG_HIGH, |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
476 FCHG_USE_ID); |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
477 pwr_ctrl->state = FCHG_STATE_NO_CHARGING; |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
478 return; |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
479 case FCHG_STATE_I2V_CAL_2: |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
480 case FCHG_STATE_CI_CHARGING: |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
481 case FCHG_STATE_CV_CHARGING: |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
482 ABB_Write_Register_on_page(PAGE0, BCICTL2, 0); |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
483 rvf_send_trace("Charging stopped by user request", 32, |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
484 NULL_PARAM, RV_TRACE_LEVEL_DEBUG_HIGH, |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
485 FCHG_USE_ID); |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
486 pwr_ctrl->state = FCHG_STATE_NO_CHARGING; |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
487 pwr_init_discharge(); |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
488 return; |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
489 default: |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
490 rvf_send_trace("Invalid state in pwr_charge_stop_req()", 36, |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
491 pwr_ctrl->state, RV_TRACE_LEVEL_ERROR, |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
492 FCHG_USE_ID); |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
493 } |
6c0659acf93e
FCHG: implemented functions for user-initiated charge start and stop
Mychaela Falconia <falcon@freecalypso.org>
parents:
334
diff
changeset
|
494 } |