eGUI alias D4D  Release 3.0
Reference Manual
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
d4dtchhw_s12_adc.h
Go to the documentation of this file.
1 /**************************************************************************
2 *
3 * Copyright 2014 by Petr Gargulak. eGUI Community.
4 * Copyright 2009-2013 by Petr Gargulak. Freescale Semiconductor, Inc.
5 *
6 ***************************************************************************
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License Version 3
9 * or later (the "LGPL").
10 *
11 * As a special exception, the copyright holders of the eGUI project give you
12 * permission to link the eGUI sources with independent modules to produce an
13 * executable, regardless of the license terms of these independent modules,
14 * and to copy and distribute the resulting executable under terms of your
15 * choice, provided that you also meet, for each linked independent module,
16 * the terms and conditions of the license of that module.
17 * An independent module is a module which is not derived from or based
18 * on this library.
19 * If you modify the eGUI sources, you may extend this exception
20 * to your version of the eGUI sources, but you are not obligated
21 * to do so. If you do not wish to do so, delete this
22 * exception statement from your version.
23 *
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
27 *
28 * You should have received a copy of the GNU General Public License
29 * and the GNU Lesser General Public License along with this program.
30 * If not, see <http://www.gnu.org/licenses/>.
31 *
32 ***************************************************************************/
47 #ifndef __D4DTCHHW_S12_ADC_H
48 #define __D4DTCHHW_S12_ADC_H
49 
50  #if (D4D_MK_STR(D4D_LLD_TCH_HW) == d4dtchhw_s12_adc_ID)
51 
52  /******************************************************************************
53  * Includes
54  ******************************************************************************/
55  #include "d4dtchhw_s12_adc_cfg.h"
56 
57  /******************************************************************************
58  * Constants
59  ******************************************************************************/
60 
61  /******************************************************************************
62  * Types
63  ******************************************************************************/
64 
65  /******************************************************************************
66  * Macros
67  ******************************************************************************/
68 
69  #define SET(x) (x##_PORT) |= (1 << (x))
70  #define RESET(x) (x##_PORT) &= ~(1 << (x))
71 
72  #define OUTPUT(x) (x##_DDR) |= (1 << (x))
73  #define INPUT(x) (x##_DDR) &= ~(1 << (x))
74 
75  /****** X PLUS signal macros ******/
76 
77  #ifndef D4DTCH_INIT_X_PLUS
78  #ifndef D4DTCH_X_PLUS
79  #error "The Macro D4DTCH_X_PLUS must be set in Touch Screen low level driver configuration file."
80  #else
81  #define D4DTCH_INIT_X_PLUS OUTPUT(D4DTCH_X_PLUS); RESET(D4DTCH_X_PLUS);
82  #endif
83  #endif
84 
85  #ifndef D4DTCH_RESET_X_PLUS
86  #ifndef D4DTCH_X_PLUS
87  #error "The Macro D4DTCH_X_PLUS must be set in Touch Screen low level driver configuration file."
88  #else
89  #define D4DTCH_RESET_X_PLUS RESET(D4DTCH_X_PLUS);
90  #endif
91  #endif
92 
93  #ifndef D4DTCH_SET_X_PLUS
94  #ifndef D4DTCH_X_PLUS
95  #error "The Macro D4DTCH_X_PLUS must be set in Touch Screen low level driver configuration file."
96  #else
97  #define D4DTCH_SET_X_PLUS SET(D4DTCH_X_PLUS);
98  #endif
99  #endif
100 
101  /****** X MINUS signal macros ******/
102 
103  #ifndef D4DTCH_INIT_X_MINUS
104  #ifndef D4DTCH_X_MINUS
105  #error "The Macro D4DTCH_X_MINUS must be set in Touch Screen low level driver configuration file."
106  #else
107  #define D4DTCH_INIT_X_MINUS OUTPUT(D4DTCH_X_MINUS); RESET(D4DTCH_X_MINUS);
108  #endif
109  #endif
110 
111  #ifndef D4DTCH_RESET_X_MINUS
112  #ifndef D4DTCH_X_MINUS
113  #error "The Macro D4DTCH_X_MINUS must be set in Touch Screen low level driver configuration file."
114  #else
115  #define D4DTCH_RESET_X_MINUS RESET(D4DTCH_X_MINUS);
116  #endif
117  #endif
118 
119  #ifndef D4DTCH_SET_X_MINUS
120  #ifndef D4DTCH_X_MINUS
121  #error "The Macro D4DTCH_X_MINUS must be set in Touch Screen low level driver configuration file."
122  #else
123  #define D4DTCH_SET_X_MINUS SET(D4DTCH_X_MINUS);
124  #endif
125  #endif
126 
127  #ifndef D4DTCH_X_MINUS_HIGH_Z_ENABLE
128  #ifndef D4DTCH_X_MINUS
129  #error "The Macro D4DTCH_X_MINUS must be set in Touch Screen low level driver configuration file."
130  #else
131  #define D4DTCH_X_MINUS_HIGH_Z_ENABLE INPUT(D4DTCH_X_MINUS);
132  #endif
133  #endif
134 
135  #ifndef D4DTCH_X_MINUS_HIGH_Z_DISABLE
136  #ifndef D4DTCH_X_MINUS
137  #error "The Macro D4DTCH_X_MINUS must be set in Touch Screen low level driver configuration file."
138  #else
139  #define D4DTCH_X_MINUS_HIGH_Z_DISABLE OUTPUT(D4DTCH_X_MINUS);
140  #endif
141  #endif
142 
143  /****** Y PLUS signal macros ******/
144 
145  #ifndef D4DTCH_INIT_Y_PLUS
146  #ifndef D4DTCH_Y_PLUS
147  #error "The Macro D4DTCH_Y_PLUS must be set in Touch Screen low level driver configuration file."
148  #else
149  #define D4DTCH_INIT_Y_PLUS OUTPUT(D4DTCH_Y_PLUS); RESET(D4DTCH_Y_PLUS);
150  #endif
151  #endif
152 
153  #ifndef D4DTCH_RESET_Y_PLUS
154  #ifndef D4DTCH_Y_PLUS
155  #error "The Macro D4DTCH_Y_PLUS must be set in Touch Screen low level driver configuration file."
156  #else
157  #define D4DTCH_RESET_Y_PLUS RESET(D4DTCH_Y_PLUS);
158  #endif
159  #endif
160 
161  #ifndef D4DTCH_SET_Y_PLUS
162  #ifndef D4DTCH_Y_PLUS
163  #error "The Macro D4DTCH_Y_PLUS must be set in Touch Screen low level driver configuration file."
164  #else
165  #define D4DTCH_SET_Y_PLUS SET(D4DTCH_Y_PLUS);
166  #endif
167  #endif
168 
169  /****** Y MINUS signal macros ******/
170 
171  #ifndef D4DTCH_INIT_Y_MINUS
172  #ifndef D4DTCH_Y_MINUS
173  #error "The Macro D4DTCH_Y_MINUS must be set in Touch Screen low level driver configuration file."
174  #else
175  #define D4DTCH_INIT_Y_MINUS OUTPUT(D4DTCH_Y_MINUS); RESET(D4DTCH_Y_MINUS);
176  #endif
177  #endif
178 
179  #ifndef D4DTCH_RESET_Y_MINUS
180  #ifndef D4DTCH_Y_MINUS
181  #error "The Macro D4DTCH_Y_MINUS must be set in Touch Screen low level driver configuration file."
182  #else
183  #define D4DTCH_RESET_Y_MINUS RESET(D4DTCH_Y_MINUS);
184  #endif
185  #endif
186 
187  #ifndef D4DTCH_SET_Y_MINUS
188  #ifndef D4DTCH_Y_MINUS
189  #error "The Macro D4DTCH_Y_MINUS must be set in Touch Screen low level driver configuration file."
190  #else
191  #define D4DTCH_SET_Y_MINUS SET(D4DTCH_Y_MINUS);
192  #endif
193  #endif
194 
195  #ifndef D4DTCH_Y_MINUS_HIGH_Z_ENABLE
196  #ifndef D4DTCH_Y_MINUS
197  #error "The Macro D4DTCH_Y_MINUS must be set in Touch Screen low level driver configuration file."
198  #else
199  #define D4DTCH_Y_MINUS_HIGH_Z_ENABLE INPUT(D4DTCH_Y_MINUS);
200  #endif
201  #endif
202 
203  #ifndef D4DTCH_Y_MINUS_HIGH_Z_DISABLE
204  #ifndef D4DTCH_Y_MINUS
205  #error "The Macro D4DTCH_Y_MINUS must be set in Touch Screen low level driver configuration file."
206  #else
207  #define D4DTCH_Y_MINUS_HIGH_Z_DISABLE OUTPUT(D4DTCH_Y_MINUS);
208  #endif
209  #endif
210 
211 
212  /****** Algorithm constants/macros *****/
213 
214  #ifndef D4DTCH_FULL_SCALE
215  #define D4DTCH_FULL_SCALE 0x0FFF
216  #endif
217 
218  #ifndef D4DTCH_X_TOUCH_MIN
219  #define D4DTCH_X_TOUCH_MIN (D4DTCH_FULL_SCALE / 10)
220  #endif
221 
222  #ifndef D4DTCH_Y_TOUCH_MIN
223  #define D4DTCH_Y_TOUCH_MIN (D4DTCH_FULL_SCALE / 10)
224  #endif
225 
226  #ifndef D4DTCH_X_TOUCH_OFFMAX
227  #define D4DTCH_X_TOUCH_OFFMAX (D4DTCH_X_TOUCH_MIN * 4 / 2)
228  #endif
229 
230  #ifndef D4DTCH_Y_TOUCH_OFFMAX
231  #define D4DTCH_Y_TOUCH_OFFMAX (D4DTCH_Y_TOUCH_MIN * 4 / 2)
232  #endif
233 
234  #ifndef D4DTCH_SAMPLE_MARGIN
235  #define D4DTCH_SAMPLE_MARGIN (D4DTCH_FULL_SCALE / 256)
236  #endif
237 
238  // b01800
239  #define D4DTCH_ADC_HW_ID 1 // USE ATD0 module
240 
241  #if D4DTCH_ADC_HW_ID == 0
242 
243  #define D4DTCH_ATDCTL0 ATD0CTL0
244  #define D4DTCH_ATDCTL1 ATD0CTL1
245  #define D4DTCH_ATDCTL2 ATD0CTL2
246  #define D4DTCH_ATDCTL3 ATD0CTL3
247  #define D4DTCH_ATDCTL4 ATD0CTL4
248  #define D4DTCH_ATDCTL5 ATD0CTL5
249  #define D4DTCH_ATDSTAT0 ATD0STAT0
250  #define D4DTCH_ATDDR0 ATD0DR0
251  #define D4DTCH_ATDDR1 ATD0DR1
252  #define D4DTCH_ATDDR2 ATD0DR2
253  #define D4DTCH_ATDDR3 ATD0DR3
254  #define D4DTCH_ATDSTAT0_SCF ATD0STAT0_SCF
255 
256  #elif D4DTCH_ADC_HW_ID == 1 // USE ATD1 module
257 
258  #define D4DTCH_ATDCTL0 ATD1CTL0
259  #define D4DTCH_ATDCTL1 ATD1CTL1
260  #define D4DTCH_ATDCTL2 ATD1CTL2
261  #define D4DTCH_ATDCTL3 ATD1CTL3
262  #define D4DTCH_ATDCTL4 ATD1CTL4
263  #define D4DTCH_ATDCTL5 ATD1CTL5
264  #define D4DTCH_ATDSTAT0 ATD1STAT0
265  #define D4DTCH_ATDDR0 ATD1DR0
266  #define D4DTCH_ATDDR1 ATD1DR1
267  #define D4DTCH_ATDDR2 ATD1DR2
268  #define D4DTCH_ATDDR3 ATD1DR3
269  #define D4DTCH_ATDSTAT0_SCF ATD1STAT0_SCF
270 
271  #endif
272 
273 
274 
275  /******************************************************************************
276  * Global variables
277  ******************************************************************************/
278 
279  /******************************************************************************
280  * Global functions
281  ******************************************************************************/
282 
283  #endif
284 #endif /* __D4DTCHHW_S12_ADC_H */
285 
286 
287 
288 
289 
290 
291 
292 
293 
294