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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? enc28j60.c

?? 用于Microchip 16位單片機的通信應用程序庫 1042
?? C
?? 第 1 頁 / 共 5 頁
字號:
#if defined(MAC_FILTER_BROADCASTS)
// NOTE: This code has NOT been tested.  See StackTsk.h's explanation
// of MAC_FILTER_BROADCASTS.
/******************************************************************************
 * Function:        void MACSetPMFilter(BYTE *Pattern, 
 *										BYTE *PatternMask, 
 *										WORD PatternOffset)
 *
 * PreCondition:    SPI bus must be initialized (done in MACInit()).
 * 					MACIsTxReady() must return TRUE
 *
 * Input:           *Pattern: Pointer to an intial pattern to compare against
 *					*PatternMask: Pointer to an 8 byte pattern mask which 
 *								  defines which bytes of the pattern are 
 *								  important.  At least one bit must be set.
 *					PatternOffset: Offset from the beginning of the Ethernet 
 *								   frame (1st byte of destination address), to
 *								   begin comparing with the given pattern.
 *
 * Output:          None
 *
 * Side Effects:    Contents of the TX buffer space are overwritten
 *
 * Overview:        MACSetPMFilter sets the hardware receive filters for: 
 *					CRC AND (Unicast OR Pattern Match).  As a result, only a 
 *					subset of the broadcast packets which are normally 
 *					received will be received.
 *
 * Note:            None
 *****************************************************************************/
void MACSetPMFilter(BYTE *Pattern, 
					BYTE *PatternMask, 
					WORD PatternOffset)
{
	WORD_VAL i;
	BYTE *MaskPtr;
	BYTE UnmaskedPatternLen;
	
	// Set the SPI write pointer and DMA startting address to the beginning of 
	// the transmit buffer
	BankSel(EWRPTL);
	WriteReg(EWRPTL, LOW(TXSTART));
	WriteReg(EWRPTH, HIGH(TXSTART));
	WriteReg(EDMASTL, LOW(TXSTART));
	WriteReg(EDMASTH, HIGH(TXSTART));

	// Fill the transmit buffer with the pattern to match against.  Only the 
	// bytes which have a mask bit of 1 are written into the buffer and will
	// subsequently be used for checksum computation.  
	MaskPtr = PatternMask;
	for(i.Val = 0x0100; i.v[0] < 64; i.v[0]++)
	{
		if( *MaskPtr & i.v[1] )
		{
			MACPut(*Pattern);
			UnmaskedPatternLen++;
		}
		Pattern++;
		
		i.v[1] <<= 1;
		if( i.v[1] == 0u )
		{
			i.v[1] = 0x01;
			MaskPtr++;
		}
	}

	// Calculate and set the DMA end address
	i.Val = TXSTART + (WORD)UnmaskedPatternLen - 1;
	WriteReg(EDMANDL, i.v[0]);
	WriteReg(EDMANDH, i.v[1]);

	// Calculate the checksum on the given pattern using the DMA module
	BFSReg(ECON1, ECON1_DMAST | ECON1_CSUMEN);
	while(ReadETHReg(ECON1).ECON1bits.DMAST);

	// Make certain that the PM filter isn't enabled while it is 
	// being reconfigured.
	BankSel(ERXFCON);
	WriteReg(ERXFCON, ERXFCON_UCEN | ERXFCON_CRCEN | ERXFCON_BCEN);

	// Get the calculated DMA checksum and store it in the PM 
	// checksum registers
	i.v[0] == ReadETHReg(EDMACSL).Val;
	i.v[1] == ReadETHReg(EDMACSH).Val;
	WriteReg(EPMCSL, i.v[0]);
	WriteReg(EPMCSH, i.v[0]);

	// Set the Pattern Match offset and 8 byte mask
	WriteReg(EPMOL, ((WORD_VAL*)&PatternOffset)->v[0]);
	WriteReg(EPMOH, ((WORD_VAL*)&PatternOffset)->v[1]);
	for(i.Val = EPMM0; i.Val <= EPMM7 ; i.Val++)
	{
		WriteReg(i.Val, *PatternMask++);
	}

	// Begin using the new Pattern Match filter instead of the 
	// broadcast filter
	WriteReg(ERXFCON, ERXFCON_UCEN | ERXFCON_CRCEN | ERXFCON_PMEN);
}//end MACSetPMFilter


/******************************************************************************
 * Function:        void MACDisablePMFilter(void)
 *
 * PreCondition:    SPI bus must be initialized (done in MACInit()).
 *
 * Input:           None
 *
 * Output:          None
 *
 * Side Effects:    None
 *
 * Overview:        MACDisablePMFilter disables the Pattern Match receive 
 *					filter (if enabled) and returns to the default filter 
 *					configuration of: CRC AND (Unicast OR Broadcast).
 *
 * Note:            None
 *****************************************************************************/
void MACDisablePMFilter(void)
{
	BankSel(ERXFCON);
	WriteReg(ERXFCON, ERXFCON_UCEN | ERXFCON_CRCEN | ERXFCON_BCEN);
	return;
}//end MACDisablePMFilter
#endif // end of MAC_FILTER_BROADCASTS specific code


/******************************************************************************
 * Function:        BYTE MACGet()
 *
 * PreCondition:    SPI bus must be initialized (done in MACInit()).
 * 					ERDPT must point to the place to read from.
 *
 * Input:           None
 *
 * Output:          Byte read from the ENC28J60's RAM
 *
 * Side Effects:    None
 *
 * Overview:        MACGet returns the byte pointed to by ERDPT and 
 *					increments ERDPT so MACGet() can be called again.  The 
 *					increment will follow the receive buffer wrapping boundary.
 *
 * Note:            None
 *****************************************************************************/
BYTE MACGet()
{
	BYTE Result;

	ENC_CS_IO = 0;
	ENC_SPI_IF = 0;
	ENC_SSPBUF = RBM;
	while(!ENC_SPI_IF);		// Wait until opcode/address is transmitted.
	Result = ENC_SSPBUF;
	ENC_SPI_IF = 0;
	ENC_SSPBUF = 0;				// Send a dummy byte to receive the register 
							//   contents.
	while(!ENC_SPI_IF);		// Wait until register is received.
	Result = ENC_SSPBUF;
	ENC_SPI_IF = 0;
	ENC_CS_IO = 1;

	return Result;
}//end MACGet


/******************************************************************************
 * Function:        WORD MACGetArray(BYTE *val, WORD len)
 *
 * PreCondition:    SPI bus must be initialized (done in MACInit()).
 * 					ERDPT must point to the place to read from.
 *
 * Input:           *val: Pointer to storage location
 *					len:  Number of bytes to read from the data buffer.
 *
 * Output:          Byte(s) of data read from the data buffer.
 *
 * Side Effects:    None
 *
 * Overview:        Burst reads several sequential bytes from the data buffer 
 *					and places them into local memory.  With SPI burst support, 
 *					it performs much faster than multiple MACGet() calls.
 *					ERDPT is incremented after each byte, following the same 
 *					rules as MACGet().
 *
 * Note:            None
 *****************************************************************************/
WORD MACGetArray(BYTE *val, WORD len)
{
	WORD i;
	BYTE Dummy;

	// Start the burst operation
	ENC_CS_IO = 0;
	ENC_SPI_IF = 0;
	ENC_SSPBUF = RBM;			// Send the Read Buffer Memory opcode.
	i = 0;		
	val--;
	while(!ENC_SPI_IF);		// Wait until opcode/address is transmitted.
	Dummy = ENC_SSPBUF;
	ENC_SPI_IF = 0;

	// Read the data
	while(i<len)
	{
		ENC_SSPBUF = 0;			// Send a dummy byte to receive a byte 
		i++;
		val++;
		while(!ENC_SPI_IF);	// Wait until byte is received.
		*val = ENC_SSPBUF;
		ENC_SPI_IF = 0;
	};

	// Terminate the burst operation
	ENC_CS_IO = 1;

	return i;
}//end MACGetArray


/******************************************************************************
 * Function:        void MACPut(BYTE val)
 *
 * PreCondition:    SPI bus must be initialized (done in MACInit()).
 * 					EWRPT must point to the location to begin writing.
 *
 * Input:           Byte to write into the ENC28J60 buffer memory
 *
 * Output:          None
 *
 * Side Effects:    None
 *
 * Overview:        MACPut outputs the Write Buffer Memory opcode/constant 
 *					(8 bits) and data to write (8 bits) over the SPI.  
 *					EWRPT is incremented after the write.
 *
 * Note:            None
 *****************************************************************************/
void MACPut(BYTE val)
{
	BYTE Dummy;

	ENC_CS_IO = 0;
	ENC_SPI_IF = 0;
	ENC_SSPBUF = WBM;			// Send the opcode and constant.
	while(!ENC_SPI_IF);		// Wait until opcode/constant is transmitted.
	Dummy = ENC_SSPBUF;
	ENC_SPI_IF = 0;
	ENC_SSPBUF = val;			// Send the byte to be writen.
	while(!ENC_SPI_IF);		// Wait until byte is transmitted.
	Dummy = ENC_SSPBUF;
	ENC_SPI_IF = 0;
	ENC_CS_IO = 1;
}//end MACPut


/******************************************************************************
 * Function:        void MACPutArray(BYTE *val, WORD len)
 *
 * PreCondition:    SPI bus must be initialized (done in MACInit()).
 * 					EWRPT must point to the location to begin writing.
 *
 * Input:           *val: Pointer to source of bytes to copy.
 *					len:  Number of bytes to write to the data buffer.
 *
 * Output:          None
 *
 * Side Effects:    None
 *
 * Overview:        MACPutArray writes several sequential bytes to the 
 *					ENC28J60 RAM.  It performs faster than multiple MACPut()
 *					calls.  EWRPT is incremented by len.
 *
 * Note:            None
 *****************************************************************************/
void MACPutArray(BYTE *val, WORD len)
{
	BYTE Dummy;

	// Select the chip and send the proper opcode
	ENC_CS_IO = 0;
	ENC_SPI_IF = 0;
	ENC_SSPBUF = WBM;			// Send the Write Buffer Memory opcode
	while(!ENC_SPI_IF);		// Wait until opcode/constant is transmitted.
	Dummy = ENC_SSPBUF;
	ENC_SPI_IF = 0;

	// Send the data
	while(len)
	{
		ENC_SSPBUF = *val;		// Start sending the byte
		val++;				// Increment after writing to ENC_SSPBUF to increase speed
		len--;				// Decrement after writing to ENC_SSPBUF to increase speed
		while(!ENC_SPI_IF);	// Wait until byte is transmitted
		Dummy = ENC_SSPBUF;
		ENC_SPI_IF = 0;
	};

	// Terminate the burst operation
	ENC_CS_IO = 1;
}//end MACPutArray


/******************************************************************************
 * Function:        static void SendSystemReset(void)
 *
 * PreCondition:    SPI bus must be initialized (done in MACInit()).
 *
 * Input:           None
 *
 * Output:          None
 *
 * Side Effects:    None
 *
 * Overview:        SendSystemReset sends the System Reset SPI command to 
 *					the Ethernet controller.  It resets all register contents 
 *					(except for ECOCON) and returns the device to the power 
 *					on default state.
 *
 * Note:            None
 *****************************************************************************/
static void SendSystemReset(void)
{
	BYTE Dummy;

	ENC_CS_IO = 0;
	ENC_SPI_IF = 0;
	ENC_SSPBUF = SR;
	while(!ENC_SPI_IF);		// Wait until the command is transmitted.
	Dummy = ENC_SSPBUF;
	ENC_SPI_IF = 0;
	ENC_CS_IO = 1;
}//end SendSystemReset


/******************************************************************************
 * Function:        REG ReadETHReg(BYTE Address)
 *
 * PreCondition:    SPI bus must be initialized (done in MACInit()).
 * 					Bank select bits must be set corresponding to the register 
 * 					to read from.
 *
 * Input:           5 bit address of the ETH control register to read from.
 *					  The top 3 bits must be 0.
 *
 * Output:          Byte read from the Ethernet controller's ETH register.
 *
 * Side Effects:    None
 *
 * Overview:        ReadETHReg sends the 8 bit RCR opcode/Address byte over 
 *					the SPI and then retrives the register contents in the 
 *					next 8 SPI clocks.
 *
 * Note:            This routine cannot be used to access MAC/MII or PHY 
 *					registers.  Use ReadMACReg() or ReadPHYReg() for that 
 *					purpose.  
 *****************************************************************************/
static REG ReadETHReg(BYTE Address)
{
	REG r;

	// Select the chip and send the Read Control Register opcode/address
	ENC_CS_IO = 0;
	ENC_SPI_IF = 0;
	ENC_SSPBUF = RCR | Address;	
		
	while(!ENC_SPI_IF);		// Wait until the opcode/address is transmitted
	r.Val = ENC_SSPBUF;
	ENC_SPI_IF = 0;
	ENC_SSPBUF = 0;				// Send a dummy byte to receive the register 
							//   contents
	while(!ENC_SPI_IF);		// Wait until the register is received
	r.Val = ENC_SSPBUF;
	ENC_SPI_IF = 0;
	ENC_CS_IO = 1;

	return r;
}//end ReadETHReg


/******************************************************************************
 * Function:        REG ReadMACReg(BYTE Address)
 *
 * PreCondition:    SPI bus must be initialized (done in MACInit()).
 * 					Bank select bits must be set corresponding to the register 
 * 					to read from.
 *
 * Input:           5 bit address of the MAC or MII register to read from.
 *					  The top 3 bits must be 0.
 *
 * Output:          Byte read from the Ethernet controller's MAC/MII register.
 *
 * Side Effects:    None
 *
 * Overview:        ReadMACReg sends the 8 bit RCR opcode/Address byte as well 
 *					as a dummy byte over the SPI and then retrives the 

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91精品一区二区三区久久久久久 | 国产精品99久久久久久有的能看 | 日韩三级高清在线| 欧美日韩一二三| av在线综合网| 91丝袜高跟美女视频| eeuss国产一区二区三区| 国产精品性做久久久久久| 免费一级欧美片在线观看| 麻豆免费看一区二区三区| 蜜臂av日日欢夜夜爽一区| 麻豆精品新av中文字幕| 国产一区二区在线影院| 国产精品一区二区91| av一二三不卡影片| 91一区二区在线观看| 欧美视频一区二| 91精品国模一区二区三区| 精品欧美黑人一区二区三区| 日本一区二区成人| 一区二区三区视频在线观看| 日本成人超碰在线观看| 国产在线不卡一区| 福利一区二区在线观看| 国产精品一区专区| 成人av在线网站| 在线综合视频播放| 国产精品毛片高清在线完整版| 一色桃子久久精品亚洲| 一区二区三区精品| 国产精品一区2区| 欧美日韩国产综合久久| 日韩亚洲欧美在线| 中文字幕电影一区| 蜜臀av性久久久久蜜臀aⅴ流畅 | 日韩福利电影在线观看| 岛国精品在线播放| 欧美一级二级在线观看| 亚洲精品欧美激情| 免费的国产精品| 欧美理论电影在线| 国产日韩欧美精品电影三级在线 | 亚洲18色成人| 国产91精品露脸国语对白| 国产一区二区三区免费观看| 91久久精品日日躁夜夜躁欧美| 久久精品一二三| 国产成人aaa| 中文字幕一区二区三区av| 成人精品一区二区三区四区| 国产精品久久久久久久裸模| 风间由美性色一区二区三区| 国产精品久久久久久久第一福利 | 免费在线一区观看| 精品国精品自拍自在线| 国产成人啪免费观看软件| 久久久久久9999| 91在线一区二区| 视频一区二区三区在线| 久久久99久久| 欧美主播一区二区三区| 麻豆国产精品一区二区三区 | 亚洲日本在线a| 欧美日韩国产高清一区二区| 久久精品久久久精品美女| 国产欧美一区二区精品婷婷| 91极品视觉盛宴| 韩国欧美国产1区| 亚洲在线免费播放| 欧美国产日本韩| 欧美日韩激情在线| 国产盗摄一区二区| 伊人夜夜躁av伊人久久| 欧美夫妻性生活| 成人av网站在线观看| 美日韩一区二区三区| 国产精品传媒视频| 欧美精品一区二区三区很污很色的| 色综合激情久久| 成人动漫视频在线| 蜜臀av亚洲一区中文字幕| 亚洲小说欧美激情另类| 亚洲国产高清在线| 久久综合av免费| 欧美一个色资源| 欧美日本免费一区二区三区| 99riav久久精品riav| 成人一级视频在线观看| 激情av综合网| 美女尤物国产一区| 国产精品麻豆欧美日韩ww| 久久婷婷国产综合国色天香| 欧美日本国产视频| 在线免费视频一区二区| 91丨porny丨首页| 色哟哟欧美精品| 成人高清视频免费观看| 日韩不卡一区二区| 日韩av中文字幕一区二区三区| 亚洲精品日韩一| 亚洲妇女屁股眼交7| 国产精品激情偷乱一区二区∴| 国产欧美一区二区三区沐欲| 国产欧美一区二区在线| 中文字幕在线不卡一区二区三区| 国产欧美日韩麻豆91| 亚洲区小说区图片区qvod| 一区二区三区国产| 午夜国产精品一区| 久久99日本精品| 成人天堂资源www在线| 色婷婷综合久久久中文字幕| 欧美日韩精品一区二区三区四区| 在线播放日韩导航| 久久久久久电影| 夜夜操天天操亚洲| 九一九一国产精品| 99re亚洲国产精品| 精品剧情在线观看| 亚洲视频 欧洲视频| 亚瑟在线精品视频| 国产高清成人在线| 欧美日韩精品专区| 国产欧美日韩麻豆91| 亚洲成人一区二区| 波多野结衣亚洲| 日韩欧美色综合网站| 1区2区3区欧美| 国产精品一区二区在线看| 91豆麻精品91久久久久久| 国产日韩v精品一区二区| 亚洲va天堂va国产va久| 成人午夜电影久久影院| 3d动漫精品啪啪一区二区竹菊| 国产精品久久久久久福利一牛影视| 亚洲成a人片在线不卡一二三区| 东方aⅴ免费观看久久av| 欧美一级搡bbbb搡bbbb| 亚洲影视在线观看| 北岛玲一区二区三区四区| 久久奇米777| 国产一区二区日韩精品| 91精品国产色综合久久不卡电影| 综合av第一页| 日本电影欧美片| 136国产福利精品导航| 国产不卡高清在线观看视频| xfplay精品久久| 久久91精品国产91久久小草| 欧美日韩视频第一区| 亚洲综合区在线| 欧美最猛性xxxxx直播| 一区二区三区91| 欧美三级视频在线| 国产激情91久久精品导航| 色婷婷久久久综合中文字幕| 欧美一级黄色片| 国产精品毛片无遮挡高清| 日本欧美一区二区| 欧美日韩在线一区二区| 中文字幕在线观看一区二区| 亚洲一区中文日韩| 成人毛片在线观看| 国产精品每日更新| 日本道在线观看一区二区| 一区二区三区视频在线看| 91同城在线观看| 午夜激情一区二区| 欧美大片一区二区| 国产老妇另类xxxxx| 综合亚洲深深色噜噜狠狠网站| 99精品偷自拍| 最近日韩中文字幕| 成人美女视频在线观看| 亚洲一区二区在线播放相泽| 正在播放一区二区| 国产在线视频精品一区| 国产精品不卡在线观看| 欧美老肥妇做.爰bbww视频| 精品一区二区三区影院在线午夜 | 久久奇米777| 在线视频你懂得一区| 久久精品国产亚洲一区二区三区 | 久久美女艺术照精彩视频福利播放| 粉嫩绯色av一区二区在线观看| 一区二区三区四区不卡在线| 精品国产伦一区二区三区观看方式| 99国产精品久久久久| 狂野欧美性猛交blacked| 亚洲美女一区二区三区| 精品久久五月天| 欧美精品亚洲一区二区在线播放| 国产精品小仙女| 日韩国产欧美一区二区三区| 亚洲色图视频免费播放| 久久久美女毛片| 欧美岛国在线观看| 91精品国产综合久久久蜜臀图片| 北条麻妃一区二区三区| 国产99精品在线观看|