???
This commit is contained in:
33
ext/poti/MCP42xxx.h
Normal file
33
ext/poti/MCP42xxx.h
Normal 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);
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user