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

📄 net_bsp.c

📁 嵌入式的tcpip协议栈
💻 C
📖 第 1 页 / 共 2 页
字号:
/*
*********************************************************************************************************
*                                              uC/TCP-IP
*                                      The Embedded TCP/IP Suite
*
*                          (c) Copyright 2003-2005; Micrium, Inc.; Weston, FL
*
*                   All rights reserved.  Protected by international copyright laws.
*                   Knowledge of the source code may not be used to write a similar
*                   product.  This file may only be used in accordance with a license
*                   and should not be redistributed in any way.
*********************************************************************************************************
*/

/*
*********************************************************************************************************
*
*                                NET BOARD SUPPORT PACKAGE (BSP) FUNCTIONS
*
*                                             NXP LPC2468
*                                                on the
*                                  Embedded Artists LPC2468 OEM Board
*
* Filename      : net_bsp.h
* Programmer    : Brian Nagel
* Version       : 1.0
* Date          : 11/27/2006
*********************************************************************************************************
*/

#define  NET_BSP_MODULE

/*
*********************************************************************************************************
*                                            INCLUDE FILES
*********************************************************************************************************
*/

#include  <includes.h>
#include  <net.h>
#include  <net_nic.h>
#include  <net_phy.h>
#include  <net_phy_def.h>

/*
*********************************************************************************************************
*                                            LOCAL DEFINES
*********************************************************************************************************
*/

/*
*********************************************************************************************************
*                                            LOCAL VARIABLES
*********************************************************************************************************
*/

/*
*********************************************************************************************************
*                                            PROTOTYPES
*********************************************************************************************************
*/

/*
*********************************************************************************************************
*********************************************************************************************************
*                                  NETWORK INTERFACE CARD FUNCTIONS
*********************************************************************************************************
*********************************************************************************************************
*/

/*
*********************************************************************************************************
*                                            NetNIC_LinkUp()
*
* Description : Message from NIC that the ethernet link is up.
*
* Argument(s) : none.
*
* Return(s)   : none.
*
* Caller(s)   : none.
*
* Note(s)     : WARNING: Called in interruption context most of the time.
*********************************************************************************************************
*/

void  NetNIC_LinkUp (void)
{
    CPU_INT32U  link_speed;
    CPU_INT32U  link_duplex;


    link_speed              =   NetNIC_PhyLinkSpeed();                  /* Read the PHY's current link speed                    */
    link_duplex             =   NetNIC_PhyLinkDuplex();                 /* Read the PHY's current link duplex mode              */

    if (link_speed == NET_PHY_SPD_0 || link_duplex == NET_PHY_DUPLEX_UNKNOWN) {

        NetNIC_LinkChange(NET_PHY_SPD_0, NET_PHY_DUPLEX_UNKNOWN);       /* Inform the EMAC about the current PHY settings       */

    } else {

        NetNIC_LinkChange(link_speed,    link_duplex);                  /* Inform the EMAC about the current PHY settings       */
    }
}


/*
*********************************************************************************************************
*                                           NetNIC_LinkDown()
*
* Description : Message from NIC that the ethernet link is down.
*
* Argument(s) : none.
*
* Return(s)   : none.
*
* Caller(s)   : none.
*
* Note(s)     : WARNING: Called in interruption context most of the time.
*********************************************************************************************************
*/

void  NetNIC_LinkDown (void)
{
    CPU_INT32U  link_speed;
    CPU_INT32U  link_duplex;


    link_speed              =   NetNIC_PhyLinkSpeed();                  /* Read the PHY's current link speed                    */
    link_duplex             =   NetNIC_PhyLinkDuplex();                 /* Read the PHY's current link duplex mode              */

    if (link_speed == NET_PHY_SPD_0 || link_duplex == NET_PHY_DUPLEX_UNKNOWN) {

        NetNIC_LinkChange(NET_PHY_SPD_0, NET_PHY_DUPLEX_UNKNOWN);       /* Inform the EMAC about the current PHY settings       */

    } else {

        NetNIC_LinkChange(link_speed,    link_duplex);                  /* Inform the EMAC about the current PHY settings       */
    }
}


/*
*********************************************************************************************************
*********************************************************************************************************
*                                  Board Support Functions
*********************************************************************************************************
*********************************************************************************************************
*/

/*
*********************************************************************************************************
*                                  RESET & INIT PHY HARDWARE
*
* Description : This function is called by EMAC_Init() to hardware reset the PHY
*             : and configure the IO pins necessary to communicate between the MAC and PHY
*
* Arguments   : none
*
* Return(s)   : none.
*
* Notes(s)    : (1) Unlike the AT91SAM7X-EK board, the PHY pin function include both peripheral A and
*                   peripheral B functions.
*               (2) The PHY PWRDWN pin is not under software control; instead, it is tied to ground.
*********************************************************************************************************
*/

void  NetBSP_Phy_HW_Init (void)
{
#if EMAC_CFG_RMII                                                       /* Configure I/O and the RMII / MII interface pins          */
#if NEW_SILICON > 0
    PINSEL2             |=   0x50150105;	                                /* Selects P1[0,1,4,8,9,10,14,15]                           */
#else
    PINSEL2             |=   0x50151105;	                                /* Selects P1[0,1,4,6,8,9,10,14,15] (errata work-around)    */
#endif
    PINSEL3             |=   0x00000005;	                                /* Selects P1[17:16]                                        */
#else
    PINSEL2             |=   0x55555555;	                                /* Selects P1[15:0]                                         */
    PINSEL3             |=   0x00000005;	                                /* Selects P1[17:16]                                        */
#endif
}

/*
*********************************************************************************************************
*                                        NetBSP_GetHostClkFreq()
*
* Description : This function returns the LPC2378 Host Clock (SYSCLK also named HCLK) frequency which is
*               used by the EMAC driver to select the MII Management interface clock divider.
*
* Arguments   : none
*
* Notes       : none
*********************************************************************************************************
*/

CPU_INT32U  NetBSP_GetHostClkFreq(void)
{
    CPU_INT32U  hclk_freq;


    hclk_freq  =  BSP_CPU_ClkFreq();                                    /* Get the cClkFrq which feeds the EMAC module              */
    return (hclk_freq);
}

/*
*********************************************************************************************************
*                                        NetBSP_DlyMs()
*
* Description : This function is used by the NIC driver to create delays of an arbitrary abount
*               of milliseconds during initialization.
*
* Arguments   : none
*********************************************************************************************************
*/

void  NetBSP_DlyMs (CPU_INT32U ms)
{
    OSTimeDlyHMSM(0, 0, ms / 1000, ms % 1000);

⌨️ 快捷键说明

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