test program for SPI_STMPE610
Dependencies: SPI_STMPE610 mbed vt100
main.cpp
- Committer:
- Rhyme
- Date:
- 2015-08-02
- Revision:
- 1:8e4295a5c716
- Parent:
- 0:bfe34cc0bc72
- Child:
- 2:0ed1195754b0
File content as of revision 1:8e4295a5c716:
/* main.cpp to test touch sensor comes with adafruit 2.8" TFT LCD shield * Copyright (c) 2014 Motoo Tanaka @ Design Methodology Lab * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ /* * Note: Since the interrupt siganl of the shield was not connected * to an interrupt pin on my frdm-kl25z, I just used polling mode. */ #include "mbed.h" #include "SPI_STMPE610.h" #if 0 #define PIN_MOSI PTD2 #define PIN_MISO PTD3 #define PIN_SCLK PTD1 #define PIN_CS_TSC PTA13 #define PIN_TSC_INTR PTC9 #endif #if defined (TARGET_KL25Z) #define PIN_MOSI PTD2 #define PIN_MISO PTD3 #define PIN_SCLK PTD1 #define PIN_CS_TFT PTD0 #define PIN_DC_TFT PTD5 #define PIN_BL_TFT PTC9 #define PIN_CS_SD PTA4 #define PIN_CS_TSC PTA13 #define PIN_TSC_INTR PTC9 #define DEVICE_NAME "KL25Z" #elif defined (TARGET_KL46Z) #define PIN_MOSI PTD6 #define PIN_MISO PTD7 #define PIN_SCLK PTD5 #define PIN_CS_TFT PTD4 #define PIN_DC_TFT PTD2 #define PIN_BL_TFT PTC9 #define PIN_CS_SD PTA4 #define PIN_CS_TSC PTA13 #define PIN_TSC_INTR PTC9 #define DEVICE_NAME "KL46Z" #elif defined (TARGET_K64F) #define PIN_MOSI PTD2 #define PIN_MISO PTD3 #define PIN_SCLK PTD1 #define PIN_CS_TFT PTD0 #define PIN_DC_TFT PTC4 #define PIN_BL_TFT PTC3 #define PIN_CS_SD PTB23 #define PIN_CS_TSC PTA0 #define PIN_TSC_INTR PTC3 #define PIN_RESET_TFT PTB20 #define PIN_ADC_CH0 PTB2 #define PIN_ADC_CH1 PTB3 #define DEVICE_NAME "K64F" #else #error TARGET NOT DEFINED #endif // SPI_STMPE610 TSC(PIN_MOSI, PIN_MISO, PIN_SCLK, PIN_CS_TSC) ; DigitalOut tft_cs(PIN_CS_TFT) ; DigitalOut sd_cs(PIN_CS_SD) ; DigitalOut tsc_cs(PIN_CS_TSC) ; // DigitalOut tsc_intr(PIN_TSC_INTR) ; // should be input, just for test int main() { uint16_t touched, x, y, z ; SPI_STMPE610 *tsc ; tsc = new SPI_STMPE610(PIN_MOSI, PIN_MISO, PIN_SCLK, PIN_CS_TSC) ; printf("Test SPI STMPE610 (%s:%s)\n\r", DEVICE_NAME, __DATE__) ; tft_cs = 1 ; sd_cs = 1 ; // tsc_intr = 1 ; tsc_cs = 0 ; while (true) { // touched = TSC.getRAWPoint(&x, &y, &z) ; touched = tsc->getRAWPoint(&x, &y, &z) ; // if (touched) { if (!((x==0)&&(y==0)&&(z==0))) { /* x &= 0x7FFF ; y &= 0x7FFF ; z &= 0x7FFF ; */ printf("x = %d, y = %d, z = %d\n\r", x, y, z) ; } wait(0.1) ; } }