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

📄 com_test.c

📁 自己写的小程序包含串口和LCD
💻 C
字号:

#include <stdio.h>
#include "def.h"
//#include "timer.h"
#include "usrdef.h"

#include "2410addr.h"

extern void Port_Init(void);
extern void Uart_Init(int mclk,int baud);
//extern void Uart_Printf(char *fmt,...);
extern void Uart_Select(int ch);
extern void Delay(int time);
extern void Uart_SendString(char *string);
extern void SetClockDivider(int hdivn,int pdivn);
extern void Uart_Init(int mclk,int baud);
extern void ChangeMPllValue(int mdiv,int pdiv,int sdiv);
extern void Isr_Init(void);
extern U8 	SetSysFclk(U32 val);
extern void Uart_SendByte(int data);
extern char Uart_Getch(void);
extern void LED_flash(char LED_n);
extern int	ISaNUM(unsigned char LED);
extern void Uart_printf(char *frm,...);


#define	CLOCK_TIMER	(1<<8)
#define CLOCK_NAND	(1<<4)
#define UART_BAUD 115200

//extern static char LED_n;
//+1************************************************************
extern void LCD_Init(void);
extern void Lcd_Pwren_Init_On_Off( unsigned char m );
extern void LCD_Port_Init( void );
extern void LCD_Init(void);
extern void Lcd_ClearScr( U16 c);
//extern void Paint_Bmp(int x0, int y0, int h, int l, unsigned char bmp[]);

extern unsigned char girl3_640_480[];


//--------------------------------------------------------------
static void Paint_Bmp(int x0, int y0, int h, int l, unsigned char bmp[])
{
    int x, y;
    U32 c;
    int p = 0;
    
    for( y = 0 ; y < l ; y++ )
    {
        for( x = 0 ; x < h ; x++ )
        {
            c = bmp[p+1] | (bmp[p]<<8) ;
            
            if ( ( (x0+x) < SCR_XSIZE_TFT_640480) && ( (y0+y) < SCR_YSIZE_TFT_640480) )
                LCD_BUFER[y0+y][x0+x] = c ;
            
            p = p + 2 ;
        }
    }
}

//+1************************************************************

int Main(void)
{
	//unsigned int LED=0;
	//MMU_Init();
	/*
	rGPHCON = rGPHCON & (~(0xffff)) ;
	rGPHCON = rGPHCON | (0xaaa0) ;
    rGPHUP  = 0x0;    // The pull up function is enable
    */
    SetClockDivider(1,1);
//	ChangeMPllValue(0xa1,0x3,0x1);
	SetSysFclk(((192<<12)|(4<<4)|1));
	Delay(1);
	Port_Init();
	Isr_Init();
	//+1*********************************************************
	LCD_Init();
	LCD_Port_Init();
    LCD_Init();
    rLCDCON1 |= 1;         // ENVID=ON
    Lcd_ClearScr( (0x00<<11) | (0x3F<<5) | (0x00) );     //clear screen
	//+1_over****************************************************
	
	Uart_Select(0);
	Uart_Init(0, UART_BAUD);
	EnableModuleClock(CLOCK_UART0|CLOCK_TIMER|CLOCK_GPIO|CLOCK_NAND);
	//ChangeMPLLValue();  //please set the Value
	
	
	while(1)
	{
		//Uart_SendString("\n,This is the first test!");
		Paint_Bmp(0,0,640,480, girl3_640_480);
		Uart_SendByte('\n');
		Uart_SendString("\n************************");
		Uart_SendString("\n*     我的测试程序     *");
		Uart_SendString("\n************************");
		

		LED_n=Uart_Getch();
		LED=ISaNUM(LED_n);
		Uart_printf("\n您刚才输入的是:%d",LED);
		LED_flash(LED);
		Delay(500);
		LED=0;
		break;	
		
		//Delay(5000);
	}
}

⌨️ 快捷键说明

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