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;
    }
}      
Committer:
Geremia
Date:
Fri Feb 13 23:17:55 2015 +0000
Revision:
2:713844a55c4e
Child:
9:1749ae993cfe
Initial TFT implementation, needs to add read cmds

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Geremia 2:713844a55c4e 1 #ifndef MBED_ILI9341_H
Geremia 2:713844a55c4e 2 #define MBED_ILI9341_H
Geremia 2:713844a55c4e 3
Geremia 2:713844a55c4e 4
Geremia 2:713844a55c4e 5
Geremia 2:713844a55c4e 6 #include "mbed.h"
Geremia 2:713844a55c4e 7 #include "TFT.h"
Geremia 2:713844a55c4e 8
Geremia 2:713844a55c4e 9 /** Class for ILI9341 tft display controller
Geremia 2:713844a55c4e 10 * to be copypasted and adapted for other controllers
Geremia 2:713844a55c4e 11 */
Geremia 2:713844a55c4e 12 class ILI9341 : public TFT
Geremia 2:713844a55c4e 13 {
Geremia 2:713844a55c4e 14
Geremia 2:713844a55c4e 15 public:
Geremia 2:713844a55c4e 16
Geremia 2:713844a55c4e 17 /** Create a PAR display interface
Geremia 2:713844a55c4e 18 * @param displayproto only supports PAR_8
Geremia 2:713844a55c4e 19 * @param port GPIO port name to use
Geremia 2:713844a55c4e 20 * @param CS pin connected to CS of display
Geremia 2:713844a55c4e 21 * @param reset pin connected to RESET of display
Geremia 2:713844a55c4e 22 * @param DC pin connected to data/command of display
Geremia 2:713844a55c4e 23 * @param WR pin connected to SDI of display
Geremia 2:713844a55c4e 24 * @param RD pin connected to RS of display
Geremia 2:713844a55c4e 25 * @param name The name used by the parent class to access the interface
Geremia 2:713844a55c4e 26 */
Geremia 2:713844a55c4e 27 ILI9341(proto_t displayproto, PortName port, PinName CS, PinName reset, PinName DC, PinName WR, PinName RD, const char* name);
Geremia 2:713844a55c4e 28
Geremia 2:713844a55c4e 29 /** Create an SPI display interface
Geremia 2:713844a55c4e 30 * @param displayproto only supports SPI_8
Geremia 2:713844a55c4e 31 * @param Hz SPI speed in Hz
Geremia 2:713844a55c4e 32 * @param mosi SPI pin
Geremia 2:713844a55c4e 33 * @param miso SPI pin
Geremia 2:713844a55c4e 34 * @param sclk SPI pin
Geremia 2:713844a55c4e 35 * @param CS pin connected to CS of display
Geremia 2:713844a55c4e 36 * @param reset pin connected to RESET of display
Geremia 2:713844a55c4e 37 * @param DC pin connected to data/command of display
Geremia 2:713844a55c4e 38 * @param name The name used by the parent class to access the interface
Geremia 2:713844a55c4e 39 */
Geremia 2:713844a55c4e 40 ILI9341(proto_t displayproto, int Hz, PinName mosi, PinName miso, PinName sclk, PinName CS, PinName reset, PinName DC, const char* name);
Geremia 2:713844a55c4e 41
Geremia 2:713844a55c4e 42
Geremia 2:713844a55c4e 43
Geremia 2:713844a55c4e 44 protected:
Geremia 2:713844a55c4e 45
Geremia 2:713844a55c4e 46
Geremia 2:713844a55c4e 47 /** Init command sequence
Geremia 2:713844a55c4e 48 */
Geremia 2:713844a55c4e 49 void init();
Geremia 2:713844a55c4e 50
Geremia 2:713844a55c4e 51
Geremia 2:713844a55c4e 52
Geremia 2:713844a55c4e 53 };
Geremia 2:713844a55c4e 54 #endif