commit 23ec8223744a9d361188b06131f00fcad1f90e9b
Author: Thomas Schöpping <tschoepp@cit-ec.uni-bielefeld.de>
Date:   Tue Feb 4 18:09:22 2020 +0100

    timer and periodic timer have been unified in a single functional unit: timer.
    
    The resulting timer object is slightly larger than one-shot timers have been, but much smaller than periodic timers.
    Size of resulting binary has been slightly decreased as well.

diff --git a/core/inc/aos_timer.h b/core/inc/aos_timer.h
index f377d90..cdd3c38 100644
--- a/core/inc/aos_timer.h
+++ b/core/inc/aos_timer.h
@@ -66,7 +66,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 /******************************************************************************/
 
 /**
- * @brief   Timer stucture.
+ * @brief   Timer structure.
  */
 typedef struct aos_timer {
   /**
@@ -75,32 +75,13 @@ typedef struct aos_timer {
   virtual_timer_t vt;
 
   /**
-   * @brief   Time to wake up.
+   * @brief   Absolute time to trigger.
    */
-  aos_timestamp_t wkuptime;
+  aos_timestamp_t triggertime;
 
   /**
-   * @brief   Pointer to a callback function.
-   */
-  vtfunc_t callback;
-
-  /**
-   * @brief   Pointer to a parameter for the callback function.
-   */
-  void* cbparam;
-} aos_timer_t;
-
-/**
- * @brief   Periodic timer structure.
- */
-typedef struct aos_periodictimer {
-  /**
-   * @brief   AMiRo-OS timer.
-   */
-  aos_timer_t timer;
-
-  /**
-   * @brief   Period interval.
+   * @brief   Relative interval for periodic timers.
+   * @note    A value of 0 indicates single shot timing.
    */
   aos_longinterval_t interval;
 
@@ -113,7 +94,7 @@ typedef struct aos_periodictimer {
    * @brief   Pointer to a parameter for the callback function.
    */
   void* cbparam;
-} aos_periodictimer_t;
+} aos_timer_t;
 
 /******************************************************************************/
 /* MACROS                                                                     */
@@ -127,12 +108,11 @@ typedef struct aos_periodictimer {
 extern "C" {
 #endif /* defined(__cplusplus) */
   void aosTimerInit(aos_timer_t* timer);
-  void aosTimerSetAbsoluteI(aos_timer_t* timer, aos_timestamp_t* uptime, vtfunc_t cb, void* par);
-  void aosTimerSetIntervalI(aos_timer_t* timer, aos_interval_t offset, vtfunc_t cb, void* par);
-  void aosTimerSetLongIntervalI(aos_timer_t* timer, aos_longinterval_t* offset, vtfunc_t cb, void* par);
-  void aosPeriodicTimerInit(aos_periodictimer_t* ptimer);
-  void aosPeriodicTimerSetI(aos_periodictimer_t* ptimer, aos_interval_t interval, vtfunc_t cb, void* par);
-  void aosPeriodicTimerSetLongI(aos_periodictimer_t* ptimer, aos_longinterval_t* interval, vtfunc_t cb, void* par);
+  void aosTimerSetAbsoluteI(aos_timer_t* timer, const aos_timestamp_t uptime, vtfunc_t cb, void* par);
+  void aosTimerSetIntervalI(aos_timer_t* timer, const aos_interval_t offset, vtfunc_t cb, void* par);
+  void aosTimerSetLongIntervalI(aos_timer_t* timer, const aos_longinterval_t offset, vtfunc_t cb, void* par);
+  void aosTimerPeriodicIntervalI(aos_timer_t* timer, const aos_interval_t interval, vtfunc_t cb, void* par);
+  void aosTimerPeriodicLongIntervalI(aos_timer_t* timer, const aos_longinterval_t interval, vtfunc_t cb, void* par);
 #if defined(__cplusplus)
 }
 #endif /* defined(__cplusplus) */
@@ -142,14 +122,14 @@ extern "C" {
 /******************************************************************************/
 
 /**
- * @brief   Set timer to fire at an absolute system time.
+ * @brief   Set timer to trigger at an absolute system time.
  *
  * @param[in] timer   Pointer to the timer to set.
- * @param[in] uptime  Pointer to the absolute uptime for the timer to fire.
+ * @param[in] uptime  Absolute uptime for the timer to trigger.
  * @param[in] cb      Pointer to a callback function to be called.
- * @param[in] par     Pointer to a parameter fpr the callback function (may be NULL).
+ * @param[in] par     Pointer to a parameter for the callback function (may be NULL).
  */
-static inline void aosTimerSetAbsolute(aos_timer_t* timer, aos_timestamp_t* uptime, vtfunc_t cb, void* par)
+static inline void aosTimerSetAbsolute(aos_timer_t* timer, const aos_timestamp_t uptime, vtfunc_t cb, void* par)
 {
   chSysLock();
   aosTimerSetAbsoluteI(timer, uptime, cb, par);
@@ -159,14 +139,16 @@ static inline void aosTimerSetAbsolute(aos_timer_t* timer, aos_timestamp_t* upti
 }
 
 /**
- * @brief   Set timer to fire after a relative interval.
+ * @brief   Set timer to trigger after a relative interval.
  *
  * @param[in] timer   Pointer to the timer to set.
- * @param[in] offset  Relative interval to set for the timer to fire.
+ * @param[in] offset  Relative interval to set for the timer to trigger.
  * @param[in] cb      Pointer to a callback function to be called.
- * @param[in] par     Pointer to a parameter fpr the callback function (may be NULL).
+ *                    In contrast to other callback functions, this gets called from an already ISR locked context.
+ *                    Thus it may not contain any chSysLockX() or chSysUnlockX() calls.
+ * @param[in] par     Pointer to a parameter for the callback function (may be NULL).
  */
-static inline void aosTimerSetInterval(aos_timer_t* timer, aos_interval_t offset, vtfunc_t cb, void* par)
+static inline void aosTimerSetInterval(aos_timer_t* timer, const aos_interval_t offset, vtfunc_t cb, void* par)
 {
   chSysLock();
   aosTimerSetIntervalI(timer, offset, cb, par);
@@ -174,14 +156,16 @@ static inline void aosTimerSetInterval(aos_timer_t* timer, aos_interval_t offset
 }
 
 /**
- * @brief   Set timer to fire after a long relative interval.
+ * @brief   Set timer to trigger after a long relative interval.
  *
  * @param[in] timer   Pointer to the timer to set.
- * @param[in] offset  Pointer to a long interval value to set for the timer to fire.
+ * @param[in] offset  Long interval value to set for the timer to trigger.
  * @param[in] cb      Pointer to a callback function to be called.
- * @param[in] par     Pointer to a parameter fpr the callback function (may be NULL).
+ *                    In contrast to other callback functions, this gets called from an already ISR locked context.
+ *                    Thus it may not contain any chSysLockX() or chSysUnlockX() calls.
+ * @param[in] par     Pointer to a parameter for the callback function (may be NULL).
  */
-static inline void aosTimerSetLongInterval(aos_timer_t* timer, aos_longinterval_t* offset, vtfunc_t cb, void* par)
+static inline void aosTimerSetLongInterval(aos_timer_t* timer, const aos_longinterval_t offset, vtfunc_t cb, void* par)
 {
   chSysLock();
   aosTimerSetLongIntervalI(timer, offset, cb, par);
@@ -189,26 +173,38 @@ static inline void aosTimerSetLongInterval(aos_timer_t* timer, aos_longinterval_
 }
 
 /**
- * @brief   Reset a timer.
+ * @brief   Set timer to trigger periodically in the specified interval.
  *
- * @param[in] timer   Pointer to the timer to reset.
+ * @param[in] timer     Pointer to the timer to set.
+ * @param[in] interval  Interval for the timer to trigger periodically.
+ * @param[in] cb        Pointer to a callback function to be called.
+ *                      In contrast to other callback functions, this gets called from an already ISR locked context.
+ *                      Thus it may not contain any chSysLockX() or chSysUnlockX() calls.
+ * @param[in] par       Pointer to a parameter for the callback function (may be NULL).
  */
-static inline void aosTimerResetI(aos_timer_t* timer)
+static inline void aosTimerPeriodicInterval(aos_timer_t *timer, const aos_interval_t interval, vtfunc_t cb, void *par)
 {
-  chVTResetI(&(timer->vt));
+  chSysLock();
+  aosTimerPeriodicIntervalI(timer, interval, cb, par);
+  chSysUnlock();
 
   return;
 }
 
 /**
- * @brief   Reset a timer.
+ * @brief   Set timer to trigger periodically in the specified interval.
  *
- * @param[in] timer   Pointer to the timer to reset.
+ * @param[in] timer     Pointer to the timer to set.
+ * @param[in] interval  Long interval value for the periodic timer to trigger periodically.
+ * @param[in] cb        Pointer to a callback function to be called.
+ *                      In contrast to other callback functions, this get called from an already ISR locked context.
+ *                      This it may not contain any chSysLockX() or chSysUnlockX() calls.
+ * @param[in] par       Pointer to a parameter for the callback function (may be NULL).
  */
-static inline void aosTimerReset(aos_timer_t* timer)
+static inline void aosTimerPeriodicLongInterval(aos_timer_t* timer, const aos_longinterval_t interval, vtfunc_t cb, void* par)
 {
   chSysLock();
-  aosTimerResetI(timer);
+  aosTimerPeriodicLongIntervalI(timer, interval, cb, par);
   chSysUnlock();
 
   return;
@@ -245,38 +241,27 @@ static inline bool aosTimerIsArmed(aos_timer_t* timer)
 }
 
 /**
- * @brief   Set a periodic timer to fire in the specified interval.
+ * @brief   Reset a timer.
  *
- * @param[in] ptimer    Pointer to the periodic timer to set.
- * @param[in] interval  Interval for the periodic timer to fire,
- * @param[in] cb        Pointer to a callback function to be called.
- *                      In contrast to other callback functions, this get called from an already ISR locked context.
- *                      This it may not contain any chSysLockX() or chSysUnlockX() calls.
- * @param[in] par       Pointer to a parameter for the callback function (may be NULL).
+ * @param[in] timer   Pointer to the timer to reset.
  */
-static inline void aosPeriodicTimerSet(aos_periodictimer_t *ptimer, aos_interval_t interval, vtfunc_t cb, void *par)
+static inline void aosTimerResetI(aos_timer_t* timer)
 {
-  chSysLock();
-  aosPeriodicTimerSetI(ptimer, interval, cb, par);
-  chSysUnlock();
+  chVTResetI(&(timer->vt));
+  timer->interval = 0;
 
   return;
 }
 
 /**
- * @brief   Set a periodic timer to fire in the specified interval.
+ * @brief   Reset a timer.
  *
- * @param[in] ptimer    Pointer to the periodic timer to set.
- * @param[in] interval  Pointer to a long interval value for the periodic timer to fire,
- * @param[in] cb        Pointer to a callback function to be called.
- *                      In contrast to other callback functions, this get called from an already ISR locked context.
- *                      This it may not contain any chSysLockX() or chSysUnlockX() calls.
- * @param[in] par       Pointer to a parameter for the callback function (may be NULL).
+ * @param[in] timer   Pointer to the timer to reset.
  */
-static inline void aosPeriodicTimerSetLong(aos_periodictimer_t* ptimer, aos_longinterval_t* interval, vtfunc_t cb, void* par)
+static inline void aosTimerReset(aos_timer_t* timer)
 {
   chSysLock();
-  aosPeriodicTimerSetLongI(ptimer, interval, cb, par);
+  aosTimerResetI(timer);
   chSysUnlock();
 
   return;
