Skip to content

Commit 0ce9e82

Browse files
EliasJRHAlan C. Assis
authored andcommitted
drivers/sensors: add Quectel L86-XXX GNSS uORB sensor driver
1 parent 3f65182 commit 0ce9e82

File tree

8 files changed

+1150
-1
lines changed

8 files changed

+1150
-1
lines changed

Documentation/components/drivers/special/sensors.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,4 @@ general interface.
3333
sensors/sht4x.rst
3434
sensors/lsm6dso32.rst
3535
sensors/lis2mdl.rst
36+
sensors/l86xxx.rst
Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
=======
2+
L86-XXX
3+
=======
4+
5+
.. tags:: experimental
6+
7+
This driver provides support for the L86-XXX family of GNSS modules by
8+
Quectel via the :doc:`uorb </components/drivers/special/sensors/sensors_uorb>` interface.
9+
Functionality for this driver was tested using the Quectel L86-M33.
10+
11+
.. warning::
12+
This driver only contains preliminary support for a handful of proprietary
13+
'PMTK' commands There is no support for the entire suite of commands yet.
14+
This driver also does not use the standard uORD GNSS upper half driver and
15+
should eventually be modified such that it does. CONSIDER THIS DRIVER EXPERIMENTAL.
16+
17+
Application Programming Interface
18+
=================================
19+
20+
To register the device for use, you will need to enable the standard upper half
21+
serial drivers (``CONFIG_STANDARD_SERIAL``), since the L86-XXX driver requires
22+
the path to the UART interface the module is connected to. You will also need to
23+
ensure that the baud rate of the UART interface is set to 9600, which is the default
24+
baud rate of the L86-XXX series of GNSS modules.
25+
26+
The driver supports changing the default baud rate and update rate of the GNSS module.
27+
As a result, you will also need to enable serial TERMIOS support (``CONFIG_SERIAL_TERMIOS``).
28+
The baud rate and update rate of the GNSS module can be configured using the ``L86_XXX_BAUD`` and ``L86_XXX_FIX_INT`` options respectively.
29+
Note that a faster update rate will require a higher baud rate to support it and the supported baud rates for the L86-XXX series of GNSS modules are:
30+
* 4800
31+
* 9600
32+
* 14400
33+
* 19200
34+
* 38400
35+
* 57600
36+
* 115200
37+
The baud rate and update rates of the module are changed at registration time.
38+
39+
.. code-block:: c
40+
41+
#if defined(CONFIG_SENSORS_L86_XXX)
42+
#include <nuttx/sensors/l86xxx.h>
43+
44+
/* Register L86-M33 on USART3 */
45+
46+
ret = l86xxx_register("/dev/l86m33", "/dev/ttyS2", 0);
47+
if (ret < 0) {
48+
syslog(LOG_ERR, "Failed to register L86-M33: %d\n", ret);
49+
}
50+
#endif
51+
52+
Once the driver is registered, it starts a thread that continuously reads raw output from the specified UART device and
53+
parses the output according to `NMEA <https://en.wikipedia.org/wiki/NMEA_0183>`_ standards using the
54+
`minmea <https://github.com/kosma/minmea>`_ library included in NuttX. The driver populates the ``sensor_gnss`` struct
55+
and pushes it to the appropriate event once all NMEA messages in its sequence have been read.
56+
57+
58+
**uORB commands**
59+
-----------------
60+
The driver implements the ``orb_activate``, ``orb_set_interval`` and, ``orb_ioctl`` operations to interact with the device.
61+
The latter is used to send proprietary 'PMTK' commands which are documented further below.
62+
63+
**Activate**
64+
65+
There are 4 modes that the L86-XXX GNSS modules can be in. Those are "Full On Mode", "Standby Mode", "Backup Mode", "Periodic Mode" and, "AlwaysLocateTM Mode".
66+
Calling ``orb_activate`` with ``enable`` set to false will enter the module into "Standby Mode".
67+
In "Standby Mode", the module doesn't output any NMEA messages but the internal core and I/O power domain are still active.
68+
69+
The module can be re-enabled by calling ``orb_activate`` with ``enable`` set to true, which will hot start the module OR by
70+
sending any 'PMTK' command.
71+
72+
**Set interval**
73+
74+
The L86-XXX GNSS modules support interval rates from 1Hz to 10Hz (100ms - 10000ms). When using ``orb_set_interval``, be aware that
75+
increasing the interval of the module may also require and increase in baud rate. An example of how this is performed can be found in
76+
source code of this driver in the register function.
77+
78+
Any interval rate outside of the supported range will result in a failed call to this function.
79+
80+
**Control**
81+
82+
The ``orb_ioctl`` interface allows one to send proprietary 'PMTK' commands to the L86-XXX GNSS module. It effectively works
83+
as a wrapper for the command framework outlined by Quectel. The return value of calls to ``orb_ioctl`` follow this pattern:
84+
85+
* -EINVAL - Invalid packet
86+
* -ENOSYS - Unsupported packet type
87+
* -EIO - Valid packet, but action failed
88+
* 0 - Valid packet, action succeeded
89+
* Other - Command failed during writing
90+
91+
The supported commands are their arguments are listed below.
92+
93+
``SNIOC_HOT_START``
94+
-------------------
95+
Used to "Hot start" the GNSS module. Normally hot start means the GNSS module was powered down for less
96+
than 3 hours (RTC must be alive) and its ephemeris is still valid. As there is no need for downloading
97+
ephemeris, it is the fastest startup method.
98+
99+
.. code-block:: c
100+
101+
orb_ioctl(sensor, SNIOC_HOT_START);
102+
103+
``SNIOC_WARM_START``
104+
--------------------
105+
Used to "Warm start" the GNSS module. Warm start means the GNSS module has approximate information of time,
106+
position and coarse data on satellite positions, but it needs to download ephemeris until it can get a fix.
107+
108+
.. code-block:: c
109+
110+
orb_ioctl(sensor, SNIOC_WARM_START);
111+
112+
``SNIOC_COLD_START``
113+
--------------------
114+
Used to "Cold start" the GNSS module. Using this message will force the GNSS module to be restarted without
115+
any prior location information, including time, position, almanacs and ephemeris data.
116+
117+
.. code-block:: c
118+
119+
orb_ioctl(sensor, SNIOC_COLD_START);
120+
121+
``SNIOC_FULL_COLD_START``
122+
-------------------------
123+
Used to "Full cold start" the GNSS module. This is effectively the same as a cold restart, but additionally
124+
clears system and user configurations. In other words, this resets the GNSS module to its factory settings.
125+
When full-cold started, the GNSS module has no information on its last location.
126+
127+
.. code-block:: c
128+
129+
orb_ioctl(sensor, SNIOC_FULL_COLD_START);
130+
131+
``SNIOC_SET_INTERVAL``
132+
----------------------
133+
Used to modify the position fix interval of the GNSS module. The argument is an integer between 100 and 10000, default value is 1000.
134+
135+
.. code-block:: c
136+
137+
orb_ioctl(sensor, SNIOC_SET_INTERVAL, 1000);
138+
139+
``SNIOC_SET_BAUD``
140+
------------------
141+
.. note::
142+
143+
This feature requires termios support to be enabled(``CONFIG_SERIAL_TERMIOS``)
144+
145+
Used to modify the baud rate of the GNSS module. The argument is an integer representing a supported baud rate, default value is 9600.
146+
Upon sending this command, the baud rate of the UART interface used to communicate with the module is also modified.
147+
Supported baud rates for the L86-XXX series of GNSS modules are:
148+
149+
* 4800
150+
* 9600
151+
* 14400
152+
* 19200
153+
* 38400
154+
* 57600
155+
* 115200
156+
157+
.. code-block:: c
158+
159+
orb_ioctl(sensor, SNIOC_SET_BAUD, 9600);
160+
161+
``SNIOC_SET_OPERATIONAL_MODE``
162+
------------------------------
163+
Used to set the navigation mode of the GNSS module. The argument is an ``L86XXX_OPERATIONAL_MODE`` enum:
164+
165+
* NORMAL - For general purpose
166+
* FITNESS - For instances in which low-speed movements (<5 m/s>) will affect calculations
167+
* AVIATION - For high-dynamic purposes that the large-acceleration movement will have more effect on the position calculation
168+
* BALLOON - For high-altitude balloon purposes that vertical movement will have more effect on the position calculation
169+
* STANDBY - Used to enter standby mode for power saving
170+
171+
Default mode is NORMAL
172+
173+
.. code-block:: c
174+
175+
orb_ioctl(sensor, SNIOC_SET_OPERATIONAL_MODE, NORMAL);
176+
177+

drivers/sensors/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ if(CONFIG_SENSORS)
3737
list(APPEND SRCS nau7802.c)
3838
endif()
3939

40+
if(CONFIG_SENSORS_L86_XXX)
41+
list(APPEND SRCS l86xxx_uorb.c)
42+
endif()
43+
4044
if(CONFIG_SENSORS_GNSS)
4145
set_source_files_properties(
4246
gnss_uorb.c DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/..

drivers/sensors/Kconfig

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,35 @@ config KXTJ9_I2C_BUS_SPEED
838838

839839
endif # SENSORS_KXTJ9
840840

841+
config SENSORS_L86_XXX
842+
bool "Quectel L86-XXX GNSS support"
843+
default n
844+
depends on SERIAL && STANDARD_SERIAL && UORB
845+
---help---
846+
Enable driver support for the L86-XXX series of GNSS modules.
847+
848+
config SENSORS_L86_XXX_THREAD_STACKSIZE
849+
int "Stack size for L86XXX module collection thread"
850+
default 10000
851+
depends on SENSORS_L86_XXX
852+
853+
config L86_XXX_BAUD
854+
int "Quectel L86-XXX baud rate"
855+
default 9600
856+
depends on SENSORS_L86_XXX && SERIAL_TERMIOS
857+
range 4800 115200
858+
---help---
859+
Supported values are: 4800, 9600, 14400, 19200, 38400, 57600 and 115200
860+
861+
config L86_XXX_FIX_INT
862+
int "Quectel L86-XXX fix interval rate"
863+
default 1000
864+
depends on SENSORS_L86_XXX && SERIAL_TERMIOS
865+
range 100 10000
866+
---help---
867+
Rate in ms at which module obtains satellite fix. Supported values
868+
are integers between 100 10000
869+
841870
config SENSORS_LIS2DH
842871
bool "STMicro LIS2DH device support"
843872
default n

drivers/sensors/Make.defs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,14 @@ ifeq ($(CONFIG_SENSORS_RPMSG),y)
3434
CSRCS += sensor_rpmsg.c
3535
endif
3636

37-
3837
ifeq ($(CONFIG_SENSORS_NAU7802),y)
3938
CSRCS += nau7802.c
4039
endif
4140

41+
ifeq ($(CONFIG_SENSORS_L86_XXX),y)
42+
CSRCS += l86xxx_uorb.c
43+
endif
44+
4245
ifeq ($(CONFIG_SENSORS_GNSS),y)
4346
CSRCS += gnss_uorb.c
4447
endif

0 commit comments

Comments
 (0)