예제 #1
0
void Test_Uart0_Int(void)
{
    Uart_Port_Set(); 
    Uart_Select(0);    
    /*********** UART0 Tx test with interrupt ***********/  
    isTxInt=1;
    uart0TxStr="ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890->UART0 Tx interrupt test is good!!!!\r\n";
    Uart_Printf("[Uart channel 0 Tx Interrupt Test]\n");

    pISR_UART0=(unsigned)Uart0_TxInt;

    rULCON0=(0<<6)|(0<<3)|(0<<2)|(3);	// Normal,No parity,One stop bit, 8bit
    rUCON0 &= 0x400;	// For the PCLK <-> UCLK fuction
    rUCON0 |= (TX_INTTYPE<<9)|(RX_INTTYPE<<8)|(0<<7)|(0<<6)|(0<<5)|(0<<4)|(1<<2)|(1);
    //Clock,Tx:Def,Rx:Def,Rx timeout:x,Rx error int:x,Loop-back:x,Send break:x,Tx:int,Rx:int
    Uart_TxEmpty(0); //wait until tx buffer is empty.
    rINTMSK=~(BIT_UART0);
    rINTSUBMSK=~(BIT_SUB_TXD0);

    while(isTxInt);
    
    /*********** UART0 Rx test with interrupt ***********/
    isRxInt=1;
    uart0RxStr=(char *)UARTBUFFER;
    Uart_Printf("\n[Uart channel 0 Rx Interrupt Test]:\n");
    Uart_Printf("After typing ENTER key, you will see the characters which was typed by you.");
    Uart_Printf("\nTo quit, press ENTER key.!!!\n");
    Uart_TxEmpty(0); //wait until tx buffer is empty.
    pISR_UART0 =(unsigned)Uart0_RxIntOrErr;
    rULCON0=(0<<6)|(0<<3)|(0<<2)|(3);	// Normal,No parity,One stop bit, 8bit
    rUCON0 &= 0x400;	// For the PCLK <-> UCLK fuction
    rUCON0 |= (TX_INTTYPE<<9)|(RX_INTTYPE<<8)|(0<<7)|(1<<6)|(0<<5)|(0<<4)|(1<<2)|(1);
    //Clock,Tx:pulse,Rx:pulse,Rx timeout:x,Rx error int:o,Loop-back:x,Send break:x,Tx:int,Rx:int

    // Clear Int Pending and Unmask    
    ClearPending(BIT_UART0);
    rINTMSK=~(BIT_UART0);
    rSUBSRCPND=(BIT_SUB_TXD0|BIT_SUB_RXD0|BIT_SUB_ERR0);    
    rINTSUBMSK=~(BIT_SUB_RXD0|BIT_SUB_ERR0);
    
    while(isRxInt);
    
    rINTSUBMSK|=(BIT_SUB_RXD0|BIT_SUB_ERR0);
    rINTMSK|=(BIT_UART0);
 
    Uart_Printf("%s\n",(char *)UARTBUFFER);
    Uart_Port_Return();
}
예제 #2
0
파일: system.c 프로젝트: uKingSky/KingSky
void Uart_Init(int pclk,int baud)
{
    int i;
    if(pclk == 0)
    pclk    = PCLK;
    rUFCON0 = 0x0;   //UART channel 0 FIFO control register, FIFO disable
    rUFCON1 = 0x0;   //UART channel 1 FIFO control register, FIFO disable
    rUFCON2 = 0x0;   //UART channel 2 FIFO control register, FIFO disable
    rUMCON0 = 0x0;   //UART chaneel 0 MODEM control register, AFC disable
    rUMCON1 = 0x0;   //UART chaneel 1 MODEM control register, AFC disable
//UART0
    rULCON0 = 0x3;   //Line control register : Normal,No parity,1 stop,8 bits
    rUCON0  = 0x245;   // Control register
    rUBRDIV0=( (int)(pclk/16./baud+0.5) -1 );   //Baud rate divisior register 0
//UART1
    rULCON1 = 0x3;
    rUCON1  = 0x245;
    rUBRDIV1=( (int)(pclk/16./baud+0.5) -1 );
//UART2
    rULCON2 = 0x3;
    rUCON2  = 0x245;
    rUBRDIV2=( (int)(pclk/16./baud+0.5) -1 ); 
	BspUart0ISRInit();
	Uart_TxEmpty(whichUart);
}
예제 #3
0
파일: idle.c 프로젝트: cyj1988jyc/2440-test
void Test_IdleModeHard(void)
{
    int i,j;

    MMU_SetAsyncBusMode(); //ARM920T should be in the async. bus mode.
    
    Uart_Printf("[IDLE Mode Hard Test with Timer0]\n");
    Uart_Printf("S3C2440 will also wake up by EINT0 falling edge.\n");

    Uart_TxEmpty(1);    //Wait until UART0 Tx buffer empty.

    rGPFCON=rGPFCON & ~(3<<0)|(2<<0); //PF0=EINT0
    rEXTINT0=rEXTINT0&(7<<0)|(0x2<<0); //EINT0=falling edge triggered
    
    rSRCPND = BIT_EINT0;
    rINTPND = BIT_EINT0;

    t0cnt=0;t1cnt=0;

    pISR_TIMER0=(U32)Timer0Int; 
    pISR_TIMER1=(U32)Timer1Int;
    pISR_EINT0=(U32)Eint0Int;

    rTCFG0=0x0;		//PRESC01=1,PRESC234=1
    rTCFG1=0x0; 	//TIMER0,1,2,3,4,5= 1/2    
    rTCNTB0=65535;	
    rTCNTB1=2570;
    rTCON=0xa0a;	//T0,T1=manualUpdate,interval mode
    rTCON=0x909;	//Start T0,T1.
    //rTCON=0x00a;
    //rTCON=0x009;
  
    rINTMSK=~(BIT_EINT0|BIT_TIMER0|BIT_TIMER1);
        
    for(i=0;i<10000;i++)
    {
    	rCLKCON|=(1<<2);  //enter IDLE mode.

	//wait until S3C2400X enters IDLE mode.	
	//wait EINT0 interrupt or RTC alarm interrupt
	for(j=0;j<10;j++);   

	rCLKCON&=~(1<<2);      
    	    //turn-off IDLE bit. IDLE bit should be turned off after wake-up.

    	if(i%100==0)Uart_Printf("#");
    }

    rTCON=0x0; //turn the timer off

    rINTMSK=BIT_ALLMSK;
    
    Uart_Printf("\nt0cnt=%d,t1cnt=%d(t0cnt+t1cnt>=10000)\n",t0cnt,t1cnt);
    Uart_Printf("Return to Normal Mode.\n");
}
예제 #4
0
void Test_SlowMode(void)
{
    int i;
    unsigned int saveREFRESH;

    slowExit=0;
    rGPFCON=rGPFCON & ~(3<<0)|(2<<0); //PF0=EINT0
    rEXTINT0=rEXTINT0&(7<<0)|(0x2<<0); //EINT0=falling edge triggered

    pISR_EINT0=(U32)SlowEint0Int;
    rINTMSK=~BIT_EINT0;

    Uart_Printf("[ SLOW MODE TEST ]\n");
    Uart_Printf("1)Entering SLOW mode.\n");
    Uart_Printf("  LEDs are flickered by 200ms period at %dMhz 20 times.\n",FCLK/1000000);
    Uart_Printf("  But, The period will be about %lfms.\n",200*FCLK/12000000.);
    Uart_Printf("  Press EINT0 key to exit SLOW mode\n");
    Uart_TxEmpty(0);	//To avoid being crushed the character

    for(i=0;i<20;i++)
    {
	Led_Display(0xf);
	Delay(1000);
	Led_Display(0x0);
	Delay(1000);
    }

    rCLKSLOW=0|(1<<4)|(1<<5)|(1<<7); //FCLK=FIN/1,SLOW mode,MPLL=off,UPLL=off 

    saveREFRESH=rREFRESH;
    rREFRESH=(1<<23)|(U32)(2048+1-12*15.6); //Trp=2clk,Trc=4clk
        //The other memory control register should be optimized for SLOW mode.
        
    while(!slowExit)
    {
	Led_Display(0xf);
	DoQsort(); 
	Led_Display(0x0);
	DoQsort();
    }
    
    rINTMSK=BIT_ALLMSK;

    rCLKSLOW=0|(1<<4)|(0<<5);//PLL on,MPLL=on
    for(i=0;i<2048;i++); //S/W MPLL lock-time
    rCLKSLOW=0|(0<<4)|(0<<5);//NORMAL mode,PLL on,MPLL=on
}
예제 #5
0
파일: idle.c 프로젝트: cyj1988jyc/2440-test
void Test_IdleMode(void)
{
    int i;
//    int extintMode;

    MMU_SetAsyncBusMode(); 
     	//ARM920T should be in the async bus mode 
    	//because FCLK is used for ARM920T in the async bus mode.

    Uart_Printf("[IDLE Mode Test]\n");
    Uart_Printf("After 10 seconds, S3C2440 will wake up by RTC alarm interrupt.\n");
    Uart_Printf("S3C2440 will also wake up by EINT0.\n");

    //PWR_Lcd_Tft_16Bit_240320_On();
    //PWR_StartIIS();
    //PWR_StartTimer();
    
    Uart_TxEmpty(1);    //Wait until UART0 Tx buffer empty.
    
    rGPFCON=rGPFCON & ~(3<<0)|(2<<0); //PF0=EINT0
    rEXTINT0=rEXTINT0&(7<<0)|(0x2<<0); //EINT0=falling edge triggered
    
    pISR_EINT0=(U32)Eint0Int;
    pISR_RTC=(U32)AlarmInt;

    rSRCPND = BIT_EINT0|BIT_RTC; //to clear the previous pending states
    rINTPND = BIT_EINT0|BIT_RTC;
    
    rINTMSK=~(BIT_EINT0|BIT_RTC);

    SetAlarmWakeUp();
    rRTCCON = 0x0;	// R/W disable, but interrupt will be generated.

    rCLKCON|=(1<<2);  //enter IDLE mode.

    for(i=0;i<10;i++);   
        //wait until S3C2400X enters IDLE mode.	
        //wait EINT0 interrupt or RTC alarm interrupt

    rCLKCON&=~(1<<2);      
    //turn-off IDLE bit. IDLE bit should be turned off after wake-up.
   
    Uart_Printf("Return to Normal Mode.\n");

    rINTMSK=BIT_ALLMSK;
}
예제 #6
0
void Uart0_TxInt(void)
{
    if(*uart0TxStr != '\0')     // mas caracteres que enviar?
    {
	   if(*uart0TxStr == '\n') 
	   {
	      WrUTXH0(CR_char);		// escribir retorno de carro
	      Uart_TxEmpty();
	   } 
	   WrUTXH0(*uart0TxStr++);  // escribir caracter y actualizar puntero
    }
    else						// fin de la cadena
    {
	   rINTMSK|=BIT_UTXD0;		// enmascarar UTXD0
	   uart0TxStr = 0;			// borrar puntero 
    }
    rI_ISPC=BIT_UTXD0;		    // finalizar interrupción
}
예제 #7
0
파일: idle.c 프로젝트: cyj1988jyc/2440-test
void Test_MMUIdleMode(void)
{
    int i;
//    int extintMode;

    MMU_SetAsyncBusMode(); //ARM920T should be in the async. Bus mode.

    Uart_Printf("[MMU IDLE Mode Test]\n");
    Uart_Printf("This routine tests MMU registser7:Wait for interrupt function.\n");
    Uart_Printf("After 10 seconds, S3C2440 will wake up by RTC alarm interrupt.\n");
    Uart_Printf("S3C2440 will also wake up by EINT0.\n");
    Uart_TxEmpty(1);    //Wait until UART0 Tx buffer empty.

    rGPFCON=rGPFCON & ~(3<<0)|(2<<0); //PF0=EINT0
    rEXTINT0=rEXTINT0&(7<<0)|(0x2<<0); //EINT0=falling edge triggered
    
    pISR_EINT0=(U32)Eint0Int;
    pISR_RTC=(U32)AlarmInt;

    rSRCPND = BIT_EINT0|BIT_RTC; //to clear the previous pending states
    rINTPND = BIT_EINT0|BIT_RTC;
    
    rINTMSK=~(BIT_EINT0|BIT_RTC);
    //rINTMSK=~(BIT_RTC);
    //rINTMSK=BIT_ALLMSK;

    SetAlarmWakeUp();
    rRTCCON = 0x0;	// R/W disable, but interrupt will be generated.

    MMU_WaitForInterrupt();
     
    //wait until S3C2400X enters IDLE mode.	
    //wait EINT0 interrupt or RTC alarm interrupt
    for(i=0;i<10;i++);   

    Uart_Printf("Return to Normal Mode.\n");

    rINTMSK=BIT_ALLMSK;
}
예제 #8
0
void Test_Uart0_Fifo(void)
{
    Uart_Port_Set(); 
    Uart_Select(0);
    /******* UART0 Tx FIFO test with interrupt ********/     
    Uart_Printf("[Uart channel 0 Tx FIFO Interrupt Test]\n");
    Uart_TxEmpty(0);	//wait until tx buffer is empty.
    
    /* <Tx Trigger Level:8Byte> */    
    uart0TxStr="ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890->UART0 Tx FIFO interrupt(8byte) test is good!!!!\r\n";
    pISR_UART0=(U32)Uart0_TxFifo;
    rULCON0=(0<<6)|(0<<3)|(0<<2)|(3);	// Normal,No parity,One stop bit, 8bit
    rUCON0 &= 0x400;	// For the PCLK <-> UCLK fuction    
    rUCON0 |= (TX_INTTYPE<<9)|(RX_INTTYPE<<8)|(0<<7)|(0<<6)|(0<<5)|(0<<4)|(1<<2)|(0);
    //Clock,Tx:Def,Rx:Def,Rx timeout:x,Rx error int:x,Loop-back:x,Send break:x,Tx:int,Rx:x
    rUFCON0=(2<<6)|(1<<4)|(1<<2)|(1<<1)|(1);
    //Tx and Rx FIFO Trigger Level:8byte,Tx and Rx FIFO Reset,FIFO on
    rINTMSK=~(BIT_UART0);
    rINTSUBMSK=~(BIT_SUB_TXD0);
    Delay(500);
    rUFCON0=(2<<6)|(1<<4)|(1<<2)|(1<<1)|(0);
    //Tx and Rx FIFO Trigger Level:8byte,Tx and Rx FIFO Reset,FIFO off

    /* <Tx Trigger Level:12Byte> */    
    uart0TxStr="ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890->UART0 Tx FIFO interrupt(12byte) test is good!!!!\r\n";
    pISR_UART0=(unsigned)Uart0_TxFifo;
    rULCON0=(0<<6)|(0<<3)|(0<<2)|(3);	// Normal,No parity,One stop bit, 8bit
    rUCON0 &= 0x400;	// For the PCLK <-> UCLK fuction    
    rUCON0 |= (TX_INTTYPE<<9)|(RX_INTTYPE<<8)|(0<<7)|(0<<6)|(0<<5)|(0<<4)|(1<<2)|(0);
    //Clock,Tx:Def,Rx:Def,Rx timeout:x,Rx error int:x,Loop-back:x,Send break:x,Tx:int,Rx:x
    rUFCON0=(3<<6)|(2<<4)|(1<<2)|(1<<1)|(1);
    //Tx and Rx FIFO Trigger Level:12byte,Tx and Rx FIFO Reset,FIFO on
    rINTMSK=~(BIT_UART0);
    rINTSUBMSK=~(BIT_SUB_RXD0|BIT_SUB_TXD0|BIT_SUB_ERR0);
    Delay(500);
    rUFCON0=(3<<6)|(2<<4)|(1<<2)|(1<<1)|(0);
    //Tx and Rx FIFO Trigger Level:12byte,Tx and Rx FIFO Reset,FIFO off

    
    /******* UART0 Rx FIFO test with interrupt ********/     
    rx_dncs=0;
    rx_point=0;
    rx_isdone=1;
    rx_filesize=0;
    rx_checksum=0;
    Uart_Printf("[Uart channel 0 Rx FIFO Interrupt Test]\n");
//----------------------------------------------------
    pISR_UART0=(unsigned)Uart0_RxFifoOrErr;

    rULCON0=(0<<6)|(0<<3)|(0<<2)|(3);	// Normal,No parity,One stop bit, 8bit
    rUCON0 &= 0x400;	// For the PCLK <-> UCLK fuction
    rUCON0 |= (TX_INTTYPE<<9)|(RX_INTTYPE<<8)|(1<<7)|(1<<6)|(0<<5)|(0<<4)|(1<<2)|(1);
    //Clock,Tx:Def,Rx:Def,Rx timeout:o,Rx error int:o,Loop-back:x,Send break:x,Tx:int,Rx:int
    rUFCON0=(1<<6)|(0<<4)|(1<<2)|(1<<1)|(1);
    //Tx and Rx FIFO Trigger Level:4byte,Tx and Rx FIFO Reset,FIFO on

    // Clear Int Pending and Unmask 
    ClearPending(BIT_UART0);
    rINTMSK=~(BIT_UART0);
    rSUBSRCPND=(BIT_SUB_RXD0|BIT_SUB_TXD0|BIT_SUB_ERR0);
    rINTSUBMSK=~(BIT_SUB_RXD0|BIT_SUB_ERR0);

    Uart_Printf("Download the target file[*.bin] by Uart0\n");
	
    while(rx_isdone);

    rINTMSK |= (BIT_UART0);	
    rINTSUBMSK|=(BIT_SUB_RXD0|BIT_SUB_TXD0|BIT_SUB_ERR0);

    rUFCON0=(3<<6)|(2<<4)|(1<<2)|(1<<1)|(0);
    //Tx and Rx FIFO Trigger Level:12byte,Tx and Rx FIFO Reset,FIFO off
			
    if(rx_dncs==(rx_checksum&0xffff)) 
	Uart_Printf("\nDownload test OK!!!\n");
    else 
	Uart_Printf("\nError!!!\n");
    Uart_Port_Return();	
}
예제 #9
0
void Test_Uart0_Dma(void)
{
    Uart_Port_Set(); 
    Uart_Select(0);    
    /*********** UART0 Tx test with DMA0 ***********/ 
    isDone=1;
    uart0TxStr="ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890->UART0 Tx Test by DMA0 is good!!!!\r\n";
    Uart_Printf("\n[Uart channel 0 DMA0 Tx Test]\n");
    Uart_TxEmpty(0);
    
    pISR_DMA0  =(unsigned)Uart0_TxDmaDone;

    rULCON0=(0<<6)|(0<<3)|(0<<2)|(3);	// Normal,No parity,One stop bit, 8bit
    rUCON0 &= 0x400;	// For the PCLK <-> UCLK fuction    
    rUCON0 |= (TX_INTTYPE<<9)|(RX_INTTYPE<<8)|(0<<7)|(0<<6)|(0<<5)|(0<<4)|(2<<2)|(0);
    //Clock,Tx:Def,Rx:Def,Rx timeout:x,Rx error int:x,Loop-back:x,Send break:x,Tx:dma0,Rx:x

    /***DMA0 init***/
    rDISRC0=(U32)uart0TxStr;	// Start address
    rDISRCC0=(0<<1)|(0);		// AHB,Increment
    rDIDST0=(U32)UTXH0;			// Memory buffer Address
    rDIDSTC0=(1<<1)|(1);		// APB,Fixed
    rDCON0=(1<<31)|(0<<30)|(1<<29)|(0<<28)|(0<<27)|(1<<24)|(1<<23)|(1<<22)|(0<<20)|strlen((char*)uart0TxStr);
    //handshake, sync PCLK, TC int, single tx, single service, Uart0, H/W request,auto-reload off, Byte size Tx, Tx count value
    rINTMSK=~(BIT_DMA0);
    rDMASKTRIG0=(0<<2)|(1<<1)|(0);    //no-stop, DMA0 channel on, no-SW trigger 

    while(isDone);

    /*********** UART0 Rx test with DMA0 ***********/ 
    isDone=1;
    uart0RxStr=(char *)UARTBUFFER;
    Uart_Printf("\n[Uart channel 0 DMA0 Rx Test]\n");
    Uart_Printf("Type any five keys!!!\n");    
    Uart_Printf("Then you will see what you typed.\n");

    pISR_DMA0=(unsigned)Uart0_RxDmaDone;
    pISR_UART0=(unsigned)Uart0_RxDmaOrErr;
    
    rULCON0=(0<<6)|(0<<3)|(0<<2)|(3);	// Normal,No parity,One stop bit, 8bit
    rUCON0 &= 0x400;	// For the PCLK <-> UCLK fuction    
    rUCON0 |= (TX_INTTYPE<<9)|(RX_INTTYPE<<8)|(0<<7)|(1<<6)|(0<<5)|(0<<4)|(1<<2)|(2);
    //Clock,Tx:Def,Rx:Def,Rx timeout:x,Rx error int:o,Loop-back:x,Send break:x,Tx:int,Rx:dma0

    /***DMA0 init***/
    rDISRC0=(U32)URXH0;			// Start address
    rDISRCC0=(1<<1)|(1);		// APB,Fixed
    rDIDST0=(U32)uart0RxStr;	        // Memory buffer Address
    rDIDSTC0= (0<<1)|(0);		// AHB,Increment
    rDCON0=(1<<31)|(0<<30)|(1<<29)|(0<<28)|(0<<27)|(1<<24)|(1<<23)|(1<<22)|(0<<20)|(5);
    //handshake, sync PCLK, TC int, single tx, single service, Uart0, H/W request,auto-reload off, Byte size Tx, Tx count value

    // Clear Int Pending and Unmask    
    ClearPending(BIT_UART0);
    rINTMSK=~(BIT_DMA0|BIT_UART0);
    rSUBSRCPND=(BIT_SUB_TXD0|BIT_SUB_RXD0|BIT_SUB_ERR0);        
    rINTSUBMSK=~(BIT_SUB_ERR0);
    rDMASKTRIG0=(0<<2)|(1<<1)|(0);    //no-stop, DMA0 channel on, no-SW trigger 

    while(isDone);

    Uart_Printf("%s\n",uart0RxStr);
    Uart_Port_Return();
}