Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for UNO R4 WIFI software serial #151

Merged
merged 3 commits into from
Aug 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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