[En-Nut-Discussion] Implementation of the GPIO API as defined in RFA_4

Ole Reinhardt ole.reinhardt at embedded-it.de
Sun Nov 11 17:06:16 CET 2012


Hi Philipp,

> At the moment, I'm cleaning the LM3S code somewhat and have now updated 
> the GPIO implementation according to the new API. It is located in the 
> branch devnut-lm3s and the code resides in 
> nut/include/arch/cm3/lm3/lm3s_gpio.h and 
> nut/arch/cm3/dev/lm3/lm3s_gpio.c. I'd greatly appreciate it if someone 
> could have a look at it and tell me if this is the way to go. At least 
> it looks sensible to me and seems to work basically (I haven't done 
> extensive testing yet).

Yes, for sure I'll do this tomorrow.

> What I haven't implemented yet is the interrupt handling. Something is 
> not clear to me at the moment: Is the implementation supposed to allow a 
> distinct interrupt handler to be registered for every single bit? 

Yes, that's the intention.

It depends on how the LM3s implements GPIO interrupt. But normally you
would have one hardware IRQ vector common to all ports or one per port.

> This 
> would then require a typedef for GPIO_SIGNAL, which can hold eight 
> pointers to the handlers and a dispatcher function which checks which 
> bit fired the interrupt and the invokes the correct handler. Is this 
> correct?

Exactly. Have a look at the LPC implementation (which is not yet
implemented under the RFA_4 guidelines btw). But the code will give you
a good guideline to implement the LM3S GPIO interrupts in the same way.

It is defined in 

lpc17x_8x_gpio.c

GpioRegisterIrqHandler()
GpioIrqEnable()
GpioIrqDisable()
GpioIrqStatus()
GpioIrqSetMode()

The hardware IRQ handler itself is implemented in lpc17xx_gpioirq.c

It implements the handler: Lpc17xxGpioIsr() and the IRQCTL function to
set the IRQ settings:

Lpc17xxGpioCtrl()


The main idea is, that the first GPIO irq which will be registered also
registeres the hardware handler. A struct holds the callback handler
information for each single (regisered) bit of the port and the hardware
handler first looks, which port / pin was signalled and calls the
assigned handler if available.

I hope this helps a little.

Bye,

Ole

-- 

Thermotemp GmbH, Embedded-IT

Embedded Hard-/ Software and Open Source Development, 
Integration and Consulting

http://www.embedded-it.de

Geschäftsstelle Siegen - Steinstraße 67 - D-57072 Siegen - 
tel +49 (0)271 5513597, +49 (0)271-73681 - fax +49 (0)271 736 97

Hauptsitz - Hademarscher Weg 7 - 13503 Berlin
Tel +49 (0)30 4315205 - Fax +49 (0)30 43665002
Geschäftsführer: Jörg Friedrichs, Ole Reinhardt
Handelsregister Berlin Charlottenburg HRB 45978 UstID DE 156329280 



More information about the En-Nut-Discussion mailing list