Added SPI burst mode to spi 8 bit.

Dependents:   Bicycl_Computer_NUCLEO-F411RE Bicycl_Computer_NUCLEO-L476RG

Fork of UniGraphic by GraphicsDisplay

Added SPI burst mode to this graphics driver. If whoever wants this rolled in to repository let me know. I replaced _spi.write(); with fastWrite(); and clearRX();

SPI8.cpp

// need to re-create SPI firmware to access SPI handle
static SPI_HandleTypeDef SpiHandle;

void SPI8::fastWrite(int data) {
    
      SpiHandle.Instance = SPI1;
    // Check if data is transmitted
    while ((SpiHandle.Instance->SR & SPI_SR_TXE) == 0);
    SpiHandle.Instance->DR = data;
}
    
void SPI8::clearRX( void ) {
        SpiHandle.Instance = SPI1;
    //Check if the RX buffer is busy
    //While busy, keep checking
    while (SpiHandle.Instance->SR & SPI_SR_BSY){   
        // Check RX buffer readable
        while ((SpiHandle.Instance->SR & SPI_SR_RXNE) == 0);
        int dummy = SpiHandle.Instance->DR;
    }
}      
Revision:
5:b222a9461d6b
Parent:
4:12ba0ecc2c1f
Child:
7:bb0383b91104
--- a/Display/TFT.cpp	Sun Feb 15 20:06:07 2015 +0000
+++ b/Display/TFT.cpp	Mon Feb 16 00:52:24 2015 +0000
@@ -83,6 +83,14 @@
     {
         proto->wr_grambuf(data, lenght);
     }
+unsigned int TFT::rd_data32_wdummy()
+    {
+        return proto->rd_data32_wdummy();
+    }
+unsigned short TFT::rd_gram()
+    {
+        return (proto->rd_gram());
+    }
 //for TFT, just send data, position counters are in hw
 void TFT::window_pushpixel(unsigned short color)
 {
@@ -141,7 +149,6 @@
 {
     //ili9486 does not like truncated 2A/2B cmds, at least in par mode
     //setting only start column/page would speedup, but needs a windowmax() before, maybe implement later
-    //fixme for PAR_16: // cmd 2A/2B expects 8bit parameters
     wr_cmd8(0x2A);
     wr_data16(x);   //start column
     wr_data16(x+w-1);//end column
@@ -152,12 +159,33 @@
     
     wr_cmd8(0x2C);  //write mem, just send pixels color next
 }
+void TFT::window4read(int x, int y, int w, int h)
+{
+    wr_cmd8(0x2A);
+    wr_data16(x);   //start column
+    wr_data16(x+w-1);//end column
+
+    wr_cmd8(0x2B);
+    wr_data16(y);   //start page
+    wr_data16(y+h-1);//end page
+    
+    wr_cmd8(0x2E);  //read mem, just pixelread next
+}
 void TFT::pixel(int x, int y, unsigned short color)
 {
     window(x,y,1,1);
   //  proto->wr_gram(color);   // 2C expects 16bit parameters
     wr_gram(color);
 }
+unsigned short TFT::pixelread(int x, int y)
+{
+    unsigned short color;
+    window4read(x,y,1,1);
+  //  proto->wr_gram(color);   // 2C expects 16bit parameters
+    color = rd_gram();
+    if(mipistd) color = BGR2RGB(color); // in case, convert BGR to RGB (should depend on cmd36 bit3) but maybe is device specific
+    return color;
+}
 void TFT::cls (void)
 {
     WindowMax();