找了各种资料,总觉得5438这么多资源,只用8M的外部晶振太慢,内部刚好有dco,调试了一下最后跑到24MHz。外加了ssd1289液晶+ads7843触摸+uartA0。115200+uartA1.9600
下附代码
#include
#include"tft.h"
#include"cc1101.h"
#include"gps.h"
#include"gsm.h"
#define uchar unsigned char
#define uint unsigned int
uchar sent[8]={"7654321"};
uchar recv[8]={"no rev"};
int num;
uchar length=8;
void Port_Init();
void init_clk();
void init_dco();
void init_ta0();
void main(){
num=0;
WDTCTL = WDTPW + WDTHOLD;
Port_Init();
init_dco();
//init_ta0();
lcdinit();
init_gps();
init_gsm();
//cc1101init();
LCD_TEST_SingleColor(0x00,0x00);
while(1)
{
//ADS7843_disp();
//LCD_TEST_SingleColor(0x00,0x00);
// if(num==1)
{
//halRfSendPacket(sent,8);
//drawchar(0x00,0X00,0XFF,0xff,sent,0,0);
// halRfReceivePacket(recv,&length);
// drawchar(0x00,0X00,0XFF,0xff,recv,0,16);
num=0x33;
//sent[6]++;
UCA0TXBUF=num;
UCA1TXBUF=num;
gps_get();
drawchar(0x00,0X00,0XFF,0xff,gpGGA,0,96);
drawchar(0x00,0X00,0XFF,0xff,gpGSA,0,0);
drawchar(0x00,0X00,0XFF,0xff,gpGSV,0,16);
drawchar(0x00,0X00,0XFF,0xff,gpRMC,0,32);
drawchar(0x00,0X00,0XFF,0xff,gpGLL,0,48);
drawchar(0x00,0X00,0XFF,0xff,gpVTG,0,64);
drawchar(0x00,0X00,0XFF,0xff,gpZDA,0,80);
drawchar(0x00,0X00,0XFF,0xff,gpZTG,0,96);
/**/ //drawchar(0x00,0X00,0XFF,0xff,gps8,0,112);
}
//LCD_TEST_SingleColor(0xff,0xff);
}
}
void Port_Init()
{
/*下面六行程序开启所有的IO口*/
P1DIR = 0XFF;P1OUT = 0XFF;
P2DIR = 0XFF;P2OUT = 0XFF;
P3DIR = 0XFF;P3OUT = 0XFF;
P4DIR = 0XFF;P4OUT = 0XFF;
P5DIR = 0XFF;P5OUT = 0XFF;
P6DIR = 0XFF;P6OUT = 0XFF;
P7DIR = 0XFF;P7OUT = 0XFF;
P8DIR = 0XFF;P8OUT = 0XFF;
P9DIR = 0XFF;P9OUT = 0XFF;
P10DIR = 0XFF;P10OUT = 0XFF;
P11DIR = 0XFF;P11OUT = 0XFF;
}
void init_clk()
{
P11DIR = BIT1+BIT2; // P11.1-2 to output direction
P11SEL |= BIT1+BIT2; // P11.1-2 to output SMCLK,MCLK
P5SEL |= 0x0C; // Port select XT2
UCSCTL6 &= ~XT2OFF; // Enable XT2
UCSCTL3 |= SELREF_2; // FLLref = REFO
// Since LFXT1 is not used,
// sourcing FLL with LFXT1 can cause
// XT1OFFG flag to set
UCSCTL4 |= SELA_2; // ACLK=REFO,SMCLK=DCO,MCLK=DCO
// Loop until XT1,XT2 & DCO stabilizes
do
{
UCSCTL7 &= ~(XT2OFFG + XT1LFOFFG + XT1HFOFFG + DCOFFG);
// Clear XT2,XT1,DCO fault flags
SFRIFG1 &= ~OFIFG; // Clear fault flags
}while (SFRIFG1&OFIFG); // Test oscillator fault flag
UCSCTL6 &= ~XT2DRIVE0; // Decrease XT2 Drive according to
// expected frequency
UCSCTL4 |= SELS_5 + SELM_5; // SMCLK=MCLK=XT2
}
void init_dco()
{
P7SEL |= 0x03; // P7.0 P7.1 外设功能
UCSCTL6 &= ~(XT1OFF); // XT1打开
UCSCTL6 |= XCAP_3; // 内部电容
do
{
UCSCTL7 &= ~XT1LFOFFG; // 清楚XT1错误标记
}while (UCSCTL7&XT1LFOFFG); // 检测XT1错误标记
__bis_SR_register(SCG0); // 禁止FLL功能
UCSCTL0 = 0x0000; // Set lowest possible DCOx, MODx
UCSCTL1 = DCORSEL_7; // DCO最大频率为16MHz
UCSCTL2 = FLLD_1 + 731; // 设置DCO频率为8MHz
// MCLK = SMCLK= Fdcoclkdiv = (N+1)X(Ffllrefclk/n)
// N为唯一需要计算的值
// Ffllrefclk FLL参考时钟,默认为XT1
// n取默认值,此时为1
// (731 + 1) * 32768 = 24MHz
__bic_SR_register(SCG0); // 使能FLL功能
// 必要延时
__delay_cycles(250000);
// 清楚错误标志位
do
{
UCSCTL7 &= ~(XT2OFFG + XT1LFOFFG + XT1HFOFFG + DCOFFG);
// 清除所有振荡器错误标志位
SFRIFG1 &= ~OFIFG; // 清除振荡器错误
}while (SFRIFG1&OFIFG); // 等待清楚完成
//UCSCTL4 |= SELA__REFOCLK+SELS__XT2CLK+SELM__DCOCLK; // SMCLK=MCLK=XT2
}
void init_asmclk()
{
}
void init_ta0()
{
TA1CCTL0 = CCIE; // CCR0 interrupt enabled
TA1CCR0 = 32768-1;
TA1CTL = TASSEL_1 + MC_1 + TACLR; // ACLK, upmode, clear TAR
__bis_SR_register(GIE); // Enter LPM3, enable interrupts
// __no_operation(); // For debugger
}
// Timer A0 interrupt service routine
#pragma vector=TIMER1_A0_VECTOR
__interrupt void TIMER1_A0_ISR(void)
{
num++; // Toggle P1.0
//_bis_SR_register(GIE);
}
#include "msp430x54x.h"
#include "Ascii_8x16.h"
//#include "intrins.h"
//#include
#define DataBusH P9OUT
#define DataBusL P8OUT
//#define DataBusL P0
typedef unsigned int uint;
typedef unsigned char uchar;
#define n 1
#define CHX 0xD0
#define CHY 0x90
#define general_delay 100
#define ZERO_FIELD_COUNT 4
#define T_DCLKH P10OUT|=BIT1
#define T_CSH P10OUT|=BIT0
#define T_DINH P10OUT|=BIT2
#define T_DOUTH P10OUT|=BIT3
#define T_IRQH P10OUT|=BIT4
#define T_DCLKL P10OUT&=~BIT1
#define T_CSL P10OUT&=~BIT0
#define T_DINL P10OUT&=~BIT2
#define T_DOUTL P10OUT&=~BIT3
#define T_IRQL P10OUT&=~BIT4
#define T_DIN P10IN&BIT2
#define T_IRQ P10IN&BIT4
#define T_DOUT P10IN&BIT3
#define KEY P2OUT&0X05
#define RSH P6OUT|=BIT0
#define CSH P6OUT|=BIT1
#define RDH P6OUT|=BIT2
#define WRH P6OUT|=BIT3
#define RSTH P6OUT|=BIT4
#define RSL P6OUT&=~BIT0
#define CSL P6OUT&=~BIT1
#define RDL P6OUT&=~BIT2
#define WRL P6OUT&=~BIT3
#define RSTL P6OUT&=~BIT4
/* LCD FUNCTION */
void LCD_INIT_SSD1289(void);
void LCD_TEST_SingleColor(char colorH,char colorL);
void LCD_TEST_Picture(unsigned char const *picture);
void LCD_TEST_id(unsigned char *id);
void adderset(char xs,char xe,int ys,int ye);
void LCD_id_SHOW(int a,int b,int c,int d);
void LCD_show_window();
void LCD_WRITE_CMD(char CMD1,char CMD2);
void LCD_WRITE_DATA(char DATAA,char DATAB);
void LCD_READ_ID(void);
void LLCD_WRITE_CMD(int cmd);
void LLCD_WRITE_DATA(int dataa);
void send_host_reg_command(int cmd,int dataa);
void HD_reset(void);
void Keypress(void);
void delayms(int value);
void delayus(int value1);
void LCD_Color_with_ADD(char data1,char data2,int x1,int x2,int y1,int y2);
void ADS7843_disp();
void benchmark(void);
void TOUCH_RESET(void);
void TOUCH_WRITE(unsigned char command);
void TOUCH_READ(unsigned char *xy);
void TOUCH_START(unsigned char channel);
void TOUCH_CAIJI(void);
void location();
void drawchar(int acolorH,int acolorL,int bcolorH,int bcolorL,char *p,int x,int y);
void drawcircle(int x0,int y0,char r);
void drawpoint(int x,int y);
void lcdinit();
unsigned int ciPressureWait =10;
unsigned int ciStartWait =100;
unsigned int ciCommandPenIrq =0xD0; // 11010000B
unsigned int ciCommandSampleX =0xD3; // 11010011B
unsigned int ciCommandSampleY =0x93; // 10010011B
unsigned int ciSampleTimes =6;
unsigned int ADC_X_START=230;
unsigned int ADC_X_END=3867;
unsigned int ADC_Y_START=287;
unsigned int ADC_Y_END=3853;
unsigned int SCREEN_X_START=0;
unsigned int SCREEN_X_END=240;
unsigned int SCREEN_Y_START=0;
unsigned int SCREEN_Y_END=320;
unsigned int vx,vy,x_len,y_len,x_org,y_org;
unsigned int pass;
int px_max=0,py_max=0,px_min=-2,py_min=-2;
int x_slope,y_slope;
int x_offset,y_offset;
unsigned int id;
/***********************************
touch sreen function
**********************************/
/*********************touch screen end**************/
void serial_delay()
{
int i;
for (i = 0;i
}
void TOUCH_RESET()
{
T_DCLKL;serial_delay();
T_CSH;serial_delay();
T_DINL;serial_delay();
T_DCLKL;serial_delay();
T_DOUTL;serial_delay();
T_CSL;serial_delay();
}
void ADS7843_SPI_Start( void )
{
T_DCLKL;serial_delay();
T_CSH;serial_delay();
T_DINH;serial_delay();
T_DCLKH;serial_delay();
T_CSL;serial_delay();
}
void ADS7843_Write (unsigned char cmd )
{
unsigned char buf, i, j ;
T_DCLKL;serial_delay();
for( i = 0; i < 8; i++ )
{
buf = (cmd >> (7-i)) & 0x01 ;
if(buf)
{
T_DINH;serial_delay();
}
else
T_DINL;serial_delay();
for( j = 0; j < general_delay; j++ );
T_DCLKH;serial_delay();
for( j = 0; j < general_delay; j++ );
T_DCLKL;serial_delay();
}
}
unsigned int ADS7843_Read ( void )
{
unsigned int buf = 0 ;
unsigned char i, j ;
P10DIR &=~BIT3;
for( i = 0; i < 12; i++ )
{
buf = buf << 1 ;
T_DCLKH;serial_delay();
for( j = 0; j < general_delay; j++ );
T_DCLKL;serial_delay();
for( j = 0; j < general_delay; j++ );
if ( T_DOUT )
buf = buf + 1 ;
//TP_DCLKL;
for( j = 0; j < general_delay; j++ );
//for( j = 0; j < general_delay; j++ );
}
for( i = 0; i < 4; i++ )
{
T_DCLKH;serial_delay();
for( j = 0; j < general_delay; j++ ); //200ns
T_DCLKL;serial_delay();
for( j = 0; j < general_delay; j++ );
}
P10DIR |=BIT3;
return( buf ) ;
}
void ADS7843_disp()// interrupt 0 using 0
{
long x, y;
char j ;
unsigned int px_max=0,py_max=0,px_min=0,py_min=0;
x_slope=0.066;//0.066
y_slope=0.090;//0.090
x_offset = -15.18;
y_offset = -25.83;
// P7DIR=0X00;
for( j = 0; j < general_delay; j++ );
if (((~P10IN)&0x10)==0x10)
{
ADS7843_SPI_Start() ;
for( j = 0; j < 5; j++ );
ADS7843_Write( CHX ) ;
x = ADS7843_Read();//dummy
ADS7843_Write( CHX ) ;
x = ADS7843_Read();//dummy
ADS7843_Write( CHX ) ;
x += ADS7843_Read();//dummy
x = x/2;
// x= 0.066 * (x - 230);
x=0.0896*(ADC_X_END - x);
//x=240-x;
ADS7843_Write( CHY ) ;
y = ADS7843_Read() ;
ADS7843_Write( CHY ) ;
y = ADS7843_Read() ;
ADS7843_Write( CHY ) ;
y += ADS7843_Read();//dummy
y = y/2;
// y= 0.0896 * (y - 287);//0.896
y= 0.066 * (ADC_Y_END - y);//0.896
//y=320-y;
if(x
x=SCREEN_Y_START;
else if (x>SCREEN_Y_END)
x=SCREEN_Y_END;
if(y
y=SCREEN_X_START;
else if (y>SCREEN_X_END)
y=SCREEN_X_END;
drawpoint(y,x);
//LCD_Color_with_ADD(0x07,0xE0,y,y+1,x,x+1);
// }
T_CSH;
}
}
void LCD_Color_with_ADD(char data1,char data2,int x1,int x2,int y1,int y2){
unsigned char i,j;
LCD_WRITE_CMD(0x00,0x44); LLCD_WRITE_DATA((x2<<8)+x1); //hs
LCD_WRITE_CMD(0x00,0x45); LLCD_WRITE_DATA(y1); //he
LCD_WRITE_CMD(0x00,0x46); LLCD_WRITE_DATA(y2); //vs
LCD_WRITE_CMD(0x00,0x4e); LLCD_WRITE_DATA(x1); //h
LCD_WRITE_CMD(0x00,0x4f); LLCD_WRITE_DATA(y1); //v
LCD_WRITE_CMD(0x00,0x22);
for(i=0;i
for (j=0;j
{
LCD_WRITE_DATA(data1,data2);
}
}
void HD_reset(){
RSTL;
delayms(50);
RSTH;
delayms(10);
}
void LCD_INIT_SSD1289(void){
send_host_reg_command(0x0025,0xe000);
send_host_reg_command(0x0000,0x0001);
delayms(40); //打开晶振
send_host_reg_command(0x0003,0xEEEE);//0xA8A4
send_host_reg_command(0x000C,0x0004);
send_host_reg_command(0x000D,0x0003);
send_host_reg_command(0x000E,0x3000);
delayms(100);
send_host_reg_command(0x001E,0x00AF);
send_host_reg_command(0x0001,0x2B3F);//驱动输出控制320*240 0x6B3F//可改
send_host_reg_command(0x0002,0x0600); //LCD Driving Waveform control
send_host_reg_command(0x0010,0x0000);
send_host_reg_command(0x0011,0x6030); //0x4030 //定义数据格式 16位色 横屏 0x6058
send_host_reg_command(0x0005,0x0000);
send_host_reg_command(0x0006,0x0000);
send_host_reg_command(0x0007,0x0001);
send_host_reg_command(0x0007,0x0021);
send_host_reg_command(0x0007,0x0023); //0x0233
send_host_reg_command(0x0007,0x0033);
send_host_reg_command(0x000B,0x0000);
send_host_reg_command(0x000F,0x0000);
delayms(100); //扫描开始地址
send_host_reg_command(0x0041,0x0000);
send_host_reg_command(0x0042,0x0000);
send_host_reg_command(0x0048,0x0000);
send_host_reg_command(0x0049,0x013F);
send_host_reg_command(0x004A,0x0000);
send_host_reg_command(0x004B,0x0000);
send_host_reg_command(0x0044,0xEF00);
send_host_reg_command(0x004F,0);//行首址0
send_host_reg_command(0x004E,0);//列首址0
send_host_reg_command(0x0045,0x0000);
send_host_reg_command(0x0046,0x013F);
send_host_reg_command(0x0023,0x0000);
send_host_reg_command(0x0024,0x0000);
send_host_reg_command(0x0021,0x0000);
send_host_reg_command(0x0030,0x0707);
send_host_reg_command(0x0031,0x0204);
send_host_reg_command(0x0032,0x0204);
send_host_reg_command(0x0033,0x0502);
send_host_reg_command(0x0034,0x0507);
send_host_reg_command(0x0035,0x0204);
send_host_reg_command(0x0036,0x0204);
send_host_reg_command(0x0037,0x0502);
send_host_reg_command(0x003A,0x0302);
send_host_reg_command(0x003B,0x0302);
send_host_reg_command(0x0023,0x0000);
send_host_reg_command(0x0024,0x0000);
send_host_reg_command(0x0028,0x0006);
send_host_reg_command(0x002F,0x122E);
LLCD_WRITE_CMD(0x0022);
delayms(200);
/*
send_host_reg_command(0x0000,0x0001);
send_host_reg_command(0x0000,0x0001); //打开晶振
send_host_reg_command(0x0003,0xA8A4); //0xA8A4
send_host_reg_command(0x000C,0x0000);
send_host_reg_command(0x000D,0x080C);
send_host_reg_command(0x000E,0x2B00);
send_host_reg_command(0x001E,0x00B0);
send_host_reg_command(0x0001,0x2B3F); //驱动输出控制320*240 0x6B3F
send_host_reg_command(0x0002,0x0600); //LCD Driving Waveform control
send_host_reg_command(0x0010,0x0000);
send_host_reg_command(0x0011,0x60b0); //0x4030 //定义数据格式 16位色 横屏 0x6058 6070
send_host_reg_command(0x0005,0x0000);
send_host_reg_command(0x0006,0x0000);
send_host_reg_command(0x0016,0xEF1C);
send_host_reg_command(0x0017,0x0003);
send_host_reg_command(0x0007,0x0233); //0x0233
send_host_reg_command(0x000B,0x0000);
send_host_reg_command(0x000F,0x0000); //扫描开始地址
delayms(40);
send_host_reg_command(0x0041,0x0000);
send_host_reg_command(0x0042,0x0000);
delayms(100);
send_host_reg_command(0x0048,0x0000);
send_host_reg_command(0x0049,0x013F);
send_host_reg_command(0x004A,0x0000);
send_host_reg_command(0x004B,0x0000);
delayms(100);
send_host_reg_command(0x0044,0xEF00);
send_host_reg_command(0x0045,0x0000);
send_host_reg_command(0x0046,0x013F);
send_host_reg_command(0x0030,0x0707);
send_host_reg_command(0x0031,0x0204);
send_host_reg_command(0x0032,0x0204);
send_host_reg_command(0x0033,0x0502);
send_host_reg_command(0x0034,0x0507);
send_host_reg_command(0x0035,0x0204);
send_host_reg_command(0x0036,0x0204);
send_host_reg_command(0x0037,0x0502);
send_host_reg_command(0x003A,0x0302);
send_host_reg_command(0x003B,0x0302);
send_host_reg_command(0x0023,0x0000);
send_host_reg_command(0x0024,0x0000);
send_host_reg_command(0x0025,0x8000);
LLCD_WRITE_CMD(0x0022);delayus(n);
delayms(200);
*/
}
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& 16 bit interface &&&&&&&&&&&&&&&&&&&&&&&&&&&&
void LCD_WRITE_CMD(char cmd1,char cmd2){
RSL;//delayus(n);
RDH;//delayus(n);
WRH;//delayus(n);
CSL;//delayus(n);
DataBusH = cmd1;//delayus(n);
// DataBusL = cmd1;
//WRL;
//;
//WRH;
DataBusL = cmd2;//delayus(n);
WRL;//delayus(n);
;//delayus(n);
WRH;//delayus(n);
CSH;//delayus(n);
}
void LCD_WRITE_DATA(char dataa,char datab){
RSH;//delayus(n);
RDH;//delayus(n);
WRH;//delayus(n);
CSL;//delayus(n);
DataBusH = dataa;//delayus(n);
//DataBusL = dataa;
//WRL;
//;
//WRH;
DataBusL = datab;//delayus(n);
WRL;//delayus(n);
;//delayus(n);
WRH;//delayus(n);
CSH;//delayus(n);
}
void LLCD_WRITE_CMD(int cmd){
RSL;//delayus(n);
RDH;//delayus(n);
WRH;//delayus(n);
CSL;//delayus(n);
DataBusH = cmd>>8;//delayus(n);
// DataBusL = cmd1;
//WRL;
//;
//WRH;
DataBusL = cmd;//delayus(n);
WRL;//delayus(n);
;//delayus(n);
WRH;//delayus(n);
CSH;//delayus(n);
}
void LLCD_WRITE_DATA(int dataa){
RSH;//delayus(n);
RDH;//delayus(n);
WRH;//delayus(n);
CSL;//delayus(n);
DataBusH = dataa>>8;//delayus(n);
//DataBusL = dataa;
// WRL;
//;
//WRH;
DataBusL = dataa;//delayus(n);
WRL;//delayus(n);
;//delayus(n);
WRH;//delayus(n);
CSH;//delayus(n);
}
void send_host_reg_command(int cmd,int dataa)
{
LLCD_WRITE_CMD(cmd);
LLCD_WRITE_DATA(dataa);
}
void adderset(char xs,char xe,int ys,int ye){
LLCD_WRITE_CMD(0x0044); LCD_WRITE_DATA(xe,xs); //hs,he
LLCD_WRITE_CMD(0x0045); LLCD_WRITE_DATA(ys); //vs
LLCD_WRITE_CMD(0x0046); LLCD_WRITE_DATA(ye); //ve
LLCD_WRITE_CMD(0x004e); LCD_WRITE_DATA(0x00,xs); //h
LLCD_WRITE_CMD(0x004f); LLCD_WRITE_DATA(ys); //v
LLCD_WRITE_CMD(0x0022);
}
void LCD_TEST_SingleColor(char colorH,char colorL){
int i,j;
LCD_WRITE_CMD(0x00,0x44); LCD_WRITE_DATA(0xef,0x00); //hs
LCD_WRITE_CMD(0x00,0x45); LCD_WRITE_DATA(0x00,0x00); //he
LCD_WRITE_CMD(0x00,0x46); LCD_WRITE_DATA(0x01,0x3f); //vs
LCD_WRITE_CMD(0x00,0x4e); LCD_WRITE_DATA(0x00,0x00); //h
LCD_WRITE_CMD(0x00,0x4f); LCD_WRITE_DATA(0x00,0x00); //v
LCD_WRITE_CMD(0x00,0x22);
for (i=0;i<320;i++){
for (j=0;j<240;j++){
LCD_WRITE_DATA(colorH,colorL);
}
}
}
void LCD_TEST_Picture(unsigned char const *picture){
unsigned char i,j,pixH,pixL;
LCD_WRITE_CMD(0x00,0x44); LCD_WRITE_DATA(0xef,0x00); //hs
LCD_WRITE_CMD(0x00,0x45); LCD_WRITE_DATA(0x00,0x00); //he
LCD_WRITE_CMD(0x00,0x46); LCD_WRITE_DATA(0x01,0x3f); //vs
LCD_WRITE_CMD(0x00,0x4e); LCD_WRITE_DATA(0x00,0x00); //h
LCD_WRITE_CMD(0x00,0x4f); LCD_WRITE_DATA(0x00,0x00); //v
LCD_WRITE_CMD(0x00,0x22);
for (i=0;i<80;i++){
for (j=0;j<240;j++){
pixH=*picture++;
pixL=*picture++;
LCD_WRITE_DATA(pixH,pixL);
//LCD_WRITE_DATA(0xf8,0x00);
}
}
}
void LCD_show_window(void){
int i,j;
LCD_WRITE_CMD(0x00,0x44); LCD_WRITE_DATA(0xef,0x00); //hs
LCD_WRITE_CMD(0x00,0x45); LCD_WRITE_DATA(0x00,0x00); //he
LCD_WRITE_CMD(0x00,0x46); LCD_WRITE_DATA(0x01,0x3f); //vs
LCD_WRITE_CMD(0x00,0x4e); LCD_WRITE_DATA(0x00,0x00); //h
LCD_WRITE_CMD(0x00,0x4f); LCD_WRITE_DATA(0x00,0x00); //v
LCD_WRITE_CMD(0x00,0x22);
for (i=0;i<1;i++){
for (j=0;j<240;j++){
LCD_WRITE_DATA(0xff,0xff);
}
}
for (i=0;i<318;i++){
for (j=0;j<240;j++){
if((j==0)||(j==239)){LCD_WRITE_DATA(0xff,0xff);}
else
{LCD_WRITE_DATA(0x00,0x00);}
}
}
for (i=0;i<1;i++){
for (j=0;j<240;j++){
LCD_WRITE_DATA(0xff,0xff);
}
}
}
/*
void Keypress(){
while(KEY)
delayms(10);
}*/
void delayms(int value){
while (value){
delayus(99);
value--;
}
}
void delayus(int value1){
int i,j;
for(i=value1;i>0;i--)
{
for(j=1;j>0;j--);
}
}
void drawcircle(int x0,int y0,char r)
{
int a,b;
// int x0,y0;
//x0=120;
//y0=120;
int di;
a=0;b=r;
di=3-(r<<1); //判断下个点位置的标志
while(a<=b)
{
LCD_Color_with_ADD(0xff,0xff,x0-b,x0-b,y0-a,y0-a); //3
LCD_Color_with_ADD(0xff,0xff,x0+b,x0+b,y0-a,y0-a); //0
LCD_Color_with_ADD(0xff,0xff,x0-a,x0-a,y0+b,y0+b); //1
LCD_Color_with_ADD(0xff,0xff,x0-b,x0-b,y0-a,y0-a); //7
LCD_Color_with_ADD(0xff,0xff,x0-a,x0-a,y0-b,y0-b); //2
LCD_Color_with_ADD(0xff,0xff,x0+b,x0+b,y0+a,y0+a); //4
LCD_Color_with_ADD(0xff,0xff,x0+a,x0+a,y0-b,y0-b); //5
LCD_Color_with_ADD(0xff,0xff,x0+a,x0+a,y0+b,y0+b); //6
LCD_Color_with_ADD(0xff,0xff,x0-b,x0-b,y0+a,y0+a);
a++;
//使用Bresenham算法画圆
if(di<0)di +=4*a+6;
else
{
di+=10+4*(a-b);
b--;
}
LCD_Color_with_ADD(0xff,0xff,x0+a,x0+a,y0+b,y0+b);
}
}
void drawchar(int acolorH,int acolorL,int bcolorH,int bcolorL,char *p,int x,int y)
{
int i,j,k,l;
for(l=0;l<30;l++)
{
for(i=0;i<16;i++)
{
k=0x80;
for(j=0;j<8;j++)
{
if(k&Font8x16[(*p-0x20)*16+i])
LCD_Color_with_ADD(acolorH,acolorL,239-(x+j),239-(x+j),319-(y+i),319-(y+i));
else
LCD_Color_with_ADD(bcolorH,bcolorL,239-(x+j),239-(x+j),319-(y+i),319-(y+i));
k=k/2;
}
}
x=x+8;
p++;
}
}
void drawpoint(int x,int y)
{
drawcircle(x,y,1);
drawcircle(x,y,2);
drawcircle(x,y,3);
}
void lcdinit()
{
P6DIR = 0XFF;P6OUT = 0XFF;
P10DIR = 0XE7;P10OUT = 0XFF;
P8DIR = 0XFF;P8OUT = 0XFF;
P9DIR = 0XFF;P9OUT = 0XFF;
TOUCH_RESET();
HD_reset();
delayms(50);
LCD_INIT_SSD1289();
delayms(10);
}
#include "msp430x54x.h"
uchar gpGGA[30]="";
uchar gpGSA[30]="";
uchar gpGSV[30]="";
uchar gpRMC[30]="";
uchar gpGLL[30]="";
uchar gpVTG[30]="";
uchar gpZDA[30]="";
uchar gpZTG[30]="";
uchar buf[100]="";
uint i,j,flag;
/*5.6-TXD;5.7-RXD*/
void gps_get()
{
uint q,p;
for(p=0;p<100;p++)
{
if((buf[p]=='R')&(buf[p+1]=='M')&(buf[p+2]=='C'))
{
for(q=0;q<30;q++)
{
gpRMC[q]=buf[p+q];
}
}
else if((buf[p]=='G')&(buf[p+1]=='G')&(buf[p+2]=='A'))
{
for(q=0;q<30;q++)
{
gpGGA[q]=buf[p+q];
}
}
else if((buf[p]=='G')&(buf[p+1]=='S')&(buf[p+2]=='A'))
{
for(q=0;q<30;q++)
{
gpGSA[q]=buf[p+q];
}
}
else if((buf[p]=='G')&(buf[p+1]=='S')&(buf[p+2]=='V'))
{
for(q=0;q<30;q++)
{
gpGSV[q]=buf[p+q];
}
}
else if((buf[p]=='G')&(buf[p+1]=='L')&(buf[p+2]=='L'))
{
for(q=0;q<30;q++)
{
gpGLL[q]=buf[p+q];
}
}
else if((buf[p]=='V')&(buf[p+1]=='T')&(buf[p+2]=='G'))
{
for(q=0;q<30;q++)
{
gpVTG[q]=buf[p+q];
}
}
else if((buf[p]=='Z')&(buf[p+1]=='D')&(buf[p+2]=='A'))
{
for(q=0;q<30;q++)
{
gpZDA[q]=buf[p+q];
}
}
else if((buf[p]=='Z')&(buf[p+1]=='T')&(buf[p+2]=='G'))
{
for(q=0;q<30;q++)
{
gpZTG[q]=buf[p+q];
}
}
}
}
void init_gps()
{
i=0;j=0;
P5SEL = 0xC0; // P5.6,7 = USCI_A0 TXD/RXD
UCA1CTL1 |= UCSWRST; // **Put state machine in reset**
UCA1CTL1 |= UCSSEL_2; // CLK = SMCLK
UCA1BR0 = 0xc4; // 32kHz/9600=3.41 (see User's Guide)
UCA1BR1 = 0x09; //
UCA1MCTL = UCBRS_0+UCBRF_0; // Modulation UCBRSx=3, UCBRFx=0
// UCA1CTL0 = 0xef;
UCA1CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
UCA1IE |= UCRXIE; // Enable USCI_A1 RX interrupt
__bis_SR_register(GIE); // Enter LPM3, interrupts enabled
//__no_operation(); // For debugger
}
#pragma vector=USCI_A1_VECTOR
__interrupt void USCI_A1_ISR(void)
{
switch(__even_in_range(UCA1IV,4))
{
case 0:break; // Vector 0 - no interrupt
case 2: // Vector 2 - RXIFG
while (!(UCA1IFG&UCTXIFG)); // USCI_A0 TX buffer ready?
// TX -> RXed character
UCA1TXBUF=UCA1RXBUF;
if(UCA1RXBUF=='G')
{
flag=1;
}
else;
if(flag)
{
buf[j]=UCA1RXBUF;
}
else;
if(j<100)
{
j++;
}
else
{
flag=0;
j=0;
}
__bis_SR_register(GIE);
break;
case 4:break; // Vector 4 - TXIFG
default: break;
}
}
#include "msp430x54x.h"
void init_gsm()
{
i=0;j=0;
P3SEL = 0x30; // P3.4,5 = USCI_A0 TXD/RXD
UCA0CTL1 |= UCSWRST; // **Put state machine in reset**
UCA0CTL1 |= UCSSEL_2; // SMCLK
UCA0BR0 = 0xd0; // 1MHz 115200 (see User's Guide)
UCA0BR1 = 0x00; // 1MHz 115200
UCA0MCTL |= UCBRS_4 + UCBRF_0; // Modulation UCBRSx=1, UCBRFx=0
UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
UCA0IE |= UCRXIE; // Enable USCI_A0 RX interrupt
__bis_SR_register(GIE); // Enter LPM3, interrupts enabled
//__no_operation(); // For debugger
}
#pragma vector=USCI_A0_VECTOR
__interrupt void USCI_A0_ISR(void)
{
switch(__even_in_range(UCA0IV,4))
{
case 0:break; // Vector 0 - no interrupt
case 2: // Vector 2 - RXIFG
while (!(UCA0IFG&UCTXIFG)); // USCI_A0 TX buffer ready?
// TX -> RXed character
UCA0TXBUF=UCA0RXBUF;
break;
case 4:break; // Vector 4 - TXIFG
default: break;
}
}