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

📄 armint.c

📁 2440友善之臂的源码!配合开发板学习
💻 C
📖 第 1 页 / 共 2 页
字号:
				s2440INT->rINTPND  = BIT_EINT8_23;
		
			return SYSINTR_SDMMC_CARD_DETECT;
		}
#endif



		//else if (submask & (1 << 8))	// 0x100 EINT8 : PCMCIA_LEVEL
		else if (dwSubMask & (1 << 8))	// 0x100 EINT8 : PCMCIA_LEVEL
		{
			s2440IOP->rEINTMASK |= 0x100;
			s2440IOP->rEINTPEND = 0x100;

			s2440INT->rSRCPND = BIT_EINT8_23;        
			if (s2440INT->rINTPND & BIT_EINT8_23) s2440INT->rINTPND = BIT_EINT8_23;

			//RETAILMSG(1, (TEXT("INT:SYSINTR_PCMCIA_LEVEL INT\r\n")));
			return SYSINTR_PCMCIA_LEVEL;
		}
		else
		{
			s2440INT->rSRCPND = BIT_EINT8_23;        
			if (s2440INT->rINTPND & BIT_EINT8_23) s2440INT->rINTPND = BIT_EINT8_23;

			//RETAILMSG(0, (TEXT("INT:???\r\n")));
			//return SYSINTR_NOP;
		}					
	}

	else if (IntPendVal == INTSRC_ADC) // INTSRC_ADC
	{
        // Touch Panel Int
       	SubIntPendVal = s2440INT->rSUBSRCPND;
       	
       	if(SubIntPendVal & INTSUB_TC) 
		{
       		s2440INT->rINTSUBMSK |= INTSUB_TC;
       		s2440INT->rSUBSRCPND  = INTSUB_TC;
       	
            s2440INT->rINTMSK |= BIT_ADC;
   	        s2440INT->rSRCPND  = BIT_ADC;        
       	    if (s2440INT->rINTPND & BIT_ADC) s2440INT->rINTPND = BIT_ADC;
           
			if( (s2440ADC->rADCDAT0 & 0x8000) || (s2440ADC->rADCDAT1 & 0x8000) )
			{
				s2440INT->rINTMSK |= BIT_TIMER1;     // Mask timer1 interrupt.
		   		s2440INT->rSRCPND = BIT_TIMER1;     // Clear pending bit
   				if (s2440INT->rINTPND & BIT_TIMER1) s2440INT->rINTPND = BIT_TIMER1;
				//RETAILMSG(0,(TEXT("INT Touch pen up \r\n")));

      	        odo_tsb->status = TOUCH_PEN_UP;
      		}
			else
			{
				//RETAILMSG(0,(TEXT("INT Touch pen down \r\n")));
   	            odo_tsb->status = TOUCH_PEN_DOWN;
			}
       
	        return SYSINTR_TOUCH_CHANGED;
		}
       	else if(SubIntPendVal & INTSUB_ADC)
		{
       		s2440INT->rINTSUBMSK |= INTSUB_ADC;
       		s2440INT->rSUBSRCPND = INTSUB_ADC;

	        s2440INT->rINTMSK |= BIT_ADC;
   		    s2440INT->rSRCPND = BIT_ADC;        
       		if (s2440INT->rINTPND & BIT_ADC) s2440INT->rINTPND = BIT_ADC;
            	
        	s2440INT->rINTMSK &= ~BIT_ADC;

           	return SYSINTR_NOP;
       	}
       	else
       		return SYSINTR_NOP;
	}

	else if (IntPendVal == INTSRC_TIMER1) // INTSRC_TIMER1
	{
       // Timer 1 interrupt to get touch point
      	s2440INT->rINTMSK |= BIT_TIMER1;
       	s2440INT->rSRCPND = BIT_TIMER1;
  	    if (s2440INT->rINTPND & BIT_TIMER1) s2440INT->rINTPND = BIT_TIMER1;

		// charlie, 020620
		if( (s2440ADC->rADCDAT0 & 0x8000) || (s2440ADC->rADCDAT1 & 0x8000) )
		{
			//RETAILMSG(0,(TEXT("INT Touch SYSINTR_TOUCH_CHANGED 1\r\n")));
			odo_tsb->status = TOUCH_PEN_UP;
			return SYSINTR_TOUCH_CHANGED;
		}

        if(odo_tsb->status == TOUCH_PEN_UP) 
		{
			//RETAILMSG(0,(TEXT("INT Touch SYSINTR_TOUCH_CHANGED 2 \r\n")));
			odo_tsb->status = TOUCH_PEN_UP;
			return SYSINTR_TOUCH_CHANGED;
		}
        else 
		{
			unsigned int TmpTCON;

        	odo_tsb->status = TOUCH_PEN_SAMPLE;
			TmpTCON = s2440PWM->rTCON;	// get TCON value to temp TCON register
			TmpTCON &= ~0xf00;     		// clear fields of Timer 1 
			TmpTCON |= 0x200;     		// interval mode(auto reload), update TCVNTB4, stop 
			s2440PWM->rTCON = TmpTCON;	// put the value to TCON register

			TmpTCON = s2440PWM->rTCON;	// get TCON value to temp TCON register
			TmpTCON &= ~0xf00;     		// clear fields of Timer 1 
			TmpTCON |= 0x100;     		// interval mode, no operation, start for Timer 4 
			s2440PWM->rTCON = TmpTCON;	// put the value to TCON register

			//RETAILMSG(0,(TEXT("INT Touch SYSINTR_TOUCH\r\n")));
	
        	return SYSINTR_TOUCH;
		}
	}

	else if (IntPendVal == INTSRC_EINT0)		// POWER BUTTON
	{ 
		s2440INT->rINTMSK |= BIT_EINT0;
		s2440INT->rSRCPND  = BIT_EINT0;			// Interrupt Clear
		if (s2440INT->rINTPND & BIT_EINT0) s2440INT->rINTPND  = BIT_EINT0;

		return(SYSINTR_POWER);	
	}

	else if(IntPendVal == INTSRC_DMA1) // AUDIO DMA input.
	{  
		s2440INT->rINTMSK |= BIT_DMA1;
		s2440INT->rSRCPND  = BIT_DMA1;
		if (s2440INT->rINTPND & BIT_DMA1) s2440INT->rINTPND  = BIT_DMA1;

		return(SYSINTR_AUDIO);
	}
	else if(IntPendVal == INTSRC_DMA2) // AUDIO DMA output.
	{  
		s2440INT->rINTMSK |= BIT_DMA2;
		s2440INT->rSRCPND  = BIT_DMA2;
		if (s2440INT->rINTPND & BIT_DMA2) s2440INT->rINTPND  = BIT_DMA2;

		return(SYSINTR_AUDIO);
	}

	else if(IntPendVal == INTSRC_USBH) 	// USB.
	{
		s2440INT->rINTMSK |= BIT_USBH;
		s2440INT->rSRCPND  = BIT_USBH;        
		if (s2440INT->rINTPND & BIT_USBH) s2440INT->rINTPND  = BIT_USBH;
		//RETAILMSG(1, (TEXT("INT:SYSINTR_USB INT\r\n")));
		return(SYSINTR_USB);     
	} 

	else if (IntPendVal == INTSRC_DMA3)
	{
		s2440INT->rINTMSK |= BIT_USBD; // USBD interrupt should be masked
		//s2440INT->rINTMSK |= BIT_DMA3;
		s2440INT->rSRCPND = BIT_DMA3;
		if (s2440INT->rINTPND & BIT_DMA3) s2440INT->rINTPND = BIT_DMA3;
		usbdShMem->usbdDma3Int=1;
		return SYSINTR_USBD;  
		//Correct. DMA3 interrupt will be connected to USBD interrupt.
		//break;
	}

	else if(IntPendVal == INTSRC_USBD) 
	{
		s2440INT->rINTMSK |= BIT_USBD;
		UsbdClearEir();	 //:-)
		s2440INT->rSRCPND = BIT_USBD;
		if (s2440INT->rINTPND & BIT_USBD) s2440INT->rINTPND = BIT_USBD;
		RETAILMSG(0,(TEXT("INT_USBD\r\n")));
		return SYSINTR_USBD;
    }

	else if(IntPendVal == INTSRC_UART0)	// SERIAL (UART0) (physical COM1: P1 connector).
	{  
		SubIntPendVal = s2440INT->rSUBSRCPND;

		// Note that we only mask the sub source interrupt - the serial driver will clear the
		// sub source pending register.
		//
		if(SubIntPendVal & INTSUB_ERR0) 
		{
			s2440INT->rINTSUBMSK |= INTSUB_ERR0;
		}
		else if(SubIntPendVal & INTSUB_RXD0) 
		{
			s2440INT->rINTSUBMSK |= INTSUB_RXD0;
			#if USE_AFC
			// by 0212.
				s2440IOP->rGPHDAT |= (0x2);  // Deassert nRTS				
			#endif
		}
		else if(SubIntPendVal & INTSUB_TXD0) 
		{
			s2440INT->rINTSUBMSK |= INTSUB_TXD0;
		}
		else
		{
			return(SYSINTR_NOP);
		}
	
		// NOTE: Don't clear INTSRC:UART0 here - serial driver does that.
		//
		s2440INT->rINTMSK |= BIT_UART0;
		if (s2440INT->rINTPND & BIT_UART0) s2440INT->rINTPND  = BIT_UART0;

		return(SYSINTR_SERIAL);
	}
	
	else if(IntPendVal == INTSRC_UART1)  // SERIAL (UART1) (physical COM2: P2 connector)   
	{   
	  	SubIntPendVal = s2440INT->rSUBSRCPND; 
	  	// Note that we only mask the sub source interrupt - the serial driver will clear the 
	  	// sub source pending register. 
	  	// 
	  	if(SubIntPendVal & INTSUB_ERR1)  
	  	{ 
	    		s2440INT->rINTSUBMSK |= INTSUB_ERR1; 
	  	} 
	  	else if(SubIntPendVal & INTSUB_RXD1)  
	  	{ 
	    		s2440INT->rINTSUBMSK |= INTSUB_RXD1; 
	  	} 
	  	else if(SubIntPendVal & INTSUB_TXD1)  
	  	{ 
	    		s2440INT->rINTSUBMSK |= INTSUB_TXD1; 
	 	} 
	  	else 
  		{ 
      			return(SYSINTR_NOP); 
    		} 
  
    		// NOTE: Don't clear INTSRC:UART0 here - serial driver does that. 
    		// 
    		s2440INT->rINTMSK |= BIT_UART1; 
    		if (s2440INT->rINTPND & BIT_UART1) s2440INT->rINTPND  = BIT_UART1; 
 
    		return(SYSINTR_SERIAL2); 
  	}      

  	else if(IntPendVal == INTSRC_UART2)	// SERIAL (UART2) (physical COM3: P2 connector)   
	{
		SubIntPendVal = s2440INT->rSUBSRCPND;

		if(SubIntPendVal & INTSUB_ERR2) 
		{
			s2440INT->rINTSUBMSK |= INTSUB_ERR2;
		}       
		else if(SubIntPendVal & INTSUB_RXD2) 
		{
			s2440INT->rINTSUBMSK |= INTSUB_RXD2;
		}       
		else if(SubIntPendVal & INTSUB_TXD2) 
		{
			s2440INT->rINTSUBMSK |= INTSUB_TXD2;
		}       
		else
		{
			return(SYSINTR_NOP);
		}

		// NOTE: Don't clear INTSRC:UART2 here - serial driver does that.
		//
		s2440INT->rINTMSK |= BIT_UART2;
		if (s2440INT->rINTPND & BIT_UART2) s2440INT->rINTPND  = BIT_UART2;
		
		return(SYSINTR_SERIAL3);
	}

	else if (IntPendVal == INTSRC_RTC)	// for alarm. 030818
	{ 
		s2440INT->rSRCPND  = BIT_RTC;   // Interrupt Clear
		s2440INT->rINTPND  = BIT_RTC;
		s2440INT->rINTMSK |= BIT_RTC;   // Alarm Interrupt Disable
		return SYSINTR_RTC_ALARM;
	}
	else if(IntPendVal == INTSRC_CAM) 
	{
//		RETAILMSG(1,(TEXT("INT:SYSINTR_CAM INT:0x%x,0x%x\r\n"),s2440INT->rSRCPND,s2440INT->rSUBSRCPND));
		
		if( s2440INT->rSUBSRCPND & (0x1<<11) )
		{
			s2440INT->rINTSUBMSK |= (0x1<<11);
			s2440INT->rINTMSK |= BIT_CAM;
			s2440INT->rSUBSRCPND = (0x1<<11);
			s2440INT->rSRCPND = BIT_CAM;
			
			if (s2440INT->rINTPND & BIT_CAM) s2440INT->rINTPND = BIT_CAM;
			return SYSINTR_CAM;
		}
		else if (s2440INT->rSUBSRCPND & BIT_SUB_CAM_P)
		{
			s2440INT->rINTSUBMSK |= (0x2<<11);
			s2440INT->rINTMSK |= BIT_CAM;
			s2440INT->rSUBSRCPND = (0x2<<11);
			s2440INT->rSRCPND = BIT_CAM;
		
			if (s2440INT->rINTPND & BIT_CAM) s2440INT->rINTPND = BIT_CAM;

			return SYSINTR_CAM;
		}
		
		s2440INT->rINTSUBMSK |= (BIT_SUB_CAM_C | BIT_SUB_CAM_P);
		s2440INT->rINTMSK |= BIT_CAM;
		s2440INT->rSUBSRCPND = (BIT_SUB_CAM_C | BIT_SUB_CAM_P);
		s2440INT->rSRCPND = BIT_CAM;

		if (s2440INT->rINTPND & BIT_CAM)
		{
			s2440INT->rINTPND = BIT_CAM;
		}

		return SYSINTR_NOP;
	}
	else if(IntPendVal == INTSRC_IIC) 
	{
		s2440INT->rINTMSK |= BIT_IIC;
		s2440INT->rSRCPND = BIT_IIC;
		if (s2440INT->rINTPND & BIT_IIC) s2440INT->rINTPND = BIT_IIC;
//		RETAILMSG(1,(TEXT("IIC Interrupt\r\n")));
		return SYSINTR_IIC;
	}
	
	return(SYSINTR_NOP);
}

void UsbdClearEir(void)
{
	static volatile struct udcreg *s2440USBD = (volatile struct udcreg *)(0xB1200140);
	
	usbdShMem->usbdEir|=*(volatile BYTE *)&s2440USBD->EIR;
	usbdShMem->usbdUir|=*(volatile BYTE *)&s2440USBD->UIR;
	*(volatile BYTE *)&s2440USBD->EIR=usbdShMem->usbdEir;
	*(volatile BYTE *)&s2440USBD->UIR=usbdShMem->usbdUir;

}

⌨️ 快捷键说明

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