|
2 | 2 | Configuring the GNSS to automatically send NAV PVT reports over I2C and log them to file on SD card
|
3 | 3 | By: Paul Clark
|
4 | 4 | SparkFun Electronics
|
5 |
| - Date: December 30th, 2020 |
| 5 | + Date: October 18th, 2021 |
6 | 6 | License: MIT. See license file for more information but you can
|
7 | 7 | basically do whatever you want with this code.
|
8 | 8 |
|
|
22 | 22 | Insert a formatted micro-SD card into the socket on the Carrier Board.
|
23 | 23 | Connect the Carrier Board to your computer using a USB-C cable.
|
24 | 24 | Ensure you have the SparkFun Apollo3 boards installed: http://boardsmanager/All#SparkFun_Apollo3
|
25 |
| - This code has been tested using version 1.2.1 of the Apollo3 boards on Arduino IDE 1.8.13. |
26 |
| - Select "SparkFun Artemis MicroMod" as the board type. |
| 25 | + This code has been tested using version 2.1.0 of the Apollo3 boards on Arduino IDE 1.8.13. |
| 26 | + - Version 2.1.1 of Apollo3 contains a feature which makes I2C communication with u-blox modules problematic |
| 27 | + - We recommend using v2.1.0 of Apollo3 until v2.2.0 is released |
| 28 | + Select "Artemis MicroMod Processor" as the board type. |
27 | 29 | Press upload to upload the code onto the Artemis.
|
28 | 30 | Open the Serial Monitor at 115200 baud to see the output.
|
29 | 31 |
|
@@ -51,7 +53,20 @@ SFE_UBLOX_GNSS myGNSS;
|
51 | 53 |
|
52 | 54 | File myFile; //File that all GNSS data is written to
|
53 | 55 |
|
54 |
| -#define sdChipSelect CS //Primary SPI Chip Select is CS for the MicroMod Artemis Processor. Adjust for your processor if necessary. |
| 56 | +//Define the microSD (SPI) Chip Select pin. Adjust for your processor if necessary. |
| 57 | +#if defined(ARDUINO_ARCH_APOLLO3) // Check for SparkFun Apollo3 (Artemis) v1 or v2 |
| 58 | + #if defined(ARDUINO_APOLLO3_SFE_ARTEMIS_MM_PB) // Check for the Artemis MicroMod Processor Board on Apollo3 v2 |
| 59 | + #define sdChipSelect SPI_CS // SPI (microSD) Chip Select for the Artemis MicroMod Processor Board on Apollo3 v2 |
| 60 | + #elif defined(ARDUINO_AM_AP3_SFE_ARTEMIS_MICROMOD) // Check for the Artemis MicroMod Processor Board on Apollo3 v1 |
| 61 | + #define sdChipSelect CS // SPI (microSD) Chip Select for the Artemis MicroMod Processor Board on Apollo3 v1 |
| 62 | + #else |
| 63 | + #define sdChipSelect CS // Catch-all for the other Artemis Boards - change this if required to match your hardware |
| 64 | + #endif |
| 65 | +#else |
| 66 | + |
| 67 | + #define sdChipSelect CS // Catch-all for all non-Artemis boards - change this if required to match your hardware |
| 68 | + |
| 69 | +#endif |
55 | 70 |
|
56 | 71 | #define packetLength 100 // NAV PVT is 92 + 8 bytes in length (including the sync chars, class, id, length and checksum bytes)
|
57 | 72 |
|
@@ -107,8 +122,20 @@ void setup()
|
107 | 122 |
|
108 | 123 | Wire.begin(); // Start I2C communication with the GNSS
|
109 | 124 |
|
110 |
| -#if defined(AM_PART_APOLLO3) |
111 |
| - Wire.setPullups(0); // On the Artemis, we can disable the internal I2C pull-ups too to help reduce bus errors |
| 125 | +// On the Artemis, we can disable the internal I2C pull-ups too to help reduce bus errors |
| 126 | +#if defined(AM_PART_APOLLO3) // Check for SparkFun Apollo3 (Artemis) v1 |
| 127 | + Wire.setPullups(0); // Disable the internal I2C pull-ups on Apollo3 v1 |
| 128 | +#elif defined(ARDUINO_ARCH_APOLLO3) // Else check for SparkFun Apollo3 (Artemis) (v2) |
| 129 | + #if defined(ARDUINO_APOLLO3_SFE_ARTEMIS_MM_PB) // Check for the Artemis MicroMod Processor Board on Apollo3 v2 |
| 130 | + // On Apollo3 v2 we can still disable the pull-ups but we need to do it manually |
| 131 | + // The IOM and pin numbers here are specific to the Artemis MicroMod Processor Board |
| 132 | + am_hal_gpio_pincfg_t sclPinCfg = g_AM_BSP_GPIO_IOM4_SCL; // Artemis MicroMod Processor Board uses IOM4 for I2C communication |
| 133 | + am_hal_gpio_pincfg_t sdaPinCfg = g_AM_BSP_GPIO_IOM4_SDA; |
| 134 | + sclPinCfg.ePullup = AM_HAL_GPIO_PIN_PULLUP_NONE; // Disable the pull-ups |
| 135 | + sdaPinCfg.ePullup = AM_HAL_GPIO_PIN_PULLUP_NONE; |
| 136 | + pin_config(PinName(39), sclPinCfg); // Artemis MicroMod Processor Board uses Pin/Pad 39 for SCL |
| 137 | + pin_config(PinName(40), sdaPinCfg); // Artemis MicroMod Processor Board uses Pin/Pad 40 for SDA |
| 138 | + #endif |
112 | 139 | #endif
|
113 | 140 |
|
114 | 141 | while (Serial.available()) // Make sure the Serial buffer is empty
|
@@ -199,7 +226,7 @@ void loop()
|
199 | 226 | if (Serial.available()) // Check if the user wants to stop logging
|
200 | 227 | {
|
201 | 228 | myFile.close(); // Close the data file
|
202 |
| - Serial.println(F("Logging stopped. Freezing...")); |
| 229 | + Serial.println(F("\r\nLogging stopped. Freezing...")); |
203 | 230 | while(1); // Do nothing more
|
204 | 231 | }
|
205 | 232 |
|
|
0 commit comments