commit 7021191ecfc8747358c1ea4b331b95ceb8908716
Author: Thomas Schöpping <tschoepp@cit-ec.uni-bielefeld.de>
Date:   Thu Mar 21 17:40:36 2019 +0100

    Revision of the periphAL interface:
    - All types have been optimized for smaller memory footprint.
    - Several inversion macros (e.g. APAL_GPIO_STATE_INVERT() ) have been introduced.
    - Now there are four active states for control GPIOs.
    - Required periphAL version has been increased to 1.1.
    - AMiRo-LLD version has been increased to 1.2 (beta)

diff --git a/periphALtypes.h b/periphALtypes.h
index 9c29e1d..abc5949 100644
--- a/periphALtypes.h
+++ b/periphALtypes.h
@@ -51,16 +51,39 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  * @brief Status values used as return value for all (or most) function calls.
  * @note  The status can be used as mask of flags.
  */
-typedef enum {
-  APAL_STATUS_OK                = 0x00u, /**< success, no error occurred                          */
-  APAL_STATUS_SUCCESS           = 0x00u, /**< success, no error occurred                          */
-  APAL_STATUS_ERROR             = 0x01u, /**< failed, some unspecified error occured              */
-  APAL_STATUS_FAILURE           = 0x01u, /**< failed, some unspecified error occured              */
-  APAL_STATUS_TIMEOUT           = 0x02u, /**< failed, timeout occurred                            */
-  APAL_STATUS_INVALIDARGUMENTS  = 0x04u, /**< failed, invalid arguments                           */
-  APAL_STATUS_UNAVAILABLE       = 0x08u, /**< failed, function unavailable                        */
-  APAL_STATUS_WARNING           = 0x10u, /**< success, but the result is probably not as expected */
-} apalExitStatus_t;
+typedef int8_t apalExitStatus_t;
+
+/**
+ * @brief   Status value for success (no error or warning occurred).
+ */
+#define APAL_STATUS_OK                          ((apalExitStatus_t)0)
+#define APAL_STATUS_SUCCESS                     ((apalExitStatus_t)0)
+
+/**
+ * @brief   Status value for unspecified failure.
+ */
+#define APAL_STATUS_ERROR                       ((apalExitStatus_t)-1)
+#define APAL_STATUS_FAILURE                     ((apalExitStatus_t)-1)
+
+/**
+ * @brief   Status value for timeout failure.
+ */
+#define APAL_STATUS_TIMEOUT                     ((apalExitStatus_t)-2)
+
+/**
+ * @brief   Status value for failure because of invalid arguments.
+ */
+#define APAL_STATUS_INVALIDARGUMENTS            ((apalExitStatus_t)-4)
+
+/**
+ * @brief   Status value for failure because the function is not available/implemented.
+ */
+#define APAL_STATUS_UNAVAILABLE                 ((apalExitStatus_t)-8)
+
+/**
+ * @brief   Status value for unspecified warning.
+ */
+#define APAL_STATUS_WARNING                     ((apalExitStatus_t)1)
 
 /*============================================================================*/
 /* GPIO                                                                       */
@@ -75,62 +98,153 @@ typedef struct apalGpio_t apalGpio_t;
 /**
  * @brief Status values to read/write a GPIO port.
  */
-typedef enum {
-  APAL_GPIO_LOW   = 0,  /**< logical low state  */
-  APAL_GPIO_HIGH  = 1,  /**< logical high state */
-} apalGpioState_t;
+typedef uint8_t apalGpioState_t;
+
+/**
+ * @brief   GPIO physical low state.
+ */
+#define APAL_GPIO_LOW                           ((apalGpioState_t)0)
 
 /**
- * @brief Status values to turn a control GPIO 'on' and 'off'.
+ * @brief   GPIO physical high state.
  */
-typedef enum {
-  APAL_GPIO_OFF = 0,  /**< logical 'turned off' state */
-  APAL_GPIO_ON  = 1,  /**< logical 'turned on' state  */
-} apalControlGpioState_t;
+#define APAL_GPIO_HIGH                          ((apalGpioState_t)1)
+
+/**
+ * @brief   Invert a physical GPIO state.
+ *
+ * @param[in] state   GPIO state to invert.
+ *
+ * @return  Inverted physical GPIO state.
+ */
+#define APAL_GPIO_STATE_INVERT(state) (                                       \
+  (apalGpioState_t)state ^ APAL_GPIO_HIGH                                     \
+)
+
+/**
+ * @brief Logical status values to turn a control GPIO 'on' and 'off'.
+ */
+typedef uint8_t apalControlGpioState_t;
+
+/**
+ * @brief   GPIO logical off state.
+ */
+#define APAL_GPIO_OFF                           ((apalControlGpioState_t)0)
+
+/**
+ * @brief   GPIO logical on state.
+ */
+#define APAL_GPIO_ON                            ((apalControlGpioState_t)1)
 
 /**
  * @brief   Polarity state of the control GPIO.
  */
-typedef enum {
-  APAL_GPIO_ACTIVE_LOW  = 0x00,   /**< A logically low state is defined as 'on'.  */
-  APAL_GPIO_ACTIVE_HIGH = 0x01,   /**< A locically high state is defined as 'on'. */
-} apalGpioActive_t;
+typedef uint8_t apalGpioActive_t;
+
+/**
+ * @brief   The control GPIO is never defined to be 'on' (does not apply).
+ */
+#define APAL_GPIO_ACTIVE_NONE                   ((apalGpioActive_t)0)
+
+/**
+ * @brief   The control GPIO is defined to be 'on' when it is phsically low.
+ */
+#define APAL_GPIO_ACTIVE_LOW                    ((apalGpioActive_t)1)
+
+/**
+ * @brief   The control GPIO is defined to be 'on' when it is physically high.
+ */
+#define APAL_GPIO_ACTIVE_HIGH                   ((apalGpioActive_t)2)
+
+/**
+ * @brief   The control GPIO is defined to be always 'on'.
+ */
+#define APAL_GPIO_ACTIVE_ANY                    ((apalGpioActive_t)3)
+
+/**
+ * @brief   Invert a GPIO active state.
+ * @details The active state is inverted only if it was either low or high.
+ *          In case it was set to none or any, the value is not modified.
+ *
+ * @param[in] active  Active state to be inverted.
+ *
+ * @return  Inverted active state.
+ */
+#define APAL_GPIO_ACTIVE_INVERT(active) (                                     \
+  (((apalGpioActive_t)active & APAL_GPIO_ACTIVE_LOW) ^                        \
+   ((apalGpioActive_t)active & APAL_GPIO_ACTIVE_HIGH)) ?                      \
+  ((apalGpioActive_t)active ^ APAL_GPIO_ACTIVE_ANY) :                         \
+  ((apalGpioActive_t)active)                                                  \
+)
 
 /**
  * @brief   Signal direction for the control GPIO.
  */
-typedef enum {
-  APAL_GPIO_DIRECTION_UNDEFINED     = 0x00,   /**< Signal direction is undefined.     */
-  APAL_GPIO_DIRECTION_INPUT         = 0x01,   /**< Signal direction is input only.    */
-  APAL_GPIO_DIRECTION_OUTPUT        = 0x02,   /**< Signal direction is output only    */
-  APAL_GPIO_DIRECTION_BIDIRECTIONAL = 0x03,   /**< Signal direction is bidirectional. */
-} apalGpioDirection_t;
+typedef uint8_t apalGpioDirection_t;
+
+/**
+ * @brief   Signal direction for the control GPIO is undefined.
+ */
+#define APAL_GPIO_DIRECTION_UNDEFINED           ((apalGpioDirection_t)0)
+
+/**
+ * @brief   Signal direction for the control GPIO is input only.
+ */
+#define APAL_GPIO_DIRECTION_INPUT               ((apalGpioDirection_t)1)
+
+/**
+ * @brief   Signal direction for the control GPIO is output only.
+ */
+#define APAL_GPIO_DIRECTION_OUTPUT              ((apalGpioDirection_t)2)
+
+/**
+ * @brief   Signal direction for the control GPIO is didirectional.
+ */
+#define APAL_GPIO_DIRECTION_BIDIRECTIONAL       ((apalGpioDirection_t)3)
+
+/**
+ * @brief   Informative or effective signal edge for control GPIOs.
+ */
+typedef uint8_t apalGpioEdge_t;
 
 /**
- * @brief   Informative signal edge for input control GPIOs.
+ * @brief   No edges indicate an interrupt or trigger an action.
  */
-typedef enum {
-  APAL_GPIO_EDGE_NONE     = 0x00,   /**< No edge indicates an interrupt.                      */
-  APAL_GPIO_EDGE_RISING   = 0x01,   /**< Rising edges indicate an interrupt.                  */
-  APAL_GPIO_EDGE_FALLING  = 0x02,   /**< Falling edges indicate an interrupt.                 */
-  APAL_GPIO_EDGE_BOTH     = 0x03,   /**< Both rising and falling edges indicate an interrupt. */
-} apalGpioEdge_t;
+#define APAL_GPIO_EDGE_NONE                     ((apalGpioEdge_t)0)
 
 /**
- * @brief   Inverts the value of the informative signal edge for interrupts.
+ * @brief   Rising edges indicate an interrupt or trigger an action.
+ */
+#define APAL_GPIO_EDGE_RISING                   ((apalGpioEdge_t)1)
+
+/**
+ * @brief   Falling edges indicate an interrupt or trigger an action.
+ */
+#define APAL_GPIO_EDGE_FALLING                  ((apalGpioEdge_t)2)
+
+/**
+ * @brief   Both rising and falling edges indicate an interrupt or trigger an action.
+ */
+#define APAL_GPIO_EDGE_BOTH                     ((apalGpioEdge_t)3)
+
+/**
+ * @brief   Inverts the value of the informative or effective signal edge for interrupts.
  * @details Rising edge is inverted to falling and vice versa.
  *          If none or both edges are enabled, the identical value is returned.
  */
-#define APAL_GPIO_EDGE_INVERT(edge)                                 \
-  ((edge == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_EDGE_FALLING :       \
-   (edge == APAL_GPIO_EDGE_FALLING) ? APAL_GPIO_EDGE_RISING : edge) \
+#define APAL_GPIO_EDGE_INVERT(edge) (                                         \
+  (((apalGpioEdge_t)edge & APAL_GPIO_EDGE_RISING) ^                           \
+   ((apalGpioEdge_t)edge & APAL_GPIO_EDGE_FALLING)) ?                         \
+  ((apalGpioEdge_t)edge ^ APAL_GPIO_EDGE_BOTH) :                              \
+  ((apalGpioEdge_t)edge)                                                      \
+)
 
 /**
  * @brief Control GPIO meta information
  */
 typedef struct {
   apalGpioDirection_t direction : 2;  /**< Direction configuration for according signals */
-  apalGpioActive_t active       : 1;  /**< Active state of the GPIO */
+  apalGpioActive_t active       : 2;  /**< Active state of the GPIO */
   apalGpioEdge_t edge           : 2;  /**< Edge configuration for according signals */
 } apalGpioMeta_t;
 
@@ -167,13 +281,19 @@ typedef uint32_t  apalPWMfrequency_t;
 typedef uint32_t  apalPWMperiod_t;
 
 /**
- * @brief PWM width limits and special values.
+ * @brief   PWM width to turn off the PWM.
  */
-typedef enum {
-  APAL_PWM_WIDTH_OFF  = 0x0000u,  /**< PWM off            */
-  APAL_PWM_WIDTH_MIN  = 0x0000u,  /**< PWM minimum width  */
-  APAL_PWM_WIDTH_MAX  = 0xFFFFu,  /**< PWM maximum width  */
-} apalPWMWidthLimit_t;
+#define APAL_PWM_WIDTH_OFF                      ((apalPWMwidth_t)0x0000u)
+
+/**
+ * @brief   Minimum allowed PWM width.
+ */
+#define APAL_PWM_WIDTH_MIN                      ((apalPWMwidth_t)0x0000u)
+
+/**
+ * @brief   Maximum allowed PWM width.
+ */
+#define APAL_PWM_WIDTH_MAX                      ((apalPWMwidth_t)0xFFFFu)
 
 /*============================================================================*/
 /* QEI                                                                        */
@@ -187,10 +307,17 @@ typedef uint32_t  apalQEICount_t;
 /**
  * @brief Direction of the QEI.
  */
-typedef enum {
-  APAL_QEI_DIRECTION_UP   = 0,  /**< QEI counted up   */
-  APAL_QEI_DIRECTION_DOWN = 1,  /**< QEI counted down */
-} apalQEIDirection_t;
+typedef uint8_t apalQEIDirection_t;
+
+/*
+ * @brief   QEI counts upwards.
+ */
+#define APAL_QEI_DIRECTION_UP                   ((apalQEIDirection_t)0)
+
+/*
+ * @brief   QEI counts downwards.
+ */
+#define APAL_QEI_DIRECTION_DOWN                 ((apalQEIDirection_t)1)
 
 /*============================================================================*/
 /* I2C                                                                        */
@@ -205,5 +332,6 @@ typedef uint16_t apalI2Caddr_t;
 /* SPI                                                                        */
 /*============================================================================*/
 
+/* nothing defined for SPI */
 
 #endif /* AMIROLLD_PERIPHALTYPES_H */
