From 8dfb6dff868943755c9340a4a75a2a8c76a0b56f Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Wed, 26 May 2021 18:15:05 +0200 Subject: [PATCH] nrf/twim: make pullup configurable, do not enable it by default. --- embassy-nrf/src/twim.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/embassy-nrf/src/twim.rs b/embassy-nrf/src/twim.rs index 4812b353f..ea3ac7553 100644 --- a/embassy-nrf/src/twim.rs +++ b/embassy-nrf/src/twim.rs @@ -30,12 +30,16 @@ pub enum Frequency { #[non_exhaustive] pub struct Config { pub frequency: Frequency, + pub sda_pullup: bool, + pub scl_pullup: bool, } impl Default for Config { fn default() -> Self { Self { frequency: Frequency::K100, + sda_pullup: false, + scl_pullup: false, } } } @@ -61,15 +65,19 @@ impl<'d, T: Instance> Twim<'d, T> { sda.conf().write(|w| { w.dir().input(); w.input().connect(); - w.pull().pullup(); w.drive().s0d1(); + if config.sda_pullup { + w.pull().pullup(); + } w }); scl.conf().write(|w| { w.dir().input(); w.input().connect(); - w.pull().pullup(); w.drive().s0d1(); + if config.scl_pullup { + w.pull().pullup(); + } w });