summaryrefslogtreecommitdiffstats
path: root/linz/oekofen_thermo/src/MCP42010.cpp
diff options
context:
space:
mode:
authormanuel <manuel@mausz.at>2020-10-21 15:55:29 +0200
committermanuel <manuel@mausz.at>2020-10-21 15:55:43 +0200
commit0b8366c59fa0b34a70b6b453bfb0f8eaf34a2f16 (patch)
treeb48edc08ae3c8d430c04539e3bb90eff8e5e493d /linz/oekofen_thermo/src/MCP42010.cpp
parentf46e8a7126b879b3c7d24ffa6b9fa2cf66089f8c (diff)
downloadarduino-0b8366c59fa0b34a70b6b453bfb0f8eaf34a2f16.tar.gz
arduino-0b8366c59fa0b34a70b6b453bfb0f8eaf34a2f16.tar.bz2
arduino-0b8366c59fa0b34a70b6b453bfb0f8eaf34a2f16.zip
Add Linz
Diffstat (limited to 'linz/oekofen_thermo/src/MCP42010.cpp')
-rw-r--r--linz/oekofen_thermo/src/MCP42010.cpp21
1 files changed, 21 insertions, 0 deletions
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 @@
1#include "MCP42010.h"
2
3MCP42010::MCP42010(uint8_t ss_pin)
4 : _ss_pin(ss_pin), _spiset(10000000, MSBFIRST, SPI_MODE0)
5{}
6
7void MCP42010::setup()
8{
9 pinMode(_ss_pin, OUTPUT);
10 SPI.begin();
11}
12
13void MCP42010::setPot(MCP42010::Poti pot, uint8_t value)
14{
15 SPI.beginTransaction(_spiset);
16 digitalWrite(_ss_pin, LOW);
17 SPI.transfer(0b00010000 | pot);
18 SPI.transfer(value);
19 digitalWrite(_ss_pin, HIGH);
20 SPI.endTransaction();
21}