Beta release with USB terminal.

wip-console
roman 2023-12-23 22:54:11 +03:00
rodzic 905c937611
commit cea1a32bcd
4 zmienionych plików z 30 dodań i 9 usunięć

Wyświetl plik

@ -29,7 +29,6 @@ pico_generate_pio_header(pico-hf-oscillator-test ${CMAKE_CURRENT_LIST_DIR}/piodc
target_sources(pico-hf-oscillator-test PUBLIC target_sources(pico-hf-oscillator-test PUBLIC
${CMAKE_CURRENT_LIST_DIR}/lib/assert.c ${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}/piodco/piodco.c
${CMAKE_CURRENT_LIST_DIR}/gpstime/GPStime.c ${CMAKE_CURRENT_LIST_DIR}/gpstime/GPStime.c
${CMAKE_CURRENT_LIST_DIR}/debug/logutils.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_name(pico-hf-oscillator-test "pico-hf-oscillator-test")
pico_set_program_version(pico-hf-oscillator-test "0.9") 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) pico_enable_stdio_usb(pico-hf-oscillator-test 1)
# Add the standard include files to the build # Add the standard include files to the build
@ -63,6 +62,7 @@ target_link_libraries(
hardware_timer hardware_timer
hardware_clocks hardware_clocks
hardware_pio hardware_pio
hardware_uart
) )
pico_add_extra_outputs(pico-hf-oscillator-test) pico_add_extra_outputs(pico-hf-oscillator-test)

Wyświetl plik

@ -47,6 +47,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "hardware/uart.h"
#include "./lib/assert.h" #include "./lib/assert.h"
#include "piodco/piodco.h" #include "piodco/piodco.h"
#include "protos.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(" 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 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"); printf(" example: GPS OFF - disable GPS receiver connection.\n");
return;
} else if(strstr(cmd, "SETFREQ")) } else if(strstr(cmd, "SETFREQ"))
{ {
if(2 != narg) if(2 != narg)
@ -102,11 +104,13 @@ void ConsoleCommandsWrapper(char *cmd, int narg, char *params)
} }
PioDCOSetFreq(&DCO, ui32frq, 0U); 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")) } else if(strstr(cmd, "STATUS"))
{ {
PushStatusMessage(); PushStatusMessage();
return;
} else if(strstr(cmd, "SWITCH")) } else if(strstr(cmd, "SWITCH"))
{ {
if(2 != narg) if(2 != narg)
@ -118,10 +122,12 @@ void ConsoleCommandsWrapper(char *cmd, int narg, char *params)
{ {
PioDCOStart(&DCO); PioDCOStart(&DCO);
printf("\nOutput is enabled"); printf("\nOutput is enabled");
return;
} else if(strstr(params, "OFF")) } else if(strstr(params, "OFF"))
{ {
PioDCOStop(&DCO); PioDCOStop(&DCO);
printf("\nOutput is disabled"); printf("\nOutput is disabled");
return;
} }
} else if(strstr(cmd, "GPSREC")) } else if(strstr(cmd, "GPSREC"))
{ {
@ -143,6 +149,11 @@ void ConsoleCommandsWrapper(char *cmd, int narg, char *params)
const uint32_t ui32pps = atol(p); const uint32_t ui32pps = atol(p);
p += strlen(p) + 1; p += strlen(p) + 1;
const uint32_t ui32baud = atol(p); const uint32_t ui32baud = atol(p);
if(DCO._pGPStime)
{
GPStimeDestroy(&DCO._pGPStime);
printf("\nGPS subsystem is disabled.");
}
GPStimeContext *pGPS = GPStimeInit(ui32uart, ui32baud, ui32pps); GPStimeContext *pGPS = GPStimeInit(ui32uart, ui32baud, ui32pps);
assert_(pGPS); assert_(pGPS);
DCO._pGPStime = pGPS; DCO._pGPStime = pGPS;
@ -160,9 +171,15 @@ void ConsoleCommandsWrapper(char *cmd, int narg, char *params)
if(DCO._pGPStime) if(DCO._pGPStime)
{ {
GPStimeDestroy(&DCO._pGPStime); GPStimeDestroy(&DCO._pGPStime);
printf("\nGPS subsystem is disabled.");
}
return;
} }
} }
}
//printf("\ncmd=%s", cmd);
PushErrorMessage(-13);
} }
void PushErrorMessage(int id) void PushErrorMessage(int id)
@ -181,6 +198,10 @@ void PushErrorMessage(int id)
printf("\nInvalid UART id, should be 0 OR 1"); printf("\nInvalid UART id, should be 0 OR 1");
break; break;
case -13:
printf("\nInvalid command");
break;
default: default:
printf("\nUnknown error"); printf("\nUnknown error");
break; break;

Wyświetl plik

@ -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. // Set up our UART with the required speed & assign pins.
uart_init(uart_id ? uart1 : uart0, uart_baud); uart_init(uart_id ? uart1 : uart0, uart_baud);
gpio_set_function(uart_id ? 8 : 12, GPIO_FUNC_UART); gpio_set_function(uart_id ? 8 : 0, GPIO_FUNC_UART);
gpio_set_function(uart_id ? 9 : 13, GPIO_FUNC_UART); gpio_set_function(uart_id ? 9 : 1, GPIO_FUNC_UART);
GPStimeContext *pgt = calloc(1, sizeof(GPStimeContext)); GPStimeContext *pgt = calloc(1, sizeof(GPStimeContext));
ASSERT_(pgt); 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. /// @brief Deinits the GPS module and destroys allocated resources.
/// @param pp Ptr to Ptr of the Context. /// @param pp Ptr to Ptr of the Context.
/// @attention *NOT* implemented completely so far. !FIXME!
void GPStimeDestroy(GPStimeContext **pp) void GPStimeDestroy(GPStimeContext **pp)
{ {
ASSERT_(pp); ASSERT_(pp);
@ -199,6 +198,7 @@ void RAM (GPStimeUartRxIsr)()
uart_inst_t *puart_id = spGPStimeContext->_uart_id ? uart1 : uart0; uart_inst_t *puart_id = spGPStimeContext->_uart_id ? uart1 : uart0;
for(;;uart_is_readable(puart_id)) for(;;uart_is_readable(puart_id))
{ {
gpio_put(PICO_DEFAULT_LED_PIN, 1);
uint8_t chr = uart_getc(puart_id); uint8_t chr = uart_getc(puart_id);
spGPStimeContext->_pbytebuff[spGPStimeContext->_u8_ixw++] = chr; spGPStimeContext->_pbytebuff[spGPStimeContext->_u8_ixw++] = chr;
spGPStimeContext->_is_sentence_ready = ('\n' == chr); spGPStimeContext->_is_sentence_ready = ('\n' == chr);

4
test.c
Wyświetl plik

@ -305,9 +305,9 @@ void RAM (SpinnerGPSreferenceTest)(void)
if(0 == ++tick % 6) if(0 == ++tick % 6)
{ {
stdio_set_driver_enabled(&stdio_uart, false); //stdio_set_driver_enabled(&stdio_uart, false);
GPStimeDump(&(pGPS->_time_data)); GPStimeDump(&(pGPS->_time_data));
stdio_set_driver_enabled(&stdio_uart, true); //stdio_set_driver_enabled(&stdio_uart, true);
} }
} }
} }