nrf/twim: add option for high drive.
This commit is contained in:
parent
29402fa76b
commit
1a3f787932
@ -34,7 +34,9 @@ pub enum Frequency {
|
|||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
pub frequency: Frequency,
|
pub frequency: Frequency,
|
||||||
|
pub sda_high_drive: bool,
|
||||||
pub sda_pullup: bool,
|
pub sda_pullup: bool,
|
||||||
|
pub scl_high_drive: bool,
|
||||||
pub scl_pullup: bool,
|
pub scl_pullup: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,7 +44,9 @@ impl Default for Config {
|
|||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
frequency: Frequency::K100,
|
frequency: Frequency::K100,
|
||||||
|
scl_high_drive: false,
|
||||||
sda_pullup: false,
|
sda_pullup: false,
|
||||||
|
sda_high_drive: false,
|
||||||
scl_pullup: false,
|
scl_pullup: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -87,7 +91,11 @@ impl<'d, T: Instance> Twim<'d, T> {
|
|||||||
sda.conf().write(|w| {
|
sda.conf().write(|w| {
|
||||||
w.dir().input();
|
w.dir().input();
|
||||||
w.input().connect();
|
w.input().connect();
|
||||||
|
if config.sda_high_drive {
|
||||||
|
w.drive().h0d1();
|
||||||
|
} else {
|
||||||
w.drive().s0d1();
|
w.drive().s0d1();
|
||||||
|
}
|
||||||
if config.sda_pullup {
|
if config.sda_pullup {
|
||||||
w.pull().pullup();
|
w.pull().pullup();
|
||||||
}
|
}
|
||||||
@ -96,7 +104,11 @@ impl<'d, T: Instance> Twim<'d, T> {
|
|||||||
scl.conf().write(|w| {
|
scl.conf().write(|w| {
|
||||||
w.dir().input();
|
w.dir().input();
|
||||||
w.input().connect();
|
w.input().connect();
|
||||||
|
if config.scl_high_drive {
|
||||||
|
w.drive().h0d1();
|
||||||
|
} else {
|
||||||
w.drive().s0d1();
|
w.drive().s0d1();
|
||||||
|
}
|
||||||
if config.scl_pullup {
|
if config.scl_pullup {
|
||||||
w.pull().pullup();
|
w.pull().pullup();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user