[En-Nut-Discussion] Unified GPIO implementation

Harald Kipp harald.kipp at egnite.de
Thu Oct 7 10:04:28 CEST 2010


On 06.10.2010 20:46, Ulrich Prinz wrote:

> But for easy 
> code reading, portability and others I could agree to either 
> uint_fast8_t or uint16_t.

You probably meant uint_fast16_t.


> I don't know about AVR32 but with ARM/Cortex it would produce overhead 
> as you have to recalculate from pin number back to address of port.
> That produces much more overhead than to pass over a second parameter.

In a way, you are right. But...


> I would like to remind that we have two entry ways into Nut/OS:
> 1) High portability
> 2) High optimization

2.1) Minimal code size
2.2) Maximum performance

... this extra overhead is introduced in the called API function only.
The callers will benefit from the reduced number of parameters. I'm
quite confident, that using pin numbers instead of port/pin pairs will
significantly reduce the overall size of today's Nut/OS libraries.

I'm not sure about the number of instruction, that are required to set a
specific port pin. They may indeed increase. (The ARM's barrel shifter
can handle the required shift within a single instruction, but this is a
special case.)

Anyway, IMHO the GPIO API never intends to provide performance, just
portability. For fast execution, no portable library will ever
outperform machine specific code.


> I will add my proposals now for GPIO into the Wiki and now with respect 
> for AVR32.

Thanks,

Harald



More information about the En-Nut-Discussion mailing list