Skip to content

Commit

Permalink
Add UWB continuous wave/frame test tools
Browse files Browse the repository at this point in the history
  • Loading branch information
hedgecrw committed Aug 11, 2024
1 parent 6daea9b commit 059d983
Show file tree
Hide file tree
Showing 5 changed files with 133 additions and 2 deletions.
16 changes: 16 additions & 0 deletions software/firmware/.cproject
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,22 @@
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>true</runAllBuilders>
</target>
<target name="uwb_cont_wave" path="tests" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>${cross_make}</buildCommand>
<buildArguments>BUILT_BY=eclipse BOARD_REV=M</buildArguments>
<buildTarget>uwb_cont_wave</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>true</runAllBuilders>
</target>
<target name="uwb_cont_frame" path="tests" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>${cross_make}</buildCommand>
<buildArguments>BUILT_BY=eclipse BOARD_REV=M</buildArguments>
<buildTarget>uwb_cont_frame</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>true</runAllBuilders>
</target>
</buildTargets>
</storageModule>
</cproject>
2 changes: 1 addition & 1 deletion software/firmware/.settings/language.settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider copy-of="extension" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"/>
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="588010151043692519" id="org.eclipse.embedcdt.managedbuild.cross.arm.core.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Arm Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="-339510081203349785" id="org.eclipse.embedcdt.managedbuild.cross.arm.core.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Arm Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
Expand Down
10 changes: 9 additions & 1 deletion software/firmware/tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ DEFINES += -DWSF_TRACE_ENABLED
DEFINES += -DAM_DEBUG_PRINTF
DEFINES += -Dgcc

DW_LIBRARY := ../src/external/decadriver/libdwt_uwb_driver-m4-hfp-6.0.7.a
DW_LIBRARY := ../src/external/decadriver/libdwt_uwb_driver-m4-hfp-6.0.14.a
LINKER_FILE := ../AmbiqSDK/bsp/$(BSP)/linker/socitrack.ld
STARTUP_FILE := ../AmbiqSDK/bsp/$(BSP)/linker/startup_gcc.c

Expand Down Expand Up @@ -358,6 +358,14 @@ system: TARGET = TestSystem
system: SRC += test_system.c
system: $(CONFIG) $(CONFIG)/test_system.o $(CONFIG)/$$(TARGET).bin program

uwb_cont_wave: TARGET = UwbContWave
uwb_cont_wave: SRC += uwb_continuous_wave.c
uwb_cont_wave: $(CONFIG) $(CONFIG)/uwb_continuous_wave.o $(CONFIG)/$$(TARGET).bin program

uwb_cont_frame: TARGET = UwbContFrame
uwb_cont_frame: SRC += uwb_continuous_frame.c
uwb_cont_frame: $(CONFIG) $(CONFIG)/uwb_continuous_frame.o $(CONFIG)/$$(TARGET).bin program

OBJS = $(SRC:%.c=$(CONFIG)/%.o)
DEPS = $(SRC:%.c=$(CONFIG)/%.d)

Expand Down
61 changes: 61 additions & 0 deletions software/firmware/tests/tools/uwb_continuous_frame.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#include "logging.h"
#include "ranging.h"
#include "system.h"

// Start-to-start delay between frames, expressed in halves of the 499.2 MHz fundamental frequency (around 4 ns)
#define CONT_FRAME_PERIOD 249600

static uint8_t eui[EUI_LEN];
static dwt_config_t config = {
5, /* Channel number. */
DWT_PLEN_128, /* Preamble length. Used in TX only. */
DWT_PAC8, /* Preamble acquisition chunk size. Used in RX only. */
9, /* TX preamble code. Used in TX only. */
9, /* RX preamble code. Used in RX only. */
1, /* 0 to use standard 8 symbol SFD, 1 to use non-standard 8 symbol, 2 for non-standard 16 symbol SFD and 3 for 4z 8 symbol SDF type */
DWT_BR_6M8, /* Data rate. */
DWT_PHRMODE_STD, /* PHY header mode. */
DWT_PHRRATE_STD, /* PHY header rate. */
(129 + 8 - 8), /* SFD timeout (preamble length + 1 + SFD length - PAC size). Used in RX only. */
DWT_STS_MODE_OFF, /* STS disabled */
DWT_STS_LEN_64, /* STS length see allowed values in Enum dwt_sts_lengths_e */
DWT_PDOA_M0 /* PDOA mode off */
};
static dwt_txconfig_t txconfig_options = {
0x34, /* PG delay. */
0xfdfdfdfd, /* TX power. */
0
};

// Standard 802.15.4e blink:
// Byte 0: frame type (0xC5 for a blink)
// Byte 1: sequence number, put to 0
// Byte 2 -> 9: device ID, hard coded constant in this example for simplicity
// Byte 10/11: frame check-sum, automatically set by DW IC in a normal transmission and set to 0 here for simplicity.
static uint8_t tx_msg[] = { 0xC5, 0, 'D', 'E', 'C', 'A', 'W', 'A', 'V', 'E', 0, 0 };

int main(void)
{
// Set up system hardware
setup_hardware();
system_enable_interrupts(true);
system_read_UID(eui, EUI_LEN);
ranging_radio_init(eui);

// Activate continuous frame mode with recommended parameters
dwt_configure(&config);
dwt_configuretxrf(&txconfig_options);
dwt_configcontinuousframemode(CONT_FRAME_PERIOD);

// Initiate continuous frame transmission like a normal transmission
dwt_writetxdata(sizeof(tx_msg), tx_msg, 0);
dwt_writetxfctrl(sizeof(tx_msg), 0, 0);
dwt_starttx(DWT_START_TX_IMMEDIATE);

// Loop forever
while (true)
am_hal_sysctrl_sleep(AM_HAL_SYSCTRL_SLEEP_DEEP);

// Should never reach this point
return 0;
}
46 changes: 46 additions & 0 deletions software/firmware/tests/tools/uwb_continuous_wave.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#include "logging.h"
#include "ranging.h"
#include "system.h"

static uint8_t eui[EUI_LEN];
static dwt_config_t config = {
5, /* Channel number. */
DWT_PLEN_1024, /* Preamble length. Used in TX only. */
DWT_PAC32, /* Preamble acquisition chunk size. Used in RX only. */
9, /* TX preamble code. Used in TX only. */
9, /* RX preamble code. Used in RX only. */
1, /* 0 to use standard 8 symbol SFD, 1 to use non-standard 8 symbol, 2 for non-standard 16 symbol SFD and 3 for 4z 8 symbol SDF type */
DWT_BR_850K, /* Data rate. */
DWT_PHRMODE_STD, /* PHY header mode. */
DWT_PHRRATE_STD, /* PHY header rate. */
(1025 + 8 - 32), /* SFD timeout (preamble length + 1 + SFD length - PAC size). Used in RX only. */
DWT_STS_MODE_OFF, /* STS disabled */
DWT_STS_LEN_64, /* STS length see allowed values in Enum dwt_sts_lengths_e */
DWT_PDOA_M0 /* PDOA mode off */
};
static dwt_txconfig_t txconfig_options = {
0x34, /* PG delay. */
0xfdfdfdfd, /* TX power. */
0
};

int main(void)
{
// Set up system hardware
setup_hardware();
system_enable_interrupts(true);
system_read_UID(eui, EUI_LEN);
ranging_radio_init(eui);

// Activate continuous wave mode with recommended parameters
dwt_configure(&config);
dwt_configuretxrf(&txconfig_options);
dwt_configcwmode();

// Loop forever
while (true)
am_hal_sysctrl_sleep(AM_HAL_SYSCTRL_SLEEP_DEEP);

// Should never reach this point
return 0;
}

0 comments on commit 059d983

Please sign in to comment.