2020-02-07 07:12 AM
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!
2020-02-07 11:00 PM
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
2020-02-11 08:27 AM
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