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 <tomi.fontanilles@nordicsemi.no>
diff --git a/drivers/gnss/Kconfig.generic b/drivers/gnss/Kconfig.generic
index 47fbd4a..bbcae30 100644
--- a/drivers/gnss/Kconfig.generic
+++ b/drivers/gnss/Kconfig.generic
@@ -15,6 +15,8 @@
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 @@
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 a50b5b4..2c92ce4 100644
--- a/drivers/gnss/gnss_nmea_generic.c
+++ b/drivers/gnss/gnss_nmea_generic.c
@@ -22,9 +22,8 @@
#include <zephyr/logging/log.h>
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 @@
/* 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 @@
.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);