diff options
Diffstat (limited to 'app/gps.c')
-rw-r--r-- | app/gps.c | 33 |
1 files changed, 21 insertions, 12 deletions
@@ -1,8 +1,11 @@ #include "project.h" -#define PPS (GPIO9) +#define PPS (GPIO7) #define PPS_PORT GPIOC +#define NRESET (GPIO8) +#define NRESET_PORT GPIOC + #define UBX_BUF_LEN 256 #define TIMEOUT 4000 @@ -23,27 +26,28 @@ uint64_t gps_last_happy; static char fix, fix2; static int32_t freq = 0; -static const int fish[] = { 1, 2, 3, 4, 5, 6, 7 }; +//static const int fish[] = { 1, 2, 3, 4, 5, 6, 7 }; static Event_ring gps_ring; static char gps_info[60]; - void exti9_5_isr (void) { - uint32_t now = SCS_DWT_CYCCNT; + uint32_t now = HW_CLOCK_REG; int v; v = !!gpio_get (PPS_PORT, PPS); nvic_disable_irq (NVIC_EXTI9_5_IRQ); - exti_reset_request (EXTI9); + exti_reset_request (EXTI7); gps_ring.events[gps_ring.tx_ptr].when = now; gps_ring.events[gps_ring.tx_ptr].value = v; gps_ring.tx_ptr = (gps_ring.tx_ptr + 1) & ERING_MASK; + if (v) sysclk_event(); + nvic_enable_irq (NVIC_EXTI9_5_IRQ); } @@ -270,7 +274,7 @@ ubx_recv_utc (uint8_t *ptr, unsigned len) next_sec = gps_time; - now = SCS_DWT_CYCCNT; + now = HW_CLOCK_REG; abs = abs_extend (now); gps_last_happy = make_happy (abs, 180); @@ -578,7 +582,7 @@ static void gps_pps_dispatch (void) uint32_t now; uint64_t abs; int v; - EPOCH e; + //EPOCH e; //UTC u; if (gps_ring.rx_ptr == gps_ring.tx_ptr) return; @@ -601,7 +605,7 @@ static void gps_pps_dispatch (void) if (gps_happy > 30) pll_dispatch (gps_last_happy, abs, "GPS"); - e = pll_decompose (abs); + //e = pll_decompose (abs); //u = time_epoch_to_utc (e); @@ -957,12 +961,17 @@ gps_init (void) // printf ("GPS ready\r\n"); // ubx_get_clock_stats(); + // + + + SET (NRESET); MAP_INPUT (PPS); + MAP_OUTPUT_PP (NRESET); - exti_select_source (EXTI9, PPS_PORT); - exti_set_trigger (EXTI9, EXTI_TRIGGER_BOTH); - exti_enable_request (EXTI9); + exti_select_source (EXTI7, PPS_PORT); + exti_set_trigger (EXTI7, EXTI_TRIGGER_BOTH); + exti_enable_request (EXTI7); nvic_enable_irq (NVIC_EXTI9_5_IRQ); return 0; @@ -1009,7 +1018,7 @@ void gps_dump_almanac (void) #if 1 int gps_bs (void) { - uint32_t now = SCS_DWT_CYCCNT; + uint32_t now = HW_CLOCK_REG; uint64_t abs = abs_extend (now); EPOCH e = pll_decompose (abs); UTC u = time_epoch_to_utc (e); |