AllJoyn/Samples/BACnetAdapter/bacnet-stack-0.8.2/ports/xplained/ASF/xmega/drivers/twi/twim.c
static void twim_interrupt_handler(void)
{
    uint8_t const master_status = transfer.bus->MASTER.STATUS;

    if (master_status & TWI_MASTER_ARBLOST_bm) {

        transfer.bus->MASTER.STATUS = master_status | TWI_MASTER_ARBLOST_bm;
        transfer.bus->MASTER.CTRLC = TWI_MASTER_CMD_STOP_gc;
        transfer.status = ERR_BUSY;

    } else if ((master_status & TWI_MASTER_BUSERR_bm) ||
        (master_status & TWI_MASTER_RXACK_bm)) {

        transfer.bus->MASTER.CTRLC = TWI_MASTER_CMD_STOP_gc;
        transfer.status = ERR_IO_ERROR;

    } else if (master_status & TWI_MASTER_WIF_bm) {

        twim_write_handler();

    } else if (master_status & TWI_MASTER_RIF_bm) {

        twim_read_handler();

    } else {

        transfer.status = ERR_PROTOCOL;
    }
}
/**
 * \internal
 *
 * \brief Common TWI master interrupt service routine.
 *
 *  Check current status and calls the appropriate handler.
 */
\internal
\brief Common TWI master interrupt service routine.

Check current status and calls the appropriate handler.
\ internal \ brief Common TWI master interrupt service routine . Check current status and calls the appropriate handler .
static void twim_interrupt_handler(void)
{
    uint8_t const master_status = transfer.bus->MASTER.STATUS;
    if (master_status & TWI_MASTER_ARBLOST_bm) {
        transfer.bus->MASTER.STATUS = master_status | TWI_MASTER_ARBLOST_bm;
        transfer.bus->MASTER.CTRLC = TWI_MASTER_CMD_STOP_gc;
        transfer.status = ERR_BUSY;
    } else if ((master_status & TWI_MASTER_BUSERR_bm) ||
        (master_status & TWI_MASTER_RXACK_bm)) {
        transfer.bus->MASTER.CTRLC = TWI_MASTER_CMD_STOP_gc;
        transfer.status = ERR_IO_ERROR;
    } else if (master_status & TWI_MASTER_WIF_bm) {
        twim_write_handler();
    } else if (master_status & TWI_MASTER_RIF_bm) {
        twim_read_handler();
    } else {
        transfer.status = ERR_PROTOCOL;
    }
}
static void twim_interrupt_handler ( void ) { uint8_t const master_status = transfer . bus -> MASTER . STATUS ; if ( master_status & TWI_MASTER_ARBLOST_bm ) { transfer . bus -> MASTER . STATUS = master_status | TWI_MASTER_ARBLOST_bm ; transfer . bus -> MASTER . CTRLC = TWI_MASTER_CMD_STOP_gc ; transfer . status = ERR_BUSY ; } else if ( ( master_status & TWI_MASTER_BUSERR_bm ) || ( master_status & TWI_MASTER_RXACK_bm ) ) { transfer . bus -> MASTER . CTRLC = TWI_MASTER_CMD_STOP_gc ; transfer . status = ERR_IO_ERROR ; } else if ( master_status & TWI_MASTER_WIF_bm ) { twim_write_handler ( ) ; } else if ( master_status & TWI_MASTER_RIF_bm ) { twim_read_handler ( ) ; } else { transfer . status = ERR_PROTOCOL ; } }
\internal
 \brief Common TWI master interrupt service routine.
\ internal \ brief Common TWI master interrupt service routine .