aboutsummaryrefslogtreecommitdiff
path: root/embassy-mspm0/src/i2c.rs
diff options
context:
space:
mode:
Diffstat (limited to 'embassy-mspm0/src/i2c.rs')
-rw-r--r--embassy-mspm0/src/i2c.rs28
1 files changed, 13 insertions, 15 deletions
diff --git a/embassy-mspm0/src/i2c.rs b/embassy-mspm0/src/i2c.rs
index ce5215871..0aefd19de 100644
--- a/embassy-mspm0/src/i2c.rs
+++ b/embassy-mspm0/src/i2c.rs
@@ -56,6 +56,19 @@ pub enum ClockDiv {
56} 56}
57 57
58impl ClockDiv { 58impl ClockDiv {
59 pub(crate) fn into(self) -> vals::Ratio {
60 match self {
61 Self::DivBy1 => vals::Ratio::DIV_BY_1,
62 Self::DivBy2 => vals::Ratio::DIV_BY_2,
63 Self::DivBy3 => vals::Ratio::DIV_BY_3,
64 Self::DivBy4 => vals::Ratio::DIV_BY_4,
65 Self::DivBy5 => vals::Ratio::DIV_BY_5,
66 Self::DivBy6 => vals::Ratio::DIV_BY_6,
67 Self::DivBy7 => vals::Ratio::DIV_BY_7,
68 Self::DivBy8 => vals::Ratio::DIV_BY_8,
69 }
70 }
71
59 fn divider(self) -> u32 { 72 fn divider(self) -> u32 {
60 match self { 73 match self {
61 Self::DivBy1 => 1, 74 Self::DivBy1 => 1,
@@ -70,21 +83,6 @@ impl ClockDiv {
70 } 83 }
71} 84}
72 85
73impl From<ClockDiv> for vals::Ratio {
74 fn from(value: ClockDiv) -> Self {
75 match value {
76 ClockDiv::DivBy1 => Self::DIV_BY_1,
77 ClockDiv::DivBy2 => Self::DIV_BY_2,
78 ClockDiv::DivBy3 => Self::DIV_BY_3,
79 ClockDiv::DivBy4 => Self::DIV_BY_4,
80 ClockDiv::DivBy5 => Self::DIV_BY_5,
81 ClockDiv::DivBy6 => Self::DIV_BY_6,
82 ClockDiv::DivBy7 => Self::DIV_BY_7,
83 ClockDiv::DivBy8 => Self::DIV_BY_8,
84 }
85 }
86}
87
88/// The I2C mode. 86/// The I2C mode.
89#[derive(Clone, Copy, PartialEq, Eq, Debug)] 87#[derive(Clone, Copy, PartialEq, Eq, Debug)]
90#[cfg_attr(feature = "defmt", derive(defmt::Format))] 88#[cfg_attr(feature = "defmt", derive(defmt::Format))]