From e704cc1193babd25db46055a6de436be687aba18 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Fri, 17 Jul 2020 15:41:13 +0200 Subject: 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. --- src/driver/mmsubstate.cc | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/driver/mmsubstate.cc (limited to 'src/driver') 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); -- cgit v1.2.3