Skip to content

Enabling and disabling the TWIM instance#266

Merged
jonas-schievink merged 6 commits intonrf-rs:masterfrom
hannes-hochreiner:master
Nov 20, 2020
Merged

Enabling and disabling the TWIM instance#266
jonas-schievink merged 6 commits intonrf-rs:masterfrom
hannes-hochreiner:master

Conversation

@hannes-hochreiner
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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!

Comment thread nrf-hal-common/src/twim.rs Outdated
Comment thread nrf-hal-common/src/twim.rs
@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