Fast GPIOs

Started by Dami1, November 28, 2012, 03:38:08 pm

Previous topic - Next topic


September 21, 2013, 04:02:18 pm #15 Last Edit: September 21, 2013, 06:16:22 pm by soenke
One Question about the config registers:

you wrote:

#define GPIO_CFG_INDEX(pin) (((pin) & 0x1F) >> 3)
writel(cfg, &pio->cfg[0] + index);

But config index should be like (at least i think so):

0-7 : 0x0
8-15 : 0x4
16-23 : 0x8
24-31 : 0xC

I took this from the A13 user manual page 384:

And if i calculate GPIO_CFG_INDEX with your code, i get:

0-7 : 0x0
8-15 : 0x1
16-23 : 0x2
24-31 : 0x3

So there is missing a factor 4?


Don't you get confused about pointer arithmetic ?
I'm just guessing, I haven't checked the code yet, because it seems complicated, and I don't remember at all, that things happened in March, half year ago !

If we add 1 to a pointer to a 32 bit integer, how much bigger is the result ?
Of course sizeof(int32) = 4

Does that explain it, or should we dig deeper, is there an error indeed ?


I was wondering if it would be a problem to use the above gpioport.h/gpioport.c by Tele for a A20 e.g. if it would need modifications in the memory mapping? Or, if so, does anyone know a library supporting interrupts for GPIO for the A20-micro?


I think you'll find the details are in the datasheets which are downloadable free.

(sysfs etc may make GPIOs available for (slow) access if that will do)



Hi John, thanks for your reply. The A10 and A20 are pin compatible, and A10 and A13 belong to the same family, so maybe the chances that the above library works for the A20 aren't too bad? Of course I could dig into tons of datasheets to find out myself, but if everyone reinvents the wheel for his own use, we wouldn't get very far. I use GPIO access via sys-fs successfully, but my new case is timing sensible *and* needs polling (RF433MHz reception), so the above library would just be perfect for me.
So if there's someone who can confirm that the memory mapping for A13 and A20 is identical, I am already happy as can be and will give this library a try. If not, I am also happy to know that I have to look further.


I really doubt you're reinventing this one.  Who else wants to do as you do?  Likely no-one in this forum.