Skip to content

Commit ce308d6

Browse files
committed
Add SFE_UBLOX_GNSS_SUPER
1 parent c31f558 commit ce308d6

File tree

2 files changed

+84
-2
lines changed

2 files changed

+84
-2
lines changed

keywords.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
SFE_UBLOX_GNSS KEYWORD1
1010
SFE_UBLOX_GNSS_SPI KEYWORD1
1111
SFE_UBLOX_GNSS_SERIAL KEYWORD1
12+
SFE_UBLOX_GNSS_SUPER KEYWORD1
1213
DevUBLOXGNSS KEYWORD1
1314

1415
ubxPacket KEYWORD1

src/SparkFun_u-blox_GNSS_v3.h

Lines changed: 83 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ class SFE_UBLOX_GNSS_SPI : public DevUBLOXGNSS
160160
}
161161

162162
// Version 2:
163-
// User passes in an SPI object and SPISettings (optional).
163+
// User passes in an SPI object and SPISettings (optional).
164164
bool begin(SPIClass &spiPort, uint8_t cs, SPISettings ismSettings, uint16_t maxWait = kUBLOXGNSSDefaultMaxWait, bool assumeSuccess = false)
165165
{
166166
// Setup a SPI object and pass into the superclass
@@ -174,7 +174,7 @@ class SFE_UBLOX_GNSS_SPI : public DevUBLOXGNSS
174174
}
175175

176176
// Version 3:
177-
// User passes in an SPI object and SPI speed (optional).
177+
// User passes in an SPI object and SPI speed (optional).
178178
bool begin(SPIClass &spiPort, uint8_t cs, uint32_t spiSpeed, uint16_t maxWait = kUBLOXGNSSDefaultMaxWait, bool assumeSuccess = false)
179179
{
180180
// Setup a SPI object and pass into the superclass
@@ -230,3 +230,84 @@ class SFE_UBLOX_GNSS_SERIAL : public DevUBLOXGNSS
230230
// I2C bus class
231231
SparkFun_UBLOX_GNSS::SfeSerial _serialBus;
232232
};
233+
234+
class SFE_UBLOX_GNSS_SUPER : public DevUBLOXGNSS // A Super Class - all three in one
235+
{
236+
public:
237+
SFE_UBLOX_GNSS_SUPER(){};
238+
239+
bool begin(uint8_t deviceAddress = kUBLOXGNSSDefaultAddress, uint16_t maxWait = kUBLOXGNSSDefaultMaxWait, bool assumeSuccess = false)
240+
{
241+
_commType = COMM_TYPE_I2C;
242+
243+
// Setup I2C object and pass into the superclass
244+
setCommunicationBus(_i2cBus);
245+
246+
// Initialize the I2C buss class i.e. setup default Wire port
247+
_i2cBus.init(deviceAddress);
248+
249+
// Initialize the system - return results
250+
return this->DevUBLOXGNSS::init(maxWait, assumeSuccess);
251+
}
252+
253+
bool begin(TwoWire &wirePort, uint8_t deviceAddress = kUBLOXGNSSDefaultAddress, uint16_t maxWait = kUBLOXGNSSDefaultMaxWait, bool assumeSuccess = false)
254+
{
255+
_commType = COMM_TYPE_I2C;
256+
257+
// Setup I2C object and pass into the superclass
258+
setCommunicationBus(_i2cBus);
259+
260+
// Give the I2C port provided by the user to the I2C bus class.
261+
_i2cBus.init(wirePort, deviceAddress);
262+
263+
// Initialize the system - return results
264+
return this->DevUBLOXGNSS::init(maxWait, assumeSuccess);
265+
}
266+
267+
bool begin(SPIClass &spiPort, uint8_t cs, SPISettings ismSettings, uint16_t maxWait = kUBLOXGNSSDefaultMaxWait, bool assumeSuccess = false)
268+
{
269+
_commType = COMM_TYPE_SPI;
270+
271+
// Setup a SPI object and pass into the superclass
272+
setCommunicationBus(_spiBus);
273+
274+
// Initialize the SPI bus class with provided SPI port, SPI setttings, and chip select pin.
275+
_spiBus.init(spiPort, ismSettings, cs, true);
276+
277+
// Initialize the system - return results
278+
return this->DevUBLOXGNSS::init(maxWait, assumeSuccess);
279+
}
280+
281+
bool begin(SPIClass &spiPort, uint8_t cs, uint32_t spiSpeed = 4000000, uint16_t maxWait = kUBLOXGNSSDefaultMaxWait, bool assumeSuccess = false)
282+
{
283+
_commType = COMM_TYPE_SPI;
284+
285+
// Setup a SPI object and pass into the superclass
286+
setCommunicationBus(_spiBus);
287+
288+
// Initialize the SPI bus class with provided SPI port, SPI setttings, and chip select pin.
289+
_spiBus.init(spiPort, spiSpeed, cs, true);
290+
291+
// Initialize the system - return results
292+
return this->DevUBLOXGNSS::init(maxWait, assumeSuccess);
293+
}
294+
295+
bool begin(Stream &serialPort, uint16_t maxWait = kUBLOXGNSSDefaultMaxWait, bool assumeSuccess = false)
296+
{
297+
_commType = COMM_TYPE_SERIAL;
298+
299+
// Setup Serial object and pass into the superclass
300+
setCommunicationBus(_serialBus);
301+
302+
// Initialize the Serial bus class
303+
_serialBus.init(serialPort);
304+
305+
// Initialize the system - return results
306+
return this->DevUBLOXGNSS::init(maxWait, assumeSuccess);
307+
}
308+
309+
private:
310+
SparkFun_UBLOX_GNSS::SfeI2C _i2cBus;
311+
SparkFun_UBLOX_GNSS::SfeSPI _spiBus;
312+
SparkFun_UBLOX_GNSS::SfeSerial _serialBus;
313+
};

0 commit comments

Comments
 (0)