Parcourir la source

git-svn-id: https://svn.ti-link.com.cn/svn/G100/PowerManagement/PS100@5300 efa15413-de06-ce4f-a13f-2108acd733b2

liuguo1 il y a 5 ans
Parent
commit
9a863b5b57
8 fichiers modifiés avec 161 ajouts et 1 suppressions
  1. 25 0
      Source/app_end_ctr.c
  2. 1 0
      Source/app_end_ctr.h
  3. 88 0
      Source/app_rs485_1.c
  4. 26 0
      Source/app_rs485_1.h
  5. 2 0
      Source/common.h
  6. 13 0
      Source/delay.c
  7. 5 0
      Source/main.c
  8. 1 1
      Source/sw_build_info.h

+ 25 - 0
Source/app_end_ctr.c

@@ -184,6 +184,8 @@ int8_t Handle_Can_Ctr_CMD(CAN_FRAME*can_ctr_frame)
 			break;
 		case KEY_END_CTR_ZHEN_JI_CE_SHI:
 			break;
+		case KEY_END_CTR_TEST_INFO:
+			break;
 		case KEY_END_CTR_QD:
 			if(work_normal == 1)
 			{
@@ -571,6 +573,29 @@ int8_t Rsp_Can_Ctr_CMD(CAN_FRAME*can_ctr_frame)
 			Writer_HT_Flash(1);
 			len = 2;
 			buf[len++] = 0;
+			break;
+		case KEY_END_CTR_TEST_INFO:
+			if((can_ctr_frame->head.rsp != FRAME_PT_NEED_RSP) || end_ctr_self_stimeout.set)
+				return 1;
+			len = 2;
+			switch(buf[len++])
+			{
+				case 1:
+					memcpy(&buf[len],&test_info.ti_bms_1,sizeof(test_info.ti_bms_1));
+					len += sizeof(test_info.ti_bms_1);
+					memcpy(&buf[len],&test_info.ti_bms_2,sizeof(test_info.ti_bms_2));
+					len += sizeof(test_info.ti_bms_2);
+					break;
+				case 2:
+					Ca_Chu_Test_Info();
+					buf[len++] = 0;
+					break;
+				default:
+					buf[len++] = 0;
+					break;
+					
+			}
+			
 			break;
 		case KEY_END_CTR_QD:
 			if((can_ctr_frame->head.rsp != FRAME_PT_NEED_RSP) || end_ctr_self_stimeout.set)

+ 1 - 0
Source/app_end_ctr.h

@@ -22,6 +22,7 @@
 #define KEY_END_CTR_BAT_UPDATE_EXIT	(0x4209)
 #define KEY_END_CTR_DAN_CI_LI_CHENG	(0x420A)
 #define KEY_END_CTR_ZHEN_JI_CE_SHI	(0x420B)
+#define KEY_END_CTR_TEST_INFO    	(0x420C)
 #define KEY_END_CTR_SELF_UP         (0x4280)
 
 

+ 88 - 0
Source/app_rs485_1.c

@@ -26,6 +26,8 @@ uint16_t bms_1_work_status = 0;
 
 uint8_t bms_1_test_define_error = 0;
 
+TEST_INFO test_info;
+
 static int8_t Get_Check_Sum_1(uint16_t*value,uint8_t*data,uint16_t size)
 {
 	uint32_t checksum;
@@ -644,3 +646,89 @@ uint8_t Sub_BMS_1_COM_Finish(void)
 	return sub_bms_1_lt_state;
 }
 
+
+
+
+
+void Save_Test_Info_To_Flash(uint8_t *data,uint16_t len)
+{
+	uint32_t capacity = (REG32(0x1FFFF7E0) & 0xFFFF) << 10;
+	uint32_t address = 0x08000000 + (capacity - TEST_INFO_FLASH_ADDRESS);
+	uint8_t i = 0;
+	uint32_t df_value = 0x0325;
+	
+	
+	fmc_unlock();
+	Flash_flag_clear();
+	fmc_page_erase(address);
+	Flash_flag_clear();
+	fmc_lock();
+
+
+
+	fmc_unlock();
+	
+	i = 0;
+	while(i<len)
+	{
+		memcpy(&df_value,&data[i],4);
+		fmc_word_program(address + i,df_value);
+		Flash_flag_clear();	
+		i+= 4;
+	}
+
+	fmc_lock();
+	
+}
+
+
+void Initial_Test_Info(void)
+{
+	uint32_t capacity = (REG32(0x1FFFF7E0) & 0xFFFF) << 10;
+	uint32_t address = 0x08000000 + (capacity - TEST_INFO_FLASH_ADDRESS);
+	
+	
+	TEST_INFO *temp_test_info = (TEST_INFO *)address;
+
+	memset(&test_info,0x00,sizeof(test_info));
+	 
+	if(temp_test_info->ti_flag != TI_VALID_FLAG_KEY)
+	{
+		test_info.ti_flag = TI_VALID_FLAG_KEY;
+		
+		Save_Test_Info_To_Flash((uint8_t *)&test_info,sizeof(test_info));
+	}
+	else
+	{
+		test_info = *temp_test_info;
+
+		test_info.ti_set = 0;
+	}
+
+	
+}
+
+void Save_Test_Info(void)
+{		
+	//if(test_info.ti_set == 0)
+	//	return;
+	
+	Save_Test_Info_To_Flash((uint8_t*)&test_info, sizeof(test_info));
+}
+void Ca_Chu_Test_Info(void)
+{
+	memset(&test_info, 0x00,sizeof(test_info));
+
+	test_info.ti_flag = TI_VALID_FLAG_KEY;
+		
+	Save_Test_Info_To_Flash((uint8_t *)&test_info,sizeof(test_info));
+}
+
+void Check_Enable_Test_Info(void)
+{

+	if(cb_operate_state == CB_BAT1_BAT2_SERIES)
+		test_info.ti_set = 1;
+	else
+		test_info.ti_set = 0;
+}
+

+ 26 - 0
Source/app_rs485_1.h

@@ -274,6 +274,24 @@ extern uint16_t bms_2_work_status ;
 extern uint8_t bms_1_test_define_error;
 extern uint8_t bms_2_test_define_error;
 
+typedef struct
+{
+	uint32_t bms_err_timeout_cnt;
+	uint32_t bms_err_cnt;
+}BMS_ERROR;
+
+#define TI_VALID_FLAG_KEY   (0x0326)
+typedef struct
+{
+	uint16_t ti_flag;
+	uint16_t ti_set;
+	BMS_ERROR ti_bms_1;
+	BMS_ERROR ti_bms_2;
+	
+}TEST_INFO;
+
+extern TEST_INFO test_info;
+
 void Check_Sub_BMS_1(void);
 
 void Check_Sub_BMS_2(void);
@@ -320,5 +338,13 @@ int8_t Update_Sub_BMS_2_Software(uint8_t step);
 
 extern void RS485_Print(uint8_t dest,uint8_t * dbuf,uint16_t dbuf_len);
 
+void Initial_Test_Info(void);
+
+void Save_Test_Info(void);
+
+void Ca_Chu_Test_Info(void);
+
+void Check_Enable_Test_Info(void);
+
 #endif
 

+ 2 - 0
Source/common.h

@@ -22,6 +22,8 @@
 #define SN_FLASH_ADDRESS   (2048)
 #define SYLC_FLASH_ADDRESS   (SN_FLASH_ADDRESS + 1024)
 #define HARD_TEST_FLASH_ADDRESS   (SYLC_FLASH_ADDRESS + 1024)
+#define TEST_INFO_FLASH_ADDRESS   (HARD_TEST_FLASH_ADDRESS + 1024)
+
 
 #define PS100_SERIAL_NUM_SIZE                      18
 #define PS100_SOFTWARE_SIZE                        20

+ 13 - 0
Source/delay.c

@@ -129,8 +129,15 @@ void SysTick_Handler(void)
 				{
 					sub_rs485_time_out_1.com_err_count = 0;
 					g_event |= SUB_BMS_1_RS485_DISC_EVENT;
+
+					if(test_info.ti_set)
+						test_info.ti_bms_1.bms_err_cnt++;
 				}
 			}
+			
+			if(test_info.ti_set)
+				test_info.ti_bms_1.bms_err_timeout_cnt++;
+			
 		}
 	}
 	
@@ -153,8 +160,14 @@ void SysTick_Handler(void)
 				{
 					sub_rs485_time_out_2.com_err_count = 0;
 					g_event |= SUB_BMS_2_RS485_DISC_EVENT;
+
+					if(test_info.ti_set)
+						test_info.ti_bms_2.bms_err_cnt++;
 				}
 			}
+
+			if(test_info.ti_set)
+				test_info.ti_bms_2.bms_err_timeout_cnt++;
 		}
 	}
 

+ 5 - 0
Source/main.c

@@ -174,6 +174,8 @@ int main(void)
 	Check_SN();
 
 	Low_Power_Initial();
+
+	Initial_Test_Info();
 	
 #if DEBUG_MODE == 0
 	Watch_Dog_Initial();
@@ -218,6 +220,8 @@ int main(void)
 		Cal_Sheng_Yu_Li_Cheng();
 
 		Check_S11_May_Operate();
+
+		Check_Enable_Test_Info();
 		
 		if(g_event & SUB_BMS_1_SEND_CMD_EVENT)
 		{
@@ -425,6 +429,7 @@ int main(void)
 		{	
 			g_event &= ~SAVE_PARAM_EVENT;
 		  	Save_Param();
+			Save_Test_Info();
 		}
 		
 	}

+ 1 - 1
Source/sw_build_info.h

@@ -1,3 +1,3 @@
 #pragma once
 
-#define CONFIG_VERSION "PS100XX_V01_0C021911"
+#define CONFIG_VERSION "PS100XX_V01_0C111358"