示例#1
0
static void td043_spi_wr(__u32 sel,__u32 addr,__u32 value)
{
	__u32 i;
	__u32 data = (addr<<10 | value);
	td043_spi_scen(sel,1);
	td043_spi_scl(sel,0);
	td043_spi_scen(sel,0); 
	for(i=0;i<16;i++)
	{
		if(data & 0x8000)
			td043_spi_sda(sel,1);
		else
			td043_spi_sda(sel,0);
		data <<= 1;
		LCD_delay_us(10);
		td043_spi_scl(sel,1);
		LCD_delay_us(10);
		td043_spi_scl(sel,0);	
	}
	td043_spi_scen(sel,1); 
}
示例#2
0
void td043_spi_wr(__u8 Addr, __u8 Data)
{
	int i;

	LCD_delay_us(8);

	td043_spi_scen(1);//CS_SET();
	td043_spi_sda(1);//TXD_SET();
	td043_spi_scl(1);//CLK_SET();
	//DRVDelayUs(2);
	LCD_delay_us(4);

	td043_spi_scen(0);//CS_CLR();
	for(i = 0; i < 6; i++)  //reg
	{
		if(Addr &(1<<(5-i)))
			td043_spi_sda(1);//TXD_SET();
		else
			td043_spi_sda(0);//TXD_CLR();

		// 模拟CLK
		td043_spi_scl(0);//CLK_CLR();
		LCD_delay_us(8);
		td043_spi_scl(1);//CLK_SET();
		//DRVDelayUs(4);
		LCD_delay_us(8);
	}

	td043_spi_sda(0);//TXD_CLR();  //write

	// 模拟CLK
	td043_spi_scl(0);//CLK_CLR();
	//DRVDelayUs(4);
	LCD_delay_us(8);
	td043_spi_scl(1);//CLK_SET();
	//DRVDelayUs(4);
	LCD_delay_us(8);

	td043_spi_sda(1);//TXD_SET();  //highz

	// 模拟CLK
	td043_spi_scl(0);//CLK_CLR();
	// DRVDelayUs(4);
	LCD_delay_us(8);
	td043_spi_scl(1);//CLK_SET();
	//DRVDelayUs(4);
	LCD_delay_us(8);

      
	for(i = 0; i < 8; i++)  //data
	{
		if(Data &(1<<(7-i)))
			td043_spi_sda(1);//TXD_SET();
		else
			td043_spi_sda(0);//TXD_CLR();

		// 模拟CLK
		td043_spi_scl(0);//CLK_CLR();
		//DRVDelayUs(4);
		LCD_delay_us(8);
		td043_spi_scl(1);//CLK_SET();
		//DRVDelayUs(4);
		LCD_delay_us(8);
	}

	td043_spi_scen(1);//CS_SET();
	td043_spi_scl(0);//CLK_CLR();
	td043_spi_sda(0);//TXD_CLR();
	//DRVDelayUs(2);
	LCD_delay_us(500);

}