Recent

Author Topic: PiGPIO - Adding GetByte "like" GetBit  (Read 1018 times)

emjtech

  • New member
  • *
  • Posts: 25
    • Global R&D ltd
PiGPIO - Adding GetByte "like" GetBit
« on: December 19, 2018, 07:40:23 pm »
Hi
I need to access the GPIO fast in order to read some special hardware.
I looked into the GetBit function (attached at the end of the post for convenience) and I so ... + (gpin shr 5) shl 2) ;
However gpin is a number from 2 to 27 (decimal) therefore the result of that calculation will always be zero
Is there something I don't get, or I can write that line as

gpiof := Pointer(LongWord(Self.FGpio) + 52);

Thanks

//*******************************************************************************
function TIoPort.GetBit(gpin : byte):boolean;
var
   gpiof : ^LongWord;
begin
  gpiof := Pointer(LongWord(Self.FGpio) + 52 + (gpin shr 5) shl 2);
  if (gpiof^ and (1 shl gpin)) = 0 then Result := False else Result := True;
end;
//*******************************************************************************
Thanks
Eli Jacob