|
|
@@ -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;
|
|
|
+}
|
|
|
+
|