From df737bb92e7ff5f5c7495c06d0e231338805a86c Mon Sep 17 00:00:00 2001
From: guanjiao <sqrgj@163.com>
Date: 星期三, 16 五月 2018 23:19:20 +0800
Subject: [PATCH] 从工程中删除platform中相关文件

---
 源码/核心板/Src/main.c                           |    3 
 源码/核心板/Src/ExternalDevices/dw_driver.c      |   64 +++++++++
 源码/核心板/Src/OnChipDevices/Rcc_Nvic_Systick.h |    2 
 源码/核心板/MDK-ARM/Project.uvprojx              |   90 +-----------
 源码/核心板/Src/OnChipDevices/Spi.c              |  104 ++++++++++++++
 源码/核心板/MDK-ARM/Project.uvoptx               |   74 +---------
 源码/核心板/Src/ExternalDevices/dw_driver.h      |    3 
 源码/核心板/Src/OnChipDevices/Rcc_Nvic_Systick.c |   20 ++
 源码/核心板/Src/decadriver/deca_device.c         |    3 
 9 files changed, 211 insertions(+), 152 deletions(-)

diff --git "a/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/MDK-ARM/Project.uvoptx" "b/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/MDK-ARM/Project.uvoptx"
index 9470837..d32e60d 100644
--- "a/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/MDK-ARM/Project.uvoptx"
+++ "b/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/MDK-ARM/Project.uvoptx"
@@ -101,8 +101,6 @@
         <sRunDeb>0</sRunDeb>
         <sLrtime>0</sLrtime>
         <bEvRecOn>1</bEvRecOn>
-        <bSchkAxf>0</bSchkAxf>
-        <bTchkAxf>0</bTchkAxf>
         <nTsel>1</nTsel>
         <sDll></sDll>
         <sDllPa></sDllPa>
@@ -210,10 +208,6 @@
       <pszMrule></pszMrule>
       <pSingCmds></pSingCmds>
       <pMultCmds></pMultCmds>
-      <pMisraNamep></pMisraNamep>
-      <pszMrulep></pszMrulep>
-      <pSingCmdsp></pSingCmdsp>
-      <pMultCmdsp></pMultCmdsp>
     </TargetOption>
   </Target>
 
@@ -297,8 +291,6 @@
         <sRunDeb>0</sRunDeb>
         <sLrtime>0</sLrtime>
         <bEvRecOn>1</bEvRecOn>
-        <bSchkAxf>0</bSchkAxf>
-        <bTchkAxf>0</bTchkAxf>
         <nTsel>1</nTsel>
         <sDll></sDll>
         <sDllPa></sDllPa>
@@ -406,10 +398,6 @@
       <pszMrule></pszMrule>
       <pSingCmds></pSingCmds>
       <pMultCmds></pMultCmds>
-      <pMisraNamep></pMisraNamep>
-      <pszMrulep></pszMrulep>
-      <pSingCmdsp></pSingCmdsp>
-      <pMultCmdsp></pMultCmdsp>
     </TargetOption>
   </Target>
 
@@ -493,8 +481,6 @@
         <sRunDeb>0</sRunDeb>
         <sLrtime>0</sLrtime>
         <bEvRecOn>1</bEvRecOn>
-        <bSchkAxf>0</bSchkAxf>
-        <bTchkAxf>0</bTchkAxf>
         <nTsel>1</nTsel>
         <sDll></sDll>
         <sDllPa></sDllPa>
@@ -602,10 +588,6 @@
       <pszMrule></pszMrule>
       <pSingCmds></pSingCmds>
       <pMultCmds></pMultCmds>
-      <pMisraNamep></pMisraNamep>
-      <pszMrulep></pszMrulep>
-      <pSingCmdsp></pSingCmdsp>
-      <pMultCmdsp></pMultCmdsp>
     </TargetOption>
   </Target>
 
@@ -689,8 +671,6 @@
         <sRunDeb>0</sRunDeb>
         <sLrtime>0</sLrtime>
         <bEvRecOn>1</bEvRecOn>
-        <bSchkAxf>0</bSchkAxf>
-        <bTchkAxf>0</bTchkAxf>
         <nTsel>1</nTsel>
         <sDll></sDll>
         <sDllPa></sDllPa>
@@ -798,10 +778,6 @@
       <pszMrule></pszMrule>
       <pSingCmds></pSingCmds>
       <pMultCmds></pMultCmds>
-      <pMisraNamep></pMisraNamep>
-      <pszMrulep></pszMrulep>
-      <pSingCmdsp></pSingCmdsp>
-      <pMultCmdsp></pMultCmdsp>
     </TargetOption>
   </Target>
 
@@ -885,8 +861,6 @@
         <sRunDeb>0</sRunDeb>
         <sLrtime>0</sLrtime>
         <bEvRecOn>1</bEvRecOn>
-        <bSchkAxf>0</bSchkAxf>
-        <bTchkAxf>0</bTchkAxf>
         <nTsel>1</nTsel>
         <sDll></sDll>
         <sDllPa></sDllPa>
@@ -994,10 +968,6 @@
       <pszMrule></pszMrule>
       <pSingCmds></pSingCmds>
       <pMultCmds></pMultCmds>
-      <pMisraNamep></pMisraNamep>
-      <pszMrulep></pszMrulep>
-      <pSingCmdsp></pSingCmdsp>
-      <pMultCmdsp></pMultCmdsp>
     </TargetOption>
   </Target>
 
@@ -1081,8 +1051,6 @@
         <sRunDeb>0</sRunDeb>
         <sLrtime>0</sLrtime>
         <bEvRecOn>1</bEvRecOn>
-        <bSchkAxf>0</bSchkAxf>
-        <bTchkAxf>0</bTchkAxf>
         <nTsel>3</nTsel>
         <sDll></sDll>
         <sDllPa></sDllPa>
@@ -1245,10 +1213,6 @@
       <pszMrule></pszMrule>
       <pSingCmds></pSingCmds>
       <pMultCmds></pMultCmds>
-      <pMisraNamep></pMisraNamep>
-      <pszMrulep></pszMrulep>
-      <pSingCmdsp></pSingCmdsp>
-      <pMultCmdsp></pMultCmdsp>
       <DebugDescription>
         <Enable>1</Enable>
         <EnableLog>0</EnableLog>
@@ -1675,32 +1639,8 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\Src\platform\deca_spi.c</PathWithFileName>
-      <FilenameWithoutPath>deca_spi.c</FilenameWithoutPath>
-      <RteFlg>0</RteFlg>
-      <bShared>0</bShared>
-    </File>
-    <File>
-      <GroupNumber>5</GroupNumber>
-      <FileNumber>33</FileNumber>
-      <FileType>1</FileType>
-      <tvExp>0</tvExp>
-      <tvExpOptDlg>0</tvExpOptDlg>
-      <bDave2>0</bDave2>
-      <PathWithFileName>..\Src\platform\deca_sleep.c</PathWithFileName>
-      <FilenameWithoutPath>deca_sleep.c</FilenameWithoutPath>
-      <RteFlg>0</RteFlg>
-      <bShared>0</bShared>
-    </File>
-    <File>
-      <GroupNumber>5</GroupNumber>
-      <FileNumber>34</FileNumber>
-      <FileType>1</FileType>
-      <tvExp>0</tvExp>
-      <tvExpOptDlg>0</tvExpOptDlg>
-      <bDave2>0</bDave2>
-      <PathWithFileName>..\Src\platform\deca_mutex.c</PathWithFileName>
-      <FilenameWithoutPath>deca_mutex.c</FilenameWithoutPath>
+      <PathWithFileName>..\Src\platform\port.c</PathWithFileName>
+      <FilenameWithoutPath>port.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
@@ -1714,7 +1654,7 @@
     <RteFlg>0</RteFlg>
     <File>
       <GroupNumber>6</GroupNumber>
-      <FileNumber>35</FileNumber>
+      <FileNumber>33</FileNumber>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -1726,7 +1666,7 @@
     </File>
     <File>
       <GroupNumber>6</GroupNumber>
-      <FileNumber>36</FileNumber>
+      <FileNumber>34</FileNumber>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -1738,7 +1678,7 @@
     </File>
     <File>
       <GroupNumber>6</GroupNumber>
-      <FileNumber>37</FileNumber>
+      <FileNumber>35</FileNumber>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -1758,7 +1698,7 @@
     <RteFlg>0</RteFlg>
     <File>
       <GroupNumber>7</GroupNumber>
-      <FileNumber>38</FileNumber>
+      <FileNumber>36</FileNumber>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -1770,7 +1710,7 @@
     </File>
     <File>
       <GroupNumber>7</GroupNumber>
-      <FileNumber>39</FileNumber>
+      <FileNumber>37</FileNumber>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
diff --git "a/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/MDK-ARM/Project.uvprojx" "b/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/MDK-ARM/Project.uvprojx"
index 3d410e6..b824829 100644
--- "a/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/MDK-ARM/Project.uvprojx"
+++ "b/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/MDK-ARM/Project.uvprojx"
@@ -10,7 +10,6 @@
       <TargetName>STM32100E-EVAL</TargetName>
       <ToolsetNumber>0x4</ToolsetNumber>
       <ToolsetName>ARM-ADS</ToolsetName>
-      <uAC6>0</uAC6>
       <TargetOption>
         <TargetCommonOption>
           <Device>STM32F100ZE</Device>
@@ -555,19 +554,9 @@
           <GroupName>platform</GroupName>
           <Files>
             <File>
-              <FileName>deca_spi.c</FileName>
+              <FileName>port.c</FileName>
               <FileType>1</FileType>
-              <FilePath>..\Src\platform\deca_spi.c</FilePath>
-            </File>
-            <File>
-              <FileName>deca_sleep.c</FileName>
-              <FileType>1</FileType>
-              <FilePath>..\Src\platform\deca_sleep.c</FilePath>
-            </File>
-            <File>
-              <FileName>deca_mutex.c</FileName>
-              <FileType>1</FileType>
-              <FilePath>..\Src\platform\deca_mutex.c</FilePath>
+              <FilePath>..\Src\platform\port.c</FilePath>
             </File>
           </Files>
         </Group>
@@ -612,7 +601,6 @@
       <TargetName>STM3210E-EVAL_XL</TargetName>
       <ToolsetNumber>0x4</ToolsetNumber>
       <ToolsetName>ARM-ADS</ToolsetName>
-      <uAC6>0</uAC6>
       <TargetOption>
         <TargetCommonOption>
           <Device>STM32F103ZG</Device>
@@ -1157,19 +1145,9 @@
           <GroupName>platform</GroupName>
           <Files>
             <File>
-              <FileName>deca_spi.c</FileName>
+              <FileName>port.c</FileName>
               <FileType>1</FileType>
-              <FilePath>..\Src\platform\deca_spi.c</FilePath>
-            </File>
-            <File>
-              <FileName>deca_sleep.c</FileName>
-              <FileType>1</FileType>
-              <FilePath>..\Src\platform\deca_sleep.c</FilePath>
-            </File>
-            <File>
-              <FileName>deca_mutex.c</FileName>
-              <FileType>1</FileType>
-              <FilePath>..\Src\platform\deca_mutex.c</FilePath>
+              <FilePath>..\Src\platform\port.c</FilePath>
             </File>
           </Files>
         </Group>
@@ -1214,7 +1192,6 @@
       <TargetName>STM32100B-EVAL</TargetName>
       <ToolsetNumber>0x4</ToolsetNumber>
       <ToolsetName>ARM-ADS</ToolsetName>
-      <uAC6>0</uAC6>
       <TargetOption>
         <TargetCommonOption>
           <Device>STM32F102CB</Device>
@@ -1759,19 +1736,9 @@
           <GroupName>platform</GroupName>
           <Files>
             <File>
-              <FileName>deca_spi.c</FileName>
+              <FileName>port.c</FileName>
               <FileType>1</FileType>
-              <FilePath>..\Src\platform\deca_spi.c</FilePath>
-            </File>
-            <File>
-              <FileName>deca_sleep.c</FileName>
-              <FileType>1</FileType>
-              <FilePath>..\Src\platform\deca_sleep.c</FilePath>
-            </File>
-            <File>
-              <FileName>deca_mutex.c</FileName>
-              <FileType>1</FileType>
-              <FilePath>..\Src\platform\deca_mutex.c</FilePath>
+              <FilePath>..\Src\platform\port.c</FilePath>
             </File>
           </Files>
         </Group>
@@ -1816,7 +1783,6 @@
       <TargetName>STM3210C-EVAL</TargetName>
       <ToolsetNumber>0x4</ToolsetNumber>
       <ToolsetName>ARM-ADS</ToolsetName>
-      <uAC6>0</uAC6>
       <TargetOption>
         <TargetCommonOption>
           <Device>STM32F107VC</Device>
@@ -2361,19 +2327,9 @@
           <GroupName>platform</GroupName>
           <Files>
             <File>
-              <FileName>deca_spi.c</FileName>
+              <FileName>port.c</FileName>
               <FileType>1</FileType>
-              <FilePath>..\Src\platform\deca_spi.c</FilePath>
-            </File>
-            <File>
-              <FileName>deca_sleep.c</FileName>
-              <FileType>1</FileType>
-              <FilePath>..\Src\platform\deca_sleep.c</FilePath>
-            </File>
-            <File>
-              <FileName>deca_mutex.c</FileName>
-              <FileType>1</FileType>
-              <FilePath>..\Src\platform\deca_mutex.c</FilePath>
+              <FilePath>..\Src\platform\port.c</FilePath>
             </File>
           </Files>
         </Group>
@@ -2418,7 +2374,6 @@
       <TargetName>STM3210E-EVAL</TargetName>
       <ToolsetNumber>0x4</ToolsetNumber>
       <ToolsetName>ARM-ADS</ToolsetName>
-      <uAC6>0</uAC6>
       <TargetOption>
         <TargetCommonOption>
           <Device>STM32F103ZE</Device>
@@ -2963,19 +2918,9 @@
           <GroupName>platform</GroupName>
           <Files>
             <File>
-              <FileName>deca_spi.c</FileName>
+              <FileName>port.c</FileName>
               <FileType>1</FileType>
-              <FilePath>..\Src\platform\deca_spi.c</FilePath>
-            </File>
-            <File>
-              <FileName>deca_sleep.c</FileName>
-              <FileType>1</FileType>
-              <FilePath>..\Src\platform\deca_sleep.c</FilePath>
-            </File>
-            <File>
-              <FileName>deca_mutex.c</FileName>
-              <FileType>1</FileType>
-              <FilePath>..\Src\platform\deca_mutex.c</FilePath>
+              <FilePath>..\Src\platform\port.c</FilePath>
             </File>
           </Files>
         </Group>
@@ -3021,7 +2966,6 @@
       <ToolsetNumber>0x4</ToolsetNumber>
       <ToolsetName>ARM-ADS</ToolsetName>
       <pCCUsed>5060422::V5.06 update 4 (build 422)::ARMCC</pCCUsed>
-      <uAC6>0</uAC6>
       <TargetOption>
         <TargetCommonOption>
           <Device>STM32F103T8</Device>
@@ -3566,19 +3510,9 @@
           <GroupName>platform</GroupName>
           <Files>
             <File>
-              <FileName>deca_spi.c</FileName>
+              <FileName>port.c</FileName>
               <FileType>1</FileType>
-              <FilePath>..\Src\platform\deca_spi.c</FilePath>
-            </File>
-            <File>
-              <FileName>deca_sleep.c</FileName>
-              <FileType>1</FileType>
-              <FilePath>..\Src\platform\deca_sleep.c</FilePath>
-            </File>
-            <File>
-              <FileName>deca_mutex.c</FileName>
-              <FileType>1</FileType>
-              <FilePath>..\Src\platform\deca_mutex.c</FilePath>
+              <FilePath>..\Src\platform\port.c</FilePath>
             </File>
           </Files>
         </Group>
diff --git "a/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/ExternalDevices/dw_driver.c" "b/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/ExternalDevices/dw_driver.c"
index 62b7c23..6c030b9 100644
--- "a/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/ExternalDevices/dw_driver.c"
+++ "b/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/ExternalDevices/dw_driver.c"
@@ -1,5 +1,4 @@
 #include "dw_driver.h"
-#include "deca_sleep.h"
 
 void Reset_DW1000(void)
 {
@@ -54,3 +53,66 @@
     EXTI_Init(&EXTI_InitStructure);
 
 }
+
+//读取外部中断状态
+
+
+//使能外部中断
+void Enable_Ext_IRQ(void)
+{
+	NVIC_EnableIRQ(DECAIRQ_EXTI_IRQn);
+}
+
+//禁止外部中断
+void Disable_Ext_IRQ(void)
+{
+	NVIC_DisnableIRQ(DECAIRQ_EXTI_IRQn);
+}
+
+/*! ------------------------------------------------------------------------------------------------------------------
+ * Function: decamutexon()
+ *
+ * Description: This function should disable interrupts. This is called at the start of a critical section
+ * It returns the irq state before disable, this value is used to re-enable in decamutexoff call
+ *
+ * Note: The body of this function is defined in deca_mutex.c and is platform specific
+ *
+ * input parameters:
+ *
+ * output parameters
+ *
+ * returns the state of the DW1000 interrupt
+ */
+decaIrqStatus_t decamutexon(void)
+{
+    decaIrqStatus_t s = port_GetEXT_IRQStatus();
+
+    if(s)
+    {
+        port_DisableEXT_IRQ(); //disable the external interrupt line
+    }
+    return s ;   // return state before disable, value is used to re-enable in decamutexoff call
+}
+
+/*! ------------------------------------------------------------------------------------------------------------------
+ * Function: decamutexoff()
+ *
+ * Description: This function should re-enable interrupts, or at least restore their state as returned(&saved) by decamutexon
+ * This is called at the end of a critical section
+ *
+ * Note: The body of this function is defined in deca_mutex.c and is platform specific
+ *
+ * input parameters:
+ * @param s - the state of the DW1000 interrupt as returned by decamutexon
+ *
+ * output parameters
+ *
+ * returns the state of the DW1000 interrupt
+ */
+void decamutexoff(decaIrqStatus_t s)        // put a function here that re-enables the interrupt at the end of the critical section
+{
+    if(s)   //need to check the port state as we can't use level sensitive interrupt on the STM ARM
+    {
+        port_EnableEXT_IRQ();
+    }
+}
\ No newline at end of file
diff --git "a/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/ExternalDevices/dw_driver.h" "b/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/ExternalDevices/dw_driver.h"
index 89bc1bd..85188ab 100644
--- "a/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/ExternalDevices/dw_driver.h"
+++ "b/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/ExternalDevices/dw_driver.h"
@@ -3,7 +3,7 @@
 #define __DW_DRIVER_H__
 
 #include "stm32f10x.h"
-
+#include "Rcc_Nvic_Systick.h"
 
 #define DW1000_RSTn					GPIO_Pin_1
 #define DW1000_RSTn_GPIO			GPIOA
@@ -15,6 +15,7 @@
 #define DECAIRQ_EXTI_PORT           GPIO_PortSourceGPIOA
 #define DECAIRQ_EXTI_PIN            GPIO_PinSource2
 
+#define deca_sleep(...)				delay_ms(__VA_ARGS__)
 
 void Reset_DW1000(void);
 
diff --git "a/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/OnChipDevices/Rcc_Nvic_Systick.c" "b/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/OnChipDevices/Rcc_Nvic_Systick.c"
index cd517b6..83c3d05 100644
--- "a/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/OnChipDevices/Rcc_Nvic_Systick.c"
+++ "b/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/OnChipDevices/Rcc_Nvic_Systick.c"
@@ -70,3 +70,23 @@
     return 0;
 	
 }
+
+void delay_us(uint32_t nTimer)  
+{  
+    uint32_t i=0;  
+    for(i=0;i<nTimer;i++){  
+        __NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();
+		__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();
+		__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();  
+        __NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();
+		__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();
+		__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();  
+        __NOP();__NOP();__NOP();__NOP(); 
+    }  
+}
+
+void delay_ms(uint32_t nTimer)  
+{  
+    uint32_t i=1000*nTimer;  
+    delay_us(i);  
+}  
diff --git "a/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/OnChipDevices/Rcc_Nvic_Systick.h" "b/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/OnChipDevices/Rcc_Nvic_Systick.h"
index 435b318..9ddbb98 100644
--- "a/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/OnChipDevices/Rcc_Nvic_Systick.h"
+++ "b/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/OnChipDevices/Rcc_Nvic_Systick.h"
@@ -7,5 +7,7 @@
 void Rcc_Init(void);
 void Nvic_Init(void);
 int Systick_Init(void);
+void delay_us(uint32_t nTimer);
+void delay_ms(uint32_t nTimer);
 
 #endif
diff --git "a/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/OnChipDevices/Spi.c" "b/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/OnChipDevices/Spi.c"
index 04ee781..c2e4ab4 100644
--- "a/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/OnChipDevices/Spi.c"
+++ "b/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/OnChipDevices/Spi.c"
@@ -71,3 +71,107 @@
     /* Write to SPIx CR1 */
     SPIx->CR1 = tmpreg;
 }
+
+/*! ------------------------------------------------------------------------------------------------------------------
+ * Function: writetospi()
+ *
+ * Low level abstract function to write to the SPI
+ * Takes two separate byte buffers for write header and write data
+ * returns 0 for success, or -1 for error
+ */
+int writetospi_serial
+(
+    uint16_t       headerLength,
+    const uint8_t *headerBuffer,
+    uint32_t       bodylength,
+    const uint8_t *bodyBuffer
+)
+{
+
+    int i = 0;
+
+    decaIrqStatus_t  stat ;
+
+    stat = decamutexon() ;
+
+    SPIx_CS_GPIO->BRR = SPIx_CS;
+
+    for(i = 0; i < headerLength; i++)
+    {
+        SPIx->DR = headerBuffer[i];
+
+        while ((SPIx->SR & SPI_I2S_FLAG_RXNE) == (uint16_t)RESET);
+
+        SPIx->DR ;
+    }
+
+    for(i = 0; i < bodylength; i++)
+    {
+        SPIx->DR = bodyBuffer[i];
+
+        while((SPIx->SR & SPI_I2S_FLAG_RXNE) == (uint16_t)RESET);
+
+        SPIx->DR ;
+    }
+
+    SPIx_CS_GPIO->BSRR = SPIx_CS;
+
+    decamutexoff(stat) ;
+
+    return 0;
+} // end writetospi()
+
+
+/*! ------------------------------------------------------------------------------------------------------------------
+ * Function: readfromspi()
+ *
+ * Low level abstract function to read from the SPI
+ * Takes two separate byte buffers for write header and read data
+ * returns the offset into read buffer where first byte of read data may be found,
+ * or returns -1 if there was an error
+ */
+int readfromspi_serial
+(
+    uint16_t       headerLength,
+    const uint8_t *headerBuffer,
+    uint32_t       readlength,
+    uint8_t       *readBuffer
+)
+{
+
+    int i = 0;
+
+    decaIrqStatus_t  stat ;
+
+    stat = decamutexon() ;
+
+    /* Wait for SPIx Tx buffer empty */
+    //while (port_SPIx_busy_sending());
+
+    SPIx_CS_GPIO->BRR = SPIx_CS;
+
+    for(i = 0; i < headerLength; i++)
+    {
+        SPIx->DR = headerBuffer[i];
+
+        while((SPIx->SR & SPI_I2S_FLAG_RXNE) == (uint16_t)RESET);
+
+        readBuffer[0] = SPIx->DR ; // Dummy read as we write the header
+    }
+
+    for(i = 0; i < readlength; i++)
+    {
+        SPIx->DR = 0;  // Dummy write as we read the message body
+
+        while((SPIx->SR & SPI_I2S_FLAG_RXNE) == (uint16_t)RESET);
+
+        readBuffer[i] = SPIx->DR ;//port_SPIx_receive_data(); //this clears RXNE bit
+    }
+
+    SPIx_CS_GPIO->BSRR = SPIx_CS;
+
+    decamutexoff(stat) ;
+
+    return 0;
+} // end readfromspi()
+
diff --git "a/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/decadriver/deca_device.c" "b/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/decadriver/deca_device.c"
index 93587d1..6d77e17 100644
--- "a/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/decadriver/deca_device.c"
+++ "b/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/decadriver/deca_device.c"
@@ -14,8 +14,7 @@
 #include "deca_param_types.h"
 #include "deca_regs.h"
 #include "deca_device_api.h"
-#include "deca_sleep.h"
-#include "port.h"
+#include "dw_driver.h"
 
 // Defines for enable_clocks function
 #define FORCE_SYS_XTI  0
diff --git "a/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/main.c" "b/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/main.c"
index 22f9c37..af5d8de 100644
--- "a/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/main.c"
+++ "b/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/main.c"
@@ -21,9 +21,6 @@
 #include <stdio.h>
 #include "deca_device_api.h"
 #include "deca_regs.h"
-#include "deca_sleep.h"
-#include "lcd.h"
-#include "port.h"
 #include "Rcc_Nvic_Systick.h"
 #include "Usart.h"
 #include "Spi.h"

--
Gitblit v1.9.3