I am new learner for raspberry pi 3B+, I ever study stm32 mcu, but it's my first time to use an Linux OS on a developing board.
I read the BCM2837-ARM-Peripherals manaul and learn how to turn on and off led by access virtual address through ioremap_nocache(). It's not too difficult for me.
But I would like to learn set a gpio input interrupt for a button, I try many ways but still fail. I refer the dht11 example and source code http://www.tortosaforum.com/raspberrypi/dht11driver.htm
I use the material code like blow, or just compile the dht11 example, all I try will make linux crash without any hint and I can operate rpi only after power reset.
#define GPIO_INT_RISING(g,v) *(gpio+19) = v ? (*(gpio+19) | (1<<g)) : (*(gpio+19) ^ (1<<g)) #define BCM2708_PERI_BASE 0x3F000000 #define GPIO_BASE (BCM2708_PERI_BASE + 0x200000) #define ARM_IRQ2_BASE 32 #define INTERRUPT_GPIO0 (ARM_IRQ2_BASE + 17) gpio = ioremap_nocache(GPIO_BASE, SZ_4K) request_irq(INTERRUPT_GPIO0, irq_handler, IRQF_SHARED, NAME, (void*) gpio) GPIO_INT_RISING(gpio_pin, 1);
I found there are another way to use library, like
button_irq = gpio_to_irq(BUTTON) request_irq( button_irq, button_isr ,IRQF_TRIGGER_RISING, MY_GPIO_INT_NAME, MY_DEV_NAME)
It works for me to trigger irq when I press the input button, but I prefer to learn more direct way like dht11 example. Can any one give me a example about how to setting gpio input interrupt with direct memory access?