Add a fix to allow the auto-NMEA examples to compile on ATmega2560/1280

This commit is contained in:
PaulZC
2022-03-03 10:22:54 +00:00
parent 9b6369e943
commit fa07e84ff0
9 changed files with 42 additions and 22 deletions
+7 -7
View File
@@ -422,7 +422,7 @@ void SFE_UBLOX_GNSS::end(void)
packetUBXHNRPVT = NULL; // Redundant?
}
#ifndef SFE_UBLOX_REDUCED_PROG_MEM
#ifndef SFE_UBLOX_DISABLE_AUTO_NMEA
if (storageNMEAGPGGA != NULL)
{
if (storageNMEAGPGGA->callbackCopy != NULL)
@@ -1863,7 +1863,7 @@ void SFE_UBLOX_GNSS::process(uint8_t incoming, ubxPacket *incomingUBX, uint8_t r
_signsOfLife = isNMEAHeaderValid();
}
#ifndef SFE_UBLOX_REDUCED_PROG_MEM
#ifndef SFE_UBLOX_DISABLE_AUTO_NMEA
// Check if we have automatic storage for this message
if (isThisNMEAauto())
{
@@ -1902,7 +1902,7 @@ void SFE_UBLOX_GNSS::process(uint8_t incoming, ubxPacket *incomingUBX, uint8_t r
if ((nmeaByteCounter > 5) || (nmeaByteCounter < 0)) // Should we add incoming to the file buffer and/or pass it to processNMEA?
{
#ifndef SFE_UBLOX_REDUCED_PROG_MEM
#ifndef SFE_UBLOX_DISABLE_AUTO_NMEA
if (isThisNMEAauto())
{
uint8_t *lengthPtr = getNMEAWorkingLengthPtr(); // Get a pointer to the working copy length
@@ -1938,7 +1938,7 @@ void SFE_UBLOX_GNSS::process(uint8_t incoming, ubxPacket *incomingUBX, uint8_t r
if (nmeaByteCounter == 0) // Check if we are done
{
#ifndef SFE_UBLOX_REDUCED_PROG_MEM
#ifndef SFE_UBLOX_DISABLE_AUTO_NMEA
if (isThisNMEAauto())
{
uint8_t *workingLengthPtr = getNMEAWorkingLengthPtr(); // Get a pointer to the working copy length
@@ -2194,7 +2194,7 @@ void SFE_UBLOX_GNSS::processNMEA(char incoming)
_nmeaOutputPort->write(incoming); // Echo this byte to the serial port
}
#ifndef SFE_UBLOX_REDUCED_PROG_MEM
#ifndef SFE_UBLOX_DISABLE_AUTO_NMEA
// Check if the NMEA message (in nmeaAddressField) is "auto" (i.e. has RAM allocated for it)
bool SFE_UBLOX_GNSS::isThisNMEAauto()
{
@@ -5568,7 +5568,7 @@ void SFE_UBLOX_GNSS::checkCallbacks(void)
packetUBXHNRPVT->automaticFlags.flags.bits.callbackCopyValid = false; // Mark the data as stale
}
#ifndef SFE_UBLOX_REDUCED_PROG_MEM
#ifndef SFE_UBLOX_DISABLE_AUTO_NMEA
if ((storageNMEAGPGGA != NULL) // If RAM has been allocated for message storage
&& (storageNMEAGPGGA->callbackCopy != NULL) // If RAM has been allocated for the copy of the data
&& (storageNMEAGPGGA->automaticFlags.flags.bits.callbackCopyValid == 1)) // If the copy of the data is valid
@@ -14818,7 +14818,7 @@ uint32_t SFE_UBLOX_GNSS::getProcessNMEAMask()
return (_processNMEA.all);
}
#ifndef SFE_UBLOX_REDUCED_PROG_MEM
#ifndef SFE_UBLOX_DISABLE_AUTO_NMEA
// Initiate automatic storage of NMEA GPGGA messages
// Get the most recent GPGGA message
+13 -6
View File
@@ -57,12 +57,19 @@
#include "u-blox_structs.h"
// Uncomment the next line (or add SFE_UBLOX_REDUCED_PROG_MEM as a compiler directive) to reduce the amount of program memory used by the library
//#define SFE_UBLOX_REDUCED_PROG_MEM // Uncommenting this line will delete the minor debug messages and disable auto-NMEA support to save memory
//#define SFE_UBLOX_REDUCED_PROG_MEM // Uncommenting this line will delete the minor debug messages to save memory
// The code just about fills the program memory on the ATmega328P (Arduino Uno), so let's delete the minor debug messages and disable auto-NMEA support anyway
#if !defined(SFE_UBLOX_REDUCED_PROG_MEM) && defined(ARDUINO_ARCH_AVR)
// Uncomment the next line (or add SFE_UBLOX_DISABLE_AUTO_NMEA as a compiler directive) to reduce the amount of program memory used by the library
//#define SFE_UBLOX_DISABLE_AUTO_NMEA // Uncommenting this line will disable auto-NMEA support to save memory
// The code exceeds the program memory on the ATmega328P (Arduino Uno), so let's delete the minor debug messages and disable auto-NMEA support anyway
// However, the ATmega2560 and ATmega1280 _do_ have enough memory, so let's exclude those
#if !defined(SFE_UBLOX_REDUCED_PROG_MEM) && defined(ARDUINO_ARCH_AVR) && !defined(ARDUINO_AVR_MEGA2560) && !defined(ARDUINO_AVR_MEGA) && !defined(ARDUINO_AVR_ADK)
#define SFE_UBLOX_REDUCED_PROG_MEM
#endif
#if !defined(SFE_UBLOX_DISABLE_AUTO_NMEA) && defined(ARDUINO_ARCH_AVR) && !defined(ARDUINO_AVR_MEGA2560) && !defined(ARDUINO_AVR_MEGA) && !defined(ARDUINO_AVR_ADK)
#define SFE_UBLOX_DISABLE_AUTO_NMEA
#endif
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
@@ -1431,7 +1438,7 @@ public:
void setProcessNMEAMask(uint32_t messages = SFE_UBLOX_FILTER_NMEA_ALL); // Control which NMEA messages are passed to processNMEA. Default to passing ALL messages
uint32_t getProcessNMEAMask(); // Return which NMEA messages are passed to processNMEA
#ifndef SFE_UBLOX_REDUCED_PROG_MEM
#ifndef SFE_UBLOX_DISABLE_AUTO_NMEA
// Support for "auto" storage of NMEA messages
uint8_t getLatestNMEAGPGGA(NMEA_GGA_data_t *data); // Return the most recent GPGGA: 0 = no data, 1 = stale data, 2 = fresh data
bool setNMEAGPGGAcallback(void (*callbackPointer)(NMEA_GGA_data_t)); // Enable a callback on the arrival of a GPGGA message
@@ -1513,7 +1520,7 @@ public:
UBX_MGA_ACK_DATA0_t *packetUBXMGAACK = NULL; // Pointer to struct. RAM will be allocated for this if/when necessary
UBX_MGA_DBD_t *packetUBXMGADBD = NULL; // Pointer to struct. RAM will be allocated for this if/when necessary
#ifndef SFE_UBLOX_REDUCED_PROG_MEM
#ifndef SFE_UBLOX_DISABLE_AUTO_NMEA
NMEA_GPGGA_t *storageNMEAGPGGA = NULL; // Pointer to struct. RAM will be allocated for this if/when necessary
NMEA_GNGGA_t *storageNMEAGNGGA = NULL; // Pointer to struct. RAM will be allocated for this if/when necessary
NMEA_GPVTG_t *storageNMEAGPVTG = NULL; // Pointer to struct. RAM will be allocated for this if/when necessary
@@ -1606,7 +1613,7 @@ private:
bool initPacketUBXMGAACK(); // Allocate RAM for packetUBXMGAACK and initialize it
bool initPacketUBXMGADBD(); // Allocate RAM for packetUBXMGADBD and initialize it
#ifndef SFE_UBLOX_REDUCED_PROG_MEM
#ifndef SFE_UBLOX_DISABLE_AUTO_NMEA
bool initStorageNMEAGPGGA(); // Allocate RAM for incoming NMEA GPGGA messages and initialize it
bool initStorageNMEAGNGGA(); // Allocate RAM for incoming NMEA GNGGA messages and initialize it
bool initStorageNMEAGPVTG(); // Allocate RAM for incoming NMEA GPVTG messages and initialize it