cancel
Showing results for 
Search instead for 
Did you mean: 

A callback() for GPIO in the A7-core on the Linux side of the STM32MP157F

iSaeed62
Associate II

Hello,

I'm working with STM32MP1-DK2. I want to run a project on it.

I need to implement a callback function in the A7-core (Linux side) to read a pin whenever a signal comes in (on the rising or falling edges).

Actually, I need to have a callback() function to read the incoming signal and do something after that. I don't know how to implement the callback() for a pin from a GPIO port for my STM32MP157F. I would be grateful if you could give me a hand with it. 

Best,

Saeed

2 REPLIES 2
Erwan SZYMANSKI
ST Employee

Hello @Community member​ ,

If you want to use this kind of feature at user space level, in your own application, I advise you to take a look at libgpiod (version 1.6) that is delivered with our OSTL-4.0. This library provides different features for GPIO read/write, and your use case should be possible with it, regarding the code of the library.

FYI, I put you here the link to the library git: https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/

When you will cross compile your application, do not forget to link the library.

I hope this information will help you.

Kind regards,

Erwan.

In order to give better visibility on the answered topics, please click on 'Select as Best' on the reply which solved your issue or answered your question. See also 'Best Answers'

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.
S_2
Associate II

Hello @Erwan SZYMANSKI​ 

Thank you for your response.

I used the library you told me about and linked it with my project. It is working, but the problem that I have is that I need the lowest delay when I send a request to A7, and receive a response from it. This delay is like 10-us when I use traditional gpio.h library. When I replace it with libgpiod, it increases dramatically and becomes roughly 100 us! (ten times bigger). Secondly, they all are pooling types. I need something like a callback() in the user space rather than a pooling procedure or a thread which takes a considerable amount of resources. Do you have any ideas to solve this issue? or should I bring M4 to the game too? If I use M4 to receive the event, what is the fastest method to deliver this event to A7? (shared memory and virtual serial port are still prone to unacceptable delays lol).