Skip to content

Commit 158315f

Browse files
authored
Merge pull request #232 from stm32-rs/i2c-cleanup
I2C warning cleanup
2 parents 34fc0c3 + 6041742 commit 158315f

File tree

1 file changed

+0
-63
lines changed

1 file changed

+0
-63
lines changed

src/i2c.rs

-63
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ use crate::time::Hertz;
1212
use cast::{u16, u8};
1313
use core::ops::Deref;
1414

15-
const MAX_NBYTE_SIZE: usize = 255;
16-
1715
/// I2C error
1816
#[non_exhaustive]
1917
#[derive(Debug)]
@@ -60,67 +58,6 @@ pub struct I2c<I2C, PINS> {
6058
pins: PINS,
6159
}
6260

63-
// TODO review why StartCondition and State structs exists. Last
64-
// update to them was november 2020
65-
/// Start conditions that govern repeated sequential transfer
66-
#[derive(Debug, Clone)]
67-
enum StartCondition {
68-
/// Non-sequential transfer. Generate both start and stop.
69-
FirstAndLast,
70-
/// First transfer in a sequence. Generate start and reload for the next.
71-
First,
72-
/// In the middle of sequential transfer. No start/stop generation.
73-
Middle,
74-
/// Generate stop to terminate the sequence.
75-
Last,
76-
}
77-
78-
impl StartCondition {
79-
/// Configures the I2C sequential transfer
80-
fn config<'a>(&self, w: &'a mut i2c1::cr2::W) -> &'a mut i2c1::cr2::W {
81-
use StartCondition::*;
82-
match self {
83-
FirstAndLast => w.start().start().autoend().automatic(),
84-
First => w.start().start().reload().not_completed(),
85-
Middle => w.start().no_start().reload().not_completed(),
86-
Last => w.start().no_start().autoend().automatic(),
87-
}
88-
}
89-
}
90-
91-
/// Yields start/stop direction from chunks of a payload
92-
#[derive(Debug, Default, Clone)]
93-
struct State {
94-
total_length: usize,
95-
current_length: Option<usize>,
96-
}
97-
98-
impl State {
99-
fn new(total_length: usize) -> Self {
100-
Self {
101-
total_length,
102-
current_length: None,
103-
}
104-
}
105-
106-
fn start_condition(&mut self, chunk_len: usize) -> StartCondition {
107-
use StartCondition::*;
108-
let total_len = self.total_length;
109-
match self.current_length.as_mut() {
110-
None if chunk_len == total_len => FirstAndLast,
111-
None => {
112-
self.current_length.replace(chunk_len);
113-
First
114-
}
115-
Some(len) if *len + chunk_len < total_len => {
116-
*len += chunk_len;
117-
Middle
118-
}
119-
Some(_) => Last,
120-
}
121-
}
122-
}
123-
12461
macro_rules! hal {
12562
($i2c_type: ident, $enr: ident, $rstr: ident, $i2cX: ident, $i2cXen: ident, $i2cXrst: ident) => {
12663
impl<SCL, SDA> I2c<$i2c_type, (SCL, SDA)> {

0 commit comments

Comments
 (0)