Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions cmake/linker_script/common/common-rom.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@
zephyr_linker_section_configure(SECTION symtab INPUT ".gnu.linkonce.symtab*")
endif()

if (CONFIG_DEVICE_DEPS)

Check failure on line 204 in cmake/linker_script/common/common-rom.cmake

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

CMakeStyle

cmake/linker_script/common/common-rom.cmake:204 CMakeStyle
zephyr_linker_section(NAME device_deps KVMA RAM_REGION GROUP RODATA_REGION NOINPUT ${XIP_ALIGN_WITH_INPUT} ENDALIGN 16)
zephyr_linker_section_configure(SECTION device_deps INPUT .__device_deps_pass1* KEEP SORT NAME PASS LINKER_DEVICE_DEPS_PASS1)
zephyr_linker_section_configure(SECTION device_deps INPUT .__device_deps_pass2* KEEP SORT NAME PASS NOT LINKER_DEVICE_DEPS_PASS1)
Expand All @@ -209,28 +209,28 @@

zephyr_iterable_section(NAME _static_thread_data KVMA RAM_REGION GROUP RODATA_REGION)

if (CONFIG_BT_IAS)

Check failure on line 212 in cmake/linker_script/common/common-rom.cmake

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

CMakeStyle

cmake/linker_script/common/common-rom.cmake:212 CMakeStyle
zephyr_iterable_section(NAME bt_ias_cb KVMA RAM_REGION GROUP RODATA_REGION)
endif()

if (CONFIG_LOG)

Check failure on line 216 in cmake/linker_script/common/common-rom.cmake

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

CMakeStyle

cmake/linker_script/common/common-rom.cmake:216 CMakeStyle
zephyr_iterable_section(NAME log_link KVMA RAM_REGION GROUP RODATA_REGION)
zephyr_iterable_section(NAME log_backend KVMA RAM_REGION GROUP RODATA_REGION)
endif()

if (CONFIG_MULTI_LEVEL_INTERRUPTS)

Check failure on line 221 in cmake/linker_script/common/common-rom.cmake

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

CMakeStyle

cmake/linker_script/common/common-rom.cmake:221 CMakeStyle
zephyr_iterable_section(NAME intc_table KVMA RAM_REGION GROUP RODATA_REGION)
endif()

if (CONFIG_HTTP_SERVER)

Check failure on line 225 in cmake/linker_script/common/common-rom.cmake

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

CMakeStyle

cmake/linker_script/common/common-rom.cmake:225 CMakeStyle
zephyr_iterable_section(NAME http_service_desc KVMA RAM_REGION GROUP RODATA_REGION)
endif()

if (CONFIG_COAP_SERVER)

Check failure on line 229 in cmake/linker_script/common/common-rom.cmake

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

CMakeStyle

cmake/linker_script/common/common-rom.cmake:229 CMakeStyle
zephyr_iterable_section(NAME coap_service KVMA RAM_REGION GROUP RODATA_REGION)
endif()

if (CONFIG_NET_MGMT)

Check failure on line 233 in cmake/linker_script/common/common-rom.cmake

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

CMakeStyle

cmake/linker_script/common/common-rom.cmake:233 CMakeStyle
zephyr_iterable_section(NAME net_mgmt_event_static_handler KVMA RAM_REGION GROUP RODATA_REGION)
endif()

Expand Down Expand Up @@ -273,3 +273,7 @@
if(CONFIG_GNSS_RTK)
zephyr_iterable_section(NAME gnss_rtk_data_callback KVMA RAM_REGION GROUP RODATA_REGION)
endif()

if(CONFIG_GNSS_VELNED)
zephyr_iterable_section(NAME gnss_velned_callback KVMA RAM_REGION GROUP RODATA_REGION)
endif()
5 changes: 5 additions & 0 deletions drivers/gnss/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ config GNSS_SATELLITES
help
Enable GNSS satellites callback.

config GNSS_VELNED
bool "GNSS velocity support"
help
Enable GNSS velocity callback.

config GNSS_DUMP
bool "GNSS dump support"
depends on LOG
Expand Down
15 changes: 15 additions & 0 deletions drivers/gnss/gnss_publish.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,18 @@ void gnss_publish_satellites(const struct device *dev, const struct gnss_satelli
k_sem_give(&semlock);
}
#endif

#if CONFIG_GNSS_VELNED
void gnss_publish_velned(const struct device *dev, const struct gnss_velned *velned)
{
(void)k_sem_take(&semlock, K_FOREVER);

STRUCT_SECTION_FOREACH(gnss_velned_callback, callback) {
if (callback->dev == NULL || callback->dev == dev) {
callback->callback(dev, velned);
}
}

k_sem_give(&semlock);
}
#endif
11 changes: 11 additions & 0 deletions drivers/gnss/gnss_u_blox_m8.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ UBX_FRAME_DEFINE(enable_nav,
UBX_FRAME_DEFINE(enable_sat,
UBX_FRAME_CFG_MSG_RATE_INITIALIZER(UBX_CLASS_ID_NAV, UBX_MSG_ID_NAV_SAT, 1));
#endif
#if CONFIG_GNSS_VELNED
UBX_FRAME_DEFINE(enable_velned,
UBX_FRAME_CFG_MSG_RATE_INITIALIZER(UBX_CLASS_ID_NAV, UBX_MSG_ID_NAV_VELNED, 1));
#endif

UBX_FRAME_ARRAY_DEFINE(u_blox_m8_init_seq,
&disable_gga, &disable_rmc, &disable_gsv, &disable_dtm, &disable_gbs,
Expand All @@ -93,6 +97,9 @@ UBX_FRAME_ARRAY_DEFINE(u_blox_m8_init_seq,
#if CONFIG_GNSS_SATELLITES
&enable_sat,
#endif
#if CONFIG_GNSS_VELNED
&enable_velned,
#endif
);

MODEM_UBX_MATCH_ARRAY_DEFINE(u_blox_m8_unsol_messages,
Expand All @@ -102,6 +109,10 @@ MODEM_UBX_MATCH_ARRAY_DEFINE(u_blox_m8_unsol_messages,
MODEM_UBX_MATCH_DEFINE(UBX_CLASS_ID_NAV, UBX_MSG_ID_NAV_SAT,
gnss_ubx_common_satellite_callback),
#endif
#if CONFIG_GNSS_VELNED
MODEM_UBX_MATCH_DEFINE(UBX_CLASS_ID_NAV, UBX_MSG_ID_NAV_VELNED,
gnss_ubx_common_velned_callback),
#endif
);

static int ubx_m8_msg_get(const struct device *dev, const struct ubx_frame *req,
Expand Down
36 changes: 36 additions & 0 deletions drivers/gnss/gnss_ubx_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,32 @@ void gnss_ubx_common_satellite_callback(struct modem_ubx *ubx, const struct ubx_
}
#endif

#if CONFIG_GNSS_VELNED
void gnss_ubx_common_velned_callback(struct modem_ubx *ubx, const struct ubx_frame *frame,
size_t len, void *user_data)
{
if (len < UBX_FRAME_SZ(sizeof(struct ubx_nav_velned))) {
return;
}

const struct ubx_nav_velned *velned =
(const struct ubx_nav_velned *)frame->payload_and_checksum;
struct gnss_ubx_common_data *data = user_data;
const struct device *dev = data->gnss;

data->velned.velocity_n = velned->vel_n;
data->velned.velocity_e = velned->vel_e;
data->velned.velocity_d = velned->vel_d;
data->velned.speed = velned->speed;
data->velned.ground_speed = velned->ground_speed;
data->velned.heading = velned->heading;
data->velned.speed_acc = velned->speed_acc;
data->velned.heading_acc = velned->heading_acc;

gnss_publish_velned(dev, &data->velned);
}
#endif

void gnss_ubx_common_init(struct gnss_ubx_common_data *data,
const struct gnss_ubx_common_config *config)
{
Expand All @@ -155,4 +181,14 @@ void gnss_ubx_common_init(struct gnss_ubx_common_data *data,
data->satellites.data = config->satellites.buf;
data->satellites.size = config->satellites.size;
#endif
#if CONFIG_GNSS_VELNED
data->velned.velocity_n = 0;
data->velned.velocity_e = 0;
data->velned.velocity_d = 0;
data->velned.speed = 0;
data->velned.ground_speed = 0;
data->velned.heading = 0;
data->velned.speed_acc = 0;
data->velned.heading_acc = 0;
#endif
}
6 changes: 6 additions & 0 deletions drivers/gnss/gnss_ubx_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ struct gnss_ubx_common_data {
size_t size;
} satellites;
#endif
#if CONFIG_GNSS_VELNED
struct gnss_velned velned;
#endif
};

struct gnss_ubx_common_config {
Expand All @@ -38,6 +41,9 @@ void gnss_ubx_common_pvt_callback(struct modem_ubx *ubx, const struct ubx_frame
void gnss_ubx_common_satellite_callback(struct modem_ubx *ubx, const struct ubx_frame *frame,
size_t len, void *user_data);

void gnss_ubx_common_velned_callback(struct modem_ubx *ubx, const struct ubx_frame *frame,
size_t len, void *user_data);

void gnss_ubx_common_init(struct gnss_ubx_common_data *data,
const struct gnss_ubx_common_config *config);

Expand Down
48 changes: 48 additions & 0 deletions include/zephyr/drivers/gnss.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,37 @@ struct gnss_satellites_callback {
gnss_satellites_callback_t callback;
};

/** GNSS velocity structure */
struct gnss_velned {
/** Velocity North in cm/s */
int32_t velocity_n;
/** Velocity East in cm/s */
int32_t velocity_e;
/** Velocity Down in cm/s */
int32_t velocity_d;
/** Speed in cm/s */
uint32_t speed;
/** Ground speed in cm/s */
uint32_t ground_speed;
/** Heading in degrees */
int32_t heading;
/** Speed accuracy in cm/s */
uint32_t speed_acc;
/** Heading accuracy in degrees */
uint32_t heading_acc;
};

/** Template for GNSS velocity callback */
typedef void (*gnss_velned_callback_t)(const struct device *dev, const struct gnss_velned *velned);

/** GNSS callback structure */
struct gnss_velned_callback {
/** Filter callback to GNSS data from this device if not NULL */
const struct device *dev;
/** Callback called when GNSS velocity is published */
gnss_velned_callback_t callback;
};

/**
* @brief Set the GNSS fix rate
*
Expand Down Expand Up @@ -451,6 +482,23 @@ static inline int z_impl_gnss_get_latest_timepulse(const struct device *dev,
#define GNSS_SATELLITES_CALLBACK_DEFINE(_dev, _callback)
#endif

/**
* @brief Register a callback structure for GNSS velocity published
*
* @param _dev Device pointer
* @param _callback The callback function
*/
#if CONFIG_GNSS_VELNED
#define GNSS_VELNED_CALLBACK_DEFINE(_dev, _callback) \
static const STRUCT_SECTION_ITERABLE(gnss_velned_callback, \
_gnss_velned_callback__##_callback) = { \
.dev = _dev, \
.callback = _callback, \
}
#else
#define GNSS_VELNED_CALLBACK_DEFINE(_dev, _callback)
#endif

/**
* @}
*/
Expand Down
3 changes: 3 additions & 0 deletions include/zephyr/drivers/gnss/gnss_publish.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@ void gnss_publish_data(const struct device *dev, const struct gnss_data *data);
void gnss_publish_satellites(const struct device *dev, const struct gnss_satellite *satellites,
uint16_t size);

/** Internal function used by GNSS drivers to publish GNSS velocity */
void gnss_publish_velned(const struct device *dev, const struct gnss_velned *velned);

#endif /* ZEPHYR_DRIVERS_GNSS_GNSS_H_ */
4 changes: 4 additions & 0 deletions include/zephyr/linker/common-rom/common-rom-misc.ld
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* SPDX-License-Identifier: Apache-2.0 */

Check warning on line 1 in include/zephyr/linker/common-rom/common-rom-misc.ld

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

Copyright missing

include/zephyr/linker/common-rom/common-rom-misc.ld:1 File has no SPDX-FileCopyrightText header, consider adding one.

#include <zephyr/linker/iterable_sections.h>

Expand Down Expand Up @@ -76,3 +76,7 @@
#if defined(CONFIG_GNSS_RTK)
ITERABLE_SECTION_ROM(gnss_rtk_data_callback, Z_LINK_ITERABLE_SUBALIGN)
#endif

#if defined(CONFIG_GNSS_VELNED)
ITERABLE_SECTION_ROM(gnss_velned_callback, Z_LINK_ITERABLE_SUBALIGN)
#endif
13 changes: 13 additions & 0 deletions include/zephyr/modem/ubx/protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ enum ubx_class_id {

enum ubx_msg_id_nav {
UBX_MSG_ID_NAV_PVT = 0x07,
UBX_MSG_ID_NAV_VELNED = 0x12,
UBX_MSG_ID_NAV_SAT = 0x35,
};

Expand Down Expand Up @@ -168,6 +169,18 @@ struct ubx_nav_sat {
} sat[];
};

struct ubx_nav_velned {
uint32_t itow;
int32_t vel_n;
int32_t vel_e;
int32_t vel_d;
uint32_t speed;
uint32_t ground_speed;
int32_t heading;
uint32_t speed_acc;
uint32_t heading_acc;
} __packed;

enum ubx_msg_id_ack {
UBX_MSG_ID_ACK = 0x01,
UBX_MSG_ID_NAK = 0x00
Expand Down
Loading