cancel
Showing results for 
Search instead for 
Did you mean: 

GPIO Interrupt on Linx Userspace Application

JSchn.1
Associate III

I am switching from a classic RTOS/Bare Metal Architecture (like the F4) to the STM32MP1 ecosystem. For that I am trying to generate an interrupt based of a GPIO input.

I could not find any specific examples for this in the wiki? Are there any tutorials for that? Is it possible to configure the Device Tree for that Interrupt using STMCubeMX?

Thanks!

2 REPLIES 2
KnarfB
Principal III

I don't know about STM32MP1 specific information, but once I did some tutorials for another board: https://github.com/FrankBau/raspi-repo-manifest/wiki/Kernel-Module-1---Hello-World. Hope they are still useful.

KnarfB

Olivier GALLIEN
ST Employee

Hi @JS.2chneider​ 

We are providing one exemple of GPIO management from user space base on gpiolib under

/usr/local/Linux-A7-examples/GPIO/buttons/

unfortunately I just discovered it's somewhat buggy.

Please use this version instead (diff in bold) :

#!/bin/sh

val=1

while true; do

    pid=$$

    gpiomon --num-events=1 --silent --rising-edge gpiochip0 13

    trap 'kill -9 $pid' 2

    if [ $val -eq 1 ]; then

        val=0

    else

        val=1

    fi

    gpioset gpiochip0 14=$val

done

Green LED5 on PA14 will toggle on each action on USER2 button (PA13)

This is working on all GPIO not already configured/assigned in Device Tree.

Else, you can also assign gpio and set related interruption inside a DT node.

Refer to https://wiki.st.com/stm32mpu/wiki/Interrupt_overview and related binding documentation.

For example you can refer to what is done in stm32mp157c-ev1-a7-examples.dts ( you need to install kernel source code cf https://wiki.st.com/stm32mpu/wiki/STM32MP1_Developer_Package_-_Linux_kernel) :

button@1 {

label = "PA13";

linux,code = <BTN_1>;

interrupts-extended = <&gpioa 13 IRQ_TYPE_EDGE_FALLING>;

status = "okay";

wakeup-source;

};

Hope it help,

Olivier

Olivier GALLIEN
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.