Csr location class shows location and satellite information, which supports H13467 + ST F103RB/NXP LCP1549 boards now.
Dependents: CsrLocationDemo CsrLocationDemo
Fork of CsrLocation by
Diff: CsrLocation.h
- Revision:
- 3:71690f7bb480
- Parent:
- 2:d4fe184925f2
- Child:
- 4:0d9b711fb646
diff -r d4fe184925f2 -r 71690f7bb480 CsrLocation.h
--- a/CsrLocation.h Wed Mar 26 09:16:55 2014 +0000
+++ b/CsrLocation.h Wed May 21 08:55:55 2014 +0000
@@ -14,6 +14,31 @@
#define CSR_RESULT_SUCCESS ((CsrResult) 0x0000)
#define CSR_RESULT_FAILURE ((CsrResult) 0xFFFF)
+#ifdef TARGET_LPC1768
+#define PINMAP_UART_DEBUG_TX USBTX
+#define PINMAP_UART_DEBUG_RX USBRX
+#define PINMAP_UART_LOC_TX D8
+#define PINMAP_UART_LOC_RX D9
+#define PINMAP_GPIO_LOC_ONOFF D11
+#define PINMAP_GPIO_LOC_RESET D12
+#define LOC_LED1 LED1
+#define LOC_LED2 LED2
+#define DBG_SERIAL_TYPE RawSerial
+#define LOC_SERIAL_TYPE RawSerial
+#elif defined(TARGET_LPC1549) || defined(TARGET_NUCLEO_F103RB)
+#define PINMAP_UART_DEBUG_TX D1
+#define PINMAP_UART_DEBUG_RX D0
+#define PINMAP_UART_LOC_TX D8
+#define PINMAP_UART_LOC_RX D2
+#define PINMAP_GPIO_LOC_ONOFF D3
+#define PINMAP_GPIO_LOC_RESET D4
+#define LOC_LED1 LED1
+#define LOC_LED2 LED2
+#define DBG_SERIAL_TYPE Serial
+#define LOC_SERIAL_TYPE RawSerial
+#endif
+
+
/* OSP protocol related definitions */
#define MAX_VERSION_LENGTH 80
@@ -86,6 +111,9 @@
/* Indicates the outputted sv status information */
#define LOC_OUTPUT_SV_STATUS (2)
+#if 0
+#define CSR_LOG_INFO printf
+#else
#define CSR_LOG_INFO(...) \
{\
if(csrLocInst.pSerialDebug != NULL)\
@@ -93,6 +121,7 @@
(csrLocInst.pSerialDebug->printf(__VA_ARGS__));\
}\
}
+#endif
/** Location enent definitions */
typedef enum
@@ -112,6 +141,15 @@
PWR_PTF,
}ePowerMode;
+/** Power mode selection */
+typedef enum
+{
+ /** NMEA protocol */
+ PROTO_NMEA,
+ /** OSP protocol */
+ PROTO_OSP,
+}eProto;
+
/* Protocol detection state */
typedef enum
{
@@ -139,8 +177,10 @@
PROTO_STATE_DET_INVALID = 0,
PROTO_STATE_DET_OSP,
PROTO_STATE_DET_NMEA,
- PROTO_STATE_SWI_OSP_FROM_NMEA,
+// PROTO_STATE_SWI_OSP_FROM_NMEA,
PROTO_STATE_DET_OSP_FROM_NMEA,
+// PROTO_STATE_SWI_NMEA_FROM_OSP,
+ PROTO_STATE_DET_NMEA_FROM_OSP,
PROTO_STATE_DET_OK,
}eProtoState;
@@ -161,16 +201,26 @@
SEND_DATA_TYPE_OSP_LPM_REQ,
SEND_DATA_TYPE_OSP_FPM_REQ,
SEND_DATA_TYPE_OSP_SWITCH2NMEA_REQ,
- SEND_DATA_TYPE_NMEA_SWITCH2OSP_REQ
+ SEND_DATA_TYPE_NMEA_SWITCH2OSP_REQ,
+ SEND_DATA_TYPE_NMEA_STOP_REQ
}eSendDataType;
-/** Structure to hold Position Response Message Information. */
-typedef struct LocPosResp
+typedef struct GpsTime
{
/** Week part of GPS time */
uint16_t gps_week;
/** Time of second part of GPS time */
uint32_t tow;
+}tGpsTime;
+
+/** Structure to hold Position Response Message Information. */
+typedef struct LocPosResp
+{
+ union
+ {
+ tGpsTime gpsTime;
+ float utcTime;
+ }u;
/** Latitude */
double lat;
/** Longitude */
@@ -256,9 +306,9 @@
typedef struct CsrLocConfig
{
/** Debug serial port to print debug information */
- RawSerial *pSerialDebug;
+ DBG_SERIAL_TYPE *pSerialDebug;
/** location serail port to communicate between mbed host side and location chip */
- RawSerial *pSerialLoc;
+ LOC_SERIAL_TYPE *pSerialLoc;
/** GPIO pin to control location chip on, a rising edge is uset to activate location chip. Please note, before activate chip, reset pin should be pull high */
DigitalOut *pPinOnoff;
/** GPIO pin to control location chip reset, low level will keep location chip in hibernation state and high level will permit location chip to be activated */
@@ -280,6 +330,7 @@
bool bPwrModeRsp;
bool bVerRsp;
+ eProto proto;
eCsrLocState locState;
eProtoState protoState;
ePowerMode pwrMode;
@@ -295,8 +346,8 @@
tLocSvStatus svStatus; /* 2 kind of messages contribute the svStaus */
- RawSerial *pSerialDebug;
- RawSerial *pSerialLoc;
+ DBG_SERIAL_TYPE *pSerialDebug;
+ LOC_SERIAL_TYPE *pSerialLoc;
DigitalOut *pPinOnoff;
DigitalOut *pPinReset;
@@ -336,7 +387,7 @@
void CsrLocReset(void);
/** Start location request, activate location chip */
- void CsrLocStart(ePowerMode pwrMode);
+ void CsrLocStart(ePowerMode pwrMode, eProto proto);
/** Process location data from chip and update location and satellite information */
void CsrLocUpdate(void);
@@ -364,15 +415,21 @@
/* Process the raw stream from location seraial port */
void _CsrLocProcessRawStream(void);
- /* Detect the OSP protocol outputted from location serial port */
- void _CsrLocDetProtoOsp(uint8_t data);
+ /* Detect the OSP protocol detection timeout */
+ void _CsrLocDetProtoOspTimeout(void);
/* Detect the NMEA protocol outputted from location serial port */
- void _CsrLocDetProtoNmea(uint8_t data);
+ void _CsrLocDetProtoNmeaTimeout(void);
+
+ /* Process the raw NMEA stream, remove the NMEA header, tail, and save the NMEA data into interal buffer */
+ void _CsrLocProcessRawNmeaStream(uint8_t data);
/* Process the raw OSP stream, remove the OSP header, size, check sum, and save the OSP data into interal buffer */
void _CsrLocProcessRawOspStream(uint8_t data);
+ /* Process the saved nmea data and decode them */
+ void _CsrLocProcessRawNmeaPkt(void);
+
/* Process the saved OSP data and decode them */
void _CsrLocProcessRawOspPkt(void);
@@ -404,3 +461,4 @@
#endif /* CSRLOCATION_H */
+

GPS mbed Shield