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