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