//
// Created by kirillius on 20.04.2020.
//

#ifndef AVR_IOHELP_H
#define AVR_IOHELP_H

//Пример: pinmode_input(DDRB, PORTB1);

#define pinmode_input(DDREGISTER, PINNAME) (DDREGISTER &= ~(1<<PINNAME))
#define pinmode_output(DDREGISTER, PINNAME) (DDREGISTER |= (1<<PINNAME))


//Пример: pinstateset(PORTB, PORTB1, true);

#define pinstateset(PORTREGISTER, PINNAME, STATE) do{ if(STATE){ PORTREGISTER |= (1<<PINNAME); }else{ PORTREGISTER &= ~(1<<PINNAME); } }while(0)

//Пример: int state = pinstateget(PINB, PORTB1);

#define pinstateget(PINREGISTER, PINNAME) (PINREGISTER & (1<<PINNAME))

#endif //AVR_IOHELP_H
