Diskusní téma: Lekce 18 - Arduino a externí EEPROM přes I2C

Datum
Vložil
Titulek

i2c eeprom zápis int hodnoty

je tedy správně toto? pro 24c32 a větší

void i2c_eepromIntWrite( int device, unsigned int adresa, int hodnota )
{
byte byte1 = hodnota;
byte byte2 = hodnota >> 8;
Wire.beginTransmission(device);
Wire.write((int)(adresa)); // odešle vyšší byte
Wire.write((int)(adresa & 0xFF)); // odešle nižší byte
Wire.write(byte1);
Wire.write(byte2);
Wire.endTransmission();
}

int i2c_eepromIntRead( int device, unsigned int adresa )
{
byte rdata1;
byte rdata2;
Wire.beginTransmission(device);
Wire.write((int)(adresa)); // odešle vyšší byte
Wire.write((int)(adresa & 0xFF)); // odešle nižší byte
Wire.endTransmission();
Wire.requestFrom(device,2);
if (Wire.available()) rdata1 = Wire.read();
if (Wire.available()) rdata2 = Wire.read();
return (rdata1+(rdata2 << 8));
}

Zpět na diskuzi

Vyhledávání

arduino8.cz © 2015 Všechna práva vyhrazena.