Add support for repeated starts in slave mode

From the data sheet TXCOMP is only set after a stop or repeated start
and address change, but EOSACC is set for a stop or repeated start when
the address remains the same. This change removes the check for TXCOMP
when not idle, to support repeated starts for both RX and TX.
This commit is contained in:
Sandeep Mistry 2015-10-01 15:53:15 -04:00
parent f5c1084f5f
commit 77179d78d0
1 changed files with 17 additions and 19 deletions

View File

@ -321,8 +321,7 @@ void TwoWire::onService(void) {
} }
} }
if (status != SLAVE_IDLE) { if (status != SLAVE_IDLE && TWI_STATUS_EOSACC(sr)) {
if (TWI_STATUS_TXCOMP(sr) && TWI_STATUS_EOSACC(sr)) {
if (status == SLAVE_RECV && onReceiveCallback) { if (status == SLAVE_RECV && onReceiveCallback) {
// Copy data into rxBuffer // Copy data into rxBuffer
// (allows to receive another packet while the // (allows to receive another packet while the
@ -342,7 +341,6 @@ void TwoWire::onService(void) {
| TWI_IDR_EOSACC | TWI_IDR_SCL_WS | TWI_IER_TXCOMP); | TWI_IDR_EOSACC | TWI_IDR_SCL_WS | TWI_IER_TXCOMP);
status = SLAVE_IDLE; status = SLAVE_IDLE;
} }
}
if (status == SLAVE_RECV) { if (status == SLAVE_RECV) {
if (TWI_STATUS_RXRDY(sr)) { if (TWI_STATUS_RXRDY(sr)) {