Files
ESP8266lib/ext/poti/MCP42xxx.h
2020-06-11 11:25:19 +02:00

34 lines
468 B
C++

#include "../../io/GPIO.h"
#include "../../Debug.h"
template <typename SPI, int PIN_CS> class MCP42xxx {
private:
SPI& spi;
public:
/** ctor */
MCP42xxx(SPI& spi) : spi(spi) {
;
}
void setVolume(const uint8_t vol) {
debugMod1(TAG, "setVolume(%d)", vol);
MyGPIO::setOutput(PIN_CS);
MyGPIO::clear(PIN_CS);
const uint8_t cmd = 0b00010011; // xx 01=write xx 11=both
spi.writeByte(cmd);
spi.writeByte(vol);
MyGPIO::set(PIN_CS);
}
};