Skip to content
Snippets Groups Projects
Commit 454adee5 authored by David's avatar David
Browse files

added TX RX delay calibration

parent 26571c53
No related branches found
No related tags found
No related merge requests found
......@@ -104,20 +104,20 @@
<File name="src/platform/deca_spi.h" path="src/platform/deca_spi.h" type="1"/>
<File name="Libraries/STM32_USB_Device_Library/Core/src/usbd_ioreq.c" path="Libraries/STM32_USB_Device_Library/Core/src/usbd_ioreq.c" type="1"/>
<File name="Libraries/STM32_USB_Device_Library/Class/cdc/src/usbd_cdc_core.c" path="Libraries/STM32_USB_Device_Library/Class/cdc/src/usbd_cdc_core.c" type="1"/>
<File name="Libraries/STM32_USB_Device_Library/Class/cdc/inc/usbd_cdc_core.h" path="Libraries/STM32_USB_Device_Library/Class/cdc/inc/usbd_cdc_core.h" type="1"/>
<File name="src/usb/usbd_desc.h" path="src/usb/usbd_desc.h" type="1"/>
<File name="Libraries/STM32_USB_Device_Library/Class/cdc/inc/usbd_cdc_core.h" path="Libraries/STM32_USB_Device_Library/Class/cdc/inc/usbd_cdc_core.h" type="1"/>
<File name="src/platform/deca_spi.c" path="src/platform/deca_spi.c" type="1"/>
<File name="src/usb" path="" type="2"/>
<File name="src/decadriver/deca_version.h" path="src/decadriver/deca_version.h" type="1"/>
<File name="Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_flash.c" path="Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_flash.c" type="1"/>
<File name="Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_wwdg.c" path="Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_wwdg.c" type="1"/>
<File name="src/application/instance.c" path="src/application/instance.c" type="1"/>
<File name="Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_wwdg.c" path="Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_wwdg.c" type="1"/>
<File name="Libraries/STM32F10x_StdPeriph_Driver/inc/stm32f10x_dbgmcu.h" path="Libraries/STM32F10x_StdPeriph_Driver/inc/stm32f10x_dbgmcu.h" type="1"/>
<File name="Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_sdio.c" path="Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_sdio.c" type="1"/>
<File name="src/decadriver/deca_device_api.h" path="src/decadriver/deca_device_api.h" type="1"/>
<File name="Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_sdio.c" path="Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_sdio.c" type="1"/>
<File name="Libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x" path="" type="2"/>
<File name="Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_iwdg.c" path="Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_iwdg.c" type="1"/>
<File name="Libraries/STM32F10x_StdPeriph_Driver/inc/stm32f10x_bkp.h" path="Libraries/STM32F10x_StdPeriph_Driver/inc/stm32f10x_bkp.h" type="1"/>
<File name="Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_iwdg.c" path="Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_iwdg.c" type="1"/>
<File name="src/compiler/compiler.h" path="src/compiler/compiler.h" type="1"/>
<File name="Libraries/STM32_USB_OTG_Driver" path="" type="2"/>
<File name="src/platform/deca_mutex.c" path="src/platform/deca_mutex.c" type="1"/>
......@@ -130,12 +130,12 @@
<File name="Libraries/STM32F10x_StdPeriph_Driver/inc/stm32f10x_sdio.h" path="Libraries/STM32F10x_StdPeriph_Driver/inc/stm32f10x_sdio.h" type="1"/>
<File name="Libraries/STM32_USB_OTG_Driver/src/usb_hcd_int.c" path="Libraries/STM32_USB_OTG_Driver/src/usb_hcd_int.c" type="1"/>
<File name="src/platform/port.c" path="src/platform/port.c" type="1"/>
<File name="Libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x/system_stm32f10x.h" path="Libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x/system_stm32f10x.h" type="1"/>
<File name="Libraries/STM32F10x_StdPeriph_Driver/inc/stm32f10x_wwdg.h" path="Libraries/STM32F10x_StdPeriph_Driver/inc/stm32f10x_wwdg.h" type="1"/>
<File name="Libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x/system_stm32f10x.h" path="Libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x/system_stm32f10x.h" type="1"/>
<File name="src/decadriver/deca_device.c" path="src/decadriver/deca_device.c" type="1"/>
<File name="Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_exti.c" path="Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_exti.c" type="1"/>
<File name="Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_rtc.c" path="Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_rtc.c" type="1"/>
<File name="Libraries/STM32F10x_StdPeriph_Driver/inc/stm32f10x_adc.h" path="Libraries/STM32F10x_StdPeriph_Driver/inc/stm32f10x_adc.h" type="1"/>
<File name="Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_rtc.c" path="Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_rtc.c" type="1"/>
<File name="Libraries/STM32_USB_Device_Library/Core/inc/usbd_req.h" path="Libraries/STM32_USB_Device_Library/Core/inc/usbd_req.h" type="1"/>
<File name="Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_fsmc.c" path="Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_fsmc.c" type="1"/>
<File name="Libraries/STM32_USB_OTG_Driver/inc/usb_otg.h" path="Libraries/STM32_USB_OTG_Driver/inc/usb_otg.h" type="1"/>
......@@ -169,8 +169,8 @@
<File name="src/decadriver/deca_param_types.h" path="src/decadriver/deca_param_types.h" type="1"/>
<File name="src/usb/deca_usb_bsp_evk1000.c" path="src/usb/deca_usb_bsp_evk1000.c" type="1"/>
<File name="Libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x/startup/startup_stm32f10x_cl.S" path="Libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x/startup/startup_stm32f10x_cl.S" type="1"/>
<File name="Libraries/STM32_USB_OTG_Driver/inc/usb_bsp.h" path="Libraries/STM32_USB_OTG_Driver/inc/usb_bsp.h" type="1"/>
<File name="src/platform/stm32f10x_conf.h" path="src/platform/stm32f10x_conf.h" type="1"/>
<File name="Libraries/STM32_USB_OTG_Driver/inc/usb_bsp.h" path="Libraries/STM32_USB_OTG_Driver/inc/usb_bsp.h" type="1"/>
<File name="Libraries/CMSIS/CM3" path="" type="2"/>
<File name="Libraries" path="" type="2"/>
<File name="src/decadriver/deca_types.h" path="src/decadriver/deca_types.h" type="1"/>
......@@ -210,8 +210,8 @@
<File name="Libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x/startup" path="" type="2"/>
<File name="Libraries/STM32_USB_OTG_Driver/inc/usb_core.h" path="Libraries/STM32_USB_OTG_Driver/inc/usb_core.h" type="1"/>
<File name="Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_bkp.c" path="Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_bkp.c" type="1"/>
<File name="Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_gpio.c" path="Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_gpio.c" type="1"/>
<File name="src/application/dw_main.c" path="src/application/dw_main.c" type="1"/>
<File name="Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_gpio.c" path="Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_gpio.c" type="1"/>
<File name="src/platform" path="" type="2"/>
<File name="Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_tim.c" path="Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_tim.c" type="1"/>
<File name="Libraries/STM32F10x_StdPeriph_Driver/inc/stm32f10x_i2c.h" path="Libraries/STM32F10x_StdPeriph_Driver/inc/stm32f10x_i2c.h" type="1"/>
......
No preview for this file type
......@@ -13,6 +13,9 @@ The software and documentation for the EVK1000 evaluation kit and DW1000 transce
## Getting Started
//TODO add a table of contents...
### UWB Configuration
The EVB1000 allows for a numer of operational configurations via microswitches and jumpers. For default operations, ensure the EVB1000 is configured as shown in the images below. Consult the EVK1000 documentation for more configuration options.
......@@ -50,8 +53,26 @@ Then simply click the *Build* button and the EVK1000/Debug/bin/ directory will b
### Interfacing with the iBQR
tx2-ros-examples
The `uwb_interface` ROS package for interfacing with UWB can be found in the `tx2-ros-examples` repository. It is run using the following:
```
rosrun uwb_interface uwb_interface_node -p /dev/ttyAMC0
```
**_NOTE:_** Roscore must be running first.
**_NOTE:_** The argument after `-p` is the path to the USB port connection and may not be the same as listed above. See the `tx2-ros-examples` repository for more information.
### EVB1000 Display
In order to save power, the LCD display is disabled by default. It can be reenabled by changing `#define USING_LCD (0)` to `#define USING_LCD (1)` in [src/application/instance.h](src/application/instance.h). When enabled, the LCD will display the range calculated and the address of the TAG/ANCHOR that it ranged with.
### Calibration
\ No newline at end of file
### Calibration
The ranging algorithm depends on RX and TX timestamps to accurately determine the time-of-flight (from which UWB distance can be derived) of the communications signals. For the derived distance calculations to be accurate, the signal propogation time from the antenna to the DW1000 transceiver (RX delay) and from the DW1000 to the antenna (TX delay) must be accounted for. By programming the RX and TX delays to the DW1000 OTP memory, the DW1000 will provide corrected timestamps to the ranging firmware.
**_NOTE:_** Step-by-step instructions for performing the RX and TX delay calibration can be found in the uwb_delay_calibration package of the tx2-ros-examples repository.
**_NOTE:_** The range measurements depend on the speed of light through air. For best results, recalibrate the UWBs using the air conditions expected for the intended operating environment.
......@@ -295,7 +295,6 @@ void configure_continuous_txspectrum_mode(uint8 s1switch)
int dw_main(void)
{
int i = 0;
int toggle = 1;
double range_result = 0;
int canSleep;
......@@ -304,6 +303,7 @@ int dw_main(void)
peripherals_init();
#if (USING_LCD == 1)
int toggle = 1;
spi_peripheral_init(1);
#else
spi_peripheral_init(0);
......@@ -339,11 +339,22 @@ int dw_main(void)
| port_is_switch_on(TA_SW1_7) << 6
| port_is_switch_on(TA_SW1_8) << 7;
// uint8 s13 = port_is_switch_on(TA_SW1_3);
// uint8 s14 = port_is_switch_on(TA_SW1_4);
// uint8 s15 = port_is_switch_on(TA_SW1_5);
// uint8 s16 = port_is_switch_on(TA_SW1_6);
// uint8 s17 = port_is_switch_on(TA_SW1_7);
// uint8 s18 = port_is_switch_on(TA_SW1_8);
// uint8 debug_msg[8];
// int n = sprintf((char*)&debug_msg[0], "s1switch: %d ", s1switch);
// send_usbmessage(&debug_msg[0], n);
// usb_run();
if(port_is_switch_on(TA_SW1_3) == S1_SWITCH_OFF)
{
int j = 1000000;
uint8 command;
#if (USING_LCD == 1)
uint8 command;
memset(dataseq, 0, LCD_BUFF_LEN);
while(j--);
......@@ -486,12 +497,56 @@ int dw_main(void)
if(instancenewrange())
{
int n, /* txl = 0, rxl = 0,*/ aaddr, taddr, txa, rxa, rng, rng_raw;
int n, rng, rng_raw;
uint64 aaddr, taddr;
ranging = 1;
//send the new range information to LCD and/or USB
range_result = instance_get_idist(inst->newRangeUWBIndex);
//set_rangeresult(range_result);
#if (USING_LCD == 1)
#if (DELAY_CALIB_OUTPUT == 1)
dataseq[0] = 0x2 ; //return cursor home
writetoLCD( 1, 0, dataseq);
dataseq[0] = 0x2 ; //return cursor home
writetoLCD( 1, 0, dataseq);
memset(dataseq, ' ', LCD_BUFF_LEN);
memset(dataseq1, ' ', LCD_BUFF_LEN);
int toggle_step = 5;
if(toggle <= toggle_step)
{
sprintf((char*)&dataseq[1], "ADDRESS - SELF ");
sprintf((char*)&dataseq1[0], "%llX", instance_get_addr());
}
else if(toggle <= toggle_step*2)
{
sprintf((char*)&dataseq[1], "RANGING WITH ");
if(inst->mode == TAG)
{
sprintf((char*)&dataseq1[0], "%.3u ANCHORS ", instfindnumactiveuwbinlist(inst));
}
else if(inst->mode == ANCHOR)
{
sprintf((char*)&dataseq1[0], "%.3u TAGS ", instfindnumactiveuwbinlist(inst));
}
}
else
{
sprintf((char*)&dataseq[0], "TX DELAY: %.5u ", inst->txAntennaDelay);
sprintf((char*)&dataseq1[0], "RX DELAY: %.5u ", inst->rxAntennaDelay);
}
toggle++;
if(toggle > toggle_step*3)
{
toggle = 0;
}
writetoLCD( 40, 1, dataseq); //send some data
writetoLCD( 16, 1, dataseq1); //send some data
#else
dataseq[0] = 0x2 ; //return cursor home
writetoLCD( 1, 0, dataseq);
......@@ -500,38 +555,27 @@ int dw_main(void)
sprintf((char*)&dataseq[1], "LAST: %4.2f m", range_result);
writetoLCD( 40, 1, dataseq); //send some data
sprintf((char*)&dataseq1[0], "%llX", instance_get_uwbaddr(inst->newRangeUWBIndex));
// sprintf((char*)&dataseq1[1], " ");
writetoLCD( 16, 1, dataseq1); //send some data
#endif
#endif
aaddr = instancenewrangeancadd();
taddr = instancenewrangetagadd();
txa = instancetxantdly();
rxa = instancerxantdly();
rng = (int) (range_result*1000);
rng_raw = (int) (instance_get_idistraw(inst->newRangeUWBIndex)*1000); //TODO change this to use actual tag
rng_raw = (int) (instance_get_idistraw(inst->newRangeUWBIndex)*1000);
if(instance_mode == TAG)
{
//n = sprintf((char*)&dataseq[0], "ia%04x t%04x %04x %04x %04x %04x %04x %02x %02x t", aaddr, taddr, rng, rng_raw, l, txa, rxa, txl, rxl);
// n = sprintf((char*)&dataseq[0], "ia%04x t%04x %08x %08x %04x %04x %04x t", aaddr, taddr, rng, rng_raw, l, txa, rxa);
n = sprintf((char*)&dataseq[0], "ia%04x t%04x %08x %08x %04x %04x t", aaddr, taddr, rng, rng_raw, txa, rxa);
n = sprintf((char*)&dataseq[0], "t %llX %llX %08X %08X", aaddr, taddr, rng, rng_raw);
}
else
{
//n = sprintf((char*)&dataseq[0], "ia%04x t%04x %04x %04x %04x %04x %04x %02x %02x a", aaddr, taddr, rng, rng_raw, l, txa, rxa, txl, rxl);
//n = sprintf((char*)&dataseq[0], "ia%04x t%04x %08x %08x %04x %04x %04x %2.2f a", aaddr, taddr, rng, rng_raw, l, txa, rxa, instance_data[0].clockOffset);
// n = sprintf((char*)&dataseq[0], "ia%04x t%04x %08x %08x %04x %04x %04x a", aaddr, taddr, rng, rng_raw, l, txa, rxa);
n = sprintf((char*)&dataseq[0], "ia%04x t%04x %08x %08x %04x %04x a", aaddr, taddr, rng, rng_raw, txa, rxa);
n = sprintf((char*)&dataseq[0], "a %llX %llX %08X %08X", aaddr, taddr, rng, rng_raw);
}
#ifdef USB_SUPPORT //this is set in the port.h file
send_usbmessage(&dataseq[0], n);
// n = sprintf((char*)&dataseq[0], "This is a test");
// send_usbmessage(&dataseq[0], n);
send_usbmessage(&dataseq[0], n);
#endif
}
......@@ -622,7 +666,6 @@ int dw_main(void)
#endif
#ifdef USB_SUPPORT //this is set in the port.h file
usb_run();
#endif
......
......@@ -21,8 +21,6 @@
#include "instance.h"
extern void usb_run(void);
extern int usb_init(void);
extern void usb_printconfig(int, uint8*, int);
......@@ -676,7 +674,8 @@ int testapprun(instance_data_t *inst, int message)
//sometimes the DW1000 tx callback (TXFRS) fails to trigger and the the SYS_STATE register
//reads IDLE for for PMSC, RX, and TX so we need another way to timeout since RX FWTO won't be triggered.
uint32 ptc = portGetTickCnt();
// uint32 ptc = portGetTickCnt();
uint32 dt = get_dt32(inst->timeofTx, portGetTickCnt());
if(inst->previousState == TA_TXBLINK_WAIT_SEND ||
inst->previousState == TA_TXFINAL_WAIT_SEND ||
......@@ -684,14 +683,16 @@ int testapprun(instance_data_t *inst, int message)
inst->previousState == TA_TXRESPONSE_WAIT_SEND)
{
//NOTE timeout duration found experimentally, may need to be changed if the delays in instance.h are modified
if(ptc - (uint32)inst->timeofTx > 10) {
// if(ptc - (uint32)inst->timeofTx > 10) {
if(dt > 10) {
inst_processtxrxtimeout(inst);
}
}
else if(inst->previousState == TA_TXRANGINGINIT_WAIT_SEND)
{
//NOTE timeout duration found experimentally, may need to be changed if the delays in instance.h are modified
if(ptc - (uint32)inst->timeofTx > 180)
// if(ptc - (uint32)inst->timeofTx > 180)
if(dt > 180)
{
inst_processtxrxtimeout(inst);
}
......@@ -916,7 +917,7 @@ int testapprun(instance_data_t *inst, int message)
break;
}
if (!inst->frameFilteringEnabled) //NOTE this might cause problems... might need to move somewhere else
if (!inst->frameFilteringEnabled)
{
// if we missed the ACK to the ranging init message we may not have turned frame filtering on
dwt_enableframefilter(DWT_FF_DATA_EN | DWT_FF_ACK_EN); //we are starting ranging - enable the filter....
......@@ -958,10 +959,10 @@ int testapprun(instance_data_t *inst, int message)
memcpy(&inst->tof[inst->uwbToRangeWith], &(messageData[TOFR]), 5);
inst->newRangeUWBIndex = inst->uwbToRangeWith;
//TODO remove or update below?
inst->newRangeAncAddress = (uint16) srcAddr[0] + ((uint16) srcAddr[1] << 8);
inst->newRangeTagAddress = (uint16) inst->eui64[0] + ((uint16) inst->eui64[1] << 8);
inst->newRangeAncAddress = instance_get_uwbaddr(inst->uwbToRangeWith);
inst->newRangeTagAddress = instance_get_addr();
break;
} //RTLS_DEMO_MSG_ANCH_RESP
case RTLS_DEMO_MSG_TAG_FINAL:
......@@ -1012,14 +1013,18 @@ int testapprun(instance_data_t *inst, int message)
inst->tof[inst->uwbToRangeWith] = (int64) ( RaRbxDaDb/(RbyDb + RayDa) );
inst->newRangeUWBIndex = inst->uwbToRangeWith;
if(reportTOF(inst, inst->newRangeUWBIndex) == 0)
{
inst->newRange = 1;
}
//TODO update or remove?
inst->newRangeTagAddress = (uint16) srcAddr[0] + ((uint16) srcAddr[1] << 8);
inst->newRangeAncAddress = (uint16) inst->eui64[0] + ((uint16) inst->eui64[1] << 8);
// inst->newRangeTagAddress = (uint16) srcAddr[0] + ((uint16) srcAddr[1] << 8);
// inst->newRangeAncAddress = (uint16) inst->eui64[0] + ((uint16) inst->eui64[1] << 8);
inst->newRangeTagAddress = instance_get_uwbaddr(inst->uwbToRangeWith);
inst->newRangeAncAddress = instance_get_addr();
inst->testAppState = TA_RXE_WAIT ;
inst->previousState = TA_INIT;
......@@ -1027,6 +1032,7 @@ int testapprun(instance_data_t *inst, int message)
inst->uwbToRangeWith = 255;
inst->frameFilteringEnabled = 0;
dwt_enableframefilter(DWT_FF_NOTYPE_EN);
dwt_setrxaftertxdelay(0);
instancesetantennadelays(); //this will update the antenna delay if it has changed
......@@ -1304,9 +1310,27 @@ void instance_readaccumulatordata(void)
#endif // support_sounding
}
//get the time difference between two between two 32-bit unsigned timestamps
//t1 is the first timestamp
//t2 is the second timetamp that occured after t1
uint32 get_dt32(uint32 t1, uint32 t2)
{
if(t2 >= t1)
{
return t2 - t1;
}
else
{
//handle timestamp roleover
return 4294967295 - t1 + t2;
}
}
#endif
/* ==========================================================
Notes:
......
......@@ -32,18 +32,25 @@ extern "C" {
#define CORRECT_RANGE_BIAS (1) // Compensate for small bias due to uneven accumulator growth at close up high power
/******************************************************************************************************************
*******************************************************************************************************************
*******************************************************************************************************************/
#define NUM_INST 1
#define SPEED_OF_LIGHT (299702547.0) // in m/s in air
#define SPEED_OF_LIGHT (299704644.54) //(299702547.0) // in m/s in air
#define MASK_40BIT (0x00FFFFFFFFFF) // DW1000 counter is 40 bits
#define MASK_TXDTS (0x00FFFFFFFE00) //The TX timestamp will snap to 8 ns resolution - mask lower 9 bits.
#define DELAY_CALIB (0) // when set to 1 - the LCD display will show information used for TX/RX delay calibration
#define SET_TXRX_DELAY (0) //when set to 1 - the DW1000 RX and TX delays are set to the TX_DELAY and RX_DELAY defines
#define TX_ANT_DELAY 0
#define RX_ANT_DELAY 0
#define USING_64BIT_ADDR (1) //when set to 0 - the DecaRanging application will use 16-bit addresses
#define USING_LCD (0) //when set to 0 - the DecaRanging application will not use the LCD display
#define USING_LCD (1) //when set to 0 - the DecaRanging application will not use the LCD display
//! callback events
#define DWT_SIG_RX_NOERR 0
......@@ -390,7 +397,8 @@ typedef struct
dwt_txconfig_t configTX ; //DW1000 TX power configuration
uint16 txAntennaDelay ; //DW1000 TX antenna delay
uint16 rxAntennaDelay ; //DW1000 RX antenna delay
uint8 antennaDelayChanged;
uint8 antennaDelayChanged;
// "MAC" features
uint8 frameFilteringEnabled ; //frame filtering is enabled
......@@ -478,14 +486,14 @@ typedef struct
int tofIndex ;
int tofCount ;
uint8 newRangeUWBIndex;
uint8 newRangeUWBIndex; //index for most recent ranging exchange
int newRange;
int newRangeAncAddress; //last 4 bytes of anchor address
int newRangeTagAddress; //last 4 bytes of tag address
uint64 newRangeAncAddress; //anchor address for most recent ranging exchange
uint64 newRangeTagAddress; //tag address for most recent ranging exchange
double idistance[UWB_LIST_SIZE];
double idistanceraw[UWB_LIST_SIZE];
//if set to 1 then it means that DW1000 is in DEEP_SLEEP
//so the ranging has finished and micro can output on USB/LCD
//if sending data to LCD during ranging this limits the speed of ranging
......@@ -527,6 +535,8 @@ void instclearuwblist(void);
int instaddactivateuwbinlist(instance_data_t *inst, uint8 *uwbAddr);
int instcheckactiveuwbinlist(instance_data_t *inst, uint8 *uwbAddr);
int instfindfirstactiveuwbinlist(instance_data_t *inst, uint8 startindex);
int instfindnumactiveuwbinlist(instance_data_t *inst);
void instance_readaccumulatordata(void);
//-------------------------------------------------------------------------------------------------------------
......@@ -584,8 +594,8 @@ uint64 instance_get_addr(void); //get own address (8 bytes)
uint64 instance_get_uwbaddr(uint8 uwb_index); //get uwb address (8 bytes)
// uint64 instance_get_anchaddr(void); //get anchor address (that sent the ToF)
int instancenewrangeancadd(void);
int instancenewrangetagadd(void);
uint64 instancenewrangeancadd(void);
uint64 instancenewrangetagadd(void);
int instancenewrange(void);
int instancesleeping(void);
int instanceanchorwaiting(void);
......@@ -620,9 +630,12 @@ uint16 instancerxantdly(void);
int instance_starttxtest(int framePeriod);
// coid instance_
instance_data_t* instance_get_local_structure_ptr(unsigned int x);
uint32 get_dt32(uint32 t1, uint32 t2);
void send_statetousb(instance_data_t *inst);
void send_rxmsgtousb(char *data);
......
......@@ -110,14 +110,14 @@ int instance_starttxtest(int framePeriod)
//NOTE: SPI frequency must be < 3MHz
port_set_dw1000_slowrate(); //max SPI before PLLs configured is ~4M
// the value here 0x1000 gives a period of 32.82 s
// the value here 0x1000 gives a period of 32.82 �s
//this is setting 0x1000 as frame period (125MHz clock cycles) (time from Tx en - to next - Tx en)
dwt_configcontinuousframemode(framePeriod);
dwt_writetxdata(127, (uint8 *) msg, 0) ;
dwt_writetxfctrl(127, 0, 0);
//to start the first frame - set TXSTRT
//to start the first frame - set TXSTRT
dwt_starttx(DWT_START_TX_IMMEDIATE);
//measure the power
......
......@@ -273,6 +273,28 @@ int instfindfirstactiveuwbinlist(instance_data_t *inst, uint8 startindex)
}
// -------------------------------------------------------------------------------------------------------------------
//
// function to find the number of UWBs in our list that are not in a timeout status
//
// -------------------------------------------------------------------------------------------------------------------
int instfindnumactiveuwbinlist(instance_data_t *inst)
{
uint8 num = 0;
for(int i=0; i<inst->uwbListLen; i++)
{
if(!inst->uwbTimeout[i])
{
num++;
}
}
return num;
}
// -------------------------------------------------------------------------------------------------------------------
#if (NUM_INST != 1)
#error These functions assume one instance only
......@@ -314,12 +336,12 @@ int instancenewrange(void)
return 0;
}
int instancenewrangeancadd(void)
uint64 instancenewrangeancadd(void)
{
return instance_data[0].newRangeAncAddress;
}
int instancenewrangetagadd(void)
uint64 instancenewrangetagadd(void)
{
return instance_data[0].newRangeTagAddress;
}
......@@ -580,6 +602,7 @@ void instance_config(instanceConfig_t *config)
//NOTE: For EVK1000 the OTP stores calibrated antenna and TX power values for configuration modes 3 and 5,
//check if to use the antenna delay calibration values as read from the OTP
if(dwt_otprevision() <= 1) //in revision 0, 1 of EVB1000/EVK1000
{
......@@ -589,11 +612,15 @@ void instance_config(instanceConfig_t *config)
//MUST change the SPI to < 3MHz as the dwt_otpread will change to XTAL clock
port_set_dw1000_slowrate(); //reduce SPI to < 3MHz
//#if (SET_TXRX_DELAY == 0)
dwt_otpread(ANTDLY_ADDRESS, &antennaDelay, 1);
instance_data[instance].txAntennaDelay = ((antennaDelay >> (16*(config->pulseRepFreq - DWT_PRF_16M))) & 0xFFFF) >> 1;
instance_data[instance].rxAntennaDelay = instance_data[instance].txAntennaDelay ;
//#else
// instance_data[instance].txAntennaDelay = (uint16)TX_ANT_DELAY;
// instance_data[instance].rxAntennaDelay = (uint16)RX_ANT_DELAY;
//#endif
//read any data from the OTP for the TX power
dwt_otpread(TXCFG_ADDRESS, otpPower, 12);
......@@ -603,11 +630,18 @@ void instance_config(instanceConfig_t *config)
power = otpPower[(config->pulseRepFreq - DWT_PRF_16M) + (chan_idx[instance_data[instance].configData.chan] * 2)];
}
#if (SET_TXRX_DELAY == 0)
// if nothing was actually programmed then set a reasonable value anyway
if(instance_data[instance].txAntennaDelay == 0)//otherwise a default values should be used
{
instance_data[instance].rxAntennaDelay = instance_data[instance].txAntennaDelay = rfDelays[config->pulseRepFreq - DWT_PRF_16M];
}
#else
instance_data[instance].txAntennaDelay = (uint16)TX_ANT_DELAY;
instance_data[instance].rxAntennaDelay = (uint16)RX_ANT_DELAY;
#endif
// -------------------------------------------------------------------------------------------------------------------
// set the antenna delay, we assume that the RX is the same as TX.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment