commit 8543d0d96fdac6b0ee30ef22a8def57fba30f9a2
Author: Thomas Schöpping <tschoepp@cit-ec.uni-bielefeld.de>
Date:   Fri Jan 25 14:38:57 2019 +0100

    Cleanup of the STM32L4 module.
    Applied several recent changes in AMiRo-OS to this module.

diff --git a/modules/RT-STM32L476RG-NUCLEO64/module.h b/modules/RT-STM32L476RG-NUCLEO64/module.h
index c2f20f0..36e40bc 100644
--- a/modules/RT-STM32L476RG-NUCLEO64/module.h
+++ b/modules/RT-STM32L476RG-NUCLEO64/module.h
@@ -1,6 +1,6 @@
 /*
 AMiRo-OS is an operating system designed for the Autonomous Mini Robot (AMiRo) platform.
-Copyright (C) 2016..2018  Thomas Schöpping et al.
+Copyright (C) 2016..2019  Thomas Schöpping et al.
 
 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
@@ -27,6 +27,8 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #ifndef _AMIROOS_MODULE_H_
 #define _AMIROOS_MODULE_H_
 
+#include <amiroos.h>
+
 /*===========================================================================*/
 /**
  * @name Module specific functions
@@ -34,33 +36,6 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 /*===========================================================================*/
 
-/*
- * @brief Makro to store data in the core coupled memory (ccm).
- *        Example:
- *        int compute_buffer[128] CCM_RAM;
- *
- * @note The ccm is not connected to any bus system.
- */
-#define CCM_RAM                                 __attribute__((section(".ram4"), aligned(4)))moduleHalCanConfig
-
-/*
- * @brief Makro to store data in the ethernet memory (eth).
- *        Example:
- *        int dma_buffer[128] ETH_RAM;
- *
- * @note The eth is a dedicated memory block with its own DMA controller.
- */
-#define ETH_RAM                                 __attribute__((section(".ram2"), aligned(4)))
-
-/*
- * @brief Makro to store data in the backup memory (bckp).
- *        Example:
- *        int backup_buffer[128] BCKP_RAM;
- *
- * @note The eth is a dedicated memory block with its own DMA controller.
- */
-#define BCKP_RAM                                __attribute__((section(".ram5"), aligned(4)))
-
 /** @} */
 
 /*===========================================================================*/
@@ -69,27 +44,21 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  * @{
  */
 /*===========================================================================*/
-#include <hal.h>
-
-/**
- * @brief   CAN driver to use.
- */
-#define MODULE_HAL_CAN                          CAND1
 
 /**
- * @brief   Configuration for the CAN driver.
+ * @brief   Serial driver of the programmer interface.
  */
-extern CANConfig moduleHalCanConfig;
+#define MODULE_HAL_PROGIF                       SD2
 
 /**
- * @brief   Serial driver of the programmer interface.
+ * @brief   Configuration for the programmer serial interface driver.
  */
-#define MODULE_HAL_PROGIF                       SD2
+extern SerialConfig moduleHalProgIfConfig;
 
 /**
  * @brief   I2C driver to access multiplexer, proximity sensors 5 to 8, power monitors for VSYS4.2, VIO 5.0 and VDD, EEPROM, touch sensor, and fuel gauge (front battery).
  */
-#define MODULE_HAL_I2C_MPU6050 I2CD3
+#define MODULE_HAL_I2C_MPU6050                  I2CD3
 
 /**
  * @brief   Configuration for the multiplexer, proximity sensors 1 to 4, power monitors for VIO1.8 and VIO 3.3, and fuel gauge (rear battery) I2C driver.
@@ -97,52 +66,18 @@ extern CANConfig moduleHalCanConfig;
 extern I2CConfig moduleHalI2cMpu6050Config;
 
 /**
- * @brief   Configuration for the programmer serial interface driver.
- */
-extern SerialConfig moduleHalProgIfConfig;
-
-/**
  * @brief   Real-Time Clock driver.
  */
 #define MODULE_HAL_RTC                          RTCD1
 
 /** @} */
 
-/**
- * @brief   Periphery communication interfaces initialization hook.
- */
-#define MODULE_INIT_PERIPHERY_COMM() {                                        \
-  /* serial driver */                                                         \
-  sdStart(&MODULE_HAL_PROGIF, &moduleHalProgIfConfig);                        \
-}
-
 /*===========================================================================*/
 /**
  * @name GPIO definitions
  * @{
  */
 /*===========================================================================*/
-#include <amiro-lld.h>
-
-/**
- * @brief   SYS_REG_EN output signal GPIO.
- */
-extern ROMCONST apalControlGpio_t moduleGpioSysRegEn;
-
-/**
- * @brief   IR_INT1 input signal GPIO.
- */
-extern ROMCONST apalControlGpio_t moduleGpioIrInt1;
-
-/**
- * @brief   POWER_EN output signal GPIO.
- */
-extern ROMCONST apalControlGpio_t moduleGpioPowerEn;
-
-/**
- * @brief   SYS_UART_DN bidirectional signal GPIO.
- */
-extern ROMCONST apalControlGpio_t moduleGpioSysUartDn;
 
 /**
  * @brief   LED output signal GPIO.
@@ -150,140 +85,108 @@ extern ROMCONST apalControlGpio_t moduleGpioSysUartDn;
 extern ROMCONST apalControlGpio_t moduleGpioLed;
 
 /**
- * @brief   SYS_UART_UP bidirectional signal GPIO.
+ * @brief   User button input signal.
  */
-extern ROMCONST apalControlGpio_t moduleGpioSysUartUp;
+extern ROMCONST apalControlGpio_t moduleGpioUserButton;
 
-/**
- * @brief   IR_INT2 input signal GPIO.
- */
-extern ROMCONST apalControlGpio_t moduleGpioIrInt2;
-
-/**
- * @brief   TOUCH_INT input signal GPIO.
- */
-extern ROMCONST apalControlGpio_t moduleGpioTouchInt;
+/** @} */
 
+/*===========================================================================*/
 /**
- * @brief   SYS_DONE input signal GPIO.
+ * @name AMiRo-OS core configurations
+ * @{
  */
-extern ROMCONST apalControlGpio_t moduleGpioSysDone;
+/*===========================================================================*/
 
 /**
- * @brief   SYS_PROG output signal GPIO.
+ * @brief   Event flag to be set on a USER_BUTTON interrupt.
  */
-extern ROMCONST apalControlGpio_t moduleGpioSysProg;
+#define MODULE_OS_IOEVENTFLAGS_USERBUTTON       AOS_IOEVENT_FLAG(GPIOC_BUTTON)
 
+#if (AMIROOS_CFG_SHELL_ENABLE == true) || (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__)
 /**
- * @brief   PATH_DC input signal GPIO.
+ * @brief   Shell prompt text.
  */
-extern ROMCONST apalControlGpio_t moduleGpioPathDc;
+extern ROMCONST char* moduleShellPrompt;
+#endif
 
 /**
- * @brief   SYS_SPI_DIR bidirectional signal GPIO.
+ * @brief   Interrupt initialization macro.
+ * @note    SSSP related interrupt signals are already initialized in 'aos_system.c'.
  */
-extern ROMCONST apalControlGpio_t moduleGpioSysSpiDir;
+#define MODULE_INIT_INTERRUPTS() {                                            \
+  /* 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));   \
+}
 
 /**
- * @brief   SYS_SYNC bidirectional signal GPIO.
+ * @brief   Unit test initialization hook.
  */
-extern ROMCONST apalControlGpio_t moduleGpioSysSync;
+#define MODULE_INIT_TESTS() {                                                 \
+  /* add unit-test shell commands */                                          \
+  aosShellAddCommand(&aos.shell, &moduleUtAlldMpu6050.shellcmd);              \
+}
 
 /**
- * @brief   SYS_PD bidirectional signal GPIO.
+ * @brief   Periphery communication interfaces initialization hook.
  */
-extern ROMCONST apalControlGpio_t moduleGpioSysPd;
+#define MODULE_INIT_PERIPHERY_COMM() {                                        \
+  /* serial driver */                                                         \
+  sdStart(&MODULE_HAL_PROGIF, &moduleHalProgIfConfig);                        \
+}
 
 /**
- * @brief   SYS_WARMRST bidirectional signal GPIO.
+ * @brief   Periphery communication interface deinitialization hook.
  */
-extern ROMCONST apalControlGpio_t moduleGpioSysWarmrst;
+#define MODULE_SHUTDOWN_PERIPHERY_COMM() {                                    \
+}
 
 /**
- * @brief   BT_RST output signal GPIO.
+ * @brief   HOOK to toggle the LEDs when the user button is pressed.
  */
-extern ROMCONST apalControlGpio_t moduleGpioBtRst;
-
+#define MODULE_MAIN_LOOP_IO_EVENT(eventflags) {                    \
+  if (eventflags & MODULE_OS_IOEVENTFLAGS_USERBUTTON) {                       \
+    apalControlGpioState_t buttonstate;                                       \
+    apalControlGpioGet(&moduleGpioUserButton, &buttonstate);                  \
+    apalControlGpioSet(&moduleGpioLed, buttonstate);                          \
+  }                                                                           \
+}
 
 /** @} */
 
-
 /*===========================================================================*/
 /**
- * @name AMiRo-OS core configurations
+ * @name Startup Shutdown Synchronization Protocol (SSSP)
  * @{
  */
 /*===========================================================================*/
 
-/**
- * @brief   Event flag to be set on a IR_INT1 / CHARGE_STAT1A interrupt.
- */
-#define MODULE_OS_IOEVENTFLAGS_IRINT1           ((eventflags_t)1 << GPIOB_IR_INT1_N)
-
-
-/**
- * @brief   Event flag to be set on a SYS_UART_DN interrupt.
- */
-#define MODULE_OS_IOEVENTFLAGS_SYSUARTDN        ((eventflags_t)1 << GPIOB_SYS_UART_DN)
-
-
-/**
- * @brief   Event flag to be set on a TOUCH_INT interrupt.
- */
-#define MODULE_OS_IOEVENTFLAGS_TOUCHINT         ((eventflags_t)1 << GPIOC_TOUCH_INT_N)
-
-
-/**
- * @brief   Event flag to be set on a PATH_DC interrupt.
- */
-#define MODULE_OS_IOEVENTFLAGS_PATHDC           ((eventflags_t)1 << GPIOC_PATH_DC)
-
-/**
- * @brief   Event flag to be set on a SYS_SPI_DIR interrupt.
- */
-#define MODULE_OS_IOEVENTFLAGS_SYSSPIDIR        ((eventflags_t)1 << GPIOC_SYS_SPI_DIR)
-
-/**
- * @brief   Event flag to be set on a SYS_SYNC interrupt.
- */
-#define MODULE_OS_IOEVENTFLAGS_SYSSYNC          ((eventflags_t)1 << GPIOC_SYS_INT_N)
-
-/**
- * @brief   Event flag to be set on a SYS_PD interrupt.
- */
-#define MODULE_OS_IOEVENTFLAGS_SYSPD            ((eventflags_t)1 << GPIOC_SYS_PD_N)
+/** @} */
 
+/*===========================================================================*/
 /**
- * @brief   Event flag to be set on a SYS_WARMRST interrupt.
+ * @name Low-level drivers
+ * @{
  */
-#define MODULE_OS_IOEVENTFLAGS_SYSWARMRST       ((eventflags_t)1 << GPIOC_SYS_WARMRST_N)
+/*===========================================================================*/
 
-/**
- * @brief   Event flag to be set on a SYS_UART_UP interrupt.
- */
-#define MODULE_OS_IOEVENTFLAGS_SYSUARTUP        ((eventflags_t)1 << GPIOB_SYS_UART_UP)
+//#include <alld_mpu6050.h>
 
-#if (AMIROOS_CFG_SHELL_ENABLE == true) || defined(__DOXYGEN__)
 /**
- * @brief   Shell prompt text.
- */
-extern ROMCONST char* moduleShellPrompt;
-#endif
-
-/**
- * @brief   Unit test initialization hook.
+ * @brief   Accelerometer (MPU6050) driver.
  */
-#define MODULE_INIT_TESTS() {                                                 \
-  /* add unit-test shell commands */                                          \
-  aosShellAddCommand(&aos.shell, &moduleUtAlldMpu6050.shellcmd);              \
-}
+//extern MPU6050Driver moduleLldMpu6050;
 
-#include <alld_mpu6050.h>
+/** @} */
 
+/*===========================================================================*/
 /**
- * @brief   Accelerometer (MPU6050) driver.
+ * @name Unit tests (UT)
+ * @{
  */
-extern MPU6050Driver moduleLldMpu6050;
+/*===========================================================================*/
+#if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__)
 
 #include <ut_alld_mpu6050.h>
 
@@ -292,6 +195,10 @@ extern MPU6050Driver moduleLldMpu6050;
  */
 extern aos_unittest_t moduleUtAlldMpu6050;
 
+#endif /* AMIROOS_CFG_TESTS_ENABLE == true */
+
+/** @} */
+
 #endif /* _AMIROOS_MODULE_H_ */
 
 /** @} */
