This commit is contained in:
2020-06-11 11:25:19 +02:00
parent 5cb02880b3
commit 5177cd5cbd
15 changed files with 1090 additions and 411 deletions

33
ext/poti/MCP42xxx.h Normal file
View File

@@ -0,0 +1,33 @@
#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);
}
};