void chb_ISR_Handler (void) { U8 dummy, state, intp_src = 0; chb_pcb_t *pcb = chb_get_pcb(); CHB_ENTER_CRIT(); /*Read Interrupt source.*/ CHB_SPI_ENABLE(); /*Send Register address and read register content.*/ dummy = chb_xfer_byte(IRQ_STATUS | CHB_SPI_CMD_RR); intp_src = chb_xfer_byte(0); CHB_SPI_DISABLE(); while (intp_src) { /*Handle the incomming interrupt. Prioritized.*/ if ((intp_src & CHB_IRQ_RX_START_MASK)) { intp_src &= ~CHB_IRQ_RX_START_MASK; } else if (intp_src & CHB_IRQ_TRX_END_MASK) { state = chb_get_state(); if ((state == RX_ON) || (state == RX_AACK_ON) || (state == BUSY_RX_AACK)) { // get the ed measurement pcb->ed = chb_reg_read(PHY_ED_LEVEL); // get the crc pcb->crc = (chb_reg_read(PHY_RSSI) & (1<<7)) ? 1 : 0; // if the crc is not valid, then do not read the frame and set the rx flag if (pcb->crc) { // get the data chb_frame_read(); pcb->rcvd_xfers++; pcb->data_rcv = true; } } else { pcb->tx_end = true; } intp_src &= ~CHB_IRQ_TRX_END_MASK; while (chb_set_state(RX_STATE) != RADIO_SUCCESS); } else if (intp_src & CHB_IRQ_TRX_UR_MASK) { intp_src &= ~CHB_IRQ_TRX_UR_MASK; pcb->underrun++; } else if (intp_src & CHB_IRQ_PLL_UNLOCK_MASK) { intp_src &= ~CHB_IRQ_PLL_UNLOCK_MASK; } else if (intp_src & CHB_IRQ_PLL_LOCK_MASK) { intp_src &= ~CHB_IRQ_PLL_LOCK_MASK; } else if (intp_src & CHB_IRQ_BAT_LOW_MASK) { intp_src &= ~CHB_IRQ_BAT_LOW_MASK; pcb->battlow++; } else { } } CHB_LEAVE_CRIT(); }
static void chb_irq_handler() { U8 dummy, state, pinval; pcb_t *pcb = chb_get_pcb(); // find out who issued the interrupt intp_src |= chb_reg_read(IRQ_STATUS); while (intp_src) { /*Handle the incomming interrupt. Prioritized.*/ if ((intp_src & CHB_IRQ_RX_START_MASK)) { intp_src &= ~CHB_IRQ_RX_START_MASK; } else if (intp_src & CHB_IRQ_TRX_END_MASK) { state = chb_get_state(); if ((state == RX_ON) || (state == RX_AACK_ON) || (state == BUSY_RX_AACK)) { // get the ed measurement pcb->ed = chb_reg_read(PHY_ED_LEVEL); // get the crc pcb->crc = (chb_reg_read(PHY_RSSI) & (1<<7)) ? 1 : 0; // if the crc is not valid, then do not read the frame and set the rx flag // CHECK COMMENTED OUT FOR PROMISCOUS MODE OPERATION //if (pcb->crc) //{ pcb->data_rcv = true; chb_frame_read(); // get the data pcb->rcvd_xfers++; //} } intp_src &= ~CHB_IRQ_TRX_END_MASK; // THIS IS CHANGED FOR PROMISCOUS MODE (to match above mode setting change): //while (chb_set_state(RX_AACK_ON) != RADIO_SUCCESS); while (chb_set_state(RX_ON) != RADIO_SUCCESS); } else if (intp_src & CHB_IRQ_TRX_UR_MASK) { intp_src &= ~CHB_IRQ_TRX_UR_MASK; pcb->underrun++; } else if (intp_src & CHB_IRQ_PLL_UNLOCK_MASK) { intp_src &= ~CHB_IRQ_PLL_UNLOCK_MASK; } else if (intp_src & CHB_IRQ_PLL_LOCK_MASK) { intp_src &= ~CHB_IRQ_PLL_LOCK_MASK; } else if (intp_src & CHB_IRQ_BAT_LOW_MASK) { intp_src &= ~CHB_IRQ_BAT_LOW_MASK; pcb->battlow++; } else { } } rx_intp_flag = false; CHB_IRQ_ENABLE(); }