[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Fw: [avr-gcc-list] Question about gcc preprocessing and port/pinassignme
From: |
Royce & Sharal Pereira |
Subject: |
Fw: [avr-gcc-list] Question about gcc preprocessing and port/pinassignments |
Date: |
Mon, 6 Dec 2004 13:17:50 +0530 |
Hi,
----- Original Message -----
From: "James Washer" <address@hidden>
To: <address@hidden>
Sent: Monday, December 06, 2004 11:49 AM
Subject: [avr-gcc-list] Question about gcc preprocessing and
port/pinassignments
>
>
> I'd like to be able to say something like
>
> #define switch PB7
> setpin(PB7)
>
> and have the following code generated
>
> PORTB |= 1<<7
> What I'm hoping for is the ability to change the definition of "switch" at
any time, and have everything work
>
> For example
>
> if I change switch to PD2, the preprocessor would (auto)magically arrange
for the following code
>
> PORTD |= 1<<2
> Any ideas?
----------------------------------------------
You could do this.
#define setpin(prt,pos) prt |= 1<<pos;
#define SWITCH portd, 2 /*only this would be needed to be modified*/
...and in your body:-
setpin(SWITCH);
//---------------------
This would work, but there may be a more elegant way. I'll leave that to the
other list members!
Regards,
--Royce.
- Fw: [avr-gcc-list] Question about gcc preprocessing and port/pinassignments,
Royce & Sharal Pereira <=