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

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

?? softuart.c

?? c8051f020單片機以太網串口通信
?? C
?? 第 1 頁 / 共 2 頁
字號:
// is transmitted or received. 
// - Checks module 1 interrupt flag (CCF1); if set, services receive state.
// - Checks module 0 interrupt flag (CCF0); if set, services transmit state.
// - Checks module 3 interrupt flag (CCF3); if set, services receive state.
// - Checks module 2 interrupt flag (CCF2); if set, services transmit state.
//
void	PCA_ISR(void) interrupt 9 
{
	static char 	SUTXST0 = 0;		// SW_UART TX state variable
	static char 	SURXST0 = 0;		// SW_UART RX state variable
	static unsigned char 	RXSHIFT0;	// SW_UART RX Shift Register
	
	unsigned int	PCA_TEMP0;		// Temporary storage variable for manipulating PCA module high & low bytes.	
							// Check receive interrupt flag first; service if CCF0 is set.

	static char 	SUTXST1 = 0;		// SW_UART TX state variable
	static char 	SURXST1 = 0;		// SW_UART RX state variable
	static unsigned char 	RXSHIFT1;	// SW_UART RX Shift Register
	
	unsigned int	PCA_TEMP1;		// Temporary storage variable for manipulating PCA module high & low bytes.	
							// Check receive interrupt flag first; service if CCF0 is set.


	if (CCF1){
		CCF1 = 0;					// Clear interrupt flag.
		switch (SURXST0){
			// State 0: START bit received.
			// In this state, a negative edge on SW_TX has caused the interrupt,
			// meaning a START has been detected and the PCA0CP0 registers have 
			// captured the value of PCA0.
			// - Check for receive enable and good START bit
			// - Switch PCA module 0 to software timer mode
			// - Add 3/2 bit time to module 0 capture registers to sample LSB.
			// - Increment RX state variable.
			case 0:
				if (SREN0 & ~SW_RX0){				// Check for receive enable and a good START bit.  
																
					PCA_TEMP0 = (PCA0CPH1 << 8);	// Read module 0 contents into
					PCA_TEMP0 |= PCA0CPL1;		// PCA_TEMP.
					PCA_TEMP0 += UART2_STARTTIME;// Add 3/2 bit times to PCA_TEMP
					PCA0CPL1 = PCA_TEMP0;		// Restore PCA0CPL0 and PCA0CPH0
					PCA0CPH1 = (PCA_TEMP0 >> 8);	// with the updated value
					PCA0CPM1 = 0x49;			// Change module 0 to software timer mode, interrupts enabled.
					SURXST0++;					// Update RX state variable.
				}
				break;
			// States 1-8: Bit Received
			// - Sample SW_RX pin
			// - Shift new bit into RXSHIFT
			// - Add 1 bit time to module 0 capture registers
			// - Increment RX state variable
			case 1:
			case 2:
			case 3:
			case 4:
			case 5:
			case 6:
			case 7:
			case 8:
				RXSHIFT0 = RXSHIFT0 >> 1;			// Shift right 1 bit
				if (SW_RX0)						// If SW_RX=1, 
					RXSHIFT0 |= 0x80;			// shift '1' into RXSHIFT msb
				PCA_TEMP0 = (PCA0CPH1 << 8);		// Read module 0 contents into
				PCA_TEMP0 |= PCA0CPL1;			// PCA_TEMP.
				PCA_TEMP0 += UART2_TIMER;			// Add 1 bit time to PCA_TEMP
				PCA0CPL1 = PCA_TEMP0;			// Restore PCA0CPL0 and PCA0CPH0
				PCA0CPH1 = (PCA_TEMP0 >> 8);		// with the updated value
				SURXST0++;						// Update RX state variable.
				break;
			// State 9: 8-bits received, Capture STOP bit.
			// - Move RXSHIFT into RDR.
			// - Set SRI (indicate receive complete).
			// - Prepare module 0 for next transfer.
			// - Reset RX state variable.
			// - Trigger IE7 if user-level interrupt support is enabled.
			case 9:
				RDR0 = RXSHIFT0;					// Move received data to receive register.
				SRI0 = 1;						// Set receive complete indicator.
				PCA0CPM1 = 0x11;				// Switch module 0 to negative capture
												// mode; interrupt enabled for START detection.
				SURXST0 = 0;						// Reset RX state variable.
				if (SES0){						// If user-level interrupt support enabled
					EIE2 |= 0x20;				// Enable IE7.
					P3IF |= 0x80;				// Trigger IE7.
				}
				break;
			}
		}
		// Check Transmit interrupt; service if CCF1 is set.
		else if (CCF0){ 
			CCF0 = 0;							// Clear interrupt flag
			switch (SUTXST0){
				// State 0: Transmit Initiated.
				// Here, the user has loaded a byte to transmit into TDR, and set the
				// module 1 interrupt to initiate the transfer.
				// - Transmit START bit (drop SW_TX)
				// - Read PCA0, add one bit time, & store in module 1 capture registers
				//   for first bit.
				// - Increment TX state variable.
				case 0:
					SW_TX0 = 0;					// Drop TX pin as START bit.
					PCA_TEMP0 = PCA0L;			// Read PCA counter value into
					PCA_TEMP0 |= (PCA0H << 8);	// PCA_TEMP.
					PCA_TEMP0 += UART2_TIMER;		// Add 1 bit time.
					PCA0CPL0 = PCA_TEMP0;		// Store updated match value into
					PCA0CPH0 = (PCA_TEMP0 >> 8);	// module 1 capture/compare registers.
					PCA0CPM0 |= 0x48;			// Enable module 1 software timer.
					SUTXST0++;					// Update TX state variable.				
					break;
				// States 1-9: Transmit Bit.
				// - Output LSB of TDR onto TX
				// - Shift TDR 1 bit right.
				// - Shift a '1' into MSB of TDR for STOP bit in State 9.
				// - Add 1 bit time to module 1 capture register
				case 1:
				case 2:
				case 3:
				case 4:
				case 5:
				case 6:
				case 7:
				case 8:
				case 9:
					SW_TX0 = (TDR0 & 0x01);		// Output LSB of TDR onto SW_TX pin.
					TDR0 >>= 1;					// Shift TDR right 1 bit.
					TDR0 |= 0x80;				// Shift '1' into MSB of TDR for
												// STOP bit in State 9.
					PCA_TEMP0 = (PCA0CPH0 << 8);	// Read module 1 contents into
					PCA_TEMP0 |= PCA0CPL0;		// PCA_TEMP.
					PCA_TEMP0 += UART2_TIMER;		// Add 1 bit time to PCA_TEMP
					PCA0CPL0 = PCA_TEMP0;		// Restore PCA0CPL1 and PCA0CPH1
					PCA0CPH0 = (PCA_TEMP0 >> 8);	// with the updated value	
					SUTXST0++;                   // Update TX state variable.
					break;
				// State 10: Last bit has been transmitted.  Transmit STOP bit
				// and end transfer.  
				// - Transmit STOP bit
				// - Set TX Complete indicator, clear Busy flag
				// - Reset TX state
				// - Prepare module 1 for next transfer.
				// - Trigger IE7 interrupt if user-level interrupts enabled.
				case 10:
					STI0 = 1;					// Indicate TX complete.
					SUTXST0 = 0;					// Reset TX state.
					SW_TX0 = 1;					// SW_TX should remain high.
					PCA0CPM0 = 0x01;			// Disable module 1 software timer; leave
												// interrupt enabled for next transmit.					
					if (SES0){					// If user-level interrupt support enabled:
						EIE2 |= 0x20;			// Enable IE7.
						P3IF |= 0x80;			// Trigger IE7.
					}
					STXBSY0 = 0;					// SW_UART TX free.	
					break;
				}
		}
//第二個串行口
	if (CCF3){
		CCF3 = 0;					// Clear interrupt flag.
		switch (SURXST1){
			case 0:
				if (SREN1 & ~SW_RX1){				// Check for receive enable and a good START bit.  
																
					PCA_TEMP1 = (PCA0CPH3 << 8);	// Read module 3 contents into
					PCA_TEMP1 |= PCA0CPL3;		// PCA_TEMP.
					PCA_TEMP1 += UART3_STARTTIME;// Add 3/2 bit times to PCA_TEMP
					PCA0CPL3 = PCA_TEMP1;		// Restore PCA0CPL0 and PCA0CPH0
					PCA0CPH3 = (PCA_TEMP1 >> 8);	// with the updated value
					PCA0CPM3 = 0x49;			// Change module 0 to software timer mode, interrupts enabled.
					SURXST1++;					// Update RX state variable.
				}
				break;
			case 1:
			case 2:
			case 3:
			case 4:
			case 5:
			case 6:
			case 7:
			case 8:
				RXSHIFT1 = RXSHIFT1 >> 1;			// Shift right 1 bit
				if (SW_RX1)						// If SW_RX=1, 
					RXSHIFT1 |= 0x80;			// shift '1' into RXSHIFT msb
				PCA_TEMP1 = (PCA0CPH3 << 8);		// Read module 3 contents into
				PCA_TEMP1 |= PCA0CPL3;			// PCA_TEMP.
				PCA_TEMP1 += UART3_TIMER;			// Add 1 bit time to PCA_TEMP
				PCA0CPL3 = PCA_TEMP1;			// Restore PCA0CPL0 and PCA0CPH0
				PCA0CPH3 = (PCA_TEMP1 >> 8);		// with the updated value
				SURXST1++;						// Update RX state variable.
				break;
			case 9:
				RDR1 = RXSHIFT1;					// Move received data to receive register.
				SRI1 = 1;						// Set receive complete indicator.
				PCA0CPM3 = 0x11;				// Switch module 0 to negative capture
												// mode; interrupt enabled for START detection.
				SURXST1 = 0;						// Reset RX state variable.
				if (SES1){						// If user-level interrupt support enabled
					EIE2 |= 0x20;				// Enable IE7.
					P3IF |= 0x80;				// Trigger IE7.
				}
				break;
			}
		}
		else if (CCF2){ 
			CCF2 = 0;							// Clear interrupt flag
			switch (SUTXST1){
				case 0:
					SW_TX1 = 0;					// Drop TX pin as START bit.
					PCA_TEMP1 = PCA0L;			// Read PCA counter value into
					PCA_TEMP1 |= (PCA0H << 8);	// PCA_TEMP.
					PCA_TEMP1 += UART3_TIMER;		// Add 1 bit time.
					PCA0CPL2 = PCA_TEMP1;		// Store updated match value into
					PCA0CPH2 = (PCA_TEMP1 >> 8);	// module 1 capture/compare registers.
					PCA0CPM2 |= 0x48;			// Enable module 1 software timer.
					SUTXST1++;					// Update TX state variable.				
					break;
				case 1:
				case 2:
				case 3:
				case 4:
				case 5:
				case 6:
				case 7:
				case 8:
				case 9:
					SW_TX1 = (TDR1 & 0x01);		// Output LSB of TDR onto SW_TX pin.
					TDR1 >>= 1;					// Shift TDR right 1 bit.
					TDR1 |= 0x80;				// Shift '1' into MSB of TDR for
												// STOP bit in State 9.
					PCA_TEMP1 = (PCA0CPH2 << 8);	// Read module 1 contents into
					PCA_TEMP1 |= PCA0CPL2;		// PCA_TEMP.
					PCA_TEMP1 += UART3_TIMER;		// Add 1 bit time to PCA_TEMP
					PCA0CPL2 = PCA_TEMP1;		// Restore PCA0CPL1 and PCA0CPH1
					PCA0CPH2 = (PCA_TEMP1 >> 8);	// with the updated value	
					SUTXST1++;                   // Update TX state variable.
					break;
				case 10:
					STI1 = 1;					// Indicate TX complete.
					SUTXST1 = 0;					// Reset TX state.
					SW_TX1 = 1;					// SW_TX should remain high.
					PCA0CPM2 = 0x01;			// Disable module 1 software timer; leave
												// interrupt enabled for next transmit.					
					if (SES1){					// If user-level interrupt support enabled:
						EIE2 |= 0x20;			// Enable IE7.
						P3IF |= 0x80;			// Trigger IE7.
					}
					STXBSY1 = 0;					// SW_UART TX free.	
					break;
				}
		}


}

//----------------------------------------------------------------------------------------
// USER_ISR: User SW_UART Interrupt Service Routine (IE7 ISR)
// If interrupt-mode test code is enabled, this ISR
// transmits 15 characters and receives 15 characters. This routine is triggered each
// time a SW_UART transmit or receive is completed.
// - Checks receive complete indicator, and services.
// - Checks transmit complete indicator, and services.
// - Checks for transmits or receives that completed during the ISR; if so, triggers the
//   interrupt again.
//

void USER_ISR(void) interrupt 19 {				// IE7 Interrupt Service Routine
	P3IF &= ~(0x80);							// Clear IE7 interrupt flag
	if (SRI0)
	{											
		SRI0 = 0;								
		CommRecBuffer2[CommRecBufferTail2]=RDR0;     
	    CommRecBufferTail2++;
	    if (CommRecBufferTail2==DB_RECMAXSIZE2)
	    {
	    	CommRecBufferTail2=0;
	    }
		FlagRecComm2=1;
   	}
	else 
	if (STI0)
	{								
		STI0 = 0;								
		CommSendBufferHead2++; 	
		if (CommSendBufferHead2==DB_SENDMAXSIZE2)
		{	 
			CommSendBufferHead2=0;
		}
		if (CommSendBufferHead2!=CommSendBufferTail2)
		{	 
			STXBSY0 = 1;
			TDR0=CommSendBuffer2[CommSendBufferHead2]; 
			CCF0 = 1;	
			SendItComm2=0;
		}       
		else
		{
			SendItComm2=1;
		}	
	}
	if (SRI1)
	{											
		SRI1 = 0;								
		CommRecBuffer3[CommRecBufferTail3]=RDR1;     
	    CommRecBufferTail3++;
	    if (CommRecBufferTail3==DB_RECMAXSIZE3)
	    {
	    	CommRecBufferTail3=0;
	    }
		FlagRecComm3=1;
   	}
	else 
	if (STI1)
	{								
		STI1 = 0;								
		CommSendBufferHead3++; 	
		if (CommSendBufferHead3==DB_SENDMAXSIZE3)
		{	 
			CommSendBufferHead3=0;
		}
		if (CommSendBufferHead3!=CommSendBufferTail3)
		{	 
			STXBSY1 = 1;
			TDR1=CommSendBuffer2[CommSendBufferHead2]; 
			CCF2 = 1;	
			SendItComm3=0;
		}       
		else
		{
			SendItComm3=1;
		}	
	}
	if (STI0|SRI0)								// If SRI or STI is set, re-trigger
		P3IF |= 0x80;							// interrupt to service.
	if (STI1|SRI1)								// If SRI or STI is set, re-trigger
		P3IF |= 0x80;							// interrupt to service.
		
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人午夜精品在线| 欧亚一区二区三区| 日韩免费在线观看| 狠狠色丁香婷综合久久| 久久久精品免费网站| 成人黄色一级视频| 日韩av在线发布| 国产精品福利电影一区二区三区四区| 91丨porny丨国产入口| 蜜桃久久av一区| 亚洲欧美日韩中文播放| 日韩欧美一级特黄在线播放| 成人av第一页| 久久超级碰视频| 一区二区三区免费看视频| www成人在线观看| 欧美一区二区三区视频在线| av激情综合网| 成人午夜激情视频| 国内精品视频一区二区三区八戒| 亚洲综合另类小说| 亚洲美女精品一区| 国产精品久久久久久久久图文区| 日韩欧美色综合| 日韩一卡二卡三卡四卡| 欧美午夜寂寞影院| 色婷婷av一区二区三区gif| aaa国产一区| 91视频免费播放| 91免费在线视频观看| 一本到不卡免费一区二区| 成人av集中营| 欧美图区在线视频| 欧美日韩第一区日日骚| 欧美电影一区二区三区| 欧美精品在线观看播放| 欧美日韩免费高清一区色橹橹| 91电影在线观看| 56国语精品自产拍在线观看| 欧美一区二区三区免费观看视频| 欧美一区二区高清| 国产欧美日韩卡一| 一区二区三区欧美视频| 午夜国产精品影院在线观看| 久久99精品网久久| 色天使久久综合网天天| 欧美一级在线免费| 国产精品久久午夜夜伦鲁鲁| 亚洲午夜视频在线观看| 国产成人综合亚洲91猫咪| 色综合久久久网| 在线视频你懂得一区二区三区| 日本一区二区三区免费乱视频| 国产亚洲精品7777| 亚洲精品日产精品乱码不卡| 日韩国产欧美视频| 91黄色免费看| 中文字幕一区在线| 国产精品一区二区你懂的| 欧美网站一区二区| 亚洲视频 欧洲视频| 国产一区二区剧情av在线| 欧美日韩国产在线观看| 亚洲欧洲日韩综合一区二区| 加勒比av一区二区| 精品乱人伦一区二区三区| 亚洲国产精品一区二区久久 | 久久综合一区二区| 同产精品九九九| 欧美日韩一区三区四区| 一区二区在线观看免费| 色天天综合久久久久综合片| 1000部国产精品成人观看| 国产精品亚洲一区二区三区妖精| 精品精品欲导航| 麻豆精品蜜桃视频网站| 26uuu久久综合| 成人免费毛片片v| 国产精品家庭影院| 色999日韩国产欧美一区二区| 综合电影一区二区三区| 欧美午夜宅男影院| 视频在线观看91| 26uuu精品一区二区在线观看| 国产曰批免费观看久久久| 中文字幕欧美国产| 欧美色男人天堂| 国内精品久久久久影院薰衣草| 亚洲国产精品高清| 欧美日韩另类国产亚洲欧美一级| 久久机这里只有精品| 中文字幕高清一区| 欧美大片在线观看一区二区| 丰满岳乱妇一区二区三区| 亚洲一区二区三区四区五区中文| 欧美一区二区在线视频| 色综合天天综合给合国产| 免费成人在线观看视频| 一区二区三区影院| 亚洲精品一区二区三区福利| 欧洲视频一区二区| 成人午夜看片网址| 久久99精品国产麻豆婷婷洗澡| 国产精品久久久久永久免费观看 | 在线观看日产精品| 懂色av噜噜一区二区三区av| 男人的j进女人的j一区| 亚洲男女一区二区三区| 亚洲欧洲色图综合| 国产精品区一区二区三| 精品日韩一区二区三区免费视频| 91成人免费在线视频| 波多野结衣中文字幕一区 | 亚洲一区av在线| 亚洲少妇屁股交4| 亚洲伦理在线免费看| 国产精品成人网| 亚洲蜜臀av乱码久久精品蜜桃| 国产精品美女一区二区三区| 国产精品久久久久aaaa樱花| 欧美激情在线观看视频免费| 国产精品国产三级国产普通话蜜臀| 精品国产一区二区在线观看| 久久精品在这里| 亚洲精品免费一二三区| 亚洲高清免费一级二级三级| 奇米精品一区二区三区四区| 美女精品一区二区| 91亚洲精品乱码久久久久久蜜桃| 91亚洲永久精品| 精品理论电影在线观看 | 制服丝袜在线91| 久久久蜜臀国产一区二区| 成人欧美一区二区三区白人| 亚洲精品久久久蜜桃| 麻豆精品一区二区| av网站一区二区三区| 精品区一区二区| 亚洲一区免费在线观看| 国内精品嫩模私拍在线| 成人精品视频一区二区三区尤物| 欧美人与禽zozo性伦| 久久久久久电影| 久久99久久久久| 欧美高清一级片在线| 国产精品久久久久影院老司| 激情综合网av| 日韩一区二区三区电影在线观看 | 国产亚洲精品超碰| 蜜桃精品视频在线| 91精品综合久久久久久| 亚洲综合小说图片| 欧美性生活大片视频| 自拍av一区二区三区| 成人性生交大合| 国产欧美中文在线| 成人免费视频一区| 中文字幕+乱码+中文字幕一区| 国产激情精品久久久第一区二区 | 不卡一区中文字幕| 中文字幕第一区| 91免费看片在线观看| 亚洲女人的天堂| 欧美群妇大交群中文字幕| 五月婷婷欧美视频| 在线播放亚洲一区| 久久99久久99小草精品免视看| 精品乱人伦一区二区三区| 国产自产v一区二区三区c| 国产欧美一区二区精品性| 不卡视频在线看| 日韩精品亚洲专区| 国产亚洲综合性久久久影院| 99国产一区二区三精品乱码| 偷窥国产亚洲免费视频| 国产蜜臀av在线一区二区三区| 欧洲精品中文字幕| 国产在线精品不卡| 亚洲成人一区二区在线观看| 精品国产一区久久| 制服.丝袜.亚洲.中文.综合| 成人三级伦理片| 精品一区中文字幕| 亚洲国产精品精华液网站| 欧美国产日韩精品免费观看| 91精品国产综合久久福利软件| 国产99久久久久| 激情综合网激情| 黄色日韩网站视频| 日本欧美一区二区| 亚洲成人av一区| 一区二区三区电影在线播| 久久九九国产精品| 久久久久97国产精华液好用吗| 制服丝袜成人动漫| 欧美一区二区精品久久911| 91精品麻豆日日躁夜夜躁| 欧美日韩精品欧美日韩精品一| 91理论电影在线观看| 99精品欧美一区|