[En-Nut-Discussion] Low level port access with porttran.h
Andre Riesberg
andre at riesberg-net.de
Sat Sep 5 09:29:59 CEST 2009
Hi all,
I am writing a 1-wire interface. This interface has a strict timing so I
use the macros from "porttran.h".
Changing the port direction, setting high and low works fine
(GPIO_INPUT, GPIO_OUTPUT, GPIO_SET_LO and GPIO_SET_HI).
Only the macro GP_IS_HI fails to compile and gives me the message:
warning: implicit declaration of function 'inr'
In the file "porttran.h" I found this:
#if defined(GPIO_ODS_REG)
#define GPIO_IS_HI(b) ((inr(GPIO_ODS_REG) & _BV(b)) == _BV(b))
#elif defined(GPIO_SOD_REG)
#define GPIO_IS_HI(b) ((inr(GPIO_SOD_REG) & _BV(b)) == _BV(b))
#else
#define GPIO_IS_HI(b)
#endif
But I think ist must like this:
#if defined(GPIO_ODS_REG)
#define GPIO_IS_HI(b) ((inr(GPIO_ODS_REG) & _BV(b)) == _BV(b))
#elif defined(GPIO_SOD_REG)
#define GPIO_IS_HI(b) ((inb(GPIO_SOD_REG) & _BV(b)) == _BV(b))
#else
#define GPIO_IS_HI(b)
#endif
The different is in line four: "inr" changed to "inb".
I use an AT90CAN128 and I think "inb" ist the typical macro (for an AVR)
to read one byte from a port. "inr" is for the ARM cpu's.
Is this correct?
Greetings
Andre
More information about the En-Nut-Discussion
mailing list