From ca62cc4ab0e6e7708708c74d96fa37760ef3b4d8 Mon Sep 17 00:00:00 2001 From: roman Date: Sun, 26 Nov 2023 23:38:09 +0300 Subject: [PATCH] GPS reference test works. --- CMakeLists.txt | 4 +++- gpstime/GPStime.c | 7 +++++-- test.c | 26 +++++++------------------- 3 files changed, 15 insertions(+), 22 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d4534ec..e5e6686 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,7 +39,7 @@ target_sources(pico-hf-oscillator-test PUBLIC pico_set_program_name(pico-hf-oscillator-test "pico-hf-oscillator-test") pico_set_program_version(pico-hf-oscillator-test "0.9") -pico_enable_stdio_uart(pico-hf-oscillator-test 0) +pico_enable_stdio_uart(pico-hf-oscillator-test 1) pico_enable_stdio_usb(pico-hf-oscillator-test 1) # Add the standard include files to the build @@ -49,6 +49,8 @@ target_include_directories(pico-hf-oscillator-test PRIVATE ${CMAKE_CURRENT_LIST_DIR}/.. ) +add_compile_options(-Wall) + # Add any user requested libraries target_link_libraries( pico-hf-oscillator-test diff --git a/gpstime/GPStime.c b/gpstime/GPStime.c index adbdde7..8e452e2 100644 --- a/gpstime/GPStime.c +++ b/gpstime/GPStime.c @@ -93,6 +93,9 @@ GPStimeContext *GPStimeInit(int uart_id, int uart_baud, int pps_gpio) gpio_set_dir(pps_gpio, GPIO_IN); gpio_set_irq_enabled_with_callback(pps_gpio, GPIO_IRQ_EDGE_RISE, true, &GPStimePPScallback); + uart_set_hw_flow(uart_id ? uart1 : uart0, false, false); + uart_set_format(uart_id ? uart1 : uart0, 8, 1, UART_PARITY_NONE); + uart_set_fifo_enabled(uart_id ? uart1 : uart0, false); irq_set_exclusive_handler(uart_id ? UART1_IRQ : UART0_IRQ, GPStimeUartRxIsr); irq_set_enabled(uart_id ? UART1_IRQ : UART0_IRQ, true); uart_set_irq_enables(uart_id ? uart1 : uart0, true, false); @@ -221,6 +224,8 @@ int GPStimeProcNMEAsentence(GPStimeContext *pg) uint8_t *prmc = (uint8_t *)strnstr((char *)pg->_pbytebuff, "$GPRMC,", sizeof(pg->_pbytebuff)); if(prmc) { + ++pg->_time_data._u32_nmea_gprmc_count; + uint64_t tm_fix = GetUptime64(); uint8_t u8ixcollector[16] = {0}; uint8_t chksum = 0; @@ -273,8 +278,6 @@ int GPStimeProcNMEAsentence(GPStimeContext *pg) pg->_time_data._u32_utime_nmea_last = GPStime2UNIX(prmc + u8ixcollector[8], prmc + u8ixcollector[0]); pg->_time_data._u64_sysclk_nmea_last = tm_fix; } - - ++pg->_time_data._u32_nmea_gprmc_count; } return 0; diff --git a/test.c b/test.c index ce51378..e79bd71 100644 --- a/test.c +++ b/test.c @@ -234,20 +234,20 @@ void RAM (SpinnerGPSreferenceTest)(void) /* LED signal */ gpio_put(PICO_DEFAULT_LED_PIN, 1); - sleep_ms(500); + sleep_ms(2500); i32_compensation_millis = PioDCOGetFreqShiftMilliHertz(&DCO, (uint64_t)(ku32_freq * 1000LL)); - StampPrintf("GPS solution status: %s | GPS-based freq compensation: %ld milliHz", - pGPS->_time_data._u8_is_solution_active ? "Active" : "No solution", - i32_compensation_millis); - gpio_put(PICO_DEFAULT_LED_PIN, 0); - sleep_ms(500); + sleep_ms(2500); - if(0 == ++tick % 30) + if(0 == ++tick % 6) + { + stdio_set_driver_enabled(&stdio_uart, false); GPStimeDump(&(pGPS->_time_data)); + stdio_set_driver_enabled(&stdio_uart, true); + } } } @@ -260,18 +260,6 @@ int main() sleep_ms(1000); printf("Start\n"); -/* - for(;;) - { - char ch = uart_getc(uart0); - if(ch) - { - stdio_set_driver_enabled(&stdio_uart, false); - printf("%c", ch); - stdio_set_driver_enabled(&stdio_uart, true); - } - } -*/ gpio_init(PICO_DEFAULT_LED_PIN); gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);