Program Listing for File mcp3204.cpp
↰ Return to documentation for file (src/mcp3204.cpp
)
#include "mcp3204/mcp3204.hh"
using iplo::MCP3204;
uint8_t MCP3204::buildRequest(std::uint8_t channel, bool single, std::uint8_t* data) {
data[0] = 0x04; // start bit
if (single) {
data[0] |= 0x02; // single read | differential
}
if (channel > 3) {
data[0] |= 0x01; // msb channel (D2)
}
if (channel) {
data[1] |= (channel << 6); // other 2 bits (D1 D0)
}
return 3;
}
MCP3204::MCP3204(SPI& spi) : MCP3X0X(spi) {
_channels = 4;
_maxValue = 4095;
}