Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix i2c.setup() for pins >= 32 #3600

Merged
merged 1 commit into from
May 13, 2023
Merged

Conversation

tomsci
Copy link

@tomsci tomsci commented May 1, 2023

  • This PR is for the dev branch rather than for the release branch.
  • This PR is compliant with the other contributing guidelines as well (if not, please describe why).
  • I have thoroughly tested my contribution.
  • The code changes are reflected in the documentation at docs/*.

pin_bit_mask in i2c_sw_master.c is a 64bit value and the current code shifts an int sized 1, so doesn't work for any pin numbers >= 32 because it's only shifting a 32-bit value. The upshot is software i2c doesn't work (on the default pins) on esp32s2 and later and probably some others too.

This change fixes that, by using a 64-bit 1 meaning the pin_bit_mask gets correctly set even for pin numbers above 32.

Tested on adafruit feather esp32s2 using pins 41 and 42 (Sda and Scl)

Which includes SDA and SCL on esp32s2.
@tomsci
Copy link
Author

tomsci commented May 13, 2023

Any chance you could look at this one while you're here @jmattsson? :D

@jmattsson jmattsson merged commit 4523bbb into nodemcu:dev-esp32 May 13, 2023
16 checks passed
@jmattsson
Copy link
Member

Yep! Thanks for the fix!

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

Successfully merging this pull request may close these issues.

None yet

3 participants