ILI9340 Library based on the Arduino version from Adafruit. It has been tested with a custom STM32F103C8 board.

Using ILI9340 Library

Using the ILI9340 Adafruit based Library

It is very easy to use this library. The Adafruit_ILI9340 can be initialized with the following ways. NOTE: the following example was tested with a custom STM32F103C8 based board.

Initialization for software SPI

// Our pins
DigitalOut rst_pin(D0);
DigitalOut cs_pin(D1);
DigitalOut dc_pin(D7);
DigitalOut clk_pin(D13);
DigitalOut mosi_pin(D11);
DigitalIn  miso_pin(D12);

// Constructor for software SPI
Adafruit_ILI9340 myTFT(NULL);        

// These should be set in both cases (software or hardware SPI)
myTFT.setRST(&rst_pin);
myTFT.setCS(&cs_pin);
myTFT.setDC(&dc_pin);

// These are needed for software SPI
myTFT.setCLK(&clk_pin);
myTFT.setMISO(&miso_pin);
myTFT.setMOSI(&mosi_pin);
    
myTFT.begin();

and

Initialization for hardware SPI

// Our pins
DigitalOut rst_pin(D0);
DigitalOut cs_pin(D1);
DigitalOut dc_pin(D7);

// Our hardware SPI
SPI spi1(D11,D12,D13);

// Constructor for software SPI
Adafruit_ILI9340 myTFT(&spi1);        

// These should be set in both cases (software or hardware SPI)
myTFT.setRST(&rst_pin);
myTFT.setCS(&cs_pin);
myTFT.setDC(&dc_pin);
    
myTFT.begin();

Then the library functions can be used as usual

Using the library

    myTFT.fillRect(0,0,240,320,0);
    myTFT.fillRect(40,40,15,15,0xF000);

    myTFT.drawChar(30,100,'a',0x0F,0,2);
    myTFT.drawChar(40,100,'b',0x0F,0,2);
    myTFT.drawChar(50,100,'c',0x0F,0,2);  

All wikipages