39 #ifndef EPPL_AVR8_MAPOUT_H_INCLUDED 
   40 #define EPPL_AVR8_MAPOUT_H_INCLUDED 
   68 #define EPPL_avr8_mapOutMaskedPins(pout, value, pos, pin, mask) \ 
   69    (*(pout)) ^= (((*(pout)) ^ EPPL_avr8_LRSH(value, pin, pos)) & ((mask)<<(pin))) 
   91       #define EPPL_avr8_mapOutFlag_direct 1 
   98       #define EPPL_avr8_mapOutFlag_const  2 
  121    #define EPPL_avr8_mapOutTempPinsNear1(pout, val, flags, pos, pin) \ 
  123          if((flags) & EPPL_avr8_mapOutFlag_direct) {\ 
  124             if(val & (1U<<(pos))) \ 
  125                eppl_avr8_asm_sbi(pout, EPPL_PINNR(pin)); \ 
  127                eppl_avr8_asm_cbi(pout, EPPL_PINNR(pin)); \ 
  128          } else if((flags) & EPPL_avr8_mapOutFlag_const) \ 
  129             EPPL_avr8_mapOutMaskedPins(pout, val, pos, EPPL_PINNR(pin), 0x01); \ 
  131             eppl_avr8_asm_bitcpy(*pout, EPPL_PINNR(pin), val, pos); \ 
  135    #define EPPL_avr8_mapOutTempPinsNear2(pout, val, flags, pos, pin) \ 
  136       EPPL_avr8_mapOutMaskedPins(pout, val, pos, EPPL_PINNR(pin), 0x03) 
  138    #define EPPL_avr8_mapOutTempPinsNear3(pout, val, flags, pos, pin) \ 
  139       EPPL_avr8_mapOutMaskedPins(pout, val, pos, EPPL_PINNR(pin), 0x07) 
  141    #define EPPL_avr8_mapOutTempPinsNear4(pout, val, flags, pos, pin) \ 
  142       EPPL_avr8_mapOutMaskedPins(pout, val, pos, EPPL_PINNR(pin), 0x0f) 
  144    #define EPPL_avr8_mapOutTempPinsNear5(pout, val, flags, pos, pin) \ 
  145       EPPL_avr8_mapOutMaskedPins(pout, val, pos, EPPL_PINNR(pin), 0x1f) 
  147    #define EPPL_avr8_mapOutTempPinsNear6(pout, val, flags, pos, pin) \ 
  148       EPPL_avr8_mapOutMaskedPins(pout, val, pos, EPPL_PINNR(pin), 0x3f) 
  150    #define EPPL_avr8_mapOutTempPinsNear7(pout, val, flags, pos, pin) \ 
  151       EPPL_avr8_mapOutMaskedPins(pout, val, pos, EPPL_PINNR(pin), 0x7f) 
  153    #define EPPL_avr8_mapOutTempPinsNear8(pout, val, flags, pos, pin) \ 
  154       EPPL_avr8_mapOutMaskedPins(pout, val, pos, EPPL_PINNR(pin), 0xff) 
  167    static inline void eppl_avr8_mapOutToOnePort1(uint8_t *pout, uint8_t port, uint8_t val, uint8_t flags, 
eppl_pin_t pin1) __attribute__((always_inline));
 
  168    static inline void eppl_avr8_mapOutToOnePort2(uint8_t *pout, uint8_t port, uint8_t val, uint8_t flags, 
eppl_pin_t pin1, 
eppl_pin_t pin2) __attribute__((always_inline));
 
  169    static inline void eppl_avr8_mapOutToOnePort3(uint8_t *pout, uint8_t port, uint8_t val, uint8_t flags, 
eppl_pin_t pin1, 
eppl_pin_t pin2, 
eppl_pin_t pin3) __attribute__((always_inline));
 
  170    static inline void eppl_avr8_mapOutToOnePort4(uint8_t *pout, uint8_t port, uint8_t val, uint8_t flags, 
eppl_pin_t pin1, 
eppl_pin_t pin2, 
eppl_pin_t pin3, 
eppl_pin_t pin4) __attribute__((always_inline));
 
  173    static inline void eppl_avr8_mapOutToOnePort7(uint8_t *pout, uint8_t port, uint8_t val, uint8_t flags, 
eppl_pin_t pin1, 
eppl_pin_t pin2, 
eppl_pin_t pin3, 
eppl_pin_t pin4, 
eppl_pin_t pin5, 
eppl_pin_t pin6, 
eppl_pin_t pin7) __attribute__((always_inline));
 
  174    static inline void eppl_avr8_mapOutToOnePort8(uint8_t *pout, uint8_t port, uint8_t val, uint8_t flags, 
eppl_pin_t pin1, 
eppl_pin_t pin2, 
eppl_pin_t pin3, 
eppl_pin_t pin4, 
eppl_pin_t pin5, 
eppl_pin_t pin6, 
eppl_pin_t pin7, 
eppl_pin_t pin8) __attribute__((always_inline));
 
  189 #define eppl_avr8_mapOutToOnePort(pout, port, val, flags, pins...) EPPL_LC(eppl_avr8_mapOutToOnePort, EPPL_COUNTARGS(pins))(pout, port, val, flags, pins) 
  203    #define EPPL_avr8_mapOutModify_DDR(m)   xEPPL_avr8_mapOutModify_DDR(EPPL_avr8_modeGet(m)) 
  210    #define EPPL_avr8_mapOutModify_PORT(m)  xEPPL_avr8_mapOutModify_PORT(EPPL_avr8_modeGet(m)) 
  217    #define EPPL_avr8_mapOutNegate_DDR(m)   xEPPL_avr8_mapOutNegate_DDR(EPPL_avr8_modeGet(m)) 
  224    #define EPPL_avr8_mapOutNegate_PORT(m)  xEPPL_avr8_mapOutNegate_PORT(EPPL_avr8_modeGet(m)) 
  227    #define xEPPL_avr8_mapOutModify_DDR(m)  ( ((m)==EPPL_mode_outOC) || ((m)==EPPL_mode_outOE) || ((m)==EPPL_mode_outPU) ) 
  229    #define xEPPL_avr8_mapOutModify_PORT(m) ( ((m)==EPPL_mode_outPP) || ((m)==EPPL_mode_outOE) || ((m)==EPPL_mode_outPU) ) 
  231    #define xEPPL_avr8_mapOutNegate_DDR(m)  ( ((m)==EPPL_mode_outOC) || ((m)==EPPL_mode_outPU) ) 
  233    #define xEPPL_avr8_mapOutNegate_PORT(m) ( 0 ) 
  253 #define EPPL_avr8_generateMapOutToOnePortOpt(repeatcntd, flags, mode, val, pins...) \ 
  255       if(0 != EPPL_GETSUBSET(EPPL_checkPortNr, repeatcntd, EPPL_extractPinPos, |, pins)) { \ 
  256          if(1 == EPPL_GETSUBSET(EPPL_checkPortNr, repeatcntd, EPPL_extractOne, +, pins)) { \ 
  257             if(EPPL_avr8_mapOutModify_DDR(mode)) \ 
  258                eppl_avr8_mapOutToOnePort((uint8_t*)EPPL_avr8_CPORTREG(DDR, repeatcntd), repeatcntd, EPPL_avr8_mapOutNegate_DDR(mode) ? (uint8_t)~(val) : (val), (flags) | EPPL_avr8_mapOutFlag_direct, pins); \ 
  259             if(EPPL_avr8_mapOutModify_PORT(mode)) \ 
  260                eppl_avr8_mapOutToOnePort((uint8_t*)EPPL_avr8_CPORTREG(PORT, repeatcntd), repeatcntd, EPPL_avr8_mapOutNegate_PORT(mode) ? (uint8_t)~(val) : (val), (flags) | EPPL_avr8_mapOutFlag_direct, pins); \ 
  262             uint8_t sval = sval; \ 
  263             eppl_avr8_mapOutToOnePort(&sval, repeatcntd, val, flags, pins); \ 
  264             if(0xff == EPPL_GETSUBSET(EPPL_checkPortNr, repeatcntd, EPPL_extractPinPos, |, pins)) { \ 
  265                if(EPPL_avr8_mapOutModify_DDR(mode)) \ 
  266                   *EPPL_avr8_CPORTREG(DDR, repeatcntd) = EPPL_avr8_mapOutNegate_DDR(mode) ? (uint8_t)~(sval) : (sval); \ 
  267                if(EPPL_avr8_mapOutModify_PORT(mode)) \ 
  268                   *EPPL_avr8_CPORTREG(PORT, repeatcntd) = EPPL_avr8_mapOutNegate_PORT(mode) ? (uint8_t)~(sval) : (sval); \ 
  270                if(EPPL_avr8_mapOutModify_DDR(mode)) \ 
  272                   uint8_t temp = *EPPL_avr8_CPORTREG(DDR, repeatcntd); \ 
  273                   temp ^= ( temp ^ ( EPPL_avr8_mapOutNegate_DDR(mode) ? (uint8_t)~(sval) : (sval) ) ) & EPPL_GETSUBSET(EPPL_checkPortNr, repeatcntd, EPPL_extractPinPos, |, pins); \ 
  274                   *EPPL_avr8_CPORTREG(DDR, repeatcntd) = temp; \ 
  276                if(EPPL_avr8_mapOutModify_PORT(mode)) \ 
  278                   uint8_t temp = *EPPL_avr8_CPORTREG(PORT, repeatcntd); \ 
  279                   temp ^= ( temp ^ ( EPPL_avr8_mapOutNegate_PORT(mode) ? (uint8_t)~(sval) : (sval) ) ) & EPPL_GETSUBSET(EPPL_checkPortNr, repeatcntd, EPPL_extractPinPos, |, pins); \ 
  280                   *EPPL_avr8_CPORTREG(PORT, repeatcntd) = temp; \ 
  301 #define EPPL_avr8_generateMapOutToOnePort(repeatcntd, mode, val, pins...) EPPL_avr8_generateMapOutToOnePortOpt(repeatcntd, __builtin_constant_p(val) ? EPPL_avr8_mapOutFlag_const : 0, mode, val, pins) 
  310 #define EPPL_avr8_MapOutIsAtomicAccessReg(reg, port, pinconfigs...) \ 
  312       (0 == EPPL_GETSUBSET(EPPL_avr8_reinit_is##reg##UNSAFE, port, EPPL_extractPinPos, |, pinconfigs)) || \ 
  313       (0xff == EPPL_GETSUBSET(EPPL_avr8_reinit_is##reg##UNSAFE, port, EPPL_extractPinPos, |, pinconfigs)) || \ 
  314       ((1 == EPPL_GETSUBSET(EPPL_avr8_reinit_is##reg##UNSAFE, port, EPPL_extractOne, +, pinconfigs)) && EPPL_avr8_CheckRegSupportsBit(EPPL_avr8_CPORTREG(reg, port))) \ 
  329 #define EPPL_avr8_MapOutIsSafe(mode, port, pins...) \ 
  332          !EPPL_avr8_mapOutModify_DDR(mode) || \ 
  333          !EPPL_GETSUBSET(EPPL_avr8_reinit_isDDRUNSAFE, port, EPPL_extractPinPos, |, EPPL_HOTPINS) || \ 
  334          EPPL_avr8_MapOutIsAtomicAccessReg(DDR, port, pins) \ 
  337          !EPPL_avr8_mapOutModify_PORT(mode) || \ 
  338          !EPPL_GETSUBSET(EPPL_avr8_reinit_isPORTUNSAFE, port, EPPL_extractPinPos, |, EPPL_HOTPINS) || \ 
  339          EPPL_avr8_MapOutIsAtomicAccessReg(PORT, port, pins) \