📄 main.c
字号:
//*************************************************************************
// Camera Module Controler
// Writed By Holmestang
// 编译环境 : ICCAVR 支持器件 : ATMEGA8515
// Use extern CRYSTAL 11.0592MHz fusebit 0xD9DE, lockbit 0x00FF
// COPYRIGHT (C) 2007
// EXTRAM: 32K (Max Address 0x260~0xFFFF)
// Crystal: 16.000Mhz
//
//*************************************************************************
#include "Main.h"
#include "TFTdriver.h"
#include "Serinit.h"
#include "Delay.h"
unsigned char *Bmp_Buffer=(unsigned char *)0x0260;
///////////////////////////////////////////////////////////
void main(void)
{
CLI(); //Disable all interrupts
PORTA = 0x00;
DDRA = 0x00;
PORTB = 0x00;
DDRB = 0x00;
PORTC = 0x00;
DDRC = 0x00;
PORTD = 0x00;
DDRD = 0x00;
PORTE = 0x00;
DDRE = 0x00;
MCUCR = 0x80; //Enable ExtRam
EMCUCR = 0x00; //Ext Ram 0x0260~0xFFFF,Low 0 wait,High 0 wait
GICR = 0x00; //No interrupt
TIMSK = 0x00; //Disable T/C1,T/C0
SFIOR = BIT(XMBK)|BIT(PUD); //XM break keeper, Pull up disable
delayms(100);
serinit();
SEI(); //Enable all interrupts
send_string("Test TFT V02\x0D\x0A\x00");
if ( !check_extram() )
send_string("Ram fail!\x0D\x0A\x00");
else
{
send_string("Ram pass!\x0D\x0A\x00");
load_bmp_to_ram();
Test_TFT_Lcd();
}
while(1);
}
void load_bmp_to_ram(void)
{
unsigned char value;
unsigned int i,length,chksum=0;
send_string("Please load bmp data to ram!\x0D\x0A\x00");
length=get_data();
length=length*0x100+get_data();
send_num( MSB(length) );
send_num( LSB(length) );
send_data(0x0D);
send_data(0x0A);
for (i=0;i<length;i++)
{
value=get_data();
*(Bmp_Buffer+i)=value;
chksum+=value;
}
send_num( MSB(chksum) );
send_num( LSB(chksum) );
send_data(0x0D);
send_data(0x0A);
send_string("Receive bmp data finish!\x0D\x0A\x00");
}
/////////////////////////////////////////////////////////////////////
BOOL check_extram(void)
{
unsigned int i,j;
unsigned char value;
send_string("Write extram ...\x0D\x0A\x00");
for( i=0; i<0x8000; i++)
*(Bmp_Buffer+i)=i&0xFF;
send_string("finish!\x0D\x0AVerify extram ...\x0D\x0A\x00");
for( i=0; i<0x8000; i++)
{
value = *(Bmp_Buffer+i);
if( value != (i&0xFF) )
{
send_data('@');
send_num(MSB(i));
send_num(LSB(i));
send_data('=');
send_num(value);
send_data(0x0D);
send_data(0x0A);
return FALSE;
}
if ((i%1024)==0)
{
j=BinBcd(MSB(i));
send_num(MSB(j));
send_num(LSB(j));
send_data(0x0D);
send_data(0x0A);
}
}
return TRUE;
}
//; ---------------------------------------------------------------------------
//; Convert a byte Bin to Bcd code
//; ---------------------------------------------------------------------------
unsigned int BinBcd(unsigned char a)
{
unsigned int i;
unsigned char b1,b2,b3;
b1=a/100;
b2=(a-b1*100)/10;
b3=a-b1*100-b2*10;
i=b1*0x100+b2*0x10+b3;
return i;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -