dnx RTOS forum

Drivers => New drivers => Topic started by: suyog44 on March 08, 2018, 05:17:10 AM

Title: LCD TFT 320*240 ili9341 driver development SPI interface
Post by: suyog44 on March 08, 2018, 05:17:10 AM
Hello Sir,
I am using dnx rtos on stm32f4 discovery board it has tft lcd 320*240 based ili9341 driver. I wish to display the OS on tft screen. Can you give any hint how i start the the development. :)
Title: Re: LCD TFT 320*240 ili9341 driver development SPI interface
Post by: Daniel on March 19, 2018, 07:28:29 PM
Hi!
To use ILI9341 I'll prefer to create SPI node device and create new library rather than creating new low level driver. In this case please create in the 'initd' program a SPI device node as following:

Code: [Select]
        // SPI1 initialization - make sure that you are using SPI1
        driver_init("SPI", 0, 0, "/dev/screen");
        f = fopen("/dev/screen", "r+");
        if (f) {
                static const SPI_config_t spi_cfg = {
                        .flush_byte  = 0x00,
                        .clk_divider = SPI_CLK_DIV__128,
                        .mode        = SPI_MODE__0, 
                        .msb_first   = true,
                        .CS_port_idx = IOCTL_GPIO_PORT_IDX__LCD_CS,  // pin should be defined in configtool
                        .CS_pin_idx  = IOCTL_GPIO_PIN_IDX__LCD_CS,  // pin should be defined in configtool
                };
                ioctl(fileno(f), IOCTL_SPI__SET_CONFIGURATION, &spi_cfg);
                fclose(f);
        }

You can put this code in initialize_additional_drivers() function at ./src/application/programs/initd/initd.c.

Next you can create a new library in ./src/application/libs/ili9341 directory or just create a new program that handle screen. To send a data through SPI interface just open created in the 'initd' SPI device (/dev/screen) and use fwrite()/fread()/ioctl() functions to send specific data. You can take a look to documentation http://www.dnx-rtos.org/doxygen/index.html (http://www.dnx-rtos.org/doxygen/index.html), there are examples how to handle SPI devices.