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

📄 ne64api.h

📁 MC9S12NE64串口与网络通信源代码
💻 H
字号:
/*****************************************************************************
 *
 * File Name     : ne64API.h
 *
 * PURPOSE: NE64 Ethernet API header definitions
 *
 *
 * DESCRIPTION: Defines headers of higher level routines for the EMAC module
 *
 *
 *****************************************************************************/

#ifndef NE64_API_H
#define NE64_API_H

#include "MOTTYPES.h"

/** \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
 */
unsigned char 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 "etherinit.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 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
 *
 *  \param  NONE
 *  \return NONE
 */
void EmacDisable(void);


/** \brief EmacEnable: switch on the EMAC
 *	\ingroup ne64api
 *
 *	switch on the EMAC
 *
 *  \param  NONE
 *  \return NONE
 */
void EmacEnable(void);


/** \brief EmacControl: Set control bits in EMAC netctl register
 *	\ingroup ne64api
 *
 *	Set control bits in EMAC netctl register
 *
 *  \param  NONE
 *  \return NONE
 */
void EmacControl(tU08 netctl);



/** \brief EtherPause: send PAUSE frame
 *	\ingroup ne64api
 *
 *	This function sends PAUSE frame
 *
 *  \param  ptrc -  if 1 ptime used for PAUSE time setting, if 0 ptime not used
 *  \param  ptime - value of PAUSE timer
 *  \return
 *	returns current value of PAUSE timer when ptrc=0
 *  \todo This function need more testing
 *  \bug
 */
tU16 EtherPause(tU08 ptrc, tU16 ptime);




//void mynop(void);
void ENABLE_INTERRUPT(void);
void DISABLE_INTERRUPT(void);
void initialize_ne64(void);                                                                     
void put_char(tU08 );


void Move( unsigned char *dest, unsigned char *src, unsigned int numbytes );
//void Bzero( unsigned char *dest, unsigned int numbytes );


/******************to output a packet****************************************************/
tU08 *sed_FormatPacket( tU08 *EtherHeadPtr, tU08 *destEAddr, tU16 ethType );
tU08 sed_Send( tU16 pkLengthInOctets );
void WriteTxByte(tU08 bytedata);
void ei_output_s( tU08 *buf, tU16 Count );
void sci0_rie(void);



#endif      /* NE64_API_H */

⌨️ 快捷键说明

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