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

📄 ne64driver.h

📁 用于以太网开发
💻 H
📖 第 1 页 / 共 2 页
字号:
/*****************************************************************************
 *                      (c) Freescale  Inc. 2004 All rights reserved
 *
 * File Name     : ne64API.h
 *
 * PURPOSE: NE64 Ethernet API header definitions
 *
 *
 * DESCRIPTION: Defines headers of higher level routines for the EMAC module
 *
 *
 * Version : 2.1
 * Date    : 02/04/04
 *
 *****************************************************************************/

#ifndef NE64_DRIVER_H
#define NE64_DRIVER_H

#include "MOTTYPES.h"
#include "ne64config.h"

/** \brief EtherInit: Start up EPHY and EMAC base on  etherinit.h user configuration
 *	\ingroup EtherInit
 *
 *	This function initializes the NE64 EMAC and EPHY and sets speed and duplex
 *  based on the users configuation in the "etherinit.h" file
 *
 *  \param  NONE 
 *  \return 
 *	NONE
 *
 *  \see ne64config.c
 *  \todo 
 *      \li  Validate Pause Resolution after lost link and re-autonegation
 *      \li  Validate Duplex Resolution after lost link and re-autonegation
 *      \li  Provide workaround for auto-negoitiation link issue 
 *  \bug 
 *      \li  Dummy MII read required after restart auto-negotiation
 *      \li  Dummy MII read required after MII write to PHY interrupt registers
 */
void EtherInit (void);


/** \brief MIIwrite: write data to PHY function
 *	\ingroup ne64api
 *
 *	Write internal EPHY registers through EMAC MII seiral management interface.
 *
 *  \param  _mpadr - address of the device
 *  \param  _mradr - address of the register within the device
 *  \param  _mwdata - data to write to the PHY register
 *  \return
 *	0xff = operation completed OK
 *    \li 0x00 = MII busy
 *  \todo Make this function repeat until it is sucessful
 *  \bug Before the MII write take affect a dummy read via the MII is required.
 *       This function could be made to do the dummy read
 *  \warning MII clock must be configured correctly and PHY PLLs must not be disabled for
 * 		MII seiral management communication
 */
tU08 MIIwrite(tU08 _mpadr, tU08 _mradr, tU16 _mwdata);


/** \brief MIIread: read data from PHY function
 *	\ingroup ne64api
 *
 * Read internal EPHY registers through EMAC MII seiral management interface.
 *
 *  \param  _mpadr - address of the device
 *  \param  _mradr - address of the register within the device
 *  \param  _mwdata - pointer to where to store the received contents of PHY register
 *  \return
 *	0xff = operation completed OK
 *    \li 0x00 = MII busy
 *  \warning MII clock must be configured correctly and PHY PLLs must not be disabled for
 * 		MII seiral management communication
 *  \see ne64api.h
 *  \todo Make this function repeat until it is sucessful
 *  \bug
 */
tU08 MIIread(tU08 _mpadr, tU08 _mradr, tU16 * _mrdata);


/** \brief EtherType: set the Ethertye acceptance registers
 *	\ingroup ne64api
 *
 *	This function set the Ethertye acceptance registers based on
 *  the users configuation in the "ne64config.h" file
 *
 *  \param  control - the acceptance mask (see definitons)
 *  \param  etype   - programmable ethertype (16bit value)
 *  \return
 *	No return value
 *  \warning It is recommend not to change the Ethertype when the EMAC is enabled
 *  \see ne64api.h
 *  \todo
 *  \bug
 */
void EtherType(tU08 control, tU16 etype);
#define T_PET   0x80 /**< Programmable Ethertype, 'etype' parameter is used */
#define T_EMW   0x10 /**< Emware Ethertype */
#define T_IPV6  0x08 /**< Internet IP version (IPV6) Ethertype */
#define T_ARP   0x04 /**< Address Resolution Protocol (ARP) Ethertype */
#define T_IPV4  0x02 /**< Internet IP version 4 (IPV6) Ethertype */
#define T_IEEE  0x01 /**< IEEE802.3 Length Field Ethertype */
#define T_ALL   0x00 /**< Accept all ethertypes */

/** \brief EtherIoctl: Setting of the multicast hash table
 *	\ingroup ne64api
 *
 *	Setting of the multicast hash table
 *
 *  \param  flag    - either MC_ALL or MC_LIST
 *  \param  listPtr - pointer to address list (valid only if flag == MC_LIST)
 *  \param  listLen - number of addresses in list (valid only if flag == MC_LIST)
 *  \return
 *	No return value
 *  \see ne64api.h
 *  \todo  This function need more testing
 *  \bug
*/
void EtherIoctl(tU08 flag, void * optionPtr, tU08 optionLen);
#define MC_ALL  0 /**< set hash to accept all multicast frames */
#define MC_LIST 1 /**< set hash to accept list of addresses */

/** \brief EtherGetPhysAddr: return EMAC current physical address
 *	\ingroup ne64api
 *
 *	return EMAC current physical address
 *
 *  \param  ethaddr - pointer to place (6 bytes) where the physical address will be stored to
 *	No return value
 *  \see ne64api.h
 *  \todo
 *  \bug
 */
void EtherGetPhysAddr(void * ethaddr);


/** \brief EtherSend: send one frame
 *	\ingroup ne64api
 *
 *	This function sends one frame
 *
 *  \param  databuf - pointer to data which should be sent
 *  \param  datalen - length of the data to be sent
 *  \return
 *	No return value
 *  \see ne64api.h
 *  \todo
 *  \bug
 */
void EtherSend(void * databuf, tU16 datalen);

/** \brief EtherReceive: read received frame
 *	\ingroup ne64api
 *
 *	This function reads the received frame
 *
 *  \param  buffer - pointer to place where the physical address will be stored to
 *  \return
 *	length of the received data (if 0 - then no data received)
 */
#if   RX_POLL_MODE
tU16 EtherReceive(void * buffer);
tU16 EtherReceiveZeroCopy(tU08 * whichbuffer);
#else	 //    RX_POLL_MODE
void ProcessPacket();
#endif //		 RX_POLL_MODE


/** \brief EtherOpen: prepare the EMAC for normal operation
 *	\ingroup ne64api
 *
 *	This function initializes the NE64 EMAC
 *
 *  \param  miisetup -  mii preamble & clock setup
 *  \param  bufmap - buffer configuration  (see tables 3-5&3-6 in EMAC doc.)
 *  \param  maxfl - initial max.frame length for receive
 *  \param  pmacad - pointer to MAC address definition
 *  \param  control - the acceptance mask (same as in EtherType function)
 *  \param  etype - programmable ethertype (16bit value)
 *  \param  rxmode - reception mode settings 	 (see RXCT_X possible values)
 *  \param  netctl - network control setup (see NETCT_X possible values)
 *  \return  NONE
 *  \see ne64api.h
 *  \todo
 *  \bug
 */
void EtherOpen(tU08 miisetup, /* */
               tU08 bufmap,   /*
                                         */
                 tU16 maxfl,   /*  */
                        void * pmacad, /*  */
                tU08 control,
                   tU16 etype, /* */
                 tU08 rxmode, /*  */
                 tU08 netctl /* */
                 );
/* miisetup values */
#define MII_NO_PREAM   0x10 /**< No preamble */
#define MII_C20     0x04    /**< 20Mhz IP Bus 2.5MHz MDC clock */
#define MII_C25     0x05		/**< 25Mhz IP Bus */
#define MII_C33     0x07		/**< 33Mhz IP Bus */
#define MII_C40     0x08		/**< 40Mhz IP Bus */
#define MII_C50     0x0a		/**< 50Mhz IP Bus */

/* network control setup values */
#define NETCT_ESWAI  0x10  /**< EMAC disabled during WAIT */
#define NETCT_EXTPHY 0x08  /**< external PHY mode */
#define NETCT_MLB    0x04  /**< MAC loopback mode */
#define NETCT_FDX    0x02  /**< full duplex mode */

/* rxmode setup values */
#define RXCT_RFCE   0x10 /**< PAUSE frame supported */
#define RXCT_PROM   0x04 /**< promiscuous mode */
#define RXCT_CONMC  0x02 /**< multicast hash table used for incoming frames chk */
#define RXCT_BCREJ  0x01 /**< all broadcast frames will be rejected */


/** \brief EtherClose: switch off the EMAC and clear interrupt flags
 *	\ingroup ne64api
 *
 *	This function switches off the EMAC and clear interrupt flags
 *
 *  \param  NONE
 *  \return NONE
 */
void EtherClose(void);


/** \brief EmacDisable: switch off the EMAC
 *	\ingroup ne64api
 *
 *	switch off the EMAC

⌨️ 快捷键说明

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