-
-
Save LuckyResistor/e55749d4948ac2aa8142f7668f9caa97 to your computer and use it in GitHub Desktop.
The implementation example for flags usage.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "TCA9548A.hpp" | |
namespace lr { | |
// ... | |
TCA9548A::Status TCA9548A::setChannel(Channel channel) | |
{ | |
if (_enabledChannels != Channels(channel)) { | |
_enabledChannels = Channels(channel); | |
return writeChannelsToChip(); | |
} | |
return Status::Success; | |
} | |
TCA9548A::Status TCA9548A::setChannels(Channels channels) | |
{ | |
if (_enabledChannels != channels) { | |
_enabledChannels = channels; | |
return writeChannelsToChip(); | |
} | |
return Status::Success; | |
} | |
TCA9548A::Status TCA9548A::clearAllChannels() | |
{ | |
if (_enabledChannels != Channels()) { | |
_enabledChannels = Channels(); | |
return writeChannelsToChip(); | |
} | |
return Status::Success; | |
} | |
TCA9548A::Status TCA9548A::writeChannelsToChip() | |
{ | |
const uint8_t data = _enabledChannels; | |
if (_wireMaster->writeBytes(_address, &data, 1) != WireMaster::Status::Success) { | |
return Status::Error; | |
} | |
return Status::Success; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment