soc/picorv32/test/badger_lwip/liblwip/badgerif.c
/**
 * Should allocate a pbuf and transfer the bytes of the incoming
 * packet from the interface into the pbuf.
 *
 * @param netif the lwip network interface structure for this ethernetif
 * @return a pbuf filled with the received packet (including MAC header)
 *         NULL on memory error
 */
Should allocate a pbuf and transfer the bytes of the incoming
packet from the interface into the pbuf.

@param netif the lwip network interface structure for this ethernetif
@return a pbuf filled with the received packet (including MAC header)
NULL on memory error
Should allocate a pbuf and transfer the bytes of the incoming packet from the interface into the pbuf . @param netif the lwip network interface structure for this ethernetif @return a pbuf filled with the received packet ( including MAC header ) NULL on memory error
void badger_input(struct netif *netif)
{
    struct pbuf *p, *q;
    if(!GET_SFR1(BASE_BADGER_SFR, 0, BIT_BADGER_RX_NEW_DATA))
        return;
    SET_SFR1(BASE_BADGER_SFR, 0, BIT_BADGER_RX_BUF_SWAP, 0);
    unsigned rx_len = badger_rx_len();
    uint8_t *buf_rx = (uint8_t *)(BASE_BADGER_RX + BADGE_LEN);
    LINK_STATS_INC(link.recv);
    p = pbuf_alloc(PBUF_RAW, rx_len, PBUF_POOL);
    q = p;
    while (q) {
        memcpy(q->payload, buf_rx, q->len);
        buf_rx += q->len;
        if(q->tot_len != q->len)
            q = q->next;
        else
            q = NULL;
    }
    if (p){
        if (netif->input(p, netif) != ERR_OK) {
            printf("Error inputting packet!!!\n");
            pbuf_free(p);
            p = NULL;
        };
    }
}
void badger_input ( struct netif * netif ) { struct pbuf * p , * q ; if ( ! GET_SFR1 ( BASE_BADGER_SFR , 0 , BIT_BADGER_RX_NEW_DATA ) ) return ; SET_SFR1 ( BASE_BADGER_SFR , 0 , BIT_BADGER_RX_BUF_SWAP , 0 ) ; unsigned rx_len = badger_rx_len ( ) ; uint8_t * buf_rx = ( uint8_t * ) ( BASE_BADGER_RX + BADGE_LEN ) ; LINK_STATS_INC ( link . recv ) ; p = pbuf_alloc ( PBUF_RAW , rx_len , PBUF_POOL ) ; q = p ; while ( q ) { memcpy ( q -> payload , buf_rx , q -> len ) ; buf_rx += q -> len ; if ( q -> tot_len != q -> len ) q = q -> next ; else q = NULL ; } if ( p ) { if ( netif -> input ( p , netif ) != ERR_OK ) { printf ( " \n " ) ; pbuf_free ( p ) ; p = NULL ; } ; } }
Should allocate a pbuf and transfer the bytes of the incoming
 packet from the interface into the pbuf.
Should allocate a pbuf and transfer the bytes of the incoming packet from the interface into the pbuf .
// check for new data // swap buffers, make new data visible // get a linked list of lwip buffers to copy data into