|
|
@@ -46,7 +46,6 @@ static int no_hall_time[5];
|
|
|
static int no_hall_count = 0;
|
|
|
u64 uart_frame_time = 0;
|
|
|
static u32 uart_reinit_count = 0;
|
|
|
-
|
|
|
static void put_no_hall_time(void){
|
|
|
no_hall_time[no_hall_count] = shark_get_seconds();
|
|
|
no_hall_count = (no_hall_count + 1) % 5;
|
|
|
@@ -669,11 +668,14 @@ static u16 _search_direct(u16 *delta_v, u8 current_cell, u8 *depth, u8 dir) {
|
|
|
delta_prev = delta_v[idx_prev];
|
|
|
|
|
|
//get the delta v of the next and current
|
|
|
+#if 0
|
|
|
if (current_cell == CELLS_NUM - 1) {
|
|
|
idx_next = 0;
|
|
|
}else {
|
|
|
idx_next = current_cell + 1;
|
|
|
}
|
|
|
+#endif
|
|
|
+ idx_next = current_cell;
|
|
|
delta_next = delta_v[idx_next];
|
|
|
|
|
|
//use the max delta v of the prev and next
|
|
|
@@ -709,7 +711,7 @@ static u32 get_balance_maskV2(void) {
|
|
|
for (int i = 0; i < CELLS_NUM - 1; i++) {
|
|
|
delta_v[i] = abs(pcellv[i] - pcellv[i + 1]);
|
|
|
}
|
|
|
- u8 depth_next, depth_prev;
|
|
|
+ u8 depth_next = 0, depth_prev = 0;
|
|
|
u8 idx_next = _search_direct(delta_v, _bms_state.cell_index_of_max_vol, &depth_next, 1);// search from max to next....
|
|
|
u8 idx_prev = _search_direct(delta_v, _bms_state.cell_index_of_max_vol, &depth_prev, 0);// search from max to prev
|
|
|
//chose the min depth whitch near from max voltage cell
|
|
|
@@ -746,7 +748,7 @@ static u8 can_do_balance(void) {
|
|
|
}
|
|
|
|
|
|
static u8 need_stop_balance(void) {
|
|
|
- if (measure_value()->load_current < -50.0 || g_is_charging) {
|
|
|
+ if (measure_value()->load_current < -100.0 || g_is_charging) {
|
|
|
return 1;
|
|
|
}
|
|
|
return 0;
|
|
|
@@ -764,9 +766,11 @@ static void check_cell_balance(void){
|
|
|
}
|
|
|
u16 mask = get_balance_maskV2();
|
|
|
if (mask) {
|
|
|
+ push_event(Cell_balance, mask);
|
|
|
_start_balance(mask);
|
|
|
shark_timer_post(&_balance_timer, BALANCE_TIME * 1000); //stop balance after BALANCE_TIME
|
|
|
}
|
|
|
+ state_debug("Cell balance mask 0x%x\n", mask);
|
|
|
}
|
|
|
#endif
|
|
|
static void calc_cell_voltage(void){
|