 |
EPPL
0.1 alpha
|
|
Go to the documentation of this file.
40 #ifndef EPPL_AVR8_INTERNALS_H_INCLUDED
41 #define EPPL_AVR8_INTERNALS_H_INCLUDED
67 #define EPPL_avr8_CPORTREG(reg, cportnr) (xEPPL_avr8_CPORTREG(reg, cportnr))
72 #define xEPPL_avr8_CPORTREG(reg, cportnr) EPPL_p##reg##cportnr
101 #define EPPL_avr8_PORTREG(reg, portnr) \
102 (((portnr) == 0) ? EPPL_avr8_CPORTREG(reg, 0) : \
103 (((portnr) == 1) ? EPPL_avr8_CPORTREG(reg, 1) : \
104 (((portnr) == 2) ? EPPL_avr8_CPORTREG(reg, 2) : \
105 (((portnr) == 3) ? EPPL_avr8_CPORTREG(reg, 3) : \
106 (((portnr) == 4) ? EPPL_avr8_CPORTREG(reg, 4) : \
107 (((portnr) == 5) ? EPPL_avr8_CPORTREG(reg, 5) : \
108 (((portnr) == 6) ? EPPL_avr8_CPORTREG(reg, 6) : \
109 (((portnr) == 7) ? EPPL_avr8_CPORTREG(reg, 7) : \
110 (((portnr) == 8) ? EPPL_avr8_CPORTREG(reg, 8) : \
111 (((portnr) == 9) ? EPPL_avr8_CPORTREG(reg, 9) : \
112 (((portnr) == 10) ? EPPL_avr8_CPORTREG(reg, 10) : \
113 (((portnr) == 11) ? EPPL_avr8_CPORTREG(reg, 11) : \
114 ((volatile uint8_t*)NULL) \
125 #define EPPL_pPORT0 &PORTA
126 #define EPPL_pPIN0 &PINA
127 #define EPPL_pDDR0 &DDRA
129 #define EPPL_pPORT0 ((uint8_t*)NULL)
130 #define EPPL_pPIN0 ((uint8_t*)NULL)
131 #define EPPL_pDDR0 ((uint8_t*)NULL)
135 #define EPPL_pPORT1 &PORTB
136 #define EPPL_pPIN1 &PINB
137 #define EPPL_pDDR1 &DDRB
139 #define EPPL_pPORT1 ((uint8_t*)NULL)
140 #define EPPL_pPIN1 ((uint8_t*)NULL)
141 #define EPPL_pDDR1 ((uint8_t*)NULL)
145 #define EPPL_pPORT2 &PORTC
146 #define EPPL_pPIN2 &PINC
147 #define EPPL_pDDR2 &DDRC
149 #define EPPL_pPORT2 ((uint8_t*)NULL)
150 #define EPPL_pPIN2 ((uint8_t*)NULL)
151 #define EPPL_pDDR2 ((uint8_t*)NULL)
155 #define EPPL_pPORT3 &PORTD
156 #define EPPL_pPIN3 &PIND
157 #define EPPL_pDDR3 &DDRD
159 #define EPPL_pPORT3 ((uint8_t*)NULL)
160 #define EPPL_pPIN3 ((uint8_t*)NULL)
161 #define EPPL_pDDR3 ((uint8_t*)NULL)
165 #define EPPL_pPORT4 &PORTE
166 #define EPPL_pPIN4 &PINE
167 #define EPPL_pDDR4 &DDRE
169 #define EPPL_pPORT4 ((uint8_t*)NULL)
170 #define EPPL_pPIN4 ((uint8_t*)NULL)
171 #define EPPL_pDDR4 ((uint8_t*)NULL)
175 #define EPPL_pPORT5 &PORTF
176 #define EPPL_pPIN5 &PINF
177 #define EPPL_pDDR5 &DDRF
179 #define EPPL_pPORT5 ((uint8_t*)NULL)
180 #define EPPL_pPIN5 ((uint8_t*)NULL)
181 #define EPPL_pDDR5 ((uint8_t*)NULL)
185 #define EPPL_pPORT6 &PORTG
186 #define EPPL_pPIN6 &PING
187 #define EPPL_pDDR6 &DDRG
189 #define EPPL_pPORT6 ((uint8_t*)NULL)
190 #define EPPL_pPIN6 ((uint8_t*)NULL)
191 #define EPPL_pDDR6 ((uint8_t*)NULL)
195 #define EPPL_pPORT7 &PORTH
196 #define EPPL_pPIN7 &PINH
197 #define EPPL_pDDR7 &DDRH
199 #define EPPL_pPORT7 ((uint8_t*)NULL)
200 #define EPPL_pPIN7 ((uint8_t*)NULL)
201 #define EPPL_pDDR7 ((uint8_t*)NULL)
205 #define EPPL_pPORT8 &PORTI
206 #define EPPL_pPIN8 &PINI
207 #define EPPL_pDDR8 &DDRI
209 #define EPPL_pPORT8 ((uint8_t*)NULL)
210 #define EPPL_pPIN8 ((uint8_t*)NULL)
211 #define EPPL_pDDR8 ((uint8_t*)NULL)
215 #define EPPL_pPORT9 &PORTJ
216 #define EPPL_pPIN9 &PINJ
217 #define EPPL_pDDR9 &DDRJ
219 #define EPPL_pPORT9 ((uint8_t*)NULL)
220 #define EPPL_pPIN9 ((uint8_t*)NULL)
221 #define EPPL_pDDR9 ((uint8_t*)NULL)
225 #define EPPL_pPORT10 &PORTK
226 #define EPPL_pPIN10 &PINK
227 #define EPPL_pDDR10 &DDRK
229 #define EPPL_pPORT10 ((uint8_t*)NULL)
230 #define EPPL_pPIN10 ((uint8_t*)NULL)
231 #define EPPL_pDDR10 ((uint8_t*)NULL)
235 #define EPPL_pPORT11 &PORTL
236 #define EPPL_pPIN11 &PINL
237 #define EPPL_pDDR11 &DDRL
239 #define EPPL_pPORT11 ((uint8_t*)NULL)
240 #define EPPL_pPIN11 ((uint8_t*)NULL)
241 #define EPPL_pDDR11 ((uint8_t*)NULL)
253 #define EPPL_avr8_CheckRegSupportsBit(regptr) ( ((int)(regptr)) - __SFR_OFFSET < 32 )
267 #define EPPL_avr8_modeGet(ms) ((ms) & EPPL_mode_mask)
272 #define EPPL_avr8_stateGet(ms) ((ms) & EPPL_outSet_mask)
279 #define EPPL_avr8_mode_knownDDR(m) ( \
281 (EPPL_avr8_modeGet(m) == EPPL_mode_outPP) || \
283 ( ((m) & EPPL_mode_flag) && \
284 ( !((m) & EPPL_mode_out) || \
286 ((m) & EPPL_outSet_flag) ) \
295 #define EPPL_avr8_mode_knownPORT(m) ( \
297 (EPPL_avr8_modeGet(m) == EPPL_mode_outOC) || \
299 ((m) & EPPL_outSet_flag) )
308 #define EPPL_avr8_mode_valueDDR(m) ( ( \
309 (EPPL_avr8_modeGet(m) == EPPL_mode_outPP) || \
310 (EPPL_avr8_mapOutModify_DDR(m) && ( \
311 (EPPL_avr8_mapOutNegate_DDR(m) && (EPPL_avr8_stateGet(m) == EPPL_outSet_0)) || \
312 (!EPPL_avr8_mapOutNegate_DDR(m) && (EPPL_avr8_stateGet(m) == EPPL_outSet_1)) \
324 #define EPPL_avr8_mode_valuePORT(m) ( ( \
325 ((EPPL_avr8_mapOutModify_PORT(m) || !(EPPL_avr8_modeGet(m) & EPPL_mode_out)) && ( \
326 (EPPL_avr8_mapOutNegate_PORT(m) && (EPPL_avr8_stateGet(m) == EPPL_outSet_0)) || \
327 (!EPPL_avr8_mapOutNegate_PORT(m) && (EPPL_avr8_stateGet(m) == EPPL_outSet_1)) \
342 #define EPPL_avr8_mode_modifiedReg(reg, from, to) ( \
343 ( EPPL_avr8_mode_known##reg(from) && EPPL_avr8_mode_known##reg(to) && (EPPL_avr8_mode_value##reg(from) != EPPL_avr8_mode_value##reg(to)) ) || \
344 ( !EPPL_avr8_mode_known##reg(from) && EPPL_avr8_mode_known##reg(to) ) \
362 #define eppl_avr8_asm_sbi(regptr, bit) \
363 __asm__ __volatile__ ( \
364 "sbi %0, %1" "\n\t" \
366 : "I" ( ((int)(regptr)) - __SFR_OFFSET ), \
379 #define eppl_avr8_asm_cbi(regptr, bit) \
380 __asm__ __volatile__ ( \
381 "cbi %0, %1" "\n\t" \
383 : "I" ( ((int)(regptr)) - __SFR_OFFSET ), \
394 #define EPPL_avr8_checkPinsDescending(...) xEPPL_avr8_checkPinsDescending(__VA_ARGS__, )
395 #define xEPPL_avr8_checkPinsDescending(pin1, pin2, ...) ( \
396 (pin1) >= 0 && (pin2) >= 0 && \
397 EPPL_PORTNR(pin1) == EPPL_PORTNR(pin2) && \
398 EPPL_PINNR(pin1) == (EPPL_PINNR(pin2) + 1) )
415 #define EPPL_avr8_LRSH(v, sl, sr) \
416 ((uint8_t)(((sl) > (sr)) ? \
417 (uint8_t)((v) << ((sl)-(sr))) \
419 (uint8_t)((v) >> ((sr)-(sl))) \
434 #define eppl_avr8_asm_bitcpy(dst, dstpos, src, srcpos) \
436 "bst %[s], %[sb]" "\n\t" \
437 "bld %[d], %[db]" "\n\t" \