diff options
| -rw-r--r-- | embassy-nrf/src/twim.rs | 12 |
1 files 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 { | |||
| 30 | #[non_exhaustive] | 30 | #[non_exhaustive] |
| 31 | pub struct Config { | 31 | pub struct Config { |
| 32 | pub frequency: Frequency, | 32 | pub frequency: Frequency, |
| 33 | pub sda_pullup: bool, | ||
| 34 | pub scl_pullup: bool, | ||
| 33 | } | 35 | } |
| 34 | 36 | ||
| 35 | impl Default for Config { | 37 | impl Default for Config { |
| 36 | fn default() -> Self { | 38 | fn default() -> Self { |
| 37 | Self { | 39 | Self { |
| 38 | frequency: Frequency::K100, | 40 | frequency: Frequency::K100, |
| 41 | sda_pullup: false, | ||
| 42 | scl_pullup: false, | ||
| 39 | } | 43 | } |
| 40 | } | 44 | } |
| 41 | } | 45 | } |
| @@ -61,15 +65,19 @@ impl<'d, T: Instance> Twim<'d, T> { | |||
| 61 | sda.conf().write(|w| { | 65 | sda.conf().write(|w| { |
| 62 | w.dir().input(); | 66 | w.dir().input(); |
| 63 | w.input().connect(); | 67 | w.input().connect(); |
| 64 | w.pull().pullup(); | ||
| 65 | w.drive().s0d1(); | 68 | w.drive().s0d1(); |
| 69 | if config.sda_pullup { | ||
| 70 | w.pull().pullup(); | ||
| 71 | } | ||
| 66 | w | 72 | w |
| 67 | }); | 73 | }); |
| 68 | scl.conf().write(|w| { | 74 | scl.conf().write(|w| { |
| 69 | w.dir().input(); | 75 | w.dir().input(); |
| 70 | w.input().connect(); | 76 | w.input().connect(); |
| 71 | w.pull().pullup(); | ||
| 72 | w.drive().s0d1(); | 77 | w.drive().s0d1(); |
| 78 | if config.scl_pullup { | ||
| 79 | w.pull().pullup(); | ||
| 80 | } | ||
| 73 | w | 81 | w |
| 74 | }); | 82 | }); |
| 75 | 83 | ||
