summaryrefslogtreecommitdiffstats
path: root/u-boot/board/goldelico/gta04/gps.c
diff options
context:
space:
mode:
authorH. Nikolaus Schaller <hns@goldelico.com>2012-10-13 08:22:02 +0200
committerH. Nikolaus Schaller <hns@goldelico.com>2012-10-13 08:22:02 +0200
commita1e3e7a2f7e812cec0627afedf1bc6c85aea4999 (patch)
treea45e837c8443ab2182ebf592c8c08516e0df848b /u-boot/board/goldelico/gta04/gps.c
parent7e4b84a1e9da223acab3bd833530d25763f19b80 (diff)
downloadbootable_bootloader_goldelico_gta04-a1e3e7a2f7e812cec0627afedf1bc6c85aea4999.zip
bootable_bootloader_goldelico_gta04-a1e3e7a2f7e812cec0627afedf1bc6c85aea4999.tar.gz
bootable_bootloader_goldelico_gta04-a1e3e7a2f7e812cec0627afedf1bc6c85aea4999.tar.bz2
added option to read PPS impulse; fixed GPIO assignments
Diffstat (limited to 'u-boot/board/goldelico/gta04/gps.c')
-rw-r--r--u-boot/board/goldelico/gta04/gps.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/u-boot/board/goldelico/gta04/gps.c b/u-boot/board/goldelico/gta04/gps.c
index 7f74dc8..9383a88 100644
--- a/u-boot/board/goldelico/gta04/gps.c
+++ b/u-boot/board/goldelico/gta04/gps.c
@@ -36,11 +36,13 @@
#define GPIO_GPSEXT 144 // external GPS antenna plugged in
#define GPIO_GPS_ON 145 // reset for GPS module
+#define GPIO_GPS_PPS 114 // Pulse per Second interrupt
#else /* Beagle Hybrid */
-#define GPIO_GPSEXT 138 // external GPS antenna plugged in
+#define GPIO_GPSEXT 144 // external GPS antenna plugged in
#define GPIO_GPS_ON 156
+#define GPIO_GPS_PPS 138 // Pulse per Second interrupt
#endif
@@ -69,6 +71,8 @@ int gps_init(void)
omap_set_gpio_direction(GPIO_GPS_ON, 0); // output
omap_request_gpio(GPIO_GPSEXT);
omap_set_gpio_direction(GPIO_GPSEXT, 1); // input
+ omap_request_gpio(GPIO_GPS_PPS);
+ omap_set_gpio_direction(GPIO_GPS_PPS, 1); // input
return 0;
}
@@ -87,6 +91,7 @@ void gps_off(void)
}
static int lastant=-1;
+static int lastpps=-1;
static long timer;
#define TIMEOUT 2 // in seconds
@@ -100,13 +105,20 @@ void gps_echo(void)
while (1)
{ // echo in both directions
int ant=omap_get_gpio_datain(GPIO_GPSEXT);
+ int pps=omap_get_gpio_datain(GPIO_GPS_PPS);
if(ant != lastant)
{ // changed
- if(ant)
- printf("external antenna\n");
- else
- printf("internal antenna\n");
- lastant=ant;
+ if(ant)
+ printf("external antenna\n");
+ else
+ printf("internal antenna\n");
+ lastant=ant;
+ }
+ if(pps != lastpps)
+ { // comes only with >= 5 satellites
+ if(lastpps >= 0)
+ printf("PPS\n");
+ lastpps=pps;
}
if(NS16550_tstc((NS16550_t)CONFIG_SYS_NS16550_COM2))
{
@@ -126,7 +138,7 @@ void gps_echo(void)
printf("no data: on-off impulse\n");
omap_set_gpio_dataout(GPIO_GPS_ON, 1);
udelay(5000);
- omap_set_gpio_dataout(GPIO_GPS_ON, 1);
+ omap_set_gpio_dataout(GPIO_GPS_ON, 0);
timer=0;
}
udelay(100); // 10 kHz @ 9 kbit/s