⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wnt10.c

📁 基于MST-G240128点阵液晶的 状态机机制 人机界面四级滚屏菜单 源代码 ,带时间片机制模拟操作系统
💻 C
📖 第 1 页 / 共 5 页
字号:
             switch( UART0_RX_CNT )
			 {
			    case  1: if( ucTMP != 0x00 )
			                UART0_RxFORMAT_MATCH = 0; // Frame Format Error. 
		                 break;
			    case  2: if( ucTMP != 0x00 )
			                UART0_RxFORMAT_MATCH = 0; // Frame Format Error. 
		                 break;
			    case  3: if( ucTMP != 0x01 )
			                UART0_RxFORMAT_MATCH = 0; // Frame Format Error. 
 		                 break;
                case  4: if( UART0_RX_Sta0 == 0 )
				         {
                            Ex386Sta0DATA = ucTMP;
				            RxBuff0Busy = 1;
				         }
		                 else if( UART0_RX_Sta1 == 0 )
				         {
                            Ex386Sta1DATA = ucTMP;
				            RxBuff1Busy = 1;
				         }
						 else
						 {
					        RxBuff0Busy = 0;
						    RxBuff1Busy = 0;
			                UART0_RxFORMAT_MATCH = 0; // Busy Now! Discard this Frame. 
			             }
						 break;
				case  6: if( ucTMP == 0x88 )
                         { 
				            if( RxBuff0Busy == 1 )
				               UART0_RX_Sta0 = 1;     // 386Ex STATUS Information Recieved.
							if( RxBuff1Busy == 1 )
				               UART0_RX_Sta1 = 1;     // 386Ex STATUS Information Recieved.		      
                         }
					     RxBuff0Busy = 0;
						 RxBuff1Busy = 0;
 			             UART0_RxFORMAT_MATCH = 0;    // RST Frame Format Match Flag.
 		                 break;
                default: break; 
             }
	      }
          /*******************************************
          ***  386Ex Command DATA Frame ***
          *******************************************/
          else if( UART0_RX_DTYPE == 2 )              // 386Ex Command DATA Frame.
          {
		     UART0_RX_CNT++;
		     switch( UART0_RX_CNT )
			 {
			    case  1: if( ucTMP != 0x00 )
			                UART0_RxFORMAT_MATCH = 0; // Frame Format Error. 
		                 break;
			    case  2: if( ucTMP != 0x00 )
			                UART0_RxFORMAT_MATCH = 0; // Frame Format Error. 
		                 break;
			    case  3: if( ucTMP != 0x01 )
			                UART0_RxFORMAT_MATCH = 0; // Frame Format Error. 
 		                 break;
                case  4: if( UART0_RX_Cmd0 == 0 )
				         {
                            Ex386Cmd0DATA = ucTMP;
				            RxBuff0Busy = 1;
				         }
		                 else if( UART0_RX_Cmd1 == 0 )
				         {
                            Ex386Cmd1DATA = ucTMP;
				            RxBuff1Busy = 1;
				         }
                         else
						 {
					        RxBuff0Busy = 0;
						    RxBuff1Busy = 0;
			                UART0_RxFORMAT_MATCH = 0; // Busy Now! Discard this Frame. 
			             }
						 break;
			    case  6: if( ucTMP == 0x88 )
                         { 
				            if( RxBuff0Busy == 1 )
				               UART0_RX_Cmd0 = 1;     // 386Ex STATUS Information Recieved.
							if( RxBuff1Busy == 1 )
				               UART0_RX_Cmd1 = 1;     // 386Ex STATUS Information Recieved.		      
                         }
					     RxBuff0Busy = 0;
						 RxBuff1Busy = 0;
 			             UART0_RxFORMAT_MATCH = 0;    // RST Frame Format Match Flag.
 		                 break;
                default: break; 
             }
		  }
          /*******************************************
          ***  Voice Record DATA Frame ***
          *******************************************/
          else if( UART0_RX_DTYPE == 3 )             // Voice Sample DATA Frame.
          {
		     UART0_RX_CNT++;
             switch( UART0_RX_CNT )
			 {
			    case   1: RxCurrFraIdx.ucVAR[1] = ucTMP;  // Low Byte.
				          break;
			    case   2: RxCurrFraIdx.ucVAR[0] = ucTMP;  // High Byte.
				          break;
                case   3: if( ucTMP != 0xC8 )             // 200 Bytes.
			              {
					         RxBuff0Busy = 0;
						     RxBuff1Busy = 0;
			                 UART0_RxFORMAT_MATCH = 0;    // Frame Format Error. 
			                 AckDATA[2] = 0xC0;           // Recieved Error.
				             AckDatReady = 1;             // ACK Frame Ready.
			              }
				          RxLastFraIdx.uiVAR++;
				          if( RxCurrFraIdx.uiVAR != RxLastFraIdx.uiVAR )
				          {
 				             if( RxCurrFraIdx.uiVAR == 0xffff )
				             {                            // The End Frame.
					            RxLastFraIdx.uiVAR = 0;   // RST Frame Index.
		                        VocSamDatWrPtr = 0;       // 
				             }
				             else
				             {
					            RxBuff0Busy = 0;
						        RxBuff1Busy = 0;
			                    UART0_RxFORMAT_MATCH = 0; // Frame Format Error. 
			                    AckDATA[2] = 0xE0;        // RX Frame Index Error.
				                AckDatReady = 1;          // ACK Frame Ready.
				             }
				          }
						  break;
                case 204: XOR = ucTMP;
				          break;
                case 205: if( ucTMP == 0x88 )
				          {
				             AckDATA[2] = 0x80;         // Recieved OK.
				             if( RxBuff0Busy == 1 )
				                UART0_RX_Vos0 = 1;      // 386Ex STATUS Information Recieved.
                             if( RxBuff1Busy == 1 )
				                UART0_RX_Vos1 = 1;      // 386Ex STATUS Information Recieved.		      
				          }
				          else                          // Frame END Error.
				             AckDATA[2] = 0xC0;         // Recieved Error.
			              
						  AckDatReady = 1;              // ACK Ready.
					      RxBuff0Busy = 0;
						  RxBuff1Busy = 0;
			              UART0_RxFORMAT_MATCH = 0;     // RST Frame Format Match Flag.
						  break;               
                default:  if( RxBuff0Busy == 1 )        // 3 <= UART0_RX_CNT <= 202
                             VocSam0DATA[UART0_RX_CNT-4] = ucTMP;
			              if( RxBuff1Busy == 1 )        // 
                             VocSam1DATA[UART0_RX_CNT-4] = ucTMP;  
						  break;               	         
             }
		  }
	   }
	   else
	   {
          if( UART0_FraHEAD_SAT1 )
          {
             switch( ucTMP )
			 {
                case 0x01:                         // 386Ex Status Frame. 
                           UART0_RX_CNT = 0;
				           UART0_RX_DTYPE = 1;      
		                   UART0_FraHEAD_OK = 1;   // Frame Format Correct.
						   break;
                case 0x21:                         // 386Ex Status Frame. 
                           UART0_RX_CNT = 0;
				           UART0_RX_DTYPE = 1;      
		                   UART0_FraHEAD_OK = 1;   // Frame Format Correct.
						   break;
                case 0x02:                         // 386Ex Command Frame.
                           UART0_RX_CNT = 0;
				           UART0_RX_DTYPE = 2;       
		                   UART0_FraHEAD_OK = 1;   // Frame Format Correct.
						   break;
                case 0x22:                         // 386Ex Command Frame.
                           UART0_RX_CNT = 0;
				           UART0_RX_DTYPE = 2;       
		                   UART0_FraHEAD_OK = 1;   // Frame Format Correct.
						   break;
                case 0x03:                         // Voice Sample DATA Frame.
                           UART0_RX_CNT = 0;
				           UART0_RX_DTYPE = 3;      
		                   UART0_FraHEAD_OK = 1;   // Frame Format Correct.
				           if( UART0_RX_Vos0 == 0 )
				              RxBuff0Busy = 1;
                           else if( UART0_RX_Vos1 == 0 )
				              RxBuff1Busy = 1;
						   break;
                case 0x23:                         // Voice Sample DATA Frame.
                           UART0_RX_CNT = 0;
				           UART0_RX_DTYPE = 3;      
		                   UART0_FraHEAD_OK = 1;   // Frame Format Correct.
				           if( UART0_RX_Vos0 == 0 )
				              RxBuff0Busy = 1;
                           else if( UART0_RX_Vos1 == 0 )
				              RxBuff1Busy = 1;
						   break;
                case 0x80:                         // 386Ex ACK Frame,RX OK. 
             	           if( TxRecFraIdx.uiVAR == 0xffff ) 
				           {  
				              if( CurrTxVocChNum == 0 )
				              {
				                 VocCh0RecTimCNT++;
					             VocCh0RecEvt = 0;
				              }
				              else if( CurrTxVocChNum == 1 )
				              {
					             VocCh1RecTimCNT++;
					             VocCh1RecEvt = 0;
				              } 
				              else if( CurrTxVocChNum == 2 )
				              {
				                 VocCh2RecTimCNT++;
					             VocCh2RecEvt = 0;
				              }
				              CurrTxVocChNum = 255;     // Current CHn Voive DATA TX Over. 
				           }
                           RxAckCNT++;                  // 386Ex ACK Times Counting. 
                           break; 
                case 0xE0:                              // 386Ex ACK Frame,Frame Index Error.
  	                       TxRecFraIdx.uiVAR = 0;       // RST TX Frame Index Counting.
                           VocRecDatRdPtr = 0;          // Voice Record CHn Start Address: 0x000n.
			               if( CurrTxVocChNum == 0 )
			                  VocRecDatRdPag = 1;
				           else if( CurrTxVocChNum == 1 )
			                  VocRecDatRdPag = 3;
				           else if( CurrTxVocChNum == 2 )
			                  VocRecDatRdPag = 5;               
                           break;
                default:                               // Frame Format Error.
				           UART0_RxFORMAT_MATCH = 0; 
						   break; 
             }						              	    
		  }
          else if( UART0_FraHEAD_SAT0 )
		  {
		     if( ucTMP == 0xaa )
                UART0_FraHEAD_SAT1 = 1; 
		     else
                UART0_RxFORMAT_MATCH = 0;           // Frame Format Error. 	    
          } 
	      else if( ucTMP == 0x55 )
		     UART0_FraHEAD_SAT0 = 1;
	   }
    }
    SFRPAGE = 0x0F;                            // P4 Page. 
	P4 = CurrSramPage;  
    SFRPAGE = 0x00;                            // P4 Page. 
}

void T0_ISR(void) interrupt 1
{	
    unsigned char CurrSramPage;
    SFRPAGE = 0x0F;                            // P4 Page.
	CurrSramPage = P4;                         // Save P4 Value.              

	SFRPAGE = TIMER01_PAGE;                    // Change to TIMER01 PAGE.
    TF0 = 0;
    WDTCN = 0xA5;                              // Enable WDT or Reload the WDT.
    // VOICE CHANNAL 0 RECORDING.
    if( VocCh0RecSTA == 1 )
    {
       ExSRAM_PageSetting( VocCh0RecDatWrPag );// Page 1 ~ 2.
       ADC0_CH_Setting(0x02);                  // AIN00,voice channal 0.                     
	   AD0INT = 0;                             // RST ADC Convert Complete Flag.
       AD0BUSY = 1;                            // Start ADC0    
       while( AD0INT == 0 );                   // Wait for Convert Over
       AdcDatBuff.ucVAR[0] = ADC0H;            // Only Get High 8 Byte.  
	   ExSramWrRdAdr = VocCh0RecDatWrPtr;
       *ExSramWrRdAdr = AdcDatBuff.ucVAR[0];   // Save CH0 DATA.
	   VocCh0RecDatWrPtr++;
       if( VocCh0RecDatWrPtr >= VocRecDatLength )     
       {                                       // 64000 Sample Points / Page( 8sec ).
	      VocCh0RecDatWrPtr = 0;               // RST Address.
          VocCh0RecDatWrPag++;                 // CH0 SRAM Page Number Increase 1.
       }
       if( VocCh0RecDatWrPag > VocCh0RecEndPag )  
	   {                                       // Voice CH0 Record Over.
  	      VocCh0RecDatWrPtr = 0;
	      VocCh0RecDatWrPag = 1;
          VocCh0RecSTA = 0;                    // Clear Voice CH0 Record STATUS Flag.     
          VocCh0RecEvt = 1;                    // Set Voice CH0 Record Over Event Flag.
	   }
    }
    // VOICE CHANNAL 1 RECORDING.
    if( VocCh1RecSTA == 1 )
    {
       ExSRAM_PageSetting( VocCh1RecDatWrPag );// Page 3 ~ 4.
       ADC0_CH_Setting(0x01);                  // AIN01,voice channal 1.                     
	   AD0INT = 0;                             // RST ADC Convert Complete Flag.
       AD0BUSY = 1;                            // Start ADC0    

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -