#ifndef VIPCORE_HPP_
#define VIPCORE_HPP_

#include <io.h>

class Vipcore
{
public:

    static const int GO = 0;
    static const int STATUS = 1;

    Vipcore(long base_address) : base_address(base_address)
    {}

    void stop(bool is_blocking)
    {
        do_write(GO,0);
        bool is_running = is_blocking;
        while(is_running)
        {
            is_running = this->is_running();
        }
    }

    void start()
    {
        do_write(GO, 1);
    }

    bool is_running()
    {
        return do_read(STATUS) & 0x1;
    }
    
protected:
    void do_write(int offset, int value)
    {
        IOWR(this->base_address, offset, value);
    }
    
    int do_read(int offset)
    {
        return IORD(base_address, offset);
    }
    
    long base_address; 
    
};

#endif /*VIPCORE_HPP_*/
