FreeCalypso > hg > fc-magnetite
comparison 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 |
comparison
equal
deleted
inserted
replaced
595:7cecc3dadbe7 | 596:e4d46979846f |
---|---|
7 #include "fchg/fchg_func_i.h" | 7 #include "fchg/fchg_func_i.h" |
8 #include "rv/rv_general.h" | 8 #include "rv/rv_general.h" |
9 #include "rvf/rvf_api.h" | 9 #include "rvf/rvf_api.h" |
10 #include "rvm/rvm_use_id_list.h" | 10 #include "rvm/rvm_use_id_list.h" |
11 #include "abb/abb.h" | 11 #include "abb/abb.h" |
12 #include "fc-target.cfg" | |
12 #include <string.h> | 13 #include <string.h> |
13 #include <stdio.h> | 14 #include <stdio.h> |
14 | 15 |
15 extern UINT16 madc_vbat_2_physical(UINT16 adc_val); | 16 extern UINT16 madc_vbat_2_physical(UINT16 adc_val); |
16 extern UINT16 madc_vbat_inverse(UINT16 mv); | 17 extern UINT16 madc_vbat_inverse(UINT16 mv); |
18 | |
19 #if defined(CONFIG_TARGET_C155) || defined(CONFIG_TARGET_J100) | |
20 #define LEDC 0x20 | |
21 #else | |
22 #define LEDC 0 | |
23 #endif | |
17 | 24 |
18 void pwr_init_discharge(void) | 25 void pwr_init_discharge(void) |
19 { | 26 { |
20 pwr_ctrl->curr_disch_thresh = 0; | 27 pwr_ctrl->curr_disch_thresh = 0; |
21 } | 28 } |
74 ABB_Write_Register_on_page(PAGE0, BCICTL2, 0x0002); | 81 ABB_Write_Register_on_page(PAGE0, BCICTL2, 0x0002); |
75 /* Program the DAC with the constant current value */ | 82 /* Program the DAC with the constant current value */ |
76 ABB_Write_Register_on_page(PAGE0, CHGREG, | 83 ABB_Write_Register_on_page(PAGE0, CHGREG, |
77 pwr_ctrl->config.ci_current + pwr_ctrl->i2v_offset); | 84 pwr_ctrl->config.ci_current + pwr_ctrl->i2v_offset); |
78 /* Enable the charger */ | 85 /* Enable the charger */ |
79 ABB_Write_Register_on_page(PAGE0, BCICTL2, 0x0003); | 86 ABB_Write_Register_on_page(PAGE0, BCICTL2, 0x0003 | LEDC); |
80 /* The total charging time starts now */ | 87 /* The total charging time starts now */ |
81 pwr_ctrl->start_time = rvf_get_tick_count(); | 88 pwr_ctrl->start_time = rvf_get_tick_count(); |
82 } | 89 } |
83 | 90 |
84 static void start_cv_charging(void) | 91 static void start_cv_charging(void) |
95 rvf_send_trace("Voltage (DAC code) ", 19, code, | 102 rvf_send_trace("Voltage (DAC code) ", 19, code, |
96 RV_TRACE_LEVEL_DEBUG_LOW, FCHG_USE_ID); | 103 RV_TRACE_LEVEL_DEBUG_LOW, FCHG_USE_ID); |
97 /* Program the DAC with the constant voltage value */ | 104 /* Program the DAC with the constant voltage value */ |
98 ABB_Write_Register_on_page(PAGE0, CHGREG, code); | 105 ABB_Write_Register_on_page(PAGE0, CHGREG, code); |
99 /* Enable the charger */ | 106 /* Enable the charger */ |
100 ABB_Write_Register_on_page(PAGE0, BCICTL2, 0x0001); | 107 ABB_Write_Register_on_page(PAGE0, BCICTL2, 0x0001 | LEDC); |
101 /* CV control loop state init */ | 108 /* CV control loop state init */ |
102 pwr_ctrl->cv_dac_init = code; | 109 pwr_ctrl->cv_dac_init = code; |
103 pwr_ctrl->cv_dac_curr = code; | 110 pwr_ctrl->cv_dac_curr = code; |
104 pwr_ctrl->cv_high_vbat_count = 0; | 111 pwr_ctrl->cv_high_vbat_count = 0; |
105 pwr_ctrl->cv_low_vbat_count = 0; | 112 pwr_ctrl->cv_low_vbat_count = 0; |