@@ -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 (byte 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(byte 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(byte 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(byte I2C_ADDRESS)
8585 Serial.println (" Received less than target amount of bytes!" );
8686}
8787
88- void EEPROM_I2C_write (byte 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(byte 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.
@@ -149,7 +149,7 @@ void EEPROM_I2C_write(byte I2C_ADDRESS)
149149 Serial.println ();
150150}
151151
152- byte EEPROM_I2C_setAddress ()
152+ char EEPROM_I2C_setAddress ()
153153{
154154 while (true )
155155 {
@@ -184,8 +184,9 @@ byte EEPROM_I2C_setAddress()
184184 }
185185}
186186
187- void EEPROM_I2C_interactive (char I2C_ADDRESS )
187+ void EEPROM_I2C_interactive (char address )
188188{
189+ char I2C_Address = address;
189190 // Loop forever
190191 while (true )
191192 {
@@ -204,13 +205,13 @@ void EEPROM_I2C_interactive(char I2C_ADDRESS)
204205 char command = Serial.read ();
205206 if (command == ' W' )
206207 // Start the write function if the command character was a 'W'.
207- EEPROM_I2C_write (I2C_ADDRESS );
208+ EEPROM_I2C_write (I2C_Address );
208209 else if (command == ' R' )
209210 // Start the read function if the command character was an 'R'.
210- EEPROM_I2C_read (I2C_ADDRESS );
211+ EEPROM_I2C_read (I2C_Address );
211212 else if (command == ' S' )
212213 // Start the setAddress funtion if the command character was an 'S'.
213- EEPROM_I2C_setAddress ();
214+ I2C_Address = EEPROM_I2C_setAddress ();
214215 else if (command == ' P' )
215216 // Start the function that polls the I2C bus.
216217 EEPROM_I2C_pollbus ();
0 commit comments