@@ -88,10 +88,7 @@ void newRAWX(UBX_RXM_RAWX_data_t *ubxDataStruct)
88
88
89
89
void setup ()
90
90
{
91
- delay (1000 );
92
-
93
91
Serial.begin (115200 );
94
- Serial.println (F (" SparkFun OpenLog ESP32 GNSS Logging : SPI and SDIO" ));
95
92
96
93
pinMode (STAT_LED, OUTPUT); // Flash the STAT LED each time we write to the SD card
97
94
digitalWrite (STAT_LED, LOW);
@@ -103,15 +100,20 @@ void setup()
103
100
pinMode (MAG_CS, OUTPUT);
104
101
digitalWrite (MAG_CS, HIGH);
105
102
103
+ spiPort.begin ();
104
+
105
+ // Do a fake transaction to initialize the SPI pins
106
+ spiPort.beginTransaction (SPISettings (4000000 , MSBFIRST, SPI_MODE0));
107
+ spiPort.endTransaction ();
108
+
106
109
pinMode (EN_3V3_SW, OUTPUT); // Enable power for the microSD card and GNSS
107
110
digitalWrite (EN_3V3_SW, HIGH);
108
111
109
- delay (1000 ); // Allow time for the SD card to start up
110
-
111
- spiPort.begin ();
112
+ delay (3000 ); // Allow time for the GNSS and SD card to start up and for Tera Term to reconnect
113
+ Serial.println (F (" SparkFun OpenLog ESP32 GNSS Logging : SPI and SDIO" ));
112
114
113
115
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
114
- // Initialize the GNSS. Wait for a 3D fix. Get the date and time for the log file
116
+ // Initialize the GNSS
115
117
116
118
Serial.println (F (" Initializing the GNSS..." ));
117
119
@@ -127,12 +129,15 @@ void setup()
127
129
begun = myGNSS.begin (spiPort, GNSS_CS, 4000000 );
128
130
if (!begun)
129
131
{
130
- Serial.println (F (" u-blox GNSS not detected on SPI bus. Please check wiring. " ));
132
+ Serial.println (F (" u-blox GNSS not detected on SPI bus." ));
131
133
delay (1000 );
132
134
}
133
135
}
134
136
while (!begun);
135
137
138
+ // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
139
+ // Wait for a 3D fix. Get the date and time for the log file
140
+
136
141
// myGNSS.factoryDefault(); delay(5000); // Uncomment this line to reset the module back to its factory defaults
137
142
138
143
myGNSS.setSPIOutput (COM_TYPE_UBX | COM_TYPE_NMEA); // Set the SPI port to output both UBX and NMEA messages
0 commit comments