Caiou
Dependents: LCD_Proj LCD_imagetest LCD_Proj_rtc
Fork of DmTftLibrary by
Diff: DmTouch.cpp
- Revision:
- 14:2db7065edbec
- Parent:
- 11:264e19992620
- Child:
- 15:0c36e018a6cc
diff -r 6ff2649b6c27 -r 2db7065edbec DmTouch.cpp --- a/DmTouch.cpp Fri Sep 18 14:59:13 2015 +0000 +++ b/DmTouch.cpp Mon Oct 12 08:35:35 2015 +0000 @@ -9,7 +9,7 @@ THIS SOFTWARE IS SUPPLIED "AS IS" WITHOUT ANY WARRANTIES AND SUPPORT. DISPLAYMODULE ASSUMES NO RESPONSIBILITY OR LIABILITY FOR THE USE OF THE SOFTWARE. ********************************************************************************************/ -// Tested with Xpt2046 +// Tested with Xpt2046 and RA8875 #include "DmTouch.h" #include "DmTouchCalibration.h" @@ -21,11 +21,10 @@ // spiMode - How to read SPI-data, Software, Hardware or Auto // useIrq - Enable IRQ or disable IRQ DmTouch::DmTouch(Display disp, SpiMode spiMode, bool useIrq) - #elif defined (DM_TOOLCHAIN_MBED) // disp - which display is used // spiMode - How to read SPI-data, Software, Hardware or Auto -DmTouch::DmTouch(Display disp, SpiMode spiMode) +DmTouch::DmTouch(Display disp, PinName mosi, PinName miso, PinName clk) #endif { _disp = disp; @@ -104,22 +103,6 @@ _touch_id = IC_2046; break; } - - if (spiMode == DmTouch::Hardware) { - _hardwareSpi = true; - } else if (spiMode == DmTouch::Software) { - _hardwareSpi = false; - } - -#if defined(DM_TOOLCHAIN_ARDUINO) - if (!useIrq) { - _irq = -1; - } -#elif defined (DM_TOOLCHAIN_MBED) - if(_touch_id != IC_8875) { - _irq = -1; - } -#endif setCalibrationMatrix(DmTouchCalibration::getDefaultCalibrationData(disp)); @@ -151,22 +134,21 @@ _bitmaskMISO = digitalPinToBitMask(_miso); } #elif defined (DM_TOOLCHAIN_MBED) - _pinCS = new DigitalOut((PinName)_cs); + _pinCS = new DigitalOut(_cs); if (_hardwareSpi) { sbi(_pinCS, _bitmaskCS); _spi = new SPI((PinName)_mosi, (PinName)_miso, (PinName)_clk); _spi->format(8,0); - _spi->frequency(2000000); // Max SPI speed - //cbi(_pinCS, _bitmaskCS); + _spi->frequency(2000000); // Max SPI speed } else { - _pinCLK = new DigitalOut((PinName)_clk); - _pinMISO = new DigitalIn((PinName)_miso); - _pinMOSI = new DigitalOut((PinName)_mosi); + _pinCLK = new DigitalOut(_clk); + _pinMISO = new DigitalIn(_miso); + _pinMOSI = new DigitalOut(_mosi); sbi(_pinCLK, _bitmaskCLK); } #endif - if (_irq != -1) { // We will use Touch IRQ + if (_irq != NC) { // We will use Touch IRQ enableIrq(); } } @@ -240,6 +222,11 @@ spiWrite(0x04); sbi(_pinCS, _bitmaskCS); } + else{ + cbi(_pinCS, _bitmaskCS); + spiWrite(0x80); // Enable PENIRQ + sbi(_pinCS, _bitmaskCS); + } } void DmTouch::spiWrite(uint8_t data) {