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

📄 int_test.c

📁 2410开发板在ADS下的中断测试程序。 运行步骤: 1 打开int.mcp工程文件 2 运行 3 按下开发板上的Eint0,Eint5,Eint19按键 观察终端上的中断输出 文件说明:
💻 C
字号:
//====================================================================
// File Name : 2410test.c
// Function  : S3C2410 Test Main Menu
// Program   : Shin, On Pil (SOP)
// Date      : May 30, 2002
// Version   : 0.0
// History
//   0.0 : Programming start (February 20,2002) -> SOP
//   1.0 (20020530) : First release for customer
//   1.1 (20020801) : Strata NOR Flash Added and etc. -> SOP
//====================================================================

#include <stdlib.h>
#include <string.h>

//Shin, On Pil
#include "def.h"
#include "option.h"
#include "2410addr.h"
#include "2410lib.h"
#include "2410slib.h"

#include "2410etc.h"
#include "2410IIC.h"
#include "2410iis.h"
#include "2410int.h"
#include "2410RTC.h"
#include "2410swi.h"
//#include "cpuspeed.h"
//#include "lcdpwr.h"
#include "timer.h"

//Kang, Weon Tark
#include "adc.h"
#include "dma.h"
#include "dma2.h"
#include "eint.h"
#include "extdma.h"
#include "k9s1208.h"
#include "mmu.h"
#include "nwait.h"
#include "sdi.h"
#include "stone.h"
#include "ts_auto.h"
#include "ts_sep.h"
#include "usbfifo.h"

//Shin, Jeong Seuk
#include "IrDA.h"
#include "lcd.h"
#include "lcdlib.h"
#include "glib.h"
#include "palette.h"
#include "spi.h"
#include "uart0.h"
#include "uart1.h"
#include "uart2.h"

//Kong, In Wook
#include "etc.h"
#include "flash.h"
#include "idle.h"
#include "pd6710.h"
#include "pll.h"
#include "power.h"
#include "pwr_c.h"
#include "stop.h"

void Isr_Init(void);
void HaltUndef(void);
void HaltSwi(void);
void HaltPabort(void);
void HaltDabort(void);

//===================================================================
void Main(void)
{
    int i,j,n,cc;
  	volatile int *shuma_write=(volatile int*)(0x28400000);
  	volatile int *da_write=(volatile int*)(0x28100000);
  	volatile int *can0_write=(volatile int*)(0x28200000);
  	volatile int *can1_write=(volatile int*)(0x28300000);
  	volatile int *ad_write=(volatile int*)(0x28500000);


//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//  1. 点亮板子上面的LED灯,查看原理图,作为IO口使用,闪5秒钟然后继续
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  Uart_Printf("SPICLK1 and NSS_KBD driver led for 5 seconds,please wait...\n");    
  Led_Display(15);        //2410lib.c


//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//  2. MMU的初始化
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      MMU_Init();         //mmu.c
   
#if ADS10   
    __rt_lib_init();                //for ADS 1.0
#endif


//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//  3. 改变时钟配置
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//    
//    ChangeClockDivider(0,0);          // 1:1:1    
//    ChangeClockDivider(1,0);          // 1:2:2    
    ChangeClockDivider(1,1);          // 1:2:4    2410lib.c

//    ChangeMPllValue(0x92,0x4,0x2);    // FCLK=50MHz    
//    ChangeMPllValue(0x96,0x5,0x1);    // FCLK=135428571Hz 
//    ChangeMPllValue(0x2a,0x1,0x0);    // FCLK=200MHz   
//    ChangeMPllValue(0x5c,0x1,0x1);    // FCLK=200MHz
//    ChangeMPllValue(0x5c,0x4,0x0);    // FCLK=200MHz
//    ChangeMPllValue(0x8e,0x7,0x0);    // FCLK=200MHz        
    ChangeMPllValue(0xa1,0x3,0x1);    // FCLK=202.8MHz  2410lib.c
//    ChangeMPllValue(0x66,0x1,0x1);    // FCLK=220MHz   
//    ChangeMPllValue(0x69,0x1,0x1);    // FCLK=226MHz       
//    ChangeMPllValue(0x96,0x2,0x1);    // FCLK=237MHz


//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//  4. 所有IO口的初始化配置
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
    Port_Init();              //2410lib.c
    

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//  5. 所有中断模式的初始化配置
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
    Isr_Init();
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//  6. RTC的初始化配置
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 

//    Rtc_Init();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//  7. 串口的初始化配置和选择
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 

    Uart_Init(0,115200);
    Uart_Select(0);

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//  8. delay和电源管理
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 

    //Check whether or not the POWER_OFF wake-up.
    Delay(0);	//calibrate Delay()
    Check_PowerOffWakeUp();  //It's needed for power-off STOP mode test.   

//SJS July 15, 2002
    //Turn on LCD. All test will be done while the LCD is turned on.
    //PWR_Lcd_Tft_16Bit_240320_On();

    //Save the wasted power consumption on GPIO.
    rIISPSR=(2<<5)|(2<<0); //IIS_LRCK=44.1Khz @384fs,PCLK=50Mhz.
    rGPHCON = rGPHCON & ~(0xf<<18)|(0x5<<18);   //CLKOUT 0,1=OUTPUT to reduce the power consumption.

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//  9. 测试LCD
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 

//SJS July 15, 2002
    //Turn on LCD. All test will be done while the LCD is turned on.
//    Test_Lcd_Tft_8Bit_240320_On();
    while(1)
    {
        i = 0;
      
        //GPG4 Output Port [9:8] 00      -> LCD power off
        rGPGCON = (rGPGCON & 0xfffffcff) | (1<<8);
        rGPGDAT &= 0xffef;        
        
        Uart_Printf("\n\nSMDK2410 Board (MCU S3C2410) Test Program Ver 1.1(20020801) FCLK = %d Hz\n\n", FCLK);
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//  10. 显示测试内容
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
        
     //   while(1)
     //   {   //display menu
     //       Uart_Printf("%2d:%s",i,function[i][1]);
     //          i++;
     //       if((int)(function[i][0])==0)
     //       {
    //            Uart_Printf("\n");
    //            break;
    //        }
    //        if((i%4)==0)
    //        Uart_Printf("\n");
    //    }

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//  11. 等待选择测试的项目
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
        Uart_Printf("\nWatchDog interrupt test : ");
        Test_Eint();
  //      i = Uart_GetIntNum();
  //      Uart_Printf("\n");

        //GPG4 Output Port [9:8] 01      -> LCD power On
        rGPGCON = (rGPGCON & 0xfffffcff) | (1<<8);
        rGPGDAT = (rGPGDAT & 0xffef) | (1<<4);        
        
  //      if(i>=0 && (i<(sizeof(function)/8)) ) 
  //          ( (void (*)(void)) (function[i][0]) )();            
    }
}

//===================================================================
void Isr_Init(void)
{
    pISR_UNDEF  = (unsigned)HaltUndef;
    pISR_SWI    = (unsigned)HaltSwi;
    pISR_PABORT = (unsigned)HaltPabort;
    pISR_DABORT = (unsigned)HaltDabort;
    
    rINTMOD     = 0x0;                     //All=IRQ mode
//    rINTCON=0x5;                           //Non-vectored,IRQ enable,FIQ disable    
    rINTMSK     = BIT_ALLMSK;              //All interrupt is masked.
    rINTSUBMSK  = BIT_SUB_ALLMSK;          //All sub-interrupt is masked. <- April 01, 2002 SOP

//    rINTSUBMSK  = ~(BIT_SUB_RXD0);         //Enable Rx0 Default value=0x7ff
//    rINTMSK     = ~(BIT_UART0);            //Enable UART0 Default value=0xffffffff    
    
//    pISR_UART0=(unsigned)RxInt;            //pISR_FIQ,pISR_IRQ must be initialized
}

//===================================================================
void HaltUndef(void)
{
    Uart_Printf("Undefined instruction exception.\n");
    while(1);
}

//===================================================================
void HaltSwi(void)
{
    Uart_Printf("SWI exception.\n");
    while(1);
}

//===================================================================
void HaltPabort(void)
{
    Uart_Printf("Pabort exception.\n");
    while(1);
}

//===================================================================
void HaltDabort(void)
{
    Uart_Printf("Dabort exception.\n");
    while(1);
}





/*
//=========================
    while(1)
    {
       Led_Display(3);
    }
//=========================    
*/
/*
//=========================
    while(1)
    {
       Led_Display(1);
       Delay(1500);   
       Led_Display(2);
       Delay(1500);             
       Led_Display(4);
       Delay(1500);   
       Led_Display(8);
       Delay(1500);                
    }
//=========================   
*/

⌨️ 快捷键说明

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