Program Listing for File mcp3202.cpp
↰ Return to documentation for file (src/mcp3202.cpp
)
#include "mcp3202/mcp3202.hh"
using iplo::MCP3202;
uint8_t MCP3202::buildRequest(std::uint8_t channel, bool single, std::uint8_t* data) {
data[0] = 0x01; // start bit
data[1] = 0x20; // MSB first bit
if (single) {
data[1] |= 0x80; // single read | differential
}
if (channel) {
data[1] |= (channel << 6); // channel = 0 or 1;
}
return 3;
}
MCP3202::MCP3202(SPI& spi) : MCP3X0X(spi) {
_channels = 2;
_maxValue = 4095;
}