i2c_dev.pas

来自「pipe类 pipe类 pipe类 pipe类 pipe类」· PAS 代码 · 共 77 行

PAS
77
字号
unit i2c_dev;

interface

uses SysUtils;

const
  //smbus_access read or write markers
  I2C_SMBUS_READ = 1;  I2C_SMBUS_WRITE	= 0;  //SMBus transaction types (size parameter in the above functions)  //Note: these no longer correspond to the (arbitrary) PIIX4 internal codes!  I2C_SMBUS_QUICK               = 0;  I2C_SMBUS_BYTE                = 1;  I2C_SMBUS_BYTE_DATA           = 2;  I2C_SMBUS_WORD_DATA           = 3;  I2C_SMBUS_PROC_CALL           = 4;  I2C_SMBUS_BLOCK_DATA          = 5;  I2C_SMBUS_I2C_BLOCK_DATA      = 6;  I2C_SMBUS_BLOCK_PROC_CALL     = 7;	//SMBus 2.0  I2C_SMBUS_BLOCK_DATA_PEC      = 8;	//SMBus 2.0  I2C_SMBUS_PROC_CALL_PEC       = 9;	//SMBus 2.0  I2C_SMBUS_BLOCK_PROC_CALL_PEC = 10;	//SMBus 2.0  I2C_SMBUS_WORD_DATA_PEC	      = 11;	//SMBus 2.0

  //commands for the ioctl like i2c_command call:
  //note that additional calls are defined in the algorithm and hw  //dependent layers - these can be listed here, or see the  //corresponding header files.  //bit-adapter specific ioctls  I2C_RETRIES	= $0701;	//number of times a device address	//should be polled when not acknowledging  I2C_TIMEOUT	= $0702;	//set timeout - call with int  //this is for i2c-dev.c  I2C_SLAVE	      = $0703; //Change slave address	//Attn.: Slave address is 7 or 10 bits  I2C_SLAVE_FORCE	= $0706; //Change slave address	//Attn.: Slave address is 7 or 10 bits	//This changes the address, even if it  //is already taken!  I2C_TENBIT    = $0704;	//0 for 7 bit addrs, != 0 for 10 bit  I2C_FUNCS	    = $0705;  //Get the adapter functionality  I2C_RDWR      = $0707;	//Combined R/W transfer (one stop only)  I2C_PEC	      =	$0708;  //	!= 0 for SMBus PEC  I2C_ACK_TEST  = $0710;	//See if a slave is at a specific address  I2C_SMBUS	    = $0720;  //SMBus-level access  //flags for the driver struct:  I2C_DF_NOTIFY	= $01;	//notify on bus (de/a)ttaches  I2C_DF_DUMMY	= $02;	//do not connect any clients  //flags for the client struct:  I2C_CLIENT_ALLOW_USE = $01; //Client allows access  I2C_CLIENT_ALLOW_MULTIPLE_USE = $02; //Allow multiple access-locks	//on an i2c_client  I2C_CLIENT_PEC = $04; //Use Packet Error Checking  I2C_CLIENT_TEN =	$10; //we have a ten bit chip addressprocedure i2c_delay(timeout: Word);
implementation

procedure i2c_delay(timeout: Word);
var
  i: Word;
begin
  for i:=1 to timeout do
    sleep(0);
end;

end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?