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

📄 main.c

📁 天煌公司的THUS-1型嵌入式实验/开发系统的串口通信实验
💻 C
字号:
#include <stdlib.h>
#include <string.h>
#include "..\inc\option.h"
#include "..\inc\44b.h"
#include "..\inc\44blib.h"
#include "..\inc\def.h"
#include "..\inc\uart.h"
void AutoTest(void);
void Isr_Init(void);
void HaltUndef(void);
void HaltSwi(void);
void HaltPabort(void);
void HaltDabort(void);
void Quit(void);
void ClearScreen(void);
void YourCode(void);


void * function[][2]=
{
	 (void *)Test_Uart0,   "UART 0    ",
       	 (void *)YourCode,     "Run Your code   ",
       	 (void *)ClearScreen,  "Clear Screen    ",    
       	 (void *)Quit,         "Quit            ",
	0,0
};

void YourCode(void)
{
    Uart_Printf("You can add code in main.c function--YourCode\n");//Add Your code here
}

/****************************************************************
   My first S344B0 Application
 ***************************************************************/

void Main(void)
{
        int i;
	float d;
        Port_Init();
   	Uart_Init(0,57600);
    	Uart_Select(0);
   	 Delay(0); 			 //calibrate Delay()
    	//ClearScreen(); 			//clear screen       
        Uart_Printf("\n*************************************************************************\n");
	Uart_Printf("\n  浙江天煌科技实业有限公司\n") ;
        Uart_Printf("\n  http:www.tianhuang.cn\n") ;
        Uart_Printf("\n    串口通信实验\n");
        Uart_Printf("\n (UART Experiment)\n");
        Uart_Printf("\n  S3C44B0X Test Program Ver 0.00 rSYSCFG=0x%x MCLK=%dMHz",rSYSCFG,MCLK/1000000) ;
        Uart_Printf("\n  COM:57600bps,8Bit,NP,UART0");
        Uart_Printf("\n  Date: " __DATE__ "\n");
        while(1)
      {
              Uart_Printf("\n");
	i=0;	
	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("\n请选择测试功能:");
	
	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;

    //rINTCON=0x1;	  // Vectored Int. IRQ enable,FIQ disable    
    rINTCON=0x5;	  // Non-vectored,IRQ enable,FIQ disable    

    rINTMOD=0x0;	  // All=IRQ mode
    rINTMSK=BIT_GLOBAL;	  // All interrupt is masked.
}




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);
}

void Quit(void)
{
    Uart_Printf("Programe end successfully.\n");
    while(1);
}



void ClearScreen(void)
{
    int i;
    for (i=0; i<24; i++)	
               Uart_Printf("\n");
}

⌨️ 快捷键说明

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