AvrIO  1.4.5
Bibliothèque C modulaire pour ATMEL AVR
gpio.h
1 
18 #ifndef _AVRIO_GPIO_H_
19 #define _AVRIO_GPIO_H_
20 
21 #include <avrio/defs.h>
22 __BEGIN_C_DECLS
23 /* ========================================================================== */
24 #include <avrio/dpin.h>
25 
41 /* constants ================================================================ */
42 
43 /* types ==================================================================== */
47 typedef unsigned int uGpioMask;
48 
60 typedef void (*vGpioCallback) (uGpioMask uPinValues, uint8_t ucPin, eDpEdge edge, void *udata);
61 
62 /* internal public functions ================================================ */
63 
70 void vGpioWrite (uint8_t ucPin, bool bValue);
71 
77 void vGpioToggle (uint8_t ucPin);
78 
86 void vGpioSetPinEdge (uint8_t ucPin, eDpEdge edge);
87 
99 void vGpioWriteAll (uGpioMask uPinMask, bool bValue);
100 
109 void vGpioToggleAll (uGpioMask uPinMask);
110 
123 uGpioMask uGpioReadAll (uGpioMask uPinMask);
124 
135 void vGpioPoll (void);
136 
137 # if defined(__DOXYGEN__)
138 /*
139  * __DOXYGEN__ defined
140  * Partie documentation ne devant pas être compilée.
141  * =============================================================================
142  */
148 static inline void vGpioSetPinMode (uint8_t ucPin, eDpMode eMode);
149 
157 static inline eDpMode eGpioPinMode (uint8_t ucPin);
158 
165 static inline eDpEdge eGpioPinEdge (uint8_t ucPin);
166 
172 static inline void vGpioSetCallback (vGpioCallback callback);
173 
179 static inline vGpioCallback pvGpioCallback (void);
180 
186 static inline void * pGpioUserData (void);
187 
193 static inline void vGpioSetUserData (void * udata);
194 
202 static inline bool bGpioRead (uint8_t ucPin);
203 
209 # else
210 /*
211  * __DOXYGEN__ not defined
212  * Partie ne devant pas être documentée.
213  * =============================================================================
214  */
215 #include "avrio-config.h"
216 #ifdef AVRIO_GPIO_ENABLE
217 #include "avrio-board-gpio.h"
218 
219 /* structures =============================================================== */
220 struct xGpioContext {
221  xDPin pin[GPIO_SIZE];
222  vGpioCallback callback;
223  uGpioMask mask;
224  uGpioMask values;
225  void * udata;
226 };
227 
228 /* structures =============================================================== */
229 extern struct xGpioContext gpio;
230 
231 /* internal public functions ================================================ */
232 // -----------------------------------------------------------------------------
233 INLINE uint8_t
234 ucGpioSize (void) {
235 
236  return GPIO_SIZE;
237 }
238 
239 // -----------------------------------------------------------------------------
240 INLINE void
241 vGpioSetPinMode (uint8_t ucPin, eDpMode eMode) {
242 
243  vDpSetMode (&gpio.pin[ucPin], eMode);
244 }
245 
246 // -----------------------------------------------------------------------------
247 INLINE eDpMode
248 eGpioPinMode (uint8_t ucPin) {
249 
250  return gpio.pin[ucPin].mode;
251 }
252 
253 // -----------------------------------------------------------------------------
254 INLINE eDpEdge
255 eGpioPinEdge (uint8_t ucPin) {
256 
257  return gpio.pin[ucPin].edge;
258 }
259 
260 // -----------------------------------------------------------------------------
261 INLINE bool
262 bGpioRead (uint8_t ucPin) {
263 
264  return bDpRead (&gpio.pin[ucPin]);
265 }
266 
267 // -----------------------------------------------------------------------------
268 INLINE void
269 vGpioSetCallback (vGpioCallback callback) {
270 
271  gpio.callback = callback;
272 }
273 
274 // -----------------------------------------------------------------------------
275 INLINE vGpioCallback
276 pvGpioCallback (void) {
277 
278  return gpio.callback;
279 }
280 
281 // -----------------------------------------------------------------------------
282 INLINE void *
283 pvGpioUserData (void) {
284 
285  return gpio.udata;
286 }
287 
288 // -----------------------------------------------------------------------------
289 INLINE void
290 vGpioSetUserData (void * udata) {
291 
292  gpio.udata = udata;
293 }
294 
295 #endif /* AVRIO_GPIO_ENABLE defined */
296 #endif /* __DOXYGEN__ not defined */
297 
298 /* ========================================================================== */
299 __END_C_DECLS
300 #endif /* _AVRIO_GPIO_H_ */
static eDpEdge eGpioPinEdge(uint8_t ucPin)
Front(s) déclenchant d&#39;une entrée.
eDpEdge
Front d&#39;entrée.
Definition: dpin.h:57
static void * pGpioUserData(void)
Données d&#39;un gestionnaire d&#39;interruption utilisateur.
static void vGpioSetPinMode(uint8_t ucPin, eDpMode eMode)
Modifie le mode de la broche.
eDpMode
Type de broche.
Definition: dpin.h:44
uint8_t edge
Definition: dpin.h:79
static void vGpioSetCallback(vGpioCallback callback)
Modification du gestionnaire de changement d&#39;état.
uGpioMask uGpioReadAll(uGpioMask uPinMask)
Lecture de l&#39;état binaire d&#39;un ensemble de broches.
static void vGpioSetUserData(void *udata)
Modification données utilisateur.
Broche numérique.
Definition: dpin.h:68
void vGpioWriteAll(uGpioMask uPinMask, bool bValue)
Modification de l&#39;état binaire de plusieurs sorties.
unsigned int uGpioMask
Definition: gpio.h:47
void vGpioPoll(void)
Scrutation des broches.
static vGpioCallback pvGpioCallback(void)
gestionnaire de changement d&#39;état
void vGpioSetPinEdge(uint8_t ucPin, eDpEdge edge)
Réglage du ou des front(s) déclenchant d&#39;une entrée.
static bool bGpioRead(uint8_t ucPin)
Lecture de l&#39;état d&#39;une broche (entrée ou sortie)
void vDpSetMode(xDPin *p, eDpMode eMode)
Modifie le mode de la broche.
void vGpioToggleAll(uGpioMask uPinMask)
Bascule de l&#39;état binaire de plusieurs sorties.
bool bDpRead(const xDPin *p)
Lecture de l&#39;état d&#39;une broche (entrée ou sortie)
void(* vGpioCallback)(uGpioMask uPinValues, uint8_t ucPin, eDpEdge edge, void *udata)
Definition: gpio.h:60
void vGpioWrite(uint8_t ucPin, bool bValue)
Modifie l&#39;état d&#39;une sortie.
static eDpMode eGpioPinMode(uint8_t ucPin)
Lecture du type actuel d&#39;une broche.
void vGpioToggle(uint8_t ucPin)
Bascule l&#39;état d&#39;une sortie.