Skip to content

Commit

Permalink
Store last command register and avoid resending.
Browse files Browse the repository at this point in the history
  • Loading branch information
strongly-typed committed Oct 12, 2018
1 parent c3eb603 commit e2350dc
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/modm/driver/gpio/pca9548a_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ modm::Pca9548a<I2cMaster>::setActiveChannel(uint8_t channel)
RF_BEGIN();

if (channel > 7) {
RF_RETURN(false);
channel = 0;
}

Expand All @@ -46,6 +47,7 @@ modm::Pca9548a<I2cMaster>::readCommandRegister(uint8_t &command_register)

this->transaction.configureRead(buffer, 1);
command_register = buffer[0];
current_command_register = command_register;

RF_END_RETURN_CALL( this->runTransaction() );
}
Expand All @@ -56,6 +58,12 @@ modm::Pca9548a<I2cMaster>::writeCommandRegister(uint8_t command_register)
{
RF_BEGIN();

if (current_command_register == command_register) {
// No change, return without bus operation
RF_RETURN(true);
}
current_command_register = command_register;

buffer[0] = command_register;
this->transaction.configureWrite(buffer, 1);

Expand Down

0 comments on commit e2350dc

Please sign in to comment.