Exemplo n.º 1
0
void i2cREAD(void)
{
    register __u8 i ;
    __u8  value = 0;

    IIC_SDAB_INPUT_SETUP();

    //__inf("-------------IIC_Read_data-----------------\n");
    for ( i=0 ; i<8 ; i++ )
	{
        value = value << 1;

        //i2cB_clock() ;
        LCD_delay_us(15) ;
        IIC_SCLB_HIGH();
        LCD_delay_us(10) ;
        IIC_SCLB_LOW();
        LCD_delay_us(10) ;

        LCD_delay_us(10) ;

        if(CHECK_SDAB_HIGH())
            value = value + 1;
    }

	//__inf("-------------read ok----------\n");
	i2cB_ack();
	i2cBStop();

}
Exemplo n.º 2
0
static __bool i2cB_ack(void)
{
	IIC_SCLB_HIGH();
	IIC_SDAB_INPUT_SETUP();
	LCD_delay_us(5);
	LCD_delay_us(5);
	if(CHECK_SDAB_HIGH())
	{
		LCD_delay_us(5) ;
		IIC_SDAB_OUTPUT_SETUP();
		LCD_delay_us(5) ;
		IIC_SCLB_LOW();
		LCD_delay_us(5) ;
		IIC_SDAB_HIGH();
		LCD_delay_us(5) ;
		return(1);
	}
	else
	{
		LCD_delay_us(5) ;
		IIC_SDAB_OUTPUT_SETUP();
		LCD_delay_us(5) ;
		IIC_SCLB_LOW();
		LCD_delay_us(5) ;
		IIC_SDAB_HIGH();
		LCD_delay_us(5) ;
		return(0);
	}
}
Exemplo n.º 3
0
//---------------------------------------------------------
static void i2cBStartA( void )
{
	IIC_SCLB_HIGH();
	IIC_SDAB_HIGH();
	LCD_delay_us(10) ;
	IIC_SDAB_LOW();
	LCD_delay_us(10) ;
	IIC_SCLB_LOW();
}
Exemplo n.º 4
0
static void i2cBStop(void)
{
   IIC_SDAB_OUTPUT_SETUP();
   IIC_SDAB_LOW();
   LCD_delay_us(5) ;
   IIC_SCLB_HIGH();
   LCD_delay_us(5) ;
   IIC_SDAB_HIGH();
   LCD_delay_us(5) ;
}
Exemplo n.º 5
0
static __bool i2cB_clock( void )
{
	__bool sample = 0;

	IIC_SCLB_HIGH();
	LCD_delay_us(10) ;
	IIC_SCLB_LOW();
	LCD_delay_us(10) ;
	return ( sample ) ;
}
Exemplo n.º 6
0
void LCD_Clear(void)
{
  LCD_PtS(LCD_CMD_CLEAR );
  LCD_com(); 
  //delay(2);
  LCD_delay_us(delay_t<<1);
}
Exemplo n.º 7
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); 
}
Exemplo n.º 8
0
static void spi_24bit_3wire(__u32 tx)
{
	__u8 i;

	spi_csx_set(0);

	for(i=0;i<24;i++)
	{
		LCD_delay_us(1);
		spi_sck_set(0);
		LCD_delay_us(1);
		if(tx & 0x800000)
			spi_sdi_set(1);
		else
			spi_sdi_set(0);
		LCD_delay_us(1);
		spi_sck_set(1);
		LCD_delay_us(1);
		tx <<= 1;
	}
	spi_sdi_set(1);
	LCD_delay_us(1);
	spi_csx_set(1);
	LCD_delay_us(3);
}
Exemplo n.º 9
0
static __bool i2cBTransmit(__u8 value)
{
	register __u8 i ;
	IIC_SDAB_OUTPUT_SETUP();
	LCD_delay_us(5) ;
	for ( i=0 ; i<8 ; i++ )
	{
		if((value&0x80)==0x80)
		{
			IIC_SDAB_HIGH();
			//__inf("//////// DATA-1  //////\n");
		}
		else
		{
			IIC_SDAB_LOW();
			//__inf("//////// DATA-0  //////\n");
		}
		value = value << 1 ;
		LCD_delay_us(10) ;
		i2cB_clock() ;

	}
	return(!i2cB_ack());
}
Exemplo n.º 10
0
static __bool i2cBStart( void )
{
	IIC_SDAB_HIGH();
	IIC_SCLB_HIGH();
	LCD_delay_us(10) ;
	IIC_SDAB_INPUT_SETUP();
	if(CHECK_SDAB_HIGH())
	{
		IIC_SDAB_OUTPUT_SETUP();
		{
			i2cBStartA();
			return(1);
		}
	}
	return(0);
}
Exemplo n.º 11
0
static __bool i2cBTransmitSubAddr(__u8 value)
{
	register __u8 i ;

	for ( i=0 ; i<8 ; i++ )
	{
		if((value&0x80)==0x80)
		{
			IIC_SDAB_HIGH();
		}
		else
		{
			IIC_SDAB_LOW();
		}
		value = value << 1 ;
		LCD_delay_us(10) ;
		i2cB_clock() ;
	}
	return(!i2cB_ack());
}
Exemplo n.º 12
0
void LCD_PtS(unsigned char data)
{
	int i = 0;
	GPIO_Set(LCD_CLK_PIN,0);
	
	while (i <= 7)
	{
		if (data & 0x80)	      // LOW BIT
		{
			GPIO_Set(LCD_DATA_PIN,1);
		}
		else			// HIGH BIT
		{
			GPIO_Set(LCD_DATA_PIN,0);
		}
		data = data << 1;
		
		GPIO_Set(LCD_CLK_PIN,1);
		LCD_delay_us(delay_t);
		GPIO_Set(LCD_CLK_PIN,0);
		i++;
	}
}
Exemplo n.º 13
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);

}