summaryrefslogtreecommitdiff
path: root/src/driver
diff options
context:
space:
mode:
authorDaniel Friesel <daniel.friesel@uos.de>2020-07-17 15:41:13 +0200
committerDaniel Friesel <daniel.friesel@uos.de>2020-07-17 15:41:13 +0200
commite704cc1193babd25db46055a6de436be687aba18 (patch)
tree8935e59e23aee3f80232fda964bdb96f20900c80 /src/driver
parent583ece21a3484fa4a923cfcd2d3a66828485da40 (diff)
Add mmsubstate driver for sub-state detection evaluation
mmsubstate is a synthetic peripheral which uses a LED to create well-defined power sub-states in select power states.
Diffstat (limited to 'src/driver')
-rw-r--r--src/driver/mmsubstate.cc41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/driver/mmsubstate.cc b/src/driver/mmsubstate.cc
new file mode 100644
index 0000000..b701f0b
--- /dev/null
+++ b/src/driver/mmsubstate.cc
@@ -0,0 +1,41 @@
+#include "driver/mmsubstate.h"
+#if defined(MULTIPASS_ARCH_HAS_I2C) && !defined(DRIVER_SOFTI2C)
+#include "driver/i2c.h"
+#else
+#include "driver/soft_i2c.h"
+#endif
+
+void MicroMoodySubstate::setSubstates(unsigned char substateCount, unsigned char switchDuration, unsigned char power)
+{
+ txbuf[0] = substateCount;
+ txbuf[1] = power;
+ txbuf[2] = switchDuration;
+ i2c.xmit(address, 3, txbuf, 0, txbuf);
+}
+
+void MicroMoodySubstate::sleep()
+{
+ setSubstates(1, 0, 0);
+}
+
+void MicroMoodySubstate::noSubstates(unsigned char power1, unsigned char power2)
+{
+ setSubstates(1, power1, power2);
+}
+
+void MicroMoodySubstate::twoSubstates(unsigned char switchDuration, unsigned char power)
+{
+ setSubstates(2, switchDuration, power);
+}
+
+void MicroMoodySubstate::fourSubstates(unsigned char switchDuration, unsigned char power)
+{
+ setSubstates(4, switchDuration, power);
+}
+
+void MicroMoodySubstate::eightSubstates(unsigned char switchDuration, unsigned char power)
+{
+ setSubstates(8, switchDuration, power);
+}
+
+MicroMoodySubstate moody(0x11);