spi driver for lcd interfacing

kamesh
Posts: 35
Joined: Sat Aug 06, 2016 5:14 am

spi driver for lcd interfacing

Postby kamesh » Sat Dec 03, 2016 9:10 am

Hi,


I would like to work on esp32 interface with lcd. Can anyone give me the updated driver for SPI.

ESP_Sprite
Posts: 9761
Joined: Thu Nov 26, 2015 4:08 am

Re: spi driver for lcd interfacing

Postby ESP_Sprite » Mon Dec 05, 2016 3:09 am

We do not have a mainstream SPI driver yet, sorry; we're working on one and it should appear in esp-idf quickly. If you want to experiment in the mean time, however, feel free to take a look at the LCD driver in the NES emulator code:
https://github.com/espressif/esp32-nese ... /spi_lcd.c

erhardd
Posts: 17
Joined: Mon Dec 05, 2016 9:16 am

Re: spi driver for lcd interfacing

Postby erhardd » Mon Dec 05, 2016 9:21 am


ESP_nilay
Posts: 4
Joined: Wed Dec 07, 2016 2:12 am

Re: spi driver for lcd interfacing

Postby ESP_nilay » Wed Dec 07, 2016 4:11 am

To add to that, we have written some codes for building a UI on ILI9341, and we can push the sample codes as soon as the SPI driver is out.

ESP_nilay
Posts: 4
Joined: Wed Dec 07, 2016 2:12 am

Re: spi driver for lcd interfacing

Postby ESP_nilay » Mon Dec 12, 2016 1:15 pm

Here's an example code for ILI9341 using the adafruit library & Sermus' compile of ILI9341 on ESP8266 found here : https://github.com/Sermus/ESP8266_Adafruit_ILI9341.

It's now using a finished SPI driver & it can be used for building a simple UI on the screen. It's based on the esp-idf official sdk, and you can directly run a make flash in the example folder attached with this reply. It's yet to be merged, hence the attachment.
Attachments
ili9341_ui.rar
(100.45 KiB) Downloaded 1129 times
Last edited by ESP_nilay on Wed Jan 25, 2017 6:54 am, edited 2 times in total.

ESP_Greg

Re: spi driver for lcd interfacing

Postby ESP_Greg » Tue Dec 13, 2016 7:20 am

Hi Nilay,
Thank you for your sharing.
I download this firmware to ESP_wrover, but no response. Is it supposed to run on ESP_wrover? Or I should use another board?

User avatar
rudi ;-)
Posts: 1729
Joined: Fri Nov 13, 2015 3:25 pm

Re: spi driver for lcd interfacing

Postby rudi ;-) » Tue Dec 13, 2016 11:33 am

ESP_Greg wrote:Hi Nilay,
Thank you for your sharing.
I download this firmware to ESP_wrover, but no response. Is it supposed to run on ESP_wrover? Or I should use another board?
hi ESP_Greg,
cause i get last days one of the fantastic ESP-WRover Kits from Santa Claus
https://twitter.com/eMbeddedHome/status ... 8278486016

( test on DevKitC )
https://twitter.com/eMbeddedHome/status ... 6283441152

i can test and help you ;-) ( thanks @espressif )

no sure what fail in your ESP_WRover ;-)

first, see the shema of the ESP_WRover Board
shema_.png
shema_.png (45.38 KiB) Viewed 24765 times

then change the code in the Header File "Adafruit_ILI9341_fast_as.h"
to the ESP_WRover Kit Shema:

DC Data ( Gpio 21 on Wrover )
Backlight BKL ( GPIO 5 on Wrover and swap 0,1 )
RST Pin ( GPIO 18 on WRover )

Code: Select all

// orig
// #define TFT_DC_DATA     GPIO_OUTPUT_SET(25, 1)
// #define TFT_DC_COMMAND  GPIO_OUTPUT_SET(25, 0)
// #define TFT_DC_INIT     PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO25_U, FUNC_GPIO25_GPIO25); TFT_DC_DATA

/* changed rudi */
#define TFT_DC_DATA     GPIO_OUTPUT_SET(21, 1)
#define TFT_DC_COMMAND  GPIO_OUTPUT_SET(21, 0)
#define TFT_DC_INIT     PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO21_U, FUNC_GPIO21_GPIO21); TFT_DC_DATA

// orig
// #define TFT_BKL_INIT    gpio_set_direction(GPIO_NUM_16,GPIO_MODE_OUTPUT);TFT_BKL_ON 
// #define TFT_BKL_ON      gpio_set_level(GPIO_NUM_16,1)
// #define TFT_BKL_OFF     gpio_set_level(GPIO_NUM_16,0)

/* changed rudi */
#define TFT_BKL_INIT    gpio_set_direction(GPIO_NUM_5,GPIO_MODE_OUTPUT);TFT_BKL_ON 
#define TFT_BKL_ON      gpio_set_level(GPIO_NUM_5,0)     // Important - here was 0,1 swap so your screen is now light 
#define TFT_BKL_OFF     gpio_set_level(GPIO_NUM_5,1)    // Important - here was 0,1 swap so your screen is now light

//  orig
// #define TFT_RST_ACTIVE    GPIO_OUTPUT_SET(17, 0)
// #define TFT_RST_DEACTIVE  GPIO_OUTPUT_SET(17, 1)
// #define TFT_RST_INIT      PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO17_U, FUNC_GPIO17_GPIO17); TFT_RST_DEACTIVE

/* changed rudi */
#define TFT_RST_ACTIVE    GPIO_OUTPUT_SET(18, 0)
#define TFT_RST_DEACTIVE  GPIO_OUTPUT_SET(18, 1)
#define TFT_RST_INIT      PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO18_U, FUNC_GPIO18_GPIO18); TFT_RST_DEACTIVE


next step: driver hspi.c
change the Pins for HSPI like ESP-WRover used the pins for HSPI

Code: Select all


void hspi_init(void)
{
    /*GPIO Inits according to Dev board for ILI9341*/
    spi_fifo = (uint32_t*)SPI_W0_REG(HSPI); //needed?


	// orig
    // PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO19_U, 2);  
    // PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO23_U, 2);  
    // PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO18_U, 2);  
    // PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO5_U, 2);   
           
	/* changed rudi */
    PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO25_U, 2);  //MISO GPIO19 // -> 25
    PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO23_U, 2);  //MOSI GPIO23 // -> 23
    PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO19_U, 2);  //CLK GPIO18  // -> 19
    PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO22_U, 2);   //CS GPIO5   // -> 22
    
    // orig
    //  gpio_matrix_in(GPIO_NUM_19, HSPIQ_IN_IDX,0);
    //  gpio_matrix_out(GPIO_NUM_23, HSPID_OUT_IDX,0,0);
    //  gpio_matrix_out(GPIO_NUM_18, HSPICLK_OUT_IDX,0,0);
    
     /* changed rudi */
    gpio_matrix_in(GPIO_NUM_25, HSPIQ_IN_IDX,0);
    gpio_matrix_out(GPIO_NUM_23, HSPID_OUT_IDX,0,0);
    gpio_matrix_out(GPIO_NUM_19, HSPICLK_OUT_IDX,0,0);
    
	// orig
	// gpio_matrix_out(GPIO_NUM_5, HSPICS0_OUT_IDX,0,0);
    
	/* changed rudi */
	gpio_matrix_out(GPIO_NUM_22, HSPICS0_OUT_IDX,0,0);
    

    spi_attr_t hSpiAttr;
    hSpiAttr.mode     = SpiMode_Master;
    hSpiAttr.subMode  = SpiSubMode_0;
    hSpiAttr.speed    = SpiSpeed_20MHz;
    hSpiAttr.bitOrder = SpiBitOrder_MSBFirst;
    hSpiAttr.halfMode = SpiWorkMode_Half;
    spi_init(HSPI, &hSpiAttr);

}

next step:

dump your Firmware from ESP-WRover before you flash with new firmware
flash your ESP-WRover with the example and smile ;-)
ESP_WRover_Nilay_HSPI_.png
ESP_WRover_Nilay_HSPI_.png (758.33 KiB) Viewed 24765 times
@ESP-Nilay
thank you. good work! honest good work
two things for proposal:
-> make pins as user friendly define and use menuconfig for the PINS example
see blink example how user can set gpio in menuconfig

-> more from you ;-) ( great worker! )
btw: You are a candidate for "ESP_ " cause your Member start with "ESP_ "
like your work - good candidate :mrgreen:


hope this helps :)
thanks again for ESP_WRover Kit espressif!

best wishes
rudi ;-)
-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪

ESP_Greg

Re: spi driver for lcd interfacing

Postby ESP_Greg » Wed Dec 14, 2016 3:09 am

rudi, thanks!~~~

I'm just rookie on ESP32. I will keep working on that~~~~~~ :D

ESP_Sprite
Posts: 9761
Joined: Thu Nov 26, 2015 4:08 am

Re: spi driver for lcd interfacing

Postby ESP_Sprite » Thu Dec 15, 2016 1:38 am

Fyi, do keep in mind that that SPI driver is preliminary. We're working on a different one which is probably going to have an entirely different API, but which should make it possible to easily talk to different devices on the SPI-bus from different parts of the program.

sermus
Posts: 2
Joined: Sun Dec 13, 2015 4:06 am

Re: spi driver for lcd interfacing

Postby sermus » Sun Dec 18, 2016 12:22 pm

ESP_nilay wrote:Here's a driver & example code for ILI9341 using the adafruit library.
Nice to see my code is in demand. Sad to see the credits are lost.

Who is online

Users browsing this forum: No registered users and 9 guests