EPPL  0.1 alpha
 All Files Typedefs Groups Pages
eppl_avr8_mapinfunc.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_MAPINFUNC_H_INCLUDED
40 #define EPPL_AVR8_MAPINFUNC_H_INCLUDED
41 
42 static inline void eppl_avr8_mapInFromOnePort1(uint8_t *pout, uint8_t port, uint8_t temp, uint8_t direct, eppl_pin_t pin1)
43 {
44  if(port == EPPL_PORTNR(pin1))
45  EPPL_avr8_mapInTempPinsNear1(pout, temp, direct, 0, pin1);
46 }
47 static inline void eppl_avr8_mapInFromOnePort2(uint8_t *pout, uint8_t port, uint8_t temp, uint8_t direct, eppl_pin_t pin1, eppl_pin_t pin2)
48 {
49  if(port == EPPL_PORTNR(pin1))
50  {
51  if(EPPL_avr8_checkPinsDescending(pin1, pin2))
52  EPPL_avr8_mapInTempPinsNear2(pout, temp, direct, 0, pin2);
53  else
54  {
55  EPPL_avr8_mapInTempPinsNear1(pout, temp, direct, 1, pin1);
56  eppl_avr8_mapInFromOnePort1(pout, port, temp, direct, pin2);
57  }
58  }
59  else
60  eppl_avr8_mapInFromOnePort1(pout, port, temp, direct, pin2);
61 }
62 static inline void eppl_avr8_mapInFromOnePort3(uint8_t *pout, uint8_t port, uint8_t temp, uint8_t direct, eppl_pin_t pin1, eppl_pin_t pin2, eppl_pin_t pin3)
63 {
64  if(port == EPPL_PORTNR(pin1))
65  {
66  if(EPPL_avr8_checkPinsDescending(pin1, pin2))
67  {
68  if(EPPL_avr8_checkPinsDescending(pin2, pin3))
69  EPPL_avr8_mapInTempPinsNear3(pout, temp, direct, 0, pin3);
70  else
71  {
72  EPPL_avr8_mapInTempPinsNear2(pout, temp, direct, 1, pin2);
73  eppl_avr8_mapInFromOnePort1(pout, port, temp, direct, pin3);
74  }
75  }
76  else
77  {
78  EPPL_avr8_mapInTempPinsNear1(pout, temp, direct, 2, pin1);
79  eppl_avr8_mapInFromOnePort2(pout, port, temp, direct, pin2, pin3);
80  }
81  }
82  else
83  eppl_avr8_mapInFromOnePort2(pout, port, temp, direct, pin2, pin3);
84 }
85 static inline void eppl_avr8_mapInFromOnePort4(uint8_t *pout, uint8_t port, uint8_t temp, uint8_t direct, eppl_pin_t pin1, eppl_pin_t pin2, eppl_pin_t pin3, eppl_pin_t pin4)
86 {
87  if(port == EPPL_PORTNR(pin1))
88  {
89  if(EPPL_avr8_checkPinsDescending(pin1, pin2))
90  {
91  if(EPPL_avr8_checkPinsDescending(pin2, pin3))
92  {
93  if(EPPL_avr8_checkPinsDescending(pin3, pin4))
94  EPPL_avr8_mapInTempPinsNear4(pout, temp, direct, 0, pin4);
95  else
96  {
97  EPPL_avr8_mapInTempPinsNear3(pout, temp, direct, 1, pin3);
98  eppl_avr8_mapInFromOnePort1(pout, port, temp, direct, pin4);
99  }
100  }
101  else
102  {
103  EPPL_avr8_mapInTempPinsNear2(pout, temp, direct, 2, pin2);
104  eppl_avr8_mapInFromOnePort2(pout, port, temp, direct, pin3, pin4);
105  }
106  }
107  else
108  {
109  EPPL_avr8_mapInTempPinsNear1(pout, temp, direct, 3, pin1);
110  eppl_avr8_mapInFromOnePort3(pout, port, temp, direct, pin2, pin3, pin4);
111  }
112  }
113  else
114  eppl_avr8_mapInFromOnePort3(pout, port, temp, direct, pin2, pin3, pin4);
115 }
116 static inline void eppl_avr8_mapInFromOnePort5(uint8_t *pout, uint8_t port, uint8_t temp, uint8_t direct, eppl_pin_t pin1, eppl_pin_t pin2, eppl_pin_t pin3, eppl_pin_t pin4, eppl_pin_t pin5)
117 {
118  if(port == EPPL_PORTNR(pin1))
119  {
120  if(EPPL_avr8_checkPinsDescending(pin1, pin2))
121  {
122  if(EPPL_avr8_checkPinsDescending(pin2, pin3))
123  {
124  if(EPPL_avr8_checkPinsDescending(pin3, pin4))
125  {
126  if(EPPL_avr8_checkPinsDescending(pin4, pin5))
127  EPPL_avr8_mapInTempPinsNear5(pout, temp, direct, 0, pin5);
128  else
129  {
130  EPPL_avr8_mapInTempPinsNear4(pout, temp, direct, 1, pin4);
131  eppl_avr8_mapInFromOnePort1(pout, port, temp, direct, pin5);
132  }
133  }
134  else
135  {
136  EPPL_avr8_mapInTempPinsNear3(pout, temp, direct, 2, pin3);
137  eppl_avr8_mapInFromOnePort2(pout, port, temp, direct, pin4, pin5);
138  }
139  }
140  else
141  {
142  EPPL_avr8_mapInTempPinsNear2(pout, temp, direct, 3, pin2);
143  eppl_avr8_mapInFromOnePort3(pout, port, temp, direct, pin3, pin4, pin5);
144  }
145  }
146  else
147  {
148  EPPL_avr8_mapInTempPinsNear1(pout, temp, direct, 4, pin1);
149  eppl_avr8_mapInFromOnePort4(pout, port, temp, direct, pin2, pin3, pin4, pin5);
150  }
151  }
152  else
153  eppl_avr8_mapInFromOnePort4(pout, port, temp, direct, pin2, pin3, pin4, pin5);
154 }
155 static inline void eppl_avr8_mapInFromOnePort6(uint8_t *pout, uint8_t port, uint8_t temp, uint8_t direct, eppl_pin_t pin1, eppl_pin_t pin2, eppl_pin_t pin3, eppl_pin_t pin4, eppl_pin_t pin5, eppl_pin_t pin6)
156 {
157  if(port == EPPL_PORTNR(pin1))
158  {
159  if(EPPL_avr8_checkPinsDescending(pin1, pin2))
160  {
161  if(EPPL_avr8_checkPinsDescending(pin2, pin3))
162  {
163  if(EPPL_avr8_checkPinsDescending(pin3, pin4))
164  {
165  if(EPPL_avr8_checkPinsDescending(pin4, pin5))
166  {
167  if(EPPL_avr8_checkPinsDescending(pin5, pin6))
168  EPPL_avr8_mapInTempPinsNear6(pout, temp, direct, 0, pin6);
169  else
170  {
171  EPPL_avr8_mapInTempPinsNear5(pout, temp, direct, 1, pin5);
172  eppl_avr8_mapInFromOnePort1(pout, port, temp, direct, pin6);
173  }
174  }
175  else
176  {
177  EPPL_avr8_mapInTempPinsNear4(pout, temp, direct, 2, pin4);
178  eppl_avr8_mapInFromOnePort2(pout, port, temp, direct, pin5, pin6);
179  }
180  }
181  else
182  {
183  EPPL_avr8_mapInTempPinsNear3(pout, temp, direct, 3, pin3);
184  eppl_avr8_mapInFromOnePort3(pout, port, temp, direct, pin4, pin5, pin6);
185  }
186  }
187  else
188  {
189  EPPL_avr8_mapInTempPinsNear2(pout, temp, direct, 4, pin2);
190  eppl_avr8_mapInFromOnePort4(pout, port, temp, direct, pin3, pin4, pin5, pin6);
191  }
192  }
193  else
194  {
195  EPPL_avr8_mapInTempPinsNear1(pout, temp, direct, 5, pin1);
196  eppl_avr8_mapInFromOnePort5(pout, port, temp, direct, pin2, pin3, pin4, pin5, pin6);
197  }
198  }
199  else
200  eppl_avr8_mapInFromOnePort5(pout, port, temp, direct, pin2, pin3, pin4, pin5, pin6);
201 }
202 static inline void eppl_avr8_mapInFromOnePort7(uint8_t *pout, uint8_t port, uint8_t temp, uint8_t direct, 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)
203 {
204  if(port == EPPL_PORTNR(pin1))
205  {
206  if(EPPL_avr8_checkPinsDescending(pin1, pin2))
207  {
208  if(EPPL_avr8_checkPinsDescending(pin2, pin3))
209  {
210  if(EPPL_avr8_checkPinsDescending(pin3, pin4))
211  {
212  if(EPPL_avr8_checkPinsDescending(pin4, pin5))
213  {
214  if(EPPL_avr8_checkPinsDescending(pin5, pin6))
215  {
216  if(EPPL_avr8_checkPinsDescending(pin6, pin7))
217  EPPL_avr8_mapInTempPinsNear7(pout, temp, direct, 0, pin7);
218  else
219  {
220  EPPL_avr8_mapInTempPinsNear6(pout, temp, direct, 1, pin6);
221  eppl_avr8_mapInFromOnePort1(pout, port, temp, direct, pin7);
222  }
223  }
224  else
225  {
226  EPPL_avr8_mapInTempPinsNear5(pout, temp, direct, 2, pin5);
227  eppl_avr8_mapInFromOnePort2(pout, port, temp, direct, pin6, pin7);
228  }
229  }
230  else
231  {
232  EPPL_avr8_mapInTempPinsNear4(pout, temp, direct, 3, pin4);
233  eppl_avr8_mapInFromOnePort3(pout, port, temp, direct, pin5, pin6, pin7);
234  }
235  }
236  else
237  {
238  EPPL_avr8_mapInTempPinsNear3(pout, temp, direct, 4, pin3);
239  eppl_avr8_mapInFromOnePort4(pout, port, temp, direct, pin4, pin5, pin6, pin7);
240  }
241  }
242  else
243  {
244  EPPL_avr8_mapInTempPinsNear2(pout, temp, direct, 5, pin2);
245  eppl_avr8_mapInFromOnePort5(pout, port, temp, direct, pin3, pin4, pin5, pin6, pin7);
246  }
247  }
248  else
249  {
250  EPPL_avr8_mapInTempPinsNear1(pout, temp, direct, 6, pin1);
251  eppl_avr8_mapInFromOnePort6(pout, port, temp, direct, pin2, pin3, pin4, pin5, pin6, pin7);
252  }
253  }
254  else
255  eppl_avr8_mapInFromOnePort6(pout, port, temp, direct, pin2, pin3, pin4, pin5, pin6, pin7);
256 }
257 static inline void eppl_avr8_mapInFromOnePort8(uint8_t *pout, uint8_t port, uint8_t temp, uint8_t direct, 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)
258 {
259  if(port == EPPL_PORTNR(pin1))
260  {
261  if(EPPL_avr8_checkPinsDescending(pin1, pin2))
262  {
263  if(EPPL_avr8_checkPinsDescending(pin2, pin3))
264  {
265  if(EPPL_avr8_checkPinsDescending(pin3, pin4))
266  {
267  if(EPPL_avr8_checkPinsDescending(pin4, pin5))
268  {
269  if(EPPL_avr8_checkPinsDescending(pin5, pin6))
270  {
271  if(EPPL_avr8_checkPinsDescending(pin6, pin7))
272  {
273  if(EPPL_avr8_checkPinsDescending(pin7, pin8))
274  EPPL_avr8_mapInTempPinsNear8(pout, temp, direct, 0, pin8);
275  else
276  {
277  EPPL_avr8_mapInTempPinsNear7(pout, temp, direct, 1, pin7);
278  eppl_avr8_mapInFromOnePort1(pout, port, temp, direct, pin8);
279  }
280  }
281  else
282  {
283  EPPL_avr8_mapInTempPinsNear6(pout, temp, direct, 2, pin6);
284  eppl_avr8_mapInFromOnePort2(pout, port, temp, direct, pin7, pin8);
285  }
286  }
287  else
288  {
289  EPPL_avr8_mapInTempPinsNear5(pout, temp, direct, 3, pin5);
290  eppl_avr8_mapInFromOnePort3(pout, port, temp, direct, pin6, pin7, pin8);
291  }
292  }
293  else
294  {
295  EPPL_avr8_mapInTempPinsNear4(pout, temp, direct, 4, pin4);
296  eppl_avr8_mapInFromOnePort4(pout, port, temp, direct, pin5, pin6, pin7, pin8);
297  }
298  }
299  else
300  {
301  EPPL_avr8_mapInTempPinsNear3(pout, temp, direct, 5, pin3);
302  eppl_avr8_mapInFromOnePort5(pout, port, temp, direct, pin4, pin5, pin6, pin7, pin8);
303  }
304  }
305  else
306  {
307  EPPL_avr8_mapInTempPinsNear2(pout, temp, direct, 6, pin2);
308  eppl_avr8_mapInFromOnePort6(pout, port, temp, direct, pin3, pin4, pin5, pin6, pin7, pin8);
309  }
310  }
311  else
312  {
313  EPPL_avr8_mapInTempPinsNear1(pout, temp, direct, 7, pin1);
314  eppl_avr8_mapInFromOnePort7(pout, port, temp, direct, pin2, pin3, pin4, pin5, pin6, pin7, pin8);
315  }
316  }
317  else
318  eppl_avr8_mapInFromOnePort7(pout, port, temp, direct, pin2, pin3, pin4, pin5, pin6, pin7, pin8);
319 }
320 
321 #endif /* EPPL_AVR8_MAPINFUNC_H_INCLUDED */