Skip to content

Commit 17eac79

Browse files
bigdinotechBrian Baltz
authored andcommitted
Fix Klockwork issues in CurieEEPROM arduino#142
-Also fixes issue of not being able to rewrite the last 3/4 of the EEPROM area
1 parent e50ef90 commit 17eac79

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

libraries/CurieEEPROM/src/CurieEEPROM.cpp

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,13 @@ void CurieEEPROM::write(uint32_t address, uint32_t data)
4848
address*=sizeof(uint32_t);
4949

5050
uint32_t rom_wr_ctrl = 0;
51-
//make sure address is valid
52-
if((address > 0x7FC) || (address%4))
53-
{
54-
return;
55-
}
5651

5752
//check if address is available for writing a new value. If not erase the whole 2K block and re-write the rest of the data
5853
if(currentValue!=0xFFFFFFFF)
5954
{
6055
//read entire 2k of data
61-
uint32_t blockdata[EEPROM_SIZE/4];
62-
for(int i = 0; i < EEPROM_SIZE/4; i++)
56+
uint32_t blockdata[EEPROM_SIZE];
57+
for(int i = 0; i < EEPROM_SIZE; i++)
6358
{
6459
blockdata[i] = read(i*sizeof(uint32_t));
6560
}
@@ -72,7 +67,7 @@ void CurieEEPROM::write(uint32_t address, uint32_t data)
7267
clear();
7368

7469
//write back all data with update data on passed address
75-
for(int i = 0; i < EEPROM_SIZE/4; i++)
70+
for(int i = 0; i < EEPROM_SIZE; i++)
7671
{
7772
//store data into ROM_WR_DATA register
7873
*(uint32_t*)(ROM_WR_DATA) = blockdata[i];
@@ -115,8 +110,8 @@ void CurieEEPROM::write8(uint32_t address, uint8_t data)
115110
if(currentValue!=0xFF)
116111
{
117112
//read entire 2k of data
118-
uint32_t blockdata[EEPROM_SIZE/4];
119-
for(int i = 0; i < EEPROM_SIZE/4; i++)
113+
uint32_t blockdata[EEPROM_SIZE];
114+
for(int i = 0; i < EEPROM_SIZE; i++)
120115
{
121116
blockdata[i] = read(i*sizeof(uint32_t));
122117
}
@@ -135,7 +130,7 @@ void CurieEEPROM::write8(uint32_t address, uint8_t data)
135130
clear();
136131

137132
//write back all data with update data on passed address
138-
for(int i = 0; i < EEPROM_SIZE/4; i++)
133+
for(int i = 0; i < EEPROM_SIZE; i++)
139134
{
140135
//store data into ROM_WR_DATA register
141136
*(uint32_t*)(ROM_WR_DATA) = blockdata[i];

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy