// *****************************************************************************/ #include "ccblkfn.h" #include "sysreg.h" #include "Uart0.h" #include "Uart1.h" #include #include #include "ccblkfn.h" #include "sysreg.h" #include #include #define EVER 1 //--------------------------------------------------------------------------// void LED_Init() { int temp; temp = *pPORTF_FER; temp++; #if (__SILICON_REVISION__ < 0x0001) *pPORTF_FER = 0x0000; *pPORTF_FER = 0x0000; #else *pPORTF_FER = 0x0000; #endif *pPORTFIO_INEN = 0x0004; // Pushbuttons *pPORTFIO_DIR = 0x0FC0; // LEDs *pPORTFIO_EDGE = 0x0004; *pPORTFIO_MASKA = 0x0004; *pPORTFIO_SET = 0x0FC0; *pPORTFIO_CLEAR = 0x0FC0; }; //--------------------------------------------------------------------------// // Function: main // //--------------------------------------------------------------------------// void main(void) { int c; /* LED_Init(); UART0_initialize(115200); UART0_putc('H'); UART0_putc('e'); UART0_putc('l'); UART0_putc('l'); UART0_putc('o'); for (;EVER;) { c = UART0_getc(); UART0_putc(c); UART0_putc('#'); *pPORTFIO_TOGGLE = 0x0040 | 0x0080 | 0x0100 | 0x0200 | 0x0400 | 0x0800; }; while(1);*/ LED_Init(); UART0_initialize(115200); /*UART0_putc('H'); UART0_putc('e'); UART0_putc('l'); UART0_putc('l'); UART0_putc('o');*/ UART1_initialize(19200); //UART1_putc('F'); char buff[255]; char word[255]; char ts[16]; char lat[16]; char latd[16]; char lon[16]; char lond[16]; char sats[16]; char date[16]; for (;EVER;) { if (UART1_checkc()) { /*c = UART1_getc(); UART0_putc(c);*/ memset(buff,'\0',255); memset(word,'\0',255); memset(ts,'\0',16); memset(lat,'\0',16); memset(latd,'\0',16); memset(lon,'\0',16); memset(lond,'\0',16); memset(sats,'\0',16); memset(date,'\0',16); UART1_gets(buff,255); sscanf(buff,"%[^,]",word); if(!strcmp(word,"$GPGGA")) { sscanf( buff, "%*[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%*[^,],%[^,]", ts,lat,latd,lon,lond,sats ); memset(buff,'\0',255); sprintf(buff,"Timestamp:%s Coords:%s%s %s%s Sats:%s\n\r",ts,lat,latd,lon,lond,sats); UART0_puts(buff); } else if(!strcmp(word,"C")) { sscanf( buff, "%*[^,],%*[^,],%*[^,],%*[^,],%*[^,],%*[^,],%*[^,],%*[^,],%*[^,],%[^,]", date ); memset(buff,'\0',255); sprintf(buff,"Date:%s\n\r",date); UART0_puts(buff); } else { sscanf( buff, "%*[^,],%*[^,],%*[^,],%*[^,],%*[^,],%*[^,],%*[^,],%*[^,],%[^,]", date ); memset(buff,'\0',255); sprintf(buff,"Date:%s\n\r",date); UART0_puts(buff); } *pPORTFIO_TOGGLE = 0x0040 | 0x0080 | 0x0100 | 0x0200 | 0x0400 | 0x0800; }; };/* if (UART0_checkc()) { c = UART0_getc(); UART1_putc(c); *pPORTFIO_TOGGLE = 0x0040 | 0x0080 | 0x0100 | 0x0200 | 0x0400 | 0x0800; };*/ while(1); }