Skip to content

Commit 40a117f

Browse files
committed
Changes name of variable I2C_ADDRESS to I2C_Address.
This prevents people from thinking it's a constant.
1 parent 04bec92 commit 40a117f

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

eeprom_edit.ino

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ void loop()
2626
}
2727

2828
//Prompt the user for an address on the EEPROM to read from, and the amount of bytes to read from there.
29-
void EEPROM_I2C_read(char I2C_ADDRESS)
29+
void EEPROM_I2C_read(char I2C_Address)
3030
{
3131
Serial.println("Enter EEPROM address (decimal) to read from:");
3232
while(!Serial.available());
@@ -50,7 +50,7 @@ void EEPROM_I2C_read(char I2C_ADDRESS)
5050
while (readcount < amount)
5151
{
5252
//Begin a transmission to the I2C device.
53-
Wire.beginTransmission(I2C_ADDRESS);
53+
Wire.beginTransmission(I2C_Address);
5454
//Write the address offset by the amount of bytes we've already read.
5555
Wire.write(address + readcount);
5656
//Write the buffered transmission, send a restart instead of a stop byte. (see T24C02A datasheet: Random read and Sequential read)
@@ -60,7 +60,7 @@ void EEPROM_I2C_read(char I2C_ADDRESS)
6060
//Print human readable error message if applicable.
6161
EEPROM_I2C_printreturncode(result);
6262
//Request amount-readcount bytes of data from the I2C device (the EEPROM). It will return up to 32 bytes.
63-
Wire.requestFrom(int(I2C_ADDRESS),amount-readcount);
63+
Wire.requestFrom(int(I2C_Address),amount-readcount);
6464
//Read the data available on the I2C bus.
6565
while(Wire.available())
6666
{
@@ -85,7 +85,7 @@ void EEPROM_I2C_read(char I2C_ADDRESS)
8585
Serial.println("Received less than target amount of bytes!");
8686
}
8787

88-
void EEPROM_I2C_write(char I2C_ADDRESS)
88+
void EEPROM_I2C_write(char I2C_Address)
8989
{
9090
//Constant for the number of tries. With 10 you're fine, I never had 10 write failures in succession.
9191
const char NUM_TRIES = 10;
@@ -118,7 +118,7 @@ void EEPROM_I2C_write(char I2C_ADDRESS)
118118
for (char result = 4; result > 0 && tries < NUM_TRIES; tries++)
119119
{
120120
//Begin a transmission to the I²C device (the EEPROM).
121-
Wire.beginTransmission(I2C_ADDRESS);
121+
Wire.beginTransmission(I2C_Address);
122122
//Write the EEPROM address to the I²C bus, this sets the start address of the write operation.
123123
Wire.write(address);
124124
//Write the byte grabbed from the I²C bus.
@@ -184,7 +184,7 @@ char EEPROM_I2C_setAddress()
184184
}
185185
}
186186

187-
void EEPROM_I2C_interactive(char I2C_ADDRESS)
187+
void EEPROM_I2C_interactive(char I2C_Address)
188188
{
189189
//Loop forever
190190
while(true)
@@ -204,10 +204,10 @@ void EEPROM_I2C_interactive(char I2C_ADDRESS)
204204
char command = Serial.read();
205205
if (command == 'W')
206206
//Start the write function if the command character was a 'W'.
207-
EEPROM_I2C_write(I2C_ADDRESS);
207+
EEPROM_I2C_write(I2C_Address);
208208
else if (command == 'R')
209209
//Start the read function if the command character was an 'R'.
210-
EEPROM_I2C_read(I2C_ADDRESS);
210+
EEPROM_I2C_read(I2C_Address);
211211
else if (command == 'S')
212212
//Start the setAddress funtion if the command character was an 'S'.
213213
EEPROM_I2C_setAddress();

0 commit comments

Comments
 (0)