diff --git a/Inc/Private/SM72445_Config.hpp b/Inc/Private/SM72445_Config.hpp index f9f1cb4..b7fc751 100644 --- a/Inc/Private/SM72445_Config.hpp +++ b/Inc/Private/SM72445_Config.hpp @@ -50,6 +50,8 @@ class SM72445_X::Config { bool panelModeOverrideEnable; // Panel Mode Override Enable bool panelModeOverride; // Panel Mode Override + bool bbReset; + bool clockOutputManualEnable; // Pin 5 Clock Output Enable bool openLoopOperation; diff --git a/Inc/Private/SM72445_ConfigBuilder.hpp b/Inc/Private/SM72445_ConfigBuilder.hpp index dc92930..cc2332c 100644 --- a/Inc/Private/SM72445_ConfigBuilder.hpp +++ b/Inc/Private/SM72445_ConfigBuilder.hpp @@ -88,9 +88,16 @@ struct SM72445_X::ConfigBuilder { */ ConfigBuilder &setPanelModeRegisterOverride(bool override); - // Config &setBbReset(bool reset); // Unsupported - // void setClockOutputManualEnable(bool enable); // Unsupported - // void setOpenLoopOperation(bool enable); // Unsupported + /** + * @brief Set the Bb Reset Bit + * + * @param reset Set bit to true or false. + * @return This ConfigBuilder. + */ + ConfigBuilder &setBbReset(bool reset); + + // ConfigBuilder setClockOutputManualEnable(bool enable); // Unsupported + // ConfigBuilder setOpenLoopOperation(bool enable); // Unsupported /** * @brief "Build" the Configuration Register. diff --git a/Inc/SM72445.hpp b/Inc/SM72445.hpp index 2176398..b83e74c 100644 --- a/Inc/SM72445.hpp +++ b/Inc/SM72445.hpp @@ -188,6 +188,11 @@ class SM72445 { */ optional getThresholdRegister(void) const; + /** + * @brief Get the I2C Device Address of this SM72445. + * + * @return DeviceAddress The I2C Device Address of this SM72445. + */ DeviceAddress getDeviceAddress(void) const; }; diff --git a/Src/SM72445_Config.cpp b/Src/SM72445_Config.cpp index 7ec075c..3a79227 100644 --- a/Src/SM72445_Config.cpp +++ b/Src/SM72445_Config.cpp @@ -30,6 +30,7 @@ Config::Config(const SM72445_X &sm72445, const Reg3 ®3) tdOn(static_cast(reg3.tdOn)), // panelModeOverrideEnable(reg3.passThroughSelect), // panelModeOverride(reg3.passThroughManual), // + bbReset(reg3.bbReset), // clockOutputManualEnable(reg3.clkOeManual), // openLoopOperation(reg3.openLoopOperation) {} @@ -105,8 +106,8 @@ ConfigBuilder &ConfigBuilder::setMaxOutputCurrentOverride(float current) { const uint16_t maxOutputCurrentAdcThreshold = current * this->sm72445.iOutGain / this->sm72445.vDDA * 0x3FFull; - if (maxOutputCurrentAdcThreshold > 0x3FFu) { - // Invalid value, exceeds settable range. Default action set to zero. + if (current < 0.0f || maxOutputCurrentAdcThreshold > 0x3FFu) { + // Invalid value, outside settable range. Default action set to zero. this->reg3.iOutMax = 0x0u; return *this; } @@ -120,8 +121,8 @@ ConfigBuilder &ConfigBuilder::setMaxOutputVoltageOverride(float voltage) { const uint16_t maxOutputVoltageAdcThreshold = voltage * this->sm72445.vOutGain / this->sm72445.vDDA * 0x3FFull; - if (maxOutputVoltageAdcThreshold > 0x3FFu) { - // Invalid value, exceeds settable range. Default action set to zero. + if (voltage < 0.0f || maxOutputVoltageAdcThreshold > 0x3FFu) { + // Invalid value, outside settable range. Default action set to zero. this->reg3.vOutMax = 0x0u; return *this; } @@ -152,6 +153,10 @@ ConfigBuilder &ConfigBuilder::setPanelModeRegisterOverride(bool override) { return *this; } +ConfigBuilder &SM72445_X::ConfigBuilder::setBbReset(bool reset) { + this->reg3.bbReset = reset; + return *this; +} SM72445::ConfigRegister ConfigBuilder::build(void) const { return ConfigRegister(Register(this->reg3)); }