Skip to content

Commit

Permalink
Merge pull request #151 from hobobandy/master
Browse files Browse the repository at this point in the history
Add support for UNO R4 WIFI software serial
  • Loading branch information
ladyada authored Aug 20, 2023
2 parents 3f09116 + ee7dd9c commit 0db82b2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
18 changes: 12 additions & 6 deletions src/Adafruit_GPS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ static bool strStartsWith(const char *str, const char *prefix);
*/
/**************************************************************************/
bool Adafruit_GPS::begin(uint32_t baud_or_i2caddr) {
#if (defined(__AVR__) || defined(ESP8266)) && defined(USE_SW_SERIAL)
#if (defined(__AVR__) || ((defined(ARDUINO_UNOR4_WIFI) || defined(ESP8266)) && \
!defined(NO_SW_SERIAL)))
if (gpsSwSerial) {
gpsSwSerial->begin(baud_or_i2caddr);
}
Expand Down Expand Up @@ -78,7 +79,8 @@ bool Adafruit_GPS::begin(uint32_t baud_or_i2caddr) {
@param ser Pointer to SoftwareSerial device
*/
/**************************************************************************/
#if (defined(__AVR__) || defined(ESP8266)) && defined(USE_SW_SERIAL)
#if (defined(__AVR__) || ((defined(ARDUINO_UNOR4_WIFI) || defined(ESP8266)) && \
!defined(NO_SW_SERIAL)))
Adafruit_GPS::Adafruit_GPS(SoftwareSerial *ser) {
common_init(); // Set everything to common state, then...
gpsSwSerial = ser; // ...override gpsSwSerial with value passed.
Expand Down Expand Up @@ -147,7 +149,8 @@ Adafruit_GPS::Adafruit_GPS() {
*/
/**************************************************************************/
void Adafruit_GPS::common_init(void) {
#if (defined(__AVR__) || defined(ESP8266)) && defined(USE_SW_SERIAL)
#if (defined(__AVR__) || ((defined(ARDUINO_UNOR4_WIFI) || defined(ESP8266)) && \
!defined(NO_SW_SERIAL)))
gpsSwSerial = NULL; // Set both to NULL, then override correct
#endif
gpsHwSerial = NULL; // port pointer in corresponding constructor
Expand Down Expand Up @@ -196,7 +199,8 @@ size_t Adafruit_GPS::available(void) {
if (paused)
return 0;

#if (defined(__AVR__) || defined(ESP8266)) && defined(USE_SW_SERIAL)
#if (defined(__AVR__) || ((defined(ARDUINO_UNOR4_WIFI) || defined(ESP8266)) && \
!defined(NO_SW_SERIAL)))
if (gpsSwSerial) {
return gpsSwSerial->available();
}
Expand All @@ -223,7 +227,8 @@ size_t Adafruit_GPS::available(void) {
*/
/**************************************************************************/
size_t Adafruit_GPS::write(uint8_t c) {
#if (defined(__AVR__) || defined(ESP8266)) && defined(USE_SW_SERIAL)
#if (defined(__AVR__) || ((defined(ARDUINO_UNOR4_WIFI) || defined(ESP8266)) && \
!defined(NO_SW_SERIAL)))
if (gpsSwSerial) {
return gpsSwSerial->write(c);
}
Expand Down Expand Up @@ -279,7 +284,8 @@ char Adafruit_GPS::read(void) {
if (paused || noComms)
return c;

#if (defined(__AVR__) || defined(ESP8266)) && defined(USE_SW_SERIAL)
#if (defined(__AVR__) || ((defined(ARDUINO_UNOR4_WIFI) || defined(ESP8266)) && \
!defined(NO_SW_SERIAL)))
if (gpsSwSerial) {
if (!gpsSwSerial->available())
return c;
Expand Down
3 changes: 2 additions & 1 deletion src/Adafruit_GPS.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
#endif
#endif

#if (defined(__AVR__) || defined(ESP8266)) && !defined(NO_SW_SERIAL)
#if (defined(__AVR__) || ((defined(ARDUINO_UNOR4_WIFI) || defined(ESP8266)) && \
!defined(NO_SW_SERIAL)))
#define USE_SW_SERIAL ///< insert line `#define NO_SW_SERIAL` before this header
///< if you don't want to include software serial in the
#endif ///< library
Expand Down

0 comments on commit 0db82b2

Please sign in to comment.