亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? enc28j60.c

?? 用于Microchip 16位單片機的通信應(yīng)用程序庫 1042
?? C
?? 第 1 頁 / 共 5 頁
字號:
 *					register contents in the last 8 SPI clocks.
 *
 * Note:            This routine cannot be used to access ETH or PHY 
 *					registers.  Use ReadETHReg() or ReadPHYReg() for that 
 *					purpose.  
 *****************************************************************************/
static REG ReadMACReg(BYTE Address)
{
	REG r;

	ENC_CS_IO = 0;
	ENC_SPI_IF = 0;
	ENC_SSPBUF = RCR | Address;	// Send the Read Control Register opcode and 
							//   address.
	while(!ENC_SPI_IF);		// Wait until opcode/address is transmitted.
	r.Val = ENC_SSPBUF;
	ENC_SPI_IF = 0;
	ENC_SSPBUF = 0;				// Send a dummy byte 
	while(!ENC_SPI_IF);		// Wait for the dummy byte to be transmitted
	r.Val = ENC_SSPBUF;
	ENC_SPI_IF = 0;
	ENC_SSPBUF = 0;				// Send another dummy byte to receive the register 
							//   contents.
	while(!ENC_SPI_IF);		// Wait until register is received.
	r.Val = ENC_SSPBUF;
	ENC_SPI_IF = 0;
	ENC_CS_IO = 1;
	
	return r;
}//end ReadMACReg


/******************************************************************************
 * Function:        ReadPHYReg
 *
 * PreCondition:    SPI bus must be initialized (done in MACInit()).
 *
 * Input:           Address of the PHY register to read from.
 *
 * Output:          16 bits of data read from the PHY register.
 *
 * Side Effects:    Alters bank bits to point to Bank 2
 *
 * Overview:        ReadPHYReg performs an MII read operation.  While in 
 *					progress, it simply polls the MII BUSY bit wasting time 
 *					(10.24us).
 *
 * Note:            None
 *****************************************************************************/
PHYREG ReadPHYReg(BYTE Register)
{
	PHYREG Result;

	// Set the right address and start the register read operation
	BankSel(MIREGADR);
	WriteReg((BYTE)MIREGADR, Register);
	WriteReg((BYTE)MICMD, MICMD_MIIRD);	

	// Loop to wait until the PHY register has been read through the MII
	// This requires 10.24us
	BankSel(MISTAT);
	while(ReadMACReg((BYTE)MISTAT).MISTATbits.BUSY);

	// Stop reading
	BankSel(MIREGADR);
	WriteReg((BYTE)MICMD, 0x00);	
	
	// Obtain results and return
	Result.VAL.v[0] = ReadMACReg((BYTE)MIRDL).Val;
	Result.VAL.v[1] = ReadMACReg((BYTE)MIRDH).Val;

	return Result;
}//end ReadPHYReg


/******************************************************************************
 * Function:        void WriteReg(BYTE Address, BYTE Data)
 *
 * PreCondition:    SPI bus must be initialized (done in MACInit()).
 * 					Bank select bits must be set corresponding to the register 
 *					to modify.
 *
 * Input:           5 bit address of the ETH, MAC, or MII register to modify.  
 *					  The top 3 bits must be 0.  
 *					Byte to be written into the register.
 *
 * Output:          None
 *
 * Side Effects:    None
 *
 * Overview:        WriteReg sends the 8 bit WCR opcode/Address byte over the 
 *					SPI and then sends the data to write in the next 8 SPI 
 *					clocks.
 *
 * Note:            This routine is almost identical to the BFCReg() and 
 *					BFSReg() functions.  It is seperate to maximize speed.  
 *					Unlike the ReadETHReg/ReadMACReg functions, WriteReg() 
 *					can write to any ETH or MAC register.  Writing to PHY 
 *					registers must be accomplished with WritePHYReg().
 *****************************************************************************/
static void WriteReg(BYTE Address, BYTE Data)
{		
	BYTE Dummy;

	ENC_CS_IO = 0;
	ENC_SPI_IF = 0;
	ENC_SSPBUF = WCR | Address;	// Send the opcode and address.
	while(!ENC_SPI_IF);		// Wait until opcode/address is transmitted.
	Dummy = ENC_SSPBUF;
	ENC_SPI_IF = 0;
	ENC_SSPBUF = Data;			// Send the byte to be writen.
	while(!ENC_SPI_IF);		// Wait until register is written.
	Dummy = ENC_SSPBUF;
	ENC_SPI_IF = 0;
	ENC_CS_IO = 1;
}//end WriteReg


/******************************************************************************
 * Function:        void BFCReg(BYTE Address, BYTE Data)
 *
 * PreCondition:    SPI bus must be initialized (done in MACInit()).
 * 					Bank select bits must be set corresponding to the register 
 *					  to modify.
 *
 * Input:           5 bit address of the register to modify.  The top 3 bits 
 *					  must be 0.  
 *					Byte to be used with the Bit Field Clear operation.
 *
 * Output:          None
 *
 * Side Effects:    None
 *
 * Overview:        BFCReg sends the 8 bit BFC opcode/Address byte over the 
 *					SPI and then sends the data in the next 8 SPI clocks.
 *
 * Note:            This routine is almost identical to the WriteReg() and 
 *					BFSReg() functions.  It is separate to maximize speed.  
 *					BFCReg() must only be used on ETH registers.
 *****************************************************************************/
static void BFCReg(BYTE Address, BYTE Data)
{
	BYTE Dummy;

	ENC_CS_IO = 0;
	ENC_SPI_IF = 0;
	ENC_SSPBUF = BFC | Address;	// Send the opcode and address.
	while(!ENC_SPI_IF);		// Wait until opcode/address is transmitted.
	Dummy = ENC_SSPBUF;
	ENC_SPI_IF = 0;
	ENC_SSPBUF = Data;			// Send the byte to be writen.
	while(!ENC_SPI_IF);		// Wait until register is written.
	Dummy = ENC_SSPBUF;
	ENC_SPI_IF = 0;
	ENC_CS_IO = 1;
}//end BFCReg


/******************************************************************************
 * Function:        void BFSReg(BYTE Address, BYTE Data)
 *
 * PreCondition:    SPI bus must be initialized (done in MACInit()).
 * 					Bank select bits must be set corresponding to the register 
 *					to modify.
 *
 * Input:           5 bit address of the register to modify.  The top 3 bits 
 *					  must be 0.  
 *					Byte to be used with the Bit Field Set operation.
 *
 * Output:          None
 *
 * Side Effects:    None
 *
 * Overview:        BFSReg sends the 8 bit BFC opcode/Address byte over the 
 *					SPI and then sends the data in the next 8 SPI clocks.
 *
 * Note:            This routine is almost identical to the WriteReg() and 
 *					BFCReg() functions.  It is separate to maximize speed.
 *					BFSReg() must only be used on ETH registers.
 *****************************************************************************/
static void BFSReg(BYTE Address, BYTE Data)
{
	BYTE Dummy;

	ENC_CS_IO = 0;
	ENC_SPI_IF = 0;
	ENC_SSPBUF = BFS | Address;	// Send the opcode and address.
	while(!ENC_SPI_IF);		// Wait until opcode/address is transmitted.
	Dummy = ENC_SSPBUF;
	ENC_SPI_IF = 0;
	ENC_SSPBUF = Data;			// Send the byte to be writen.
	while(!ENC_SPI_IF);		// Wait until register is written.
	Dummy = ENC_SSPBUF;
	ENC_SPI_IF = 0;
	ENC_CS_IO = 1;
}//end BFSReg


/******************************************************************************
 * Function:        WritePHYReg
 *
 * PreCondition:    SPI bus must be initialized (done in MACInit()).
 *
 * Input:           Address of the PHY register to write to.
 *					16 bits of data to write to PHY register.
 *
 * Output:          None
 *
 * Side Effects:    Alters bank bits to point to Bank 3
 *
 * Overview:        WritePHYReg performs an MII write operation.  While in 
 *					progress, it simply polls the MII BUSY bit wasting time.
 *
 * Note:            None
 *****************************************************************************/
void WritePHYReg(BYTE Register, WORD Data)
{
	// Write the register address
	BankSel(MIREGADR);
	WriteReg((BYTE)MIREGADR, Register);
	
	// Write the data
	// Order is important: write low byte first, high byte last
	WriteReg((BYTE)MIWRL, ((WORD_VAL*)&Data)->v[0]);	
	WriteReg((BYTE)MIWRH, ((WORD_VAL*)&Data)->v[1]);

	// Wait until the PHY register has been written
	BankSel(MISTAT);
	while(ReadMACReg((BYTE)MISTAT).MISTATbits.BUSY);
}//end WritePHYReg


/******************************************************************************
 * Function:        BankSel
 *
 * PreCondition:    SPI bus must be initialized (done in MACInit()).
 *
 * Input:           Register address with the high byte containing the 2 bank 
 *					  select 2 bits.
 *
 * Output:          None
 *
 * Side Effects:    None
 *
 * Overview:        BankSel takes the high byte of a register address and 
 *					changes the bank select bits in ETHCON1 to match.
 *
 * Note:            None
 *****************************************************************************/
static void BankSel(WORD Register) 
{
	BFCReg(ECON1, ECON1_BSEL1 | ECON1_BSEL0);
	BFSReg(ECON1, ((WORD_VAL*)&Register)->v[1]);
}//end BankSel


/******************************************************************************
 * Function:        static BOOL TestMemory(void) 
 *
 * PreCondition:    SPI bus must be initialized (done in MACInit()).
 *
 * Input:           None
 *
 * Output:          TRUE if the memory tests have passed 
 *					FALSE if the BIST has detected a hardware fault
 *
 * Side Effects:    Alters the state of numerous control registers and all 
 *					RAM bytes.
 *
 * Overview:        The internal BIST and DMA modules are used to fill the 
 *					entire dual port memory and calculate a checksum of the 
 *					data stored within.  Address and Random fill modes are 
 *					used.
 *
 * Note:            For the Random Fill mode, the random number generator is
 *					seeded by the contents of the TMR0L PIC SFR.  If the timer
 *					is running, additional confidence that the memory is 
 *					working can be obtained by calling TestMemory multiple 
 *					times.
 *****************************************************************************/
#if defined(MAC_POWER_ON_TEST)
static BOOL TestMemory(void) 
{
	#define RANDOM_FILL		0b0000
	#define ADDRESS_FILL	0b0100
	#define PATTERN_SHIFT	0b1000
	
	WORD_VAL DMAChecksum, BISTChecksum;
	
	
	// Select Bank 0 and disable anything that could have been in progress
	WriteReg(ECON1, 0x00);
	
	// Set up necessary pointers for the DMA to calculate over the entire 
	// memory
	WriteReg(EDMASTL, 0x00);
	WriteReg(EDMASTH, 0x00);
	WriteReg(EDMANDL, LOW(RAMSIZE-1u));
	WriteReg(EDMANDH, HIGH(RAMSIZE-1u));
	WriteReg(ERXNDL, LOW(RAMSIZE-1u));
	WriteReg(ERXNDH, HIGH(RAMSIZE-1u));

	// Enable Test Mode and do an Address Fill
	BankSel(EBSTCON);
	WriteReg((BYTE)EBSTCON, EBSTCON_TME | 
						 EBSTCON_BISTST | 
						 ADDRESS_FILL);
	
	
	// Wait for the BIST to complete and disable test mode before 
	// starting any DMA operations.
	while(ReadETHReg((BYTE)EBSTCON).EBSTCONbits.BISTST);
	BFCReg((BYTE)EBSTCON, EBSTCON_TME);


	// Begin reading the memory and calculating a checksum over it
	// Block until the checksum is generated
	BFSReg(ECON1, ECON1_DMAST | ECON1_CSUMEN);
	BankSel(EDMACSL);
	while(ReadETHReg(ECON1).ECON1bits.DMAST);

	// Obtain the resulting DMA checksum and the expected BIST checksum
	DMAChecksum.v[0] = ReadETHReg(EDMACSL).Val;
	DMAChecksum.v[1] = ReadETHReg(EDMACSH).Val;
	BankSel(EBSTCSL);
	BISTChecksum.v[0] = ReadETHReg((BYTE)EBSTCSL).Val;
	BISTChecksum.v[1] = ReadETHReg((BYTE)EBSTCSH).Val;
	BFCReg((BYTE)EBSTCON, EBSTCON_TME);
	
	// Compare the results
	// 0xF807 should always be generated in Address fill mode
	if( (DMAChecksum.Val != BISTChecksum.Val) || (DMAChecksum.Val != 0xF807) )
		return FALSE;
	
	// Seed the random number generator and begin another Random Fill test 
	// with the DMA and BIST memory access ports swapped.
#ifdef __C30__
	WriteReg((BYTE)EBSTSD, TMR1);
#else
	WriteReg((BYTE)EBSTSD, TMR0L);
#endif
	WriteReg((BYTE)EBSTCON, EBSTCON_TME | 
					  EBSTCON_PSEL | 
					  EBSTCON_BISTST | 
					  RANDOM_FILL);
						 
						 
	// Wait for the BIST to complete and disable test mode since 
	// we won't be needing it anymore
	while(ReadETHReg((BYTE)EBSTCON).EBSTCONbits.BISTST);
	BFCReg((BYTE)EBSTCON, EBSTCON_TME);
	
	
	// Begin reading the memory and calculating a checksum over it
	// Block until the checksum is generated
	BFSReg(ECON1, ECON1_DMAST | ECON1_CSUMEN);
	BankSel(EDMACSL);
	while(ReadETHReg(ECON1).ECON1bits.DMAST);

	// Obtain the resulting DMA checksum and the expected BIST checksum
	DMAChecksum.v[0] = ReadETHReg(EDMACSL).Val;
	DMAChecksum.v[1] = ReadETHReg(EDMACSH).Val;
	BankSel(EBSTCSL);
	BISTChecksum.v[0] = ReadETHReg((BYTE)EBSTCSL).Val;
	BISTChecksum.v[1] = ReadETHReg((BYTE)EBSTCSH).Val;
	
	return (DMAChecksum.Val == BISTChecksum.Val);
}//end TestMemory
#endif


/******************************************************************************
 * Function:        void MACSetDuplex(DUPLEX DuplexState) 
 *
 * PreCondition:    SPI bus must be initialized (done in MACInit()).
 *
 * Input:           Member of DUPLEX enum:
 *						FULL: Set full duplex mode
 *						HALF: Set half duplex mode
 *						USE_PHY: Set the MAC to match the PHYDPLXMODE bit in 
 *								 PHYCON.  This is controlled by LEDB on RESET.
 *
 * Output:          None
 *
 * Side Effects:    Changes bank bits to Bank 2.
 *
 * Overview:        Disables RX, TX logic, sets MAC up for full duplex 
 *					operation, sets PHY up for full duplex operation, and 
 *					reenables RX logic.  The back-to-back inter-packet gap 
 *					register (MACBBIPG) is updated to maintain a 9.6us gap.
 *
 * Note:            If a packet is being transmitted or received while this 
 *					function 

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
中文字幕一区二区三区不卡在线 | 国产精品一区在线| 99re6这里只有精品视频在线观看| 欧美精品1区2区| 中文字幕一区二区三区在线观看| 男男gaygay亚洲| 91电影在线观看| 中文字幕一区二区三区四区 | 亚洲不卡av一区二区三区| 成人在线综合网| 欧美白人最猛性xxxxx69交| 亚洲午夜一区二区三区| 成人高清免费观看| 久久久久国色av免费看影院| 青青草国产成人av片免费| 在线看国产日韩| 中文字幕综合网| 成人综合婷婷国产精品久久| 欧美xxxxx牲另类人与| 日韩中文字幕麻豆| 欧美日韩一区二区三区视频| 亚洲欧美色图小说| 成人av电影观看| 国产网站一区二区| 国产精品小仙女| 亚洲精品在线观看网站| 另类人妖一区二区av| 欧美美女网站色| 亚洲成人动漫在线免费观看| 欧美亚洲丝袜传媒另类| 亚洲激情网站免费观看| 91免费国产在线观看| 日韩美女视频19| 一本高清dvd不卡在线观看| 国产精品国产三级国产普通话三级 | 免费观看一级欧美片| 欧美精品在线一区二区三区| 亚洲午夜在线视频| 欧美亚洲国产一卡| 亚洲国产一二三| 欧美色综合久久| 亚洲v精品v日韩v欧美v专区| 欧美日韩国产首页在线观看| 视频在线观看一区| 日韩精品一区二区三区蜜臀| 久久精品国产精品亚洲红杏| 精品久久久久久久久久久久包黑料 | 欧美国产成人在线| 国产福利一区二区三区| 中日韩av电影| av不卡一区二区三区| 亚洲欧美一区二区三区久本道91| 日本韩国一区二区三区| 亚洲h动漫在线| 欧美一卡在线观看| 韩国精品主播一区二区在线观看 | 日韩欧美国产成人一区二区| 国内精品久久久久影院色| 久久免费精品国产久精品久久久久| 国产乱人伦偷精品视频不卡 | 欧美zozo另类异族| 国产成人av一区二区三区在线 | 日韩欧美电影一二三| 国产一区二区三区最好精华液| 国产日韩成人精品| 一本到不卡精品视频在线观看| 亚洲自拍偷拍图区| 日韩欧美国产1| 成人午夜视频免费看| 亚洲免费在线看| 91精品黄色片免费大全| 经典三级视频一区| 亚洲视频在线观看三级| 欧美挠脚心视频网站| 国产另类ts人妖一区二区| 国产精品超碰97尤物18| 欧美三区免费完整视频在线观看| 奇米一区二区三区| 国产拍欧美日韩视频二区| 在线观看视频91| 免费欧美在线视频| 国产精品国产a级| 欧美精品久久天天躁| 国产一区二区三区在线观看精品 | 国产精品拍天天在线| 欧洲精品中文字幕| 久久99久久99小草精品免视看| 国产精品久久久久一区| 欧美日韩电影在线| 国产福利精品一区二区| 一区二区三区日韩| 精品免费日韩av| 色综合久久天天| 精品亚洲成a人在线观看| 综合色天天鬼久久鬼色| 日韩三级在线免费观看| 91在线观看视频| 老司机一区二区| 亚洲欧美日韩系列| 精品国精品国产尤物美女| 色婷婷亚洲精品| 国产一区 二区| 午夜电影网一区| 中文字幕成人在线观看| 欧美一级理论性理论a| av网站免费线看精品| 美女脱光内衣内裤视频久久网站| 亚洲色图欧美偷拍| 久久综合九色综合欧美亚洲| 在线观看一区二区视频| 成人爽a毛片一区二区免费| 日本亚洲一区二区| 一区二区三区中文字幕电影| 2014亚洲片线观看视频免费| 欧美日本在线播放| 91香蕉视频mp4| 狠狠色综合播放一区二区| 亚洲电影你懂得| 中文字幕在线一区二区三区| 精品国产露脸精彩对白| 欧美视频一区在线观看| 不卡一区中文字幕| 国产九色精品成人porny | 一区二区三区久久| 中文字幕欧美日本乱码一线二线| 91精品国产综合久久久久久 | 国产成人在线视频网站| 美国毛片一区二区| 亚洲h精品动漫在线观看| 亚洲免费在线观看视频| 国产精品九色蝌蚪自拍| 久久综合狠狠综合久久综合88| 欧美狂野另类xxxxoooo| 91高清在线观看| 99久免费精品视频在线观看| 国产成人鲁色资源国产91色综| 激情文学综合网| 老色鬼精品视频在线观看播放| 亚洲成人自拍一区| 亚洲线精品一区二区三区| 中文字幕一区二区三区在线观看| 国产欧美一区二区精品忘忧草| 精品黑人一区二区三区久久| 欧美一区二区视频在线观看2022| 欧美三级中文字| 91成人看片片| 91成人在线精品| 在线观看精品一区| 日本高清成人免费播放| 91原创在线视频| 日本精品视频一区二区| 欧洲精品中文字幕| 欧美色图天堂网| 欧美日韩亚洲综合在线| 欧美日韩一区二区三区高清| 欧美日韩高清在线播放| 欧美日本一区二区三区四区| 欧美高清dvd| 日韩一卡二卡三卡国产欧美| 欧美一级久久久| 精品国产免费人成在线观看| 2024国产精品| 国产精品午夜在线观看| 亚洲欧美一区二区三区国产精品| 一区二区三区四区国产精品| 亚洲综合色婷婷| 午夜私人影院久久久久| 日韩成人免费在线| 久久99久久99精品免视看婷婷 | 国产一区二区在线电影| 国产乱国产乱300精品| 粉嫩aⅴ一区二区三区四区五区| 粉嫩蜜臀av国产精品网站| 成人app下载| 欧美在线999| 欧美一区二区三区人| 精品人在线二区三区| 亚洲国产精品成人综合| 亚洲美女淫视频| 日韩av在线播放中文字幕| 久久精品理论片| 成人免费av在线| 91久久精品一区二区二区| 欧美精品xxxxbbbb| 欧美变态tickle挠乳网站| 亚洲国产精品成人综合色在线婷婷| 亚洲视频精选在线| 婷婷国产在线综合| 国内精品国产成人| 99九九99九九九视频精品| 精品视频一区二区不卡| 日韩欧美在线网站| 日本一区二区综合亚洲| 一区二区三区不卡在线观看| 日韩不卡一区二区三区| 国产麻豆视频一区| 在线精品国精品国产尤物884a| 日韩精品一区二区三区四区 | 久久久不卡网国产精品一区| 综合婷婷亚洲小说|