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

📄 44test.c

📁 Dignostic test program for SMDK441f board chip peripellel. ADS1.2 compiler
💻 C
字号:
#include "def.h"
#include "option.h"
#include <string.h>
#include "k44.h"
#include "k44lib.h"
#include "wdt.h"
#include "timer.h"
#include "uart.h"
#include "int.h"
#include "isram.h"
#include "iflash.h"
#include "iflashm.h"
#include "power.h"
#include "nwait.h"

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



void *function[][2]=
{                              //1234567890123456
    (void *)Test_Wdt, 		"WDog Timer      ",
    (void *)Test_BasicTimerInt, "BT int.         ",
    (void *)Test_Timer, 	"Timer012345     ",
    (void *)Test_TimerRegRead,  "TnCNT Read      ",
    (void *)Test_Uart,          "UART tx int.    ",
    (void *)MakeHwInt,          "H/W vector int. ",
    (void *)Test_Isram,         "Isram March     ",
    (void *)Test_Eint,		"EINT0,1,2       ",
    (void *)Test_Iflash,        "Iflash E/W/R    ",
    (void *)Test_IflashM,       "Iflash E/W/R M  ",
    (void *)Test_IdleMode,      "IDLE mode       ",
    (void *)Test_IdleModeWithTimer,
    				"IDLE_TIMER mode ",
    (void *)Test_StopMode,      "STOP mode       ",
    (void *)Test_Wait,		"nWAIT           ",

    0,0
};



void Main(void)
{
    int i;

    //_ctype_init(); //to use ctype.h

    Port_Init();
    ChangePllValue(PLL_M,PLL_P,PLL_S);
    
    rFMACON=0x82;           //rFMACON is configured properly.
    
    Led_Display(0x0);
    Isr_Init();
    Uart_Init(57600);
    Delay(0);

    while(1)
    {
	i=0;
        Uart_Printf("\n\nS3F441FX Test Program Ver 0.1 rSYSCFG=%x MCLK=%d\n",rSYSCFG,MCLK_FREQ);
	
	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");
	}
	
	Uart_Printf("Select the function to test?");
	i=Uart_GetIntNum();
	Uart_Printf("\n");
	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;

    rINTMODE=0x0;		//all IRQ
    rINTPEND=0x0;		//clear all pending bits
    rINTMASK=0x0;		
    rSYSCON =rSYSCON|0x100; 	//Enable global interrupt control.
    	    
    /*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);
}

⌨️ 快捷键说明

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