📄 main.c
字号:
//*----------------------------------------------------------------------------
//* ATMEL Microcontroller Software Support - ROUSSET -
//*----------------------------------------------------------------------------
//* File Name : main.c
//* Object : main application written in C
//* Creation : FB 13/01/2003
//* 1.1 31/03/03 JPP : Add DBGU message
//*----------------------------------------------------------------------------
#include <stdio.h>
#include "s1d13806.h"
#include "AT91RM9200.h"
#include "lib_AT91RM9200.h"
/* Master Clock */
#define MCK_KHz 60000
/* Video Graphic Controller */
#define S1D13806_BASE ( (unsigned char *) 0x30000000 )
#define S1D13806_DISP_MEM_BASE ( ( (int) S1D13806_BASE) + ((int) 0x200000) )
//////////////////////////////////////////////////////////////////////////////
// Externals
//////////////////////////////////////////////////////////////////////////////
//* Interrupt Handlers
extern void AT91F_ST_ASM_HANDLER(void);
//* Function in init.c
extern void AT91F_DBGU_Printk(char *buffer);
extern char s1d13806_CharSet16[16*256];
//////////////////////////////////////////////////////////////////////////////
// Global variables
//////////////////////////////////////////////////////////////////////////////
//* Image data buffer declaration
//static char image_buf[ ( H_MAX_RES * V_MAX_RES * 3 ) + BMP_HEADER_SIZE ] ;
//* Message buffer
char MsgBuffer[256];
unsigned char Hzm_1[]={
0x11,0x00,0x11,0x00,0x11,0x00,0x23,0xFC, // 你
0x22,0x04,0x64,0x08,0xA8,0x40,0x20,0x40,
0x21,0x50,0x21,0x48,0x22,0x4C,0x24,0x44,
0x20,0x40,0x20,0x40,0x21,0x40,0x20,0x80,
0x10,0x00,0x11,0xFC,0x10,0x04,0x10,0x08, // 好
0xFC,0x10,0x24,0x20,0x24,0x24,0x27,0xFE,
0x24,0x20,0x44,0x20,0x28,0x20,0x10,0x20,
0x28,0x20,0x44,0x20,0x84,0xA0,0x00,0x40,
0x00,0x00,0x47,0xFE,0x34,0x02,0x18,0xA4, // 深
0x81,0x10,0x62,0x48,0x20,0x40,0x08,0x44,
0x17,0xFE,0x20,0xE0,0xE1,0x50,0x22,0x4E,
0x2C,0x44,0x20,0x40,0x20,0x40,0x20,0x40,
0x10,0x04,0x11,0x04,0x11,0x24,0x11,0x24, // 圳
0x15,0x24,0xFF,0x24,0x11,0x24,0x11,0x24,
0x11,0x24,0x11,0x24,0x1D,0x24,0xF1,0x24,
0x42,0x24,0x02,0x04,0x04,0x04,0x00,0x04,
0x02,0x00,0x01,0x00,0x00,0x04,0xFF,0xFE, // 市
0x01,0x00,0x01,0x08,0x3F,0xFC,0x21,0x08,
0x21,0x08,0x21,0x08,0x21,0x08,0x21,0x08,
0x21,0x28,0x21,0x10,0x01,0x00,0x01,0x00,
0x08,0x20,0x08,0x28,0x7F,0xFC,0x08,0x20, // 英
0x01,0x10,0x1F,0xF8,0x11,0x10,0x11,0x10,
0x11,0x14,0xFF,0xFE,0x01,0x00,0x02,0x80,
0x02,0x80,0x04,0x60,0x18,0x1C,0x60,0x08,
0x00,0x10,0x1F,0xF8,0x10,0x10,0x11,0x10, // 贝
0x11,0x10,0x11,0x10,0x11,0x10,0x11,0x10,
0x11,0x10,0x11,0x10,0x11,0x10,0x12,0x10,
0x02,0x40,0x04,0x20,0x08,0x18,0x30,0x08,
0x10,0x40,0x10,0x44,0x2F,0xFE,0x20,0x40, // 德
0x47,0xFC,0x94,0xA4,0x14,0xA4,0x27,0xFC,
0x60,0x00,0xAF,0xFE,0x20,0x40,0x21,0x20,
0x25,0x24,0x25,0x0A,0x28,0xFA,0x20,0x00,
0x02,0x00,0x02,0x04,0xFF,0xFE,0x04,0x00, // 有
0x04,0x10,0x0F,0xF8,0x08,0x10,0x18,0x10,
0x2F,0xF0,0x48,0x10,0x88,0x10,0x0F,0xF0,
0x08,0x10,0x08,0x10,0x08,0x50,0x08,0x20,
0x00,0x08,0x7D,0xFC,0x45,0x08,0x49,0x08, // 限
0x49,0xF8,0x51,0x08,0x49,0x08,0x49,0xF8,
0x45,0x04,0x45,0x88,0x45,0x50,0x69,0x20,
0x51,0x10,0x41,0x4E,0x41,0x84,0x41,0x00,
0x00,0x00,0x00,0x80,0x04,0x80,0x04,0x40, // 公
0x08,0x40,0x08,0x20,0x11,0x10,0x21,0x0E,
0xC2,0x04,0x02,0x00,0x04,0x00,0x08,0x40,
0x10,0x20,0x1F,0xF0,0x00,0x10,0x00,0x00,
0x00,0x08,0x3F,0xFC,0x00,0x08,0x00,0x48, // 司
0xFF,0xE8,0x00,0x08,0x00,0x88,0x3F,0xC8,
0x20,0x88,0x20,0x88,0x20,0x88,0x20,0x88,
0x3F,0x88,0x20,0x88,0x00,0x28,0x00,0x10
};
unsigned char Hzm_2[]={
0x00,0x50,0x00,0x48,0x7F,0xFC,0x40,0x40, // 感
0x7F,0xC0,0x40,0x48,0x5F,0x48,0x51,0x50,
0x51,0x22,0x5F,0x52,0x90,0x8E,0x02,0x00,
0x29,0x90,0x28,0xAC,0x48,0x24,0x07,0xE0,
0x02,0x08,0x44,0x88,0x2F,0xC8,0x28,0x88, // 谢
0x0F,0x88,0x08,0xFE,0xEF,0x88,0x28,0x88,
0x28,0xC8,0x3F,0xA8,0x21,0xA8,0x2A,0x88,
0x34,0x88,0x28,0x88,0x12,0xA8,0x01,0x10,
0x11,0x00,0x11,0x00,0x11,0x00,0x23,0xFC, // 你
0x22,0x04,0x64,0x08,0xA8,0x40,0x20,0x40,
0x21,0x50,0x21,0x48,0x22,0x4C,0x24,0x44,
0x20,0x40,0x20,0x40,0x21,0x40,0x20,0x80,
0x04,0x80,0x7E,0x80,0x44,0x84,0x54,0xFE, // 购
0x55,0x04,0x56,0x04,0x54,0x44,0x54,0x44,
0x54,0x84,0x54,0xA4,0x55,0x14,0x55,0xF4,
0x10,0x14,0x28,0x04,0x44,0x28,0x84,0x10,
0x00,0x00,0x7F,0xFC,0x00,0x84,0x08,0x88, // 买
0x06,0x80,0x02,0x80,0x20,0x80,0x19,0x00,
0x09,0x04,0xFF,0xFE,0x02,0x00,0x02,0xC0,
0x04,0x30,0x08,0x18,0x30,0x0C,0xC0,0x04,
0x04,0x80,0x0E,0xA0,0x78,0x90,0x08,0x90, // 我
0x08,0x84,0xFF,0xFE,0x08,0x80,0x08,0x90,
0x0A,0x90,0x0C,0x60,0x18,0x40,0x68,0xA0,
0x09,0x20,0x0A,0x14,0x28,0x14,0x10,0x0C,
0x00,0x00,0x00,0x80,0x04,0x80,0x04,0x40, // 公
0x08,0x40,0x08,0x20,0x11,0x10,0x21,0x0E,
0xC2,0x04,0x02,0x00,0x04,0x00,0x08,0x40,
0x10,0x20,0x1F,0xF0,0x00,0x10,0x00,0x00,
0x00,0x08,0x3F,0xFC,0x00,0x08,0x00,0x48, // 司
0xFF,0xE8,0x00,0x08,0x00,0x88,0x3F,0xC8,
0x20,0x88,0x20,0x88,0x20,0x88,0x20,0x88,
0x3F,0x88,0x20,0x88,0x00,0x28,0x00,0x10,
0x02,0x00,0x01,0x00,0x01,0x08,0x7F,0xFC, // 产
0x08,0x10,0x04,0x20,0x04,0x48,0x1F,0xFC,
0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,
0x20,0x00,0x20,0x00,0x40,0x00,0x80,0x00,
0x00,0x10,0x1F,0xF8,0x10,0x10,0x10,0x10, // 品
0x10,0x10,0x1F,0xF0,0x10,0x10,0x02,0x04,
0x7F,0xFE,0x42,0x84,0x42,0x84,0x42,0x84,
0x42,0x84,0x42,0x84,0x7E,0xFC,0x42,0x84
};
//* system timer counter
unsigned int StTick = 0;
//*----------------------------------------------------------------------------
//* \fn AT91F_GetTickCount
//* \brief This function returns the value of the system timer
//*----------------------------------------------------------------------------
unsigned int AT91F_GetTickCount(void)
{
return(StTick);
}
void delay_ms(unsigned int ms)
{
unsigned int k,j;
for(k=0;k<ms;k++)
{
for(j=0;j<50;j++) j=j;
}
}
//*----------------------------------------------------------------------------
//* \fn AT91F_ST_HANDLER
//* \brief This function is invoked by main
//*----------------------------------------------------------------------------
void AT91F_ST_HANDLER(void)
{
volatile int StStatus;
// Read the system timer status register
StStatus = *(AT91C_ST_SR);
StTick++;
}
//*----------------------------------------------------------------------------
//* \fn AT91F_ST_SetPeriodIntervalTimer
//* \brief Set Periodic Interval Interrupt (period min <=> 1/32768 s)
//*----------------------------------------------------------------------------
__inline void AT91F_ST_SetPeriodIntervalTimer(
AT91PS_ST pSt,
unsigned int period)
{
volatile int status;
pSt->ST_IDR = AT91C_ST_PITS; /* Interrupt disable Register */
status = pSt->ST_SR;
pSt->ST_PIMR = period; /* Period Interval Mode Register */
}
__inline void Display_Chinse(unsigned char *zm,int Pos_x,int Pos_y,unsigned short Color_Sel )
{
short* Display_mem = (short *) S1D13806_DISP_MEM_BASE ;
int i,j;
static unsigned char Msb,Lsb;
static unsigned short MaskBit;
static unsigned short HzkLineData;
Display_mem=Display_mem+(Pos_y*640)+Pos_x;
for(j=0;j<16;j++)
{
Msb=*(zm+2*j);
Lsb=*(zm+2*j+1);
HzkLineData=((((short)Msb)*256)+((short)Lsb));
MaskBit=0x8000;
for ( i = 0 ; i < 16 ; i++, Display_mem++)
{
if((HzkLineData&MaskBit)!=0)
*Display_mem = Color_Sel ;
else
*Display_mem = 0 ;
MaskBit=(MaskBit>>1);
}
Display_mem=Display_mem+640-16;//goto next line
}
}
__inline void Print_Chinse(unsigned char *zm,int Pos_x,int Pos_y,unsigned char numberHz,unsigned short Color_Sel )
{
unsigned char i;
for(i=0;i<numberHz;i++)
{
Display_Chinse(zm+i*32,Pos_x,Pos_y,Color_Sel);
Pos_x=Pos_x+16;
}
}
//*----------------------------------------------------------------------------
//* \fn AT91F_FillDisplayMemory
//* \brief Fill display memory by filling 1.25 MB Display Memory
//*----------------------------------------------------------------------------
__inline void AT91F_FillDisplayMemory(void)
{
char* buf ;
int i,pos_x,pos_y;
short* disp_mem = (short *) S1D13806_DISP_MEM_BASE ;
disp_mem = ( short * ) S1D13806_DISP_MEM_BASE ;
//* Fill display memory by filling 1.25 MB Display Memory with Green
for ( i = 0 ; i < ( int ) (640 * 480) ; i++, disp_mem++ )
*disp_mem = 00 ;
pos_x=10;
pos_y=0;
Print_Chinse(Hzm_1,pos_x,pos_y,12,RED_WORD_MASK);
pos_x=pos_x+2;
pos_y=pos_y+16;
Print_Chinse(Hzm_1,pos_x,pos_y,12,GREEN_WORD_MASK);
pos_x=pos_x+2;
pos_y=pos_y+16;
Print_Chinse(Hzm_1,pos_x,pos_y,12,BLUE_WORD_MASK);
pos_x=pos_x+2;
pos_y=pos_y+16;
Print_Chinse(Hzm_1,pos_x,pos_y,12,GREEN_WORD_MASK | RED_WORD_MASK);
pos_x=pos_x+2;
pos_y=pos_y+16;
Print_Chinse(Hzm_1,pos_x,pos_y,12,GREEN_WORD_MASK | BLUE_WORD_MASK);
pos_x=pos_x+2;
pos_y=pos_y+16;
Print_Chinse(Hzm_1,pos_x,pos_y,12,RED_WORD_MASK | BLUE_WORD_MASK);
pos_x=pos_x+2;
pos_y=pos_y+16;
Print_Chinse(Hzm_2,pos_x,pos_y,10,RED_WORD_MASK);
pos_x=pos_x+2;
pos_y=pos_y+16;
Print_Chinse(Hzm_2,pos_x,pos_y,10,GREEN_WORD_MASK);
pos_x=pos_x+2;
pos_y=pos_y+16;
Print_Chinse(Hzm_2,pos_x,pos_y,10,BLUE_WORD_MASK);
pos_x=pos_x+2;
pos_y=pos_y+16;
Print_Chinse(Hzm_2,pos_x,pos_y,10,GREEN_WORD_MASK | RED_WORD_MASK);
pos_x=pos_x+2;
pos_y=pos_y+16;
Print_Chinse(Hzm_2,pos_x,pos_y,10,GREEN_WORD_MASK | BLUE_WORD_MASK);
pos_x=pos_x+2;
pos_y=pos_y+16;
Print_Chinse(Hzm_2,pos_x,pos_y,10,RED_WORD_MASK | BLUE_WORD_MASK);
delay_ms(40000);
disp_mem = ( short * ) S1D13806_DISP_MEM_BASE ;
//* Fill display memory by filling 1.25 MB Display Memory with Red
for ( i = 0 ; i < ( int ) ( 640 * 80 *2)/2 ; i++, disp_mem++ )
*disp_mem = RED_WORD_MASK ;
// disp_mem = ( short * ) S1D13806_DISP_MEM_BASE ;
//* Fill display memory by filling 1.25 MB Display Memory with Green
for ( i = 0 ; i < ( int ) ( 640 * 80*2 )/2 ; i++, disp_mem++ )
*disp_mem =GREEN_WORD_MASK ;
//disp_mem = ( short * ) S1D13806_DISP_MEM_BASE ;
//* Fill display memory by filling 1.25 MB Display Memory with Blue
for ( i = 0 ; i < ( int ) ( 640 * 80*2 )/2 ; i++, disp_mem++ )
*disp_mem =BLUE_WORD_MASK ;
// disp_mem = ( short * ) S1D13806_DISP_MEM_BASE ;
//* Fill display memory by filling 1.25 MB Display Memory with Green + Blue
for ( i = 0 ; i < ( int ) ( 640 * 80 *2)/2 ; i++, disp_mem++ )
*disp_mem = ( GREEN_WORD_MASK | BLUE_WORD_MASK );
// disp_mem = ( short * ) S1D13806_DISP_MEM_BASE ;
//* Fill display memory by filling 1.25 MB Display Memory with Red + Blue
for ( i = 0 ; i < ( int )( 640* 80*2 )/2 ; i++, disp_mem++ )
*disp_mem = ( RED_WORD_MASK | BLUE_WORD_MASK ) ;
//disp_mem = ( short * ) S1D13806_DISP_MEM_BASE ;
//* Fill display memory by filling 1.25 MB Display Memory with Green + Red
for ( i = 0 ; i < ( int ) ( 640 * 80 *2)/2 ; i++, disp_mem++ )
*disp_mem = ( GREEN_WORD_MASK | RED_WORD_MASK ) ;
delay_ms(40000);
disp_mem = ( short * ) S1D13806_DISP_MEM_BASE ;
//buf = ( char * ) S1D13806_DISP_MEM_BASE ;
for ( i = 0 ; i < ( int ) ( 640 * 480*2 )/2 ; i++, disp_mem++ )
*disp_mem = 0x00 ;
}
//*----------------------------------------------------------------------------
//* \fn main
//* \brief
//*----------------------------------------------------------------------------
int main()
{
char message[64];
int i ;
AT91PS_S1D13806_Desc s1d13806_base = (AT91PS_S1D13806_Desc) S1D13806_BASE;
AT91F_DBGU_Printk("\n\r-I- ==================================================\n\r");
AT91F_DBGU_Printk("-I- AT91RM9200 Epson Embedded Memory Display Controller Test\n\r");
AT91F_DBGU_Printk("-I- --------------------------------------------------------\n\r");
//* System Timer initialization
AT91F_ST_SetPeriodIntervalTimer(AT91C_BASE_ST, 0x3); // period <=> 100us
AT91F_ST_EnableIt(AT91C_BASE_ST, AT91C_ST_PITS);
AT91F_AIC_ConfigureIt ( AT91C_BASE_AIC, // AIC base address
AT91C_ID_SYS, // System peripheral ID
AT91C_AIC_PRIOR_HIGHEST, // Max priority
AT91C_AIC_SRCTYPE_INT_LEVEL_SENSITIVE, // Level sensitive
AT91F_ST_ASM_HANDLER );
//* Enable ST interrupt
AT91F_AIC_EnableIt(AT91C_BASE_AIC, AT91C_ID_SYS);
//* Epson S1D13806 Initialisation FOR A CRT Monitor !!!!!!!!!!!
AT91F_DBGU_Printk(" Init S1D13806 Display Controller \n\r");
AT91F_S1D13806_Init ( s1d13806_base,
S1D13806_DISP_MEM_BASE,
(unsigned int) TFT_Display_Conf,
(unsigned int) Display_Def_0,
(unsigned int) Char_Def_0,
(unsigned int) MCK_KHz ) ;
AT91F_DBGU_Printk("S1D13806 Display Controller Init OK\n\r");
//* Fill Display Memory
AT91F_DBGU_Printk("LCD汉字显示测试: \n\r");
while(1)
{
AT91F_FillDisplayMemory();
AT91F_DBGU_Printk("LCD汉字显示测试: \n\r");
}
//* Display Strings
AT91F_DBGU_Printk("Display Strings\n\r");
for ( i = 0 ; i < ( ( ( ( ( ( 320 *240) / 16 ) / 16 ) / 8 ) + 2 ) * 4 ) ; i++ )
{
sprintf (message,"SHARP STN LCD Test OK !");
AT91F_S1D13806_16bpp_print_string ( s1d13806_base, message ) ;
sprintf (message," How Are you 123456789 !");
AT91F_S1D13806_16bpp_print_string ( s1d13806_base, message ) ;
}
//* Display Last String
sprintf ( message, " Auto Test Finished ") ;
AT91F_S1D13806_16bpp_print_string ( s1d13806_base, message ) ;
AT91F_DBGU_Printk(message);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -