A board support package for the LPC4088 Display Module.

Dependencies:   DM_HttpServer DM_USBHost

Dependents:   lpc4088_displaymodule_emwin lpc4088_displaymodule_demo_sphere sampleGUI sampleEmptyGUI ... more

Fork of DMSupport by EmbeddedArtists AB

Revision:
28:8ae20cb0b943
Parent:
26:a65fbb4bde5c
Child:
31:d47cffcb0a3e
--- a/Display/BiosTouch.cpp	Fri Jan 23 13:48:44 2015 +0100
+++ b/Display/BiosTouch.cpp	Fri Jan 23 17:31:56 2015 +0100
@@ -41,9 +41,8 @@
            _listener(NULL), _lostData(0),
            _dbgAdded(0), _dbgRemoved(0) {}
         void handleTouchInterrupt();
-        void handleI2CInterrupt();
         void handleNewData(touch_coordinate_t* coord, int num);
-        void changeTouchInterrupt(bool enable, bool rising);
+        void changeTouchInterrupt(bool enable, touch_irq_trigger_t trigger);
         TouchPanel::TouchError read(touch_coordinate_t* coord, int num);
         void run();
         FunctionPointer* setListener(FunctionPointer* listener);
@@ -65,19 +64,10 @@
  * Local variables
  *****************************************************************************/
 
-static TouchHandler* theTouchHandler = NULL; // ugly but needed for IRQ
-
 /******************************************************************************
  * Private Functions
  *****************************************************************************/
 
-static void touch_i2c0_irq_handler()
-{
-  if (theTouchHandler != NULL) {
-    theTouchHandler->handleI2CInterrupt();
-  }
-}
-
 BiosTouch::BiosTouch() : 
     _initialized(false),
     _haveInfo(false),
@@ -106,9 +96,9 @@
 }
 
 // Function called from the BIOS
-static void touchIrqEnabler(uint32_t arg, bool enable, bool rising)
+static void touchIrqEnabler(uint32_t arg, bool enable, touch_irq_trigger_t trigger)
 {
-  ((TouchHandler*)arg)->changeTouchInterrupt(enable, rising);
+  ((TouchHandler*)arg)->changeTouchInterrupt(enable, trigger);
 }
 
 // Function called from the BIOS
@@ -192,13 +182,6 @@
   CLR_MEAS_PIN_2();
 }
 
-void TouchHandler::handleI2CInterrupt()
-{
-  SET_MEAS_PIN_3();
-  _bios->touchI2CIRQHandler(_biosData);
-  CLR_MEAS_PIN_3();
-}
-
 void TouchHandler::handleNewData(touch_coordinate_t* coord, int num)
 {
   SET_MEAS_PIN_4();
@@ -215,20 +198,30 @@
   CLR_MEAS_PIN_4();
 }
 
-void TouchHandler::changeTouchInterrupt(bool enable, bool rising)
+void TouchHandler::changeTouchInterrupt(bool enable, touch_irq_trigger_t trigger)
 {
-  if (enable) {
-    if (rising) {
-      _touchIRQ.rise(this, &TouchHandler::handleTouchInterrupt);
-    } else {
-      _touchIRQ.fall(this, &TouchHandler::handleTouchInterrupt);
-    }
-  } else {
-    if (rising) {
-      _touchIRQ.rise(NULL);
-    } else {
-      _touchIRQ.fall(NULL);
-    }
+  switch (trigger) {
+    case TOUCH_IRQ_RISING_EDGE:
+      if (enable) {
+        _touchIRQ.rise(this, &TouchHandler::handleTouchInterrupt);
+      } else {
+        _touchIRQ.rise(NULL);
+      }
+      break;
+
+    case TOUCH_IRQ_FALLING_EDGE:
+      if (enable) {
+        _touchIRQ.fall(this, &TouchHandler::handleTouchInterrupt);
+      } else {
+        _touchIRQ.fall(NULL);
+      }
+      break;
+          
+    case TOUCH_IRQ_HIGH_LEVEL:
+    case TOUCH_IRQ_LOW_LEVEL:
+    default:
+      DMBoard::instance().logger()->printf("BIOS requests unknown trigger type %d\n", trigger);
+      break;
   }
 }
 
@@ -256,7 +249,7 @@
         break;
       }
       
-      result = (TouchError)_bios->touchInformation(_biosData, &_supportsTouch, &_supportsTouchCalibration, &_touchIsResistive, &_touchNumFingers);
+      result = (TouchError)_bios->touchInformation(_biosData, &_supportsTouch, &_supportsTouchCalibration, &_touchNumFingers);
       if (result != TouchError_Ok) {
         break;
       }
@@ -268,10 +261,7 @@
         break;
       }
       
-      NVIC_DisableIRQ(I2C0_IRQn);
-      NVIC_SetVector(I2C0_IRQn, (uint32_t)touch_i2c0_irq_handler);      
-      _handler = theTouchHandler = new TouchHandler(_bios, _biosData, _touchNumFingers);
-      NVIC_EnableIRQ(I2C0_IRQn);
+      _handler = new TouchHandler(_bios, _biosData, _touchNumFingers);
           
       result = (TouchError)_bios->touchInit(_biosData, touchIrqEnabler, (uint32_t)_handler, touchNewData, (uint32_t)_handler);
       if (result != TouchError_Ok) {
@@ -292,7 +282,6 @@
       if (_handler != NULL) {
         delete _handler;
         _handler = NULL;
-        theTouchHandler = NULL;
       }
     }
   }
@@ -327,7 +316,6 @@
   if (!_haveInfo) {
       err = TouchError_NoInit;
   } else {
-    *resistive = _touchIsResistive;
     *maxPoints = _touchNumFingers;
     *calibrated = _supportsTouchCalibration;
   }