more workin' on i2c
This commit is contained in:
parent
c9632ab73c
commit
2213c03439
|
|
@ -383,9 +383,7 @@ float Adafruit_GPS::secondsSinceDate() {
|
||||||
|
|
||||||
|
|
||||||
size_t Adafruit_GPS::available(void) {
|
size_t Adafruit_GPS::available(void) {
|
||||||
char c = 0;
|
if (paused) return 0;
|
||||||
|
|
||||||
if (paused) return c;
|
|
||||||
|
|
||||||
#if (defined(__AVR__) || defined(ESP8266)) && defined(USE_SW_SERIAL)
|
#if (defined(__AVR__) || defined(ESP8266)) && defined(USE_SW_SERIAL)
|
||||||
if (gpsSwSerial) {
|
if (gpsSwSerial) {
|
||||||
|
|
@ -398,7 +396,7 @@ size_t Adafruit_GPS::available(void) {
|
||||||
if (gpsI2C) {
|
if (gpsI2C) {
|
||||||
return 1; // I2C doesnt have 'availability' so always has a byte at least to read!
|
return 1; // I2C doesnt have 'availability' so always has a byte at least to read!
|
||||||
}
|
}
|
||||||
return false;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t Adafruit_GPS::write(uint8_t c) {
|
size_t Adafruit_GPS::write(uint8_t c) {
|
||||||
|
|
@ -476,10 +474,6 @@ char Adafruit_GPS::read(void) {
|
||||||
|
|
||||||
//Serial.print(c);
|
//Serial.print(c);
|
||||||
|
|
||||||
// if (c == '$') { //please don't eat the dollar sign - rdl 9/15/14
|
|
||||||
// currentline[lineidx] = 0;
|
|
||||||
// lineidx = 0;
|
|
||||||
// }
|
|
||||||
currentline[lineidx++] = c;
|
currentline[lineidx++] = c;
|
||||||
if (lineidx >= MAXLINELENGTH)
|
if (lineidx >= MAXLINELENGTH)
|
||||||
lineidx = MAXLINELENGTH-1; // ensure there is someplace to put the next received character
|
lineidx = MAXLINELENGTH-1; // ensure there is someplace to put the next received character
|
||||||
|
|
@ -592,7 +586,6 @@ bool Adafruit_GPS::begin(uint32_t baud_or_i2caddr)
|
||||||
} else {
|
} else {
|
||||||
_i2caddr = baud_or_i2caddr;
|
_i2caddr = baud_or_i2caddr;
|
||||||
}
|
}
|
||||||
gpsI2C->setClock(400000);
|
|
||||||
// A basic scanner, see if it ACK's
|
// A basic scanner, see if it ACK's
|
||||||
gpsI2C->beginTransmission(_i2caddr);
|
gpsI2C->beginTransmission(_i2caddr);
|
||||||
return (gpsI2C->endTransmission () == 0);
|
return (gpsI2C->endTransmission () == 0);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
// Test code for Adafruit GPS That Support Using I2C
|
||||||
|
//
|
||||||
|
// This code shows how to test a passthru between USB and I2C
|
||||||
|
//
|
||||||
|
// Pick one up today at the Adafruit electronics shop
|
||||||
|
// and help support open source hardware & software! -ada
|
||||||
|
|
||||||
|
#include <Adafruit_GPS.h>
|
||||||
|
|
||||||
|
// Connect to the GPS on the hardware I2C port
|
||||||
|
Adafruit_GPS GPS(&Wire);
|
||||||
|
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
// wait for hardware serial to appear
|
||||||
|
while (!Serial);
|
||||||
|
|
||||||
|
// make this baud rate fast enough to we aren't waiting on it
|
||||||
|
Serial.begin(115200);
|
||||||
|
|
||||||
|
Serial.println("Adafruit GPS library basic I2C test!");
|
||||||
|
GPS.begin(0x10); // The I2C address to use is 0x10
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
if (Serial.available()) {
|
||||||
|
char c = Serial.read();
|
||||||
|
GPS.write(c);
|
||||||
|
}
|
||||||
|
if (GPS.available()) {
|
||||||
|
char c = GPS.read();
|
||||||
|
Serial.write(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue