Skip to content

Commit 373dbb6

Browse files
committed
gnss: rtk: Add basic integration
Incorporate the basic RTK API as well as a basic client integration (serial) as a way to receive and publish the RTK data. Signed-off-by: Luis Ubieda <luisf@croxel.com>
1 parent 4ba7eb7 commit 373dbb6

File tree

19 files changed

+397
-0
lines changed

19 files changed

+397
-0
lines changed

cmake/linker_script/common/common-rom.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,3 +259,7 @@ endif()
259259
if(CONFIG_GNSS_SATELLITES)
260260
zephyr_iterable_section(NAME gnss_satellites_callback KVMA RAM_REGION GROUP RODATA_REGION)
261261
endif()
262+
263+
if(CONFIG_GNSS_RTK)
264+
zephyr_iterable_section(NAME gnss_rtk_data_callback KVMA RAM_REGION GROUP RODATA_REGION)
265+
endif()

include/zephyr/gnss/rtk/decoder.h

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright (c) 2025 Croxel Inc.
3+
* Copyright (c) 2025 CogniPilot Foundation
4+
*
5+
* SPDX-License-Identifier: Apache-2.0
6+
*/
7+
8+
#ifndef ZEPHYR_INCLUDE_GNSS_RTK_DECODER_H_
9+
#define ZEPHYR_INCLUDE_GNSS_RTK_DECODER_H_
10+
11+
#include <stdint.h>
12+
#include <stddef.h>
13+
14+
/**
15+
* @brief Get an RTK frame from buffer
16+
*
17+
* Used by RTK clients to extract frames from a data-buffer.
18+
*
19+
* @param[in] buf Buffer holding encoded data.
20+
* @param[in] buf_len Buffer length.
21+
* @param[out] data Pointer to the decoded frame.
22+
* @param[out] data_len Length of the decoded frame
23+
*
24+
* @return Zero if successful.
25+
* @return -ENOENT if no frames have been decoded successfully.
26+
* @return -EAGAIN if there's an incomplete frame starting at the data pointer.
27+
* @return Other negative error code if decoding failed.
28+
*/
29+
int gnss_rtk_decoder_frame_get(uint8_t *buf, size_t buf_len,
30+
uint8_t **data, size_t *data_len);
31+
32+
#endif /* ZEPHYR_INCLUDE_GNSS_RTK_DECODER_H_ */

include/zephyr/gnss/rtk/rtk.h

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Copyright (c) 2023 Trackunit Corporation
3+
* Copyright (c) 2025 Croxel Inc.
4+
* Copyright (c) 2025 CogniPilot Foundation
5+
*
6+
* SPDX-License-Identifier: Apache-2.0
7+
*/
8+
9+
#ifndef ZEPHYR_INCLUDE_GNSS_RTK_RTK_H_
10+
#define ZEPHYR_INCLUDE_GNSS_RTK_RTK_H_
11+
12+
#ifdef __cplusplus
13+
extern "C" {
14+
#endif
15+
16+
#include <stdint.h>
17+
#include <stddef.h>
18+
19+
struct gnss_rtk_data {
20+
const uint8_t *data;
21+
size_t len;
22+
};
23+
24+
typedef void (*gnss_rtk_data_callback_t)(const struct device *dev,
25+
const struct gnss_rtk_data *data);
26+
27+
struct gnss_rtk_data_callback {
28+
const struct device *dev;
29+
gnss_rtk_data_callback_t callback;
30+
};
31+
32+
#if CONFIG_GNSS_RTK
33+
#define GNSS_RTK_DATA_CALLBACK_DEFINE(_dev, _callback) \
34+
static const STRUCT_SECTION_ITERABLE(gnss_rtk_data_callback, \
35+
_gnss_rtk_data_callback__##_callback) = { \
36+
.dev = _dev, \
37+
.callback = _callback, \
38+
}
39+
#else
40+
#define GNSS_RTK_DATA_CALLBACK_DEFINE(_dev, _callback)
41+
#endif
42+
43+
#ifdef __cplusplus
44+
}
45+
#endif
46+
47+
#endif /* ZEPHYR_INCLUDE_GNSS_RTK_RTK_H_ */

include/zephyr/gnss/rtk/rtk_publish.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* Copyright (c) 2025 Croxel Inc.
3+
* Copyright (c) 2025 CogniPilot Foundation
4+
*
5+
* SPDX-License-Identifier: Apache-2.0
6+
*/
7+
8+
#ifndef ZEPHYR_INCLUDE_GNSS_RTK_PUBLISH_H_
9+
#define ZEPHYR_INCLUDE_GNSS_RTK_PUBLISH_H_
10+
11+
#include <stdint.h>
12+
#include <stddef.h>
13+
#include <zephyr/gnss/rtk/rtk.h>
14+
15+
/* Internal function used by RTK clients to publish data-correction. */
16+
void gnss_rtk_publish_data(const struct gnss_rtk_data *data);
17+
18+
#endif /* ZEPHYR_INCLUDE_GNSS_RTK_PUBLISH_H_ */

include/zephyr/linker/common-rom/common-rom-misc.ld

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,7 @@
6868
#if defined(CONFIG_GNSS_SATELLITES)
6969
ITERABLE_SECTION_ROM(gnss_satellites_callback, Z_LINK_ITERABLE_SUBALIGN)
7070
#endif
71+
72+
#if defined(CONFIG_GNSS_RTK)
73+
ITERABLE_SECTION_ROM(gnss_rtk_data_callback, Z_LINK_ITERABLE_SUBALIGN)
74+
#endif

subsys/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ add_subdirectory(canbus)
1616
add_subdirectory(debug)
1717
add_subdirectory(fb)
1818
add_subdirectory(fs)
19+
add_subdirectory(gnss)
1920
add_subdirectory(ipc)
2021
add_subdirectory(logging)
2122
add_subdirectory(mem_mgmt)

subsys/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ source "subsys/dsp/Kconfig"
2020
source "subsys/emul/Kconfig"
2121
source "subsys/fb/Kconfig"
2222
source "subsys/fs/Kconfig"
23+
source "subsys/gnss/Kconfig"
2324
source "subsys/input/Kconfig"
2425
source "subsys/ipc/Kconfig"
2526
source "subsys/jwt/Kconfig"

subsys/gnss/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Copyright (c) 2025 Croxel Inc.
2+
# Copyright (c) 2025 CogniPilot Foundation
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
add_subdirectory_ifdef(CONFIG_GNSS_RTK rtk)

subsys/gnss/Kconfig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Copyright (c) 2025 Croxel Inc.
2+
# Copyright (c) 2025 CogniPilot Foundation
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
rsource "rtk/Kconfig"

subsys/gnss/rtk/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Copyright (c) 2025 Croxel Inc.
2+
# Copyright (c) 2025 CogniPilot Foundation
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
zephyr_library()
6+
zephyr_library_sources(rtk.c)
7+
8+
add_subdirectory(protocol)
9+
add_subdirectory_ifdef(CONFIG_GNSS_RTK_SERIAL serial)

0 commit comments

Comments
 (0)