📄 main.c
字号:
//*----------------------------------------------------------------------------
//* ATMEL Microcontroller Software Support - ROUSSET -
//*----------------------------------------------------------------------------
//* The software is delivered "AS IS" without warranty or condition of any
//* kind, either express, implied or statutory. This includes without
//* limitation any warranty or condition with respect to merchantability or
//* fitness for any particular purpose, or against the infringements of
//* intellectual property rights of others.
//*----------------------------------------------------------------------------
//* 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 "ics1523.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);
//////////////////////////////////////////////////////////////////////////////
// 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];
//* 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);
}
//*----------------------------------------------------------------------------
//* \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 */
}
//*----------------------------------------------------------------------------
//* \fn AT91F_FillDisplayMemory
//* \brief Fill display memory by filling 1.25 MB Display Memory
//*----------------------------------------------------------------------------
__inline void AT91F_FillDisplayMemory(void)
{
char* buf ;
int i;
short* disp_mem = (short *) S1D13806_DISP_MEM_BASE ;
//* Fill display memory by filling 1.25 MB Display Memory with 0xFF
buf = ( char * ) S1D13806_DISP_MEM_BASE ;
for ( i = 0 ; i < ( int ) ( 640 * 480 * 2 ) ; i++, buf++ )
{
if ( ( i < ( int ) ( ( ( 640 * 480 * 2 )/2 ) - ( 640 * 2 * 5 ) ) )
|| ( i > ( int ) ( ( ( 640 * 480 * 2 )/2 ) + ( 640 * 2 * 5 ) ) ) )
*buf = 0xFF ;
else
*buf = 0x00 ;
}
//* Fill display memory by filling 1.25 MB Display Memory with Green
for ( i = 0 ; i < ( int ) ( 640 * 480 * 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 * 480 * 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 Red
for ( i = 0 ; i < ( int ) ( 640 * 480 * 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 + Blue
for ( i = 0 ; i < ( int ) ( 640 * 480 * 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 * 480 * 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 * 480 * 2 )/2 ; i++, disp_mem++ )
*disp_mem = ( GREEN_WORD_MASK | RED_WORD_MASK ) ;
buf = ( char * ) S1D13806_DISP_MEM_BASE ;
//* Clear display memory by filling 1.25 MB Display Memory with 0
for ( i = 0 ; i < ( int ) ( 640 * 480 * 2 ) ; i++, buf++ )
*buf = 0x00 ;
buf = ( char * ) S1D13806_DISP_MEM_BASE ;
for ( i = 0 ; i < ( int ) ( 640 * 480 * 4 ) ; i++, buf++ )
*buf = 0x00 ;
buf = ( char * ) S1D13806_DISP_MEM_BASE ;
for ( i = 0 ; i < ( int ) ( 640 * 480 * 4 ) ; i++, buf++ )
image_buf[i] = *buf ;
}
//*----------------------------------------------------------------------------
//* \fn main
//* \brief
//*----------------------------------------------------------------------------
int main()
{
char message[64];
int i,ack ;
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);
//* ICS1523 Clock Generator Initialisation
ack = AT91F_ICS1523_Init ( (unsigned int) Clock_Conf, (unsigned int) MCK_KHz) ;
if ( ack == (int) ICS1523_ACCESS_OK )
sprintf (message, " \n\rICS1523 Clock Generator Init OK\n\r" ) ;
else
if ( ack == (int) ICS1523_ACCESS_ERROR )
sprintf (message, " \n\rICS1523 Clock Generator Init failed\n\r" ) ;
AT91F_DBGU_Printk(message);
//* Epson S1D13806 Initialisation FOR A CRT Monitor !!!!!!!!!!!
AT91F_S1D13806_Init ( s1d13806_base,
S1D13806_DISP_MEM_BASE,
(unsigned int) CRT_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("Fill Display \n\r");
AT91F_FillDisplayMemory();
//* Display Strings
AT91F_DBGU_Printk("Display Strings\n\r");
for ( i = 0 ; i < ( ( ( ( ( ( 640 * 480 * 2 ) / 16 ) / 16 ) / 8 ) + 2 ) * 4 ) ; i++ )
{
sprintf (message," Test OK ! %04d",i);
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);
while(1);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -