pin definitions and I/O macros More...
#include <avr/io.h>
Go to the source code of this file.
Defines | |
#define | _READ(IO) (IO ## _RPORT & _BV(IO ## _PIN)) |
read a pin | |
#define | _WRITE(IO, v) |
write to a pin | |
#define | _TOGGLE(IO) do { IO ## _RPORT = _BV(IO ## _PIN); } while (0) |
toggle a pin | |
#define | _SET_INPUT(IO) do { IO ## _DDR &= ~_BV(IO ## _PIN); } while (0) |
set pin as input | |
#define | _SET_OUTPUT(IO) do { IO ## _DDR |= _BV(IO ## _PIN); } while (0) |
set pin as output | |
#define | _GET_INPUT(IO) ((IO ## _DDR & _BV(IO ## _PIN)) == 0) |
check if pin is an input | |
#define | _GET_OUTPUT(IO) ((IO ## _DDR & _BV(IO ## _PIN)) != 0) |
check if pin is an output | |
#define | READ(IO) _READ(IO) |
Read a pin wrapper. | |
#define | WRITE(IO, v) _WRITE(IO, v) |
Write to a pin wrapper. | |
#define | TOGGLE(IO) _TOGGLE(IO) |
toggle a pin wrapper | |
#define | SET_INPUT(IO) _SET_INPUT(IO) |
set pin as input wrapper | |
#define | SET_OUTPUT(IO) _SET_OUTPUT(IO) |
set pin as output wrapper | |
#define | GET_INPUT(IO) _GET_INPUT(IO) |
check if pin is an input wrapper | |
#define | GET_OUTPUT(IO) _GET_OUTPUT(IO) |
check if pin is an output wrapper |
pin definitions and I/O macros
why double up on these macros? see http://gcc.gnu.org/onlinedocs/cpp/Stringification.html
#define _WRITE | ( | IO, | |||
v | ) |
do { \ if (v) { IO ## _WPORT |= _BV(IO ## _PIN); }\ else { IO ## _WPORT &= ~_BV(IO ## _PIN); };\ } while (0)
write to a pin