[En-Nut-Discussion] Unified GPIO implementation
Thiago A. Corrêa
thiago.correa at gmail.com
Wed Oct 6 07:29:27 CEST 2010
Hi,
For reference, Ulrich started wiki page on the subject here:
http://www.ethernut.de/nutwiki/Unified_GPIO_Implementation
I have added some info on AVR32, and I would like to hear comments
from you on the subject.
About the GPIO Architecture Specific section, it's suggested to
use different function signatures for different archtectures, whether
they are 8 bit or 32 bits. It's suggested:
AVR:
int8_t GpioPinConfigSet( uint8_t port, uint8_t pin, uint8_t cfg)
AVR32,ARM,Cortex
int GpioPinConfigSet( uint32_t port, uint32_t pin, uint32_t cfg)
Why not define it as simply int8_t GpioPinConfigSet( uint8_t port,
uint8_t pin, uint8_t cfg) for all architectures? The range of values
is more than enough, and the aledged optimization isn't there from
what I can tell, for the 32 bit. Is the assembly output for arm or
cortex different for arguments which are 8 bits instead of 32 bits? Or
is it to keep the stack word aligned?
About the port definitions:
#define NUTGPIO_PORT -> Same as port A
#define NUTGPIO_PORTA -> Can be a numeric, a pointer or a address value
#define NUTGPIO_PORTB
We already have those defined in include/dev/gpio.h, except that _PORT
is 0 and _PORTA is 1. Should we change it?
There is also one area that is not covered in the document. The
AVR32 toolchain defines which references the GPIO set their values as
pin numbers, not ports/pins. So, some sort of conversion macro is
needed, to use that convention with the port/pin convention in Nut/OS.
For example, one can find in one of the toolchain headers something
like this:
#define AVR32_USART2_RXD_0_PIN 33
Which would translate to port B, pin 1.
Kind Regards,
Thiago A. Correa
More information about the En-Nut-Discussion
mailing list