	
	//[i] memory m0;
	public memory m0
	{
		type = [uint16 0x0000, 0xFFFF] uint8;
	}
	//--------------------------------------------
	//[i] function_void OS_init;
	public void OS_init()
	{
		SDA_DIR = 1;
		SDA_OUT = 1;
		
		SCL_DIR = 1;
		SCL_OUT = 1;
	}
	//---------------------------------------------------
	public void set_uint32( uint16 addr16, uint32 data32 )
	{
		//WP_OUT = 0;
		addr16 << 2;
		set_uint8( addr16, data32.0(uint8) );
		set_uint8( addr16 + 1, data32.8(uint8) );
		set_uint8( addr16 + 2, data32.16(uint8) );
		set_uint8( addr16 + 3, data32.24(uint8) );
		//WP_OUT = 1;
	}
	//---------------------------------------------------
	public uint32 get_uint32( uint16 addr16 )
	{
		addr16 << 2;
		uint32 data = 0;
		data.0(uint8) = get_uint8( addr16 );
		data.8(uint8) = get_uint8( addr16 + 1 );
		data.16(uint8) = get_uint8( addr16 + 2 );
		data.24(uint8) = get_uint8( addr16 + 3 );
		return data;
	}
	//--------------------------------------------
	//向一个地址写入一个字节
	void set_uint8( uint16 addr, uint8 data )
	{
		start_iic();
		write_byte( 0xA0 );
		write_byte( addr.8(uint8) );
		write_byte( addr.0(uint8) );
		write_byte( data );
		end_iic();
		write_delay();
	}
	//从一个地址读取一个字节
	uint8 get_uint8( uint16 addr )
	{
		start_iic();
		write_byte( 0xA0 );
		write_byte( addr.8(uint8) );
		write_byte( addr.0(uint8) );
		end_iic();
		start_iic();
		write_byte( 0xA1 );
		uint8 data = read_byte();
		NoAck();
		end_iic();
		return data;
	}
	//---------------------------------------------------
	//开始IIC通信
	void start_iic()
	{
		SDA_OUT = 1;
		SCL_OUT = 1;
		delay_1us();
		SDA_OUT = 0;
		delay_1us();
		SCL_OUT = 0;
		delay_1us();
	}
	//结束IIC通信
	void end_iic()
	{
		SDA_OUT = 0;
		SCL_OUT = 1;
		delay_1us();
		SDA_OUT = 1;
		delay_1us();
		SCL_OUT = 1;
		delay_1us();
	}
	//等待应答信号
	void wait()
	{
		SDA_DIR = 0;
		SCL_OUT = 1;
		delay_1us();
		while( SDA_IN == 1 ) {}
		SCL_OUT = 0;
		delay_1us();
		SDA_DIR = 1;
	}
	//写一个字节
	void write_byte( uint8 data )
	{
		loop( 8 ) {
			SDA_OUT = data.7(bit);
			data << 1;
			delay_1us();
			SCL_OUT = 1;
			delay_1us();
			SCL_OUT = 0;
			delay_1us();
		}
		wait();
	}
	//读一个字节
	uint8 read_byte()
	{
		uint8 data;
		SDA_DIR = 0;
		loop( 8 ) {
			data << 1;
			data.0(bit) = SDA_IN;
			SCL_OUT = 1;
			delay_1us();
			SCL_OUT = 0;
			delay_1us();
		}
		SDA_DIR = 1;
		return data;
	}
	//发送非应答
	void NoAck()
	{
		//SDA_OUT = 0;		//应答
		SDA_OUT = 1;		//非应答
		delay_1us();
		SCL_OUT = 1;
		delay_1us();
		SCL_OUT = 0;
		delay_1us();
	}
	//---------------------------------------------------
	//写入等待延时
	void write_delay()
	{
		loop( 50000 ) {}
	}
	//延时1微秒
	void delay_1us()
	{
		loop( 2 ) {}
	}