- #ifdef I2C_TIMEOUT
- uint16_t timeout_timer = timer_read();
- while( !(TWCR & (1<<TWINT)) ) {
- if ((timer_read() - timeout_timer) > I2C_TIMEOUT) {
- return 2; // should make these codes standard
- }
+ uint16_t timeout_timer = timer_read();
+ while( !(TWCR & (1<<TWINT)) ) {
+ if (timeout && (timer_read() - timeout_timer) > timeout) {
+ return I2C_STATUS_TIMEOUT;