EPPL  0.1 alpha
 All Files Typedefs Groups Pages
eppl_avr8_init.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2013, Radoslaw Koppel
3  All rights reserved.
4 
5  Redistribution and use in source and binary forms, with or without
6  modification, are permitted provided that the following conditions are met:
7 
8  - Redistributions of source code must retain the above copyright
9  notice, this list of conditions and the following disclaimer.
10 
11  - Redistributions in binary form must reproduce the above copyright
12  notice, this list of conditions and the following disclaimer in the
13  documentation and/or other materials provided with the distribution.
14 
15  - Neither the name of the copyright holders nor the
16  names of its contributors may be used to endorse or promote products
17  derived from this software without specific prior written permission.
18 
19  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22  DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER BE LIABLE FOR ANY
23  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
39 #ifndef EPPL_AVR8_INIT_H_INCLUDED
40 #define EPPL_AVR8_INIT_H_INCLUDED
41 
62  #define EPPL_avr8_init_isPORTSET(param, bit) ( (EPPL_PORTNR(bit) == EPPL_PORTNR(param)) && EPPL_avr8_mode_modifiedReg(PORT, EPPL_GC(param), EPPL_GC(bit)) && EPPL_avr8_mode_valuePORT(EPPL_GC(bit)) )
63 
68  #define EPPL_avr8_init_isPORTCLR(param, bit) ( (EPPL_PORTNR(bit) == EPPL_PORTNR(param)) && EPPL_avr8_mode_modifiedReg(PORT, EPPL_GC(param), EPPL_GC(bit)) && !EPPL_avr8_mode_valuePORT(EPPL_GC(bit)) )
69 
74  #define EPPL_avr8_init_isDDRSET(param, bit) ( (EPPL_PORTNR(bit) == EPPL_PORTNR(param)) && EPPL_avr8_mode_modifiedReg(DDR, EPPL_GC(param), EPPL_GC(bit)) && EPPL_avr8_mode_valueDDR(EPPL_GC(bit)) )
75 
80  #define EPPL_avr8_init_isDDRCLR(param, bit) ( (EPPL_PORTNR(bit) == EPPL_PORTNR(param)) && EPPL_avr8_mode_modifiedReg(DDR, EPPL_GC(param), EPPL_GC(bit)) && !EPPL_avr8_mode_valueDDR(EPPL_GC(bit)) )
81 
94 #define eppl_avr8_InitReg(reg, port, default, pinconfigs...) \
95  *EPPL_avr8_CPORTREG(reg, port) = (\
96  EPPL_avr8_mode_value##reg(default) ? \
97  (0xff & ~EPPL_GETSUBSET(EPPL_avr8_init_is##reg##CLR, EPPL_SC(EPPL_DEFPP(port, 0), default), EPPL_extractPinPos, |, pinconfigs) ) \
98  : \
99  EPPL_GETSUBSET(EPPL_avr8_init_is##reg##SET, EPPL_SC(EPPL_DEFPP(port, 0), default), EPPL_extractPinPos, |, pinconfigs) \
100  )
101 
113 #define eppl_avr8_InitOnePort(port, default, pinconfigs...) \
114  do{\
115  if(EPPL_avr8_CPORTREG(PORT, port) != NULL) \
116  {\
117  eppl_avr8_InitReg(PORT, port, default, pinconfigs); \
118  eppl_avr8_InitReg(DDR, port, default, pinconfigs); \
119  }\
120  }while(0)
121 
123 #endif /* EPPL_AVR8_INIT_H_INCLUDED */