Fixed line draw
[hackover2013-badge-firmware.git] / drivers / lcd / tft / touchscreen.h
1 /**************************************************************************/
2 /*!
3 @file touchscreen.h
4 @author K. Townsend (microBuilder.eu)
5
6 @section LICENSE
7
8 Software License Agreement (BSD License)
9
10 Copyright (c) 2010, microBuilder SARL
11 All rights reserved.
12
13 Redistribution and use in source and binary forms, with or without
14 modification, are permitted provided that the following conditions are met:
15 1. Redistributions of source code must retain the above copyright
16 notice, this list of conditions and the following disclaimer.
17 2. Redistributions in binary form must reproduce the above copyright
18 notice, this list of conditions and the following disclaimer in the
19 documentation and/or other materials provided with the distribution.
20 3. Neither the name of the copyright holders nor the
21 names of its contributors may be used to endorse or promote products
22 derived from this software without specific prior written permission.
23
24 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
25 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
28 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 */
35 /**************************************************************************/
36 #ifndef __TOUCHSCREEN_H__
37 #define __TOUCHSCREEN_H__
38
39 #include "projectconfig.h"
40
41 #define TS_XP_PORT (1)
42 #define TS_XP_PIN (0)
43 #define TS_XP_FUNC_GPIO do {IOCON_JTAG_TMS_PIO1_0 &= ~(IOCON_JTAG_TMS_PIO1_0_FUNC_MASK | IOCON_JTAG_TMS_PIO1_0_ADMODE_MASK); IOCON_JTAG_TMS_PIO1_0 |= IOCON_JTAG_TMS_PIO1_0_FUNC_GPIO;} while (0)
44 #define TS_XP_FUNC_ADC do {IOCON_JTAG_TMS_PIO1_0 &= ~(IOCON_JTAG_TMS_PIO1_0_FUNC_MASK | IOCON_JTAG_TMS_PIO1_0_ADMODE_MASK); IOCON_JTAG_TMS_PIO1_0 |= IOCON_JTAG_TMS_PIO1_0_FUNC_AD1;} while (0)
45
46 #define TS_XM_PORT (1)
47 #define TS_XM_PIN (1)
48 #define TS_XM_FUNC_GPIO do {IOCON_JTAG_TDO_PIO1_1 &= ~(IOCON_JTAG_TDO_PIO1_1_FUNC_MASK | IOCON_JTAG_TDO_PIO1_1_ADMODE_MASK); IOCON_JTAG_TDO_PIO1_1 |= IOCON_JTAG_TDO_PIO1_1_FUNC_GPIO;} while (0)
49 #define TS_XM_FUNC_ADC do {IOCON_JTAG_TDO_PIO1_1 &= ~(IOCON_JTAG_TDO_PIO1_1_FUNC_MASK | IOCON_JTAG_TDO_PIO1_1_ADMODE_MASK); IOCON_JTAG_TDO_PIO1_1 |= IOCON_JTAG_TDO_PIO1_1_FUNC_AD2;} while (0)
50
51 #define TS_YP_PORT (0)
52 #define TS_YP_PIN (11)
53 #define TS_YP_FUNC_GPIO do {IOCON_JTAG_TDI_PIO0_11 &= ~(IOCON_JTAG_TDI_PIO0_11_FUNC_MASK | IOCON_JTAG_TDI_PIO0_11_ADMODE_MASK); IOCON_JTAG_TDI_PIO0_11 |= IOCON_JTAG_TDI_PIO0_11_FUNC_GPIO;} while (0)
54 #define TS_YP_FUNC_ADC do {IOCON_JTAG_TDI_PIO0_11 &= ~(IOCON_JTAG_TDI_PIO0_11_FUNC_MASK | IOCON_JTAG_TDI_PIO0_11_ADMODE_MASK); IOCON_JTAG_TDI_PIO0_11 |= IOCON_JTAG_TDI_PIO0_11_FUNC_AD0;} while (0)
55
56 #define TS_YM_PORT (1)
57 #define TS_YM_PIN (2)
58 #define TS_YM_FUNC_GPIO do {IOCON_JTAG_nTRST_PIO1_2 &= ~(IOCON_JTAG_nTRST_PIO1_2_FUNC_MASK | IOCON_JTAG_nTRST_PIO1_2_ADMODE_MASK); IOCON_JTAG_nTRST_PIO1_2 |= IOCON_JTAG_nTRST_PIO1_2_FUNC_GPIO;} while (0)
59 #define TS_YM_FUNC_ADC do {IOCON_JTAG_nTRST_PIO1_2 &= ~(IOCON_JTAG_nTRST_PIO1_2_FUNC_MASK | IOCON_JTAG_nTRST_PIO1_2_ADMODE_MASK); IOCON_JTAG_nTRST_PIO1_2 |= IOCON_JTAG_nTRST_PIO1_2_FUNC_AD3;} while (0)
60
61 #define TS_YP_ADC_CHANNEL (0) // ADC0.0
62 #define TS_XP_ADC_CHANNEL (1) // ADC0.1
63 #define TS_XM_ADC_CHANNEL (2) // ADC0.2
64 #define TS_YM_ADC_CHANNEL (3) // ADC0.3
65
66 typedef struct Point
67 {
68 int32_t x;
69 int32_t y;
70 } tsPoint_t;
71
72 typedef struct Matrix
73 {
74 int32_t An,
75 Bn,
76 Cn,
77 Dn,
78 En,
79 Fn,
80 Divider ;
81 } tsMatrix_t;
82
83 typedef struct
84 {
85 uint32_t xraw; // Touch screen x
86 uint32_t yraw; // Touch screen Y
87 uint16_t xlcd; // LCD co-ordinate X
88 uint16_t ylcd; // LCD co-ordinate Y
89 uint32_t z1;
90 uint32_t z2;
91 bool valid; // Whether this is a valid reading or not
92 } tsTouchData_t;
93
94 typedef enum
95 {
96 TS_ERROR_NONE = 0,
97 TS_ERROR_TIMEOUT = -1, // Timeout occured before a valid reading
98 TS_ERROR_XYMISMATCH = -2 // Unable to get a stable X/Y value
99 } tsTouchError_t;
100
101 // Method Prototypes
102 void tsInit ( void );
103 tsTouchError_t tsRead(tsTouchData_t* data);
104 void tsCalibrate ( void );
105 tsTouchError_t tsWaitForEvent(tsTouchData_t* data, uint32_t timeoutMS);
106 int tsSetThreshhold(uint8_t value);
107 uint8_t tsGetThreshhold(void);
108
109 #endif
This page took 0.051048 seconds and 5 git commands to generate.