/* Polls if an available TX descriptor is ready. Can be used to determine if the low level transmit function will block.  */
s32_t lpc_tx_ready(struct netif *netif)
/* Polls if an available TX descriptor is ready. Can be used to determine if the low level transmit function will block.  */
s32_t lpc_tx_ready(struct netif *netif)
{
    s32_t fb;
    u32_t idx, cidx;
    cidx = LPC_EMAC->TxConsumeIndex;
    idx = LPC_EMAC->TxProduceIndex;
    if (idx == cidx)
        fb = LPC_NUM_BUFF_TXDESCS;
    else if (cidx > idx)
        fb = (LPC_NUM_BUFF_TXDESCS - 1) -
            ((idx + LPC_NUM_BUFF_TXDESCS) - cidx);
    else
        fb = (LPC_NUM_BUFF_TXDESCS - 1) - (cidx - idx);
    return fb;
}