From b4c8d47536a125d4a8068f553adadb6c53d0d751 Mon Sep 17 00:00:00 2001 From: Tomi Fontanilles Date: Mon, 22 Apr 2024 16:56:46 +0300 Subject: [PATCH] drivers: gnss: nmea_generic: some fixes/improvements - Configure a UART TX buffer; the backend would otherwise assert in its configuration or (if the asserts are off) miserably fail when trying to send anything to the GNSS modem. - Fine tune the UART RX buffer size and make it depend on whether satellite data is received. - Remove unused k_spinlock. - Make declaration of Kconfig items dependent on GNSS_NMEA_GENERIC conditional. Signed-off-by: Tomi Fontanilles --- drivers/gnss/Kconfig.generic | 4 ++++ drivers/gnss/gnss_nmea_generic.c | 12 ++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/gnss/Kconfig.generic b/drivers/gnss/Kconfig.generic index 47fbd4a7c6..bbcae309a3 100644 --- a/drivers/gnss/Kconfig.generic +++ b/drivers/gnss/Kconfig.generic @@ -15,6 +15,8 @@ config GNSS_NMEA_GENERIC help Generic NMEA based GNSS device. +if GNSS_NMEA_GENERIC + config GNSS_NMEA_GENERIC_SATELLITES_COUNT int "Maximum satellite count" depends on GNSS_SATELLITES @@ -24,3 +26,5 @@ config GNSS_NMEA_GENERIC_SATELLITES_COUNT the GNSS device. This does not affect the number of devices that the device is actually tracking, just how many of those can be reported in the satellites callback. + +endif diff --git a/drivers/gnss/gnss_nmea_generic.c b/drivers/gnss/gnss_nmea_generic.c index a50b5b4cae..2c92ce480b 100644 --- a/drivers/gnss/gnss_nmea_generic.c +++ b/drivers/gnss/gnss_nmea_generic.c @@ -22,9 +22,8 @@ #include LOG_MODULE_REGISTER(gnss_nmea_generic, CONFIG_GNSS_LOG_LEVEL); -#define DT_DRV_COMPAT gnss_nmea_generic - -#define UART_RECV_BUF_SZ 128 +#define UART_RX_BUF_SZ (256 + IS_ENABLED(CONFIG_GNSS_SATELLITES) * 512) +#define UART_TX_BUF_SZ 64 #define CHAT_RECV_BUF_SZ 256 #define CHAT_ARGV_SZ 32 @@ -42,14 +41,13 @@ struct gnss_nmea_generic_data { /* UART backend */ struct modem_pipe *uart_pipe; struct modem_backend_uart uart_backend; - uint8_t uart_backend_receive_buf[UART_RECV_BUF_SZ]; + uint8_t uart_backend_receive_buf[UART_RX_BUF_SZ]; + uint8_t uart_backend_transmit_buf[UART_TX_BUF_SZ]; /* Modem chat */ struct modem_chat chat; uint8_t chat_receive_buf[CHAT_RECV_BUF_SZ]; uint8_t *chat_argv[CHAT_ARGV_SZ]; - - struct k_spinlock lock; }; MODEM_CHAT_MATCHES_DEFINE(unsol_matches, @@ -110,6 +108,8 @@ static void gnss_nmea_generic_init_pipe(const struct device *dev) .uart = cfg->uart, .receive_buf = data->uart_backend_receive_buf, .receive_buf_size = sizeof(data->uart_backend_receive_buf), + .transmit_buf = data->uart_backend_transmit_buf, + .transmit_buf_size = sizeof(data->uart_backend_transmit_buf), }; data->uart_pipe = modem_backend_uart_init(&data->uart_backend, &uart_backend_config);