kopia lustrzana https://github.com/OpenRTX/OpenRTX
core: gps: added new API for GPS device management
rodzic
b8e220c276
commit
219bb4e986
|
@ -21,8 +21,8 @@
|
|||
#define GPS_H
|
||||
|
||||
#include <datetime.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <minmea.h>
|
||||
|
||||
/**
|
||||
* Data structure representing a single satellite as part of a GPS fix.
|
||||
|
@ -57,6 +57,51 @@ typedef struct
|
|||
}
|
||||
gps_t;
|
||||
|
||||
/**
|
||||
* Data structure for GPS device managment.
|
||||
*/
|
||||
struct gpsDevice {
|
||||
void *priv;
|
||||
void (*enable)(void *priv);
|
||||
void (*disable)(void *priv);
|
||||
int (*getSentence)(void *priv, char *buf, const size_t bufSize);
|
||||
};
|
||||
|
||||
/**
|
||||
* Enable the GPS.
|
||||
*
|
||||
* @param dev: pointer to GPS device handle.
|
||||
*/
|
||||
static inline void gps_enable(const struct gpsDevice *dev)
|
||||
{
|
||||
dev->enable(dev->priv);
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable the GPS.
|
||||
*
|
||||
* @param dev: pointer to GPS device handle.
|
||||
*/
|
||||
static inline void gps_disable(const struct gpsDevice *dev)
|
||||
{
|
||||
dev->disable(dev->priv);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a full NMEA sentence from the GPS.
|
||||
* This function is nonblocking.
|
||||
*
|
||||
* @param dev: pointer to GPS device handle.
|
||||
* @param buf: pointer to a buffer where to write the sentence.
|
||||
* @param bufSize: size of the destination buffer.
|
||||
* @return the length of the extracted sentence, -1 if the sentence is
|
||||
* longer than the maximum allowed size or zero if no sentence is available.
|
||||
*/
|
||||
static inline int gps_getSentence(const struct gpsDevice *dev, char *buf, const size_t bufSize)
|
||||
{
|
||||
return dev->getSentence(dev->priv, buf, bufSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function perfoms the task of reading data from the GPS module,
|
||||
* if available, enabled and ready, decode NMEA sentences and update
|
||||
|
|
|
@ -75,6 +75,7 @@ typedef struct
|
|||
|
||||
} hwInfo_t;
|
||||
|
||||
struct gpsDevice;
|
||||
|
||||
/**
|
||||
* This function handles device hardware initialization.
|
||||
|
@ -168,6 +169,14 @@ void platform_setTime(datetime_t t);
|
|||
*/
|
||||
const hwInfo_t *platform_getHwInfo();
|
||||
|
||||
#ifdef CONFIG_GPS
|
||||
/**
|
||||
* Detect and initialize the on-board GPS.
|
||||
* @return a GPS device handle or NULL if no device has been detected.
|
||||
*/
|
||||
const struct gpsDevice *platform_initGps();
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#include <minmea.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gps.h>
|
||||
|
|
Ładowanie…
Reference in New Issue