AvrIO  1.4.5
Bibliothèque C modulaire pour ATMEL AVR
counter.h
1 
18 #ifndef _AVRIO_COUNTER_H_
19 #define _AVRIO_COUNTER_H_
20 #include <avrio/task.h>
21 #include <avrio/mutex.h>
22 
23 __BEGIN_C_DECLS
24 /* ========================================================================== */
25 
40 /* constants ================================================================ */
44 typedef enum eCounterMode {
47 } eCounterMode;
48 
49 /* structures =============================================================== */
53 struct xCounterOps {
54  void (*init) (void); /***< Initialisation du comptage */
55  uint16_t (*read) (void);
56  void (*clear) (void);
57  void (*enable) (bool);
58 };
59 
65 struct xCounter;
66 
67 /* types ==================================================================== */
68 typedef struct xCounterOps xCounterOps;
69 
70 /* internal public functions ================================================ */
77 void vCounterInit (struct xCounter * c, xCounterOps * o);
78 
84 void vCounterStart (struct xCounter * c);
85 
92 void vCounterSetMode (struct xCounter * c, eCounterMode m);
93 
100 void vCounterSetWindow (struct xCounter * c, uint16_t usWindowMs);
101 
108 bool bCounterIsComplete (struct xCounter * c);
109 
115 void vCounterWaitForComplete (struct xCounter * c);
116 
123 double dCounterFreq (struct xCounter * c);
124 
131 uint16_t usCounterCount (struct xCounter * c);
132 
133 #if defined(__DOXYGEN__)
134 /*
135  * __DOXYGEN__ defined
136  * Partie documentation ne devant pas être compilée.
137  * =============================================================================
138  */
145 inline eCounterMode eCounterGetMode (struct xCounter * c);
146 
153 inline uint16_t usCounterGetWindow (struct xCounter * c);
159 #else
160 /*
161  * __DOXYGEN__ not defined
162  * Partie ne devant pas être documentée.
163  * =============================================================================
164  */
165 typedef struct xCounter {
166  xTaskHandle xTask;
167  xMutex xReady;
168  eCounterMode eMode;
169  uint16_t usLastValue;
170  uint16_t usWindow;
171  xCounterOps * xOps;
172 } xCounter;
173 
174 /* inline public functions ================================================== */
175 
176 // -----------------------------------------------------------------------------
177 INLINE eCounterMode
178 eCounterGetMode (struct xCounter * c) {
179  return c->eMode;
180 }
181 
182 // -----------------------------------------------------------------------------
183 INLINE uint16_t
184 usCounterGetWindow (struct xCounter * c) {
185  return c->usWindow;
186 }
187 
188 #endif /* __DOXYGEN__ not defined */
189 
190 /* ========================================================================== */
191 __END_C_DECLS
192 #endif /* _AVRIO_COUNTER_H_ */
double dCounterFreq(struct xCounter *c)
Dernière fréqunence.
void vCounterStart(struct xCounter *c)
Démarre la mesure.
int8_t xTaskHandle
xTaskHandle Identifiant d&#39;une tâche
Definition: task.h:58
uint16_t usCounterGetWindow(struct xCounter *c)
Lecture de la durée de la fenêtre de mesure.
void(* clear)(void)
Definition: counter.h:56
uint16_t(* read)(void)
Definition: counter.h:55
void vCounterSetWindow(struct xCounter *c, uint16_t usWindowMs)
Modifie la durée de la fenêtre de mesure.
volatile uint8_t xMutex
Type mutex.
Definition: mutex.h:59
void vCounterInit(struct xCounter *c, xCounterOps *o)
Initialisation d&#39;un compteur.
bool bCounterIsComplete(struct xCounter *c)
Teste si la mesure est terminée.
void vCounterSetMode(struct xCounter *c, eCounterMode m)
Modifie le mode de fonctionnement.
void(* enable)(bool)
Definition: counter.h:57
uint16_t usCounterCount(struct xCounter *c)
Dernier comptage.
eCounterMode
Mode de fonctionnement d&#39;un compteur.
Definition: counter.h:44
eCounterMode eCounterGetMode(struct xCounter *c)
Lecture du mode de fonctionnement.
void vCounterWaitForComplete(struct xCounter *c)
Attends que la mesure se termine.