From 57fd1055d8fbe17973be302c365ba0d9c892c31f Mon Sep 17 00:00:00 2001
From: birdyou <qian.yao@jumacc.com>
Date: Tue, 17 May 2016 14:30:02 +0800
Subject: [PATCH] Fixed sensor_tag bug.

Fixed sensor_tag which can not read sensor data.
---
 applications/juma/echo/mdk-arm/echo.uvprojx          | 12 ++----------
 applications/juma/sensor_tag/app.c                   |  4 ++--
 .../juma/sensor_tag/mdk-arm/sensor_tag.uvprojx       |  8 ++++++--
 .../sensor_tag_dma/mdk-arm/sensor_tag_dma.uvprojx    |  8 ++++++--
 system/bsp/cannon_v2/bsp_common.c                    |  4 ++++
 system/main.c                                        |  2 +-
 6 files changed, 21 insertions(+), 17 deletions(-)

diff --git a/applications/juma/echo/mdk-arm/echo.uvprojx b/applications/juma/echo/mdk-arm/echo.uvprojx
index a678f9c..2dfe7a9 100644
--- a/applications/juma/echo/mdk-arm/echo.uvprojx
+++ b/applications/juma/echo/mdk-arm/echo.uvprojx
@@ -10,12 +10,11 @@
       <TargetName>ECHO</TargetName>
       <ToolsetNumber>0x4</ToolsetNumber>
       <ToolsetName>ARM-ADS</ToolsetName>
-      <pCCUsed>5060020::V5.06 (build 20)::ARMCC</pCCUsed>
       <TargetOption>
         <TargetCommonOption>
           <Device>STM32F401RETx</Device>
           <Vendor>STMicroelectronics</Vendor>
-          <PackID>Keil.STM32F4xx_DFP.2.3.0</PackID>
+          <PackID>Keil.STM32F4xx_DFP.2.7.0</PackID>
           <PackURL>http://www.keil.com/pack</PackURL>
           <Cpu>IROM(0x08000000,0x80000) IRAM(0x20000000,0x18000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLE</Cpu>
           <FlashUtilSpec></FlashUtilSpec>
@@ -85,8 +84,6 @@
             <UserProg2Name></UserProg2Name>
             <UserProg1Dos16Mode>0</UserProg1Dos16Mode>
             <UserProg2Dos16Mode>0</UserProg2Dos16Mode>
-            <nStopA1X>0</nStopA1X>
-            <nStopA2X>0</nStopA2X>
           </AfterMake>
           <SelectedForBatchBuild>0</SelectedForBatchBuild>
           <SVCSIdString></SVCSIdString>
@@ -230,7 +227,6 @@
             <useUlib>1</useUlib>
             <EndSel>0</EndSel>
             <uLtcg>0</uLtcg>
-            <nSecure>0</nSecure>
             <RoSelD>3</RoSelD>
             <RwSelD>3</RwSelD>
             <CodeSel>0</CodeSel>
@@ -365,10 +361,6 @@
             <uSurpInc>0</uSurpInc>
             <uC99>1</uC99>
             <useXO>0</useXO>
-            <v6Lang>0</v6Lang>
-            <v6LangP>0</v6LangP>
-            <vShortEn>0</vShortEn>
-            <vShortWch>0</vShortWch>
             <VariousControls>
               <MiscControls>--C99 --gnu  -W#177</MiscControls>
               <Define>STM32F401xE,USE_HAL_DRIVER,USE_STM32F4XX_NUCLEO,ENABLE_SPI_FIX,BLUENRG_MS,RTC_LSE,SENSOR_FIFO,NO_PRINTF,SERVER_ROLE,CANNON_V2</Define>
@@ -734,7 +726,7 @@
           </Files>
         </Group>
         <Group>
-          <GroupName>system/cmiss</GroupName>
+          <GroupName>system/cmsis</GroupName>
           <Files>
             <File>
               <FileName>system_stm32f4xx.c</FileName>
diff --git a/applications/juma/sensor_tag/app.c b/applications/juma/sensor_tag/app.c
index 25d4924..4ba1e46 100644
--- a/applications/juma/sensor_tag/app.c
+++ b/applications/juma/sensor_tag/app.c
@@ -25,7 +25,7 @@ static void read_humidity(void* arg);
 static void read_pressure(void* arg);
 static void read_magenetometer(void* arg);
 static void read_accelerometer(void* arg);
-static void gyroscopic(void* arg);
+static void read_gyroscopic(void* arg);
 static void led_on(void* arg);
 static void led_off(void* arg);
 
@@ -138,7 +138,7 @@ static void read_accelerometer(void* arg)
         ble_device_send(0x04, 6, (uint8_t*)ACC);
     }
 
-    run_after_delay(gyroscopic, NULL, UPDATE_INTERVAL);
+    run_after_delay(read_gyroscopic, NULL, UPDATE_INTERVAL);
 }
 
 static void read_gyroscopic(void* arg)
diff --git a/applications/juma/sensor_tag/mdk-arm/sensor_tag.uvprojx b/applications/juma/sensor_tag/mdk-arm/sensor_tag.uvprojx
index f5af531..7fa628a 100644
--- a/applications/juma/sensor_tag/mdk-arm/sensor_tag.uvprojx
+++ b/applications/juma/sensor_tag/mdk-arm/sensor_tag.uvprojx
@@ -14,6 +14,8 @@
         <TargetCommonOption>
           <Device>STM32F401RETx</Device>
           <Vendor>STMicroelectronics</Vendor>
+          <PackID>Keil.STM32F4xx_DFP.2.7.0</PackID>
+          <PackURL>http://www.keil.com/pack</PackURL>
           <Cpu>IROM(0x08000000,0x80000) IRAM(0x20000000,0x18000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLE</Cpu>
           <FlashUtilSpec></FlashUtilSpec>
           <StartupFile></StartupFile>
@@ -72,6 +74,8 @@
             <UserProg2Name></UserProg2Name>
             <UserProg1Dos16Mode>0</UserProg1Dos16Mode>
             <UserProg2Dos16Mode>0</UserProg2Dos16Mode>
+            <nStopB1X>0</nStopB1X>
+            <nStopB2X>0</nStopB2X>
           </BeforeMake>
           <AfterMake>
             <RunUserProg1>0</RunUserProg1>
@@ -128,6 +132,7 @@
             <RestoreFunctions>1</RestoreFunctions>
             <RestoreToolbox>1</RestoreToolbox>
             <LimitSpeedToRealTime>0</LimitSpeedToRealTime>
+            <RestoreSysVw>1</RestoreSysVw>
           </Simulator>
           <Target>
             <UseTarget>1</UseTarget>
@@ -139,8 +144,7 @@
             <RestoreFunctions>0</RestoreFunctions>
             <RestoreToolbox>1</RestoreToolbox>
             <RestoreTracepoints>1</RestoreTracepoints>
-            <RestoreTracepoints>1</RestoreTracepoints>
-            <RestoreTracepoints>1</RestoreTracepoints>
+            <RestoreSysVw>1</RestoreSysVw>
           </Target>
           <RunDebugAfterBuild>0</RunDebugAfterBuild>
           <TargetSelection>11</TargetSelection>
diff --git a/applications/juma/sensor_tag_dma/mdk-arm/sensor_tag_dma.uvprojx b/applications/juma/sensor_tag_dma/mdk-arm/sensor_tag_dma.uvprojx
index 1e560a5..937dd24 100644
--- a/applications/juma/sensor_tag_dma/mdk-arm/sensor_tag_dma.uvprojx
+++ b/applications/juma/sensor_tag_dma/mdk-arm/sensor_tag_dma.uvprojx
@@ -14,6 +14,8 @@
         <TargetCommonOption>
           <Device>STM32F401RETx</Device>
           <Vendor>STMicroelectronics</Vendor>
+          <PackID>Keil.STM32F4xx_DFP.2.7.0</PackID>
+          <PackURL>http://www.keil.com/pack</PackURL>
           <Cpu>IROM(0x08000000,0x80000) IRAM(0x20000000,0x18000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLE</Cpu>
           <FlashUtilSpec></FlashUtilSpec>
           <StartupFile></StartupFile>
@@ -72,6 +74,8 @@
             <UserProg2Name></UserProg2Name>
             <UserProg1Dos16Mode>0</UserProg1Dos16Mode>
             <UserProg2Dos16Mode>0</UserProg2Dos16Mode>
+            <nStopB1X>0</nStopB1X>
+            <nStopB2X>0</nStopB2X>
           </BeforeMake>
           <AfterMake>
             <RunUserProg1>0</RunUserProg1>
@@ -128,6 +132,7 @@
             <RestoreFunctions>1</RestoreFunctions>
             <RestoreToolbox>1</RestoreToolbox>
             <LimitSpeedToRealTime>0</LimitSpeedToRealTime>
+            <RestoreSysVw>1</RestoreSysVw>
           </Simulator>
           <Target>
             <UseTarget>1</UseTarget>
@@ -139,8 +144,7 @@
             <RestoreFunctions>0</RestoreFunctions>
             <RestoreToolbox>1</RestoreToolbox>
             <RestoreTracepoints>1</RestoreTracepoints>
-            <RestoreTracepoints>1</RestoreTracepoints>
-            <RestoreTracepoints>1</RestoreTracepoints>
+            <RestoreSysVw>1</RestoreSysVw>
           </Target>
           <RunDebugAfterBuild>0</RunDebugAfterBuild>
           <TargetSelection>6</TargetSelection>
diff --git a/system/bsp/cannon_v2/bsp_common.c b/system/bsp/cannon_v2/bsp_common.c
index 01174bd..e983979 100644
--- a/system/bsp/cannon_v2/bsp_common.c
+++ b/system/bsp/cannon_v2/bsp_common.c
@@ -79,6 +79,10 @@ void bsp_init(void)
     /*UART2 init*/
     UART_Init();
     HAL_Delay(1000);
+		/*sensor layer init*/
+		#ifdef SENSOR_FIFO
+		jsensor_sys_init();
+		#endif
     /* Initialize the BlueNRG SPI driver */
     BNRG_SPI_Init();
     /* Initialize the BlueNRG HCI */
diff --git a/system/main.c b/system/main.c
index 4de9a9f..98c6a49 100644
--- a/system/main.c
+++ b/system/main.c
@@ -17,7 +17,7 @@
 
 int main(void)
 {
-  		bsp_init();
+		bsp_init();
     dispatch_init();
     on_ready();
     while(1)