//*********************************************************************************** // // avriomacros.h (rev 1.1) // // Author: Jeremy Greenwood // // Description: // Includes basic macro functions for input and output tasks. Intended for // use with AVR microcontrollers compiled with GCC. // // To use this in a project: // // A) 1. Add this file to project or B) 1. Add this file to avr/include // 2. #include "avriomacros.h" 2. #include // //*********************************************************************************** /* Macro function to declare an output pin */ #define out(bit,port) DDR##port |= (1 << bit) /* Macro function to declare an input pin */ #define in(bit,port) DDR##port |= (0 << bit) /* Macro function to set an output pin high */ #define on(bit,port) PORT##port |= (1 << bit) /* Macro function to set an output pin low */ #define off(bit,port) PORT##port &= ~(1 << bit) /* Macro function to toggle an output pin */ #define flip(bit,port) PORT##port ^= (1 << bit) /* Macro function to set internal pullup resistor of input pin (same as on macro)*/ #define pullup(bit,port) PORT##port |= (1 << bit) // helps distinguish whats being done without comments /* Macro function to get state of input pin */ #define get(bit,port) (PIN##port & (1 << bit))