基于MSP430F249的GPS+GPRS车载GPS
基于MSP430F249的GPS GPRS车载GPS.zip
(412.19 KB)
//******************************************************************************
// MSP430x24x Demo - Software Toggle P1.0, MCLK = VLO/8
//
// Description; Pulse P1.0 with a 1/100 active duty cycle using software.
// Ultra-low frequency ~ 1.5kHz, ultra-low power active mode demonstrated. All
// the 6 I/O ports are configured as low outputs to eliminate floating inputs.
// ACLK = VL0, MCLK = VLO/8 ~ 1.5kHz, SMCLK = n/a
//
// MSP430F249
// -----------------
// /|\| XIN|-
// | | |
// --|RST XOUT|-
// | |
// | P1.0|-->LED
// | P5.4/MCLK|-->MCLK = VLO/8
// | P5.6/ACLK|-->ACLK = VLO
//
// B. Nisarga
// Texas Instruments Inc.
// July 2007
// Built with CCE Version: 3.2.0 and IAR Embedded Workbench Version: 3.42A
//******************************************************************************
//38 Decoder Control
//#define Y0_138 (0x0080) //P6.7
//#define Y1_138 (0x0040) //P6.6
//#define Y2_138 (0x0020) //P6.5
//#define EN_138 (0x0010) //P6.4
//38 Decoder Output
//#define USB_RESET ((0x0000)<<5) //000
//#define GPS_RESET ((0x0004)<<5) //001
//#define WDG_Disable ((0x0002)<<5) //010
//#define CPU_LED ((0x0006)<<5) //011
//#define IPONE_POWER_EN ((0x0001)<<5) //100
//#define SPI_USB_CS ((0x0005)<<5) //101
//#define SPI_UART_EXTEND2_CS ((0x0003)<<5) //110
//#define SPI_UART_EXTEND1_CS ((0x0008)<<5) //111
#include "430bios.h"
#include "EXAR.H"
#include "HAL.H"
#include "general.h"
#include "main_init.h"
#include "pcf8563.h"
#include "Do_Reset.h"
#include "Do_M22.h"
#include "gps.h"
#include "flash_record.h"
#include "DATA_APC.H"
#include "SET_P.H"
// volatile to prevent optimization
//volatile unsigned char j=0;
unsigned char flag=0;
//unsigned char flag1=0;
//unsigned char buf1[8]={0x55,0xAA};
//void SendUart(unsigned char *pBuffer,unsigned char n_byte);
//void init_GPRS(void);
#pragma vector = TIMERB0_VECTOR
__interrupt void TimerB (void)
{
//CCR0+=1000; //定时1ms,外部时钟为8M的时钟。
gTimer++; //1ms增加一次记数
gprsTimer++;
if(GPRS_STATUS&GPRS_TCP_FLAG)
gM22_TCP_ECHO_Timer++;
if(gTimer>1000)
{
gTimer=0;
gSysTimer++;
gCircle_Timer++;
GprsPower=1;
//flag1=1;
//if(apc_flag!=0)
//{
// apc_flag=0;
// EXAR_fiforeset();
// for(j=0;j<EXAR_j;j++)
// Send_ComA(Ptr_Chn1[j]);
// EXAR_j=0;
//}
flag=~flag;
if(flag!=0)
{
//P6OUT |= EN_138; //Enable 38 Decoder
//P6OUT |= 0xD0;//(CPU_LED|0x1F); //Cpu Led off
//IO_CS_FUN(CPU_LED);
}
else
{
//P6OUT &= ~EN_138;
//P6OUT &= 0x7F;
//IO_NCS_FUN();
}
}
}
//volatile unsigned int i;
void main(void)
{
unsigned int i;
// unsigned char mm[256];
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
init_clk();
init_com0_gprs();
init_port();
init_GPS();
init_rtc();
init_flash();
init_sram();
init_EXAR();
Init_USB();
Read_Gprs_P();
Init_FMCL04();
RTC_Set_DateTime(0x00101117,0x00123559);
page_count_global=power_on_find_page();
_EINT();
init_GPRS(); // P5.6= ACLK option select
for (;;)
{
//if(flag!=0)
//{
//flag=0;
//delay(5);
//for(i=0;i<256;i++)
// I2C_Write(FM24C04_WriteAddress_Page1,247, 'A');
// I2C_Write(FM24C04_WriteAddress_Page1,248, 'P');
// I2C_Write(FM24C04_WriteAddress_Page1,249, 'C');
// for(i=0;i<256;i++)
//I2C_Write(FM24C04_WriteAddress_Page0,i,'A' );
// for(i=0;i<256;i++)
// {
// mm[i]=I2C_Read(FM24C04_WriteAddress_Page1,FM24C04_ReadAddress_Page1,i);
// }
// for(i=0;i<256;i++)
// {
// mm[i]=I2C_Read(FM24C04_WriteAddress_Page0,FM24C04_ReadAddress_Page0,i );
// }
//RTC_ReadAll();
//SendUart(buf1,sizeof(buf1));
//}
if(Query376Interrupt())
{
for(i=0;i<2000;i++);
Do_USB();
}
if(GPRS_STATUS&GPRS_POWER_OFF)
{
Do_OFF_Power();
}
else if(GPRS_STATUS&GPRS_RST_FLAG)
{
Do_Reset_GSM_On();
}
else
{
Do_G20_Out();
}
Do_GPS_Module();
EXAR_APC_FUN();
Write_APC_Data();
if(gGeneral_Flag&SET_P_FLAG)
{
gGeneral_Flag&=~SET_P_FLAG;
Read_Gprs_P();
}
//if(flag!=0)
//{
//flag=0 ;
//Send_ComB(gYear);
//Send_ComB(gMonth);
//Send_ComB(gDate);
//Send_ComB(gHour);
//Send_ComB(gMinute);
//Send_ComB(gSecond);
//Send_ComB(0x0d);
//Send_ComB(0x0a);
//}
//delay(500);
//i=0;
}
}
#pragma vector= USCIAB0RX_VECTOR
__interrupt void Uart0Rx(void)
{
//int i=0;
//if((UCA0STAT&UCRXERR)==0)
//{
//AddUsData(RXBUF0);
if( gReceive0_GSM_Buffer_Point != gReceive0_GSM_Buffer_End )
{ // 缓冲区满了将不接收数据,因此每包数据不要超过256字节比较好
gReceive0_GSM_Buffer[gReceive0_GSM_Buffer_Point] = UCA0RXBUF;
gReceive0_GSM_Buffer_Point++;
if( gReceive0_GSM_Buffer_Point >= sizeof(gReceive0_GSM_Buffer) ) gReceive0_GSM_Buffer_Point=0;
//gM22_GSM_ECHO_Timer=0;
gM22_TCP_ECHO_Timer=0;
}
//}
//else
//{
//}
}
unsigned char Compare_String(unsigned char *Source,unsigned char *Target,unsigned int Count )
{
while(Count>0)
{
if((*Source)!=(*Target)) return(0);
Source++;
Target++;
Count--;
}
return(1);
}
|