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

📄 44btest.c

📁 自己编写的
💻 C
字号:
/*
*modified by liangweidong for single chip ARM opration system in 25 july 2005.
*I hope the program can run by itself,  and it can realize all functions.
*this program is prepared for replanting to linux opration system.
*2005-7-25
*/

#include <string.h>
#include "..\inc\option.h"
#include "..\inc\44b.h"
#include "..\inc\44blib.h"
#include "..\inc\def.h"
#include "..\inc\cache.h"
#include "..\inc\uart.h"
#include "..\inc\power.h"
#include "..\inc\dma.h"
#include "..\inc\timer.h"
#include "..\inc\rtc.h"
#include "..\inc\etc.h"
#include "..\inc\iic.h"
#include "..\inc\stop.h"
#include "..\inc\extdma.h"
#include "..\inc\tp.h"
#include "..\inc\usb.h"
#include "..\inc\kb.h"
#include "..\inc\Pwm.h"
#include "..\inc\led.h"
#include "..\inc\lcd.h"
#include "..\inc\lcdlib.h"
#include "..\inc\44blcd.h"

#include "..\inc\character.h"
#include "..\inc\page.h"

extern unsigned int uart_baud = 115200;
extern unsigned char key_value = 0;
extern unsigned char file_sequence = 0;

//extern char *date[8];
flagsetting  *flag_setting;
fileparameter *file_parameter;



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

void keyboard_INI(void);
unsigned keyboard_ISR(void);

void ISR_ExINT0(void);
void ISR_ExINT1(void);
void ISR_ExINT2(void);
void ISR_ExINT3(void);
void ISR_ExINT4(void);
void ISR_ExINT5(void);
void ISR_ExINT6(void);

//void page_setfigure(void);
//void page_setmark(void);
//void  testcolor_tm320240(void);
//void clrscreen_color(void);
//void	blackscreen(void);
//void Lcd256_Init(void);
//void ColorXLine(unsigned int start_x, unsigned int start_y, unsigned  int linelong);
//void ColorYLine(unsigned int start_x, unsigned int start_y, unsigned  int linelong);
//void Display_ASCIITable( unsigned char x, unsigned short int y,   char *p);

#define TEST 0


typedef  struct 
{
	unsigned int key_totalsetting:1;		//
	unsigned int key_filesetting:1;			//
	unsigned int key_marksetting:1;		//
	unsigned int key_saveorload:1;			//
	unsigned int key_displayparamter:1;	//
	unsigned int key_monitor:1;			//
	unsigned int key_initsetting:1;			//
//	unsigned int key_backdata:1;			//
	unsigned int key_backdata:1;			//
	unsigned int key_uparrow:1;			//
	unsigned int key_timessetting:1;		//
	unsigned int key_running:1;			//
	unsigned int key_liftarrow:1;			//
	unsigned int key_downarrow:1;			//
	unsigned int key_rightarrow:1;			//
	unsigned int key_enter:1;				//
}key_states;



void Main(void)
{
	unsigned short int i;//, j,n;

	rSYSCFG=SYSCFG_8KB;
#if (PLLON==1)
	ChangePllValue(PLL_M,PLL_P,PLL_S);
#endif

	Isr_Init();
	Port_Init();
	Delay(500);
	Uart_Init(0,115200);
	Uart_Select(0);

	Lcd256_Init();


	while(TEST)
	{
	/*	

	
		i = hex_conver_decade(0x1234);
		Display_number(20*ASCIIX, 38*ASCIIY, i);
		Delay(50000);
		
		Test_Rtc_Alarm();
		Delay(10);
		Test_Rtc_Tick();
		Delay(10);
		DisplayRtc();
		
		clrscreen_color();
		Delay(1);
		init_total_file();
		Delay(1);
		page_setfigure();
		Delay(5000);
//		clrscreen_color();
//		Delay(1);

*/
		clrscreen_color();
		Delay(1);

		display_figure(0);
		Delay(5000);
		clrscreen_color();
		Delay(1);
		
		display_figure(1);
		Delay(5000);
		clrscreen_color();
		Delay(1);
		
		display_figure(2);
		Delay(5000);
		clrscreen_color();
		Delay(1);
		
		display_figure(3);
		Delay(5000);
		clrscreen_color();
		Delay(1);
	

	}

	clrscreen_color();
	Delay(1); 
	displaylcd();//display open picture.
	Delay(3000);
	keyboard_INI();

	 while(1)
	{
		i=0;
		clrscreen_color();
		Delay(1);
		init_total_file();
		Delay(1);
		page_setfigure();
		Delay(9000);
		
		while(1)
		{
		switch (key_value)
			{
			case 0x087:    //F1 总体参数设置
				clrscreen_color();
				Delay(1);
		 		page_other_set();
				
				Uart_Printf("key F1 total parameter set \n");

				key_value = 0;
				break;

			case 0x08b:  //F2 文件程序参数设置
				clrscreen_color();
				Delay(1);
				page_setfigure();
				
				Uart_Printf("key F2 file gragram parameter set \n");
				key_value = 0;			
				break;

			case 0x08d:  //F3 提醒标志设定
				clrscreen_color();
				Delay(1);
				page_setmark();
					
				Uart_Printf("key F3 the alarm marks set \n");
				key_value = 0;			
				break;

			case 0x08e:  //F4 数据保存或读取
				clrscreen_color();
				Delay(1);
				page_setfile();
				
				Uart_Printf("key F4 save or load file data \n");
				key_value = 0;
				break;

			case 0x0c7:  //F5 文件数据与参数显示
				clrscreen_color();
				Delay(1);
				page_data();
				
				Uart_Printf("key F5 display data and parameter of the file \n");
				key_value = 0;
				break;

			case 0x0cb:  //F6 监视
				clrscreen_color();
				Delay(1);
				page_moniter();
				
				Uart_Printf("key F6 is monitor key \n");
				key_value = 0;
				break;


			case 0x0cd:  //F7 初始调试设置
				clrscreen_color();
				Delay(1);
				page_machine_setup();
				
				Uart_Printf("key F7 initialization parameter set \n");
				key_value = 0;
				break;

			case 0x0ce:  //F8 通讯设置
				clrscreen_color();
				Delay(1);
				
				Uart_Printf("key F8 communication parameter set \n");
				key_value = 0;
				break;

			case 0x0a7:  //F9 数据备份
				clrscreen_color();
				Delay(1);
	//			page_usb();
				
				Uart_Printf("key F9 backup the file data to USB disk! \n");
				key_value = 0;
				break;

			case 0x0ab:  //向上箭头
				clrscreen_color();
				Delay(1);
	//			cursor_mark_up();
				
				Uart_Printf("key ^ ! \n");
				key_value = 0;
				break;

			case 0x0ad:  //10、100倍数键
	//			clrscreen();
	//			Delay(1);
	//			multple_set();
				
				Uart_Printf("key multiple 10 100 ! \n");
				key_value = 0;
				break;

			case 0x0ae:  //调整运行键
				clrscreen_color();
				Delay(1);
	//			adjust_run();
				
				Uart_Printf("key adjust and run key! \n");

				key_value = 0;
				break;

			case 0x097:  //向左箭头
				clrscreen_color();
				Delay(1);
	//			cursor_mark_lift();
				
				Uart_Printf("key <- ! \n");
				key_value = 0;
				break;

			case 0x09b:  //向下箭头
				clrscreen_color();
				Delay(1);
	//			cursor_mark_down();
				
				Uart_Printf("key v ! \n");
				key_value = 0;
				break;

			case 0x09d:  //向右箭头
				clrscreen_color();
				Delay(1);
	//			cursor_make_right();
				
				Uart_Printf("-> ! \n");
				key_value = 0;
				break;

			case 0x09e:  //确定键
				clrscreen_color();
				Delay(1);
	//			enter_key();

				Uart_Printf("enter key \n");
				key_value = 0;
				break;
	//		default:
	//			Display_number(10,  10,  key_value);
	//			Uart_Printf("the key value is error !!!\n");
	//			break;
			}
		}

	}
	  
}

void Isr_Init(void)
{
    U32 i;
    
    pISR_UNDEF=(unsigned)HaltUndef;
    pISR_SWI  =(unsigned)HaltSwi;
    pISR_PABORT=(unsigned)HaltPabort;
    pISR_DABORT=(unsigned)HaltDabort;

/*added by liangwd */
    pISR_EINT2 = (unsigned)keyboard_ISR;
    pISR_EINT3 = (unsigned)ISR_ExINT3;
    pISR_EINT0 = (unsigned)ISR_ExINT0;
    pISR_EINT1 = (unsigned)ISR_ExINT1;

//    pISR_EINT2 = (unsigned)ISR_ExINT2;
//	pISR_EINT4 = (unsigned)ISR_ExINT4;
	
	
     for(i=_RAM_STARTADDRESS;i<(_RAM_STARTADDRESS+0x20);i+=4)
    {
	*((volatile unsigned *)i)=0xEA000000+0x1FFE;
    }

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

    rINTMOD=0x0;	  // All=IRQ mode
    rINTMSK|= ~(BIT_GLOBAL|BIT_EINT2);	  // 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);
}


/*    added by liangwd*/
void ISR_ExINT0(void)
{
	
	Uart_Printf("Now, execute Exintrrupte0!!");
	Delay(100);
}

void ISR_ExINT1(void)
{
	Uart_Printf("Now, execute Exintrrupte1!!");
	Delay(100);
}


void ISR_ExINT2(void)
{
	Uart_Printf("Now, execute Exintrrupte2!!");
	Delay(100);
}

void ISR_ExINT3(void)
{
	Uart_Printf("Now, execute Exintrrupte3!!");
	Delay(100);
}

void ISR_ExINT4(void)
{
	Uart_Printf("Now, execute Exintrrupte4!!");
	Delay(100);
}

void ISR_ExINT5(void)
{
	Uart_Printf("Now, execute Exintrrupte5!!");
	Delay(100);
}

void ISR_ExINT6(void)
{
	Uart_Printf("Now, execute Exintrrupte6!!");
	Delay(100);
}


//writed by liangwd
//initialization the keyboard
void keyboard_INI(void)
{

	//initialize the port E and the port G

	//PORT E GROUP
	//PE0:FOUT, PE1:TxD0, PE2:RxD0, GPE3, GPE4, GPE5,GPE6,GPE7, CODECLK   
	//    10       10,      10,    01  , 01,   01,  01,  01,   10
	rPCONE = 0x2B;	  	//0x2B:input,0x2552A:output	
	rPUPE = 0xff;		        //0xff:inter pull-up resistor disable,0x00:pull-up able
//	rPUPE = 0x0;			//modified by liangweidong 2005-8-30
	Delay(1);
	
	//PORT F GROUP
	//IICSCL IICSDA  nWAIT nXBACK0 nXDREQ0 GPF5 GPF6 GPF7 GPF8 
	//  10     10      10    10      10     0    0    0    0
	rPCONF=0x9256A;		//0x2B:input,0x2552A:output	
	rPUPF=0x00;			//0xff:inter pull-up resistor disable,0x00:pull-up able
	rPDATF = 0x0;
	Delay(1);
	
      //PORT G GROUP
      //EINT0 EINT1 EINT2 EINT3 GPG4 GPG5 GPG6 GPG7
      //	  0x0
      //  11      11   11     11   01   01   01   01
      rPDATG=0x0;			/**/
      rPCONG=0x55FF;
      rPUPG=0xf;
    
      rSPUCR=0x7;  //pull-up disable
      rEXTINT=0x22222022;  //All EINT[7:0] will be falling edge triggered.

	//initialize interupte
	rINTCON = 0x5;
	rINTMOD = 0x0;
	rINTMSK = ~(BIT_GLOBAL | BIT_EINT2);
	pISR_EINT2 = (unsigned)keyboard_ISR;

}

//writed by liangweidong
//get key volue
void Getkey(void)
{

	unsigned	char x, y, xrecord, yrecord;

	x = (rPDATF & 0x01e0) >> 1;
	y = rPDATE &0x0f0;
	yrecord = y;

	//PORT E GROUP
	//PE0:FOUT, PE1:TxD0, PE2:RxD0, GPE3, GPE4, GPE5,GPE6,GPE7, CODECLK   
	//    10       10,      10,    01  , 01,   01,  01,  01,   10
	rPCONE = 0x2552A;		 //0x2B:input,0x2552A:output	
	rPUPE = 0x00;	        	//0xff:inter pull-up resistor disable,0x00:pull-up able	
	rPDATE=0xff;      		
	Delay(10);
	
	//PORT F GROUP
	//IICSCL IICSDA  nWAIT nXBACK0 nXDREQ0 GPF5 GPF6 GPF7 GPF8 
	//  10     10      10    10      10     0    0    0    0
	rPCONF=0x2A;		  	 //0x9256A:output,0x2A:input
	rPUPF=0xff;				 //0x00:pull-up able,0xff:disable
//	rPUPE = 0x0;				//modified by liangweidong 2005-8-30
	rPDATF = 0x0;			 //added by liangweidong
	Delay(100);
	
	x = (rPDATF & 0x01e0) >> 1;
	y = rPDATE &0x0f0;
	xrecord = x;		
	key_value = xrecord+ (yrecord>> 4);

	//PORT E GROUP
	//PE0:FOUT, PE1:TxD0, PE2:RxD0, GPE3, GPE4, GPE5,GPE6,GPE7, CODECLK   
	//    10       10,      10,    01  , 01,   01,  01,  01,   10
	rPCONE = 0x2B;	  	//0x2B:input,0x2552A:output	
	rPUPE = 0xff;	        //0xff:inter pull-up resistor disable,0x00:pull-up able	
//	rPUPE = 0x0;			//modified liangweidong 2005-8-30
	Delay(10);
	//PORT F GROUP
	//IICSCL IICSDA  nWAIT nXBACK0 nXDREQ0 GPF5 GPF6 GPF7 GPF8 
	//  10     10      10    10      10     0    0    0    0
	rPCONF=0x9256A;		//0x2B:input,0x2552A:output	
	rPUPF=0x00;			//0xff:inter pull-up resistor disable,0x00:pull-up able
	rPDATF = 0x0;
	Delay(10);
	
}

//writed by liangweiding 
//the keyboard interrupt service routine
unsigned __irq  keyboard_ISR (void)
{


	unsigned	char x, y, xrecord, yrecord;

	x = (rPDATF & 0x01e0) >> 1;
	y = rPDATE &0x0f0;
	yrecord = y;

	//PORT E GROUP
	//PE0:FOUT, PE1:TxD0, PE2:RxD0, GPE3, GPE4, GPE5,GPE6,GPE7, CODECLK   
	//    10       10,      10,    01  , 01,   01,  01,  01,   10
	rPCONE = 0x2552A;		 //0x2B:input,0x2552A:output	
	rPUPE = 0x00;	        	//0xff:inter pull-up resistor disable,0x00:pull-up able	
	rPDATE=0xff;      		
	Delay(10);
	
	//PORT F GROUP
	//IICSCL IICSDA  nWAIT nXBACK0 nXDREQ0 GPF5 GPF6 GPF7 GPF8 
	//  10     10      10    10      10     0    0    0    0
	rPCONF=0x2A;		  	 //0x9256A:output,0x2A:input
	rPUPF=0xff;				 //0x00:pull-up able,0xff:disable
//	rPUPE = 0x0;				//modified by liangweidong 2005-8-30
	rPDATF = 0x0;			 //added by liangweidong
	Delay(100);
	
	x = (rPDATF & 0x01e0) >> 1;
	y = rPDATE &0x0f0;
	xrecord = x;		
	key_value = xrecord+ (yrecord>> 4);

	//PORT E GROUP
	//PE0:FOUT, PE1:TxD0, PE2:RxD0, GPE3, GPE4, GPE5,GPE6,GPE7, CODECLK   
	//    10       10,      10,    01  , 01,   01,  01,  01,   10
	rPCONE = 0x2B;	  	//0x2B:input,0x2552A:output	
	rPUPE = 0xff;	        //0xff:inter pull-up resistor disable,0x00:pull-up able	
//	rPUPE = 0x0;			//modified liangweidong 2005-8-30
	Delay(10);
	//PORT F GROUP
	//IICSCL IICSDA  nWAIT nXBACK0 nXDREQ0 GPF5 GPF6 GPF7 GPF8 
	//  10     10      10    10      10     0    0    0    0
	rPCONF=0x9256A;		//0x2B:input,0x2552A:output	
	rPUPF=0x00;			//0xff:inter pull-up resistor disable,0x00:pull-up able
	rPDATF = 0x0;
	Delay(10);

	Uart_Printf("The key value is  %x  \n", key_value);
	rI_ISPC = BIT_EINT2;
	
	return 0;
}


⌨️ 快捷键说明

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