From 13fa2c6eaab3b3ee51d447d2549f6e09c821dc60 Mon Sep 17 00:00:00 2001
From: zhyinch <zhyinch@gmail.com>
Date: 星期一, 20 十二月 2021 12:14:04 +0800
Subject: [PATCH] 1

---
 Src/decadriver/deca_device.c |   30 +++++++++++++++++++++++++++---
 1 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/Src/decadriver/deca_device.c b/Src/decadriver/deca_device.c
index f5269c5..3208299 100644
--- a/Src/decadriver/deca_device.c
+++ b/Src/decadriver/deca_device.c
@@ -153,9 +153,11 @@
 #define VBAT_ADDRESS   (0x08)
 #define VTEMP_ADDRESS  (0x09)
 #define XTRIM_ADDRESS  (0x1E)
-
+uint8_t module_power;
+uint32_t power_temp,power_input;
 int dwt_initialise(uint16_t config)
 {
+		
     uint8_t plllockdetect = EC_CTRL_PLLLCK;
     uint16_t otp_addr = 0;
     uint32_t ldo_tune = 0;
@@ -177,7 +179,16 @@
     }
 
     _dwt_enableclocks(FORCE_SYS_XTI); // NOTE: set system clock to XTI - this is necessary to make sure the values read by _dwt_otpread are reliable
-    dwt_write32bitreg(TX_POWER_ID, 0x1f1f1f1f);
+	 dw1000local.deviceID =  dwt_readdevid() ;
+		if(module_power>36)
+		{
+			power_temp =(module_power-36);
+		}else{
+			power_temp = ((6-(module_power/6))<<5)|(module_power%6);
+		}
+	power_input= power_temp<<24|power_temp<<16|power_temp<<8|power_temp;
+	dwt_write32bitreg(TX_POWER_ID, power_input);
+		dw1000local.deviceID =  dwt_readdevid() ;
     // Configure the CPLL lock detect
     dwt_writetodevice(EXT_SYNC_ID, EC_CTRL_OFFSET, 1, &plllockdetect); 
     // Read OTP revision number
@@ -185,6 +196,7 @@
     dw1000local.otprev = (otp_addr >> 8) & 0xff;			// OTP revision is next byte
     // Load LDO tune from OTP and kick it if there is a value actually programmed.
     ldo_tune = _dwt_otpread(LDOTUNE_ADDRESS);
+		dw1000local.deviceID =  dwt_readdevid() ;
     if((ldo_tune & 0xFF) != 0)
     {
         uint8_t ldok = OTP_SF_LDO_KICK;
@@ -2124,7 +2136,19 @@
     dw1000local.sysCFGreg |= SYS_CFG_AUTOACK;
     dwt_write32bitreg(SYS_CFG_ID, dw1000local.sysCFGreg) ;
 }
-
+void dwt_enableautorxeanble(uint8_t enable)
+{
+    // Set auto ACK reply delay
+    
+    // Enable auto ACK
+	if(enable)
+	{
+    dw1000local.sysCFGreg |= SYS_CFG_RXAUTR;
+	}else{
+		dw1000local.sysCFGreg&=0xDFFFFFFF;
+	}
+    dwt_write32bitreg(SYS_CFG_ID, dw1000local.sysCFGreg) ;
+}
 /*! ------------------------------------------------------------------------------------------------------------------
  * @fn dwt_setdblrxbuffmode()
  *

--
Gitblit v1.9.3