AvrIO  1.4.5
Bibliothèque C modulaire pour ATMEL AVR
dpin.h
1 
18 #ifndef _AVRIO_DPIN_H_
19 #define _AVRIO_DPIN_H_
20 
21 #include <avrio/defs.h>
22 __BEGIN_C_DECLS
23 /* ========================================================================== */
24 #include <avr/io.h>
25 
39 /* constants ================================================================ */
44 typedef enum {
45 
46  eModeInput = 0,
50  eModeUnknown = -1
51 } eDpMode;
52 
57 typedef enum {
58  eEdgeNone = 0,
62 } eDpEdge;
63 
64 /* structures =============================================================== */
68 struct xDPin {
69  volatile uint8_t * port;
70 #if defined(__AVR_ATtiny441__ ) || defined(__AVR_ATtiny841__)
71  volatile uint8_t * pue;
72 #define DPIN_PUE 1
73 #define DPIN_PUE_FIELD 1
74 #endif
75  struct {
76 
77  uint8_t pin: 3;
78  int8_t mode: 3;
79  uint8_t edge: 2;
80  };
81 };
82 typedef struct xDPin xDPin;
83 
84 /* internal public functions ================================================ */
90 void vDpSetMode (xDPin * p, eDpMode eMode);
91 
97 void vDpWrite (xDPin * p, bool bValue);
98 
103 void vDpToggle (xDPin * p);
104 
112 bool bDpRead (const xDPin * p);
113 
114 # if defined(__DOXYGEN__)
115 /*
116  * __DOXYGEN__ defined
117  * Partie documentation ne devant pas être compilée.
118  * =============================================================================
119  */
127 static inline void vDpInit (xDPin * p, volatile uint8_t * pucPort, uint8_t ucPin, eDpMode eMode);
128 
134 # else
135 /*
136  * __DOXYGEN__ not defined
137  * Partie ne devant pas être documentée.
138  * =============================================================================
139  */
140 // -----------------------------------------------------------------------------
141 INLINE void
142 vDpInit (xDPin * p, volatile uint8_t * pucPort, uint8_t ucPin, eDpMode eMode) {
143  p->port = pucPort;
144  p->pin = ucPin;
145 
146 #ifdef DPIN_PUE_FIELD
147  if (pucPort == &PORTA) {
148  p->pue = &PUEA;
149  }
150 #ifdef PUEB
151  else if (pucPort == &PORTB) {
152  p->pue = &PUEB;
153  }
154 #endif
155 #ifdef PUEC
156 else if (pucPort == &PORTC) {
157  p->pue = &PUEC;
158 }
159 #endif
160 #endif
161 
162  vDpSetMode (p, eMode);
163 }
164 #endif
165 
166 /* ========================================================================== */
167 __END_C_DECLS
168 #endif /* _AVRIO_DPIN_H_ */
eDpEdge
Front d&#39;entrée.
Definition: dpin.h:57
volatile uint8_t * port
Definition: dpin.h:69
eDpMode
Type de broche.
Definition: dpin.h:44
static void vDpInit(xDPin *p, volatile uint8_t *pucPort, uint8_t ucPin, eDpMode eMode)
Initialisation d&#39;une broche.
uint8_t edge
Definition: dpin.h:79
Definition: dpin.h:61
void vDpToggle(xDPin *p)
Bascule l&#39;état de la sortie ou la résistance de pullup pour une entrée.
Broche numérique.
Definition: dpin.h:68
void vDpSetMode(xDPin *p, eDpMode eMode)
Modifie le mode de la broche.
void vDpWrite(xDPin *p, bool bValue)
Modifie l&#39;état de la sortie ou la résistance de pullup pour une entrée.
bool bDpRead(const xDPin *p)
Lecture de l&#39;état d&#39;une broche (entrée ou sortie)
Definition: dpin.h:58
int8_t mode
Definition: dpin.h:78
uint8_t pin
Definition: dpin.h:77