Skip to content

Conversation

@knifter
Copy link

@knifter knifter commented May 27, 2019

I require my device to listen to multiple slave addresses. This can be 'hacked' by directly writing the mask to the TWAMR register. But because the TwoWire library does not store the contents of the TWDR when it enters slave-receive mode I was unable to retrieve the actual address that was written to in the onReceive() handler.

I was able to incorporate both into libraries/Wire with an example and made a pull request.
I've made two changes:

  1. support for slave-address mask setting
    begin() allows for an (optional) mask parameter, which is defaulted to 0xFF.
  2. retrieving the slave address written to from Wire
    I've stored the value of TWDR when the receiver goes into TWI_SRX mode. This value can then be
    retreived with the Wire.getLastAddress() method.

I would prefer having this address passed as param in the onReceive callback or another option (as user:tinoest mentions on the forum) would be to write the slave address to the rxBuffer first. But both break backwards compatibility as it would break existing sketches.

@matthijskooijman matthijskooijman changed the title Implemented Multiple TwoWire Slave support Implemented Multiple TwoWire Slave address support Sep 6, 2019
@knifter
Copy link
Author

knifter commented Oct 28, 2019

This is not going to be merged, is it? Because I'm cleaning up my forks..

@CLAassistant
Copy link

CLAassistant commented Apr 9, 2021

CLA assistant check
All committers have signed the CLA.

@knifter
Copy link
Author

knifter commented Jan 6, 2022

I've signed the CLA several times (including last year). I've just recently discovered this commit was done with another email address. I've added those to my account and tried again and again. Sorry, can't seem to sign the CLA.

@per1234
Copy link
Contributor

per1234 commented Jan 6, 2022

Hi @knifter. Thanks so much for your pull request.

I apologize for the inconvenience with the CLA. I believe it will be resolved by doing this:

https://docs.github.com/en/pull-requests/committing-changes-to-your-project/troubleshooting-commits/why-are-my-commits-linked-to-the-wrong-user#commits-are-not-linked-to-any-user

Hopefully the check will automatically pass once that has been done. If not, please comment here and we will investigate.

@per1234
Copy link
Contributor

per1234 commented Jan 6, 2022

Aha! Please disregard my advice above. I only needed to trigger a check by the CLA bot and it is now recognized. So no additional action is required on your part for the CLA.

@Chaos02
Copy link

Chaos02 commented May 19, 2024

Hi, is this still active? is there a newer version of this?
I would also like my arduino to be able to respond to two addresses (I want to emulate a fan controller I fried and do some other stuff on the same arduino)

kind regards, I hope someone can point me in the right direction!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants