eGUI alias D4D  Release 3.0
Reference Manual
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
d4dtch_cr_touch.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 ***************************************************************************/
46 #ifndef __D4DTCH_CR_TOUCH_H
47 #define __D4DTCH_CR_TOUCH_H
48 
49  #if (D4D_MK_STR(D4D_LLD_TCH) == d4dtch_cr_touch_ID)
50 
51  /******************************************************************************
52  * Includes
53  ******************************************************************************/
54  #include "d4dtch_cr_touch_cfg.h"
55 
56  /******************************************************************************
57  * Constants
58  ******************************************************************************/
59  #define D4D_CRTCH_STATUS 0x00
60  #define D4D_CRTCH_STATUS1 0x01
61  #define D4D_CRTCH_STATUS2 0x02
62  #define D4D_CRTCH_X 0x03
63  #define D4D_CRTCH_Y 0x05
64  #define D4D_CRTCH_PRESS 0x07
65  #define D4D_CRTCH_FIFO_ST 0x09
66  #define D4D_CRTCH_FIFO_X 0x0A
67  #define D4D_CRTCH_FIFO_Y 0x0C
68  #define D4D_CRTCH_FIFO_PRESS 0x0E
69  #define D4D_CRTCH_UART_BAUD 0x10
70 
71  #define D4D_CRTCH_RES_CFG 0x40
72 
73 
74  #define D4D_CRTCH_STATUS1_RTST_MASK 0x80
75  #define D4D_CRTCH_STATUS1_RTSRDY_MASK 0x01
76 
77  #define D4D_CRTCH_RES_CFG_RTPRESEN_MASK 0x80
78 
79  #define D4D_CRTCH_STATUS2_RTSD_MASK 0x03
80 
81 
82 
83  /****** Algorithm constants/macros *****/
84 
85  #ifndef D4DTCH_FULL_SCALE
86  #define D4DTCH_FULL_SCALE 0x0FFF
87  #endif
88 
89  #ifndef D4DTCH_X_TOUCH_MIN
90  #define D4DTCH_X_TOUCH_MIN (D4DTCH_FULL_SCALE / 10)
91  #endif
92 
93  #ifndef D4DTCH_Y_TOUCH_MIN
94  #define D4DTCH_Y_TOUCH_MIN (D4DTCH_FULL_SCALE / 10)
95  #endif
96 
97  #ifndef D4DTCH_X_TOUCH_OFFMAX
98  #define D4DTCH_X_TOUCH_OFFMAX (D4DTCH_X_TOUCH_MIN * 4 / 2)
99  #endif
100 
101  #ifndef D4DTCH_Y_TOUCH_OFFMAX
102  #define D4DTCH_Y_TOUCH_OFFMAX (D4DTCH_Y_TOUCH_MIN * 4 / 2)
103  #endif
104 
105  #ifndef D4DTCH_SAMPLE_MARGIN
106  #define D4DTCH_SAMPLE_MARGIN (D4DTCH_FULL_SCALE / 256)
107  #endif
108 
109 
110  #ifndef D4DTCH_IIC_BAUDRATE
111  #define D4DTCH_IIC_BAUDRATE 400000
112  #endif
113 
114  #ifndef D4DTCH_IIC_ADDRESS
115  #define D4DTCH_IIC_ADDRESS 0x49
116  #endif
117 
118  #ifndef D4DTCH_INVERSE_X
119  #define D4DTCH_INVERSE_X 0
120  #endif
121 
122  #ifndef D4DTCH_INVERSE_Y
123  #define D4DTCH_INVERSE_Y 0
124  #endif
125 
126  #ifndef D4DTCH_SWAP_AXES
127  #define D4DTCH_SWAP_AXES 0
128  #endif
129 
130 
131  // Default TOUCHPANDING signal port name
132  #ifndef D4D_CRTCH_TOUCHPANDING_PORT
133  #define D4D_CRTCH_TOUCHPANDING_PORT B
134  #endif
135 
136  // Default TOUCHPANDING signal pin number
137  #ifndef D4D_CRTCH_TOUCHPENDING_PIN
138  #define D4D_CRTCH_TOUCHPENDING_PIN 22
139  #endif
140 
141  // Default TOUCHPANDING signal pin MUX
142  #ifndef D4D_CRTCH_TOUCHPENDING_PCR_MUX
143  #define D4D_CRTCH_TOUCHPENDING_PCR_MUX 1
144  #endif
145 
146  // Default TOUCHPANDING signal pin control flags
147  #ifndef D4D_CRTCH_TOUCHPENDING_PCR_FLAGS
148  #define D4D_CRTCH_TOUCHPENDING_PCR_FLAGS (PORT_PCR_PS_MASK | PORT_PCR_PE_MASK)
149  #endif
150 
151  // Default TOUCHPANDING signal clock gate number
152  #ifndef D4D_CRTCH_TOUCHPENDING_SCGC
153  #define D4D_CRTCH_TOUCHPENDING_SCGC 5
154  #endif
155 
156  // Constructs the SIM System Clock Gating Control Register address (e.g. SIM_SCGC5)
157  #ifndef D4D_CRTCH_TOUCHPENDING_SIM_SCGC
158  #define D4D_CRTCH_TOUCHPENDING_SIM_SCGC D4D_PASTE(SIM_SCGC, D4D_CRTCH_TOUCHPENDING_SCGC)
159  #endif
160 
161  // Constructs the SIM System Clock Gating Control Register mask (e.g. SIM_SCGC5_PORTB_MASK)
162  #ifndef D4D_CRTCH_TOUCHPENDING_SIM_SCGC_MASK
163  #define D4D_CRTCH_TOUCHPENDING_SIM_SCGC_MASK D4D_PASTE(D4D_PASTE(SIM_SCGC, D4D_PASTE(D4D_CRTCH_TOUCHPENDING_SCGC, _PORT)), D4D_PASTE(D4D_CRTCH_TOUCHPANDING_PORT, _MASK))
164  #endif
165 
166  // Constructs the PORT Pin Control Register address (e.g. PORTB_PCR22)
167  #ifndef D4D_CRTCH_TOUCHPENDING_PCR
168  #define D4D_CRTCH_TOUCHPENDING_PCR D4D_PASTE(D4D_PASTE(PORT, D4D_CRTCH_TOUCHPANDING_PORT), D4D_PASTE(_PCR, D4D_CRTCH_TOUCHPENDING_PIN))
169  #endif
170 
171  // Constructs the GPIO Port Data Input Register address (e.g. GPIOB_PDIR)
172  #ifndef D4D_CRTCH_GPIO_PDIR
173  #define D4D_CRTCH_GPIO_PDIR D4D_PASTE(GPIO, D4D_PASTE(D4D_CRTCH_TOUCHPANDING_PORT, _PDIR))
174  #endif
175 
176 
177  #ifndef D4D_LLD_TCH_HW_CRTOUCH
178  #define D4D_LLD_TCH_HW_CRTOUCH d4dtchhw_crtouch_iicBareMetal
179  #endif
180 
181  /******************************************************************************
182  * Macros
183  ******************************************************************************/
184 
185 
186  #if D4DTCH_INVERSE_X != 0
187  #define D4DTCH_INVERSE_X_INT D4DTCH_FULL_SCALE
188  #endif
189 
190  #if D4DTCH_INVERSE_Y != 0
191  #define D4DTCH_INVERSE_Y_INT D4DTCH_FULL_SCALE
192  #endif
193 
194  /******************************************************************************
195  * Types
196  ******************************************************************************/
197 #pragma pack (push)
198 #pragma pack (1)
199 
200  typedef struct
201  {
207 #pragma pack (pop)
208 
210  {
211  unsigned char (*D4DTCHHWCRTOUCH_Init)(void);
212  unsigned char (*D4DTCHHWCRTOUCH_DeInit)(void);
213  void (*D4DTCHHWCRTOUCH_SetAddress)(unsigned char);
214  signed long (*D4DTCHHWCRTOUCH_SetBaudRate)(unsigned long baudRate);
215  unsigned char (*D4DTCHHWCRTOUCH_MultiReadBytes)(unsigned char regAddr, unsigned char* pBuffer, unsigned char cnt);
216  unsigned char (*D4DTCHHWCRTOUCH_MultiWriteBytes)(unsigned char regAddr, unsigned char* pBuffer, unsigned char cnt);
217  unsigned char COMM_OK;
219 
220  /******************************************************************************
221  * Global variables
222  ******************************************************************************/
223 
225 
226  /******************************************************************************
227  * Global functions
228  ******************************************************************************/
229 
230  #endif
231 #endif /* __D4DTCH_CR_TOUCH_H */
232 
233 
234 
235 
236 
237 
238 
239 
240 
241 
unsigned char(* D4DTCHHWCRTOUCH_MultiReadBytes)(unsigned char regAddr, unsigned char *pBuffer, unsigned char cnt)
unsigned char(* D4DTCHHWCRTOUCH_MultiWriteBytes)(unsigned char regAddr, unsigned char *pBuffer, unsigned char cnt)
#define D4D_LLD_TCH_HW_CRTOUCH
unsigned char Byte
Type definition of Byte (unsigned 8-bit).
Definition: d4d_types.h:151
unsigned char(* D4DTCHHWCRTOUCH_Init)(void)
unsigned char(* D4DTCHHWCRTOUCH_DeInit)(void)
void(* D4DTCHHWCRTOUCH_SetAddress)(unsigned char)
struct D4DTCHHWCRTOUCH_FUNCTIONS_S D4DTCHHWCRTOUCH_FUNCTIONS
signed long(* D4DTCHHWCRTOUCH_SetBaudRate)(unsigned long baudRate)
unsigned short Word
Type definition of Word (unsigned 16-bit).
Definition: d4d_types.h:159