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

Enabling and disabling the TWIM instance #266

Merged
merged 6 commits into from
Nov 20, 2020
Merged

Enabling and disabling the TWIM instance #266

merged 6 commits into from
Nov 20, 2020

Conversation

hannes-hochreiner
Copy link
Contributor

When a new TWIM instance is created, it is automatically enabled. This is very convenient in normal use. For a low power sensor, I found myself in the situation that I needed to deactivate (and later reactivate) the instance in order to safe energy. The simplest way I found to do this, was to add the "enable" and "disable" functions to the instance.

Please let me know, whether you would like to integrate this change into the main branch.

@Dirbaio
Copy link
Member

Dirbaio commented Nov 20, 2020

+1 to this! I have done hacks with unsafe in my project to do this from outside the hal, having it in the hal would be very nice!

  • Maybe there should be some safety against trying to do transfers while disabled?
  • For more power saving, disconnect the sda/scl pins on disable (dir=input, input=disconnected), and connect them again on enable.

Copy link
Contributor

@jonas-schievink jonas-schievink left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this looks reasonable!

nrf-hal-common/src/twim.rs Outdated Show resolved Hide resolved
nrf-hal-common/src/twim.rs Show resolved Hide resolved
@jonas-schievink jonas-schievink merged commit 195aef5 into nrf-rs:master Nov 20, 2020
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.

3 participants