@@ -88,10 +88,7 @@ void newRAWX(UBX_RXM_RAWX_data_t *ubxDataStruct)
8888
8989void setup ()
9090{
91- delay (1000 );
92-
9391 Serial.begin (115200 );
94- Serial.println (F (" SparkFun OpenLog ESP32 GNSS Logging : SPI and SDIO" ));
9592
9693 pinMode (STAT_LED, OUTPUT); // Flash the STAT LED each time we write to the SD card
9794 digitalWrite (STAT_LED, LOW);
@@ -103,15 +100,20 @@ void setup()
103100 pinMode (MAG_CS, OUTPUT);
104101 digitalWrite (MAG_CS, HIGH);
105102
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+
106109 pinMode (EN_3V3_SW, OUTPUT); // Enable power for the microSD card and GNSS
107110 digitalWrite (EN_3V3_SW, HIGH);
108111
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" ));
112114
113115 // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
114- // Initialize the GNSS. Wait for a 3D fix. Get the date and time for the log file
116+ // Initialize the GNSS
115117
116118 Serial.println (F (" Initializing the GNSS..." ));
117119
@@ -127,12 +129,15 @@ void setup()
127129 begun = myGNSS.begin (spiPort, GNSS_CS, 4000000 );
128130 if (!begun)
129131 {
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." ));
131133 delay (1000 );
132134 }
133135 }
134136 while (!begun);
135137
138+ // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
139+ // Wait for a 3D fix. Get the date and time for the log file
140+
136141 // myGNSS.factoryDefault(); delay(5000); // Uncomment this line to reset the module back to its factory defaults
137142
138143 myGNSS.setSPIOutput (COM_TYPE_UBX | COM_TYPE_NMEA); // Set the SPI port to output both UBX and NMEA messages
0 commit comments