DigitalWrite - change to faster version

alda

Member
Hi,
I want change instruction DigitalWrite to:
#define CLR( x , y ) ( x&=(˜(1<<y ) ) )
#define SET( x , y ) ( x|=(1<<y ) )
One instruction is for set and second for reset. It's much faster than original DigitalWrite instruction.
But for arduino mega I'm not sure how to correctly define a pins, because definition must be changed
Instruction CLR(PORTB, 0) - will set to zero a pin 53 ?
Can I define port linke this ? :
#define pinBatterySwitch (PORTB, 0)
But then CLR (pinBatterySwitch); don't work
Thanks for help
Alex
 
Oben