Académique Documents
Professionnel Documents
Culture Documents
c
/*
******************************************************************************************************************************
*
Rhydo Technologies Pvt Ltd, Golden Plaza, Cochin, Kerala, India
*
*
(c) Copyright 2010, Rhydo Technologies, Cochin, Kerala
*
* All rights reserved. Rhydo Technologiess source code is an unpublished work and the use of a
* copyright notice does not imply otherwise. This source code contains confidential,trade secret
* material of Rhydo Technologies. Any attempt or participation in deciphering,decoding,reverse
* engineering or in any way altering the source code is strictly prohibited, unless the prior written
* consent of Rhydo Technologies is obtained.
*
* File name : Gps_Lcd.c
* Created
: 12 - May - 2010
/*
/*
/*
*/
*/
*/
Final_Gps_Lcd_Atmel.c
*/
static void SendCommand(const unsigned char Com);
static void SendData(const unsigned char Dat);
static void LcdInitial(void);
static void PgmInitGps();
static void UartInit();
static void DelayMs(int);
/*
**************************************************************************************************************************
*
CODE AREA
**************************************************************************************************************************
*/
void main()
{
PgmInitGps();
LcdInitial();
UartInit();
while (1)
/* Main Infinite Loop */
{
if (LcdSent)
/* GPS Data storage over
*/
{
LcdSent = 0;
/*
Clear Flag
REN=0;
/*
Disable GPS reception
SendCommand(0x80);
/* Position Cursor to Lcd First Location
DelayMs(3);
SendData('L');
/* Send La: to LCD
SendData('a');
SendData(':');
SendData(RMCData[17]);
SendData(RMCData[18]);
SendData('.');
/* Send .(dot) to LCD
*/
SendData(RMCData[19]);
SendData(RMCData[20]);
DataCount = 22;
while (DataCount < 26)
{
SendData(RMCData[DataCount]);
DataCount++;
}
SendData(RMCData[27]);
*/
*/
*/
*/
SendCommand(0xC0);
DelayMs(3);
SendData('L');
SendData('o');
SendData(':');
SendData(RMCData[29]);
SendData(RMCData[30]);
SendData(RMCData[31]);
SendData('.');
SendData(RMCData[32]);
*/
*/
Page 2
Final_Gps_Lcd_Atmel.c
SendData(RMCData[33]);
DataCount = 35;
while (DataCount < 39)
{
SendData(RMCData[DataCount]);
DataCount++;
}
SendData(RMCData[40]);
REN
= 1;
/* Enable GPS reception
}
}
}
/* End of While
/* End of Main
*/
*/
*/
/*
***************************************************************************************************************************
* Function
: RXN()interrupt 4
* Description : Interrupt service routine - Services USART(GPS) Receive Interrupt
* Parameters : None
***************************************************************************************************************************
*/
void RXN()interrupt 4
{
RI = 0;
DataRec = SBUF;
if (DataRec == '$')
/*'$' indicates the starting of data */
{
DataFlag = 1;
}
else if (DataFlag)
{
DataFlag = 0;
if (DataRec == 'G') FirstData = 1;
}
else if (FirstData)
{
FirstData = 0;
if (DataRec == 'P') SecData = 1;
}
else if (SecData)
{
SecData = 0;
if (DataRec == 'R')
/*
'$GPR' is recieved */
{
GPSData = 1;
DataCount = 0;
}
}
else if ((DataRec == '*') && (GPSData == 1)) /* '*' indicates the end of data */
{
LcdSent = 1;
GPSData = 0;
}
if (GPSData)
Page 3
Final_Gps_Lcd_Atmel.c
{
RMCData[DataCount] = DataRec;
DataCount++;
}
}
/*
***************************************************************************************************************************
* Function
: PgmInitGps
* Description : GPS Module Initialization function
* Parameters : None
***************************************************************************************************************************
*/
static void PgmInitGps()
{
DataFlag = 0;
DataCount = 0;
LcdSent = 0;
FirstData = 0;
SecData = 0;
GPSData = 0;
}
/*
***************************************************************************************************************************
* Function
: UartInit
* Description : Usart Initialization function - Baudrate 9600
* Parameters : None
***************************************************************************************************************************
*/
static void UartInit()
{
SM0=0;SM1=1;
/*
Set Serial port mode to 8-bit UART
*/
TMOD=0X20;
/*
Set timer 1 mode to 8-bit Auto-Reload
*/
TF1=0;
/*
Clear timer1 Overflow flag initially
*/
TR1=0;
/*
Disable timer1 Run initially
*/
TH1=0XFd;
/*
Set baudrate to 9600 at 11.0592MHz
*/
TI=0;
/*
Clear Transmit Flag initially
*/
EA=1;
/*
Enable global interrupt
*/
ES=1;
/*
Enable serial interrupt
*/
RI=0;
/*
Clear Receive Flag initially
*/
REN=1;
/*
Enable reception
*/
TR1=1;
/*
Start Timer
*/
}
/*
***************************************************************************************************************************
* Function : LcdInitial
* Description : Function to initialise LCD
* Parameters : None
***************************************************************************************************************************
*/
static void LcdInitial(void)
{
Page 4
Final_Gps_Lcd_Atmel.c
DelayMs(20);
SendCommand(0x38);
DelayMs(3);
SendCommand(0x38);
DelayMs(2);
SendCommand(0x38);
DelayMs(1);
SendCommand(0x0c);
DelayMs(3);
SendCommand(0x01);
DelayMs(3);
SendCommand(0x06);
DelayMs(3);
SendCommand(0x80);
DelayMs(3);
}
/*
***************************************************************************************************************************
* Function
: SendCommand
* Description : Function to send a command to LCD
* Parameters : Com, contains the command to be send
***************************************************************************************************************************
*/
static void SendCommand(const unsigned char Com)
{
RW = 0;
RS = 0;
/* RS = 0, command */
P0 = Com;
EN = 1;
DelayMs(2);
EN = 0;
}
/*
***************************************************************************************************************************
* Function
: SendData
* Description : Function to send data to LCD
* Parameters : Dat, contains the data to be send
***************************************************************************************************************************
*/
static void SendData(const unsigned char Dat)
{
RW = 0;
RS = 1;
/* RS = 1, Data */
P0 = Dat;
EN = 1;
DelayMs(2);
EN = 0;
}
/*
***************************************************************************************************************************
* Function
: DelayMs
* Description : Delay in terms of MilliSeconds
* Parameters : None
Page 5
Final_Gps_Lcd_Atmel.c
***************************************************************************************************************************
*/
static void DelayMs(int count)
{
count *= 1000;
while(--count>0);
}
/*
***************************************************************************************************************************
*
END
***************************************************************************************************************************
*/
Page 6