test program for SPI_STMPE610

Dependencies:   SPI_STMPE610 mbed vt100

Revision:
3:547b48007148
Parent:
2:0ed1195754b0
--- a/main.cpp	Mon Mar 13 00:49:23 2017 +0000
+++ b/main.cpp	Mon May 01 00:33:06 2017 +0000
@@ -14,21 +14,10 @@
   * to an interrupt pin on my frdm-kl25z, I just used polling mode.
   */
 #include "mbed.h"
+#include "vt100.h"
 #include "SPI_STMPE610.h"
 
-#if 0
-#ifndef TARGET_NECLEO_F411RE
-#define TARGET_NECLEO_F411RE 
-#endif
-#endif 
-
-#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
+vt100 *tty = 0 ;
 
 #if   defined (TARGET_KL25Z) 
 #define PIN_MOSI        PTD2
@@ -90,6 +79,8 @@
 #define PIN_SCLK  P2_0
 #define PIN_MISO P2_2
 #define PIN_MOSI P2_1
+// #define PIN_MISO P2_1
+// #define PIN_MOSI P2_2
 #define PIN_CS0  P2_3
 /* Interrupt */
 #define PIN_INT0 P2_4
@@ -122,34 +113,35 @@
   #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 tft_cs(PIN_CS_TFT, 1) ;
+DigitalOut sd_cs(PIN_CS_SD, 1) ;
+DigitalOut tsc_cs(PIN_CS_TSC, 1) ;
 // DigitalOut tsc_intr(PIN_TSC_INTR) ; // should be input, just for test
+// DigitalOut tft_reset(PIN_RESET_TFT, 1) ;
 
 int main()
 {
     uint16_t touched, x, y, z ;
     SPI_STMPE610 *tsc ;
+#if (TARGET_MAX32600MBED)
+    uint32_t *SPI0_MSTR_CFG = (uint32_t*)0x40030000 ;
+    tty = new vt100(57600) ;
+#else
+    tty = new vt100() ;
+#endif
+    tty->cls() ;
+    
     tsc = new SPI_STMPE610(PIN_MOSI, PIN_MISO, PIN_SCLK, PIN_CS_TSC) ;
-//    tsc->spi_format(8, 1) ;
+ //   tsc->spi_frequency(1000000) ; 
+ //   tsc->spi_format(8, 0) ;
     printf("Test SPI STMPE610 (%s:%s)\n\r", DEVICE_NAME, __DATE__) ;
-    tft_cs = 1 ;
-    sd_cs = 1 ;
-//    tsc_intr = 1 ;
-    tsc_cs = 0 ;
+
+    tft_cs = 1 ; /* disable TFT display */
+    sd_cs = 1 ; /* disable SD */
+
     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 ;
-            */
+        if (touched) {
             printf("x = %d, y = %d, z = %d\n\r", x, y, z) ;
         }
         wait(0.1) ;