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.
Fork of gnss by
GnssI2C Class Reference
GNSS class which uses a i2c as physical interface. More...
#include <gnss.h>
Inherits GnssParser.
Public Types | |
| enum | { WAIT = -1, NOT_FOUND = 0 } |
Public Member Functions | |
| GnssI2C (PinName sda GNSS_IF(=NC,=NC), PinName scl GNSS_IF(=NC,=NC), unsigned char i2cAdr GNSS_IF(=(66<< 1),=(66<< 1)), int rxSize=256) | |
| Constructor. | |
| virtual | ~GnssI2C (void) |
| Destructor. | |
| virtual bool | init (PinName pn=GNSS_IF(NC, NC)) |
| Helper function to probe the i2c device. | |
| virtual int | getMessage (char *buf, int len) |
| Get a line from the physical interface. | |
| virtual int | send (const char *buf, int len) |
| Send a buffer. | |
| virtual int | sendNmea (const char *buf, int len) |
| Send an NMEA message, this function just takes the payload and calculates and adds checksum ($ and *XX will be added). | |
| virtual int | sendUbx (unsigned char cls, unsigned char id, const void *buf=NULL, int len=0) |
| Send a UBX message, this function just takes the payload and calculates and adds checksum. | |
| void | powerOff (void) |
| Power off the GNSS, it can be again woken up by an edge on the serial port on the external interrupt pin. | |
Static Public Member Functions | |
| static const char * | findNmeaItemPos (int ix, const char *start, const char *end) |
| get the first character of a NMEA field. | |
| static bool | getNmeaItem (int ix, char *buf, int len, double &val) |
| Extract a double value from a buffer containing a NMEA message. | |
| static bool | getNmeaItem (int ix, char *buf, int len, int &val, int base) |
| Extract a interger value from a buffer containing a NMEA message. | |
| static bool | getNmeaItem (int ix, char *buf, int len, char &val) |
| Extract a char value from a buffer containing a NMEA message. | |
| static bool | getNmeaAngle (int ix, char *buf, int len, double &val) |
| Extract a latitude/longitude value from a buffer containing a NMEA message. | |
Protected Member Functions | |
| bool | writeable (void) |
| Check if the port is writeable (like SerialPipe) | |
| bool | putc (int c) |
| Write a character (like SerialPipe). | |
| virtual int | _send (const void *buf, int len) |
| Write bytes to the physical interface. | |
| int | _get (char *buf, int len) |
| Read bytes from the physical interface. | |
| void | _powerOn (void) |
| Power on the GNSS module. | |
Static Protected Member Functions | |
| static int | _getMessage (Pipe< char > *pipe, char *buf, int len) |
| Get a line from the physical interface. | |
| static int | _parseNmea (Pipe< char > *pipe, int len) |
| Check if the current offset of the pipe contains a NMEA message. | |
| static int | _parseUbx (Pipe< char > *pipe, int len) |
| Check if the current offset of the pipe contains a UBX message. | |
Protected Attributes | |
| Pipe< char > | _pipe |
| the rx pipe. | |
| unsigned char | _i2cAdr |
| the i2c address. | |
| DigitalInOut * | _gnssEnable |
| IO pin that enables GNSS. | |
Static Protected Attributes | |
| static const char | REGLEN = 0xFD |
| the length i2c register address. | |
| static const char | REGSTREAM = 0xFF |
| the stream i2c register address. | |
| static const char | _toHex [16] = { '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F' } |
| num to hex conversion | |
Detailed Description
GNSS class which uses a i2c as physical interface.
Definition at line 250 of file gnss.h.
Member Enumeration Documentation
anonymous enum [inherited] |
Constructor & Destructor Documentation
| GnssI2C | ( | PinName sda | GNSS_IF=NC,=NC, |
| PinName scl | GNSS_IF=NC,=NC, | ||
| unsigned char i2cAdr | GNSS_IF=(66<< 1),=(66<< 1), | ||
| int | rxSize = 256 |
||
| ) |
Constructor.
- Parameters:
-
sda is the I2C SDA pin (between CPU and GNSS). scl is the I2C SCL pin (CPU to GNSS). adr the I2C address of the GNSS set to (66<<1). rxSize the size of the serial rx buffer.
Member Function Documentation
| int _get | ( | char * | buf, |
| int | len | ||
| ) | [protected] |
| int _getMessage | ( | Pipe< char > * | pipe, |
| char * | buf, | ||
| int | len | ||
| ) | [static, protected, inherited] |
Get a line from the physical interface.
- Parameters:
-
pipe the receiveing pipe to parse messages . buf the buffer to store it. len size of the buffer.
- Returns:
- type and length if something was found, WAIT if not enough data is available, NOT_FOUND if nothing was found.
| int _parseNmea | ( | Pipe< char > * | pipe, |
| int | len | ||
| ) | [static, protected, inherited] |
Check if the current offset of the pipe contains a NMEA message.
- Parameters:
-
pipe the receiveing pipe to parse messages. len numer of bytes to parse at maximum.
- Returns:
- length if something was found (including the NMEA frame), WAIT if not enough data is available, NOT_FOUND if nothing was found.
| int _parseUbx | ( | Pipe< char > * | pipe, |
| int | len | ||
| ) | [static, protected, inherited] |
Check if the current offset of the pipe contains a UBX message.
- Parameters:
-
pipe the receiveing pipe to parse messages. len numer of bytes to parse at maximum.
- Returns:
- length if something was found (including the UBX frame), WAIT if not enough data is available, NOT_FOUND if nothing was found.
| void _powerOn | ( | void | ) | [protected, inherited] |
| int _send | ( | const void * | buf, |
| int | len | ||
| ) | [protected, virtual] |
Write bytes to the physical interface.
- Parameters:
-
buf the buffer to write. len size of the buffer to write.
- Returns:
- bytes written.
Implements GnssParser.
| const char * findNmeaItemPos | ( | int | ix, |
| const char * | start, | ||
| const char * | end | ||
| ) | [static, inherited] |
| int getMessage | ( | char * | buf, |
| int | len | ||
| ) | [virtual] |
Get a line from the physical interface.
- Parameters:
-
buf the buffer to store it. len size of the buffer.
- Returns:
- type and length if something was found, WAIT if not enough data is available, NOT_FOUND if nothing was found.
Implements GnssParser.
| bool getNmeaAngle | ( | int | ix, |
| char * | buf, | ||
| int | len, | ||
| double & | val | ||
| ) | [static, inherited] |
Extract a latitude/longitude value from a buffer containing a NMEA message.
- Parameters:
-
ix the index of the field to extract (will extract ix and ix + 1), buf the NMEA message, len the size of the NMEA message, val the extracted latitude or longitude,
- Returns:
- true if successful, false otherwise.
| bool getNmeaItem | ( | int | ix, |
| char * | buf, | ||
| int | len, | ||
| char & | val | ||
| ) | [static, inherited] |
| bool getNmeaItem | ( | int | ix, |
| char * | buf, | ||
| int | len, | ||
| int & | val, | ||
| int | base | ||
| ) | [static, inherited] |
Extract a interger value from a buffer containing a NMEA message.
- Parameters:
-
ix the index of the field to extract. buf the NMEA message. len the size of the NMEA message. val the extracted value. base the numeric base to be used (e.g. 8, 10 or 16).
- Returns:
- true if successful, false otherwise.
| bool getNmeaItem | ( | int | ix, |
| char * | buf, | ||
| int | len, | ||
| double & | val | ||
| ) | [static, inherited] |
| bool init | ( | PinName | pn = GNSS_IF( NC, NC ) ) |
[virtual] |
Helper function to probe the i2c device.
- Parameters:
-
pn the power-on pin for the chip.
- Returns:
- true if successfully detected the GNSS chip.
Implements GnssParser.
| void powerOff | ( | void | ) | [inherited] |
| bool putc | ( | int | c ) | [protected] |
Write a character (like SerialPipe).
- Parameters:
-
c the character to write.
- Returns:
- true if succesffully written .
| int send | ( | const char * | buf, |
| int | len | ||
| ) | [virtual] |
Send a buffer.
- Parameters:
-
buf the buffer to write. len size of the buffer to write.
- Returns:
- bytes written.
Reimplemented from GnssParser.
| int sendNmea | ( | const char * | buf, |
| int | len | ||
| ) | [virtual] |
Send an NMEA message, this function just takes the payload and calculates and adds checksum ($ and *XX
will be added).
- Parameters:
-
buf the message payload to write. len size of the message payload to write.
- Returns:
- total bytes written.
Reimplemented from GnssParser.
| int sendUbx | ( | unsigned char | cls, |
| unsigned char | id, | ||
| const void * | buf = NULL, |
||
| int | len = 0 |
||
| ) | [virtual] |
Send a UBX message, this function just takes the payload and calculates and adds checksum.
- Parameters:
-
cls the UBX class id. id the UBX message id. buf the message payload to write. len size of the message payload to write.
- Returns:
- total bytes written.
Reimplemented from GnssParser.
| bool writeable | ( | void | ) | [protected] |
Check if the port is writeable (like SerialPipe)
- Returns:
- true if writeable
Field Documentation
DigitalInOut* _gnssEnable [protected, inherited] |
const char _toHex = { '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F' } [static, protected, inherited] |
const char REGLEN = 0xFD [static, protected] |
Generated on Thu Jul 14 2022 09:58:19 by
1.7.2
