|
View:
New views
5 Messages
—
Rating Filter:
Alert me
|
|
|
Low level port access with porttran.hHi 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 _______________________________________________ http://lists.egnite.de/mailman/listinfo/en-nut-discussion |
|
|
Re: Low level port access with porttran.hHi Andre,
Andre Riesberg wrote: > I am writing a 1-wire interface. This interface has a strict timing so I > use the macros from "porttran.h". This is exactly the reason why we have slow, but convenient GpioXXX functions and weird, but fast GPIO_XXX macros. > 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. There should have been an inr() (r stands for register) for the AVR as well, which is exactly the same as inb() on this platform. Thanks for reporting this. Harald _______________________________________________ http://lists.egnite.de/mailman/listinfo/en-nut-discussion |
|
|
Re: Low level port access with porttran.hHarald Kipp wrote:
>Hi Andre, > >Andre Riesberg wrote: > > > >>I am writing a 1-wire interface. This interface has a strict timing so I >>use the macros from "porttran.h". >> >> > >This is exactly the reason why we have slow, but convenient GpioXXX >functions and weird, but fast GPIO_XXX macros. > > > > >>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. >> >> > >There should have been an inr() (r stands for register) for the AVR as >well, which is exactly the same as inb() on this platform. > >Thanks for reporting this. > >Harald >_______________________________________________ >http://lists.egnite.de/mailman/listinfo/en-nut-discussion > > > > I have just finished my 1-Wire interface for the AVR's. But this interface works only with a (quick) fix in the "porttran.h" file.: Line 404: #if defined(GPIO_PDS_REG) //#define GPIO_GET(b) ((inr(GPIO_PDS_REG) & _BV(b)) == _BV(b)) #define GPIO_GET(b) ((inb(GPIO_PDS_REG) & _BV(b)) == _BV(b)) #else #define GPIO_GET(b) #endif This works fine, but I think this is not the solution you prefer! In the moment I am not sure in with file I have to add the "inb" function for AVR's. Can anybody make this modification or help me to make this modification? Then I be able to post my 1-Write interface... Greetings André _______________________________________________ http://lists.egnite.de/mailman/listinfo/en-nut-discussion |
|
|
Re: Low level port access with porttran.hOn Mon, 07 Sep 2009 12:12:08 +0200, Andre Riesberg <andre@...> wrote: > Hi Harald, > > I have just finished my 1-Wire interface for the AVR's. But this > interface works only with a (quick) fix in the "porttran.h" file.: > > Line 404: > > #if defined(GPIO_PDS_REG) > //#define GPIO_GET(b) ((inr(GPIO_PDS_REG) & _BV(b)) == _BV(b)) > #define GPIO_GET(b) ((inb(GPIO_PDS_REG) & _BV(b)) == _BV(b)) > #else > #define GPIO_GET(b) > #endif > > This works fine, but I think this is not the solution you prefer! In the > moment I am not sure in with file I have to add the "inb" function for > AVR's. > Can anybody make this modification or help me to make this modification? > Then I be able to post my 1-Write interface... > Hmm... In include/arch/avr.h there is no definition for inr. inr is only defined for ARM and AVR32. So normally there must have been a compiler error if using GPIO_GET(b) with the original code. With Andres code it should work. May no one stumbled accross that one as no one used a recent compiler where the libc is updated? Harald, I like this patch and if Andre verified it to work... Optionally inr and outr should be mapped to inb and outb for 8-bit architecture, what may be more elegant for the arch-independance. Best regards, Ulrich _______________________________________________ http://lists.egnite.de/mailman/listinfo/en-nut-discussion |
|
|
Re: Low level port access with porttran.hUlrich Prinz wrote:
> Harald, I like this patch and if Andre verified it to work... > Optionally inr and outr should be mapped to inb and outb for 8-bit > architecture, what may be more elegant for the arch-independance. I'd vote for adding inr and outr to AVR, because it's the natural way for a CPU to access its registers. Harald _______________________________________________ http://lists.egnite.de/mailman/listinfo/en-nut-discussion |
| Free embeddable forum powered by Nabble | Forum Help |