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

📄 main.c

📁 NOKIA 6610液晶初始化程序
💻 C
字号:
//ICC-AVR application builder : 2004-11-15 下午 07:08:16
// Target : M8
// Crystal: 8.0000Mhz

#include <iom8v.h>
#include <macros.h>
#include "lcd6610.h"



void port_init(void)
{
 PORTB = 0x00;
 DDRB  = 0xFF;
 PORTC = 0x7F; //m103 output only
 DDRC  = 0x00;
 PORTD = 0x00;
 DDRD  = 0xFF;
}

//call this routine to initialise all peripherals
void init_devices(void)
{
 //stop errant interrupts until set up
 CLI(); //disable all interrupts
 port_init();

 MCUCR = 0x00;
 GICR  = 0x00;
 TIMSK = 0x00; //timer interrupt sources
 //SEI(); //re-enable interrupts
 //all peripherals are now initialised
}



//
void main(void)
{char a,b,c,d,r,ob=0;
 init_devices();
     OSCCAL=0xff;                        // 8M系统内部时钟校准    
    //设置MCU的I/O口
	DDRD=0xFF;
	PORTD=0x00;
    DDRB = 0xFF;
	PORTB=0x00;
//    SPSR |= BIT(SPI2X);                 // 设置SPI时钟倍速
//   SPCR |= BIT(SPE)|BIT(MSTR);		// 使能SPI接口,主机模式,4M时钟
//SPCR=0x51; 
//SPCR = 0x73; //setup SPI
//SPSR = 0x01; //setup SPI
SPCR = (1<<SPE) | (1<<MSTR) | (1<<CPHA) | (1<<CPOL);
 //insert your functional code here...
// glcdn_Delay(9900000);

init_lcd();

RGB2(255,255,255);
glcdn_ClearLcd();

sc_cbk(255,0,255,1);
sc_cfg(0,0,255,1);
sc_cfr(0,0,255,1);
sc_csh(0,0,255,1);
sc_ctext(0,0,0,1);
/*
DrawChar(5,5,'y');
DrawChar(20,5,1);
DrawStr(5,35,"XJ1234567}{()*! \1\2\0",1);
//n6100DrawCircle(64,64,30);
//glcdn_InitDisplay();
//
// SPCR = (1<<MSTR)|(1<<SPE)|(1<<SPR0);
//backgroundColor=4;

*/
st[0]='X';
st[1]='J';
st[2]=':';
st[3]='J';
st[4]='F';
st[5]='\0';
backgroundColor=0x21;
b2=6;
for(a=0;a<19;a++)
st[a]='0';
st[17]=0;
RGB(255,255,255);
st[4]=1;
st[5]=2;
//init_lcd();
sc_ctext(0,0,0,1);
sc_cbk(255,255,0,1);
RoundRect(1,1,127,127,6);
sc_cbk(255,255,0,0);
while(1)
{



//st[4]='X';


//RGB2(0,0,255);

//glcdCircle(64,64,26);




//for(r=6;r<16;r++)
//st[r]=a+r+0x20;
a++;

if(a>8){

DrawStr(8,b2,st,0);
st[0]=a+0x30;
st[1]=a+0x30;
st[2]=c+0x30;
st[3]=d+0x30;
for(r=6;r<16;r++)
st[r]=c+r+0x20;


a=0;
if(b++>8)
{sc_cfg(255,255,0,1);
//sc_cbk(255,255,0,1);
RoundRect(5,5+ob*12,119,12,3);

sc_cfg(0,0,255,1);
//sc_cbk(0,255,0,1);
RoundRect(5,5+c*12,119,12,3);
ob=c;
b=0;
if(c++>8)
{c=0;
if(d++>9)d=0;
}
}
}

b2+=12;
if(b2>120)b2=6;
}



//glcdn_Delay(1900);


sc_cfg(0,255,255,1);
b2=1;
 while(1)
 {
//while(1);
//RGB2(255,255,255);
 //glcdn_ClearLcd();
// n6100DrawCircle(64,64,backgroundColor);
//RGB2(0,0,255);


 glcdCircle(64,64,backgroundColor);
 RoundRect(backgroundColor,backgroundColor,backgroundColor+5,backgroundColor+5,10);
backgroundColor++;

  if(backgroundColor>64)
 {backgroundColor=7;
 //b2++;
 //if(b2>64)b2=5;
 //goto top;
 
 b2=(b2+1)%2;
 sc_cbk(255,255,0,b2-1);
 }
 
//glcdn_InitDisplay2();
//glcdn_InitDisplay();
//glcdn_WriteCommand(0x5C);
//glcdn_WriteData(0x7f);
//glcdn_InitDisplay();
//init_lcd();
//glcdn_Delay(13900);
//glcdn_SetPageArea(GLCD_X_START, GLCD_X_END, GLCD_Y_START, GLCD_Y_END);
//while(1)
//glcdn_ClearLcd();
//	{glcdn_WriteCommand(MEM_WRITE);
//	glcdn_WriteData(RED);
//	glcdn_Delay(80);
	}
 
}

void sp(unsigned char dd,unsigned char cmd)
{
unsigned char i;
//csl;

sclkl;
if(cmd)
sdatah;
else
sdatal;
sclkh;

for(i=0;i<8;i++)
{
sclkl;
//NOP();
if(((dd<<i)&0x80)==0x80)
sdatah;
else
sdatal;

sclkh;
}

//csh;
}

⌨️ 快捷键说明

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