/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/* 
 * File:   DigitalIO.h
 * Author: yovany
 *
 * Created on June 19, 2018, 2:41 PM
 */

#ifndef DIGITALIO_H
#define DIGITALIO_H
#include <stdint.h>

#define AS_INPUT 0x00 //- Indicates that the IO is an Input
#define AS_OUTPUT 0x01 //- Indicates that the IO is an Output

class DigitalIO {
public:
    DigitalIO(uint8_t ioPin, uint8_t ioDir = 0x00);
    DigitalIO(const DigitalIO& orig);
    void write(uint8_t state);
    uint8_t read();
    uint8_t change();
    virtual ~DigitalIO();
    void release();
private:
    uint8_t io_pin, io_dir, prev_state;
    void asInput();
    void asOutput();
    void init();
    uint8_t bcmPin(uint8_t ioPin);
    void bcm_init();
    void bcm_end();

};

#endif /* DIGITALIO_H */

