mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
[ion/device] Fix Flash::SectorAtAddress to handle random values
This commit is contained in:
committed by
LeaNumworks
parent
fc80180d46
commit
c934531ced
@@ -54,13 +54,14 @@ static void typed_memcpy(uint8_t * source, uint8_t * destination, size_t length)
|
||||
}
|
||||
|
||||
int SectorAtAddress(uint32_t address) {
|
||||
uint32_t sectorAddresses[NumberOfSectors] = {
|
||||
uint32_t sectorAddresses[NumberOfSectors+1] = {
|
||||
0x08000000, 0x08004000, 0x08008000, 0x0800C000,
|
||||
0x08010000, 0x08020000, 0x08040000, 0x08060000,
|
||||
0x08080000, 0x080A0000, 0x080C0000, 0x080E0000
|
||||
0x08080000, 0x080A0000, 0x080C0000, 0x080E0000,
|
||||
0x08100000
|
||||
};
|
||||
for (int i=0; i<NumberOfSectors; i++) {
|
||||
if (sectorAddresses[i] == address) {
|
||||
if (address >= sectorAddresses[i] && address < sectorAddresses[i+1]) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user