AnsweredAssumed Answered

How to send 8-bit address and 8-bit data through spi write function in linux

Question asked by sandesh gowda on Feb 11, 2014

1)  In my lcd driver i am sending address and data to the lcd panel through spi write function.

 

2)  when i probe the MOSI signal i diidn't get data from the signal

 

               I copied code below,  please let me know is it right or wrong

 

 

//////////////////////////////////////////////////////////////////////////////////

 

static const struct {

        unsigned char addr;

        unsigned char data;

} tftcluster_spi_init_seq[] = {

                          {0x00,0x07}, {0x01,0x00}, {0x02,0x03}, {0x03,0xCC}, {0x04,0x46}, {0x05,0x0D}, {0x06,0x00}, {0x07,0x00}, {0x08,0x08}, {0x09,0x40}, {0x0A,0x88}, {0x0B,0x88}, {0x0C,0x20}, {0x0D,0x20}, {0x0E,0x10}, {0x0F,0xA4}, {0x10,0x04}, {0x11,0x24}, {0x12,0x24}, {0x1E,0x00}, {0x20,0x00},

};

 

 

static int tftcluster_spi_send(struct spi_device *spi, unsigned char reg_addr,

                        unsigned char reg_data)

{

        int ret = 0;

        unsigned int cmd = 0, data = 0, data1 = 0;

 

        cmd = 0x0000 | reg_addr; /* register address write */

        data1 = 0x0000 | reg_data ; /* register data write */

        data = (data1 << 8) | cmd;

    

       printk("\nAddr: %x  Data: %x Write_Data: %x \n",cmd, data1, data);

 

        ret = spi_write(spi, (unsigned char *)&data, 2);

        if (ret)

                pr_err("error in spi_write %x\n", data);

                    

        return ret; 

}           

 

Message was edited by: sandesh gowda

Outcomes