Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: GPS.h
- Revision:
- 74:208e3e32d263
- Parent:
- 51:e7b81c31baec
- Child:
- 75:ce6e12067d0c
--- a/GPS.h Thu May 15 08:25:45 2014 +0000
+++ b/GPS.h Thu May 15 22:20:42 2014 +0000
@@ -5,12 +5,9 @@
#include "SerialPipe.h"
#ifdef TARGET_UBLOX_C027
- // if we detect the C027 platform we will assign the
- // default pinname and baudrate in the constructor
- // this helper macro will be used.
- #define _C027DEFAULT(name) = name
+ #define _IF(onboard, shield) onboard
#else
- #define _C027DEFAULT(name)
+ #define _IF(onboard, shield) shield
#endif
/** basic gps parser class
@@ -18,6 +15,14 @@
class GPSParser
{
public:
+
+ //! Constructor
+ ~GPSParser(void);
+
+ /** Power on / Wake up the gps
+ */
+ virtual bool init(void) = 0;
+
enum {
// getLine Responses
WAIT = -1, //!< wait for more incoming data (the start of a message was found, or no data available)
@@ -66,7 +71,7 @@
*/
virtual int sendUbx(unsigned char cls, unsigned char id,
const void* buf = NULL, int len = 0);
-
+
/** Power off the gps, it can be again woken up by an
edge on the serial port on the external interrupt pin.
*/
@@ -155,6 +160,9 @@
virtual int _send(const void* buf, int len) = 0;
static const char toHex[16]; //!< num to hex conversion
+#ifdef TARGET_UBLOX_C027
+ bool _onboard;
+#endif
};
/** gps class which uses a serial port
@@ -170,12 +178,14 @@
\param rxSize the size of the serial rx buffer
\param txSize the size of the serial tx buffer
*/
- GPSSerial(PinName tx _C027DEFAULT( GPSTXD ),
- PinName rx _C027DEFAULT( GPSRXD ),
- int baudrate _C027DEFAULT( GPSBAUD ),
+ GPSSerial(PinName tx _IF( = GPSTXD, /* = D8 */), // resistor on shield not populated
+ PinName rx _IF( = GPSRXD, /* = D9 */), // resistor on shield not populated
+ int baudrate _IF( = GPSBAUD, = 9600 ),
int rxSize = 256 ,
int txSize = 128 );
+ virtual bool init(void);
+
/** Get a line from the physical interface.
\param buf the buffer to store it
\param len size of the buffer
@@ -205,15 +215,15 @@
\param adr the I2C address of the GPS set to (66<<1)
\param rxSize the size of the serial rx buffer
*/
- GPSI2C(PinName sda _C027DEFAULT( GPSSDA ),
- PinName scl _C027DEFAULT( GPSSCL ),
- unsigned char i2cAdr _C027DEFAULT( GPSADR ),
+ GPSI2C(PinName sda _IF( = GPSSDA, = D14 ),
+ PinName scl _IF( = GPSSCL, = D15 ),
+ unsigned char i2cAdr _IF( = GPSADR, = (66<<1) ),
int rxSize = 256 );
-
+
/** helper function to probe the i2c device
\return true if successfully detected the gps.
*/
- bool detect(void);
+ virtual bool init(void);
/** Get a line from the physical interface.
\param buf the buffer to store it
@@ -277,7 +287,6 @@
int _get(char* buf, int len);
Pipe<char> _pipe; //!< the rx pipe
- bool found; //!< flag if device is detected.
unsigned char _i2cAdr; //!< the i2c address
static const char REGLEN; //!< the length i2c register address
static const char REGSTREAM;//!< the stream i2c register address