
	I2C.SDA = SDA;
	I2C.SCL = SCL;
	I2C =
	#include <system\common\I2C\driver.txt>
	
	const uint8 DeviceAddr = 0xC0;
	
	const uint8 PCA9685_MODE1 = 0x00;
	const uint8 PCA9685_PRESCALE = 0xFE;
	
	const uint8 LED0_ON_L = 0x06;
	const uint8 LED0_ON_H = 0x07;
	const uint8 LED0_OFF_L = 0x08;
	const uint8 LED0_OFF_H = 0x09;
	
	
	//--------------------------------------------
	//[i] function_void OS_init;
	public void OS_init()
	{
		I2C.Init();
		
		loop( 200 ) loop( 200 ) {}
		
		I2C.A1_set_uint8( DeviceAddr, PCA9685_MODE1, 0 );
		
		SetFreq( 50 );
	}
	
	//[i] function_void write int32 int32;
	public void write( int32 c, int32 d )
	{
		if( c < 0 || c > 15 ) {
			return;
		}
		if( d < 0 ) {
			d = 0;
		}
		uint8 cc = 4 * (uint8)(uint16)(uint)c;
		
		if( d > 4095 ) {
			d = 4095;
		}
		uint16 dd = (uint16)(uint)d;
		
		
		I2C.A1_set_uint8( DeviceAddr, LED0_ON_L + cc, 0 );
		I2C.A1_set_uint8( DeviceAddr, LED0_ON_H + cc, 0 );
		
		I2C.A1_set_uint8( DeviceAddr, LED0_OFF_L + cc, dd.0(uint8) );
		I2C.A1_set_uint8( DeviceAddr, LED0_OFF_H + cc, dd.8(uint8) );
	}
	
	//ÉèÖÃÆµÂÊ
	void SetFreq( int32 f )
	{
		f = f * 92 / 100;  // Correct for overshoot in the frequency setting 
		int32 prescaleval = 25000000;
		prescaleval /= 4096;
		prescaleval /= f;
		prescaleval -= 1;
		uint8 p = (uint8)(uint16)(uint)prescaleval;
		
		uint8 oldmode = I2C.A1_get_uint8( DeviceAddr, PCA9685_MODE1 );
		uint8 newmode = ( oldmode & 0x7F ) | 0x10; // sleep
		I2C.A1_set_uint8( DeviceAddr, PCA9685_MODE1, newmode ); // go to sleep
		I2C.A1_set_uint8( DeviceAddr, PCA9685_PRESCALE, p ); // set the prescaler
		I2C.A1_set_uint8( DeviceAddr, PCA9685_MODE1, oldmode );
		loop( 100 ) loop( 100 ) {}
		I2C.A1_set_uint8( DeviceAddr, PCA9685_MODE1, oldmode | 0xa1 ); 
	}
	
	
	
	