kopia lustrzana https://github.com/RPiks/pico-hf-oscillator
Beta release with USB terminal.
rodzic
905c937611
commit
cea1a32bcd
|
@ -29,7 +29,6 @@ pico_generate_pio_header(pico-hf-oscillator-test ${CMAKE_CURRENT_LIST_DIR}/piodc
|
|||
|
||||
target_sources(pico-hf-oscillator-test PUBLIC
|
||||
${CMAKE_CURRENT_LIST_DIR}/lib/assert.c
|
||||
# ${CMAKE_CURRENT_LIST_DIR}/lib/thirdparty/strnstr.c
|
||||
${CMAKE_CURRENT_LIST_DIR}/piodco/piodco.c
|
||||
${CMAKE_CURRENT_LIST_DIR}/gpstime/GPStime.c
|
||||
${CMAKE_CURRENT_LIST_DIR}/debug/logutils.c
|
||||
|
@ -41,7 +40,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 1)
|
||||
pico_enable_stdio_uart(pico-hf-oscillator-test 0)
|
||||
pico_enable_stdio_usb(pico-hf-oscillator-test 1)
|
||||
|
||||
# Add the standard include files to the build
|
||||
|
@ -63,6 +62,7 @@ target_link_libraries(
|
|||
hardware_timer
|
||||
hardware_clocks
|
||||
hardware_pio
|
||||
hardware_uart
|
||||
)
|
||||
|
||||
pico_add_extra_outputs(pico-hf-oscillator-test)
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "hardware/uart.h"
|
||||
#include "./lib/assert.h"
|
||||
#include "piodco/piodco.h"
|
||||
#include "protos.h"
|
||||
|
@ -86,6 +87,7 @@ void ConsoleCommandsWrapper(char *cmd, int narg, char *params)
|
|||
printf(" GPSREC OFF/uart_id,pps_pin,baud - enable/disable GPS receiver connection.\n");
|
||||
printf(" example: GPS 0,3,9600 - enable GPS receiver connection with UART0 & PPS on gpio3, 9600 baud port speed.\n");
|
||||
printf(" example: GPS OFF - disable GPS receiver connection.\n");
|
||||
return;
|
||||
} else if(strstr(cmd, "SETFREQ"))
|
||||
{
|
||||
if(2 != narg)
|
||||
|
@ -102,11 +104,13 @@ void ConsoleCommandsWrapper(char *cmd, int narg, char *params)
|
|||
}
|
||||
|
||||
PioDCOSetFreq(&DCO, ui32frq, 0U);
|
||||
printf("\nFrequency is set to %lu Hz", ui32frq);
|
||||
printf("\nFrequency is set to %lu+.000 Hz", ui32frq);
|
||||
return;
|
||||
|
||||
} else if(strstr(cmd, "STATUS"))
|
||||
{
|
||||
PushStatusMessage();
|
||||
return;
|
||||
} else if(strstr(cmd, "SWITCH"))
|
||||
{
|
||||
if(2 != narg)
|
||||
|
@ -118,10 +122,12 @@ void ConsoleCommandsWrapper(char *cmd, int narg, char *params)
|
|||
{
|
||||
PioDCOStart(&DCO);
|
||||
printf("\nOutput is enabled");
|
||||
return;
|
||||
} else if(strstr(params, "OFF"))
|
||||
{
|
||||
PioDCOStop(&DCO);
|
||||
printf("\nOutput is disabled");
|
||||
return;
|
||||
}
|
||||
} else if(strstr(cmd, "GPSREC"))
|
||||
{
|
||||
|
@ -143,6 +149,11 @@ void ConsoleCommandsWrapper(char *cmd, int narg, char *params)
|
|||
const uint32_t ui32pps = atol(p);
|
||||
p += strlen(p) + 1;
|
||||
const uint32_t ui32baud = atol(p);
|
||||
if(DCO._pGPStime)
|
||||
{
|
||||
GPStimeDestroy(&DCO._pGPStime);
|
||||
printf("\nGPS subsystem is disabled.");
|
||||
}
|
||||
GPStimeContext *pGPS = GPStimeInit(ui32uart, ui32baud, ui32pps);
|
||||
assert_(pGPS);
|
||||
DCO._pGPStime = pGPS;
|
||||
|
@ -154,15 +165,21 @@ void ConsoleCommandsWrapper(char *cmd, int narg, char *params)
|
|||
PushErrorMessage(-1);
|
||||
|
||||
return;
|
||||
|
||||
|
||||
} else if(2 == narg)
|
||||
{
|
||||
if(DCO._pGPStime)
|
||||
{
|
||||
GPStimeDestroy(&DCO._pGPStime);
|
||||
printf("\nGPS subsystem is disabled.");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//printf("\ncmd=%s", cmd);
|
||||
PushErrorMessage(-13);
|
||||
}
|
||||
|
||||
void PushErrorMessage(int id)
|
||||
|
@ -181,6 +198,10 @@ void PushErrorMessage(int id)
|
|||
printf("\nInvalid UART id, should be 0 OR 1");
|
||||
break;
|
||||
|
||||
case -13:
|
||||
printf("\nInvalid command");
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("\nUnknown error");
|
||||
break;
|
||||
|
|
|
@ -76,8 +76,8 @@ GPStimeContext *GPStimeInit(int uart_id, int uart_baud, int pps_gpio)
|
|||
|
||||
// Set up our UART with the required speed & assign pins.
|
||||
uart_init(uart_id ? uart1 : uart0, uart_baud);
|
||||
gpio_set_function(uart_id ? 8 : 12, GPIO_FUNC_UART);
|
||||
gpio_set_function(uart_id ? 9 : 13, GPIO_FUNC_UART);
|
||||
gpio_set_function(uart_id ? 8 : 0, GPIO_FUNC_UART);
|
||||
gpio_set_function(uart_id ? 9 : 1, GPIO_FUNC_UART);
|
||||
|
||||
GPStimeContext *pgt = calloc(1, sizeof(GPStimeContext));
|
||||
ASSERT_(pgt);
|
||||
|
@ -105,7 +105,6 @@ GPStimeContext *GPStimeInit(int uart_id, int uart_baud, int pps_gpio)
|
|||
|
||||
/// @brief Deinits the GPS module and destroys allocated resources.
|
||||
/// @param pp Ptr to Ptr of the Context.
|
||||
/// @attention *NOT* implemented completely so far. !FIXME!
|
||||
void GPStimeDestroy(GPStimeContext **pp)
|
||||
{
|
||||
ASSERT_(pp);
|
||||
|
@ -199,6 +198,7 @@ void RAM (GPStimeUartRxIsr)()
|
|||
uart_inst_t *puart_id = spGPStimeContext->_uart_id ? uart1 : uart0;
|
||||
for(;;uart_is_readable(puart_id))
|
||||
{
|
||||
gpio_put(PICO_DEFAULT_LED_PIN, 1);
|
||||
uint8_t chr = uart_getc(puart_id);
|
||||
spGPStimeContext->_pbytebuff[spGPStimeContext->_u8_ixw++] = chr;
|
||||
spGPStimeContext->_is_sentence_ready = ('\n' == chr);
|
||||
|
|
4
test.c
4
test.c
|
@ -305,9 +305,9 @@ void RAM (SpinnerGPSreferenceTest)(void)
|
|||
|
||||
if(0 == ++tick % 6)
|
||||
{
|
||||
stdio_set_driver_enabled(&stdio_uart, false);
|
||||
//stdio_set_driver_enabled(&stdio_uart, false);
|
||||
GPStimeDump(&(pGPS->_time_data));
|
||||
stdio_set_driver_enabled(&stdio_uart, true);
|
||||
//stdio_set_driver_enabled(&stdio_uart, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue