Exemple #1
0
void KEYS::writeByte(uint8_t data, uint8_t reg) {
  Wire.beginTransmission(_address);
  I2CWRITE((uint8_t) reg);
  
  I2CWRITE((uint8_t) data);
  Wire.endTransmission();

  return;
}
Exemple #2
0
bool KEYS::read3Bytes(uint32_t *data, uint8_t reg) {

  union
  {
    uint8_t b[4];
    uint32_t w;
  } datau;
  
  datau.w = *data;

  Wire.beginTransmission(_address);
  I2CWRITE((uint8_t) reg);
  Wire.endTransmission();
  uint8_t timeout=0;
  
  Wire.requestFrom(_address, (uint8_t) 0x03);
  while(Wire.available() < 3) {
    timeout++;
	if(timeout > I2CTIMEOUT) {
	  return(true);
	}
	delay(1);
  } 		//Experimental
  
  datau.b[0] = I2CREAD();
  datau.b[1] = I2CREAD();
  datau.b[2] = I2CREAD();
  
  *data = datau.w;
  

return(false);
}
Exemple #3
0
void I2C_4DI4RO::updateGPIO() {
	/* Compute new GPIO states */
	uint8_t value = (_PIN & ~_DDR) | _PORT;

	/* Start communication and send GPIO values as byte */
	Wire.beginTransmission(_address);
	I2CWRITE(value);
	Wire.endTransmission();
}
Exemple #4
0
void KEYS::write3Bytes(uint32_t data, uint8_t reg) {

  union
  {
    uint8_t b[4];
    uint32_t w;
  } datau;
  
  datau.w = data;

  Wire.beginTransmission(_address);
  I2CWRITE((uint8_t) reg);
  
  I2CWRITE((uint8_t) datau.b[0]);
  I2CWRITE((uint8_t) datau.b[1]);
  I2CWRITE((uint8_t) datau.b[2]);
  
  Wire.endTransmission();
  return;
}
Exemple #5
0
void PCF8574::updateGPIO() {

	/* Read current GPIO states */
	//readGPIO(); // Experimental

	/* Compute new GPIO states */
	//uint8_t value = ((_PIN & ~_DDR) & ~(~_DDR & _PORT)) | _PORT; // Experimental
	uint8_t value = (_PIN & ~_DDR) | _PORT;

	/* Start communication and send GPIO values as byte */
	Wire.beginTransmission(_address);
	I2CWRITE(value);
	Wire.endTransmission();
}
Exemple #6
0
bool KEYS::readByte(uint8_t *data, uint8_t reg) {
  Wire.beginTransmission(_address);
  I2CWRITE((uint8_t) reg);
  Wire.endTransmission();
  uint8_t timeout=0;
  
  Wire.requestFrom(_address, (uint8_t) 0x01);
  while(Wire.available() < 1) {
    timeout++;
	if(timeout > I2CTIMEOUT) {
	  return(true);
	}
	delay(1);
  } 			// Experimental
  
  *data = I2CREAD();

return(false);
}