2015-02-05 20:52:15 +03:00
|
|
|
#ifndef __EASYAVR_H_
|
|
|
|
#define __EASYAVR_H_
|
|
|
|
|
2015-02-14 20:39:18 +03:00
|
|
|
|
|
|
|
// Sets pin of port to 1
|
|
|
|
//
|
|
|
|
// Example for PD2: PIN_ON(D, 2)
|
|
|
|
#define PIN_ON(port,pin) ((PORT ## port) |= _BV(P ## port ## pin))
|
|
|
|
|
|
|
|
|
|
|
|
// Sets pin of port to 0
|
|
|
|
//
|
|
|
|
// Example for PD2: PIN_OFF(D, 2)
|
|
|
|
#define PIN_OFF(port,pin) ((PORT ## port) &= ~_BV(P ## port ## pin))
|
|
|
|
|
|
|
|
|
2015-02-14 20:49:46 +03:00
|
|
|
// Sets pin of port to value
|
2015-02-14 20:39:18 +03:00
|
|
|
//
|
|
|
|
// Example for PD2: PIN_SET(D, 2, 1)
|
|
|
|
#define PIN_SET(port,pin,val) (val > 0 ? PIN_ON(port,pin) : PIN_OFF(port,pin))
|
|
|
|
|
|
|
|
|
|
|
|
// Sets all of port pins to OUTPUT mode
|
|
|
|
//
|
|
|
|
// Example for PORTD: PORT_AS_OUTPUT(D)
|
|
|
|
#define PORT_AS_OUTPUT(port) ((DDR ## port) = 0xFF)
|
|
|
|
|
|
|
|
// Sets all of port pins to INPUT mode
|
|
|
|
//
|
|
|
|
// Example for PORTD: PORT_AS_INPUT(D)
|
|
|
|
#define PORT_AS_INPUT(port) ((DDR ## port) = 0x00)
|
2015-02-05 20:52:15 +03:00
|
|
|
|
|
|
|
#endif
|