Commit 27712d3d authored by 李冠华's avatar 李冠华

feat:暂存测试更改

parent 6e5823cf
...@@ -65,6 +65,11 @@ static void APP_SystemClockConfig(void); ...@@ -65,6 +65,11 @@ static void APP_SystemClockConfig(void);
// static void APP_FlashBlank(void); // static void APP_FlashBlank(void);
// static void APP_FlashVerify(void); // static void APP_FlashVerify(void);
// void xie_ce_shi(void);
// void ca_ce_shi(void);
/** /**
* @brief Main program. * @brief Main program.
* @retval int * @retval int
...@@ -90,6 +95,7 @@ int main(void) ...@@ -90,6 +95,7 @@ int main(void)
// CAN_Config(); // CAN_Config();
BSP_LED_On(LED_GREEN); BSP_LED_On(LED_GREEN);
// printf("开始断电测试!!!!!\n\r");
/* Wait for the button to be pressed */ /* Wait for the button to be pressed */
// while (BSP_PB_GetState(BUTTON_USER)) // while (BSP_PB_GetState(BUTTON_USER))
// { // {
...@@ -149,7 +155,7 @@ int main(void) ...@@ -149,7 +155,7 @@ int main(void)
// EEPROM_Write_Data(SECTOR_15_START_ADDR, koko, 8); // EEPROM_Write_Data(SECTOR_15_START_ADDR, koko, 8);
// memset(koko,0,32); // memset(koko,0,32);
EEPROM_Init(); EEPROM_Init();
// for(uint8_t i = 0; i < 250; i ++) // for(uint8_t i = 0; i < 202; i ++)
// { // {
// EEPROM_Write_Data(EEPROM_BLOCK_UDS_FLAG, TestData,8); // EEPROM_Write_Data(EEPROM_BLOCK_UDS_FLAG, TestData,8);
// TestData[0] ++; // TestData[0] ++;
...@@ -240,6 +246,17 @@ int main(void) ...@@ -240,6 +246,17 @@ int main(void)
// NVS_Test_Max_Service(); // NVS_Test_Max_Service();
// CAN_TX_Service(); // CAN_TX_Service();
// } // }
// while(1)
// {
// ca_ce_shi();
// printf("ca chu wan le!!!!!\n\r");
// xie_ce_shi();
// printf("xie wan le!!!!!\n\r");
// }
} }
/** /**
...@@ -366,6 +383,46 @@ static void APP_SystemClockConfig(void) ...@@ -366,6 +383,46 @@ static void APP_SystemClockConfig(void)
// addr += 4; // addr += 4;
// } // }
// } // }
void ca_ce_shi(void)
{
uint32_t PAGEError = 0;
FLASH_EraseInitTypeDef EraseInitStruct = {0};
/* Unlock Flash */
HAL_FLASH_Unlock();
EraseInitStruct.TypeErase = FLASH_TYPEERASE_PAGEERASE; /* Erase type FLASH_TYPEERASE_PAGEERASE=Page erase, FLASH_TYPEERASE_SECTORERASE=Sector Erase */
EraseInitStruct.PageAddress = SECTOR_9_START_ADDR; /* Erase Start Address */
EraseInitStruct.NbPages = ((SECTOR_15_START_ADDR - SECTOR_9_START_ADDR) / 0x100); /* Number of pages that need to be erased */
if (HAL_FLASHEx_Erase(&EraseInitStruct, &PAGEError) != HAL_OK) /* Executing page erasure, PAGEError returns the page with the erasure error and 0xFFFFFFFF, indicating successful erasure */
{
;
}
else
{
;
}
/* Lock Flash */
HAL_FLASH_Lock();
}
void xie_ce_shi(void)
{
uint32_t flash_program_start = SECTOR_9_START_ADDR ; /* flash program start address */
uint32_t flash_program_end = (SECTOR_15_START_ADDR - 1); /* flash program end address */
uint32_t *src = (uint32_t *)DATA; /* Program data */
HAL_FLASH_Unlock();
while (flash_program_start < flash_program_end)
{
if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_PAGE, flash_program_start, src) == HAL_OK)/* Program */
{
flash_program_start += FLASH_PAGE_SIZE; /* flash Start point first page */
src += FLASH_PAGE_SIZE / 4; /* Update data point */
}
}
HAL_FLASH_Lock();
}
/** /**
* @brief This function is executed in case of error occurrence. * @brief This function is executed in case of error occurrence.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment