RFLPC_IRQ_HANDLER _eth_irq_handler() { rfEthDescriptor *d; rfEthRxStatus *s; int i = 0; if (rflpc_eth_irq_get_status() & RFLPC_ETH_IRQ_EN_RX_DONE) /* packet received */ { /* Process all pending packets, but limit to the number of descriptor * to avoid beeing stuck in handler because of packet flood */ while (rflpc_eth_get_current_rx_packet_descriptor(&d, &s) && i++ < TX_DESCRIPTORS) { if (mbed_process_input(d->packet, rflpc_eth_get_packet_size(s->status_info)) == ETH_INPUT_FREE_PACKET) rflpc_eth_done_process_rx_packet(); else break; } } if (rflpc_eth_irq_get_status() & RFLPC_ETH_IRQ_EN_TX_DONE) mbed_eth_garbage_tx_buffers(); rflpc_eth_irq_clear(rflpc_eth_irq_get_status()); }
int16_t mbed_eth_get_byte() { uint8_t byte; if (current_rx_frame == NULL) { MBED_DEBUG("SMEWS Required a byte but none available!\r\n"); return -1; } byte = current_rx_frame[current_rx_frame_idx++]; ++byte_count; if (current_rx_frame_idx >= current_rx_frame_size) { current_rx_frame = NULL; current_rx_frame_size = 0; current_rx_frame_idx = 0; rflpc_eth_done_process_rx_packet(); byte_count = 0; if (rflpc_eth_rx_available()) /* If packet have been received but not yet handled, force IRQ generation */ rflpc_eth_irq_trigger(RFLPC_ETH_IRQ_EN_RX_DONE); } return byte; }