Skip to content

Commit

Permalink
Attempt to fix slave functionality
Browse files Browse the repository at this point in the history
 Reported in MCUdude#122
  • Loading branch information
MCUdude committed Jan 5, 2020
1 parent b5cd9c5 commit 3be80b6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions avr/libraries/Wire/src/Wire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Modified 2012 by Todd Krein (todd@krein.org) to implement repeated starts
Modified 2017 by Chuck Todd (ctodd@cableone.net) to correct Unconfigured Slave Mode reboot
*/

extern "C" {
Expand Down Expand Up @@ -60,14 +61,16 @@ void TwoWire::begin(void)
txBufferLength = 0;

twi_init();
twi_attachSlaveTxEvent(onRequestService); // default callback must exist
twi_attachSlaveRxEvent(onReceiveService); // default callback must exist
}

void TwoWire::begin(uint8_t address)
{
twi_setAddress(address);
begin();
twi_attachSlaveTxEvent(onRequestService);
twi_attachSlaveRxEvent(onReceiveService);
begin();
twi_setAddress(address);
}

void TwoWire::begin(int address)
Expand Down
7 changes: 5 additions & 2 deletions avr/libraries/Wire1/src/Wire1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Modified 2012 by Todd Krein (todd@krein.org) to implement repeated starts
Modified 2017 by Chuck Todd (ctodd@cableone.net) to correct Unconfigured Slave Mode reboot
*/

extern "C" {
Expand Down Expand Up @@ -60,14 +61,16 @@ void TwoWire1::begin(void)
txBufferLength = 0;

twi_init1();
twi_attachSlaveTxEvent1(onRequestService); // default callback must exist
twi_attachSlaveRxEvent1(onReceiveService); // default callback must exist
}

void TwoWire1::begin(uint8_t address)
{
twi_setAddress1(address);
begin();
twi_attachSlaveTxEvent1(onRequestService);
twi_attachSlaveRxEvent1(onReceiveService);
begin();
twi_setAddress1(address);
}

void TwoWire1::begin(int address)
Expand Down

0 comments on commit 3be80b6

Please sign in to comment.