2015-02-05 20:52:15 +03:00
|
|
|
#ifndef __EASYAVR_H_
|
|
|
|
#define __EASYAVR_H_
|
|
|
|
|
2015-02-14 20:39:18 +03:00
|
|
|
|
2015-03-08 13:40:41 +03:00
|
|
|
// Sets pin of port to 1
|
2015-02-14 20:39:18 +03:00
|
|
|
//
|
2015-08-07 11:28:31 +03:00
|
|
|
// Example for PD2: PIN_ON(PORTD, 2)
|
|
|
|
#define PIN_ON(port,pin) ((port) |= (1 << (pin)))
|
2015-02-14 20:39:18 +03:00
|
|
|
|
|
|
|
|
2015-03-08 13:40:41 +03:00
|
|
|
// Sets pin of port to 0
|
2015-02-14 20:39:18 +03:00
|
|
|
//
|
2015-08-07 11:28:31 +03:00
|
|
|
// Example for PD2: PIN_OFF(PORTD, 2)
|
|
|
|
#define PIN_OFF(port,pin) ((port) &= ~(1 << (pin)))
|
2015-02-14 20:39:18 +03:00
|
|
|
|
|
|
|
|
2015-03-08 13:40:41 +03:00
|
|
|
// Sets pin of port to value
|
2015-02-14 20:39:18 +03:00
|
|
|
//
|
2015-08-07 11:28:31 +03:00
|
|
|
// Example for PD2: PIN_SET(PORTD, 2, 1)
|
|
|
|
#define PIN_SET(port,pin,val) (((val) > 0) ? PIN_ON((port),(pin)) : PIN_OFF((port),(pin)))
|
2015-03-08 13:40:41 +03:00
|
|
|
|
|
|
|
// Sets all of port pins to OUTPUT mode
|
2015-02-14 20:39:18 +03:00
|
|
|
//
|
2015-08-07 11:28:31 +03:00
|
|
|
// Example for PORTD: PORT_AS_OUTPUT(PORTD)
|
|
|
|
#define PORT_AS_OUTPUT(port) ((port) = 0xFF)
|
2015-02-14 20:39:18 +03:00
|
|
|
|
2015-03-08 13:40:41 +03:00
|
|
|
// Sets all of port pins to INPUT mode
|
2015-02-14 20:39:18 +03:00
|
|
|
//
|
2015-08-07 11:28:31 +03:00
|
|
|
// Example for PORTD: PORT_AS_INPUT(PORTD)
|
|
|
|
#define PORT_AS_INPUT(port) ((port) = 0x00)
|
2015-02-05 20:52:15 +03:00
|
|
|
|
2015-03-08 13:40:41 +03:00
|
|
|
// Sets pin of port to OUTPUT mode
|
|
|
|
//
|
2015-08-07 11:28:31 +03:00
|
|
|
// Example for PD1: PORT_AS_OUTPUT(DDRD, 1)
|
|
|
|
#define PIN_AS_OUTPUT(ddr,pin) ((ddr) |= (1 << (pin)))
|
2015-03-08 13:40:41 +03:00
|
|
|
|
|
|
|
|
|
|
|
// Sets pin of port to INPUT mode
|
|
|
|
//
|
2015-08-07 11:28:31 +03:00
|
|
|
// Example for PD1: PORT_AS_INPUT(DDRD, 1)
|
|
|
|
#define PIN_AS_INPUT(ddr,pin) ((ddr) &= ~(1 << (pin)))
|
2015-03-08 13:40:41 +03:00
|
|
|
|
|
|
|
// Checks pin's value of port
|
|
|
|
// Returns 1 or 0
|
|
|
|
//
|
2015-08-07 11:28:31 +03:00
|
|
|
// Example for PD2: CHECK_PIN(PIND, 2)
|
|
|
|
#define CHECK_PIN(pinreg,pin) (((pinreg) & (1 << (pin))) != 0)
|
2015-03-08 13:40:41 +03:00
|
|
|
|
|
|
|
|
2015-02-05 20:52:15 +03:00
|
|
|
#endif
|