Zephyr API Documentation 4.0.0-rc2
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
gnss.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2023 Trackunit Corporation
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
12#ifndef ZEPHYR_INCLUDE_DRIVERS_GNSS_H_
13#define ZEPHYR_INCLUDE_DRIVERS_GNSS_H_
14
24#include <zephyr/kernel.h>
25#include <zephyr/types.h>
26#include <zephyr/device.h>
28#include <errno.h>
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
45
47typedef int (*gnss_set_fix_rate_t)(const struct device *dev, uint32_t fix_interval_ms);
48
50typedef int (*gnss_get_fix_rate_t)(const struct device *dev, uint32_t *fix_interval_ms);
51
63
65typedef int (*gnss_set_navigation_mode_t)(const struct device *dev,
66 enum gnss_navigation_mode mode);
67
69typedef int (*gnss_get_navigation_mode_t)(const struct device *dev,
70 enum gnss_navigation_mode *mode);
71
91
94
96typedef int (*gnss_set_enabled_systems_t)(const struct device *dev, gnss_systems_t systems);
97
99typedef int (*gnss_get_enabled_systems_t)(const struct device *dev, gnss_systems_t *systems);
100
102typedef int (*gnss_get_supported_systems_t)(const struct device *dev, gnss_systems_t *systems);
103
105typedef int (*gnss_get_latest_timepulse_t)(const struct device *dev, k_ticks_t *timestamp);
106
118
136
148
164
176
186
188typedef void (*gnss_data_callback_t)(const struct device *dev, const struct gnss_data *data);
189
197
213
215typedef void (*gnss_satellites_callback_t)(const struct device *dev,
216 const struct gnss_satellite *satellites,
217 uint16_t size);
218
226
236__syscall int gnss_set_fix_rate(const struct device *dev, uint32_t fix_interval_ms);
237
238static inline int z_impl_gnss_set_fix_rate(const struct device *dev, uint32_t fix_interval_ms)
239{
240 const struct gnss_driver_api *api = (const struct gnss_driver_api *)dev->api;
241
242 if (api->set_fix_rate == NULL) {
243 return -ENOSYS;
244 }
245
246 return api->set_fix_rate(dev, fix_interval_ms);
247}
248
258__syscall int gnss_get_fix_rate(const struct device *dev, uint32_t *fix_interval_ms);
259
260static inline int z_impl_gnss_get_fix_rate(const struct device *dev, uint32_t *fix_interval_ms)
261{
262 const struct gnss_driver_api *api = (const struct gnss_driver_api *)dev->api;
263
264 if (api->get_fix_rate == NULL) {
265 return -ENOSYS;
266 }
267
268 return api->get_fix_rate(dev, fix_interval_ms);
269}
270
280__syscall int gnss_set_navigation_mode(const struct device *dev,
281 enum gnss_navigation_mode mode);
282
283static inline int z_impl_gnss_set_navigation_mode(const struct device *dev,
284 enum gnss_navigation_mode mode)
285{
286 const struct gnss_driver_api *api = (const struct gnss_driver_api *)dev->api;
287
288 if (api->set_navigation_mode == NULL) {
289 return -ENOSYS;
290 }
291
292 return api->set_navigation_mode(dev, mode);
293}
294
304__syscall int gnss_get_navigation_mode(const struct device *dev,
305 enum gnss_navigation_mode *mode);
306
307static inline int z_impl_gnss_get_navigation_mode(const struct device *dev,
308 enum gnss_navigation_mode *mode)
309{
310 const struct gnss_driver_api *api = (const struct gnss_driver_api *)dev->api;
311
312 if (api->get_navigation_mode == NULL) {
313 return -ENOSYS;
314 }
315
316 return api->get_navigation_mode(dev, mode);
317}
318
328__syscall int gnss_set_enabled_systems(const struct device *dev, gnss_systems_t systems);
329
330static inline int z_impl_gnss_set_enabled_systems(const struct device *dev,
331 gnss_systems_t systems)
332{
333 const struct gnss_driver_api *api = (const struct gnss_driver_api *)dev->api;
334
335 if (api->set_enabled_systems == NULL) {
336 return -ENOSYS;
337 }
338
339 return api->set_enabled_systems(dev, systems);
340}
341
351__syscall int gnss_get_enabled_systems(const struct device *dev, gnss_systems_t *systems);
352
353static inline int z_impl_gnss_get_enabled_systems(const struct device *dev,
354 gnss_systems_t *systems)
355{
356 const struct gnss_driver_api *api = (const struct gnss_driver_api *)dev->api;
357
358 if (api->get_enabled_systems == NULL) {
359 return -ENOSYS;
360 }
361
362 return api->get_enabled_systems(dev, systems);
363}
364
374__syscall int gnss_get_supported_systems(const struct device *dev, gnss_systems_t *systems);
375
376static inline int z_impl_gnss_get_supported_systems(const struct device *dev,
377 gnss_systems_t *systems)
378{
379 const struct gnss_driver_api *api = (const struct gnss_driver_api *)dev->api;
380
381 if (api->get_supported_systems == NULL) {
382 return -ENOSYS;
383 }
384
385 return api->get_supported_systems(dev, systems);
386}
387
401__syscall int gnss_get_latest_timepulse(const struct device *dev, k_ticks_t *timestamp);
402
403static inline int z_impl_gnss_get_latest_timepulse(const struct device *dev,
404 k_ticks_t *timestamp)
405{
406 const struct gnss_driver_api *api = (const struct gnss_driver_api *)dev->api;
407
408 if (api->get_latest_timepulse == NULL) {
409 return -ENOSYS;
410 }
411
412 return api->get_latest_timepulse(dev, timestamp);
413}
414
421#if CONFIG_GNSS
422#define GNSS_DATA_CALLBACK_DEFINE(_dev, _callback) \
423 static const STRUCT_SECTION_ITERABLE(gnss_data_callback, \
424 _gnss_data_callback__##_callback) = { \
425 .dev = _dev, \
426 .callback = _callback, \
427 }
428#else
429#define GNSS_DATA_CALLBACK_DEFINE(_dev, _callback)
430#endif
431
438#if CONFIG_GNSS_SATELLITES
439#define GNSS_SATELLITES_CALLBACK_DEFINE(_dev, _callback) \
440 static const STRUCT_SECTION_ITERABLE(gnss_satellites_callback, \
441 _gnss_satellites_callback__##_callback) = { \
442 .dev = _dev, \
443 .callback = _callback, \
444 }
445#else
446#define GNSS_SATELLITES_CALLBACK_DEFINE(_dev, _callback)
447#endif
448
453#ifdef __cplusplus
454}
455#endif
456
457#include <zephyr/syscalls/gnss.h>
458
459#endif /* ZEPHYR_INCLUDE_DRIVERS_GNSS_H_ */
System error numbers.
uint32_t k_ticks_t
Tick precision used in timeout APIs.
Definition sys_clock.h:48
void(* gnss_data_callback_t)(const struct device *dev, const struct gnss_data *data)
Template for GNSS data callback.
Definition gnss.h:188
int gnss_get_enabled_systems(const struct device *dev, gnss_systems_t *systems)
Get enabled GNSS systems.
gnss_fix_status
GNSS fix status.
Definition gnss.h:108
int gnss_set_fix_rate(const struct device *dev, uint32_t fix_interval_ms)
Set the GNSS fix rate.
gnss_pps_mode
GNSS PPS modes.
Definition gnss.h:35
int gnss_get_supported_systems(const struct device *dev, gnss_systems_t *systems)
Get supported GNSS systems.
int(* gnss_get_fix_rate_t)(const struct device *dev, uint32_t *fix_interval_ms)
API for getting fix rate.
Definition gnss.h:50
uint32_t gnss_systems_t
Type storing bitmask of GNSS systems.
Definition gnss.h:93
int(* gnss_set_fix_rate_t)(const struct device *dev, uint32_t fix_interval_ms)
API for setting fix rate.
Definition gnss.h:47
void(* gnss_satellites_callback_t)(const struct device *dev, const struct gnss_satellite *satellites, uint16_t size)
Template for GNSS satellites callback.
Definition gnss.h:215
int gnss_set_enabled_systems(const struct device *dev, gnss_systems_t systems)
Set enabled GNSS systems.
int gnss_get_fix_rate(const struct device *dev, uint32_t *fix_interval_ms)
Get the GNSS fix rate.
int gnss_get_latest_timepulse(const struct device *dev, k_ticks_t *timestamp)
Get the timestamp of the latest PPS timepulse.
int(* gnss_set_enabled_systems_t)(const struct device *dev, gnss_systems_t systems)
API for enabling systems.
Definition gnss.h:96
gnss_system
Systems contained in gnss_systems_t.
Definition gnss.h:73
int(* gnss_get_navigation_mode_t)(const struct device *dev, enum gnss_navigation_mode *mode)
API for getting navigation mode.
Definition gnss.h:69
int gnss_set_navigation_mode(const struct device *dev, enum gnss_navigation_mode mode)
Set the GNSS navigation mode.
int(* gnss_get_latest_timepulse_t)(const struct device *dev, k_ticks_t *timestamp)
API for getting timestamp of last PPS pulse.
Definition gnss.h:105
gnss_fix_quality
GNSS fix quality.
Definition gnss.h:120
int(* gnss_get_enabled_systems_t)(const struct device *dev, gnss_systems_t *systems)
API for getting enabled systems.
Definition gnss.h:99
gnss_navigation_mode
GNSS navigation modes.
Definition gnss.h:53
int gnss_get_navigation_mode(const struct device *dev, enum gnss_navigation_mode *mode)
Get the GNSS navigation mode.
int(* gnss_set_navigation_mode_t)(const struct device *dev, enum gnss_navigation_mode mode)
API for setting navigation mode.
Definition gnss.h:65
int(* gnss_get_supported_systems_t)(const struct device *dev, gnss_systems_t *systems)
API for getting enabled systems.
Definition gnss.h:102
@ GNSS_FIX_STATUS_ESTIMATED_FIX
Estimated fix acquired.
Definition gnss.h:116
@ GNSS_FIX_STATUS_DGNSS_FIX
Differential GNSS fix acquired.
Definition gnss.h:114
@ GNSS_FIX_STATUS_NO_FIX
No GNSS fix acquired.
Definition gnss.h:110
@ GNSS_FIX_STATUS_GNSS_FIX
GNSS fix acquired.
Definition gnss.h:112
@ GNSS_PPS_MODE_ENABLED_AFTER_LOCK
PPS output enabled from first lock.
Definition gnss.h:41
@ GNSS_PPS_MODE_DISABLED
PPS output disabled.
Definition gnss.h:37
@ GNSS_PPS_MODE_ENABLED
PPS output always enabled.
Definition gnss.h:39
@ GNSS_PPS_MODE_ENABLED_WHILE_LOCKED
PPS output enabled while locked.
Definition gnss.h:43
@ GNSS_SYSTEM_GALILEO
Galileo.
Definition gnss.h:79
@ GNSS_SYSTEM_BEIDOU
BeiDou Navigation Satellite System.
Definition gnss.h:81
@ GNSS_SYSTEM_SBAS
Satellite-Based Augmentation System (SBAS)
Definition gnss.h:87
@ GNSS_SYSTEM_IMES
Indoor Messaging System (IMES)
Definition gnss.h:89
@ GNSS_SYSTEM_GLONASS
GLObal NAvigation Satellite System (GLONASS)
Definition gnss.h:77
@ GNSS_SYSTEM_IRNSS
Indian Regional Navigation Satellite System (IRNSS)
Definition gnss.h:85
@ GNSS_SYSTEM_GPS
Global Positioning System (GPS)
Definition gnss.h:75
@ GNSS_SYSTEM_QZSS
Quasi-Zenith Satellite System (QZSS)
Definition gnss.h:83
@ GNSS_FIX_QUALITY_GNSS_SPS
Standard positioning service.
Definition gnss.h:124
@ GNSS_FIX_QUALITY_RTK
Real-time kinematic.
Definition gnss.h:130
@ GNSS_FIX_QUALITY_DGNSS
Differential GNSS.
Definition gnss.h:126
@ GNSS_FIX_QUALITY_INVALID
Invalid fix.
Definition gnss.h:122
@ GNSS_FIX_QUALITY_ESTIMATED
Estimated fix.
Definition gnss.h:134
@ GNSS_FIX_QUALITY_GNSS_PPS
Precise positioning service.
Definition gnss.h:128
@ GNSS_FIX_QUALITY_FLOAT_RTK
Floating real-time kinematic.
Definition gnss.h:132
@ GNSS_NAVIGATION_MODE_HIGH_DYNAMICS
High dynamics have higher impact on tracking.
Definition gnss.h:61
@ GNSS_NAVIGATION_MODE_ZERO_DYNAMICS
Dynamics have no impact on tracking.
Definition gnss.h:55
@ GNSS_NAVIGATION_MODE_BALANCED_DYNAMICS
Low and high dynamics have equal impact on tracking.
Definition gnss.h:59
@ GNSS_NAVIGATION_MODE_LOW_DYNAMICS
Low dynamics have higher impact on tracking.
Definition gnss.h:57
#define BIT(n)
Unsigned integer with bit position n set (signed in assembly language).
Definition util_macro.h:44
#define ENOSYS
Function not implemented.
Definition errno.h:82
Public kernel APIs.
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
Runtime device structure (in ROM) per driver instance.
Definition device.h:412
const void * api
Address of the API structure exposed by the device instance.
Definition device.h:418
GNSS callback structure.
Definition gnss.h:191
gnss_data_callback_t callback
Callback called when GNSS data is published.
Definition gnss.h:195
const struct device * dev
Filter callback to GNSS data from this device if not NULL.
Definition gnss.h:193
GNSS data structure.
Definition gnss.h:178
struct navigation_data nav_data
Navigation data acquired.
Definition gnss.h:180
struct gnss_info info
GNSS info when navigation data was acquired.
Definition gnss.h:182
struct gnss_time utc
UTC time when data was acquired.
Definition gnss.h:184
GNSS API structure.
Definition gnss.h:166
gnss_set_fix_rate_t set_fix_rate
Definition gnss.h:167
gnss_set_enabled_systems_t set_enabled_systems
Definition gnss.h:171
gnss_get_latest_timepulse_t get_latest_timepulse
Definition gnss.h:174
gnss_get_navigation_mode_t get_navigation_mode
Definition gnss.h:170
gnss_set_navigation_mode_t set_navigation_mode
Definition gnss.h:169
gnss_get_enabled_systems_t get_enabled_systems
Definition gnss.h:172
gnss_get_fix_rate_t get_fix_rate
Definition gnss.h:168
gnss_get_supported_systems_t get_supported_systems
Definition gnss.h:173
GNSS info data structure.
Definition gnss.h:138
enum gnss_fix_quality fix_quality
The fix quality.
Definition gnss.h:146
uint32_t hdop
Horizontal dilution of precision in 1/1000.
Definition gnss.h:142
enum gnss_fix_status fix_status
The fix status.
Definition gnss.h:144
uint16_t satellites_cnt
Number of satellites being tracked.
Definition gnss.h:140
GNSS satellite structure.
Definition gnss.h:199
uint8_t prn
Pseudo-random noise sequence.
Definition gnss.h:201
uint16_t azimuth
Azimuth relative to True North in degrees [0, 359].
Definition gnss.h:207
uint8_t elevation
Elevation in degrees [0, 90].
Definition gnss.h:205
uint8_t snr
Signal-to-noise ratio in dB.
Definition gnss.h:203
enum gnss_system system
System of satellite.
Definition gnss.h:209
uint8_t is_tracked
True if satellite is being tracked.
Definition gnss.h:211
GNSS callback structure.
Definition gnss.h:220
const struct device * dev
Filter callback to GNSS data from this device if not NULL.
Definition gnss.h:222
gnss_satellites_callback_t callback
Callback called when GNSS satellites is published.
Definition gnss.h:224
GNSS time data structure.
Definition gnss.h:150
uint8_t month
Month [1, 12].
Definition gnss.h:160
uint16_t millisecond
Millisecond [0, 60999].
Definition gnss.h:156
uint8_t minute
Minute [0, 59].
Definition gnss.h:154
uint8_t century_year
Year [0, 99].
Definition gnss.h:162
uint8_t hour
Hour [0, 23].
Definition gnss.h:152
uint8_t month_day
Day of month [1, 31].
Definition gnss.h:158
Navigation data structure.
Definition navigation.h:25