Recent

Author Topic: Interrupt code besides wiringpi and pascalio  (Read 362 times)

pascalbythree

  • Full Member
  • ***
  • Posts: 110
Interrupt code besides wiringpi and pascalio
« on: March 12, 2022, 06:23:13 pm »
Code: Pascal  [Select][+][-]
  1. program Project1;
  2. uses fpgpio;
  3. var
  4.   pin_21: TGpioPin;
  5.   NewValue: Boolean;
  6. begin
  7.   pin_21 := TGpioLinuxPin.Create(21);
  8.   pin_21.Direction := gdIn;
  9.   pin_21.InterruptMode := [gimRising, gimFalling];
  10.   try
  11.     repeat
  12.       if input.WaitForInterrupt(TGpioLinuxPin.INTERRUPT_WAIT_INFINITE, NewValue) then
  13.         Writeln('Interrupt on Pin ', input.PinID, ' with value ', NewValue)
  14.       else
  15.         WriteLn('Timeout');
  16.     until False;
  17.   except
  18.     // e.g. on sig int
  19.     pin_21.Destroy;
  20.   end;
  21. end.

   
Code: Pascal  [Select][+][-]
  1. wiringPiSetupGpio;
  2.   wiringPiISR(19,INT_EDGE_FALLING,@WVW_TEST_PROCEDURE);

Hey freepascal Crew, does anybody have short example code to interrupt your GPIOPIN on fpc for raspberry ?

On PascalIO it works, but it only needs to wait for a pinchange, wich is not preferred to unfold incoming signals from my distance sensor HC-SR04

On wiringPI it works, but i can not have a falling and rising in one procedure and it also does not have code for previous pin status.

Does anybody know a other component pack?

Some native FPC code wil maybe also do.

Thank you and Greets, Wouter van Wegen.


MarkMLl

  • Hero Member
  • *****
  • Posts: 4764
Re: Interrupt code besides wiringpi and pascalio
« Reply #1 on: March 18, 2022, 02:57:42 pm »
Are those true interrupts, i.e. handled via the Linux kernel, or simply pins which are periodically polled?

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

Thaddy

  • Hero Member
  • *****
  • Posts: 11774
Re: Interrupt code besides wiringpi and pascalio
« Reply #2 on: March 18, 2022, 03:18:13 pm »
Are those true interrupts, i.e. handled via the Linux kernel, or simply pins which are periodically polled?

MarkMLl
They are true interrupts in both cases. I may have an example for the second one. Have to look it up, though.l
Black themes should be banned.

MarkMLl

  • Hero Member
  • *****
  • Posts: 4764
Re: Interrupt code besides wiringpi and pascalio
« Reply #3 on: March 18, 2022, 03:30:44 pm »
They are true interrupts in both cases. I may have an example for the second one. Have to look it up, though.l

I'm being cautious. Some I2C/SPI-connected GPIO stuff that I've been looking explains that its interrupts are handled by polling at the driver level, even if they're exposed by the gpiod etc. API as apparent interrupts.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

 

TinyPortal © 2005-2018