src/ENC28J60.c
static int16_t enc28j60_get_rx_free_space(const struct enc28j60_dev *priv) {
    uint8_t epktcnt;
    uint16_t erxwrpt, erxrdpt, erxst, erxnd;
    int16_t result;

    epktcnt = rcr(priv, ENC28J60_EPKTCNT);
    if (epktcnt == 255)
        return -1;
    
    while (true) {
        erxwrpt = (uint16_t)rcr(priv, ENC28J60_ERXWRPTL);
        erxwrpt |= (uint16_t)rcr(priv, ENC28J60_ERXWRPTH) << 8;
        if (epktcnt == rcr(priv, ENC28J60_EPKTCNT))
            break;
    }

    erxrdpt = (uint16_t)rcr(priv, ENC28J60_ERXRDPTL);
    erxrdpt |= (uint16_t)rcr(priv, ENC28J60_ERXRDPTH) << 8;

    erxst = (uint16_t)rcr(priv, ENC28J60_ERXSTL);
    erxst |= (uint16_t)rcr(priv, ENC28J60_ERXSTH) << 8;

    erxnd = (uint16_t)rcr(priv, ENC28J60_ERXNDL);
    erxnd |= (uint16_t)rcr(priv, ENC28J60_ERXNDH) << 8;

    if (erxwrpt > erxrdpt)
        result = (erxnd - erxst) - (erxwrpt - erxrdpt);
    else if (erxwrpt == erxrdpt)
        result = erxnd - erxst;
    else
        result = erxrdpt - erxwrpt - 1;

    return result;
}
/*!
 * @brief Get size of free space of RX buffer
 * @return Free space in the RX buffer
 */
@brief Get size of free space of RX buffer
@return Free space in the RX buffer
@brief Get size of free space of RX buffer @return Free space in the RX buffer
static int16_t enc28j60_get_rx_free_space(const struct enc28j60_dev *priv) {
    uint8_t epktcnt;
    uint16_t erxwrpt, erxrdpt, erxst, erxnd;
    int16_t result;
    epktcnt = rcr(priv, ENC28J60_EPKTCNT);
    if (epktcnt == 255)
        return -1;
    while (true) {
        erxwrpt = (uint16_t)rcr(priv, ENC28J60_ERXWRPTL);
        erxwrpt |= (uint16_t)rcr(priv, ENC28J60_ERXWRPTH) << 8;
        if (epktcnt == rcr(priv, ENC28J60_EPKTCNT))
            break;
    }
    erxrdpt = (uint16_t)rcr(priv, ENC28J60_ERXRDPTL);
    erxrdpt |= (uint16_t)rcr(priv, ENC28J60_ERXRDPTH) << 8;
    erxst = (uint16_t)rcr(priv, ENC28J60_ERXSTL);
    erxst |= (uint16_t)rcr(priv, ENC28J60_ERXSTH) << 8;
    erxnd = (uint16_t)rcr(priv, ENC28J60_ERXNDL);
    erxnd |= (uint16_t)rcr(priv, ENC28J60_ERXNDH) << 8;
    if (erxwrpt > erxrdpt)
        result = (erxnd - erxst) - (erxwrpt - erxrdpt);
    else if (erxwrpt == erxrdpt)
        result = erxnd - erxst;
    else
        result = erxrdpt - erxwrpt - 1;
    return result;
}
static int16_t enc28j60_get_rx_free_space ( const struct enc28j60_dev * priv ) { uint8_t epktcnt ; uint16_t erxwrpt , erxrdpt , erxst , erxnd ; int16_t result ; epktcnt = rcr ( priv , ENC28J60_EPKTCNT ) ; if ( epktcnt == 255 ) return -1 ; while ( true ) { erxwrpt = ( uint16_t ) rcr ( priv , ENC28J60_ERXWRPTL ) ; erxwrpt |= ( uint16_t ) rcr ( priv , ENC28J60_ERXWRPTH ) << 8 ; if ( epktcnt == rcr ( priv , ENC28J60_EPKTCNT ) ) break ; } erxrdpt = ( uint16_t ) rcr ( priv , ENC28J60_ERXRDPTL ) ; erxrdpt |= ( uint16_t ) rcr ( priv , ENC28J60_ERXRDPTH ) << 8 ; erxst = ( uint16_t ) rcr ( priv , ENC28J60_ERXSTL ) ; erxst |= ( uint16_t ) rcr ( priv , ENC28J60_ERXSTH ) << 8 ; erxnd = ( uint16_t ) rcr ( priv , ENC28J60_ERXNDL ) ; erxnd |= ( uint16_t ) rcr ( priv , ENC28J60_ERXNDH ) << 8 ; if ( erxwrpt > erxrdpt ) result = ( erxnd - erxst ) - ( erxwrpt - erxrdpt ) ; else if ( erxwrpt == erxrdpt ) result = erxnd - erxst ; else result = erxrdpt - erxwrpt - 1 ; return result ; }
@brief Get size of free space of RX buffer
 @return Free space in the RX buffer
@brief Get size of free space of RX buffer @return Free space in the RX buffer