diff options
| author | Dario Nieuwenhuis <[email protected]> | 2022-05-03 00:43:46 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2022-05-03 00:52:48 +0200 |
| commit | 1a3f7879321a13aa9bd42a7058eb909340fa941d (patch) | |
| tree | 4de2fff3998435d4cd9969b7639cd7c0a47b4c3b | |
| parent | 29402fa76be8088b637c21dcaaa9c3b0a1ea9f99 (diff) | |
nrf/twim: add option for high drive.
| -rw-r--r-- | embassy-nrf/src/twim.rs | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/embassy-nrf/src/twim.rs b/embassy-nrf/src/twim.rs index 9bee16f3d..298441bea 100644 --- a/embassy-nrf/src/twim.rs +++ b/embassy-nrf/src/twim.rs | |||
| @@ -34,7 +34,9 @@ pub enum Frequency { | |||
| 34 | #[non_exhaustive] | 34 | #[non_exhaustive] |
| 35 | pub struct Config { | 35 | pub struct Config { |
| 36 | pub frequency: Frequency, | 36 | pub frequency: Frequency, |
| 37 | pub sda_high_drive: bool, | ||
| 37 | pub sda_pullup: bool, | 38 | pub sda_pullup: bool, |
| 39 | pub scl_high_drive: bool, | ||
| 38 | pub scl_pullup: bool, | 40 | pub scl_pullup: bool, |
| 39 | } | 41 | } |
| 40 | 42 | ||
| @@ -42,7 +44,9 @@ impl Default for Config { | |||
| 42 | fn default() -> Self { | 44 | fn default() -> Self { |
| 43 | Self { | 45 | Self { |
| 44 | frequency: Frequency::K100, | 46 | frequency: Frequency::K100, |
| 47 | scl_high_drive: false, | ||
| 45 | sda_pullup: false, | 48 | sda_pullup: false, |
| 49 | sda_high_drive: false, | ||
| 46 | scl_pullup: false, | 50 | scl_pullup: false, |
| 47 | } | 51 | } |
| 48 | } | 52 | } |
| @@ -87,7 +91,11 @@ impl<'d, T: Instance> Twim<'d, T> { | |||
| 87 | sda.conf().write(|w| { | 91 | sda.conf().write(|w| { |
| 88 | w.dir().input(); | 92 | w.dir().input(); |
| 89 | w.input().connect(); | 93 | w.input().connect(); |
| 90 | w.drive().s0d1(); | 94 | if config.sda_high_drive { |
| 95 | w.drive().h0d1(); | ||
| 96 | } else { | ||
| 97 | w.drive().s0d1(); | ||
| 98 | } | ||
| 91 | if config.sda_pullup { | 99 | if config.sda_pullup { |
| 92 | w.pull().pullup(); | 100 | w.pull().pullup(); |
| 93 | } | 101 | } |
| @@ -96,7 +104,11 @@ impl<'d, T: Instance> Twim<'d, T> { | |||
| 96 | scl.conf().write(|w| { | 104 | scl.conf().write(|w| { |
| 97 | w.dir().input(); | 105 | w.dir().input(); |
| 98 | w.input().connect(); | 106 | w.input().connect(); |
| 99 | w.drive().s0d1(); | 107 | if config.scl_high_drive { |
| 108 | w.drive().h0d1(); | ||
| 109 | } else { | ||
| 110 | w.drive().s0d1(); | ||
| 111 | } | ||
| 100 | if config.scl_pullup { | 112 | if config.scl_pullup { |
| 101 | w.pull().pullup(); | 113 | w.pull().pullup(); |
| 102 | } | 114 | } |
