Csr location class shows location and satellite information, which supports H13467 + ST F103RB/NXP LCP1549 boards now.
Dependents: CsrLocationDemo CsrLocationDemo
Fork of CsrLocation by
Revision 1:bbaf9b8d646a, committed 2014-03-25
- Comitter:
- zhjcpi
- Date:
- Tue Mar 25 05:26:26 2014 +0000
- Parent:
- 0:aba381fc8158
- Child:
- 2:d4fe184925f2
- Commit message:
- optimization csrLocation class
Changed in this revision
| CsrLocation.cpp | Show annotated file Show diff for this revision Revisions of this file |
| CsrLocation.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/CsrLocation.cpp Mon Mar 24 08:23:25 2014 +0000
+++ b/CsrLocation.cpp Tue Mar 25 05:26:26 2014 +0000
@@ -8,15 +8,15 @@
#include "CsrLocation.h"
-const static CsrUint8 sOspStopReq[] = {0xa0, 0xa2, 0x00, 0x02, 0xcd, 0x10, 0x00, 0xdd, 0xb0, 0xb3};
-const static CsrUint8 sOspVerReq[] = {0xA0, 0xA2, 0x00, 0x02, 0x84, 0x00, 0x00, 0x84, 0xB0, 0xB3};
-const static CsrUint8 sOspLpmReq[] = {0xA0, 0xA2, 0x00, 0x2A, 0xDA, 0x06, 0x01, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x01, 0x00, 0x78, 0x00, 0x1E,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC8, 0x00, 0x00, 0x01, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x63, 0xB0, 0xB3};
-const static CsrUint8 sOspFpmReq[] = {0xA0, 0xA2, 0x00, 0x03, 0xDA, 0x00, 0x00, 0x00, 0xDA, 0xB0, 0xB3};
-const static CsrUint8 sOspSwitch2NmeaReq[] = {0xA0, 0xA2, 0x00, 0x18, 0x81, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x05, 0x01, 0x01, 0x01, 0x00,
+static CsrUint8 sOspStopReq[] = {0xa0, 0xa2, 0x00, 0x02, 0xcd, 0x10, 0x00, 0xdd, 0xb0, 0xb3};
+static CsrUint8 sOspVerReq[] = {0xA0, 0xA2, 0x00, 0x02, 0x84, 0x00, 0x00, 0x84, 0xB0, 0xB3};
+static CsrUint8 sOspLpmReq[] = {0xA0, 0xA2, 0x00, 0x2A, 0xDA, 0x06, 0x01, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x01, 0x00, 0x78, 0x00, 0x1E,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC8, 0x00, 0x00, 0x01, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x63, 0xB0, 0xB3};
+static CsrUint8 sOspFpmReq[] = {0xA0, 0xA2, 0x00, 0x03, 0xDA, 0x00, 0x00, 0x00, 0xDA, 0xB0, 0xB3};
+static CsrUint8 sOspSwitch2NmeaReq[] = {0xA0, 0xA2, 0x00, 0x18, 0x81, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x05, 0x01, 0x01, 0x01, 0x00,
0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x12, 0xC0, 0x01, 0x64, 0xB0, 0xB3};
-const static CsrCharString sNmeaSwitch2OspReq[] = "$PSRF100,0,115200,8,1,0*04\r\n";
+static CsrCharString sNmeaSwitch2OspReq[] = "$PSRF100,0,115200,8,1,0*04\r\n";
CsrLocation::CsrLocation(tCsrLocConfig *pLocConfig)
{
@@ -74,6 +74,9 @@
_CsrLocHwOnoff();
csrLocInst.locState = CSR_LOC_STATE_RUN;
+ csrLocInst.bPwrModeRsp = FALSE;
+ csrLocInst.bVerRsp = FALSE;
+
}
else
{
@@ -137,9 +140,6 @@
memset(pLocInst->serialBuf, 0 , MAX_SERIAL_BUF_LEN);
memset(pLocInst->serialPkt, 0 , MAX_SERIAL_PKT_LEN);
- pLocInst->isOspHeader = FALSE;
- pLocInst->isNmeaHeader = FALSE;
-
pLocInst->checksum = 0;
pLocInst->msgSize = 0;
pLocInst->decodeIndex = 0;
@@ -175,14 +175,10 @@
break;
default:
/* Discard received data */
- pLocInst->out = pLocInst->in;
+ //pLocInst->out = pLocInst->in;
break;
}
}
- else
- {
- wait_ms(1);
- }
}
void CsrLocation::_CsrLocDetProtoOsp(CsrUint8 data)
@@ -420,6 +416,8 @@
pLocInst->protoState = PROTO_STATE_DET_OK;
pLocInst->appEventCb(CSR_LOC_EVENT_START_RESULT, 0);
}
+
+// pLocInst->bRawOspPktReady = TRUE;
_CsrLocProcessRawOspPkt();
pLocInst->protoDetState = STATE_START1;
}
@@ -446,6 +444,12 @@
CsrUint32 msgSize;
CsrResult result;
+// if(!pLocInst->bRawOspPktReady)
+// {
+// return;
+// }
+
+// pLocInst->bRawOspPktReady = FALSE;
msgSize = _CsrLocCalcMsgSize();
if(msgSize > 0)
{
@@ -734,21 +738,29 @@
break;
case OSP_MSG_HW_CONFIG_REQ:
CSR_LOG_INFO("hw config req.\r\n");
- if(csrLocInst.pwrMode == PWR_PTF)
- {
+ if(!csrLocInst.bVerRsp);
+ {
_CsrLocSendData(SEND_DATA_TYPE_OSP_VER_REQ);
- _CsrLocSendData(SEND_DATA_TYPE_OSP_LPM_REQ);
}
- else
+
+ if(!csrLocInst.bPwrModeRsp)
{
- _CsrLocSendData(SEND_DATA_TYPE_OSP_FPM_REQ);
- _CsrLocSendData(SEND_DATA_TYPE_OSP_VER_REQ);
+ if(csrLocInst.pwrMode == PWR_PTF)
+ {
+ _CsrLocSendData(SEND_DATA_TYPE_OSP_LPM_REQ);
+ }
+ else
+ {
+ _CsrLocSendData(SEND_DATA_TYPE_OSP_FPM_REQ);
+ }
}
break;
case OSP_MSG_PWR_MODE_LPM_RSP:
+ csrLocInst.bPwrModeRsp = TRUE;
CSR_LOG_INFO("lpm response.\r\n");
break;
case OSP_MSG_PWR_MODE_FPM_RSP:
+ csrLocInst.bPwrModeRsp = TRUE;
CSR_LOG_INFO("fpm response.\r\n");
break;
default:
@@ -770,7 +782,7 @@
pLocInst->in &= (MAX_SERIAL_BUF_LEN-1);
if(pLocInst->in == pLocInst->out)
{
- CSR_LOG_INFO("rx overwritten.\r\n");
+ CSR_LOG_INFO("rx overwritten %d %d.\r\n", pLocInst->in, pLocInst->out);
}
}
@@ -815,7 +827,6 @@
{
for (i = 0; i < size; i++)
{
- while(pLocInst->pSerialLoc->writeable() == 0) {}
pLocInst->pSerialLoc->putc(pData[i]);
}
}
--- a/CsrLocation.h Mon Mar 24 08:23:25 2014 +0000
+++ b/CsrLocation.h Tue Mar 25 05:26:26 2014 +0000
@@ -296,7 +296,7 @@
/** Debug serial port to print debug information */
Serial *pSerialDebug;
/** location serail port to communicate between mbed host side and location chip */
- Serial *pSerialLoc;
+ 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 */
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 */
@@ -315,13 +315,13 @@
typedef struct CsrLocInst
{
CsrBool bStopFlag;
+ CsrBool bPwrModeRsp;
+ CsrBool bVerRsp;
eCsrLocState locState;
eProtoState protoState;
ePowerMode pwrMode;
CsrUint32 baudRate;
- CsrBool isOspHeader;
- CsrBool isNmeaHeader;
CsrInt32 computedCheckSum;
CsrInt32 checksum;
CsrInt32 msgSize;
@@ -334,14 +334,14 @@
tLocSvStatus svStatus; /* 2 kind of messages contribute the svStaus */
Serial *pSerialDebug;
- Serial *pSerialLoc;
+ 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 */
- CsrUint16 in;
- CsrUint16 out;
+ CsrUint32 in;
+ CsrUint32 out;
csr_app_output_callback appOutCb;
csr_app_event_callback appEventCb;

GPS mbed Shield