From 0b8366c59fa0b34a70b6b453bfb0f8eaf34a2f16 Mon Sep 17 00:00:00 2001 From: manuel Date: Wed, 21 Oct 2020 15:55:29 +0200 Subject: Add Linz --- linz/oekofen_thermo/src/MCP42010.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 linz/oekofen_thermo/src/MCP42010.cpp (limited to 'linz/oekofen_thermo/src/MCP42010.cpp') diff --git a/linz/oekofen_thermo/src/MCP42010.cpp b/linz/oekofen_thermo/src/MCP42010.cpp new file mode 100644 index 0000000..aa6de2b --- /dev/null +++ b/linz/oekofen_thermo/src/MCP42010.cpp @@ -0,0 +1,21 @@ +#include "MCP42010.h" + +MCP42010::MCP42010(uint8_t ss_pin) + : _ss_pin(ss_pin), _spiset(10000000, MSBFIRST, SPI_MODE0) +{} + +void MCP42010::setup() +{ + pinMode(_ss_pin, OUTPUT); + SPI.begin(); +} + +void MCP42010::setPot(MCP42010::Poti pot, uint8_t value) +{ + SPI.beginTransaction(_spiset); + digitalWrite(_ss_pin, LOW); + SPI.transfer(0b00010000 | pot); + SPI.transfer(value); + digitalWrite(_ss_pin, HIGH); + SPI.endTransaction(); +} -- cgit v1.2.3