Skip to main content
Visitor II
February 7, 2020
Question

GPIO Interrupt on Linx Userspace Application

  • February 7, 2020
  • 2 replies
  • 1476 views

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!

    This topic has been closed for replies.

    2 replies

    Super User
    February 8, 2020

    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

    Technical Moderator
    February 11, 2020

    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