📄 mac.h.bak
字号:
#define RxEn 0x0001
#define RxHalt 0x0002
#define LongEn 0x0004
#define ShortEn 0x0008
#define StripCRC 0x0010
#define PassCtl 0x0020
#define IgnoreCRC 0x0040
#define EnAlign 0x0100
#define EnCRCErr 0x0200
#define EnOver 0x0400
#define EnLongErr 0x0800
#define EnRxPar 0x2000
#define EnGood 0x4000
/* --------- *
* Rx Status *
* --------- */
#define OvMax (0x0004)
#define CtlRcv (0x0020)
#define IntRx (0x0040)
#define Rx10stat (0x0080)
#define AlignErr (0x0100)
#define CRCErr (0x0200)
#define Overflow (0x0400)
#define LongErr (0x0800)
#define RxPar (0x2000)
#define Good (0x4000)
#define RxHalted (0x8000)
/*
// Receive Status Register(MACRXSTAT)
#define MCtlRecd 0x0020
#define MIntRx 0x0040
#define MRx10Stat 0x0080
#define MAllignErr 0x0100
#define MCRCErr 0x0200
#define MOverflow 0x0400
#define MLongErr 0x0800
#define MRxPar 0x2000
#define MRxGood 0x4000
#define MRxHalted 0x8000
*/
// Tx/Rx common descriptor structure
typedef struct FrameDescriptor {
U32 FrameDataPtr;
U32 Reserved; // cf: RX-reserved, TX-Reserved(25bits) + Control bits(7bits)
U32 StatusAndFrameLength;
U32 NextFrameDescriptor;
} sFrameDescriptor;
// MAC Frame Structure
typedef __packed struct ETH_HEADER {
U8 DestinationAddr[6] ;
U8 SourceAddr[6] ;
U8 LengthOrType[2] ;
} etheader ;
typedef __packed struct MACFrame {
etheader Header ;
U8 LLCData[1506] ;
} sMACFrame;
// MAC Tx Error Structure
typedef struct MACTxStatus {
U32 MacTxGood ;
U32 ExCollErr ;
U32 TxDefferedErr ;
U32 sPaused ;
U32 UnderErr ;
U32 DeferErr ;
U32 NCarrErr ;
U32 sSQE ;
U32 LateCollErr ;
U32 TxParErr ;
U32 sTxHalted ;
} pMACTxStatus ;
// MAC Rx Error Structure
typedef struct MACRxStatus {
U32 OvMaxSize ;
U32 sCtlRecd ;
U32 sRx10Stat ;
U32 AllgnErr ;
U32 sCRCErr ;
U32 OverflowErr ;
U32 sLongErr ;
U32 RxParErr ;
U32 sRxHalted ;
U32 gErrorPacketCnt;
} pMACRxStatus ;
// BDMA Tx Error Structure
typedef struct BDMATxStatus {
U32 BTxNLErr ;
U32 BTxNOErr ;
U32 BTxEmptyErr ;
} pBDMATxStatus ;
// BDMA Rx Error Structure
typedef struct BDMARxStatus {
U32 BdmaRxCnt ;
U32 BdmaRxGood ;
U32 BRxNLErr ;
U32 BRxNOErr ;
U32 BRxMSOErr ;
} pBDMARxStatus ;
/* ------------------------------------------ */
/* PHY(ICS1890) Register Description */
/* ------------------------------------------ */
/* PHY_CNTL_REG : 0x00 */
/* PHY_STATUS_REG : 0x01 */
/* PHY_ID_REG1 : 0x02 */
/* PHY_ID_REG2 : 0x03 */
/* PHY_ANA_REG : 0x04 */
/* PHY_ANLPAR_REG : 0x05 */
/* PHY_ANE_REG : 0x06 */
/* PHY_ECNTL_REG1 : 0x10 */
/* PHY_QPDS_REG : 0x11 */
/* PHY_10BOP_REG : 0x12 */
/* PHY_ECNTL_REG2 : 0x13 */
/* ------------------------------------------ */
#define PHY_CNTL_REG 0x00
#define PHY_STATUS_REG 0x01
#define PHY_ID_REG1 0x02
#define PHY_ID_REG2 0x03
#define PHY_ANA_REG 0x04
#define PHY_ANLPAR_REG 0x05
#define PHY_ANE_REG 0x06
#define PHY_ECNTL_REG1 0x10
#define PHY_QPDS_REG 0x11
#define PHY_10BOP_REG 0x12
#define PHY_ECNTL_REG2 0x13
#define PHYHWADDR 0x20 /* PHY H/W Address is 0x1 */
#define PHYREGWRITE 0x1 << 10
#define MiiBusy 0x1 << 11
/* PHY control register */
#define RESET_PHY 1 << 15
#define ENABLE_LOOPBACK 1 << 14
#define DR_100MB 1 << 13
#define ENABLE_AN 1 << 12
#define PHY_MAC_ISOLATE 1 << 10
#define RESTART_AN 1 << 9
#define PHY_FULLDUPLEX 1 << 8
#define PHY_COL_TEST 1 << 7
/* PHY Status register */
#define AN_COMPLETE 1 << 5
/* PHY Auto-negotiation Advertisement register */
#define DR100_TX_FULL 1 << 8
#define DR100_TX_HALF 1 << 7
#define DR10_TX_FULL 1 << 6
#define DR10_TX_HALF 1 << 5
/*
* Initialize Ethernet and MAC controller
*/
extern void LanInitialize(void) ;
extern void MacWatchdogInit(void) ;
extern void MacInitialize(void) ;
extern void TxFDInitialize(void) ;
extern void RxFDInitialize(void) ;
extern void ReadyMacTx(void) ;
extern void ReadyMacRx(void) ;
extern void GetMyMacAddr(void) ;
/*
* LAN Watch-Dog function
*/
extern void Lan_WatchDog(void) ;
/*
* Manage and initialize PHY
*/
extern void ResetPhyChip(void) ;
extern void MiiStationWrite(U32 PhyInAddr, U32 PhyAddr, U32 PhyWrData) ;
extern U32 MiiStationRead(U32 PhyInAddr, U32 PhyAddr) ;
extern void delay_physet(void) ;
/*
* MAC and BDMA interrupt service routine
*/
extern void MAC_Tx_isr(void) ;
extern void MAC_Rx_isr(void) ;
extern void BDMA_Tx_isr(void) ;
extern void BDMA_Rx_isr(void) ;
extern void BdmaRxForSingleIsr(void) ;
/*
* Send Packet
*/
extern int SendPacket(U8 *Data,int Size) ;
extern void Eth_Multi_Transmit(void) ;
extern int Random_Pkt_Transmit(int seed) ;
extern void TxMacFrame(void) ;
extern void ControlFrameTransfer(void) ;
extern void SingleTransfer(void) ;
/*
* Receive Packet
*/
extern void GetRxFrameData(U8 *pFrameData, U32 FrameLength, U32 RxStatus) ;
extern void RxMacFrame(void) ;
/*
* Debug Information
*/
extern void MacDebugStatus(void) ;
extern void ReadErrReport(void) ;
extern void ClearErrReport(void) ;
/*
* Loopback test
*/
extern void MacLoopBackTest(void) ;
extern int InterruptLoopBackTest(void) ;
extern int CompareLoopBackData(U8 *pTxFrameData, U32 UserFrameBufferPtr) ;
extern void MacInternalLoopBack(void) ;
extern int PollingLoopBackTest(void) ;
extern void MacPollLoopBack(void) ;
//extern void PhyNoColLoopBack(void) ;
extern int PhyNoColLoopBack(void) ;
extern void PhyColLoopBack(void) ;
extern void PhysicalLoopBack(void) ;
extern void MacAllLoopBack(void) ;
/*
* Diagnostic test MAC and BDMA controller
*/
extern void MacTest(void) ;
extern void MacEtcTest(void) ;
extern void MDCOnTest(void) ;
extern void MDCOffTest(void) ;
extern void PhyStationRdWrTest(void) ;
extern void BdmaBufferTest(void) ;
extern void MacTxHaltReqTest(void) ;
extern void MacFifoTest(void) ;
/*
* Utility
*/
extern void PrintRxFrame(U8 *pFramePtr, U32 FrameLength) ;
extern void MacAddrWrite(void) ;
extern void MacAddrRead(void) ;
extern void CaptureRxFrame(void) ;
extern void CaptureAndShowFrame(void) ;
extern void CaptureAllRxFrame(void) ;
extern void CaptureMyRxFrame(void) ;
extern void CaptureBroadFrame(void) ;
extern void CaptureCntlFrame(void) ;
extern void CaptureMatchedDest(void) ;
extern void ShowRecevedFrameData(void) ;
/*
* MAC and BDMA configuration
*/
extern void MacConfig(void) ;
extern void ViewMacAndBdmaConfiguration(void) ;
extern void ChangeMacAndBdmaConfiguration(void) ;
#endif /* _MAC_ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -