简体   繁体   English

共享用于Flash和TFT LCD的SPI硬件的问题

[英]Issue with sharing SPI hardware for flash and tft LCD

I am using TFT LCD screen (ILI9163c) which is connected with athros AR9331 module with spi pins. 我正在使用TFT LCD屏幕(ILI9163c),该屏幕通过spi引脚与athros AR9331模块连接。 Athros AR9331 is running with OpenWRT linux distribution. Athros AR9331与OpenWRT linux发行版一起运行。 So, I am driving my LCD with spidev0.1 using my C application code. 因此,我正在使用C应用程序代码使用spidev0.1驱动LCD。

Athros AR9331 board is using same SPI pins for driving flash memory on board, which is handled from kernel. Athros AR9331板使用相同的SPI引脚来驱动板上的闪存,该闪存由内核处理。

I have separate chip select pin for LCD to give proper data recognizance for LCD by making it low and high from code, but still sometimes LCD screen affected with garbage when some data transferred (using other script or application) on flash while LCD printing is on going from my code. 我为LCD设置了单独的芯片选择引脚,通过将其设置为高电平和低电平来为LCD提供适当的数据识别,但是当LCD打印处于打开状态时,当某些数据通过闪存传输(使用其他脚本或应用程序)传输时,有时LCD屏幕受垃圾影响。从我的代码。

I have control on LCD chip select from code but not for flash. 我可以控制LCD芯片从代码中选择,但不能控制闪光灯。 so in this case what should i do to handle a situation when operation for both flash and LCD is going parallel. 所以在这种情况下,当闪光灯和LCD的操作并行进行时,我该怎么办?

This is my function code for sending data on LCD using SPIdev0.1. 这是我使用SPIdev0.1在LCD上发送数据的功能代码。

    void spi_transactor(unsigned int wlength,
                        unsigned int rlength,
                        const unsigned char write_data,
                        int mode)
    {
       int ret;
       struct spi_ioc_transfer xfer[4];
       unsigned char init_reg[1];

       init_reg[0] = write_data;

       if (mode)
       {
          gpio_set_value(_rs, 1);  // DATA 
       }
       else
       {
          gpio_set_value(_rs, 0);  // COMMAND
       }

       memset(xfer, 0, sizeof xfer);

       xfer[0].bits_per_word = 8;
       xfer[0].tx_buf = (unsigned long) &init_reg[0];
       xfer[0].rx_buf = 0;                        //( unsigned long ) &buf_rx[0];
       xfer[0].len = wlength + rlength;
       xfer[0].delay_usecs = 0;
       xfer[0].speed_hz = speedx;               
       //xfer[0].speed_hz = 40000000;            // 40MHZ

 gpio_set_value(_CS, 0);          // SET ChipSELECT LOW    
       ret = ioctl(spi_fd, SPI_IOC_MESSAGE(1), &xfer);     
 gpio_set_value(_CS, 1);          // SET ChipSELECT HIGH 

       (void) ret;
       //DEBUG_PRINT("%d\n",ret);
       //if (ret <= 0) ; 
       //DEBUG_PRINT("ERROR: %s\n", strerror(errno));

    }

i think it can be possible if we can configure my gpio as Chipselect in spidev0.1 driver in kernel... But how i can configure gpio as chipselect in kernel ? 我认为如果可以在内核的spidev0.1驱动程序中将我的gpio配置为Chipselect是可能的...但是我如何在内核中将gpio配置为Chipselect呢?

i found something similar to this, here... 我在这里找到了类似的东西...

openWRT custom chipselect GPIO openWRT定制芯片选择GPIO

just registered general GPIO-pin as CS1 for LCD from spi driver and finally i solved my issue. 刚刚从spi驱动程序将通用GPIO引脚注册为LCD的CS1,最后我解决了我的问题。

Thank you @AK , @user694733 谢谢@AK,@ user694733

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM