commit deaaa47ee7b4833794a93ca7a1cee202a255071b
Author: Cung Sang <csang@techfak.uni-bielefeld.de>
Date:   Fri Feb 8 18:39:52 2019 +0100

    Added DW1000 demo app on top of NUCLEO_F103RB example

diff --git a/modules/NUCLEO-F103RB/module.h b/modules/NUCLEO-F103RB/module.h
index 4a69559..cdce702 100644
--- a/modules/NUCLEO-F103RB/module.h
+++ b/modules/NUCLEO-F103RB/module.h
@@ -36,6 +36,26 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 /*===========================================================================*/
 
+#ifdef AMIROLLD_CFG_DW1000
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+apalGpioState_t port_CheckEXT_IRQ(void) ;
+
+void dw1000_spi_init(void);
+
+void process_deca_irq(void);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* AMIROLLD_CFG_DW1000 */
+
+
 /** @} */
 
 /*===========================================================================*/
@@ -60,8 +80,30 @@ extern SerialConfig moduleHalProgIfConfig;
  */
 #define MODULE_HAL_RTC                          RTCD1
 
+
+#ifdef AMIROLLD_CFG_DW1000
+
+/**
+ * @brief   SPI interface driver for the motion sensors (gyroscope and accelerometer).
+ */
+#define MODULE_HAL_SPI_UWB                      SPID2
+
+
+/**
+ * @brief   Configuration for the SPI interface driver to communicate with the LED driver.
+ */
+extern SPIConfig moduleHalSpiUwbHsConfig;
+
+/**
+ * @brief   Configuration for the SPI interface driver to communicate with the wireless transceiver.
+ */
+extern SPIConfig moduleHalSpiUwbLsConfig;
+
+#endif /* AMIROLLD_CFG_DW1000 */
+
 /** @} */
 
+
 /*===========================================================================*/
 /**
  * @name GPIO definitions
@@ -74,6 +116,27 @@ extern SerialConfig moduleHalProgIfConfig;
  */
 extern ROMCONST apalControlGpio_t moduleGpioLed;
 
+#ifdef AMIROLLD_CFG_DW1000
+/**
+ * @brief   DW1000 reset output signal
+ * @note    the reset pin should be drived as low by MCU to activate.
+ *          Then, put back the reset pin as input to MCU (tri-state float on the air
+ *          is not supported in AMiRo)
+ */
+extern ROMCONST apalControlGpio_t moduleGpioDw1000Reset;
+
+/**
+ * @brief   DW1000 interrupt IRQn input signal.
+ */
+extern ROMCONST apalControlGpio_t moduleGpioDw1000Irqn;
+
+/**
+ * @brief   DW1000 SPI chip select  output signal.
+ */
+extern ROMCONST apalControlGpio_t moduleGpioSpiChipSelect ;
+
+#endif /* AMIROLLD_CFG_DW1000 */
+
 /**
  * @brief   User button input signal.
  */
@@ -89,10 +152,16 @@ extern ROMCONST apalControlGpio_t moduleGpioUserButton;
 /*===========================================================================*/
 
 /**
+ * @brief   Event flag to be call dwt_isr() interrupt.
+ */
+#define MODULE_OS_IOEVENTFLAGS_DW1000_IRQn      AOS_IOEVENT_FLAG(GPIOB_ARD_D6)
+
+/**
  * @brief   Event flag to be set on a USER_BUTTON interrupt.
  */
 #define MODULE_OS_IOEVENTFLAGS_USERBUTTON       AOS_IOEVENT_FLAG(GPIOC_BUTTON)
 
+
 #if (AMIROOS_CFG_SHELL_ENABLE == true) || (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__)
 /**
  * @brief   Shell prompt text.
@@ -100,6 +169,7 @@ extern ROMCONST apalControlGpio_t moduleGpioUserButton;
 extern ROMCONST char* moduleShellPrompt;
 #endif
 
+
 /**
  * @brief   Interrupt initialization macro.
  * @note    SSSP related interrupt signals are already initialized in 'aos_system.c'.
@@ -108,14 +178,35 @@ extern ROMCONST char* moduleShellPrompt;
   /* user button */                                                           \
   palSetPadCallback(moduleGpioUserButton.gpio->port, moduleGpioUserButton.gpio->pad, _intCallback, &moduleGpioUserButton.gpio->pad);  \
   palEnablePadEvent(moduleGpioUserButton.gpio->port, moduleGpioUserButton.gpio->pad, APAL2CH_EDGE(moduleGpioUserButton.meta.edge));   \
+  MODULE_INIT_INTERRUPTS_DW1000();                                            \
 }
+#ifdef AMIROLLD_CFG_DW1000
+  #define MODULE_INIT_INTERRUPTS_DW1000() {                                   \
+    palSetPadCallback(moduleGpioDw1000Irqn.gpio->port, moduleGpioDw1000Irqn.gpio->pad, _intCallback, &moduleGpioDw1000Irqn.gpio->pad);  \
+    palEnablePadEvent(moduleGpioDw1000Irqn.gpio->port, moduleGpioDw1000Irqn.gpio->pad, APAL2CH_EDGE(moduleGpioDw1000Irqn.meta.edge));   \
+  }
+#else
+  #define MODULE_INIT_INTERRUPTS_DW1000() {                                  \
+  }
+#endif /* AMIROLLD_CFG_DW1000 */
+
 
 /**
  * @brief   Unit test initialization hook.
  */
 #define MODULE_INIT_TESTS() {                                                 \
   /* add unit-test shell commands */                                          \
+  MODULE_INIT_TESTS_DW1000();                                                 \
 }
+#ifdef AMIROLLD_CFG_DW1000
+  #define MODULE_INIT_TESTS_DW1000() {                                        \
+    aosShellAddCommand(&aos.shell, &moduleUtAlldDw1000.shellcmd);             \
+  }
+#else
+  #define MODULE_INIT_TESTS_DW1000() {                                         \
+  }
+#endif /* AMIROLLD_CFG_DW1000 */
+
 
 /**
  * @brief   Periphery communication interfaces initialization hook.
@@ -123,24 +214,58 @@ extern ROMCONST char* moduleShellPrompt;
 #define MODULE_INIT_PERIPHERY_COMM() {                                        \
   /* serial driver */                                                         \
   sdStart(&MODULE_HAL_PROGIF, &moduleHalProgIfConfig);                        \
+  MODULE_INIT_PERIPHERY_COMM_DW1000();                                        \
 }
+#ifdef AMIROLLD_CFG_DW1000
+  #define MODULE_INIT_PERIPHERY_COMM_DW1000() {                               \
+    /* SPI init */                                                            \
+    dw1000_spi_init();                                                        \
+    spiStart(&MODULE_HAL_SPI_UWB, &moduleHalSpiUwbLsConfig);                  \
+  }
+#else
+  #define MODULE_INIT_PERIPHERY_COMM_DW1000() {                               \
+  }
+#endif /* AMIROLLD_CFG_DW1000 */
+
 
 /**
  * @brief   Periphery communication interface deinitialization hook.
  */
 #define MODULE_SHUTDOWN_PERIPHERY_COMM() {                                    \
+  MODULE_SHUTDOWN_PERIPHERY_COMM_DW1000();                                    \
+}
+#ifdef AMIROLLD_CFG_DW1000
+#define MODULE_SHUTDOWN_PERIPHERY_COMM_DW1000() {                             \
+  /* SPI */                                                                   \
+  spiStop(&MODULE_HAL_SPI_UWB);                                               \
 }
+#else
+  #define MODULE_SHUTDOWN_PERIPHERY_COMM_DW1000() {                           \
+  }
+#endif /* AMIROLLD_CFG_DW1000 */
 
 /**
- * @brief   HOOK to toggle the LEDs when the user button is pressed.
+ * @brief   HOOK to call process_deca_irq() func when the dw1000 interrupt pin is activated.
  */
-#define MODULE_MAIN_LOOP_IO_EVENT(eventflags) {                               \
+#define MODULE_MAIN_LOOP_IO_EVENT(eventflags) {		                          \
   if (eventflags & MODULE_OS_IOEVENTFLAGS_USERBUTTON) {                       \
     apalControlGpioState_t buttonstate;                                       \
     apalControlGpioGet(&moduleGpioUserButton, &buttonstate);                  \
     apalControlGpioSet(&moduleGpioLed, buttonstate);                          \
   }                                                                           \
+  MODULE_MAIN_LOOP_IO_EVENT_DW1000();                                         \
 }
+#ifdef AMIROLLD_CFG_DW1000
+  #define MODULE_MAIN_LOOP_IO_EVENT_DW1000() {                                \
+    if(eventflags & MODULE_OS_IOEVENTFLAGS_DW1000_IRQn) {		              \
+      /*apalGpioToggle(moduleGpioLedGreen.gpio); // just for debug  */        \
+      process_deca_irq();                                                     \
+    }	                                                                      \
+  }
+#else
+  #define MODULE_MAIN_LOOP_IO_EVENT_DW1000() {                                \
+  }
+#endif  /* AMIROLLD_CFG_DW1000 */
 
 /** @} */
 
@@ -159,6 +284,12 @@ extern ROMCONST char* moduleShellPrompt;
  * @{
  */
 /*===========================================================================*/
+#ifdef AMIROLLD_CFG_DW1000
+#include <alld_DW1000.h>
+
+extern DW1000Driver moduleLldDw1000;
+
+#endif /* AMIROLLD_CFG_DW1000 */
 
 /** @} */
 
@@ -170,6 +301,16 @@ extern ROMCONST char* moduleShellPrompt;
 /*===========================================================================*/
 #if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__)
 
+#if defined(AMIROLLD_CFG_DW1000) && (AMIROLLD_CFG_DW1000 == 1)
+#include<ut_alld_dw1000_v1.h>
+
+/**
+ * @brief   DW1000 unit test object.
+ */
+extern aos_unittest_t moduleUtAlldDw1000;
+
+#endif /* defined(AMIROLLD_CFG_DW1000) && (AMIROLLD_CFG_DW1000 == 1) */
+
 #endif /* AMIROOS_CFG_TESTS_ENABLE == true */
 
 /** @} */
