GPSロガー最終形態に完成!(SparkFun GPS-09171 & GPS-00464)
今日、ようやっと、GPSロガー最終形態に完成した。ブレッドビードから万能基板へ移行して、GPSモジュールのバックアップバッテリ(リチュウム二次電池)を搭載し、ケースをバックに入れ易い比較的薄型へ移行した。
バックアップバッテリの搭載には、外部回路が多少に追加が必要だった。そのアップは、、、、
|
|
|
|
|
|
#include "mbed.h"
#include "string.h"
#include "SDFileSystem.h"
#include "PowerControl/PowerControl.h"
#include "EthernetPowerControl.h"
#include "ClockControl.h"
#include "TextLCD.h"
Serial gps( p13, p14);
DigitalOut led1(LED1);
DigitalOut led2(LED2);
DigitalOut LCD_RW( p27 );
DigitalOut bkLight( p28 );
InterruptIn btm(p29);
SDFileSystem sd(p5,p6,p7,p8, "gps");
TextLCD lcd( p26, p25, p24, p23, p22, p21, TextLCD::LCD20x4 ); // rs, e, d4, d5, d6, d7
char BMSG[16] = {
0xa0,
0xa1,
0x00,
0x09,
0x08, // Configure NMEA message interval
0x0a, // GGA
0x00, // GSA
0x00, // GSV
0x00, // GLL
0x0a, // RMC
0x00, // VTG
0x00, // ZDA
0x00, // ATTR
0x00, // Parity
0x0d,
0x0a
};
char BMSG_BPS[11] = {
0xa0,
0xa1,
0x00,
0x04,
0x05,
0x00, // COM1
0x00, // 4800bps
0x00,
0x00, // Parity
0x0d,
0x0a
};
#define USR_POWERDOWN (0x104)
int semihost_powerdown() {
uint32_t arg;
return __semihost(USR_POWERDOWN, &arg);
}
int ENABLE_SD = 1;
char buf[1024];
int ptr_in = 0;
int ptr_ou = 0;
struct tm myTm;
struct tm *ptm;
time_t myTime;
char strLatitude[11];
char strLongitude[11];
char strHeight[7];
void handler_btm(void)
{
if (ENABLE_SD == 1) {
ENABLE_SD = 0;
led2 = 1;
} else {
ENABLE_SD = 1;
led2 = 0;
}
}
void handler_serial(void)
{
char cc;
FILE *fp;
char cbuf[3];
int lfc;
int oft = 0;
int oft_m = 0;
int oft_n = 0;
int oft_e = 0;
cbuf[2] = 0x00;
led1 = 1;
for ( ptr_in=0, lfc=1; ptr_in 1) {
buf[ptr_in++] = cc;
break;
} else {
if (buf[5] != 'A') goto MY_EXIT;
cc = ',';
oft = ptr_in+1;
}
}
buf[ptr_in++] = cc;
}
buf[ptr_in++] = 0x00;
printf( "%s\n\r", &(buf[0]) );
printf( "-------\n\r" );
if (buf[oft+5] == 'C') {
int i, j;
for (i=20, j=0;j<10;i++,j++) {
cc = buf[oft+i];
if (cc == ',') break;
strLatitude[j] = cc;
}
strLatitude[j] = 0x00;
oft_n = oft + i + 1;
i += 3;
for (j=0;j<10;i++,j++) {
cc = buf[oft+i];
if (cc == ',') break;
strLongitude[j] = cc;
}
strLongitude[j] = 0x00;
oft_e = oft + i + 1;
for (i=0;i<7;i++) {
cc = buf[oft_m+i];
if (cc == ',') break;
strHeight[i] = cc;
}
strHeight[i] = 0x00;
printf( "--- %s, %s, %s ---\n\r", strLatitude, strLongitude,strHeight );
if (buf[oft+18] != 'A')
{
lcd.cls();
for ( ptr_ou=0; ptr_outm_year + 1900,
ptm->tm_mon + 1,
ptm->tm_mday
);
// printf( "%s\n", mydate );
sprintf( fname, "/gps/%s.csv", mydate );
if ( ENABLE_SD ) {
fp = fopen ( fname, "a" );
if (fp != NULL ){
fprintf( fp, "%04d/%02d/%02d %02d:%02d:%02d,%s",
ptm->tm_year+1900,
ptm->tm_mon+1,
ptm->tm_mday,
ptm->tm_hour,
ptm->tm_min,
ptm->tm_sec,
&(buf[0]) );
fclose( fp );
} else {
printf( "can't open sd\n" );
}
}
lcd.cls();
lcd.printf( "%04d/%02d/%02d %02d:%02d:%02d\n%c: %s\n%c: %s\nH: %s",
ptm->tm_year+1900,
ptm->tm_mon+1,
ptm->tm_mday,
ptm->tm_hour,
ptm->tm_min,
ptm->tm_sec,
buf[oft_n],
strLatitude,
buf[oft_e],
strLongitude,
strHeight
);
}
}
MY_EXIT:
led1 = 0 ;
}
int main() {
setSystemFrequency( 0x3, 0x1, 6, 1 ); // need a change to 4800bps
PHY_PowerDown();
Peripheral_PowerDown(
LPC1768_PCONP_PCADC |
// LPC1768_PCONP_PCUART0 |
// LPC1768_PCONP_PCUART1 |
LPC1768_PCONP_PCUART2 |
LPC1768_PCONP_PCUART3 |
// LPC1768_PCONP_PCSSP0 |
// LPC1768_PCONP_PCSSP1 |
LPC1768_PCONP_PCCAN1 |
LPC1768_PCONP_PCCAN2 |
LPC1768_PCONP_PCENET |
LPC1768_PCONP_PCUSB |
// LPC1768_PCONP_PCI2C0 |
LPC1768_PCONP_PCI2C1 |
LPC1768_PCONP_PCI2C2 |
LPC1768_PCONP_PCPWM1 |
LPC1768_PCONP_PCMCPWM
);
semihost_powerdown();
LCD_RW = 0;
bkLight = 1;
gps.baud(4800);
// gps.baud(9600);
lcd.cls();
lcd.printf( "Begin a test!" );
wait( 5.0 );
int ptr;
char cs;
if (0) { // tool for change to 4800 bps
cs = 0;
for ( ptr=0; ptr<4; ptr++ ) {
cs = cs ^ BMSG_BPS[4+ptr];
}
BMSG_BPS[4+ptr] = cs;
for (ptr=0; ptr<11; ptr++ ) {
gps.putc( BMSG_BPS[ptr] );
}
gps.getc();
gps.baud(4800);
setSystemFrequency( 0x3, 0x1, 6, 1 ); // need a change to 4800bps
}
printf( "go test!\n\r" );
if (0) { // tool for filtering massages
cs = 0;
for ( ptr=0; ptr<9; ptr++ ) {
cs = cs ^ BMSG[4+ptr];
}
BMSG[4+ptr] = cs;
for (ptr=0; ptr<16; ptr++ ) {
gps.putc( BMSG[ptr] );
}
gps.getc();
}
gps.attach(handler_serial);
btm.fall( &handler_btm );
while (1) {
Sleep();
}
} トラックバック(0)
このブログ記事を参照しているブログ一覧: GPSロガー最終形態に完成!(SparkFun GPS-09171 & GPS-00464)
このブログ記事に対するトラックバックURL: http://the.nerd.jp/blogs/cgi-bin/mt-tb.cgi/4679








