Ejemplo n.º 1
0
/**
 *  \brief Disable RX & reset registers and descriptor list
 *  \param pDrv Pointer to GMAC Driver instance.
 */
static void GMACD_ResetRx(sGmacd *pDrv, gmacQueList_t queIdx )
{
    Gmac    *pHw = pDrv->pHw;
    uint8_t *pRxBuffer = pDrv->queueList[queIdx].pRxBuffer;
    sGmacRxDescriptor *pRd = pDrv->queueList[queIdx].pRxD;

    uint32_t Index;
    uint32_t Address;

    /* Disable RX */
    GMAC_ReceiveEnable(pHw, 0);

    /* Setup the RX descriptors. */
    pDrv->queueList[queIdx].wRxI = 0;
    for(Index = 0; Index < pDrv->queueList[queIdx].wRxListSize; Index++) {
        Address = (uint32_t)(&(pRxBuffer[Index *
                                         pDrv->queueList[queIdx].wRxBufferSize]));
        /* Remove GMAC_RXD_bmOWNERSHIP and GMAC_RXD_bmWRAP */
        pRd[Index].addr.val = Address & GMAC_ADDRESS_MASK;
        pRd[Index].status.val = 0;
    }

    pRd[pDrv->queueList[queIdx].wRxListSize - 1].addr.val |= GMAC_RX_WRAP_BIT;

    /* Receive Buffer Queue Pointer Register */
    GMAC_SetRxQueue(pHw, (uint32_t)pRd, queIdx);
}
Ejemplo n.º 2
0
Archivo: gmac.c Proyecto: djyos/djyos
static void __MacBdRcvInit(u32 qindex)
{
    tagQueue *queue;
    volatile tagRcvBD *rcvbd;
    u32       i;
    u32       address;
    u32       status;

    queue = &gMacDriver.queueList[qindex];
    //initialize the receive bd
    status = 0;
    for(i =0;i < queue->rcvbdlen;i++)
    {
        rcvbd = queue->rcvbdtab + i;
        address = (u32)(queue->rcvmem + queue->rcvbuflen*i);
        rcvbd->addr.val = address&GMAC_ADDRESS_MASK;
        rcvbd->status.val = status;
    }
    rcvbd->addr.val |= GMAC_RX_WRAP_BIT;   //the last one must be wrap
    queue->rcvbdcur = 0;

    //set the address to the register
    GMAC_SetRxQueue(gMacDriver.pHw, (u32)queue->rcvbdtab, qindex);
    return;
}