
unit TSL2561
{
	public link unit SDA {}
	public link unit SCL {}
	
	I2C.SDA = SDA;
	I2C.SCL = SCL;
	I2C =
	#include <system\common\I2C\driver.txt>
	
	const uint8 DeviceAddr = 0B0111_0010;
	
	//--------------------------------------------
	//[i] function_void OS_init;
	public void OS_init()
	{
		I2C.Init();
		I2C.A1_set_uint8( DeviceAddr, 0x80, 0x03 );
		I2C.A1_set_uint8( DeviceAddr, 0x81, 0x00 );
		I2C.A1_set_uint8( DeviceAddr, 0x86, 0x00 );
	}
	//---------------------------------------------------
	//[i] function_int32 get_channel0;
	public int32 get_channel0()
	{
		I2C.A1_get_byte2( DeviceAddr, 0x8C );
		uint16 data1;
		data1.0(uint8) = I2C.byte0;
		data1.8(uint8) = I2C.byte1;
		return (int)data1;
	}
	//---------------------------------------------------
	//[i] function_int32 get_channel1;
	public int32 get_channel1()
	{
		I2C.A1_get_byte2( DeviceAddr, 0x8E );
		uint16 data1;
		data1.0(uint8) = I2C.byte0;
		data1.8(uint8) = I2C.byte1;
		return (int)data1;
	}
}







