#include <msp430x24x.h>
#include "Set_DCO.h"
typedef unsigned long DWORD;
typedef unsigned int WORD;
typedef unsigned char BYTE;
#define P1_2_HALF 0x04
#define P1_3_EN 0x08
#define P1_4_CW 0x10
#define P2_0_RS 0x01
#define P2_1_RW 0x02
#define P2_2_EN 0x04
#define P2_3_CS1 0x08
#define P2_4_CS2 0x10
#define P2_5_RST 0x20
#define P3_0_DB0 0x01
#define P3_1_DB1 0x02
#define P3_2_DB2 0x04
#define P3_3_DB3 0x08
#define P3_4_DB4 0x10
#define P3_5_DB5 0x20
#define P3_6_DB6 0x40
#define P3_7_DB7 0x80
unsigned int static autoing=0x01;
const BYTE welcome[4][32] = //欢迎使用
{
0x04,0x34,0xC4,0x04,0xC4,0x3C,0x20,0x10,
0x0F,0xE8,0x08,0x08,0x28,0x18,0x00,0x00,
0x10,0x08,0x06,0x01,0x82,0x8C,0x40,0x30,
0x0C,0x03,0x0C,0x10,0x60,0xC0,0x40,0x00,
0x40,0x42,0x44,0xC8,0x00,0xFC,0x04,0x02,
0x82,0xFC,0x04,0x04,0x04,0xFE,0x04,0x00,
0x00,0x40,0x20,0x1F,0x20,0x47,0x42,0x41,
0x40,0x7F,0x40,0x42,0x44,0x63,0x20,0x00,
0x40,0x20,0xF8,0x07,0x04,0xF4,0x14,0x14,
0x14,0xFF,0x14,0x14,0x14,0xF6,0x04,0x00,
0x00,0x00,0xFF,0x00,0x80,0x43,0x45,0x29,
0x19,0x17,0x21,0x21,0x41,0xC3,0x40,0x00,
0x00,0x00,0xFE,0x22,0x22,0x22,0x22,0xFE,
0x22,0x22,0x22,0x22,0xFF,0x02,0x00,0x00,
0x80,0x60,0x1F,0x02,0x02,0x02,0x02,0x7F,
0x02,0x02,0x42,0x82,0x7F,0x00,0x00,0x00,
};
const BYTE wsd[6][32] = //未收到反射波
{
0x80,0x88,0x88,0x88,0x88,0x88,0x88,0xFF,
0x88,0x88,0x88,0x88,0x8C,0xC8,0x80,0x00,
0x00,0x20,0x10,0x08,0x04,0x02,0x01,0xFF,
0x01,0x02,0x04,0x08,0x10,0x30,0x10,0x00,
0x00,0xF8,0x00,0x00,0xFF,0x00,0x80,0x60,
0xDF,0x10,0x10,0x10,0xF0,0x18,0x10,0x00,
0x00,0x0F,0x04,0x02,0xFF,0x80,0x80,0x40,
0x21,0x16,0x08,0x16,0x61,0xC0,0x40,0x00,
0x00,0x62,0x52,0x4A,0xC6,0x42,0x52,0x63,
0xC2,0x00,0xF8,0x00,0x00,0xFF,0x00,0x00,
0x40,0x42,0x42,0x42,0x7F,0x22,0x23,0x22,
0x20,0x00,0x0F,0x40,0x80,0x7F,0x00,0x00,
0x00,0x00,0xFC,0x24,0x24,0xE4,0x24,0x24,
0x24,0x22,0x22,0xA3,0x62,0x00,0x00,0x00,
0x40,0x30,0x0F,0x80,0x80,0x40,0x23,0x14,
0x08,0x14,0x22,0x21,0x40,0xC0,0x40,0x00,
0x00,0x00,0xFC,0xA6,0xA5,0xA4,0xFE,0x24,
0x20,0x20,0x20,0x20,0xFF,0x20,0x20,0x00,
0x44,0x44,0x27,0x14,0x4C,0x84,0x7F,0x00,
0x01,0x06,0x40,0x80,0x7F,0x00,0x00,0x00,
0x20,0x42,0x04,0x0C,0x80,0xF8,0x88,0x88,
0x88,0xFF,0x88,0x88,0xA8,0x18,0x00,0x00,
0x04,0x04,0xFE,0x41,0x30,0x8F,0x40,0x22,
0x14,0x08,0x14,0x22,0x41,0xC0,0x40,0x00
};
const BYTE juli[3][32] = //距离为
{
0x00,0x3E,0x22,0xE2,0x22,0x3E,0x00,0xFE,
0x22,0x22,0x22,0x22,0xF3,0x22,0x00,0x00,
0x20,0x7F,0x20,0x3F,0x12,0x12,0x00,0x7F,
0x42,0x42,0x42,0x42,0x47,0x60,0x40,0x00,
0x04,0x04,0x04,0xF4,0x04,0x8C,0x55,0x26,
0x54,0x8C,0x04,0xF4,0x04,0x06,0x04,0x00,
0x00,0xFC,0x04,0x05,0x25,0x35,0x2D,0x27,
0x25,0x35,0x25,0x45,0x84,0x7E,0x04,0x00,
0x20,0x20,0x20,0x22,0x24,0x2C,0x20,0xE0,
0x3F,0x20,0x20,0x20,0x20,0xF0,0x20,0x00,
0x00,0x40,0x20,0x10,0x08,0x04,0x03,0x00,
0x02,0x04,0x4C,0x80,0x40,0x3F,0x00,0x00
}
const BYTE CHAR_0[5]={0x3E,0x51,0x49,0x45,0x3E};
const BYTE CHAR_1[5]={0x00,0x42,0x7F,0x40,0x00};
const BYTE CHAR_2[5]={0x42,0x61,0x51,0x49,0x66};
const BYTE CHAR_3[5]={0x23,0x41,0x45,0x4B,0x31};
const BYTE CHAR_4[5]={0x18,0x14,0x52,0x7F,0x50};
const BYTE CHAR_5[5]={0x27,0x45,0x45,0x45,0x39};
const BYTE CHAR_6[5]={0x3C,0x4A,0x49,0x49,0x30};
const BYTE CHAR_7[5]={0x03,0x71,0x09,0x05,0x03};
const BYTE CHAR_8[5]={0x36,0x49,0x49,0x49,0x36};
const BYTE CHAR_9[5]={0x06,0x49,0x49,0x29,0x1E};
const BYTE CHAR_~[5]={0x08,0x04,0x08,0x10,0x08}; // '~'
const BYTE CHAR_c[5]={0x38,0x44,0x44,0x44,0x08};// 'c'
const BYTE CHAR_m[5]={0x78,0x04,0x78,0x04,0x78};// 'm'
const BYTE CHAR[10][5]={
0x3E,0x51,0x49,0x45,0x3E,//0
0x00,0x42,0x7F,0x40,0x00,//1
0x42,0x61,0x51,0x49,0x66,//2
0x23,0x41,0x45,0x4B,0x31,//3
0x18,0x14,0x52,0x7F,0x50,//4
0x27,0x45,0x45,0x45,0x39,//5
0x3C,0x4A,0x49,0x49,0x30,//6
0x03,0x71,0x09,0x05,0x03,//7
0x36,0x49,0x49,0x49,0x36,//8
0x06,0x49,0x49,0x29,0x1E //9
};
void LCM_Initializtion(){
/*****************************
** 硬件连接说明 **
** LCM SYB12684 **
** P3.0~7 <----> DB0~7 **
** P2.0 <----> DI **
** P2.1 <----> RW **
** P2.2 <----> E **
** P2.3 <----> CS1 **
** P2.4 <----> CS2 **
** P2.5 <----> RESET **
******************************/
P3DIR = 0xFF;
P3OUT = 0x00;
P2DIR = 0xFF;
P2OUT = P2_3_CS1 | P2_4_CS2 | P2_5_RST;
P2OUT &=~P2_5_RST;
_NOP();
_NOP();
P2OUT |= P2_2_EN;
_NOP();
_NOP();
P2OUT &=~P2_2_EN;
_NOP();
_NOP();
P2OUT |= P2_5_RST;
_NOP();
_NOP();
}
void write_command( BYTE nByte )
{
P3DIR = 0xFF;
P2OUT |= P2_3_CS1+P2_4_CS2;
P2OUT &=~(P2_0_RS+P2_1_RW);
P3OUT = nByte;
P2OUT |= P2_2_EN;
P2OUT &=~P2_2_EN;
}
void write_char( BYTE nByte, BYTE CS1, BYTE CS2 )
{
P3DIR = 0xFF;
if(CS1) P2OUT |= P2_3_CS1;
else P2OUT &=~P2_3_CS1;
if(CS2) P2OUT |= P2_4_CS2;
else P2OUT &=~P2_4_CS2;
P2OUT |= P2_0_RS;
P2OUT &=~P2_1_RW;
P3OUT = nByte;
P2OUT |= P2_2_EN;
P2OUT &=~P2_2_EN;
}
void clear_lcm( void )
{
BYTE i,j;
for(i=0;i<8;i++)
{
write_command(i|0xB8);
write_command(0x40);
for(j=0;j<128;j++)
{
if(j<=63) write_char(0,1,0);
else write_char(0,0,1);
_NOP();
}
}
}
void display_hanzi( BYTE *chr, BYTE nRow, BYTE nCol )
{
BYTE i,tmpCol;
write_command(0xB8|nRow);
tmpCol=nCol;
for(i=0;i<16;i++)
{
if(tmpCol<=63)
{
write_command(0x40|tmpCol);
write_char(chr[i],1,0);
}
else
{
write_command(0x40|(tmpCol-64));
write_char(chr[i],0,1);
}
tmpCol++;
}
write_command(0xB8|nRow+1);
tmpCol=nCol;
for(i=0;i<16;i++)
{
if(tmpCol<=63)
{
write_command(0x40|tmpCol);
write_char(chr[i+16],1,0);
}
else
{
write_command(0x40|(tmpCol-64));
write_char(chr[i+16],0,1);
}
tmpCol++;
}
}
void display_16_16_icon( BYTE *chr, BYTE nRow, BYTE nCol )
{
BYTE i,tmpCol;
write_command(0xB8|nRow);
tmpCol=nCol;
for(i=0;i<16;i++)
{
if(tmpCol<=63)
{
write_command(0x40|tmpCol);
write_char(chr[i],1,0);
}
else
{
write_command(0x40|(tmpCol-64));
write_char(chr[i],0,1);
}
tmpCol++;
}
write_command(0xB8|nRow+1);
tmpCol=nCol;
for(i=0;i<16;i++)
{
if(tmpCol<=63)
{
write_command(0x40|tmpCol);
write_char(chr[i+16],1,0);
}
else
{
write_command(0x40|(tmpCol-64));
write_char(chr[i+16],0,1);
}
tmpCol++;
}
}
void display_char(BYTE *chr, BYTE nRow, BYTE nCol)
{
BYTE i,tmpCol;
write_command(0xB8|nRow);
tmpCol=nCol;
for(i=0;i<5;i++)
{
if(tmpCol<=63)
{
write_command(0x40|tmpCol);
write_char(chr[i],1,0);
}
else
{
write_command(0x40|(tmpCol-64));
write_char(chr[i],0,1);
}
tmpCol++;
}
}
void display_welcome(void)
{
display_hanzi((BYTE *)&welcome[0][0],1,13);
display_hanzi((BYTE *)&welcome[1][0],1,42);
display_hanzi((BYTE *)&welcome[2][0],1,71);
display_hanzi((BYTE *)&welcome[3][0],1,100);
}
void display_wsd(void)
{
display_hanzi((BYTE *)&wsd[0][0],1,9);
display_hanzi((BYTE *)&wsd[1][0],1,38);
display_hanzi((BYTE *)&wsd[2][0],1,67);
display_hanzi((BYTE *)&wsd[3][0],1,95);
display_hanzi((BYTE *)&wsd[4][0],1,124);
display_hanzi((BYTE *)&wsd[5][0],1,133);
}
void display_juli(int i)
{
display_hanzi((BYTE *)&juli[0][0],0,0);
display_hanzi((BYTE *)&juli[1][0],0,0);
display_hanzi((BYTE *)&juli[2][0],0,0);
if(i == 1)then
评论0