@@ -26,7 +26,7 @@ void loop()
26
26
}
27
27
28
28
// 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 (byte I2C_ADDRESS )
29
+ void EEPROM_I2C_read (char I2C_Address )
30
30
{
31
31
Serial.println (" Enter EEPROM address (decimal) to read from:" );
32
32
while (!Serial.available ());
@@ -50,7 +50,7 @@ void EEPROM_I2C_read(byte I2C_ADDRESS)
50
50
while (readcount < amount)
51
51
{
52
52
// Begin a transmission to the I2C device.
53
- Wire.beginTransmission (I2C_ADDRESS );
53
+ Wire.beginTransmission (I2C_Address );
54
54
// Write the address offset by the amount of bytes we've already read.
55
55
Wire.write (address + readcount);
56
56
// 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(byte I2C_ADDRESS)
60
60
// Print human readable error message if applicable.
61
61
EEPROM_I2C_printreturncode (result);
62
62
// 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);
64
64
// Read the data available on the I2C bus.
65
65
while (Wire.available ())
66
66
{
@@ -85,7 +85,7 @@ void EEPROM_I2C_read(byte I2C_ADDRESS)
85
85
Serial.println (" Received less than target amount of bytes!" );
86
86
}
87
87
88
- void EEPROM_I2C_write (byte I2C_ADDRESS )
88
+ void EEPROM_I2C_write (char I2C_Address )
89
89
{
90
90
// Constant for the number of tries. With 10 you're fine, I never had 10 write failures in succession.
91
91
const char NUM_TRIES = 10 ;
@@ -118,7 +118,7 @@ void EEPROM_I2C_write(byte I2C_ADDRESS)
118
118
for (char result = 4 ; result > 0 && tries < NUM_TRIES; tries++)
119
119
{
120
120
// Begin a transmission to the I²C device (the EEPROM).
121
- Wire.beginTransmission (I2C_ADDRESS );
121
+ Wire.beginTransmission (I2C_Address );
122
122
// Write the EEPROM address to the I²C bus, this sets the start address of the write operation.
123
123
Wire.write (address);
124
124
// Write the byte grabbed from the I²C bus.
@@ -149,7 +149,7 @@ void EEPROM_I2C_write(byte I2C_ADDRESS)
149
149
Serial.println ();
150
150
}
151
151
152
- byte EEPROM_I2C_setAddress ()
152
+ char EEPROM_I2C_setAddress ()
153
153
{
154
154
while (true )
155
155
{
@@ -184,8 +184,9 @@ byte EEPROM_I2C_setAddress()
184
184
}
185
185
}
186
186
187
- void EEPROM_I2C_interactive (char I2C_ADDRESS )
187
+ void EEPROM_I2C_interactive (char address )
188
188
{
189
+ char I2C_Address = address;
189
190
// Loop forever
190
191
while (true )
191
192
{
@@ -204,13 +205,13 @@ void EEPROM_I2C_interactive(char I2C_ADDRESS)
204
205
char command = Serial.read ();
205
206
if (command == ' W' )
206
207
// Start the write function if the command character was a 'W'.
207
- EEPROM_I2C_write (I2C_ADDRESS );
208
+ EEPROM_I2C_write (I2C_Address );
208
209
else if (command == ' R' )
209
210
// Start the read function if the command character was an 'R'.
210
- EEPROM_I2C_read (I2C_ADDRESS );
211
+ EEPROM_I2C_read (I2C_Address );
211
212
else if (command == ' S' )
212
213
// Start the setAddress funtion if the command character was an 'S'.
213
- EEPROM_I2C_setAddress ();
214
+ I2C_Address = EEPROM_I2C_setAddress ();
214
215
else if (command == ' P' )
215
216
// Start the function that polls the I2C bus.
216
217
EEPROM_I2C_pollbus ();
0 commit comments