diff --git a/keywords.txt b/keywords.txt index 867959d..1d78d3d 100644 --- a/keywords.txt +++ b/keywords.txt @@ -45,7 +45,7 @@ getData KEYWORD2 currentChannel KEYWORD2 internalCalibration KEYWORD2 toVoltage KEYWORD2 - +setPWRSW KEYWORD2 ####################################### # Instances (KEYWORD2) ####################################### diff --git a/src/ad7124.cpp b/src/ad7124.cpp index 50a5765..ef8ac08 100644 --- a/src/ad7124.cpp +++ b/src/ad7124.cpp @@ -218,6 +218,22 @@ Ad7124Chip::setCurrentSource (uint8_t source, uint8_t ch, IoutCurrent current) { return writeRegister (IOCon_1); } +// ----------------------------------------------------------------------------- +int +Ad7124Chip::setPWRSW(bool enabled) { + Ad7124Register * r; + + r = ®[IOCon_1]; + + r->value &= ~ AD7124_IO_CTRL1_REG_PDSW; + + if (enabled == true) { + r->value |= AD7124_IO_CTRL1_REG_PDSW; + } + + return writeRegister (IOCon_1); +} + // ----------------------------------------------------------------------------- int Ad7124Chip::setBiasPins (uint16_t pinMask) { diff --git a/src/ad7124.h b/src/ad7124.h index 3704134..cbfedc9 100644 --- a/src/ad7124.h +++ b/src/ad7124.h @@ -336,6 +336,17 @@ class Ad7124Chip { */ int setCurrentSource (uint8_t source, uint8_t ch, Ad7124::IoutCurrent current); + /** + * @brief Set state of power switch pin + * + * The AD7124-4 contains a low side switch that can be used + * to control excitation power to a bridge circuit. + * + * @param enabled State to set switch to. enabled = closed + * @return 0 for success or negative error code + */ + int setPWRSW(bool enabled) ; + /** * @brief Setting up bias voltage on AIN-Pins *