avr-libc-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-libc-dev] Determine defined port


From: Harald Kipp
Subject: Re: [avr-libc-dev] Determine defined port
Date: Sun, 22 Aug 2004 18:35:31 +0200

I found a simpler solution myself by using the ## operator.

The user specifies what he easily understands

  #define MY_PORT  PORTC

There is still an enumerated list required

  #define GPIO_PORTA  1
  ...
  #define GPIO_PORTC  3
  ...

but it is hidden from the user. The code will use

  #define MY_GPIO  GPIO_##MY_PORT

and

  #if (MY_GPIO == GPIO_PORTC)
  ...
  #endif
  sbi(MY_PORT, 7);

will allow to add port specific code.

Yeah, I was too fast with asking questions, but may be one day someone
else benefits from this monologue. :-)

Thanks again,

Harald





reply via email to

[Prev in Thread] Current Thread [Next in Thread]