/*************************************************************************
Terminates the data transfer and releases the I2C bus
*************************************************************************/
void twi_stop(void)
{
/* send stop condition */
TWCR = (1<<TWINT)| (1<<TWEN) | (1<<TWSTO);
// wait until stop condition is executed and bus released
while(TWCR &(1<<TWSTO));
}/* twi_stop */