From: Olivier Matz Date: Tue, 9 Sep 2014 17:03:35 +0000 (+0200) Subject: change gps_loop -> gps_log X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=ec4c8344d2a20a04c284adedebfa308249612077;p=fpv.git change gps_loop -> gps_log --- diff --git a/imuboard/gps_venus.c b/imuboard/gps_venus.c index 7470858..bd9a774 100644 --- a/imuboard/gps_venus.c +++ b/imuboard/gps_venus.c @@ -560,7 +560,7 @@ void gps_get_pos(struct gps_pos *pos) memcpy(pos, &gps_pos, sizeof(*pos)); } -int gps_loop(void) +int gps_log(void) { uint32_t ms; uint8_t flags, prio; @@ -568,39 +568,35 @@ int gps_loop(void) 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; diff --git a/imuboard/gps_venus.h b/imuboard/gps_venus.h index ca2bd8f..7970088 100644 --- a/imuboard/gps_venus.h +++ b/imuboard/gps_venus.h @@ -38,7 +38,7 @@ struct gps_pos { } __attribute__ ((packed)); int gps_venus_init(void); -int gps_loop(void); +int gps_log(void); /* does not lock intr, must be done by user */ void gps_get_pos(struct gps_pos *pos); diff --git a/imuboard/main.c b/imuboard/main.c index 386528b..bee118f 100644 --- a/imuboard/main.c +++ b/imuboard/main.c @@ -184,11 +184,13 @@ int main(void) //sd_main(); imu_init(); - //imu_loop(); gps_venus_init(); - gps_loop(); + + imuboard.flags |= IMUBOARD_F_BOOT_OK; while (1) { + //imu_log(); + //gps_log(); cmdline_poll(); }