Przeglądaj źródła

add some log

Signed-off-by: FuangCao <cavan.cao@foxmail.com>
FuangCao 5 lat temu
rodzic
commit
12e7ca3ab8
6 zmienionych plików z 24 dodań i 6 usunięć
  1. 7 1
      Source/app.c
  2. 4 0
      Source/common.h
  3. 7 1
      Source/drv_can.c
  4. 4 2
      Source/drv_io.c
  5. 1 1
      Source/main.c
  6. 1 1
      Source/sw_build_info.h

+ 7 - 1
Source/app.c

@@ -103,6 +103,7 @@ uint8_t Check_Battery_2_On(void)
 }
 void S11_FL_On(uint8_t on)
 {
+	println("S11_FL: %d", on);
 	S11_ENABLE(on);
 	FL_Enable(on);
 }
@@ -117,7 +118,9 @@ void Battery_CB_Operate(CB_VAL *cb_val)
 {
 	if(cb_val == NULL)
 		return;
-	
+
+	println("S11:%d, S21:%d, SS:%d", cb_val->s11_bit, cb_val->s21_bit, cb_val->ss__bit);
+
 	S10_ENABLE(cb_val->s10_bit);
 	S11_ENABLE(cb_val->s11_bit);
 	S20_ENABLE(cb_val->s20_bit);
@@ -149,6 +152,9 @@ int8_t Battery_CB_Switch(uint8_t cb_operate)
 {
 	CB_VAL cb_val_temp;
 	uint16_t i = 0;
+
+	println("switch: %d", cb_operate);
+
 #define COM_TIMEOUT  (15)
 
 	switch(cb_operate)

+ 4 - 0
Source/common.h

@@ -27,6 +27,10 @@
 
 #define PS100_SERIAL_NUM_SIZE                      18
 #define PS100_SOFTWARE_SIZE                        20
+
+#define println(fmt, args ...) \
+	printf(fmt "\n", ##args)
+
 extern const uint8_t soft_version[];
 extern uint8_t sn[PS100_SERIAL_NUM_SIZE];
 

+ 7 - 1
Source/drv_can.c

@@ -452,10 +452,16 @@ static can_trasnmit_message_struct shark_can_log_message;
 
 static void shark_can_log_flush(uint8_t dest)
 {
+	uint32_t times = 100000;
+
 	shark_can_log_message.tx_efid = 3 << 24 | 1 << 19 | 1 << 14 | SELF_ID << 7 | dest;
 	shark_can_log_message.tx_ff = CAN_FF_EXTENDED;
 	shark_can_log_message.tx_ft = CAN_FT_DATA;
-	can_message_transmit(CAN0, &shark_can_log_message);
+
+	while (can_message_transmit(CAN0, &shark_can_log_message) == CAN_NOMAILBOX && times > 0) {
+		times--;
+	}
+
 	shark_can_log_message.tx_dlen = 0;
 }
 

+ 4 - 2
Source/drv_io.c

@@ -40,6 +40,8 @@ void Check_S11_May_Operate(void)
 }
 void Check_S11(uint8_t on,uint8_t from)
 {
+	println("Check_S11: %d %d", on, from);
+
 	if(on)
 	{
 		if(S11_May_Operate())
@@ -68,7 +70,7 @@ void Check_S11(uint8_t on,uint8_t from)
 }
 void QD_Enable_From(uint8_t on,uint8_t from)
 {
-	printf("qd: %d %d\n", on, from);
+	println("qd: %d %d", on, from);
 
 	Check_S11(on,FROM_QD);
 	QD_Enable(on);
@@ -101,7 +103,7 @@ void ACC2_PWM(void)
 }
 void ACC2_Enable(uint8_t on)
 {
-	printf("acc2: %d\n", on);
+	println("acc2: %d", on);
 
 #if ACC2_USE_PWM
 	Check_S11(on,FROM_ACC12);

+ 1 - 1
Source/main.c

@@ -219,7 +219,7 @@ int main(void)
 
 		Cal_Sheng_Yu_Li_Cheng();
 
-		Check_S11_May_Operate();
+		// Check_S11_May_Operate();
 
 		Check_Enable_Test_Info();
 		

+ 1 - 1
Source/sw_build_info.h

@@ -1,3 +1,3 @@
 #pragma once
 
-#define CONFIG_VERSION "PS100XX_V01_0C301614"
+#define CONFIG_VERSION "PS100XX_V01_0C301712"