Csr location demo application shows location and satellite information, which supports H13467 + ST F103RB/NXP LCP1549 boards now.
Dependencies: CsrLocation mbed GPSProvider
Fork of CsrLocationDemo by
Revision 9:87d1555b6219, committed 2014-08-05
- Comitter:
- zhjcpi
- Date:
- Tue Aug 05 06:22:37 2014 +0000
- Parent:
- 8:e2c9664bfcb4
- Child:
- 10:8dbf356c44ec
- Commit message:
- Add button support to triger position report in PTF mode.
Changed in this revision
| CsrLocation.lib | Show annotated file Show diff for this revision Revisions of this file |
| CsrLocationDemo.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/CsrLocation.lib Mon Aug 04 10:15:40 2014 +0000 +++ b/CsrLocation.lib Tue Aug 05 06:22:37 2014 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/zhjcpi/code/CsrLocation/#aed3c66b39d9 +http://mbed.org/users/zhjcpi/code/CsrLocation/#1fde78f27d5b
--- a/CsrLocationDemo.cpp Mon Aug 04 10:15:40 2014 +0000
+++ b/CsrLocationDemo.cpp Tue Aug 05 06:22:37 2014 +0000
@@ -29,11 +29,16 @@
APP_CMD_ONOFF_ON, // Debug command, pull onoff pin high level
APP_CMD_ONOFF_OFF, // Debug command, pull onoff pin low level
APP_CMD_RESET_ON, // Debug command, pull reset pin high level
- APP_CMD_RESET_OFF // Debug command, pull reset pin low level
+ APP_CMD_RESET_OFF, // Debug command, pull reset pin low level
+ APP_CMD_PINTEST_ON, // Debug command, pull test pin high level
+ APP_CMD_PINTEST_OFF, // Debug command, pull test pin low level
+ APP_CMD_PINTEST_OFF_ON // Debug command, pull test pin low firstly, then pull high level
+
}eAppCmd;
static void _AppShowCmd(void);
+static void _AppBtnPushed(void);
static void _AppOutputCallback(uint32_t msgId, void * const pMsgData, uint32_t msgLength);
static void _AppEventCallback(eCsrLocEventType event, uint32_t data);
static void _ConsoleRxHandler(void);
@@ -50,13 +55,20 @@
static DigitalOut sPinReset(PINMAP_GPIO_LOC_RESET);
static DigitalOut sLedLocOn(LOC_LED1);
static DigitalOut sLedPosReport(LOC_LED2);
-
+static InterruptIn sBtn(PINMAP_GPIO_BTN);
+static DigitalOut sPinTest(D10);
int main(void)
{
CsrLocation *pCsrLoc;
tCsrLocConfig locConfig;
+ sLedLocOn = 0;
+ sLedPosReport = 0;
+ sPinTest = 1;
+ sBtn.mode(PullUp);
+ sBtn.fall(&_AppBtnPushed);
+
/* initialize the debug serial port */
sSerialDebug.baud(APP_DBG_PORT_BAUD);
sSerialDebug.attach(&_ConsoleRxHandler);
@@ -95,22 +107,12 @@
break;
case APP_CMD_START:
sAppCmd = APP_CMD_IDLE;
- if(pCsrLoc->CsrLocGetState() == CSR_LOC_STATE_RUN)
- {
- CSR_APP_LOG_INFO("Cannot execute this command as location is in running state, please stop location firstly.\r\n");
- break;
- }
CSR_APP_LOG_INFO("start location.\r\n");
sLedLocOn = 1;
pCsrLoc->CsrLocStart(sPwrMode, sProto);
break;
case APP_CMD_STOP:
sAppCmd = APP_CMD_IDLE;
- if(pCsrLoc->CsrLocGetState() == CSR_LOC_STATE_IDLE)
- {
- CSR_APP_LOG_INFO("Cannot execute this command as location is not in running state.\r\n");
- break;
- }
CSR_APP_LOG_INFO("stop location.\r\n");
sLedLocOn = 0;
pCsrLoc->CsrLocStop();
@@ -152,79 +154,52 @@
sAppCmd = APP_CMD_IDLE;
sPinReset = 0;
break;
- case APP_CMD_PTF_GETPOS:
+ case APP_CMD_PINTEST_ON:
+ CSR_APP_LOG_INFO("test pin on.\r\n");
+ sAppCmd = APP_CMD_IDLE;
+ sPinTest = 1;
+ break;
+ case APP_CMD_PINTEST_OFF:
+ CSR_APP_LOG_INFO("test pin off.\r\n");
sAppCmd = APP_CMD_IDLE;
- if(pCsrLoc->CsrLocGetState() != CSR_LOC_STATE_RUN)
- {
- CSR_APP_LOG_INFO("Cannot execute this command as location is not in running state, please start location in PTF mode firstly.\r\n");
- break;
- }
+ sPinTest = 0;
+ break;
+ case APP_CMD_PINTEST_OFF_ON:
+ CSR_APP_LOG_INFO("test pin off and high.\r\n");
+ sAppCmd = APP_CMD_IDLE;
+ sPinTest = 0;
+ wait_ms(100);
+ sPinTest = 1;
+ break;
+ case APP_CMD_PTF_GETPOS:
CSR_APP_LOG_INFO("lpm get pos.\r\n");
+ sAppCmd = APP_CMD_IDLE;
pCsrLoc->CsrLocLpmGetPos();
break;
case APP_CMD_NMEA:
+ CSR_APP_LOG_INFO("select NMEA protocol.\r\n");
+ sProto = PROTO_NMEA;
sAppCmd = APP_CMD_IDLE;
- if(pCsrLoc->CsrLocGetState() == CSR_LOC_STATE_RUN)
- {
- CSR_APP_LOG_INFO("Cannot execute this command as location is in running state, please stop location firstly.\r\n");
- break;
- }
- if(sPwrMode != PWR_FULL)
- {
- CSR_APP_LOG_INFO("Cannot select NMEA protocol because current lpm is not supported for NMEA protocol, pls switch to FPM firstly.\r\n");
- }
- else
- {
- CSR_APP_LOG_INFO("select NMEA protocol.\r\n");
- sProto = PROTO_NMEA;
- }
break;
case APP_CMD_OSP:
- sAppCmd = APP_CMD_IDLE;
- if(pCsrLoc->CsrLocGetState() == CSR_LOC_STATE_RUN)
- {
- CSR_APP_LOG_INFO("Cannot execute this command as location is in running state, please stop location firstly.\r\n");
- break;
- }
CSR_APP_LOG_INFO("select OSP protocol.\r\n");
sProto = PROTO_OSP;
+ sAppCmd = APP_CMD_IDLE;
break;
case APP_CMD_SWITCH_NMEA:
+ CSR_APP_LOG_INFO("switch to NMEA protocol.\r\n");
sAppCmd = APP_CMD_IDLE;
- if(pCsrLoc->CsrLocGetState() == CSR_LOC_STATE_RUN)
- {
- CSR_APP_LOG_INFO("Cannot execute this command as location is in running state, please stop location firstly.\r\n");
- break;
- }
- CSR_APP_LOG_INFO("switch to NMEA protocol.\r\n");
pCsrLoc->CsrLocDebugSwitch2Nmea();
break;
case APP_CMD_PM_FULL:
+ CSR_APP_LOG_INFO("fpm set.\r\n");
sAppCmd = APP_CMD_IDLE;
- if(pCsrLoc->CsrLocGetState() == CSR_LOC_STATE_RUN)
- {
- CSR_APP_LOG_INFO("Cannot execute this command as location is in running state, please stop location firstly.\r\n");
- break;
- }
- CSR_APP_LOG_INFO("fpm set.\r\n");
sPwrMode = PWR_FULL;
break;
case APP_CMD_PM_PTF:
+ CSR_APP_LOG_INFO("lpm ptf set.\r\n");
sAppCmd = APP_CMD_IDLE;
- if(pCsrLoc->CsrLocGetState() == CSR_LOC_STATE_RUN)
- {
- CSR_APP_LOG_INFO("Cannot execute this command as location is in running state, please stop location firstly.\r\n");
- break;
- }
- if(sProto == PROTO_NMEA)
- {
- CSR_APP_LOG_INFO("Cannot set lpm because LPM is not supported for current NMEA protocol, pls switch to OSP firstly.\r\n");
- }
- else
- {
- CSR_APP_LOG_INFO("lpm ptf set.\r\n");
- sPwrMode = PWR_PTF;
- }
+ sPwrMode = PWR_PTF;
break;
}
}
@@ -244,6 +219,14 @@
}
+static void _AppBtnPushed(void)
+{
+ sAppCmd = APP_CMD_PTF_GETPOS;
+// sLedLocOn = !sLedLocOn;
+// wait_ms(10);
+// sLedLocOn = 0;
+}
+
static void _AppOutputCallback(uint32_t msgId, void * const pMsgData, uint32_t msgLength)
{
switch(msgId)
@@ -252,7 +235,9 @@
{
tLocPosResp *pPosRsp = (tLocPosResp *)pMsgData;
CSR_APP_LOG_INFO("Loc: lat=%f, lon=%f, alt=%f\r\n", pPosRsp->lat, pPosRsp->lon, pPosRsp->alt);
- sLedPosReport = !sLedPosReport;
+ sLedPosReport = 1;
+ wait_ms(10);
+ sLedPosReport = 0;
break;
}
case LOC_OUTPUT_SV_STATUS:
@@ -380,6 +365,18 @@
{
sAppCmd = APP_CMD_RESET_OFF;
}
+ else if(strcmp(pCmd, "pinteston") == 0)
+ {
+ sAppCmd = APP_CMD_PINTEST_ON;
+ }
+ else if(strcmp(pCmd, "pintestoff") == 0)
+ {
+ sAppCmd = APP_CMD_PINTEST_OFF;
+ }
+ else if(strcmp(pCmd, "pintestoffon") == 0)
+ {
+ sAppCmd = APP_CMD_PINTEST_OFF_ON;
+ }
else
{
CSR_APP_LOG_INFO("\r\nUnknown command %s\r\n", pCmd);

GPS mbed Shield