⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 gps mmc logging using z8f6421 zilog microcontroller
💻 C
字号:
#include <ez8.h>
#include <sio.h>
#include <string.h>
#include <stdlib.h>
#include "mmc.h"
#include "spi.h"
#include "fat.h"
#include "GPS_parsing.h"

#define STR_LEN 15

char timeRMC[STR_LEN];
char latRMC[STR_LEN];
char NS;
char longRMC[STR_LEN];
char EW;
char satusedGGA[STR_LEN];

char strfile[10]="000000";			// CSV Filename (numeric only)
char newdata[100];			// MMC Buffer



void main (void)
{
	char filename[9]="000000";	// YYMMDD__, create_csv_file will automatically append two digits after, alphanumeric only
	extern char *RMC;
	extern char *GGA;
	int degLAT;
	int degLONG;
	float coordLAT;
	float coordLONG;
	int i = 0;


	init_uart(_UART0, _DEFFREQ, 4800);		//initialize UART0
	init_uart(_UART1, _DEFFREQ, 4800);	
	PBDD=0x3F;
	PBAF=0x3F;
	PBOC &= ~0xFF;
	PBHDE |= 0xFF;
	
	PDDD &= ~0x03;		// PD0,PD1 Output
	PDDD |=  0x40;		// PD6 Input 



	if(!(PDIN & 0x40))	// Press PD6 before Reset to Format MMC
		format_to_fat16();
	
	printf("Creating CSV\n");
	create_folder_file(filename,1,0);
	sprintf(newdata,"Time,Lat (Deg),Lat(string),N/S,Long (Deg),Long (string),E/W,Satellites Used%c%c", 13, 10);
	writetommc(newdata,strfile,0);
	printf("Writing location data in MMC\n");
	
	
	while (1) {

			select_port(_UART1);
			strcpy(GGA, GGAstring());
			printf("\n\nGGA Reading: \n%s\n", GGA);
	
			strncpy(satusedGGA, &GGA[45], 2);
			satusedGGA[2] = '\0';
			printf("Satelllites used: %s", satusedGGA);
			strcpy(RMC, RMCstring());
			printf("\n\nRMC Reading:\n");
		   	printf("%s\n", RMC);   
			RMCtime(RMC);
			printf("Time: %s\n", timeRMC);
			RMClat();
			printf("Latitude: %s %c\n", latRMC, NS);
			RMClong();
			printf("Longitude: %s %c\n", longRMC, EW);
			
			coordLAT = atof(latRMC);
			coordLAT = coordLAT*0.01;
			degLAT = coordLAT;
			coordLAT = ((coordLAT - degLAT)*100/60) + degLAT;
			
			coordLONG = atof(longRMC);
			coordLONG = coordLONG*0.01;
			degLONG = coordLONG;
			coordLONG = ((coordLONG - degLONG)*100/60) + degLONG;
	
	
			sprintf(newdata,"%s,%f,%s,%c,%f,%s,%c,%s%c%c", timeRMC, coordLAT, latRMC, NS, coordLONG, longRMC, EW, satusedGGA, 13, 10);
			printf("\n%s\n", newdata);
			writetommc(newdata,strfile,0); 
		}	
		
		printf("It's not supposed to end. There is something very, very wrong.");

}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -