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: Mon, 23 Aug 2004 19:50:10 +0200

Eric,

thanks for your response, but still I'm not able to use it during
preprocessing to exclude or include specific code.

In the meantime I found out, that not even my proposed solution
worked. :-( It's a lot more complicated than expected. The related
document is here
http://gcc.gnu.org/onlinedocs/gcc-3.3.3/cpp/Argument-Prescan.html#Argument%20Prescan

I finally discovered a solution by using two macros as described in that
document _and_ use them before including any avr-libc headers like
avr/iom128.h.

Now I'm in doubt, if all that had been worth the hassle and how
portable my code will be. Well, at least I got some deeper
insight into the preprocessor.

Harald



At 09:17 23.08.2004 -0600, E. Weddington wrote:
Harald Kipp wrote:

Hi all,

I stumbled over the following pre-processor problem.

Somewhere in an include file there's a macro

  #define MY_PORT  PORTC

User's should be able to adapt the program to their hardware
be simply changing this include file.

To make the code independent from the specified port,
I need something like

  #if (MY_PORT == PORTC)
  /* Do something PORTC specific, like disabling XMEM */
  #endif
  sbi(MY_PORT, 7);

Obviously this won't work, because PORTC is an already dereferenced
volatile pointer. No chance to retrieve the pointer address, right?
Actually you *can* retrieve the pointer address. The register names can be used as variables, so you can take the address of it like so:

&PORTC

HTH
Eric






reply via email to

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