diff --git a/software/firmware/.cproject b/software/firmware/.cproject index ae4bc7cb..754ffe75 100644 --- a/software/firmware/.cproject +++ b/software/firmware/.cproject @@ -385,6 +385,22 @@ true true + + ${cross_make} + BUILT_BY=eclipse BOARD_REV=M + uwb_cont_wave + true + true + true + + + ${cross_make} + BUILT_BY=eclipse BOARD_REV=M + uwb_cont_frame + true + true + true + \ No newline at end of file diff --git a/software/firmware/.settings/language.settings.xml b/software/firmware/.settings/language.settings.xml index be7c1aa0..73035b0b 100644 --- a/software/firmware/.settings/language.settings.xml +++ b/software/firmware/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/software/firmware/tests/Makefile b/software/firmware/tests/Makefile index ee791d1c..7dba8d15 100644 --- a/software/firmware/tests/Makefile +++ b/software/firmware/tests/Makefile @@ -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 @@ -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) diff --git a/software/firmware/tests/tools/uwb_continuous_frame.c b/software/firmware/tests/tools/uwb_continuous_frame.c new file mode 100644 index 00000000..80e8e17a --- /dev/null +++ b/software/firmware/tests/tools/uwb_continuous_frame.c @@ -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; +} diff --git a/software/firmware/tests/tools/uwb_continuous_wave.c b/software/firmware/tests/tools/uwb_continuous_wave.c new file mode 100644 index 00000000..de1cefc0 --- /dev/null +++ b/software/firmware/tests/tools/uwb_continuous_wave.c @@ -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; +}