Skip to content

Commit 49632de

Browse files
authored
stm32g4-staging v0.22.0 (#190)
1 parent 0ac9098 commit 49632de

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ version = "0.0.2"
1313

1414
[dependencies]
1515
nb = "1"
16-
stm32g4 = { version = "0.21.0", package = "stm32g4-staging" }
16+
stm32g4 = { version = "0.22.0", package = "stm32g4-staging" }
1717
paste = "1.0"
1818
bitflags = "1.2"
1919
vcell = "0.1"

src/adc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1840,7 +1840,7 @@ macro_rules! adc {
18401840
self.config.difsel = df;
18411841

18421842
self.adc_reg.difsel().modify(|_, w| {
1843-
for i in 0..18 {
1843+
for i in 0..19 {
18441844
w.difsel(i).bit(df.get_channel(i).into());
18451845
}
18461846
w

src/spi.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ macro_rules! spi {
139139
}
140140

141141
// disable SS output
142-
spi.cr2().write(|w| w.ssoe().clear_bit());
142+
spi.cr2().write(|w| w.ssoe().disabled());
143143

144144
let spi_freq = speed.into().raw();
145145
let bus_freq = <$SPIX as RccBus>::Bus::get_frequency(&rcc.clocks).raw();
@@ -155,8 +155,8 @@ macro_rules! spi {
155155
_ => 0b111,
156156
};
157157

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()
160160
});
161161

162162
spi.cr1().write(|w| unsafe {
@@ -165,25 +165,23 @@ macro_rules! spi {
165165
.cpol()
166166
.bit(mode.polarity == Polarity::IdleHigh)
167167
.mstr()
168-
.set_bit()
168+
.master()
169169
.br()
170170
.bits(br)
171171
.lsbfirst()
172-
.clear_bit()
172+
.msbfirst()
173173
.ssm()
174-
.set_bit()
174+
.enabled()
175175
.ssi()
176-
.set_bit()
176+
.slave_not_selected()
177177
.rxonly()
178-
.clear_bit()
179-
.dff()
180-
.clear_bit()
178+
.full_duplex()
179+
.crcl()
180+
.eight_bit()
181181
.bidimode()
182-
.clear_bit()
183-
.ssi()
184-
.set_bit()
182+
.unidirectional()
185183
.spe()
186-
.set_bit()
184+
.enabled()
187185
});
188186

189187
Spi { spi, pins }
@@ -194,7 +192,7 @@ macro_rules! spi {
194192
}
195193

196194
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());
198196
Spi {
199197
spi: self.spi,
200198
pins: self.pins,
@@ -238,15 +236,17 @@ macro_rules! spi {
238236
nb::Error::WouldBlock
239237
})
240238
}
239+
241240
fn set_tx_only(&mut self) {
242241
self.spi
243242
.cr1()
244-
.modify(|_, w| w.bidimode().set_bit().bidioe().set_bit());
243+
.modify(|_, w| w.bidimode().bidirectional().bidioe().output_enabled());
245244
}
245+
246246
fn set_bidi(&mut self) {
247247
self.spi
248248
.cr1()
249-
.modify(|_, w| w.bidimode().clear_bit().bidioe().clear_bit());
249+
.modify(|_, w| w.bidimode().unidirectional().bidioe().output_disabled());
250250
}
251251
}
252252

@@ -335,7 +335,7 @@ macro_rules! spi {
335335
// stop receiving data
336336
self.set_tx_only();
337337
// 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() };
339339
// drain rx fifo
340340
Ok(while match self.nb_read::<u8>() {
341341
Ok(_) => true,

0 commit comments

Comments
 (0)