@@ -12,8 +12,6 @@ use crate::time::Hertz;
12
12
use cast:: { u16, u8} ;
13
13
use core:: ops:: Deref ;
14
14
15
- const MAX_NBYTE_SIZE : usize = 255 ;
16
-
17
15
/// I2C error
18
16
#[ non_exhaustive]
19
17
#[ derive( Debug ) ]
@@ -60,67 +58,6 @@ pub struct I2c<I2C, PINS> {
60
58
pins : PINS ,
61
59
}
62
60
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
-
124
61
macro_rules! hal {
125
62
( $i2c_type: ident, $enr: ident, $rstr: ident, $i2cX: ident, $i2cXen: ident, $i2cXrst: ident) => {
126
63
impl <SCL , SDA > I2c <$i2c_type, ( SCL , SDA ) > {
0 commit comments