Procházet zdrojové kódy

for ml5238 debug when current may be error

Signed-off-by: huhui <huhui@sharkgulf.com>
huhui před 5 roky
rodič
revize
1a194b898b

+ 4 - 2
Application/app/bms_message.c

@@ -199,17 +199,19 @@ void process_bms_message(can_frame_t *frame, int len){
 		}
 		case CAN_KEY_SET_LOGGER:
 			if (len < 1) {
+				ml5238_reg_log(); //just for debug
 				result = 1;
 			} else if (len < 2) {
 				set_log_all(frame->data[0]);
-			} else {
+			} else if (len < 3){
 				set_log_level(frame->data[0], frame->data[1]);
 			}
 			protocol_send_ack(frame->head.can_addr, frame->key, result);
 			break;
 		case CAN_KEY_START_CALI:
 			if (len != sizeof(cali_cmd_t)) {
-				result = 0;
+				current_calibrate();//just for debug
+				result = 1;
 			}else {
 				cali_cmd_t * cmd = (cali_cmd_t *)frame->data;
 				uint8_t adc = cmd->flags & 0x01;

+ 1 - 1
Application/app/sox/state.c

@@ -404,7 +404,7 @@ static void _check_mos_stat(void){
 			int dmos = ml5238_is_discharging();
 			int cmos = ml5238_is_charging();
 			if (dmos + cmos == 0){
-				state_error("current = %d, but all mos is closed\n", measure_value()->load_current);
+				//state_error("current = %d, but all mos is closed\n", measure_value()->load_current);
 				return;
 			}
 			if (dmos == 1 && cmos == 1){

+ 10 - 6
Application/bsp/ml5238.c

@@ -221,16 +221,20 @@ int ml5238_is_short_current_enabled(int mode){
 	return 1;
 }
 
-void ml5238_softreset(void)
-{
-	unsigned char i;
-	
-	for(i=0u;i<0x0Au;i++)
-	{
+void ml5238_softreset(void) {	
+	for(unsigned char i = 0u; i < 0x0Au; i++){
 		ml5238_write((uint8_t)(ML5238_VMON + i), 0x00u);	
 	}
 }
 
+void ml5238_reg_log(void){
+	uint8_t data = 0xFF;
+	for(unsigned char i = 0u; i < 0x0Au; i++){
+		ml5238_read((uint8_t)(ML5238_VMON + i), &data);
+		sys_debug("Reg %d:0x%x\n", (ML5238_VMON + i), data);
+	}
+}
+
 void ml5238_power_down(void){
 	do {
 		ml5238_write(ML5238_PSENSE, PSENSE_EPSH|PSENSE_IPSH); //before power down, we must enable charger detect

+ 1 - 0
Application/bsp/ml5238.h

@@ -17,6 +17,7 @@ int ml5238_is_charging(void);
 int ml5238_is_discharging(void);
 int ml5238_is_short_current_enabled(int mode);
 uint8_t ml5238_noop_register_rw(uint8_t data);//ml5238 ¶Áд²âÊÔ
+void ml5238_reg_log(void);
 
 
 typedef void (*ml5238_notify_hander)(int event);