AvrIO  1.4.5
Bibliothèque C modulaire pour ATMEL AVR
icounter.h
1 
18 #ifndef _AVRIO_ICOUNTER_H_
19 #define _AVRIO_ICOUNTER_H_
20 #include <avrio/task.h>
21 #include <avrio/irq.h>
22 #include <avrio/mutex.h>
23 
24 __BEGIN_C_DECLS
25 /* ========================================================================== */
26 
39 /* constants ================================================================ */
43 typedef enum eICounterMode {
47 
48 /* structures =============================================================== */
49 
55 struct xICounter;
56 
57 /* types ==================================================================== */
58 
59 /* internal public functions ================================================ */
66 void vICounterInit (struct xICounter * c, xIrqHandle i);
67 
73 void vICounterStart (struct xICounter * c);
74 
81 void vICounterSetMode (struct xICounter * c, eICounterMode m);
82 
89 void vICounterSetWindow (struct xICounter * c, uint16_t usWindowMs);
90 
97 bool bICounterIsComplete (struct xICounter * c);
98 
104 void vICounterWaitForComplete (struct xICounter * c);
105 
112 double dICounterFreq (struct xICounter * c);
113 
120 uint16_t usICounterCount (struct xICounter * c);
121 
122 #if defined(__DOXYGEN__)
123 /*
124  * __DOXYGEN__ defined
125  * Partie documentation ne devant pas être compilée.
126  * =============================================================================
127  */
134 inline eICounterMode eCounterGetMode (struct xICounter * c);
135 
142 inline uint16_t usICounterGetWindow (struct xICounter * c);
148 #else
149 /*
150  * __DOXYGEN__ not defined
151  * Partie ne devant pas être documentée.
152  * =============================================================================
153  */
154 typedef struct xICounter {
155  xTaskHandle xTask;
156  xMutex xReady;
157  xIrqHandle xInt;
158  eICounterMode eMode;
159  volatile uint16_t usCounter;
160  uint16_t usLastValue;
161  uint16_t usWindow;
162 } xICounter;
163 
164 /* inline public functions ================================================== */
165 
166 // -----------------------------------------------------------------------------
167 INLINE eICounterMode
168 eICounterGetMode (struct xICounter * c) {
169  return c->eMode;
170 }
171 
172 // -----------------------------------------------------------------------------
173 INLINE uint16_t
174 usICounterGetWindow (struct xICounter * c) {
175  return c->usWindow;
176 }
177 #endif /* __DOXYGEN__ not defined */
178 
179 /* ========================================================================== */
180 __END_C_DECLS
181 #endif /* _AVRIO_ICOUNTER_H_ */
eICounterMode
Mode de fonctionnement d&#39;un compteur.
Definition: icounter.h:43
int8_t xTaskHandle
xTaskHandle Identifiant d&#39;une tâche
Definition: task.h:58
void vICounterWaitForComplete(struct xICounter *c)
Attends que la mesure se termine.
void vICounterSetMode(struct xICounter *c, eICounterMode m)
Modifie le mode de fonctionnement.
volatile uint8_t xMutex
Type mutex.
Definition: mutex.h:59
eICounterMode eCounterGetMode(struct xICounter *c)
Lecture du mode de fonctionnement.
double dICounterFreq(struct xICounter *c)
Dernière fréqunence.
uint16_t usICounterGetWindow(struct xICounter *c)
Lecture de la durée de la fenêtre de mesure.
bool bICounterIsComplete(struct xICounter *c)
Teste si la mesure est terminée.
void vICounterInit(struct xICounter *c, xIrqHandle i)
Initialisation d&#39;un compteur.
void vICounterSetWindow(struct xICounter *c, uint16_t usWindowMs)
Modifie la durée de la fenêtre de mesure.
void vICounterStart(struct xICounter *c)
Démarre la mesure.
uint16_t usICounterCount(struct xICounter *c)
Dernier comptage.
int8_t xIrqHandle
Désigne le numéro d&#39;une interruption.
Definition: irq.h:119