Program Listing for File mcp3x0x.hh

Return to documentation for file (include/mcp3x0x/mcp3x0x.hh)

#ifndef IPLO_MCP3X0X_H
#define IPLO_MCP3X0X_H

#include <cstdint>

#include "spi_bus/spi.hh"

namespace iplo {

class MCP3X0X {
protected:
    std::uint8_t _channels{};
    std::int16_t _maxValue{};
    SPI& _spi;
    virtual std::uint8_t buildRequest(std::uint8_t channel, bool single, std::uint8_t* data) = 0;

    std::int16_t readAnalogValue(std::uint8_t channel, bool single);

public:
    explicit MCP3X0X(SPI& spi);

    std::int16_t analogRead(std::uint8_t channel);

    std::int16_t differentialRead(std::uint8_t channel);

    std::int16_t deltaRead(std::uint8_t channel);

    std::uint8_t channels();
};

} /* namespace iplo */

#endif /* IPLO_MCP3X0X_H */