resources/libtiny/USIWire.cpp
// must be called in:
// slave tx event callback
// or after beginTransmission(address)
must be called in:
slave tx event callback
or after beginTransmission(address)
must be called in : slave tx event callback or after beginTransmission ( address )
size_t TwoWire::write(uint8_t data) {
  if (transmitting) { 
    if (BufferLength >= TWI_BUFFER_SIZE) {
      return 0;
    }
    Buffer[BufferIndex] = data;
    ++BufferIndex;
    BufferLength = BufferIndex;
  } else { 
    if (!USI_TWI_Space_In_Transmission_Buffer()) {
      return 0;
    }
    USI_TWI_Transmit_Byte(data);
  }
  return 1;
}
size_t TwoWire :: write ( uint8_t data ) { if ( transmitting ) { if ( BufferLength >= TWI_BUFFER_SIZE ) { return 0 ; } Buffer [ BufferIndex ] = data ; ++ BufferIndex ; BufferLength = BufferIndex ; } else { if ( ! USI_TWI_Space_In_Transmission_Buffer ( ) ) { return 0 ; } USI_TWI_Transmit_Byte ( data ) ; } return 1 ; }
must be called in:
slave tx event callback
or after beginTransmission(address)
must be called in : slave tx event callback or after beginTransmission ( address )
// in master transmitter mode // don't bother if buffer is full // put byte in tx buffer // update amount in buffer // in slave send mode // don't bother if buffer is full // reply to master