⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 syslib.c

📁 ads826x bsp 重要代码:sysLib.c - Motorola ads 8260 board system-dependent library
💻 C
📖 第 1 页 / 共 4 页
字号:
    NSDELAY (200);    /* now we toggle the clock and delay again */    *M8260_IOP_PCDAT(immrVal) &= ~(0x00200000);	/* ~(10) */    NSDELAY (200);    return (OK);    } /**************************************************************************** sysFccMiiBitRd - read one bit from the MII interface** This routine reads one bit from the MDIO line of a MII* interface. The MDC line is asserted for a while, and then negated.** SEE ALSO: sysFccMiiBitWr()** RETURNS: OK, or ERROR.*/STATUS sysFccMiiBitRd    (    UINT32      immrVal,      	/* base address of the on-chip RAM */    UINT8	fccNum,		/* FCC being used */    INT8 *      bitVal          /* the bit being read */    )    {    /*      * we create the timing reference for transfer of info on the MDIO line      * MDIO is mapped on PC9, MDC on PC10. We can read data on MDIO after     * at least 400 nsec.     */    *M8260_IOP_PCPAR(immrVal) &= ~(0x00600000);	/* ~(10|9) */    *M8260_IOP_PCDIR(immrVal) &= ~(0x00400000);	/* ~(9) */    *M8260_IOP_PCDIR(immrVal) |= (0x00200000);	/* (10) */    *M8260_IOP_PCDAT(immrVal) |= (0x00200000);	/* (10) */    /* delay about 200 nsec. */    NSDELAY (200);    /* now we toggle the clock and delay again */    *M8260_IOP_PCDAT(immrVal) &= ~(0x00200000);	/* (10) */    NSDELAY (200);    /* we can now read the MDIO data on PC9 */    *bitVal = (*M8260_IOP_PCDAT(immrVal) & (0x00400000)) >> 22;     return (OK);    } /**************************************************************************** sysMiiOptRegsHandle - handle some MII optional registers** This routine handles some MII optional registers in the PHY * described by <pPhyInfo>.** In the case of the ads8260, the PHY that implements the physical layer * for the FCC is an LXT970. The default values for some of its chip-specific* registers seem to be uncompatible with 100Base-T operations. This routine * is expected to perform any PHY-specific functions required to bring the* PHY itself to a state where 100Base-T operations may be possible.** SEE ALSO: miiLib, motFccEnd.** RETURNS: OK, or ERROR.*/STATUS sysMiiOptRegsHandle    (    PHY_INFO	* pPhyInfo		/* PHY control structure pointer */    )    {    int		retVal;			/* a convenience */    /*      * the LXT970 on the ads8260 comes up with the scrambler     * function disabled, so that it will not work in 100Base-T mode.     * write 0 to the configuration register (address 0x13)      * to enable the scrambler function      */    MII_WRITE (pPhyInfo->phyAddr, 0x13, 0x0, retVal);    if (retVal != OK)        return (ERROR);    return (OK);    }#endif	/* INCLUDE_MOTFCCEND *//**************************************************************************** sysFlashLED - flash one of the signal lamps** This routine will flash the indicated signal lamp for about 1/4 second** SEE ALSO:** RETURNS: NA*/void sysFlashLED    (    int LED	/* bitmap of LED to flash */    )    {    sysControlLED(LED, BCSR0_LED_ON);    taskDelay(15);    sysControlLED(LED, BCSR0_LED_OFF);    }/**************************************************************************** sysControlLED - control one of the signal lamps** This routine will turn the indicated signal lamp on or off, as* requested** SEE ALSO:** RETURNS: NA*/void sysControlLED    (    int LED, 	/* bitmap of LED to control */    int on	/* if TRUE turn LED ON; otherwise, turn LED OFF */    )    {    CACHE_PIPE_FLUSH();			/* always before first read */    if (on)	*(UINT32 *)BCSR0 &= ~LED; /* clearing bit turns LED on */    else	*(UINT32 *)BCSR0 |= LED; /* setting bit turns LED off */    }#ifdef INCLUDE_PCI 	/* board level PCI routines *//********************************************************************************* sysPciSpecialCycle - generate a special cycle with a message** This routine generates a special cycle with a message.** NOMANUAL** RETURNS: OK*/STATUS sysPciSpecialCycle    (    int		busNo,    UINT32	message    )    {    int deviceNo	= 0x0000001f;    int funcNo		= 0x00000007;    PCI_OUT_LONG (sysPciConfAddr,                  pciConfigBdfPack (busNo, deviceNo, funcNo) |                  0x80000000);    PCI_OUT_LONG (sysPciConfData, message);    return (OK);    }/********************************************************************************* sysPciConfigRead - read from the PCI configuration space** This routine reads either a byte, word or a long word specified by* the argument <width>, from the PCI configuration space* This routine works around a problem in the hardware which hangs* PCI bus if device no 12 is accessed from the PCI configuration space.** NOMANUAL** RETURNS: OK, or ERROR if this library is not initialized*/STATUS sysPciConfigRead    (    int	busNo,    /* bus number */    int	deviceNo, /* device number */    int	funcNo,	  /* function number */    int	offset,	  /* offset into the configuration space */    int width,	  /* width to be read */    void * pData /* data read from the offset */    )    {    UINT8  retValByte = 0;    UINT16 retValWord = 0;    UINT32 retValLong = 0;    STATUS retStat = ERROR;    if ((busNo == 0) && (deviceNo == 12))        return (ERROR);    switch (width)        {        case 1:	/* byte */            PCI_OUT_LONG (sysPciConfAddr,                          pciConfigBdfPack (busNo, deviceNo, funcNo) |                          (offset & 0xfc) | 0x80000000);                        retValByte = PCI_IN_BYTE (sysPciConfData + (offset & 0x3));            *((UINT8 *)pData) = retValByte;	    retStat = OK;            break;        case 2: /* word */            PCI_OUT_LONG (sysPciConfAddr,                          pciConfigBdfPack (busNo, deviceNo, funcNo) |                          (offset & 0xfc) | 0x80000000);	    retValWord = PCI_IN_WORD (sysPciConfData + (offset & 0x2));            *((UINT16 *)pData) = retValWord;	    retStat = OK;	    break;        case 4: /* long */	    PCI_OUT_LONG (sysPciConfAddr,		          pciConfigBdfPack (busNo, deviceNo, funcNo) |		          (offset & 0xfc) | 0x80000000);	    retValLong = PCI_IN_LONG (sysPciConfData);            *((UINT32 *)pData) = retValLong;	    retStat = OK;            break;        default:            retStat = ERROR;            break;        }    return (retStat);    }/********************************************************************************* sysPciConfigWrite - write to the PCI configuration space** This routine writes either a byte, word or a long word specified by* the argument <width>, to the PCI configuration space* This routine works around a problem in the hardware which hangs* PCI bus if device no 12 is accessed from the PCI configuration space.** NOMANUAL** RETURNS: OK, or ERROR if this library is not initialized*/STATUS sysPciConfigWrite    (    int	busNo,    /* bus number */    int	deviceNo, /* device number */    int	funcNo,	  /* function number */    int	offset,	  /* offset into the configuration space */    int width,	  /* width to write */    ULONG data	  /* data to write */    )    {    if ((busNo == 0) && (deviceNo == 12))        return (ERROR);    switch (width)        {        case 1:	/* byte */            PCI_OUT_LONG (sysPciConfAddr,                          pciConfigBdfPack (busNo, deviceNo, funcNo) |                          (offset & 0xfc) | 0x80000000);	    PCI_OUT_BYTE ((sysPciConfData + (offset & 0x3)), data);            break;        case 2: /* word */            PCI_OUT_LONG (sysPciConfAddr,                          pciConfigBdfPack (busNo, deviceNo, funcNo) |                          (offset & 0xfc) | 0x80000000);	    PCI_OUT_WORD ((sysPciConfData + (offset & 0x2)), data);	    break;        case 4: /* long */	    PCI_OUT_LONG (sysPciConfAddr,		          pciConfigBdfPack (busNo, deviceNo, funcNo) |		          (offset & 0xfc) | 0x80000000);	    PCI_OUT_LONG (sysPciConfData, data);            break;        default:            return (ERROR);                    }    return (OK);    }#endif /* INCLUDE_PCI *//******************************************************************************** sysUsDelay - delay at least the specified amount of time (in microseconds)** This routine will delay for at least the specified amount of time using the* lower 32 bit "word" of the Time Base register as the timer.  The accuracy of* the delay increases as the requested delay increases due to a certain amount* of overhead.  As an example, a requested delay of 10 microseconds is* accurate within approximately twenty percent, and a requested delay of 100* microseconds is accurate within approximately two percent.** NOTE:  This routine will not relinquish the CPU; it is meant to perform a* busy loop delay.  The minimum delay that this routine will provide is* approximately 10 microseconds.  The maximum delay is approximately the* size of UINT32; however, there is no roll-over compensation for the total* delay time, so it is necessary to back off two times the system tick rate* from the maximum.** RETURNS: N/A*/void sysUsDelay    (    UINT32    delay        /* length of time in microsec to delay */    )    {    volatile int loop;    volatile UINT32 decValue;      for(loop=0;loop<(delay/10);loop++)	decValue = vxDecGet();    }/********************************************************************* * * sysMsDelay - Uses the decrementer to calculate time elapsed * * void sysMsDelay *   ( *   UINT        delay              * length of time in MS to delay * *   ) * * RETURNS : NONE * */void sysMsDelay    (    UINT        delay                   /* length of time in MS to delay */    )    {    register UINT oldval;               /* decrementer value */    register UINT newval;               /* decrementer value */    register UINT totalDelta;           /* Dec. delta for entire delay period */    register UINT decElapsed;           /* cumulative decrementer ticks */    /*     * Calculate delta of decrementer ticks for desired elapsed time.     * The macro DEC_CLOCK_FREQ MUST REFLECT THE PROPER 6xx BUS SPEED.     */    totalDelta = ((DEC_CLOCK_FREQ / 4) / 1000) * delay;    /*     * Now keep grabbing decrementer value and incrementing "decElapsed" until     * we hit the desired delay value.  Compensate for the fact that we may     * read the decrementer at 0xffffffff before the interrupt service     * routine has a chance to set in the rollover value.     */    decElapsed = 0;    oldval = vxDecGet ();    while (decElapsed < totalDelta)        {        newval = vxDecGet ();        if ( DELTA(oldval,newval) < 1000 )            decElapsed += DELTA(oldval,newval);  /* no rollover */        else            if (newval > oldval)                decElapsed += abs((int)oldval);  /* rollover */        oldval = newval;        }    }/********************************************************************* * * sysDelay - Fixed 1ms delay. Just calls sysMsDelay * * sysDelay(void) * * RETURNS : NONE * */void sysDelay (void)    {    sysMsDelay (1);    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -