aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/osal/os-less/AVR
diff options
context:
space:
mode:
authorFabio Utzig <utzig@utzig.org>2017-03-23 13:20:48 +0000
committerFabio Utzig <utzig@utzig.org>2017-03-23 13:20:48 +0000
commit5acf1106551fd474f98458f68704acb599b02da8 (patch)
treeefb9591c1f31d86324e64f0e51845f495f62eef9 /os/hal/osal/os-less/AVR
parentc75384d31a937724eafc5a3a22a68a7d2152f710 (diff)
downloadChibiOS-5acf1106551fd474f98458f68704acb599b02da8.tar.gz
ChibiOS-5acf1106551fd474f98458f68704acb599b02da8.tar.bz2
ChibiOS-5acf1106551fd474f98458f68704acb599b02da8.zip
Updated AVR os-less for new osal_vt
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@10128 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/osal/os-less/AVR')
-rw-r--r--os/hal/osal/os-less/AVR/osal.c115
-rw-r--r--os/hal/osal/os-less/AVR/osal.h48
2 files changed, 1 insertions, 162 deletions
diff --git a/os/hal/osal/os-less/AVR/osal.c b/os/hal/osal/os-less/AVR/osal.c
index 2f31a190f..c1a7ac3a4 100644
--- a/os/hal/osal/os-less/AVR/osal.c
+++ b/os/hal/osal/os-less/AVR/osal.c
@@ -23,6 +23,7 @@
*/
#include "osal.h"
+#include "osal_vt.h"
/*===========================================================================*/
/* Module local definitions. */
@@ -39,11 +40,6 @@
*/
const char *osal_halt_msg;
-/**
- * @brief Virtual timers delta list header.
- */
-virtual_timers_list_t vtlist;
-
/*===========================================================================*/
/* Module local types. */
/*===========================================================================*/
@@ -56,115 +52,6 @@ virtual_timers_list_t vtlist;
/* Module local functions. */
/*===========================================================================*/
-/**
- * @brief Timers initialization.
- *
- * @notapi
- */
-static void vtInit(void) {
-
- /* Virtual Timers initialization.*/
- vtlist.vt_next = vtlist.vt_prev = (void *)&vtlist;
- vtlist.vt_time = (systime_t)-1;
- vtlist.vt_systime = 0;
-}
-
-/**
- * @brief Returns @p TRUE if the specified timer is armed.
- *
- * @param[out] vtp the @p virtual_timer_t structure pointer
- *
- * @notapi
- */
-static bool vtIsArmedI(virtual_timer_t *vtp) {
-
- return vtp->vt_func != NULL;
-}
-
-/**
- * @brief Virtual timers ticker.
- * @note The system lock is released before entering the callback and
- * re-acquired immediately after. It is callback's responsibility
- * to acquire the lock if needed. This is done in order to reduce
- * interrupts jitter when many timers are in use.
- *
- * @notapi
- */
-static void vtDoTickI(void) {
-
- vtlist.vt_systime++;
- if (&vtlist != (virtual_timers_list_t *)vtlist.vt_next) {
- virtual_timer_t *vtp;
-
- --vtlist.vt_next->vt_time;
- while (!(vtp = vtlist.vt_next)->vt_time) {
- vtfunc_t fn = vtp->vt_func;
- vtp->vt_func = (vtfunc_t)NULL;
- vtp->vt_next->vt_prev = (void *)&vtlist;
- (&vtlist)->vt_next = vtp->vt_next;
- osalSysUnlockFromISR();
- fn(vtp->vt_par);
- osalSysLockFromISR();
- }
- }
-}
-
-/**
- * @brief Enables a virtual timer.
- * @note The associated function is invoked from interrupt context.
- *
- * @param[out] vtp the @p virtual_timer_t structure pointer
- * @param[in] time the number of ticks before the operation timeouts, the
- * special values are handled as follow:
- * - @a TIME_INFINITE is allowed but interpreted as a
- * normal time specification.
- * - @a TIME_IMMEDIATE this value is not allowed.
- * .
- * @param[in] vtfunc the timer callback function. After invoking the
- * callback the timer is disabled and the structure can
- * be disposed or reused.
- * @param[in] par a parameter that will be passed to the callback
- * function
- *
- * @notapi
- */
-static void vtSetI(virtual_timer_t *vtp, systime_t time,
- vtfunc_t vtfunc, void *par) {
- virtual_timer_t *p;
-
- vtp->vt_par = par;
- vtp->vt_func = vtfunc;
- p = vtlist.vt_next;
- while (p->vt_time < time) {
- time -= p->vt_time;
- p = p->vt_next;
- }
-
- vtp->vt_prev = (vtp->vt_next = p)->vt_prev;
- vtp->vt_prev->vt_next = p->vt_prev = vtp;
- vtp->vt_time = time;
- if (p != (void *)&vtlist)
- p->vt_time -= time;
-}
-
-/**
- * @brief Disables a Virtual Timer.
- * @note The timer MUST be active when this function is invoked.
- *
- * @param[in] vtp the @p virtual_timer_t structure pointer
- *
- * @notapi
- */
-static void vtResetI(virtual_timer_t *vtp) {
-
- if (vtp->vt_next != (void *)&vtlist)
- vtp->vt_next->vt_time += vtp->vt_time;
- vtp->vt_prev->vt_next = vtp->vt_next;
- vtp->vt_next->vt_prev = vtp->vt_prev;
- vtp->vt_func = (vtfunc_t)NULL;
-}
-
-
static void callback_timeout(void *p) {
osalSysLockFromISR();
osalThreadResumeI((thread_reference_t *)p, MSG_TIMEOUT);
diff --git a/os/hal/osal/os-less/AVR/osal.h b/os/hal/osal/os-less/AVR/osal.h
index f0ae5d372..eeb348050 100644
--- a/os/hal/osal/os-less/AVR/osal.h
+++ b/os/hal/osal/os-less/AVR/osal.h
@@ -166,54 +166,6 @@ typedef int16_t msg_t;
typedef uint32_t systime_t;
/**
- * @brief Type of a Virtual Timer callback function.
- */
-typedef void (*vtfunc_t)(void *);
-
-/**
- * @brief Type of a Virtual Timer structure.
- */
-typedef struct virtual_timer virtual_timer_t;
-
-/**
- * @brief Virtual timers list header.
- * @note The content of this structure is not part of the API and should
- * not be relied upon. Implementers may define this structure in
- * an entirely different way.
- * @note The delta list is implemented as a double link bidirectional list
- * in order to make the unlink time constant, the reset of a virtual
- * timer is often used in the code.
- */
-typedef struct {
- virtual_timer_t *vt_next; /**< @brief Next timer in the timers
- list. */
- virtual_timer_t *vt_prev; /**< @brief Last timer in the timers
- list. */
- systime_t vt_time; /**< @brief Must be initialized to -1. */
- volatile systime_t vt_systime; /**< @brief System Time counter. */
-} virtual_timers_list_t;
-
-/**
- * @extends virtual_timers_list_t
- *
- * @brief Virtual Timer descriptor structure.
- * @note The content of this structure is not part of the API and should
- * not be relied upon. Implementers may define this structure in
- * an entirely different way.
- */
-struct virtual_timer {
- virtual_timer_t *vt_next; /**< @brief Next timer in the timers
- list. */
- virtual_timer_t *vt_prev; /**< @brief Previous timer in the timers
- list. */
- systime_t vt_time; /**< @brief Time delta before timeout. */
- vtfunc_t vt_func; /**< @brief Timer callback function
- pointer. */
- void *vt_par; /**< @brief Timer callback function
- parameter. */
-};
-
-/**
* @brief Type of realtime counter.
*/
typedef uint32_t rtcnt_t;