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
9
- This example shows how to query a u-blox module for its UART1 settings and
9
+ This example shows how to query a Ublox module for its UART1 settings and
10
10
then change them if the settings aren't what we want.
11
11
12
12
Note: getVal/setVal/delVal are only support in u-blox protocol versions 27 and higher.
@@ -33,17 +33,19 @@ void setup()
33
33
Serial.begin (115200 );
34
34
while (!Serial)
35
35
; // Wait for user to open terminal
36
- Serial.println (" SparkFun u-blox Example" );
36
+ Serial.println (" SparkFun Ublox Example" );
37
37
38
38
Wire.begin ();
39
39
40
40
if (myGPS.begin () == false ) // Connect to the Ublox module using Wire port
41
41
{
42
- Serial.println (F (" u-blox GPS not detected at default I2C address. Please check wiring. Freezing." ));
42
+ Serial.println (F (" Ublox GPS not detected at default I2C address. Please check wiring. Freezing." ));
43
43
while (1 )
44
44
;
45
45
}
46
46
47
+ bool response = true ;
48
+
47
49
// Read the settings from RAM (what the module is running right now, not BBR, Flash, or default)
48
50
uint8_t currentUART1Setting_ubx = myGPS.getVal8 (UBLOX_CFG_UART1INPROT_UBX);
49
51
uint8_t currentUART1Setting_nmea = myGPS.getVal8 (UBLOX_CFG_UART1INPROT_NMEA);
@@ -62,7 +64,6 @@ void setup()
62
64
Serial.println (" Updating UART1 configuration" );
63
65
64
66
// setVal sets the values for RAM, BBR, and Flash automatically so no .saveConfiguration() is needed
65
- bool response = true ;
66
67
response &= myGPS.setVal8 (UBLOX_CFG_UART1INPROT_UBX, 1 ); // Enable UBX on UART1 Input
67
68
response &= myGPS.setVal8 (UBLOX_CFG_UART1INPROT_NMEA, 1 ); // Enable NMEA on UART1 Input
68
69
response &= myGPS.setVal8 (UBLOX_CFG_UART1INPROT_RTCM3X, 0 ); // Disable RTCM on UART1 Input
@@ -73,7 +74,23 @@ void setup()
73
74
Serial.println (" SetVal succeeded" );
74
75
}
75
76
else
76
- Serial.println (" Nothing to change" );
77
+ Serial.println (" No port change needed" );
78
+
79
+ // Change speed of UART2
80
+ uint32_t currentUART2Baud = myGPS.getVal32 (UBLOX_CFG_UART2_BAUDRATE);
81
+ Serial.print (" currentUART2Baud: " );
82
+ Serial.println (currentUART2Baud);
83
+
84
+ if (currentUART2Baud != 57600 )
85
+ {
86
+ response &= myGPS.setVal32 (UBLOX_CFG_UART2_BAUDRATE, 57600 );
87
+ if (response == false )
88
+ Serial.println (" SetVal failed" );
89
+ else
90
+ Serial.println (" SetVal succeeded" );
91
+ }
92
+ else
93
+ Serial.println (" No baud change needed" );
77
94
78
95
Serial.println (" Done" );
79
96
}
0 commit comments