Reputation: 149
I am trying to use a device driver that is present in the Zephyr Project.
To my understanding the steps to import the driver are as followed:
# Copyright (c) 2023 Trackunit Corporation
# SPDX-License-Identifier: Apache-2.0
menuconfig GNSS
bool "GNSS drivers"
select EXPERIMENTAL
help
Enable GNSS drivers and configuration.
if GNSS
config GNSS_SATELLITES
bool "GNSS satellites support"
help
Enable GNSS sattelites callback.
config GNSS_DUMP
bool "GNSS dump support"
depends on LOG
help
Enable GNSS dump library
config GNSS_DUMP_TO_LOG
bool "Dump GNSS events to log"
select GNSS_DUMP
help
Enable GNSS dump to log.
if GNSS_DUMP_TO_LOG
config GNSS_DUMP_TO_LOG_BUF_SIZE
int "GNSS log dump buffer size"
default 128
help
Size of GNSS log dump buffer
endif
config GNSS_PARSE
bool "GNSS parsing utilities"
help
Enable GNSS parsing utilities.
config GNSS_NMEA0183
bool "NMEA0183 parsing utilities"
select GNSS_PARSE
help
Enable NMEA0183 parsing utilities.
config GNSS_NMEA0183_MATCH
bool "GNSS NMEA0183 match utilities"
select GNSS_NMEA0183
help
Enable NMEA0183 match utilities.
config GNSS_INIT_PRIORITY
int "GNSS driver initialization priority"
default 80
range 0 99
help
Driver initialization priority for GNSS drivers.
config GNSS_U_BLOX_PROTOCOL
bool "GNSS U-BLOX protocol"
select MODEM_UBX
help
Enable gnss u-blox protocol.
module = GNSS
module-str = gnss
source "subsys/logging/Kconfig.template.log_config"
rsource "Kconfig.emul"
rsource "Kconfig.generic"
rsource "Kconfig.quectel_lcx6g"
rsource "Kconfig.u_blox_m10"
rsource "Kconfig.luatos_air530z"
endif
I have included all of the configs that are after config keyword.
# Copyright 2024 NXP
# SPDX-License-Identifier: Apache-2.0
config GNSS_U_BLOX_M10
bool "U-BLOX M10 GNSS Module"
default y
depends on GNSS
depends on DT_HAS_U_BLOX_M10_ENABLED
select MODEM_MODULES
select MODEM_BACKEND_UART
select MODEM_CHAT
select MODEM_UBX
select GNSS_PARSE
select GNSS_NMEA0183
select GNSS_NMEA0183_MATCH
select GNSS_U_BLOX_PROTOCOL
select UART_USE_RUNTIME_CONFIGURE
help
Enable U-BLOX M10 GNSS modem driver.
config GNSS_U_BLOX_M10_SATELLITES_COUNT
int "Maximum satellite count"
depends on GNSS_SATELLITES
default 24
help
Maximum number of satellite that the driver that can be decoded from
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.
After this I am not sure what to do 100% but from prior experience I should be able to import the dirver file and work with the functions.
To do this I included the following statement in my main.c file:
#include <zephyr/drivers/gnss/gnss_u_blox_m10.c>
However this is referring an error. SO after doing more research about the matter, I have read that the device just uses the generic gnss interface to get you the data.
Is this true? When looking at the GNSS example it just uses the following code for data collection:
static void gnss_data_cb(const struct device *dev, const struct gnss_data *data)
{
if (data->info.fix_status != GNSS_FIX_STATUS_NO_FIX) {
printf("Got a fix!\n");
}
}
GNSS_DATA_CALLBACK_DEFINE(GNSS_MODEM, gnss_data_cb);
Am I suppose to use the generic interface as illustrated above?
Is there some reference that clearly spells this out?
Upvotes: 0
Views: 68
Reputation: 5098
You are missing one critical piece to enabling the GNSS hardware, and then aren't quite using the API correctly from your post. The steps you should follow for any hardware device, in general, are:
boards/
folder that have examples for how you would declare the GNSS module as a child of the associated UART controller to which it is connected.CONFIG_GNSS
and then any others for which you do not like the default. In the case of the actual driver (ie, CONFIG_GNSS_U_BLOX_M10
), it's usually set to y
so only as there is a matching node and it's status
in the devicetree is "okay"
. Notice the dependency on DT_HAS_U_BLOX_M10_ENABLED
, this Kconfig is generated by the devicetree and cannot be override by the project. And if it's not enabled, you will not be able to force CONFIG_GNSS_U_BLOX_M10
as even if a value is set to y
in the project, it will still respect its dependencies.Upvotes: 0