Graham Cantin / MODGPS

Dependents:   Telnet_server

Fork of MODGPS by Andy K

Embed: (wiki syntax)

« Back to documentation index

GPS Class Reference

GPS module. More...

#include <GPS.h>

Public Types

enum  ppsEdgeType { ppsRise = 0, ppsFall }
 

The PPS edge type to interrupt on.

More...
enum  Parity
 

A copy of the Serial parity enum.

More...

Public Member Functions

 GPS (PinName tx, PinName rx, const char *name=NULL)
 GPS constructor.
bool isTimeValid (void)
 Is the time reported by the GPS valid.
int getGPSquality (void)
 Is the positional fix reported by the GPS valid.
int numOfSats (void)
 How many satellites were used in the last fix.
double latitude (void)
 What was the last reported latitude (in degrees)
double longitude (void)
 What was the last reported longitude (in degrees)
double altitude (void)
 What was the last reported altitude (in kilometers)
double height (void)
 What was the last reported altitude/height (in kilometers)
GPS_Geodeticgeodetic (GPS_Geodetic *g)
 Get all three geodetic parameters together.
GPS_Geodeticgeodetic (void)
 Get all three geodetic parameters together.
GPS_TimetimeNow (GPS_Time *n)
 Take a snap shot of the current time.
GPS_TimetimeNow (void)
 Take a snap shot of the current time.
double julianDayNumber (void)
 Return the curent day.
double julianDate (void)
 Return the curent date/time as a Julian date.
double siderealDegrees (void)
 Get the current sidereal degree angle.
double siderealHA (void)
 Get the current sidereal hour angle.
void ppsAttach (PinName irq, ppsEdgeType type=ppsRise)
 Optionally, connect a 1PPS single to an Mbed pin.
void ppsUnattach (void)
 Remove any 1PPS signal previously attached.
void rx_irq (void)
 GPS serial receive interrupt handler.
void pps_irq (void)
 GPS pps interrupt handler.
void ticktock (void)
 10ms Ticker callback.
template<typename T >
void attach_pps (T *tptr, void(T::*mptr)(void))
 Attach a user object/method callback function to the PPS signal.
void attach_pps (void(*fptr)(void))
 Attach a user callback function to the PPS signal.
template<typename T >
void attach_rmc (T *tptr, void(T::*mptr)(void))
 Attach a user callback function to the NMEA RMC message processed signal.
void attach_rmc (void(*fptr)(void))
 Attach a user callback function to the NMEA RMC message processed signal.
template<typename T >
void attach_gga (T *tptr, void(T::*mptr)(void))
 Attach a user callback function to the NMEA GGA message processed signal.
void attach_gga (void(*fptr)(void))
 Attach a user callback function to the NMEA GGA message processed signal.
void baud (int baudrate)
 Set the baud rate the GPS module is using.
void format (int bits, Parity parity, int stop_bits)
 Set the serial port format the GPS module is using.

Data Fields

void * _base
 A pointer to the UART peripheral base address being used.
char buffer [2][GPS_BUFFER_LEN]
 The RX serial buffer.
int active_buffer
 The current "active" buffer, i.e. the buffer the ISR is writing to.
int rx_buffer_in
 The active buffer "in" pointer.
bool process_required
 Boolean flag set when the "passive" buffer is full and needs processing.
FunctionPointer cb_pps
 A callback object for the 1PPS user API.
FunctionPointer cb_rmc
 A callback object for the NMEA RMS message processed signal user API.
FunctionPointer cb_gga
 A callback object for the NMEA GGA message processed signal user API.

Protected Attributes

bool _ppsInUse
 Flag set true when a GPS PPS has been attached to a pin.
InterruptIn * _pps
 An InterruptIn object to "trigger" on the PPS edge.
Ticker * _second100
 A Ticker object called every 10ms.
GPS_Time theTime
 A GPS_Time object used to hold the last parsed time/date data.
GPS_Geodetic thePlace
 A GPS_Geodetic object used to hold the last parsed positional data.

Detailed Description

GPS module.

Author:
Andy Kirkham
See also:
http://mbed.org/cookbook/MODGPS
example1.cpp
example2.cpp
The MODGPS API
gps_interfaces.png

Wiring up the GPS module

Example:

 #include "mbed.h"
 #include "GPS.h"

 DigitalOut led1(LED1);
 Serial pc(USBTX, USBRX);
 GPS gps(NC, p10); 

 int main() {
     GPS_Time t;

     // Wait for the GPS NMEA data to become valid.
     while (!gps.isTimeValid()) {
       led1 = !led1;
       wait(1);
     }

     gps.timeNow(&t);

     pc.printf("The time/date is %02d:%02d:%02d %02d/%02d/%04d\r\n",
        t.hour, t.minute, t.second, t.day, t.month, t.year);

     // Wait until at least four satellites produce a position fix and a valid quality.
     while (gps.numOfSats() < 4 && gps.getGPSquality != 0) {
       led1 = !led1;
       wait(1);
     }

     pc.printf("Lat = %.4f Lon = %.4f Alt = %.1fkm\r\n", 
         gps.latitude(), gps.longitude, gps.altitude());

     // Make the LED go steady to indicate we have finished.
     led1 = 1;
 
     while(1) {}
 }

Definition at line 99 of file GPS.h.


Member Enumeration Documentation

enum Parity

A copy of the Serial parity enum.

Definition at line 109 of file GPS.h.

The PPS edge type to interrupt on.

Enumerator:
ppsRise 

Use the rising edge (default).

ppsFall 

Use the falling edge.

Definition at line 103 of file GPS.h.


Constructor & Destructor Documentation

GPS ( PinName  tx,
PinName  rx,
const char *  name = NULL 
)

GPS constructor.

The GPS constructor is used to initialise the GPS object.

Parameters:
txUsually unused and set to NC
rxThe RX pin the GPS is connected to, p10, p14( OR p25), p27.
nameAn option name for RPC usage.

Definition at line 25 of file GPS.cpp.


Member Function Documentation

void pps_irq ( void   )

GPS pps interrupt handler.

Definition at line 123 of file GPS.cpp.

void ppsUnattach ( void   )

Remove any 1PPS signal previously attached.

Definition at line 54 of file GPS.cpp.

void rx_irq ( void   )

GPS serial receive interrupt handler.

Definition at line 131 of file GPS.cpp.

void ticktock ( void   )

10ms Ticker callback.

Definition at line 101 of file GPS.cpp.


Field Documentation

void* _base

A pointer to the UART peripheral base address being used.

Definition at line 449 of file GPS.h.

InterruptIn* _pps [protected]

An InterruptIn object to "trigger" on the PPS edge.

Definition at line 634 of file GPS.h.

bool _ppsInUse [protected]

Flag set true when a GPS PPS has been attached to a pin.

Definition at line 631 of file GPS.h.

Ticker* _second100 [protected]

A Ticker object called every 10ms.

Definition at line 637 of file GPS.h.

The current "active" buffer, i.e. the buffer the ISR is writing to.

Definition at line 455 of file GPS.h.

char buffer[2][GPS_BUFFER_LEN]

The RX serial buffer.

Definition at line 452 of file GPS.h.

FunctionPointer cb_gga

A callback object for the NMEA GGA message processed signal user API.

Definition at line 602 of file GPS.h.

FunctionPointer cb_pps

A callback object for the 1PPS user API.

Definition at line 510 of file GPS.h.

FunctionPointer cb_rmc

A callback object for the NMEA RMS message processed signal user API.

Definition at line 556 of file GPS.h.

Boolean flag set when the "passive" buffer is full and needs processing.

Definition at line 461 of file GPS.h.

The active buffer "in" pointer.

Definition at line 458 of file GPS.h.

GPS_Geodetic thePlace [protected]

A GPS_Geodetic object used to hold the last parsed positional data.

Definition at line 643 of file GPS.h.

GPS_Time theTime [protected]

A GPS_Time object used to hold the last parsed time/date data.

Definition at line 640 of file GPS.h.