34 lines
468 B
C++
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);
|
|
|
|
}
|
|
|
|
};
|