
int8_t Battery_CB_Switch_Bake(uint8_t cb_operate)
{
	CB_VAL cb_val_temp;
	uint8_t delay_flag = 0;
	
	switch(cb_operate)
	{
		case CB_BAT1:
			cb_val_temp.s10_bit = 1;
			cb_val_temp.s11_bit = 1;
			cb_val_temp.s20_bit = 0;
			cb_val_temp.s21_bit = 0;
			cb_val_temp.ss__bit = 0;
			break;
		case CB_BAT2:
			
			cb_val_temp.s10_bit = 0;
			cb_val_temp.s11_bit = 0;
			cb_val_temp.s20_bit = 1;
			cb_val_temp.s21_bit = 1;
			cb_val_temp.ss__bit = 0;
			break;
		case CB_BAT1_BAT2_PARRALLEL:
			if(sub_bms_info_1.packet_common.m_total_vol >= sub_bms_info_2.packet_common.m_total_vol)
			{
			
				cb_val_temp.s10_bit = 1;
				cb_val_temp.s11_bit = 1;
				cb_val_temp.s20_bit = 1;
				cb_val_temp.s21_bit = 0;
				cb_val_temp.ss__bit = 0;
			}
			else
			{
				
				cb_val_temp.s10_bit = 1;
				cb_val_temp.s11_bit = 0;
				cb_val_temp.s20_bit = 1;
				cb_val_temp.s21_bit = 1;
				cb_val_temp.ss__bit = 0;
			}
			break;
		case CB_BAT1_BAT2_SERIES:
		
			cb_val_temp.s10_bit = 1;
			cb_val_temp.s11_bit = 0;
			cb_val_temp.s20_bit = 1;
			cb_val_temp.s21_bit = 0;
			cb_val_temp.ss__bit = 1;
			break;
		case CB_BAT_NO:
		default:
			cb_val_temp.s10_bit = 0;
			cb_val_temp.s11_bit = 0;
			cb_val_temp.s20_bit = 0;
			cb_val_temp.s21_bit = 0;
			cb_val_temp.ss__bit = 0;
			break;
	}

	// 1----->0
	if(cb_val_last.s10_bit > cb_val_temp.s10_bit)
	{
		S10_ENABLE(cb_val_temp.s10_bit);
		delay_flag = 1;
	}

	if(cb_val_last.s11_bit > cb_val_temp.s11_bit)
	{
		S11_ENABLE(cb_val_temp.s11_bit);
		delay_flag = 1;
	}

	if(cb_val_last.s20_bit > cb_val_temp.s20_bit)
	{
		S20_ENABLE(cb_val_temp.s20_bit);
		delay_flag = 1;
	}

	if(cb_val_last.s21_bit > cb_val_temp.s21_bit)
	{
		S21_ENABLE(cb_val_temp.s21_bit);
		delay_flag = 1;
	}

	if(cb_val_last.ss__bit > cb_val_temp.ss__bit)
	{
		SS__ENABLE(cb_val_temp.ss__bit);
		delay_flag = 1;
	}

	//delay
	if(delay_flag)
		delay_1ms(1);

	//
	Battery_CB_Operate(&cb_val_temp);

	//
	cb_val_last = cb_val_temp;

	cb_operate_state = cb_operate;
	
	return cb_operate;
	
}
