File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -42,14 +42,17 @@ class EEPROMClass : public FlashIAPBlockDevice {
42
42
void write (int idx, uint8_t * data, uint32_t size){
43
43
mbed::bd_size_t scratch_size = (_cfg.sram_bytes +3 )/4 ;
44
44
uint32_t scratch[scratch_size];
45
+
45
46
FlashIAPBlockDevice::read ((uint8_t *)scratch, 0 , _cfg.sram_bytes ); // keep all of flash in sram in case we need to erase
46
- if (memcmp ((void *)(((uint8_t *)scratch) + idx), data, size)){ // compare desired data (data) to existing information in flash (scratch)
47
+
48
+ if (memcmp ((void *)(((uint8_t *)scratch) + idx), data, size)){ // compare desired data (data) to existing information in flash (scratch)
49
+ memcpy (scratch + idx/4 , data, size);
50
+
47
51
erase ();
48
- memcpy (scratch, data, size);
49
52
int result = FlashIAPBlockDevice::program ((uint8_t *)scratch, 0 , 4 *scratch_size);
53
+
50
54
return ;
51
55
}
52
- // printf("contents already match\n");
53
56
}
54
57
void write (int idx, uint8_t val){
55
58
write (idx, &val, 1 );
You can’t perform that action at this time.
0 commit comments