memcpy(pos, &gps_pos, sizeof(*pos));
}
-int gps_loop(void)
+int gps_log(void)
{
uint32_t ms;
uint8_t flags, prio;
char buf[128];
struct gps_pos pos;
- while (1) {
-
- IRQ_LOCK(flags);
- ms = global_ms;
- IRQ_UNLOCK(flags);
-
- /* get position (prevent modification of gps pos during copy) */
- prio = callout_mgr_set_prio(&imuboard.intr_cm, GPS_PRIO);
- gps_get_pos(&pos);
- callout_mgr_restore_prio(&imuboard.intr_cm, prio);
-
- /* XXX copy */
- len = snprintf(buf, sizeof(buf),
- "%"PRIu32" "
- "svnum %.2X lat %3.5f long %3.5f "
- "alt %3.5f sea_alt %3.5f\n",
- ms, gps_pos.sv_num,
- (double)gps_pos.latitude/10000000.,
- (double)gps_pos.longitude/10000000.,
- (double)gps_pos.altitude/100.,
- (double)gps_pos.sea_altitude/100.);
-
-
- if (sd_log_enabled()) {
-
- if (sd_log_write(buf, len) != len) {
- printf_P(PSTR("error writing to file\n"));
- return -1;
- }
+ IRQ_LOCK(flags);
+ ms = global_ms;
+ IRQ_UNLOCK(flags);
+
+ /* get position (prevent modification of gps pos during copy) */
+ prio = callout_mgr_set_prio(&imuboard.intr_cm, GPS_PRIO);
+ gps_get_pos(&pos);
+ callout_mgr_restore_prio(&imuboard.intr_cm, prio);
+
+ /* XXX copy */
+ len = snprintf(buf, sizeof(buf),
+ "%"PRIu32" "
+ "svnum %.2X lat %3.5f long %3.5f "
+ "alt %3.5f sea_alt %3.5f\n",
+ ms, gps_pos.sv_num,
+ (double)gps_pos.latitude / 10000000.,
+ (double)gps_pos.longitude / 10000000.,
+ (double)gps_pos.altitude / 100.,
+ (double)gps_pos.sea_altitude / 100.);
+
+
+ if (sd_log_enabled()) {
+ if (sd_log_write(buf, len) != len) {
+ printf_P(PSTR("error writing to file\n"));
+ return -1;
}
- else
- printf_P(PSTR("%s"), buf);
-
+ }
+ else {
+ printf_P(PSTR("%s"), buf);
}
return 0;