Lcd companion boards support (VKLCD50RTA & VKLCD70RT)
Embed:
(wiki syntax)
Show/hide line numbers
stmpe811iic.h
00001 /******************************************************************************* 00002 00003 *******************************************************************************/ 00004 /****************************************************************************** 00005 * File Name : tpiic.h 00006 * Description : TPIIC header 00007 ******************************************************************************/ 00008 #ifndef STMPE811IIC_H 00009 #define STMPE811IIC_H 00010 00011 #include "lcd_panel.h" 00012 /****************************************************************************** 00013 Includes <System Includes> , "Project Includes" 00014 ******************************************************************************/ 00015 00016 #define __USE_DEFAULT_CALIBRATION_DATA__ 00017 00018 #define STMPE811_DEVICE_ADDR (0x82) 00019 //#define STMPE811_DEVICE_ADDR (0x88) 00020 //#define EE_LPC11U35_DEVICE_ADDR (0xA0) 00021 00022 #define TPIIC_CH 3 00023 #define TPIIC_SCL P1_6 00024 #define TPIIC_SDA P1_7 00025 00026 #if (LCD_VDC5_CH0_PANEL==LCD_CH0_PANEL_VKLCD70RT) 00027 #define TPIRQ_CH 1 00028 #define TPIRQ_PIN P7_8 00029 00030 #define EEIIC_CH 3 00031 #define EEIIC_SCL P1_6 00032 #define EEIIC_SDA P1_7 00033 #define EE_CALIB_DEVICE_ADDR 0xA8 00034 00035 #define TPCALIBRATION_DATA 0x38,0x00,0x00,0x00,0x01,0x00,0x00,0x00,\ 00036 0x50,0xb4,0x52,0x38,0xec,0x97,0xd0,0x3f,0xd7,0xfe,0x58,0xc5,0x10,0xb2,0x52,0x3f,\ 00037 0xde,0x09,0xc6,0x87,0xaa,0x7d,0xbb,0x3e,0x65,0xaa,0xb4,0xd2,0x56,0x04,0xc5,0xbf,\ 00038 0x02,0xb3,0x33,0x61,0x9b,0x1e,0x34,0xc0,0x88,0x87,0xc3,0x39,0x38,0x7d,0x83,0x40 00039 #else 00040 #define TPIRQ_CH 2 00041 #define TPIRQ_PIN P1_2 00042 00043 #define EEIIC_CH 0 00044 #define EEIIC_SCL P1_0 00045 #define EEIIC_SDA P1_1 00046 #define EE_CALIB_DEVICE_ADDR 0xA8 00047 00048 #define TPCALIBRATION_DATA 0x38,0x00,0x00,0x00,0x01,0x00,0x00,0x00,\ 00049 0x66,0x44,0x6c,0xe9,0x11,0xa1,0xbf,0xbf,0x70,0x8f,0x61,0x1c,0x3f,0x5e,0x20,0x3f,\ 00050 0xad,0x80,0xca,0x76,0x62,0xb9,0x8a,0x3e,0xae,0x95,0xef,0x7e,0xa7,0x8d,0xb2,0xbf,\ 00051 0x24,0x37,0x82,0x68,0xe6,0xc1,0x7e,0x40,0xf4,0xb6,0xa8,0xe8,0x88,0xa3,0x71,0x40 00052 #endif 00053 00054 #define FIFO_DEPTH 128 // packets, which means 12bit x + 12bit y +8bit = 32bit for 1 data packet 00055 00056 //sys regs 00057 #define CHIP_ID 0x00 // 16 R 0x0811 Device identification 00058 #define ID_VER 0x02 // 8 R 0x01 Revision number 0x01 for engineering sample for final silicon 00059 #define SYS_CTRL1 0x03 // 8 R/W 0x00 Reset control 00060 #define SYS_CTRL2 0x04 // 8 R/W 0x0F Clock control 00061 #define SPI_CFG 0x08 // 8 R/W 0x01 SPI interface configuration 00062 #define INT_CTRL 0x09 // 8 R/W 0x00 Interrupt control register 00063 #define INT_EN 0x0A // 8 R/W 0x00 Interrupt enable register 00064 #define INT_STA 0x0B // 8 R 0x10 interrupt status register 00065 #define GPIO_EN 0x0C // 8 R/W 0x00 GPIO interrupt enable register 00066 #define GPIO_INT_STA 0x0D // 8 R 0x00 GPIO interrupt status register 00067 #define ADC_INT_EN 0x0E // 8 R/W 0x00 ADC interrupt enable register 00068 #define ADC_INT_STA 0x0F // 8 R 0x00 ADC interrupt status register 00069 #define GPIO_SET_PIN 0x10 // 8 R/W 0x00 GPIO set pin register 00070 #define GPIO_CLR_PIN 0x11 // 8 R/W 0x00 GPIO clear pin register 00071 #define GPIO_MP_STA 0x12 // 8 R/W 0x00 GPIO monitor pin state register 00072 #define GPIO_DIR 0x13 // 8 R/W 0x00 GPIO direction register 00073 #define GPIO_ED 0x14 // 8 R/W 0x00 GPIO edge detect register 00074 #define GPIO_RE 0x15 // 8 R/W 0x00 GPIO rising edge register 00075 #define GPIO_FE 0x16 // 8 R/W 0x00 GPIO falling edge register 00076 #define GPIO_AF 0x17 // 8 R/W 0x00 Alternate function register 00077 00078 //ADC regs 00079 #define ADC_CTRL1 0x20 // 8 R/W 0x9C ADC control 00080 #define ADC_CTRL2 0x21 // 8 R/W 0x01 ADC control 00081 #define ADC_CAPT 0x22 // 8 R/W 0xFF To initiate ADC data acquisition 00082 #define ADC_DATA_CH0 0x30 // 16 R 0x0000 ADC channel 0 00083 #define ADC_DATA_CH1 0x32 // 16 R 0x0000 ADC channel 1 00084 #define ADC_DATA_CH2 0x34 // 16 R 0x0000 ADC channel 2 00085 #define ADC_DATA_CH3 0x36 // 16 R 0x0000 ADC channel 3 00086 #define ADC_DATA_CH4 0x38 // 16 R 0x0000 ADC channel 4 00087 #define ADC_DATA_CH5 0x3A // 16 R 0x0000 ADC channel 5 00088 #define ADC_DATA_CH6 0x3C // 16 R 0x0000 ADC channel 6 00089 #define ADC_DATA_CH7 0x3E // 16 R 0x0000 ADC channel 7 00090 00091 //touch regs 00092 #define TSC_CTRL 0x40 // 8 R/W 0x90 4-wire touchscreen controller setup 00093 #define TSC_CFG 0x41 // 8 R/W 0x00 Touchscreen controller configuration 00094 #define WDW_TR_X 0x42 // 16 R/W 0x0FFF Window setup for top right X 00095 #define WDW_TR_Y 0x44 // 16 R/W 0x0FFF Window setup for top right Y 00096 #define WDW_BL_X 0x46 // 16 R/W 0x0000 Window setup for bottom left X 00097 #define WDW_BL_Y 0x48 // 16 R/W 0x0000 Window setup for bottom left Y 00098 #define FIFO_TH 0x4A // 8 R/W 0x00 FIFO level to generate interrupt 00099 #define FIFO_STA 0x4B // 8 R/W 0x20 Current status of FIFO 00100 #define FIFO_SIZE 0x4C // 8 R 0x00 Current filled level of FIFO 00101 #define TSC_DATA_X 0x4D // 16 R 0x0000 Data port for touchscreen controller data access 00102 #define TSC_DATA_Y 0x4F // 16 R 0x0000 Data port for touchscreen controller data access 00103 #define TSC_DATA_Z 0x51 // 8 R 0x0000 Data port for touchscreen controller data access 00104 #define TSC_DATA_XYZ 0x52 // 32 R 0x00000000 Data port for touchscreen controller data access 00105 #define TSC_FRACT_Z 0x56 // 8 0x00 00106 #define TSC_DATA_AI 0x57 // 8 R 0x00 Data port for touchscreen controller data access AUTO_INCREMENT 00107 #define TSC_DATA_NAI 0x07 // 8 R 0x00 Data port for touchscreen controller data access NONE_AUTO_INCREMENT 00108 #define TSC_DATA_FIFO 0xD7 // 00109 #define TSC_I_DRIVE 0x58 // 8 R/W 0x00 00110 #define TSC_SHIELD 0x59 // 8 R/W 0x00 00111 00112 //temperature regs 00113 #define TEMP_CTRL 0x60 // 8 R/W 0x00 Temperature sensor setup 00114 #define TEMP_DATA 0x61 // 8 R 0x00 Temperature data access port 00115 #define TEMP_TH 0x62 // 8 R/W 0x00 Threshold for temperature controlled interrupt 00116 00117 //interrupt status & enable bits 00118 #define INT_GPIO 0x80 00119 #define INT_ADC 0x40 00120 #define INT_TEMP_SENS 0x20 00121 #define INT_FIFO_EMPTY 0x10 00122 #define INT_FIFO_FULL 0x08 00123 #define INT_FIFO_OFLOW 0x04 00124 #define INT_FIFO_TH 0x02 00125 #define INT_TOUCH_DET 0x01 00126 00127 //Z axis accuracy 00128 #define _8_0 0x00 00129 #define _7_1 0x01 00130 #define _6_2 0x02 00131 #define _5_3 0x03 00132 #define _4_4 0x04 00133 #define _3_5 0x05 00134 #define _2_6 0x06 00135 #define _1_7 0x07 00136 00137 #define INIT_DATA /* {register, value}, ... */ \ 00138 {SYS_CTRL1, 0x02}, /* 0. Reset touchscreen controller */ \ 00139 {SYS_CTRL2, 0x0C}, /* 1. Disable the clock gating for the touchscreen controller and ADC in the SYS_CFG2 register*/ \ 00140 {INT_EN, (INT_FIFO_OFLOW | INT_FIFO_TH | INT_TOUCH_DET)}, /* 2. Configure which interrupts to be outputed */ \ 00141 {ADC_CTRL1, 0x49}, /* 3. Write: register Add = 0x20 ADC_CTRL1, data = 0x49 delay, 2mS */ \ 00142 {ADC_CTRL2, 0x01}, /* 4. Write: register Add = 0x21 ADC_CTRL2, data = 0x01 */ \ 00143 {GPIO_AF, 0x00}, /* 5. Write: register Add = 0x17 GPIO_AF, data = 0x00 */ \ 00144 {TSC_CFG, 0x6C}, /* 6. 5ms panel voltage setting time, 1ms touch detection delay, averaging on every 2-nd sample */ \ 00145 {FIFO_TH, 0x05}, /* 7. Group points reading (if more than 4 points collected generate interrupt) */ \ 00146 {FIFO_STA, 0x01}, /* 8a. Clear FIFO */ \ 00147 {FIFO_STA, 0x00}, /* 8b. Reset FIFO */ \ 00148 {TSC_FRACT_Z, _1_7}, /* 9. Choose the appropriate accurency of the measured pressure of the touch 7 fractional bits & 1 int */ \ 00149 {TSC_I_DRIVE, 0x00}, /* 10. Write: register Add = 0x58 TSC_I_DRIVE, data = 0x01 */ \ 00150 {TSC_CTRL, 0x01}, /* 11. Configure the operating mode and the window tracking index, start touch detection & data acquisition*/\ 00151 {INT_STA, 0xFF}, /* 12. Clear Interrupt register*/ \ 00152 {INT_CTRL, 0x03}, /* 13. Configure the interrupt signal and enable the interrupts //int-> Edge interrupt -> falling edge*/ 00153 00154 /****************************************************************************** 00155 Variable Externs 00156 ******************************************************************************/ 00157 00158 typedef union __CALIB { 00159 struct __DATA 00160 { 00161 unsigned long len; 00162 unsigned long flag; 00163 double KX1, KY1, KX2, KY2, KX3, KY3; 00164 }data; 00165 unsigned char KX08[sizeof(struct __DATA)]; 00166 }touch_calib_data_t; 00167 00168 typedef union RAW_SAMPLE__ { 00169 struct AXIS__ 00170 { 00171 unsigned short x; 00172 unsigned short y; 00173 unsigned long z; 00174 }axis; 00175 unsigned long long dot; 00176 }touch_raw_data_t; 00177 00178 typedef union SCREEN_SAMPLE__ { 00179 struct AXIS_ 00180 { 00181 short x; 00182 short y; 00183 float z; 00184 }axis; 00185 unsigned long long dot; 00186 }touch_screen_data_t; 00187 00188 #endif /* STMPE811IIC_H */ 00189
Generated on Tue Jul 12 2022 14:32:47 by
1.7.2