📄 net_nic.h
字号:
/*
*********************************************************************************************************
* uC/TCP-IP
* The Embedded TCP/IP Suite
*
* (c) Copyright 2003-2007; Micrium, Inc.; Weston, FL
*
* All rights reserved. Protected by international copyright laws.
*
* uC/TCP-IP is provided in source form for FREE evaluation, for educational
* use or peaceful research. If you plan on using uC/TCP-IP in a commercial
* product you need to contact Micrium to properly license its use in your
* product. We provide ALL the source code for your convenience and to help
* you experience uC/TCP-IP. The fact that the source code is provided does
* NOT mean that you can use it without paying a licensing fee.
*
* Network Interface Card (NIC) port files provided, as is, for FREE and do
* NOT require any additional licensing or licensing fee.
*
* Knowledge of the source code may NOT be used to develop a similar product.
*
* Please help us continue to provide the Embedded community with the finest
* software available. Your honesty is greatly appreciated.
*********************************************************************************************************
*/
/*
*********************************************************************************************************
*
* NETWORK INTERFACE CARD
*
* LuminaryMicro LM3Snnnn EMAC
*
* Filename : net_nic.h
* Version : V1.90
* Programmer(s) : BAN
*********************************************************************************************************
* Note(s) : (1) Supports EMAC section of LuminaryMicro's LM3Snnnn microcontroller.
*
* (2) REQUIREs Ethernet Network Interface Layer located in the following network directory :
*
* \<Network Protocol Suite>\IF\Ether\
*
* where
* <Network Protocol Suite> directory path for network protocol suite
*
* (3) Since the LM3Snnnn EMAC (NIC) module is integrated into the LM3Snnnn microcontroller,
* the endianness of the registers is the same as the CPU, which is little-endian by default.
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* EXTERNS
*********************************************************************************************************
*/
#ifdef NET_NIC_MODULE
#define NET_NIC_EXT
#else
#define NET_NIC_EXT extern
#endif
/*
*********************************************************************************************************
* DEFINES
*********************************************************************************************************
*/
#define EMAC_PHY_INIT_AUTO_NEG_RETRIES 10
/*
*********************************************************************************************************
* NIC DRIVER LAYER / ETHERNET ERROR CODES
*
* Note(s) : (1) ALL NIC-independent error codes #define'd in 'net_err.h';
* ALL LM3Snnnn-specific error codes #define'd in this 'net_nic.h'.
*
* (2) Network error code '10,000' series reserved for NIC drivers.
*********************************************************************************************************
*/
#define EMAC_ERR_TX_BUSY 10700
#define EMAC_ERR_RX_NO_PACKET 10701
#define EMAC_ERR_NO_EMAC 10702
/*
*********************************************************************************************************
* DATA TYPES
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* GLOBAL VARIABLES
*********************************************************************************************************
*/
NET_NIC_EXT CPU_BOOLEAN NetNIC_ConnStatus; /* NIC's connection status : DEF_ON/DEF_OFF. */
#if (NET_CTR_CFG_STAT_EN == DEF_ENABLED) /* ------------------- NET DRV STATS ------------------ */
NET_NIC_EXT NET_CTR NetNIC_StatRxPktCtr;
NET_NIC_EXT NET_CTR NetNIC_StatTxPktCtr;
#endif
#if (NET_CTR_CFG_ERR_EN == DEF_ENABLED) /* ------------------- NET DRV ERRS ------------------- */
NET_NIC_EXT NET_CTR NetNIC_ErrRxPktDiscardedCtr;
NET_NIC_EXT NET_CTR NetNIC_ErrTxPktDiscardedCtr;
#endif
/*
*********************************************************************************************************
* FUNCTION PROTOTYPES
*********************************************************************************************************
*/
void NetNIC_Init (NET_ERR *perr);
void NetNIC_IntEn (NET_ERR *perr);
/* ------------------- STATUS FNCTS ------------------- */
CPU_BOOLEAN NetNIC_ConnStatusGet (void);
void NetNIC_ISR_Handler (void); /* Decode & handle rx/tx ISRs. */
/* --------------------- RX FNCTS --------------------- */
CPU_INT16U NetNIC_RxPktGetSize (void); /* Get NIC rx pkt size. */
void NetNIC_RxPkt (void *ppkt, /* Rx pkt from NIC. */
CPU_INT16U size,
NET_ERR *perr);
void NetNIC_RxPktDiscard (CPU_INT16U size, /* Discard rx pkt in NIC. */
NET_ERR *perr);
/* --------------------- TX FNCTS --------------------- */
void NetNIC_TxPkt (void *ppkt,
CPU_INT16U size,
NET_ERR *perr);
void NetNIC_TxPktDiscard (NET_ERR *perr);
/* -------------------- PHY FNCTS --------------------- */
CPU_INT16U NetNIC_PhyRegRd (CPU_INT08U phy,
CPU_INT08U reg,
NET_ERR *perr);
void NetNIC_PhyRegWr (CPU_INT08U phy,
CPU_INT08U reg,
CPU_INT16U val,
NET_ERR *perr);
/*
*********************************************************************************************************
* FUNCTION PROTOTYPES
* DEFINED IN OS'S net_os.c
*********************************************************************************************************
*/
void NetOS_NIC_Init (NET_ERR *perr); /* Create Drv objs & start Drv tasks. */
void NetOS_NIC_TxRdyWait (NET_ERR *perr); /* Wait on drv tx rdy signal from NIC. */
void NetOS_NIC_TxRdySignal (void); /* Post drv tx rdy signal from NIC. */
/*
*********************************************************************************************************
* CONFIGURATION ERRORS
*********************************************************************************************************
*/
#ifndef EMAC_CFG_MAC_ADDR_SEL
#error "EMAC_CFG_MAC_ADDR_SEL not #define'd in 'net_bsp.h' "
#error " [MUST be EMAC_CFG_MAC_ADDR_SEL_CFG]"
#elif (EMAC_CFG_MAC_ADDR_SEL != EMAC_CFG_MAC_ADDR_SEL_CFG)
#error "EMAC_CFG_MAC_ADDR_SEL illegally #define'd in 'net_bsp.h' "
#error " [MUST be EMAC_CFG_MAC_ADDR_SEL_CFG]"
#endif
#ifndef NET_NIC_CFG_TX_PKT_PREPARE_EN
#error "NET_NIC_CFG_TX_PKT_PREPARE_EN not #define'd in 'net_cfg.h'"
#error " [MUST be DEF_DISABLED]"
#elif (NET_NIC_CFG_TX_PKT_PREPARE_EN != DEF_DISABLED)
#error "NET_NIC_CFG_TX_PKT_PREPARE_EN illegally #define'd in 'net_cfg.h'"
#error " [MUST be DEF_DISABLED]"
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -