modify space
This commit is contained in:
parent
516702d69e
commit
6b614c05b8
|
@ -42,122 +42,122 @@
|
||||||
*/
|
*/
|
||||||
static rt_uint32_t GetSector(rt_uint32_t Address)
|
static rt_uint32_t GetSector(rt_uint32_t Address)
|
||||||
{
|
{
|
||||||
uint32_t sector = 0;
|
uint32_t sector = 0;
|
||||||
|
|
||||||
#if defined (FLASH_OPTCR_nDBANK)
|
#if defined (FLASH_OPTCR_nDBANK)
|
||||||
FLASH_OBProgramInitTypeDef OBInit;
|
FLASH_OBProgramInitTypeDef OBInit;
|
||||||
uint32_t nbank = 0;
|
uint32_t nbank = 0;
|
||||||
|
|
||||||
//get duel bank ability:nDBANK(Bit29)
|
//get duel bank ability:nDBANK(Bit29)
|
||||||
HAL_FLASHEx_OBGetConfig(&OBInit);
|
HAL_FLASHEx_OBGetConfig(&OBInit);
|
||||||
nbank = ((OBInit.USERConfig & 0x20000000U) >> 29);
|
nbank = ((OBInit.USERConfig & 0x20000000U) >> 29);
|
||||||
//1:single bank mode
|
//1:single bank mode
|
||||||
if(1 == nbank)
|
if(1 == nbank)
|
||||||
{
|
{
|
||||||
|
if((Address < ADDR_FLASH_SECTOR_1) && (Address >= ADDR_FLASH_SECTOR_0))
|
||||||
|
{
|
||||||
|
sector = FLASH_SECTOR_0;
|
||||||
|
}
|
||||||
|
else if((Address < ADDR_FLASH_SECTOR_2) && (Address >= ADDR_FLASH_SECTOR_1))
|
||||||
|
{
|
||||||
|
sector = FLASH_SECTOR_1;
|
||||||
|
}
|
||||||
|
else if((Address < ADDR_FLASH_SECTOR_3) && (Address >= ADDR_FLASH_SECTOR_2))
|
||||||
|
{
|
||||||
|
sector = FLASH_SECTOR_2;
|
||||||
|
}
|
||||||
|
else if((Address < ADDR_FLASH_SECTOR_4) && (Address >= ADDR_FLASH_SECTOR_3))
|
||||||
|
{
|
||||||
|
sector = FLASH_SECTOR_3;
|
||||||
|
}
|
||||||
|
else if((Address < ADDR_FLASH_SECTOR_5) && (Address >= ADDR_FLASH_SECTOR_4))
|
||||||
|
{
|
||||||
|
sector = FLASH_SECTOR_4;
|
||||||
|
}
|
||||||
|
else if((Address < ADDR_FLASH_SECTOR_6) && (Address >= ADDR_FLASH_SECTOR_5))
|
||||||
|
{
|
||||||
|
sector = FLASH_SECTOR_5;
|
||||||
|
}
|
||||||
|
else if((Address < ADDR_FLASH_SECTOR_7) && (Address >= ADDR_FLASH_SECTOR_6))
|
||||||
|
{
|
||||||
|
sector = FLASH_SECTOR_6;
|
||||||
|
}
|
||||||
|
else if((Address < ADDR_FLASH_SECTOR_8) && (Address >= ADDR_FLASH_SECTOR_7))
|
||||||
|
{
|
||||||
|
sector = FLASH_SECTOR_7;
|
||||||
|
}
|
||||||
|
else if((Address < ADDR_FLASH_SECTOR_9) && (Address >= ADDR_FLASH_SECTOR_8))
|
||||||
|
{
|
||||||
|
sector = FLASH_SECTOR_8;
|
||||||
|
}
|
||||||
|
else if((Address < ADDR_FLASH_SECTOR_10) && (Address >= ADDR_FLASH_SECTOR_9))
|
||||||
|
{
|
||||||
|
sector = FLASH_SECTOR_9;
|
||||||
|
}
|
||||||
|
else if((Address < ADDR_FLASH_SECTOR_11) && (Address >= ADDR_FLASH_SECTOR_10))
|
||||||
|
{
|
||||||
|
sector = FLASH_SECTOR_10;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sector = FLASH_SECTOR_11;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else //0:dual bank mode
|
||||||
|
{
|
||||||
|
RT_ASSERT("rtthread doesn't support duel bank mode yet!");
|
||||||
|
}
|
||||||
|
#else //no dual bank ability
|
||||||
if((Address < ADDR_FLASH_SECTOR_1) && (Address >= ADDR_FLASH_SECTOR_0))
|
if((Address < ADDR_FLASH_SECTOR_1) && (Address >= ADDR_FLASH_SECTOR_0))
|
||||||
{
|
{
|
||||||
sector = FLASH_SECTOR_0;
|
sector = FLASH_SECTOR_0;
|
||||||
}
|
}
|
||||||
else if((Address < ADDR_FLASH_SECTOR_2) && (Address >= ADDR_FLASH_SECTOR_1))
|
else if((Address < ADDR_FLASH_SECTOR_2) && (Address >= ADDR_FLASH_SECTOR_1))
|
||||||
{
|
{
|
||||||
sector = FLASH_SECTOR_1;
|
sector = FLASH_SECTOR_1;
|
||||||
}
|
}
|
||||||
else if((Address < ADDR_FLASH_SECTOR_3) && (Address >= ADDR_FLASH_SECTOR_2))
|
else if((Address < ADDR_FLASH_SECTOR_3) && (Address >= ADDR_FLASH_SECTOR_2))
|
||||||
{
|
{
|
||||||
sector = FLASH_SECTOR_2;
|
sector = FLASH_SECTOR_2;
|
||||||
}
|
}
|
||||||
else if((Address < ADDR_FLASH_SECTOR_4) && (Address >= ADDR_FLASH_SECTOR_3))
|
else if((Address < ADDR_FLASH_SECTOR_4) && (Address >= ADDR_FLASH_SECTOR_3))
|
||||||
{
|
{
|
||||||
sector = FLASH_SECTOR_3;
|
sector = FLASH_SECTOR_3;
|
||||||
}
|
}
|
||||||
else if((Address < ADDR_FLASH_SECTOR_5) && (Address >= ADDR_FLASH_SECTOR_4))
|
else if((Address < ADDR_FLASH_SECTOR_5) && (Address >= ADDR_FLASH_SECTOR_4))
|
||||||
{
|
{
|
||||||
sector = FLASH_SECTOR_4;
|
sector = FLASH_SECTOR_4;
|
||||||
}
|
}
|
||||||
else if((Address < ADDR_FLASH_SECTOR_6) && (Address >= ADDR_FLASH_SECTOR_5))
|
else if((Address < ADDR_FLASH_SECTOR_6) && (Address >= ADDR_FLASH_SECTOR_5))
|
||||||
{
|
{
|
||||||
sector = FLASH_SECTOR_5;
|
sector = FLASH_SECTOR_5;
|
||||||
}
|
}
|
||||||
else if((Address < ADDR_FLASH_SECTOR_7) && (Address >= ADDR_FLASH_SECTOR_6))
|
else if((Address < ADDR_FLASH_SECTOR_7) && (Address >= ADDR_FLASH_SECTOR_6))
|
||||||
{
|
{
|
||||||
sector = FLASH_SECTOR_6;
|
sector = FLASH_SECTOR_6;
|
||||||
}
|
}
|
||||||
else if((Address < ADDR_FLASH_SECTOR_8) && (Address >= ADDR_FLASH_SECTOR_7))
|
else if((Address < ADDR_FLASH_SECTOR_8) && (Address >= ADDR_FLASH_SECTOR_7))
|
||||||
{
|
{
|
||||||
sector = FLASH_SECTOR_7;
|
sector = FLASH_SECTOR_7;
|
||||||
}
|
}
|
||||||
else if((Address < ADDR_FLASH_SECTOR_9) && (Address >= ADDR_FLASH_SECTOR_8))
|
else if((Address < ADDR_FLASH_SECTOR_9) && (Address >= ADDR_FLASH_SECTOR_8))
|
||||||
{
|
{
|
||||||
sector = FLASH_SECTOR_8;
|
sector = FLASH_SECTOR_8;
|
||||||
}
|
}
|
||||||
else if((Address < ADDR_FLASH_SECTOR_10) && (Address >= ADDR_FLASH_SECTOR_9))
|
else if((Address < ADDR_FLASH_SECTOR_10) && (Address >= ADDR_FLASH_SECTOR_9))
|
||||||
{
|
{
|
||||||
sector = FLASH_SECTOR_9;
|
sector = FLASH_SECTOR_9;
|
||||||
}
|
}
|
||||||
else if((Address < ADDR_FLASH_SECTOR_11) && (Address >= ADDR_FLASH_SECTOR_10))
|
else if((Address < ADDR_FLASH_SECTOR_11) && (Address >= ADDR_FLASH_SECTOR_10))
|
||||||
{
|
{
|
||||||
sector = FLASH_SECTOR_10;
|
sector = FLASH_SECTOR_10;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sector = FLASH_SECTOR_11;
|
sector = FLASH_SECTOR_11;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else //0:dual bank mode
|
|
||||||
{
|
|
||||||
RT_ASSERT("rtthread doesn't support duel bank mode yet!");
|
|
||||||
}
|
|
||||||
#else //no dual bank ability
|
|
||||||
if((Address < ADDR_FLASH_SECTOR_1) && (Address >= ADDR_FLASH_SECTOR_0))
|
|
||||||
{
|
|
||||||
sector = FLASH_SECTOR_0;
|
|
||||||
}
|
|
||||||
else if((Address < ADDR_FLASH_SECTOR_2) && (Address >= ADDR_FLASH_SECTOR_1))
|
|
||||||
{
|
|
||||||
sector = FLASH_SECTOR_1;
|
|
||||||
}
|
|
||||||
else if((Address < ADDR_FLASH_SECTOR_3) && (Address >= ADDR_FLASH_SECTOR_2))
|
|
||||||
{
|
|
||||||
sector = FLASH_SECTOR_2;
|
|
||||||
}
|
|
||||||
else if((Address < ADDR_FLASH_SECTOR_4) && (Address >= ADDR_FLASH_SECTOR_3))
|
|
||||||
{
|
|
||||||
sector = FLASH_SECTOR_3;
|
|
||||||
}
|
|
||||||
else if((Address < ADDR_FLASH_SECTOR_5) && (Address >= ADDR_FLASH_SECTOR_4))
|
|
||||||
{
|
|
||||||
sector = FLASH_SECTOR_4;
|
|
||||||
}
|
|
||||||
else if((Address < ADDR_FLASH_SECTOR_6) && (Address >= ADDR_FLASH_SECTOR_5))
|
|
||||||
{
|
|
||||||
sector = FLASH_SECTOR_5;
|
|
||||||
}
|
|
||||||
else if((Address < ADDR_FLASH_SECTOR_7) && (Address >= ADDR_FLASH_SECTOR_6))
|
|
||||||
{
|
|
||||||
sector = FLASH_SECTOR_6;
|
|
||||||
}
|
|
||||||
else if((Address < ADDR_FLASH_SECTOR_8) && (Address >= ADDR_FLASH_SECTOR_7))
|
|
||||||
{
|
|
||||||
sector = FLASH_SECTOR_7;
|
|
||||||
}
|
|
||||||
else if((Address < ADDR_FLASH_SECTOR_9) && (Address >= ADDR_FLASH_SECTOR_8))
|
|
||||||
{
|
|
||||||
sector = FLASH_SECTOR_8;
|
|
||||||
}
|
|
||||||
else if((Address < ADDR_FLASH_SECTOR_10) && (Address >= ADDR_FLASH_SECTOR_9))
|
|
||||||
{
|
|
||||||
sector = FLASH_SECTOR_9;
|
|
||||||
}
|
|
||||||
else if((Address < ADDR_FLASH_SECTOR_11) && (Address >= ADDR_FLASH_SECTOR_10))
|
|
||||||
{
|
|
||||||
sector = FLASH_SECTOR_10;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sector = FLASH_SECTOR_11;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
return sector;
|
return sector;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue