AllJoyn/Samples/BACnetAdapter/bacnet-stack-0.8.2/ports/xplained/ASF/xmega/drivers/twi/twis.c
void TWI_SlaveInterruptHandler(TWI_Slave_t * twi)
{
    uint8_t currentStatus = twi->interface->SLAVE.STATUS;

    /* If bus error. */
    if (currentStatus & TWI_SLAVE_BUSERR_bm) {
        twi->bytesReceived = 0;
        twi->bytesSent = 0;
        twi->result = TWIS_RESULT_BUS_ERROR;
        twi->status = TWIS_STATUS_READY;
    }

    /* If transmit collision. */
    else if (currentStatus & TWI_SLAVE_COLL_bm) {
        twi->bytesReceived = 0;
        twi->bytesSent = 0;
        twi->result = TWIS_RESULT_TRANSMIT_COLLISION;
        twi->status = TWIS_STATUS_READY;
    }

    /* If address match. */
    else if ((currentStatus & TWI_SLAVE_APIF_bm) &&
        (currentStatus & TWI_SLAVE_AP_bm)) {

        TWI_SlaveAddressMatchHandler(twi);
    }

    /* If stop (only enabled through slave read transaction). */
    else if (currentStatus & TWI_SLAVE_APIF_bm) {
        TWI_SlaveStopHandler(twi);
    }

    /* If data interrupt. */
    else if (currentStatus & TWI_SLAVE_DIF_bm) {
        TWI_SlaveDataHandler(twi);
    }

    /* If unexpected state. */
    else {
        TWI_SlaveTransactionFinished(twi, TWIS_RESULT_FAIL);
    }
}
/*! \brief Common TWI slave interrupt service routine.
 *
 *  Handles all TWI transactions and responses to address match, data reception,
 *  data transmission, bus error and data collision.
 *
 *  \param twi The TWI_Slave_t struct instance.
 */
\brief Common TWI slave interrupt service routine.
Handles all TWI transactions and responses to address match, data reception,
data transmission, bus error and data collision.

\param twi The TWI_Slave_t struct instance.
\ brief Common TWI slave interrupt service routine . Handles all TWI transactions and responses to address match data reception data transmission bus error and data collision . \ param twi The TWI_Slave_t struct instance .
void TWI_SlaveInterruptHandler(TWI_Slave_t * twi)
{
    uint8_t currentStatus = twi->interface->SLAVE.STATUS;
    if (currentStatus & TWI_SLAVE_BUSERR_bm) {
        twi->bytesReceived = 0;
        twi->bytesSent = 0;
        twi->result = TWIS_RESULT_BUS_ERROR;
        twi->status = TWIS_STATUS_READY;
    }
    else if (currentStatus & TWI_SLAVE_COLL_bm) {
        twi->bytesReceived = 0;
        twi->bytesSent = 0;
        twi->result = TWIS_RESULT_TRANSMIT_COLLISION;
        twi->status = TWIS_STATUS_READY;
    }
    else if ((currentStatus & TWI_SLAVE_APIF_bm) &&
        (currentStatus & TWI_SLAVE_AP_bm)) {
        TWI_SlaveAddressMatchHandler(twi);
    }
    else if (currentStatus & TWI_SLAVE_APIF_bm) {
        TWI_SlaveStopHandler(twi);
    }
    else if (currentStatus & TWI_SLAVE_DIF_bm) {
        TWI_SlaveDataHandler(twi);
    }
    else {
        TWI_SlaveTransactionFinished(twi, TWIS_RESULT_FAIL);
    }
}
void TWI_SlaveInterruptHandler ( TWI_Slave_t * twi ) { uint8_t currentStatus = twi -> interface -> SLAVE . STATUS ; if ( currentStatus & TWI_SLAVE_BUSERR_bm ) { twi -> bytesReceived = 0 ; twi -> bytesSent = 0 ; twi -> result = TWIS_RESULT_BUS_ERROR ; twi -> status = TWIS_STATUS_READY ; } else if ( currentStatus & TWI_SLAVE_COLL_bm ) { twi -> bytesReceived = 0 ; twi -> bytesSent = 0 ; twi -> result = TWIS_RESULT_TRANSMIT_COLLISION ; twi -> status = TWIS_STATUS_READY ; } else if ( ( currentStatus & TWI_SLAVE_APIF_bm ) && ( currentStatus & TWI_SLAVE_AP_bm ) ) { TWI_SlaveAddressMatchHandler ( twi ) ; } else if ( currentStatus & TWI_SLAVE_APIF_bm ) { TWI_SlaveStopHandler ( twi ) ; } else if ( currentStatus & TWI_SLAVE_DIF_bm ) { TWI_SlaveDataHandler ( twi ) ; } else { TWI_SlaveTransactionFinished ( twi , TWIS_RESULT_FAIL ) ; } }
\brief Common TWI slave interrupt service routine.
\ brief Common TWI slave interrupt service routine .
/* If bus error. */ /* If transmit collision. */ /* If address match. */ /* If stop (only enabled through slave read transaction). */ /* If data interrupt. */ /* If unexpected state. */