zephyr/drivers/gnss/gnss_publish.c
Bjarki Arge Andreasen 28f5f2d1ed drivers: Add GNSS API public header
This commit adds the public header for the GNSS API, along
with the initial GNSS Kconfig file and an entry in the
common linker file for registered GNSS data callbacks.

A very naive implementation of the GNSS data callback is
provided as well in drivers/gnss/gnss_publish.c

Signed-off-by: Bjarki Arge Andreasen <bjarkix123@gmail.com>
2023-10-30 11:43:19 -04:00

37 lines
843 B
C

/*
* Copyright (c) 2023 Trackunit Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "gnss_publish.h"
#include <zephyr/kernel.h>
#include <zephyr/sys/iterable_sections.h>
static struct k_spinlock lock;
void gnss_publish_data(const struct device *dev, const struct gnss_data *data)
{
K_SPINLOCK(&lock) {
STRUCT_SECTION_FOREACH(gnss_data_callback, callback) {
if (callback->dev == NULL || callback->dev == dev) {
callback->callback(dev, data);
}
}
}
}
#if CONFIG_GNSS_SATELLITES
void gnss_publish_satellites(const struct device *dev, const struct gnss_satellite *satellites,
uint16_t size)
{
K_SPINLOCK(&lock) {
STRUCT_SECTION_FOREACH(gnss_satellites_callback, callback) {
if (callback->dev == NULL || callback->dev == dev) {
callback->callback(dev, satellites, size);
}
}
}
}
#endif