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:
trevieze
Date:
Fri Aug 04 19:47:21 2017 +0000
Revision:
36:0ced7cf0ec8c
Parent:
18:ffa58f1a680a
Child:
21:ae0a4eedfc90
Added Gimp Graphic Display Routine for Compass

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 18:ffa58f1a680a 18 * @param displayproto PAR_8 or PAR_16
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
dreschpe 9:1749ae993cfe 26 * @param LCDSIZE_X x size in pixel - optional
dreschpe 9:1749ae993cfe 27 * @param LCDSIZE_Y y size in pixel - optional
Geremia 2:713844a55c4e 28 */
dreschpe 9:1749ae993cfe 29 //ILI9341(proto_t displayproto, PortName port, PinName CS, PinName reset, PinName DC, PinName WR, PinName RD, const char* name);
dreschpe 9:1749ae993cfe 30 ILI9341(proto_t displayproto, PortName port, PinName CS, PinName reset, PinName DC, PinName WR, PinName RD, const char* name ,const unsigned int LCDSIZE_X = 240, unsigned int LCDSIZE_Y = 320);
Geremia 2:713844a55c4e 31
Geremia 2:713844a55c4e 32 /** Create an SPI display interface
Geremia 18:ffa58f1a680a 33 * @param displayproto SPI_8 or SPI_16
Geremia 2:713844a55c4e 34 * @param Hz SPI speed in Hz
Geremia 2:713844a55c4e 35 * @param mosi SPI pin
Geremia 2:713844a55c4e 36 * @param miso SPI pin
Geremia 2:713844a55c4e 37 * @param sclk SPI pin
Geremia 2:713844a55c4e 38 * @param CS pin connected to CS of display
Geremia 2:713844a55c4e 39 * @param reset pin connected to RESET of display
Geremia 2:713844a55c4e 40 * @param DC pin connected to data/command of display
Geremia 2:713844a55c4e 41 * @param name The name used by the parent class to access the interface
dreschpe 9:1749ae993cfe 42 * @param LCDSIZE_X x size in pixel - optional
dreschpe 9:1749ae993cfe 43 * @param LCDSIZE_Y y size in pixel - optional
Geremia 2:713844a55c4e 44 */
dreschpe 9:1749ae993cfe 45 //ILI9341(proto_t displayproto, int Hz, PinName mosi, PinName miso, PinName sclk, PinName CS, PinName reset, PinName DC, const char* name);
dreschpe 9:1749ae993cfe 46 ILI9341(proto_t displayproto, int Hz, PinName mosi, PinName miso, PinName sclk, PinName CS, PinName reset, PinName DC, const char* name ,unsigned int LCDSIZE_X = 240, unsigned int LCDSIZE_Y = 320);
Geremia 2:713844a55c4e 47
Geremia 2:713844a55c4e 48
Geremia 2:713844a55c4e 49
Geremia 2:713844a55c4e 50 protected:
Geremia 2:713844a55c4e 51
Geremia 2:713844a55c4e 52
Geremia 2:713844a55c4e 53 /** Init command sequence
Geremia 2:713844a55c4e 54 */
Geremia 2:713844a55c4e 55 void init();
Geremia 2:713844a55c4e 56
Geremia 2:713844a55c4e 57
Geremia 2:713844a55c4e 58
Geremia 2:713844a55c4e 59 };
Geremia 2:713844a55c4e 60 #endif