[fpc-devel] Problems with fpioctl on ARM debian linux and FPC2.6

Stefan Fischer sfischer at basis.biz
Tue Jun 19 10:52:31 CEST 2012


Hello,
 
I have a project, where I have to write a driver for /dev/spidev0.0, but
I have problems with fpioctl.
 
I believe that I have problems with the parameter passing or type
casting of fpioctl.
In some forums, I've found mysterios Pointer(PtrInt(xx) syntax like
that: fpioctl(fd,funcnum, Pointer(PtrInt(xy)) : 
I have no idea why this construction is necesary
 
 
My code snipet is below:
 
spi_ioc_transfer_t = record
    tx_buf_ptr   : pointer;
    rx_buf_ptr   : pointer;
    len    : longword;
    delay_usec  : word;
    speed_hz     : longword;
    bits_per_word : byte;
    cs_change  : byte;
    pad    : longword;
  end;
 
var xfer : array[0..1] of spi_ioc_transfer_t; rx0,tx0 : array[0..42] of
byte; 
 
tx0 [ 0]:=$00; tx0 [ 1]:=$00; 
xfer[0].len:=2; xfer[0].speed_hz:=500000; xfer[0].bits_per_word:=8;
xfer[0].tx_buf_ptr := addr(tx0[ 0]); xfer[0].rx_buf_ptr := addr(rx0[
0]);
 
fd:=fpOpen('/dev/spidev0.0',O_RdWr);
...
result := fpioctl(fd, (*SPI_IOC_MESSAGE(1)*) 1075866368, @xfer[0]);
(* function number 107.. 368 taken from operating c example *)
 
I get -1 as result
What's wrong.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20120619/8e45ce33/attachment.html>


More information about the fpc-devel mailing list