Skip to content

Commit d94905c

Browse files
authored
Update to stm32g4 v0.14.0 (#38)
1 parent ec94703 commit d94905c

File tree

5 files changed

+13
-15
lines changed

5 files changed

+13
-15
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ version = "0.0.0"
1414
[dependencies]
1515
cortex-m = "0.7.1"
1616
nb = "0.1.1"
17-
stm32g4 = "0.13.0"
17+
stm32g4 = "0.14.0"
1818
paste = "1.0"
1919
bitflags = "1.2"
2020
vcell = "0.1"

src/fdcan.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ where
522522
{
523523
I::enable(&rcc.rb);
524524

525-
if rcc.rb.ccipr.read().fdcansel() == 0 {
525+
if rcc.rb.ccipr.read().fdcansel().is_hse() {
526526
// Select P clock as FDCAN clock source
527527
rcc.rb.ccipr.modify(|_, w| {
528528
// This is sound, as `FdCanClockSource` only contains valid values for this field.
@@ -537,7 +537,7 @@ where
537537

538538
let can = Self::create_can(FdCanConfig::default(), can_instance);
539539
let reg = can.registers();
540-
assert!(reg.endn.read() == 0x87654321_u32);
540+
assert!(reg.endn.read().bits() == 0x87654321_u32);
541541
can
542542
}
543543

src/i2c.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ macro_rules! flush_txdr {
129129
($i2c:expr) => {
130130
// If a pending TXIS flag is set, write dummy data to TXDR
131131
if $i2c.isr.read().txis().bit_is_set() {
132-
$i2c.txdr.write(|w| unsafe { w.txdata().bits(0) });
132+
$i2c.txdr.write(|w| w.txdata().bits(0));
133133
}
134134

135135
// If TXDR is not flagged as empty, write 1 to flush it
@@ -219,7 +219,7 @@ macro_rules! i2c {
219219
i2c.timingr.write(|w| unsafe { w.bits(timing_bits) });
220220

221221
// Enable the I2C processing
222-
i2c.cr1.modify(|_, w| unsafe {
222+
i2c.cr1.modify(|_, w| {
223223
w.pe()
224224
.set_bit()
225225
.dnf()
@@ -264,7 +264,7 @@ macro_rules! i2c {
264264
// Set START and prepare to send `bytes`.
265265
// The START bit can be set even if the bus is BUSY or
266266
// I2C is in slave mode.
267-
self.i2c.cr2.write(|w| unsafe {
267+
self.i2c.cr2.write(|w| {
268268
w
269269
// Start transfer
270270
.start().set_bit()
@@ -286,14 +286,14 @@ macro_rules! i2c {
286286
busy_wait!(self.i2c, txis, bit_is_set);
287287

288288
// Put byte on the wire
289-
self.i2c.txdr.write(|w| unsafe { w.txdata().bits(*byte) });
289+
self.i2c.txdr.write(|w| { w.txdata().bits(*byte) });
290290
}
291291

292292
// Wait until the write finishes before beginning to read.
293293
busy_wait!(self.i2c, tc, bit_is_set);
294294

295295
// reSTART and prepare to receive bytes into `buffer`
296-
self.i2c.cr2.write(|w| unsafe {
296+
self.i2c.cr2.write(|w| {
297297
w
298298
// Start transfer
299299
.start().set_bit()
@@ -328,7 +328,7 @@ macro_rules! i2c {
328328
fn write(&mut self, addr: u8, bytes: &[u8]) -> Result<(), Self::Error> {
329329
assert!(bytes.len() < 256 && bytes.len() > 0);
330330

331-
self.i2c.cr2.modify(|_, w| unsafe {
331+
self.i2c.cr2.modify(|_, w| {
332332
w
333333
// Start transfer
334334
.start().set_bit()
@@ -348,7 +348,7 @@ macro_rules! i2c {
348348
busy_wait!(self.i2c, txis, bit_is_set);
349349

350350
// Put byte on the wire
351-
self.i2c.txdr.write(|w| unsafe { w.txdata().bits(*byte) });
351+
self.i2c.txdr.write(|w| w.txdata().bits(*byte) );
352352
}
353353

354354
// automatic STOP
@@ -371,7 +371,7 @@ macro_rules! i2c {
371371
// Set START and prepare to receive bytes into `buffer`.
372372
// The START bit can be set even if the bus
373373
// is BUSY or I2C is in slave mode.
374-
self.i2c.cr2.modify(|_, w| unsafe {
374+
self.i2c.cr2.modify(|_, w| {
375375
w
376376
// Start transfer
377377
.start().set_bit()

src/rcc/enable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ bus! {
129129
UART4 => (APB1_1, 19),
130130
I2C1 => (APB1_1, 21),
131131
I2C2 => (APB1_1, 22),
132-
USB_FS_DEVICE => (APB1_1, 23),
132+
USB => (APB1_1, 23),
133133
FDCAN1 => (APB1_1, 25),
134134
PWR => (APB1_1, 28),
135135
I2C3 => (APB1_1, 30),

src/rcc/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,7 @@ impl Rcc {
176176
let r = (pll_freq / (pll_cfg.r as u32)).hz();
177177
let q = match pll_cfg.q {
178178
Some(div) if div > 1 && div <= 8 => {
179-
self.rb
180-
.pllcfgr
181-
.write(move |w| unsafe { w.pllq().bits(div - 1) });
179+
self.rb.pllcfgr.write(move |w| w.pllq().bits(div - 1));
182180
let req = freq / div as u32;
183181
Some(req.hz())
184182
}

0 commit comments

Comments
 (0)