EPPL  0.1 alpha
 All Files Typedefs Groups Pages
eppl.h
Go to the documentation of this file.
1 
44 #ifndef EPPL_H_INCLUDED
45 #include "eppl_config.h"
46 #include "eppl_internals.h"
47 #include "eppl_target.h"
48 
63 typedef signed long eppl_pin_t;
64 
73 #define EPPL_NP (-255L)
74 
87 #define EPPL_PINCNT ( EPPL_port_PORTSIZE * EPPL_port_PORTCNT )
88 
103 #define EPPL_DEFPP(port, pin) ( (port)*EPPL_port_PORTSIZE + (pin) )
104 
112 #define EPPL_PORTNR(px) (((px) % EPPL_PINCNT) / EPPL_port_PORTSIZE)
113 
121 #define EPPL_PINNR(px) ((px)%EPPL_port_PORTSIZE)
122 
129 #define EPPL_SC(px, conf) ( ((px) < 0) ? (px) : ( (px) + ( (conf) * EPPL_PINCNT ) ) )
130 
138 #define EPPL_GC(px) ( ( (px) / EPPL_PINCNT) % (EPPL_port_CONFSIZE) )
139 
159 #define EPPL_SR(px, from, to) ( ((px) < 0) ? (px) : ( ((from) << (EPPL_configBits)) | (to) ) * (EPPL_PINCNT) + (px))
160 
164 #define EPPL_GRfrom(px) ( (((px) / EPPL_PINCNT) >> EPPL_configBits) % EPPL_avr8_CONFSIZE )
165 
168 #define EPPL_GRto(px) EPPL_GC(px)
169 
186 #define EPPL_COUNTARGS(args...) xEPPL_COUNTARGS(args, EPPL_COUNTARGS_RSEQ)
187 
196 #define EPPL_ActivePinCountInSet(pins...) EPPL_GETSUBSET(EPPL_checkPinDefined, 0, EPPL_extractOne, +, pins)
197 
212 #define EPPL_PinCountInSet(pins...) EPPL_COUNTARGS(pins)
213 
242 #define EPPL_PROCESSEVERYPIN(macro, op, pins...) \
243  EPPL_LC(EPPL_PROCESSEVERYPIN, EPPL_COUNTARGS(pins))(macro, op, pins)
244 
253 #define EPPL_PROCESSEVERYARG(macro, op, args...) \
254  EPPL_PROCESSEVERYPIN(macro, op, args)
255 
286 #define EPPL_REPEATONEVERYPIN(macro, pins...) \
287  do{\
288  EPPL_PROCESSEVERYPIN(macro, none, pins) \
289  }while(0)
290 
299 #define EPPL_REPEATONEVERYARG(macro, args...) \
300  do{\
301  EPPL_PROCESSEVERYARG(macro, none, args) \
302  }while(0)
303 
336 #define eppl_init(default, pinconfigs...) \
337  do{\
338  EPPL_REPEAT(EPPL_port_PORTCNT, EPPL_generateInitOnePort, default, pinconfigs) \
339  }while(0)
340 
351 #define eppl_reinitFromISR(pinconfigs...) \
352  do{\
353  EPPL_REPEAT(EPPL_port_PORTCNT, EPPL_generateReinitOnePort, pinconfigs) \
354  }while(0)
355 
374 #define eppl_reinit(pinconfigs...) \
375  do{ \
376  eppl_port_LockableBlockBegin(!(EPPL_REPEAT(EPPL_port_PORTCNT, EPPL_generatePortSafeCheck, pinconfigs) 1)); \
377  eppl_reinitFromISR(pinconfigs); \
378  eppl_port_LockableBlockEnd(!(EPPL_REPEAT(EPPL_port_PORTCNT, EPPL_generatePortSafeCheck, pinconfigs) 1)); \
379  }while(0)
380 
408 #define eppl_mapIn(pins...) \
409  ( EPPL_REPEAT(EPPL_port_PORTCNT, EPPL_port_generateMapInFromOnePort, pins) (uint8_t)0 )
410 
411 
420 #define eppl_mapOutFromISR(mode, value, pins...) \
421  do{ EPPL_REPEAT(EPPL_port_PORTCNT, EPPL_port_generateMapOutToOnePort, mode, value, pins) }while(0)
422 
423 
439 #define eppl_mapOut(mode, value, pins...) \
440  do{ \
441  eppl_port_LockableBlockBegin(!(EPPL_REPEAT(EPPL_port_PORTCNT, EPPL_generateMapOutSafeCheck, mode, pins) 1)); \
442  eppl_mapOutFromISR(mode, value, pins); \
443  eppl_port_LockableBlockEnd(!(EPPL_REPEAT(EPPL_port_PORTCNT, EPPL_generateMapOutSafeCheck, mode, pins) 1)); \
444  }while(0)
445 
448 /* Target file have to be included after all main definitions */
449 #include EPPL_TARGET_FILE
450 
451 #endif /* EPPL_H_INCLUDED */