|
|
@@ -18,7 +18,11 @@ static float imon_gain_now;
|
|
|
static float vim0_10x = 0.0f;
|
|
|
static float vim0_50x = 0.0f;
|
|
|
static float vim0_now;
|
|
|
+#if defined CONFIG_BOARD_SP700
|
|
|
#define r_resistor 1.0f // 1ºÁÅ·
|
|
|
+#elif defined CONFIG_BOARD_SP600
|
|
|
+#define r_resistor 2.0f
|
|
|
+#endif
|
|
|
#define r_pcb_resistor 0.0f // pcb resistor
|
|
|
static const float r_sense = r_resistor + r_pcb_resistor;
|
|
|
static const float v_ref = 3300.0f; //adc ref = 3.3v
|
|
|
@@ -70,19 +74,19 @@ void current_calibrate(void){
|
|
|
void measure_system_init(void){
|
|
|
adc_init();
|
|
|
ml5238_init();
|
|
|
- cs1180_init();
|
|
|
+ //cs1180_init();
|
|
|
current_calibrate();
|
|
|
}
|
|
|
|
|
|
/* get battery pack's current (mA) */
|
|
|
-float get_imon_current(int calibration){
|
|
|
- float adc = adc_sample(ADC_CHAN_IMON, calibration);
|
|
|
+float get_imon_current(void){
|
|
|
+ float adc = adc_sample(ADC_CHAN_IMON, TRUE);
|
|
|
if (adc >= 0xFFF0 && (!_is_x10_gain())){//overflow, use 10x gain
|
|
|
select_gain_10x(1);
|
|
|
- adc = adc_sample(ADC_CHAN_IMON, calibration);
|
|
|
+ adc = adc_sample(ADC_CHAN_IMON, TRUE);
|
|
|
}else if (adc <= 0x1F && (_is_x10_gain())){// is too small, select 50x gain
|
|
|
select_gain_10x(0);
|
|
|
- adc = adc_sample(ADC_CHAN_IMON, calibration);
|
|
|
+ adc = adc_sample(ADC_CHAN_IMON, TRUE);
|
|
|
}
|
|
|
float cali_adc = ML5238_V_RSENSER(adc, vim0_now, imon_gain_now);
|
|
|
|
|
|
@@ -90,25 +94,25 @@ float get_imon_current(int calibration){
|
|
|
}
|
|
|
|
|
|
/* get cell's voltage (mV) */
|
|
|
-float get_vmon_voltage(int cell, int calibration){
|
|
|
+float get_vmon_voltage(int cell){
|
|
|
ml5238_select_cell_to_vmon(cell);
|
|
|
- delay_us(50);
|
|
|
- float adc = adc_sample(ADC_CHAN_VMON, calibration);
|
|
|
+ delay_us(100);
|
|
|
+ float adc = adc_sample(ADC_CHAN_VMON, TRUE);
|
|
|
|
|
|
- return (adc / max_adc) * v_ref * 1000;
|
|
|
+ return cell_real_vol((adc / max_adc) * v_ref);
|
|
|
}
|
|
|
|
|
|
/* get battery pack's aux current (mA) */
|
|
|
-float get_small_current(int calibration){
|
|
|
- float adc = adc_sample(ADC_CHAN_AUX_CURR, calibration);
|
|
|
+float get_small_current(void){
|
|
|
+ float adc = adc_sample(ADC_CHAN_AUX_CURR, TRUE);
|
|
|
|
|
|
return (adc / max_adc * v_ref) / small_cur_r_sense * 1000;
|
|
|
}
|
|
|
|
|
|
-int get_pcb_temperature(int calibration){
|
|
|
+int get_pcb_temperature(void){
|
|
|
TEMP_OPEN(1);
|
|
|
delay_us(100);
|
|
|
- uint16_t adc = adc_sample(ADC_CHAN_TEMPERATURE_4, calibration);
|
|
|
+ uint16_t adc = adc_sample(ADC_CHAN_TEMPERATURE_4, TRUE);
|
|
|
TEMP_OPEN(0);
|
|
|
return get_temp_by_adc(adc);
|
|
|
}
|
|
|
@@ -116,10 +120,10 @@ int get_pcb_temperature(int calibration){
|
|
|
/*
|
|
|
* index : 0...2
|
|
|
*/
|
|
|
-int get_pack_temperature(int index, int calibration){
|
|
|
+int get_pack_temperature(int index){
|
|
|
TEMP_OPEN(1);
|
|
|
delay_us(100);
|
|
|
- uint16_t adc = adc_sample(ADC_CHAN_TEMPERATURE_1 + index, calibration);
|
|
|
+ uint16_t adc = adc_sample(ADC_CHAN_TEMPERATURE_1 + index, TRUE);
|
|
|
TEMP_OPEN(0);
|
|
|
return get_temp_by_adc(adc);
|
|
|
}
|