Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
The implementation example for flags usage.
#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