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

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

?? enc28j60.c

?? 用于Microchip 16位單片機的通信應(yīng)用程序庫 1042
?? C
?? 第 1 頁 / 共 5 頁
字號:
			BFCReg(ECON1, ECON1_TXRTS);

			// Save the current read pointer (controlled by application)
			BankSel(ERDPTL);
			ReadPtrSave.v[0] = ReadETHReg(ERDPTL).Val;
			ReadPtrSave.v[1] = ReadETHReg(ERDPTH).Val;

			// Get the location of the transmit status vector
			TXEnd.v[0] = ReadETHReg(ETXNDL).Val;
			TXEnd.v[1] = ReadETHReg(ETXNDH).Val;
			TXEnd.Val++;
			
			// Read the transmit status vector
			WriteReg(ERDPTL, TXEnd.v[0]);
			WriteReg(ERDPTH, TXEnd.v[1]);
			MACGetArray((BYTE*)&TXStatus, sizeof(TXStatus));

			// Implement retransmission if a late collision occured (this can 
			// happen on B5 when certain link pulses arrive at the same time 
			// as the transmission)
			for(i = 0; i < 16; i++)
			{
				if(ReadETHReg(EIR).EIRbits.TXERIF && TXStatus.bits.LateCollision)
				{
					// Reset the TX logic
					BFSReg(ECON1, ECON1_TXRST);
					BFCReg(ECON1, ECON1_TXRST);
					BFCReg(EIR, EIR_TXERIF | EIR_TXIF);

					// Transmit the packet again
					BFSReg(ECON1, ECON1_TXRTS);
					while(!(ReadETHReg(EIR).Val & (EIR_TXERIF | EIR_TXIF)));

					// Cancel the previous transmission if it has become stuck set
					BFCReg(ECON1, ECON1_TXRTS);

					// Read transmit status vector
					WriteReg(ERDPTL, TXEnd.v[0]);
					WriteReg(ERDPTH, TXEnd.v[1]);
					MACGetArray((BYTE*)&TXStatus, sizeof(TXStatus));
				}
				else
				{
					break;
				}
			}

			// Restore the current read pointer
			WriteReg(ERDPTL, ReadPtrSave.v[0]);
			WriteReg(ERDPTH, ReadPtrSave.v[1]);
		}
	}
}


/******************************************************************************
 * Function:        void MACSetRxBuffer(WORD offset)
 *
 * PreCondition:    A packet has been obtained by calling MACGetHeader() and 
 *					getting a TRUE result.
 *
 * Input:           offset: WORD specifying how many bytes beyond the Ethernet 
 *							header's type field to relocate the SPI read and 
 *							write pointers.
 *
 * Output:          None
 *
 * Side Effects:    None
 *
 * Overview:        SPI read and write pointers are updated.  All calls to 
 *					MACGet(), MACPut(), MACGetArray(), and MACPutArray(), 
 *					and various other functions will use these new values.
 *
 * Note:			RXSTOP must be statically defined as being > RXSTART for 
 *					this function to work correctly.  In other words, do not 
 *					define an RX buffer which spans the 0x1FFF->0x0000 memory
 *					boundary.
 *****************************************************************************/
void MACSetRxBuffer(WORD offset)
{
	WORD_VAL ReadPT;

	// Determine the address of the beginning of the entire packet
	// and adjust the address to the desired location
	ReadPT.Val = CurrentPacketLocation.Val + sizeof(ENC_PREAMBLE) + offset;
	
	// Since the receive buffer is circular, adjust if a wraparound is needed
	if ( ReadPT.Val > RXSTOP )
		ReadPT.Val -= RXSIZE;
	
	// Set the SPI read and write pointers to the new calculated value
	BankSel(ERDPTL);
	WriteReg(ERDPTL, ReadPT.v[0]);
	WriteReg(ERDPTH, ReadPT.v[1]);
	WriteReg(EWRPTL, ReadPT.v[0]);
	WriteReg(EWRPTH, ReadPT.v[1]);
}


/******************************************************************************
 * Function:        void MACSetTxBuffer(BUFFER buffer, WORD offset)
 *
 * PreCondition:    None
 *
 * Input:           buffer: BYTE specifying which transmit buffer to seek 
 *							within.  If MAC_TX_BUFFER_COUNT <= 1, this 
 *							parameter is not used.
 *					offset: WORD specifying how many bytes beyond the Ethernet 
 *							header's type field to relocate the SPI read and 
 *							write pointers.
 *
 * Output:          None
 *
 * Side Effects:    None
 *
 * Overview:        SPI read and write pointers are updated.  All calls to 
 *					MACGet(), MACPut(), MACGetArray(), and MACPutArray(), 
 *					and various other functions will use these new values.
 *
 * Note:			None
 *****************************************************************************/
void MACSetTxBuffer(BUFFER buffer, WORD offset)
{
    CurrentTxBuffer = buffer;

	// Calculate the proper address.  Since the TX memory area is not circular,
	// no wrapparound checks are necessary. +1 adjustment is needed because of 
	// the per packet control byte which preceeds the packet in the TX memory 
	// area.
#if MAC_TX_BUFFER_COUNT > 1
	offset += TxBuffers[buffer].StartAddress.Val + 1 + sizeof(ETHER_HEADER);
#else
	offset += TXSTART + 1 + sizeof(ETHER_HEADER);
#endif

	// Set the SPI read and write pointers to the new calculated value
	BankSel(EWRPTL);
	WriteReg(ERDPTL, ((WORD_VAL*)&offset)->v[0]);
	WriteReg(ERDPTH, ((WORD_VAL*)&offset)->v[1]);
	WriteReg(EWRPTL, ((WORD_VAL*)&offset)->v[0]);
	WriteReg(EWRPTH, ((WORD_VAL*)&offset)->v[1]);
}


#if defined(MCHP_MAC)
// MACCalcRxChecksum() and MACCalcTxChecksum() use the DMA module to calculate
// checksums.  These two functions have been tested.
/******************************************************************************
 * Function:        WORD MACCalcRxChecksum(WORD offset, WORD len)
 *
 * PreCondition:    None
 *
 * Input:           offset	- Number of bytes beyond the beginning of the 
 *							Ethernet data (first byte after the type field) 
 *							where the checksum should begin
 *					len		- Total number of bytes to include in the checksum
 *
 * Output:          16-bit checksum as defined by rfc 793.
 *
 * Side Effects:    None
 *
 * Overview:        This function performs a checksum calculation in the MAC
 *                  buffer itself using the hardware DMA module
 *
 * Note:            None
 *****************************************************************************/
WORD MACCalcRxChecksum(WORD offset, WORD len)
{
	WORD_VAL temp;

	// Add the offset requested by firmware plus the Ethernet header
	temp.Val = CurrentPacketLocation.Val + sizeof(ENC_PREAMBLE) + offset;
	if ( temp.Val > RXSTOP )		// Adjust value if a wrap is needed
	{
		temp.Val -= RXSIZE;
	}
	// Program the start address of the DMA
	BankSel(EDMASTL);
	WriteReg(EDMASTL, temp.v[0]);
	WriteReg(EDMASTH, temp.v[1]);

	// Calculate the end address, given the start address and len
	temp.Val += len-1;
	if ( temp.Val > RXSTOP )		// Adjust value if a wrap is needed
	{
		temp.Val -= RXSIZE;
	}
	// Program the end address of the DMA
	WriteReg(EDMANDL, temp.v[0]);
	WriteReg(EDMANDH, temp.v[1]);
	
	// Calculate the checksum using the DMA device
	BFSReg(ECON1, ECON1_DMAST | ECON1_CSUMEN);
	while(ReadETHReg(ECON1).ECON1bits.DMAST);

	// Swap endianness and return
	temp.v[1] = ReadETHReg(EDMACSL).Val;
	temp.v[0] = ReadETHReg(EDMACSH).Val;

	return temp.Val;
}


/******************************************************************************
 * Function:        WORD MACCalcTxChecksum(WORD offset, WORD len)
 *
 * PreCondition:    None
 *
 * Input:           offset	- Number of bytes beyond the beginning of the 
 *							Ethernet data (first byte after the type field) 
 *							where the checksum should begin
 *					len		- Total number of bytes to include in the checksum
 *
 * Output:          16-bit checksum as defined by rfc 793.
 *
 * Side Effects:    None
 *
 * Overview:        This function performs a checksum calculation in the MAC
 *                  buffer itself using the hardware DMA module
 *
 * Note:            None
 *****************************************************************************/
WORD MACCalcTxChecksum(WORD offset, WORD len)
{
	WORD_VAL temp;

	// Program the start address of the DMA, after adjusting for the Ethernet 
	// header
#if MAC_TX_BUFFER_COUNT > 1
	temp.Val = TxBuffers[CurrentTxBuffer].StartAddress.Val + sizeof(ETHER_HEADER)
				+ offset + 1;	// +1 needed to account for per packet control byte
#else
	temp.Val = TXSTART + sizeof(ETHER_HEADER)
				+ offset + 1;	// +1 needed to account for per packet control byte
#endif
	BankSel(EDMASTL);
	WriteReg(EDMASTL, temp.v[0]);
	WriteReg(EDMASTH, temp.v[1]);
	
	// Program the end address of the DMA.
	temp.Val += len-1;
	WriteReg(EDMANDL, temp.v[0]);
	WriteReg(EDMANDH, temp.v[1]);
	
    // Calcualte the checksum using the DMA device
	BFSReg(ECON1, ECON1_DMAST | ECON1_CSUMEN);
	while(ReadETHReg(ECON1).ECON1bits.DMAST);

	// Swap endianness and return
	temp.v[1] = ReadETHReg(EDMACSL).Val;
	temp.v[0] = ReadETHReg(EDMACSH).Val;

	return temp.Val;
}


/******************************************************************************
 * Function:        WORD CalcIPBufferChecksum(WORD len)
 *
 * PreCondition:    Read buffer pointer set to starting of checksum data
 *
 * Input:           len: Total number of bytes to calculate the checksum over. 
 *						 The first byte included in the checksum is the byte 
 *						 pointed to by ERDPT, which is updated by calls to 
 *						 MACGet(), MACSetRxBuffer(), MACSetTxBuffer(), etc.
 *
 * Output:          16-bit checksum as defined by rfc 793.
 *
 * Side Effects:    None
 *
 * Overview:        This function performs a checksum calculation in the MAC
 *                  buffer itself.  The ENC28J60 has a hardware DMA module 
 *					which can calculate the checksum faster than software, so 
 *					this function replaces the CaclIPBufferChecksum() function 
 *					defined in the helpers.c file.  Through the use of 
 *					preprocessor defines, this replacement is automatic.
 *
 * Note:            This function works either in the RX buffer area or the TX
 *					buffer area.  No validation is done on the len parameter.
 *****************************************************************************/
WORD CalcIPBufferChecksum(WORD len)
{
	WORD_VAL temp;

	// Take care of special cases which the DMA cannot be used for
	if(len == 0u)
	{
		return 0xFFFF;
	}
	else if(len == 1u)
	{
		return ~(((WORD)MACGet())<<8);
	}
		

	// Set the DMA starting address to the SPI read pointer value
	BankSel(ERDPTL);
	temp.v[0] = ReadETHReg(ERDPTL).Val;
	temp.v[1] = ReadETHReg(ERDPTH).Val;
	WriteReg(EDMASTL, temp.v[0]);
	WriteReg(EDMASTH, temp.v[1]);
	
	// See if we are calculating a checksum within the RX buffer (where 
	// wrapping rules apply) or TX/unused area (where wrapping rules are 
	// not applied)
#if RXSTART == 0
	if(temp.Val <= RXSTOP)
#else
	if(temp.Val >= RXSTART && temp.Val <= RXSTOP)
#endif
	{
		// Calculate the DMA ending address given the starting address and len 
		// parameter.  The DMA will follow the receive buffer wrapping boundary.
		temp.Val += len-1;
		if(temp.Val > RXSTOP)
		{
			temp.Val -= RXSIZE;
		}
	}
	else
	{
		temp.Val += len-1;
	}	

	// Write the DMA end address
	WriteReg(EDMANDL, temp.v[0]);
	WriteReg(EDMANDH, temp.v[1]);
	
	// Begin the DMA checksum calculation and wait until it is finished
	BFSReg(ECON1, ECON1_DMAST | ECON1_CSUMEN);
	while(ReadETHReg(ECON1).ECON1bits.DMAST);

	// Return the resulting good stuff
	temp.v[0] = ReadETHReg(EDMACSL).Val;
	temp.v[1] = ReadETHReg(EDMACSH).Val;
	return temp.Val;
}
#endif	// End of MCHP_MAC specific code


/******************************************************************************
 * Function:        void MACCopyRxToTx(WORD RxOffset, WORD TxOffset, WORD len)
 *
 * PreCondition:    None
 *
 * Input:           RxOffset: Offset in the RX buffer (0=first byte of 
 * 							  destination MAC address) to copy from.
 *					TxOffset: Offset in the TX buffer (0=first byte of
 *							  destination MAC address) to copy to.
 *					len:	  Number of bytes to copy
 *
 * Output:          None
 *
 * Side Effects:    None
 *
 * Overview:        If the TX logic is transmitting a packet (ECON1.TXRTS is 
 *					set), the hardware will wait until it is finished.  Then, 
 *					the DMA module will copy the data from the receive buffer 
 *					to the transmit buffer.
 *
 * Note:            None
 *****************************************************************************/
// Remove this line if your application needs to use this 
// function.  This code has NOT been tested.
#if 0 
void MACCopyRxToTx(WORD RxOffset, WORD TxOffset, WORD len)
{
	WORD_VAL temp;

	temp.Val = CurrentPacketLocation.Val + RxOffset + sizeof(ENC_PREAMBLE);
	if ( temp.Val > RXSTOP )		// Adjust value if a wrap is needed
		temp.Val -= RXSIZE;

	BankSel(EDMASTL);
	WriteReg(EDMASTL, temp.v[0]);
	WriteReg(EDMASTH, temp.v[1]);

	temp.Val += len-1;
	if ( temp.Val > RXSTOP )		// Adjust value if a wrap is needed
		temp.Val -= RXSIZE;

	WriteReg(EDMANDL, temp.v[0]);
	WriteReg(EDMANDH, temp.v[1]);
	
	TxOffset += TXSTART+1;
	WriteReg(EDMADSTL, ((WORD_VAL*)&TxOffset)->v[0]);
	WriteReg(EDMADSTH, ((WORD_VAL*)&TxOffset)->v[1]);
	
	// Do the DMA Copy.  The DMA module will wait for TXRTS to become clear 
	// before starting the copy.
	BFCReg(ECON1, ECON1_CSUMEN);
	BFSReg(ECON1, ECON1_DMAST);
	while(ReadETHReg(ECON1).ECON1bits.DMAST);
}
#endif


?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品一区二区av| 精品99一区二区三区| 国产二区国产一区在线观看| 青青草97国产精品免费观看| 日韩av一区二区三区四区| 天天亚洲美女在线视频| 亚洲v日本v欧美v久久精品| 亚洲欧美日韩电影| 亚洲一区二区三区四区不卡| 亚洲综合在线视频| 亚洲一区二区三区在线看| 亚洲影院在线观看| 亚洲不卡在线观看| 日韩精品一二三| 久久99精品国产91久久来源| 国内精品久久久久影院一蜜桃| 韩国v欧美v日本v亚洲v| 国产精品一二三区| 成人的网站免费观看| 91日韩精品一区| 在线观看一区二区视频| 精品视频资源站| 日韩一区二区免费在线观看| 久久亚区不卡日本| 国产精品久久看| 一级做a爱片久久| 日韩成人午夜电影| 狠狠色综合日日| 成人精品免费网站| 在线影院国内精品| 3751色影院一区二区三区| 日韩精品资源二区在线| 久久久精品影视| 亚洲免费观看高清完整版在线观看| 亚洲国产精品一区二区久久恐怖片| 日本在线播放一区二区三区| 国产毛片精品视频| 91丨porny丨蝌蚪视频| 欧美日韩激情一区二区三区| 欧美www视频| 国产精品成人在线观看| 亚洲成av人片观看| 国产精品羞羞答答xxdd| 欧美在线免费观看亚洲| 欧美电影免费提供在线观看| 国产精品拍天天在线| 亚洲国产成人高清精品| 国产电影一区在线| 欧美日韩午夜精品| 久久久久久99精品| 亚洲综合在线免费观看| 国产一区二区三区精品欧美日韩一区二区三区 | 国产综合久久久久影院| 一本色道久久加勒比精品| 亚洲精品在线电影| 亚洲综合成人网| 国产成人免费在线视频| 欧美高清激情brazzers| 国产精品国产成人国产三级| 亚洲sss视频在线视频| 成人av在线资源网站| 欧美一区二区三区白人| 国产精品超碰97尤物18| 狠狠色综合日日| 欧美三级在线播放| 国产精品伦一区| 国内精品免费在线观看| 欧美男男青年gay1069videost| 国产精品色哟哟网站| 精品中文av资源站在线观看| 欧美日韩精品一区二区| 中文字幕一区二区三区不卡在线| 另类小说图片综合网| 欧洲一区二区三区在线| 国产精品理伦片| 国产麻豆9l精品三级站| 欧美精品九九99久久| 亚洲嫩草精品久久| 成人午夜又粗又硬又大| 精品免费一区二区三区| 婷婷久久综合九色国产成人| 91玉足脚交白嫩脚丫在线播放| 久久婷婷国产综合国色天香| 五月婷婷另类国产| 91高清视频在线| 亚洲视频中文字幕| 不卡av在线免费观看| 久久精品视频网| 久99久精品视频免费观看| 欧美卡1卡2卡| 亚洲国产一区视频| 色噜噜狠狠成人网p站| 亚洲欧美在线视频观看| 国产成人免费网站| 久久久久久久久久久电影| 精久久久久久久久久久| 日韩你懂的在线播放| 日韩经典中文字幕一区| 欧美精品成人一区二区三区四区| 亚洲成人av免费| 欧美人狂配大交3d怪物一区| 伊人色综合久久天天| 91美女片黄在线| 亚洲女人的天堂| 91福利国产精品| 亚洲第一搞黄网站| 69p69国产精品| 日本中文在线一区| 欧美videofree性高清杂交| 精品午夜久久福利影院| 欧美精品一区二区三区久久久| 麻豆国产精品官网| 亚洲精品在线观看视频| 国产寡妇亲子伦一区二区| 国产欧美日韩另类视频免费观看| 成人综合婷婷国产精品久久蜜臀| 国产精品久久久久久久久搜平片| 波多野结衣欧美| 一区二区三区国产豹纹内裤在线| 欧美性大战久久久| 肉丝袜脚交视频一区二区| 日韩欧美国产精品一区| 国产精品1区2区| 国产精品美女久久福利网站| 91小视频免费观看| 亚洲电影在线播放| 欧美一级欧美一级在线播放| 黑人巨大精品欧美黑白配亚洲| 国产日韩影视精品| 99综合影院在线| 亚洲电影中文字幕在线观看| 日韩免费在线观看| 成人禁用看黄a在线| 亚洲在线视频免费观看| 日韩欧美视频在线| 国产91精品在线观看| 亚洲靠逼com| 日韩欧美一区二区视频| 成人综合婷婷国产精品久久| 亚洲影视在线观看| 日韩欧美国产1| www.欧美亚洲| 天天操天天综合网| 国产日产欧美一区二区三区 | 国产日产欧美精品一区二区三区| 色综合天天综合网天天看片| 男人的j进女人的j一区| 欧美国产日韩a欧美在线观看| 在线观看不卡一区| 久久97超碰国产精品超碰| 综合在线观看色| 日韩精品一区二区三区中文精品| 成人一区在线看| 免费成人性网站| 亚洲欧洲成人精品av97| 精品国产乱码久久久久久浪潮 | 日韩午夜中文字幕| av一区二区三区在线| 日本欧美肥老太交大片| 国产精品的网站| 欧美xxxx老人做受| 色婷婷激情一区二区三区| 国产精品一区专区| 天天综合网天天综合色| 国产精品电影院| 久久影音资源网| 欧美疯狂性受xxxxx喷水图片| eeuss鲁一区二区三区| 人人爽香蕉精品| 亚洲自拍与偷拍| 国产精品理论在线观看| 精品久久久久一区二区国产| 精品视频123区在线观看| 不卡的电视剧免费网站有什么| 美女一区二区三区在线观看| 亚洲乱码国产乱码精品精98午夜| 久久精品一区蜜桃臀影院| 欧美精品一二三| 一本一道久久a久久精品综合蜜臀 一本一道综合狠狠老 | 亚洲成人动漫在线免费观看| 中文久久乱码一区二区| 久久综合九色综合欧美亚洲| 7878成人国产在线观看| 在线观看亚洲一区| 99精品视频在线播放观看| 国产精品综合一区二区三区| 青青草国产成人99久久| 婷婷久久综合九色国产成人| 一区二区三区欧美日| 亚洲天堂成人网| 国产精品欧美一级免费| 久久美女艺术照精彩视频福利播放| 制服.丝袜.亚洲.另类.中文| 欧美丝袜自拍制服另类| 色婷婷综合久久久中文一区二区| va亚洲va日韩不卡在线观看| 国产成人免费在线视频| 国产成人综合网| 国产成人小视频| 成人黄页毛片网站|