b0VIM 8.1£:¢`¢|piFPC~pi/FPCTracker/test_spi.pasutf-8
U3210#"! UtpˇóˇˇˇˇHöad°≈Òﬁ≈‰ﬂ¿øπ™©î~}L€©ÄuZQ70/)Ï
Î
—
∞
è
g
f
O
6
!


¯„‚∑∂†poJ%˚—£uHﬁ
°
v
X
5



œ	∞	Ä	W	1	
	ÈÃº¨õ}|xk43$#¯ÙÊ”Õ«tsT;˛Âîv+Ã√π∏±¨´üûÖbLE@?,+˜Ò‘´§üûäâQK.˚ˆı€⁄úògIC,Ï …≠ãä    FillByte (inbuf [0], len, 0);    SetLength (inbuf, len);    Move (dout, outbuf [0], len);    FillByte (outbuf [0], len, 0);    SetLength (outbuf, len);  if len> 0 then beginbegin  transfer: spi_ioc_transfer;  inbuf: array of byte;  outbuf: array of byte;varprocedure Tspi.TransferSync (const dout; var din; len: byte);// Send, receive SPI dataend;  end;    DataOut: = FpWrite (spihnd, dout, cnt);  if spihnd <> -1 then beginbeginfunction Tspi.DataOut (const dout; cnt: byte): integer;// SPI Buffer Writeend;  end;    DataIn: = FpRead (spihnd, din, cnt);  if spihnd <> -1 then beginbeginfunction Tspi.DataIn (var din; cnt: byte): integer;// SPI Buffer Readend;  end;    FpClose (spihnd);  if spihnd <> -1 then beginbeginprocedure Tspi.Close ();// exit SPIend;  end;  finally    end;      FpIOCtl (spihnd, cSPI_WR_MAX_SPEED_HZ, @ val32); // set speed      val32: = cSPI_SPEED;      FpIOCtl (spihnd, cSPI_WR_LSB_FIRST, @ val8); // Set MSB or LSB first      val8: = cSPI_LSBF; //-1      FpIOCtl (spihnd, cSPI_WR_BITS_PER_WORD, @ val8); // set data bits per byte      val8: = cSPI_BITS;      FpIOCtl (spihnd, cSPI_WR_MODE, @ val8); // set fashion      val8: = cSPI_MODE;    if spihnd <> -1 then begin    spihnd: = FpOpen (cSPI_DEVICE, O_RdWr); // Open the interface for read / write  trybegin  val32: longword;  val8: byte;varprocedure Tspi.Init ();// initialize SPIimplementation  spihnd: longint; // the filehandle for the interface  spi: Tspi;var  end; // a total of 32 bytes    pad: uint16;    rxn: uint8;    txn: uint8;    csc: uint8; // CS change    bpw: uint8; // bits per word    delay: uint16; // delay CS in usec    speed: uint32; // data rate in Hz    len: uint32; // Number of characters    rx_buf: uint64; //pointer; // always 64-bit    tx_buf: uint64; //pointer;  spi_ioc_transfer = record // Control register required for FileIOgrade  cSPI_MODE = cSPI_MODE_0;  cSPI_LSBF = 0; // LSB first = -1  cSPI_BITS = 8; // data bits  cSPI_SPEED = 1000000; // data rate in Hz// cSPI_DEVICE = '/dev/spidev0.1'; // Device 0, ChipSelect 1  cSPI_DEVICE = '/dev/spidev0.0'; // Device 0, ChipSelect 0  cSPI_WR_MAX_SPEED_HZ: uint32 = $ 40046B04;  cSPI_RD_MAX_SPEED_HZ: uint32 = $ 80046B04;  cSPI_WR_BITS_PER_WORD: uint32 = $ 40016B03;  cSPI_RD_BITS_PER_WORD: uint32 = $ 80016B03;  cSPI_WR_LSB_FIRST: uint32 = $ 40016B02;  cSPI_RD_LSB_FIRST: uint32 = $ 80016B02;  cSPI_WR_MODE: uint32 = $ 40016B01;  cSPI_RD_MODE: uint32 = $ 80016B01;  // Read / Write + Size + MagicByte + Register  // control register  cSPI_CTRL = $ 6B; // is the "magic byte"  cSPI_READY = $ 80;  cSPI_NO_CS = $ 40;  cSPI_LOOP = $ 20;  cSPI_3WIRE = $ 10;  cSPI_LSB_FIRST = $ 08;  cSPI_CS_HIGH = $ 04;  cSPI_MODE_3 = (SPI_CPOL or SPI_CPHA);  cSPI_MODE_2 = (SPI_CPOL or 0);  cSPI_MODE_1 = (0 or SPI_CPHA);  cSPI_MODE_0 = (0 or 0);  cSPI_CPOL = $ 02;  cSPI_CPHA = $ 01;  // SPI mode flagsconst  end;    {public declarations}  public    {private declarations}  private  function FastShift (dout: byte): byte;  procedure TransmitSync (const dout; len: byte);  procedure TransferSync (const dout; var din; len: byte);  function DataOut (const dout; cnt: byte): integer;  function DataIn (var din; cnt: byte): integer;  procedure Close ();  procedure Init ();  Tspi = classgrade  Cla        procedure ShowRext(Text: String);unit test_spi;ad√˜	H—§x_F$ÓÌÂ∂™àxsrON¸
ﬁ
ÿ
¡
§
Å
_
^
/

∆≠îrS<;3¯˜ÓÁ‚·¿øìèÇd^R%‹
«
∞
ê
s
^
]
W
*
 



˛	˝	¯	˜	ˆ	end.end;  end;    FastShift: = din;  finally    FpIOCtl (spihnd, $ 40206B00, @transfer);  try  transfer.csc: = 0;  transfer.bpw: = cSPI_BITS;  transfer.speed: = cSPI_SPEED;  transfer.delay: = 0;  transfer.len: = 1;  transfer.rx_buf: = uint64 (@din);  transfer.tx_buf: = uint64 (@dout);  FillByte (transfer, SizeOf (transfer), 0);  din: = 0;begin  transfer: spi_ioc_transfer;  din: byte;varfunction Tspi.FastShift (dout: byte): byte;// Send, receive SPI single byteend;  end;    end;    finally      FpIOCtl (spihnd, $ 40206B00, @transfer);    try    transfer.csc: = 0;    transfer.bpw: = cSPI_BITS;    transfer.speed: = cSPI_SPEED;    transfer.delay: = 0;    transfer.len: = len;    transfer.rx_buf: = uint64 (@outbuf [0]); // same buffer    transfer.tx_buf: = uint64 (@outbuf [0]);    FillByte (transfer, SizeOf (transfer), 0);    Move (dout, outbuf [0], len);    FillByte (outbuf [0], len, 0);    SetLength (outbuf, len);  if len> 0 then beginbegin  transfer: spi_ioc_transfer;  outbuf: array of byte;varprocedure Tspi.TransmitSync (const dout; len: byte);// Send SPI data without receivingend;  end;    end;      Move (inbuf [0], din, len);    finally      FpIOCtl (spihnd, $ 40206B00, @transfer);    try    transfer.csc: = 0;    transfer.bpw: = cSPI_BITS;    transfer.speed: = cSPI_SPEED;    transfer.delay: = 0;    transfer.len: = len;    transfer.rx_buf: = uint64 (@inbuf [0]);    transfer.tx_buf: = uint64 (@outbuf [0]);    FillByte (transfer, SizeOf (transfer), 0);ad+õóˆı—– ª∫•èé]('Ï∫ëêÜkbHA@:&%˝
¸
‚
¡
†
x
w
`
G
2

	
ÙÛ»«±ÅÄ[6‚¥ÜY,+Ô
≤
á
i
F
+
*
$
‡	¡	ë	h	B		˙›ÕΩ¨éçâ|ED54"!	˜‰ﬁÿÖÑeLˆ•á<!›‘ …¬Ωº∞Øñês]VQP=<Âºµ∞Øõöb\?ÏÎ≠©êxZT= ˝€⁄æúõ    FillByte (inbuf [0], len, 0);    SetLength (inbuf, len);    Move (dout, outbuf [0], len);    FillByte (outbuf [0], len, 0);    SetLength (outbuf, len);  if len> 0 then beginbegin  transfer: spi_ioc_transfer;  inbuf: array of byte;  outbuf: array of byte;varprocedure Tspi.TransferSync (const dout; var din; len: byte);// Send, receive SPI dataend;  end;    DataOut: = FpWrite (spihnd, dout, cnt);  if spihnd <> -1 then beginbeginfunction Tspi.DataOut (const dout; cnt: byte): integer;// SPI Buffer Writeend;  end;    DataIn: = FpRead (spihnd, din, cnt);  if spihnd <> -1 then beginbeginfunction Tspi.DataIn (var din; cnt: byte): integer;// SPI Buffer Readend;  end;    FpClose (spihnd);  if spihnd <> -1 then beginbeginprocedure Tspi.Close ();// exit SPIend;  end;  finally    end;      FpIOCtl (spihnd, cSPI_WR_MAX_SPEED_HZ, @ val32); // set speed      val32: = cSPI_SPEED;      FpIOCtl (spihnd, cSPI_WR_LSB_FIRST, @ val8); // Set MSB or LSB first      val8: = cSPI_LSBF; //-1      FpIOCtl (spihnd, cSPI_WR_BITS_PER_WORD, @ val8); // set data bits per byte      val8: = cSPI_BITS;      FpIOCtl (spihnd, cSPI_WR_MODE, @ val8); // set fashion      val8: = cSPI_MODE;    if spihnd <> -1 then begin    spihnd: = FpOpen (cSPI_DEVICE, O_RdWr); // Open the interface for read / write  trybegin  val32: longword;  val8: byte;varprocedure Tspi.Init ();// initialize SPIimplementation  spihnd: longint; // the filehandle for the interface  spi: Tspi;var  end; // a total of 32 bytes    pad: uint16;    rxn: uint8;    txn: uint8;    csc: uint8; // CS change    bpw: uint8; // bits per word    delay: uint16; // delay CS in usec    speed: uint32; // data rate in Hz    len: uint32; // Number of characters    rx_buf: uint64; //pointer; // always 64-bit    tx_buf: uint64; //pointer;  spi_ioc_transfer = record // Control register required for FileIOgrade  cSPI_MODE = cSPI_MODE_0;  cSPI_LSBF = 0; // LSB first = -1  cSPI_BITS = 8; // data bits  cSPI_SPEED = 1000000; // data rate in Hz// cSPI_DEVICE = '/dev/spidev0.1'; // Device 0, ChipSelect 1  cSPI_DEVICE = '/dev/spidev0.0'; // Device 0, ChipSelect 0  cSPI_WR_MAX_SPEED_HZ: uint32 = $ 40046B04;  cSPI_RD_MAX_SPEED_HZ: uint32 = $ 80046B04;  cSPI_WR_BITS_PER_WORD: uint32 = $ 40016B03;  cSPI_RD_BITS_PER_WORD: uint32 = $ 80016B03;  cSPI_WR_LSB_FIRST: uint32 = $ 40016B02;  cSPI_RD_LSB_FIRST: uint32 = $ 80016B02;  cSPI_WR_MODE: uint32 = $ 40016B01;  cSPI_RD_MODE: uint32 = $ 80016B01;  // Read / Write + Size + MagicByte + Register  // control register  cSPI_CTRL = $ 6B; // is the "magic byte"  cSPI_READY = $ 80;  cSPI_NO_CS = $ 40;  cSPI_LOOP = $ 20;  cSPI_3WIRE = $ 10;  cSPI_LSB_FIRST = $ 08;  cSPI_CS_HIGH = $ 04;  cSPI_MODE_3 = (SPI_CPOL or SPI_CPHA);  cSPI_MODE_2 = (SPI_CPOL or 0);  cSPI_MODE_1 = (0 or SPI_CPHA);  cSPI_MODE_0 = (0 or 0);  cSPI_CPOL = $ 02;  cSPI_CPHA = $ 01;  // SPI mode flagsconst  end;    {public declarations}  public    {private declarations}  private  function FastShift (dout: byte): byte;  procedure TransmitSync (const dout; len: byte);  procedure TransferSync (const dout; var din; len: byte);  function DataOut (const dout; cnt: byte): integer;  function DataIn (var din; cnt: byte): integer;  procedure Close ();  procedure Init ();  Tspi = classgrade  Classes, SysUtils, BaseUnix;usesinterface