Rev 70 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 70 | Rev 79 | ||
---|---|---|---|
Line 43... | Line 43... | ||
43 | for (int ptr = 0; ptr < NVRAM_WORDS; ptr++) |
43 | for (int ptr = 0; ptr < NVRAM_WORDS; ptr++) |
44 | { |
44 | { |
45 | // erase the entry just found |
45 | // erase the entry just found |
46 | if (NVRAM_Base[ptr].data.tag == data.data.tag) |
46 | if (NVRAM_Base[ptr].data.tag == data.data.tag) |
47 | { |
47 | { |
48 | // erase previous data |
48 | // erase previous data, delete any entries that have a matching tag |
49 | WriteNVRAM(&NVRAM_Base[ptr], MARKED_ERASED); |
49 | WriteNVRAM(&NVRAM_Base[ptr], MARKED_ERASED); |
- | 50 | // record the next location to the marked erased location |
|
- | 51 | // so that future writes occur further along in the Flash |
|
50 | base = ptr; |
52 | if (base == 0) |
51 | break; |
53 | base = ptr; |
52 | } |
54 | } |
53 | } |
55 | } |
- | 56 | ||
54 | // search forward for next erased or empty element, use it |
57 | // search forward for next erased or empty element, use it |
55 | for (int offset = 1; offset < NVRAM_WORDS + 1; offset++) |
58 | for (int offset = 1; offset < NVRAM_WORDS + 1; offset++) |
56 | { |
59 | { |
57 | int index = (base + offset) % NVRAM_WORDS; |
60 | int index = (base + offset) % NVRAM_WORDS; |
58 | if (NVRAM_Base[index].u32 == MARKED_ERASED.u32 || NVRAM_Base[index].u32 == HARDWARE_ERASED.u32) |
61 | if (NVRAM_Base[index].u32 == MARKED_ERASED.u32 || NVRAM_Base[index].u32 == HARDWARE_ERASED.u32) |