@@ -139,7 +139,7 @@ macro_rules! spi {
139
139
}
140
140
141
141
// disable SS output
142
- spi. cr2( ) . write( |w| w. ssoe( ) . clear_bit ( ) ) ;
142
+ spi. cr2( ) . write( |w| w. ssoe( ) . disabled ( ) ) ;
143
143
144
144
let spi_freq = speed. into( ) . raw( ) ;
145
145
let bus_freq = <$SPIX as RccBus >:: Bus :: get_frequency( & rcc. clocks) . raw( ) ;
@@ -155,8 +155,8 @@ macro_rules! spi {
155
155
_ => 0b111 ,
156
156
} ;
157
157
158
- spi. cr2( ) . write( |w| unsafe {
159
- w. frxth( ) . set_bit ( ) . ds( ) . bits ( 0b111 ) . ssoe( ) . clear_bit ( )
158
+ spi. cr2( ) . write( |w| {
159
+ w. frxth( ) . quarter ( ) . ds( ) . eight_bit ( ) . ssoe( ) . disabled ( )
160
160
} ) ;
161
161
162
162
spi. cr1( ) . write( |w| unsafe {
@@ -165,25 +165,23 @@ macro_rules! spi {
165
165
. cpol( )
166
166
. bit( mode. polarity == Polarity :: IdleHigh )
167
167
. mstr( )
168
- . set_bit ( )
168
+ . master ( )
169
169
. br( )
170
170
. bits( br)
171
171
. lsbfirst( )
172
- . clear_bit ( )
172
+ . msbfirst ( )
173
173
. ssm( )
174
- . set_bit ( )
174
+ . enabled ( )
175
175
. ssi( )
176
- . set_bit ( )
176
+ . slave_not_selected ( )
177
177
. rxonly( )
178
- . clear_bit ( )
179
- . dff ( )
180
- . clear_bit ( )
178
+ . full_duplex ( )
179
+ . crcl ( )
180
+ . eight_bit ( )
181
181
. bidimode( )
182
- . clear_bit( )
183
- . ssi( )
184
- . set_bit( )
182
+ . unidirectional( )
185
183
. spe( )
186
- . set_bit ( )
184
+ . enabled ( )
187
185
} ) ;
188
186
189
187
Spi { spi, pins }
@@ -194,7 +192,7 @@ macro_rules! spi {
194
192
}
195
193
196
194
pub fn enable_tx_dma( self ) -> Spi <$SPIX, PINS > {
197
- self . spi. cr2( ) . modify( |_, w| w. txdmaen( ) . set_bit ( ) ) ;
195
+ self . spi. cr2( ) . modify( |_, w| w. txdmaen( ) . enabled ( ) ) ;
198
196
Spi {
199
197
spi: self . spi,
200
198
pins: self . pins,
@@ -238,15 +236,17 @@ macro_rules! spi {
238
236
nb:: Error :: WouldBlock
239
237
} )
240
238
}
239
+
241
240
fn set_tx_only( & mut self ) {
242
241
self . spi
243
242
. cr1( )
244
- . modify( |_, w| w. bidimode( ) . set_bit ( ) . bidioe( ) . set_bit ( ) ) ;
243
+ . modify( |_, w| w. bidimode( ) . bidirectional ( ) . bidioe( ) . output_enabled ( ) ) ;
245
244
}
245
+
246
246
fn set_bidi( & mut self ) {
247
247
self . spi
248
248
. cr1( )
249
- . modify( |_, w| w. bidimode( ) . clear_bit ( ) . bidioe( ) . clear_bit ( ) ) ;
249
+ . modify( |_, w| w. bidimode( ) . unidirectional ( ) . bidioe( ) . output_disabled ( ) ) ;
250
250
}
251
251
}
252
252
@@ -335,7 +335,7 @@ macro_rules! spi {
335
335
// stop receiving data
336
336
self . set_tx_only( ) ;
337
337
// wait for tx fifo to be drained by the peripheral
338
- while self . spi. sr( ) . read( ) . ftlvl( ) != 0 { core:: hint:: spin_loop( ) } ;
338
+ while self . spi. sr( ) . read( ) . ftlvl( ) . is_empty ( ) { core:: hint:: spin_loop( ) } ;
339
339
// drain rx fifo
340
340
Ok ( while match self . nb_read:: <u8 >( ) {
341
341
Ok ( _) => true ,
0 commit comments