chage tab

This commit is contained in:
redoc 2020-03-12 15:02:26 +08:00 committed by GitHub
parent acf4fc6d2e
commit 363903b984
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 59 additions and 59 deletions

View File

@ -186,72 +186,72 @@ __exit:
*/
int stm32_flash_erase(rt_uint32_t addr, size_t size)
{
rt_err_t result = RT_EOK;
rt_err_t result = RT_EOK;
#if defined(FLASH_BANK2_END)
uint32_t addr_bank1 = 0;
uint32_t size_bank1 = 0;
uint32_t addr_bank2 = 0;
uint32_t size_bank2 = 0;
uint8_t bank1_flag = 0;
uint8_t bank2_flag = 0;
uint32_t addr_bank1 = 0;
uint32_t size_bank1 = 0;
uint32_t addr_bank2 = 0;
uint32_t size_bank2 = 0;
uint8_t bank1_flag = 0;
uint8_t bank2_flag = 0;
#endif
#if defined(FLASH_BANK2_END)
if(addr <= FLASH_BANK1_END)
{
addr_bank1 = addr;
bank1_flag = 1;
if(addr <= FLASH_BANK1_END)
{
addr_bank1 = addr;
bank1_flag = 1;
if((addr + size) > FLASH_BANK1_END)
{
addr_bank2 = FLASH_BANK1_END + 1;
size_bank2 = addr + size - (FLASH_BANK1_END + 1);
if((addr + size) > FLASH_BANK1_END)
{
addr_bank2 = FLASH_BANK1_END + 1;
size_bank2 = addr + size - (FLASH_BANK1_END + 1);
if(size_bank2)
{
bank2_flag = 1;
}
if(size_bank2)
{
bank2_flag = 1;
}
size_bank1 = FLASH_BANK1_END + 1 - addr_bank1;
}
else
{
size_bank1 = size;
}
}
else
{
addr_bank2 = addr;
size_bank2 = size;
bank1_flag = 0;
bank2_flag = 1;
}
size_bank1 = FLASH_BANK1_END + 1 - addr_bank1;
}
else
{
size_bank1 = size;
}
}
else
{
addr_bank2 = addr;
size_bank2 = size;
bank1_flag = 0;
bank2_flag = 1;
}
if(bank1_flag)
{
log_d("bank1: addr (0x%p), size %d", (void *)addr_bank1, size_bank1);
if(bank1_flag)
{
log_d("bank1: addr (0x%p), size %d", (void *)addr_bank1, size_bank1);
if(size_bank1 != stm32_flash_erase_bank(FLASH_BANK_1, addr_bank1, size_bank1))
{
result = -RT_ERROR;
}
}
if(size_bank1 != stm32_flash_erase_bank(FLASH_BANK_1, addr_bank1, size_bank1))
{
result = -RT_ERROR;
}
}
if(bank2_flag)
{
log_d("bank2: addr (0x%p), size %d", (void *)addr_bank2, size_bank2);
if(bank2_flag)
{
log_d("bank2: addr (0x%p), size %d", (void *)addr_bank2, size_bank2);
if(size_bank2 != stm32_flash_erase_bank(FLASH_BANK_2, addr_bank2, size_bank2))
{
result = -RT_ERROR;
}
}
if(size_bank2 != stm32_flash_erase_bank(FLASH_BANK_2, addr_bank2, size_bank2))
{
result = -RT_ERROR;
}
}
return result;
return result;
#else
return stm32_flash_erase_bank(FLASH_BANK_1, addr, size);
return stm32_flash_erase_bank(FLASH_BANK_1, addr, size);
#endif
}