avr-gcc-list
[Top][All Lists]
Advanced

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

[avr-gcc-list] Question about gcc preprocessing and port/pin assignments


From: James Washer
Subject: [avr-gcc-list] Question about gcc preprocessing and port/pin assignments
Date: Mon, 6 Dec 2004 14:43:57 -0800

In my earlier mail, I thanked Dave.. Looking back, I see there are TWO Dave's 
that have been helping.. Thanks to both!!

Here's the current defines


//Example defines
#define DATA1         D, 7
#define DATA2         C, 3
#define DATA3         B, 3

//Code to manipulate PORTx, PINx, and DDRx using definitions like those above
#define PINDEF_PORT(a,b)        (PORT##a)
#define DDR(a,b)        (DDR##a)
#define PINDEF_PIN(a,b) (1<<(b))
#define PINDEF_PINPORT(pindef)   (PIN ## a)

//Set a pin
#define SETPIN(pindef)  PINDEF_PORT(pindef) |=  PINDEF_PIN(pindef)

//Clear a pin
#define CLRPIN(pindef)  PINDEF_PORT(pindef) &= ~PINDEF_PIN(pindef)

//Set a IO to output
#define DDR_OUT(pindef) DDR(pindef) |= PINDEF_PIN(pindef)

//Set a IO to input
#define DDR_IN(pindef)  DDR(pindef) &= ~PINDEF_PIN(pindef)

//Read the value of a pin
#define GETPIN(pindef)  PINDEF_PINPORT(pindef) & PINDEF_PIN(pindef)



reply via email to

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