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:
- 2:d4fe184925f2
- Parent:
- 1:bbaf9b8d646a
- Child:
- 3:71690f7bb480
diff -r bbaf9b8d646a -r d4fe184925f2 CsrLocation.h --- a/CsrLocation.h Tue Mar 25 05:26:26 2014 +0000 +++ b/CsrLocation.h Wed Mar 26 09:16:55 2014 +0000 @@ -10,47 +10,9 @@ #define CSR_LOC_SDK_VER "CSR-LOC-SDK-0.5" -/* Data type definitions */ -#undef FALSE -#define FALSE (0) - -#undef TRUE -#define TRUE (1) - -/* Unsigned fixed width types */ -typedef unsigned char CsrUint8; -typedef unsigned short CsrUint16; -typedef unsigned int CsrUint32; - -/* Signed fixed width types */ -typedef signed char CsrInt8; -typedef signed short CsrInt16; -typedef signed int CsrInt32; - -/* Boolean */ -typedef CsrUint8 CsrBool; - -/* String types */ -typedef char CsrCharString; -typedef CsrUint8 CsrUtf8String; -typedef CsrUint16 CsrUtf16String; /* 16-bit UTF16 strings */ -typedef CsrUint32 CsrUint24; - -/* - * Floating point - * - * Note: If a given compiler does not support floating point, it is - * OK to omit these definitions; alternative versions of the code using - * these types may be available. Consult the relevant documentation - * or the customer support group for information on this. - */ -typedef float CsrFloat; -typedef double CsrDouble; - -typedef CsrUint16 CsrResult; +typedef uint16_t CsrResult; #define CSR_RESULT_SUCCESS ((CsrResult) 0x0000) #define CSR_RESULT_FAILURE ((CsrResult) 0xFFFF) -/* The end of data type definitions */ /* OSP protocol related definitions */ #define MAX_VERSION_LENGTH 80 @@ -68,21 +30,21 @@ /* NMEA message footer */ #define NMEA_MSG_TAIL0 ('*') -#define CSR_SWAPIN16(bytestream) (((CsrUint16)*((bytestream)+0) << 8) | ((CsrUint16)*((bytestream)+1))) +#define CSR_SWAPIN16(bytestream) (((uint16_t)*((bytestream)+0) << 8) | ((uint16_t)*((bytestream)+1))) #define CSR_SWAPIN32(bytestream)\ - ( ((CsrUint32)*((bytestream)+0) << 24)\ - | ((CsrUint32)*((bytestream)+1) << 16)\ - | ((CsrUint32)*((bytestream)+2) << 8)\ - | ((CsrUint32)*((bytestream)+3) )) + ( ((uint32_t)*((bytestream)+0) << 24)\ + | ((uint32_t)*((bytestream)+1) << 16)\ + | ((uint32_t)*((bytestream)+2) << 8)\ + | ((uint32_t)*((bytestream)+3) )) /* import macros for little endian: */ /* NOTE: must use {} around these macros when calling in a loop */ #define BINARY_IMPORT_UINT8(bytestream) ( *((bytestream)++)) -#define BINARY_IMPORT_UINT16(bytestream) ((CsrUint16) CSR_SWAPIN16((bytestream))); bytestream+=2 -#define BINARY_IMPORT_UINT32(bytestream) ((CsrUint32) CSR_SWAPIN32((bytestream))); bytestream+=4 -#define BINARY_IMPORT_SINT32(bytestream) ((CsrInt32) CSR_SWAPIN32((bytestream))); bytestream+=4 +#define BINARY_IMPORT_UINT16(bytestream) ((uint16_t) CSR_SWAPIN16((bytestream))); bytestream+=2 +#define BINARY_IMPORT_UINT32(bytestream) ((uint32_t) CSR_SWAPIN32((bytestream))); bytestream+=4 +#define BINARY_IMPORT_SINT32(bytestream) ((int32_t) CSR_SWAPIN32((bytestream))); bytestream+=4 #define OSP_MAKE_MSG_ID(mid, sid) ((((mid) & 0xFF) << 8) | ((sid) & 0xFF)) @@ -206,87 +168,87 @@ typedef struct LocPosResp { /** Week part of GPS time */ - CsrUint16 gps_week; + uint16_t gps_week; /** Time of second part of GPS time */ - CsrUint32 tow; + uint32_t tow; /** Latitude */ - CsrDouble lat; + double lat; /** Longitude */ - CsrDouble lon; + double lon; /** Altitude */ - CsrDouble alt; + double alt; } tLocPosResp; /** Structure to hold Satellite Information. */ typedef struct LocSvInfo { /** Prn or svId */ - CsrUint8 prn; + uint8_t prn; /** The ratio of carrier and noise */ - CsrFloat cno; + float cno; /** elevation */ - CsrFloat elevation; + float elevation; /** azimuth */ - CsrFloat azimuth; + float azimuth; /** satellite state */ - CsrUint16 state; + uint16_t state; } tLocSvInfo; /** Structure to hold Satellite Information for GLONASS */ typedef struct LocGloSvInfo { /** Prn or svId */ - CsrUint8 prn; + uint8_t prn; /** Slot number */ - CsrUint8 sno; + uint8_t sno; /** The ratio of carrier and noise */ - CsrFloat cno; + float cno; /** elevation */ - CsrFloat elevation; + float elevation; /** azimuth */ - CsrFloat azimuth; + float azimuth; /** satellite state */ - CsrUint16 state; + uint16_t state; } tLocGloSvInfo; /** Structure to hold Satellite Status Information. */ typedef struct LocSvStatus { /** Week part of GPS time */ - CsrUint16 gps_week; + uint16_t gps_week; /** Time of second part of GPS time */ - CsrUint32 tow; + uint32_t tow; /** Time of millisecond part of GPS time */ - CsrUint32 tow_sub_ms; + uint32_t tow_sub_ms; /**Number of GPS SVs currently visible **/ - CsrUint8 numOfSVs; + uint8_t numOfSVs; /**Number of GLONASS SVs currently visible **/ - CsrUint8 numOfGloSVs; + uint8_t numOfGloSVs; /** GPS SVs information */ tLocSvInfo svList[LOC_MAX_GNSS_SVS]; /** GLONASS SVs information */ tLocGloSvInfo gloSvList[LOC_NUM_OF_GLO_FREQ_CHANNELS]; /** Bit mask indicating which SVs have ephemeris data **/ - CsrUint32 ephemerisMask; + uint32_t ephemerisMask; /** Bit mask indicating which GLONASS SVs have ephemeris data **/ - CsrUint32 gloEphemerisMask; + uint32_t gloEphemerisMask; /** Bit mask indicating which SVs were used in latest sent fix **/ - CsrUint32 svUsedInFixMask; + uint32_t svUsedInFixMask; /** Bit mask indicating which GLONASS SVs were used in latest sent fix **/ - CsrUint32 gloSvUsedInFixMask; + uint32_t gloSvUsedInFixMask; /** Bit mask indicating which QZSS SVs were used in latest sent fix **/ - CsrUint32 qzssSvUsedInFixMask; + uint32_t qzssSvUsedInFixMask; /** Bit mask indicating which SBAS SVs were used in latest sent fix **/ - CsrUint32 sbasSvUsedInFixMask; + uint32_t sbasSvUsedInFixMask; } tLocSvStatus; /** Applicaiton register this out callback function and CsrLocaiton class will pass outputted information to application */ -typedef void (*csr_app_output_callback)(CsrUint32 msgId, void * const pMsgData, CsrUint32 msgLength); +typedef void (*csr_app_output_callback)(uint32_t msgId, void * const pMsgData, uint32_t msgLength); /** Applicaiton register this event callback function and CsrLocaiton class will pass internal porcessing event to application */ -typedef void (*csr_app_event_callback)(eCsrLocEventType event, CsrUint32 data); +typedef void (*csr_app_event_callback)(eCsrLocEventType event, uint32_t data); /** tCsrLocConfig structure * Application needs to decides and pass the configuration into CsrLocation class. @@ -294,7 +256,7 @@ typedef struct CsrLocConfig { /** Debug serial port to print debug information */ - Serial *pSerialDebug; + RawSerial *pSerialDebug; /** location serail port to communicate between mbed host side and location chip */ RawSerial *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 */ @@ -306,42 +268,42 @@ /* General OSP mesasge format */ typedef struct OspMsg { - CsrUint32 msgId; - CsrUint32 length; - CsrUint8 payload[4]; + uint32_t msgId; + uint32_t length; + uint8_t payload[4]; } tOspMsg; /* keep the internal data of CsrLocation class */ typedef struct CsrLocInst { - CsrBool bStopFlag; - CsrBool bPwrModeRsp; - CsrBool bVerRsp; + bool bStopFlag; + bool bPwrModeRsp; + bool bVerRsp; eCsrLocState locState; eProtoState protoState; ePowerMode pwrMode; - CsrUint32 baudRate; - CsrInt32 computedCheckSum; - CsrInt32 checksum; - CsrInt32 msgSize; - CsrInt32 decodeIndex; + uint32_t baudRate; + int32_t computedCheckSum; + int32_t checksum; + int32_t msgSize; + int32_t decodeIndex; eProtoDetState protoDetState; Timeout *pTimeoutChk; /* timeout process */ - CsrBool bTimeoutFlag; + bool bTimeoutFlag; eEngineStatus engStatus; tLocSvStatus svStatus; /* 2 kind of messages contribute the svStaus */ - Serial *pSerialDebug; + RawSerial *pSerialDebug; RawSerial *pSerialLoc; DigitalOut *pPinOnoff; DigitalOut *pPinReset; - CsrUint8 serialBuf[MAX_SERIAL_BUF_LEN]; /* buffer the serial data from uart callback function */ - CsrUint8 serialPkt[MAX_SERIAL_PKT_LEN]; /* decoded osp data */ - CsrUint32 in; - CsrUint32 out; + uint8_t serialBuf[MAX_SERIAL_BUF_LEN]; /* buffer the serial data from uart callback function */ + uint8_t serialPkt[MAX_SERIAL_PKT_LEN]; /* decoded osp data */ + uint32_t in; + uint32_t out; csr_app_output_callback appOutCb; csr_app_event_callback appEventCb; @@ -403,22 +365,22 @@ void _CsrLocProcessRawStream(void); /* Detect the OSP protocol outputted from location serial port */ - void _CsrLocDetProtoOsp(CsrUint8 data); + void _CsrLocDetProtoOsp(uint8_t data); /* Detect the NMEA protocol outputted from location serial port */ - void _CsrLocDetProtoNmea(CsrUint8 data); + void _CsrLocDetProtoNmea(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(CsrUint8 data); + void _CsrLocProcessRawOspStream(uint8_t data); /* Process the saved OSP data and decode them */ void _CsrLocProcessRawOspPkt(void); /* Calculate the OSP message size to allcate buffer to save the decoded OSP data */ - CsrUint32 _CsrLocCalcMsgSize(void); + uint32_t _CsrLocCalcMsgSize(void); /* Decode OSP data into pakcet data structure */ - CsrResult _CsrLocDecodeOspPkt( CsrUint8 *payload, CsrUint32 payload_length, CsrUint32 *message_id, void *message_structure, CsrUint32 *message_length); + CsrResult _CsrLocDecodeOspPkt( uint8_t *payload, uint32_t payload_length, uint32_t *message_id, void *message_structure, uint32_t *message_length); /* Process the decode OSP packet and pass to application when needed */ void _CsrLocProcessOspPkt(tOspMsg *pOspMsg);