| 1137 | } |
| 1138 | |
| 1139 | void twi_stop(void) { |
| 1140 | // send stop condition |
| 1141 | TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT) | _BV(TWSTO); |
| 1142 | |
| 1143 | // wait for stop condition to be executed on bus |
| 1144 | // TWINT is not set after a stop condition! |
| 1145 | while (TWCR & _BV(TWSTO)) { |
| 1146 | continue; |
| 1147 | } |
| 1148 | |
| 1149 | // update twi state |
| 1150 | twi_state = TWI_READY; |
| 1151 | } |
| 1152 | |
| 1153 | void twi_releaseBus(void) { |
| 1154 | // release bus |