File tree Expand file tree Collapse file tree 1 file changed +34
-2
lines changed Expand file tree Collapse file tree 1 file changed +34
-2
lines changed Original file line number Diff line number Diff line change 66#include <string.h>
77#include <stdbool.h>
88
9-
9+ // uart id and tx/rx pins could vary according to the microcontroller used
10+ // please refer to the datasheet
1011#define UART_ID uart1
1112#define BAUD_RATE 9600
1213#define UART_TX_PIN 4
@@ -156,4 +157,35 @@ void process_gps_data(GPSData *gps_data)
156157 chars_read ++ ;
157158 }
158159 }
159- }
160+ }
161+
162+ int main ()
163+ {
164+ stdio_init_all ();
165+
166+ uart_gps_init ();
167+
168+ // recommended cold start waiting time (could vary based on the gps module)
169+ sleep_ms (7 * 60 * 1000 );
170+
171+ GPSData gps_data = {0 };
172+
173+ while (1 )
174+ {
175+ process_gps_data (& gps_data );
176+
177+ if (gps_data .is_valid )
178+ {
179+ printf ("GPS Location:\n" );
180+ printf ("Latitude: %.6f\n" , gps_data .latitude );
181+ printf ("Longitude: %.6f\n" , gps_data .longitude );
182+ gps_data .is_valid = false;
183+ }
184+
185+ // sufficient waiting time required between each gps reading and the next one
186+ sleep_ms (30 * 1000 );
187+ tight_loop_contents ();
188+ }
189+
190+ return 0 ;
191+ }
You can’t perform that action at this time.
0 commit comments