commit 8d4d058ef04e5c1564739f2563ab1d2cab80af05
Author: Cung Sang <csang@techfak.uni-bielefeld.de>
Date:   Wed Jul 31 17:05:22 2019 +0200

    adapt sample of DW1000 with current format on NUCLEO_F103RB

diff --git a/modules/NUCLEO-F103RB/module.c b/modules/NUCLEO-F103RB/module.c
index b147329..232e1c2 100644
--- a/modules/NUCLEO-F103RB/module.c
+++ b/modules/NUCLEO-F103RB/module.c
@@ -50,7 +50,6 @@ SerialConfig moduleHalProgIfConfig = {
 };
 
 #if (BOARD_DW1000_CONNECTED == true)
-
 /*! SPI (high and low speed) configuration for DW1000 */
 SPIConfig moduleHalSpiUwbHsConfig = {
   /* circular buffer mode        */ false,
@@ -69,7 +68,6 @@ SPIConfig moduleHalSpiUwbLsConfig = {
   /* CR1                         */ SPI_CR1_BR_1 | SPI_CR1_BR_0,
   /* CR2                         */ 0,
 };
-
 #endif /* (BOARD_DW1000_CONNECTED == true) */
 
 /** @} */
@@ -97,12 +95,11 @@ ROMCONST apalControlGpio_t moduleGpioLed = {
 };
 
 #if (BOARD_DW1000_CONNECTED == true)
-
 /**
  * @brief   DW1000 reset output signal GPIO.
  */
 static apalGpio_t _gpioDw1000Reset = {
-  /* line */ PAL_LINE(GPIOA, GPIOA_ARD_A0),
+  /* line */ LINE_ARD_D15, //PAL_LINE(GPIOA, GPIOA_ARD_A0)
 };
 ROMCONST apalControlGpio_t moduleGpioDw1000Reset = {
   /* GPIO */ &_gpioDw1000Reset,
@@ -118,7 +115,7 @@ ROMCONST apalControlGpio_t moduleGpioDw1000Reset = {
  * @brief   DW1000 interrrupt input signal GPIO.
  */
 static apalGpio_t _gpioDw1000Irqn = {
-  /* line */ PAL_LINE(GPIOB, GPIOB_ARD_D6),
+  /* line */ LINE_ARD_D14,  // PAL_LINE(GPIOB, GPIOB_ARD_D6)
 };
 ROMCONST apalControlGpio_t moduleGpioDw1000Irqn = {
   /* GPIO */ &_gpioDw1000Irqn,
@@ -144,7 +141,6 @@ ROMCONST apalControlGpio_t moduleGpioSpiChipSelect = {
     /* interrupt edge */ APAL_GPIO_EDGE_NONE,
   },
 };
-
 #endif /* (BOARD_DW1000_CONNECTED == true) */
 
 /**
@@ -194,7 +190,6 @@ ROMCONST char* moduleShellPrompt = "NUCLEO-F103RB";
 /*===========================================================================*/
 
 #if (BOARD_DW1000_CONNECTED == true)
-
 /*! @brief TODO: Manual implementation of SPI configuration. Somehow, it is necessary in NUCLEO-F103RB  */
 void dw1000_spi_init(void){
   palSetPadMode(GPIOB, GPIOB_PIN13, PAL_MODE_STM32_ALTERNATE_PUSHPULL);
@@ -204,6 +199,45 @@ void dw1000_spi_init(void){
   apalGpioWrite(moduleGpioSpiChipSelect.gpio, APAL_GPIO_LOW);
 }
 
+/*! @brief entry point to the IRQn event in DW1000 module
+ *
+ * */
+void process_deca_irq(void){
+  do{
+    dwt_isr();
+   //while IRS line active (ARM can only do edge sensitive interrupts)
+  }while(port_CheckEXT_IRQ() == 1);
+}
+
+/*! @brief Check the current value of GPIO pin and return the value */
+apalGpioState_t port_CheckEXT_IRQ(void) {
+  apalGpioState_t  val;
+  apalGpioRead(moduleGpioDw1000Irqn.gpio, &val);
+  return val;
+}
+
+/*! @brief Manually set the chip select pin of the SPI */
+void set_SPI_chip_select(void){
+  apalGpioWrite(moduleGpioSpiChipSelect.gpio, APAL_GPIO_HIGH);
+}
+
+/*! @brief Manually reset the chip select pin of the SPI */
+void clear_SPI_chip_select(void){
+  apalGpioWrite(moduleGpioSpiChipSelect.gpio, APAL_GPIO_LOW);
+}
+
+/*! @brief Change the SPI speed configuration on the fly */
+void setHighSpeed_SPI(bool speedValue, DW1000Driver* drv){
+
+  spiStop(drv->spid);
+
+  if (speedValue == FALSE){
+    spiStart(drv->spid, &moduleHalSpiUwbLsConfig);  // low speed spi configuration
+  }
+  else{
+    spiStart(drv->spid, &moduleHalSpiUwbHsConfig); // high speed spi configuration
+  }
+}
 #endif /* (BOARD_DW1000_CONNECTED == true) */
 /** @} */
 
@@ -223,13 +257,11 @@ ButtonDriver moduleLldUserButton = {
 };
 
 #if (BOARD_DW1000_CONNECTED == true)
-
 DW1000Driver moduleLldDw1000 = {
   /* SPI driver         */ &MODULE_HAL_SPI_UWB,
   /* ext interrupt      */ &moduleGpioDw1000Irqn,
   /* RESET DW1000       */ &moduleGpioDw1000Reset,
 };
-
 #endif /* (BOARD_DW1000_CONNECTED == true) */
 
 /** @} */
@@ -263,28 +295,15 @@ static int _testButtonShellCmdCb(BaseSequentialStream* stream, int argc, char* a
 AOS_SHELL_COMMAND(moduleTestButtonShellCmd, "test:button", _testButtonShellCmdCb);
 
 #if (BOARD_DW1000_CONNECTED == true) || defined(__DOXYGEN__)
-
 /*
  * UwB Driver (DW1000)
  */
-static int _utShellCmdCb_Dw1000(BaseSequentialStream* stream, int argc, char* argv[])
+#include <module_test_DW1000.h>
+static int _testDw1000ShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[])
 {
-  (void)argc;
-  (void)argv;
-  aosUtRun(stream, &moduleUtAlldDw1000, NULL);
-  return AOS_OK;
+  return moduleTestDw1000ShellCb(stream, argc, argv, NULL);
 }
-aos_unittest_t moduleUtAlldDw1000 = {
-  /* info           */ "DW1000",
-  /* name           */ "UWB System",
-  /* test function  */ utAlldDw1000Func,
-  /* shell command  */ {
-    /* name     */ "unittest:Uwb",
-    /* callback */ _utShellCmdCb_Dw1000,
-    /* next     */ NULL,
-  },
-  /* data           */ &moduleLldDw1000,
-};
+AOS_SHELL_COMMAND(moduleTestDw1000ShellCmd, "test:DW1000", _testDw1000ShellCmdCb);
 #endif /* (BOARD_DW1000_CONNECTED == true) */
 
 /*
@@ -308,8 +327,11 @@ static int _testAllShellCmdCb(BaseSequentialStream* stream, int argc, char* argv
   status |= moduleTestButtonShellCb(stream, 0, targv, &result_test);
   result_total = aosTestResultAdd(result_total, result_test);
 
+#if (BOARD_DW1000_CONNECTED == true) || defined(__DOXYGEN__)
   /* DW1000 */
-  //TODO
+  status |= moduleTestDw1000ShellCb(stream, 0, targv, &result_test);
+  result_total = aosTestResultAdd(result_total, result_test);
+#endif /* (BOARD_DW1000_CONNECTED == true) */
 
   // print total result
   chprintf(stream, "\n");
