AvrIO  1.4.5
Bibliothèque C modulaire pour ATMEL AVR
task.h
1 
18 #ifndef _AVRIO_KERNEL_H_
19 #define _AVRIO_KERNEL_H_
20 
21 #include <util/atomic.h>
22 #include <avrio/delay.h>
23 __BEGIN_C_DECLS
24 /* ======================================================================== */
49 /* constants ============================================================== */
53 # define AVRIO_KERNEL_ERROR (-1)
54 /* types ================================================================== */
58 typedef int8_t xTaskHandle;
59 
63 typedef void (*xTaskFunction) (xTaskHandle);
64 
65 /* internal public functions ================================================ */
74 xTaskHandle xTaskCreate (ticks_t xIntervalTicks, xTaskFunction xFunction);
75 
80 void vTaskDelete (xTaskHandle t);
81 
85 void vTaskSetInterval (xTaskHandle t, ticks_t xIntervalTicks);
86 
93 void vTaskStart (xTaskHandle t);
94 
100 void vTaskStop (xTaskHandle t);
101 
107 bool xTaskIsStarted (xTaskHandle t);
108 
112 ticks_t xTaskSystemTime (void);
113 
114 #if defined(__DOXYGEN__)
115 /*
116  * __DOXYGEN__ defined
117  * Partie documentation ne devant pas être compilée.
118  * =============================================================================
119  */
120 
124 ticks_t xTaskGetInterval (xTaskHandle t);
125 
129 ticks_t xTaskConvertMs (time_t xTimeMs);
130 
134 time_t xTaskConvertTicks (ticks_t xTicks);
135 
140 inline void vTaskRewind (xTaskHandle t);
141 
148 inline void vTaskSetUserData (xTaskHandle t, void * data);
149 
156 inline void * pvTaskGetUserData (xTaskHandle t);
157 
162 # else
163 /*
164  * __DOXYGEN__ not defined
165  * Partie ne devant pas être documentée.
166  * =============================================================================
167  */
168 
169 #define xTaskConvertMs(ms) xDelayMsToTicks(ms)
170 #define xTaskConvertTicks(t) xDelayTicksToMs(t)
171 
172 /* structures =============================================================== */
173 typedef struct xTask {
174  ticks_t xInterval; /* période en ticks d'exécution de la fonction */
175  ticks_t xValue; /* valeur courante en ticks de la tâche */
176  xTaskFunction xFunction; /* pointeur sur la fonction de la tâche */
177  void * udata;
178 } xTask;
179 
180 /* public variables ========================================================= */
181 extern volatile xTask pxTasks[];
182 
183 /* inline public functions ================================================== */
184 INLINE void
186 
187  vTaskStop (t);
188  vTaskStart (t);
189 }
190 
191 // -----------------------------------------------------------------------------
192 INLINE void
193 vTaskSetUserData (xTaskHandle i, void * data) {
194 
195  pxTasks[i].udata = data;
196 }
197 
198 // -----------------------------------------------------------------------------
199 INLINE void *
201 
202  return pxTasks[i].udata;
203 }
204 
205 // -----------------------------------------------------------------------------
206 INLINE ticks_t
208 
209  return pxTasks[i].xInterval + 1;
210 }
211 
212 # endif /* __DOXYGEN__ not defined */
213 /* ========================================================================== */
214 __END_C_DECLS
215 #endif /* _AVRIO_KERNEL_H_ */
ticks_t xTaskConvertMs(time_t xTimeMs)
Convertit une valeur de temps (millisecondes) en ticks.
time_t xTaskConvertTicks(ticks_t xTicks)
Convertit une valeur de ticks en millisecondes.
ticks_t xTaskGetInterval(xTaskHandle t)
Lit la période d&#39;une tâche.
int8_t xTaskHandle
xTaskHandle Identifiant d&#39;une tâche
Definition: task.h:58
ticks_t xTaskSystemTime(void)
Renvoie le nombre de ticks depuis le démarrage du système.
void(* xTaskFunction)(xTaskHandle)
La fonction d&#39;une tâche ne renvoit rien et reçoit son identifiant.
Definition: task.h:63
void * pvTaskGetUserData(xTaskHandle t)
Renvoie la variable utilisateur d&#39;une tâche.
xTaskHandle xTaskCreate(ticks_t xIntervalTicks, xTaskFunction xFunction)
Ajout d&#39;une tâche.
void vTaskSetInterval(xTaskHandle t, ticks_t xIntervalTicks)
Modifie la période d&#39;une tâche.
void vTaskDelete(xTaskHandle t)
Suppression d&#39;une tâche.
void vTaskRewind(xTaskHandle t)
Rembobine le décompte d&#39;une tâche.
void vTaskStop(xTaskHandle t)
Arrête une tâche.
bool xTaskIsStarted(xTaskHandle t)
Indique si une tâche est lancée.
void vTaskSetUserData(xTaskHandle t, void *data)
Modifie la variable utilisateur d&#39;une tâche.
void vTaskStart(xTaskHandle t)
Démarre une tâche.