#pragma once
#ifndef OV7725_REG_BUF_H
#define OV7725_REG_BUF_H

#include <mbed.h>
#include "OV7725RegAddr.h"

#define WRITE_DEFAULT_REG_ON
#define WRITE_ORIGIN_REG_ON

namespace SW
{
    class Core;
}

class OV7725RegBuf
{
public:
    OV7725RegBuf(SW::Core & core);
    
    ~OV7725RegBuf();
    
    uint8_t * GetData();
    
    static bool IsAddressReserved(const uint8_t addr);
    
    //Blocking method. Do not use during the running state!!
    void SCCBWrite(const uint8_t RegAddr, uint8_t Data);
    
    //Blocking method. Do not use during the running state!!
    uint8_t SCCBRead(const uint8_t RegAddr);
    
    //Blocking method. Do not use during the running state!!
    void ReadRegisters();
    
#ifdef WRITE_DEFAULT_REG_ON
    void WriteDefaultRegisters();
#endif
    
#ifdef WRITE_ORIGIN_REG_ON
    void WriteOriginalRegisters();
#endif
    
private:
    uint8_t * m_data;
    
    SW::Core & m_core;
    
    I2C m_sccbCtrl;
};

#endif //OV7725_REG_BUF_H