0

Does anyone know how to correlate an interrupt source with a handler, without importing libraries, assuming that you have the addresses for all your registers? An example for any ARM processor would help, but in my case I am using the Pi3's BCM2837. My interpretation of this post about the datasheet, is that the BCM2835 manual is equivalent.

On page 90, I see the address that enables rising edge detection, so I put this code into my program:

//-v- I think this allows me to enable detection on GPIO pins 0-31
#define RisingInterruptEnable (*(int *) 0x7E2004C)
//-^- e.g. "RisingInterruptEnable = 0x1" enables GPIO 0 rising detect

From page 112-117 of the manual,I found the register that enables InterruptReQuests [0x7E00B214], but I honestly don't understand how to use it. I see how to enable gpio_int[0], but I could not find what gpio_int meant after searching the pdf.

From this post about function pointers I know how to "point to" whatever function I use for the handler. However I still do not understand:

How do I correlate an interrupt source with a function [without importing libraries, assuming I know the addresses to all of my registers]?

elscan
  • 113
  • 1
  • 9
  • sounds like you are not quite ready for interrupts, work your way up to them...start by polling. aiming the interrupt at a function pointer is well down the road from that. you will want to wrap the function with some asm... – old_timer Mar 04 '19 at 05:03
  • have you worked through polling the interrupts and clearing them and such? if this is the pi3 its another 10 times harder than a pi-zero. the broadcom interrupt controller is pretty simple, the pi3 has a number of possible modes each can have a different solution. – old_timer Mar 04 '19 at 05:05

2 Answers2

1

Not sure that examples for any ARM processor would help, since the BCM2837 does not seem to be using a standard ARM GIC acording to bcm2837.dtsi.

I would then suggest to look at the excellent raspberry-pi specific examples provided by David Welch here: You will find examples dealing with interrupts and accessing registers directly - I am assuming you are writing some baremetal code.

Frant
  • 5,382
  • 1
  • 16
  • 22
0

There are several levels of indirection here, even just in the hardware.

Starting with the GPIO pin, this can be configured to generate an interrupt within the GPIO peripheral (as you have seen). However, all this does is drive an output from that peripheral (and identify the trigger in one of the other GPIO registers). This on-chip signal is gpio_int[0].

According to the data sheet, this signal from GPIO_0 connects to IRQ[49] of the A53 cluster (this is a very implementation specific aspect).

To enable IRQ[49], you then need to use the registers in the interrupt controller, for enable and handler (since the direction to the right interrupt handler is handled in hardware).

Once in your interrupt handler, you will need to go back to the GPIO registers to work out which (of what you have enabled there) actually caused the interrupt (and this will depend on your use case - maybe you only needed to enable one, and you won't need further checking).

Sean Houlihane
  • 1,698
  • 16
  • 22