static void trxSpiCallback(unsigned int interrupt_code) {

    if(interrupt_code == SPIC_TRANS_SUCCESS) {

        spic1EndTransaction(); // End previous transaction

        if(trx_state == RX_AACK_ON) {
            trxReadBuffer();
            irqCallback(RADIO_RX_SUCCESS);

        } else if(trx_state == TX_ARET_ON) {

            // Packet was successfully transferred to the radio buffer
            // Do something?

        }

    } else if(interrupt_code == SPIC_TRANS_TIMEOUT) {

        // This is indicative of some form of failure!
        spic1Reset();
        irqCallback(RADIO_HW_FAILURE);

    }

}
void trxReset(void) {

    unsigned int i;

    spic1Reset();   // Reset comm
    trxWriteSubReg(SR_TRX_CMD, CMD_TRX_OFF);  // Force to off state

    i = 0;
    while(i < 0xFFF0) {
        if(trxReadSubReg(SR_TRX_STATUS) == TRX_OFF) { break; }
        i++;
    }
    trx_state = TRX_OFF;

}
Beispiel #3
0
// ISR for timeout timer
void __attribute__((interrupt, no_auto_psv)) _T6Interrupt(void) {
    
    // Only one channel busy at a time
    if(port_status[0] == STAT_SPI_BUSY) {
    
        spic1Reset();
        int_handler[0](SPIC_TRANS_TIMEOUT);
        
    } else if (port_status[1] == STAT_SPI_BUSY) {
    
        spic2Reset();
        int_handler[1](SPIC_TRANS_TIMEOUT);
        
    }
        
    _T6IF = 0;

}