Skip to content

Commit 858163f

Browse files
authored
Merge pull request #680 from stm32-rs/fix-txrx-aliases
fix rx tx aliases
2 parents 6a05a0e + b120fc8 commit 858163f

File tree

6 files changed

+22
-11
lines changed

6 files changed

+22
-11
lines changed

CHANGELOG.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,20 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased]
99

10-
- complete and rework Dma Stream API [#666]
11-
- add `.set_count()` for QEI, add `.write_count()` for TIM [#677]
12-
- add "Fast start" section in README [#678]
10+
### Changed
11+
12+
- complete and rework Dma Stream API [#666]
1313
- SPI bidi takes 2 pins [#526]
1414

15+
### Fixed
16+
17+
- fix serial RxN & TxN alises
18+
19+
### Added
20+
21+
- add `.set_count()` for QEI, add `.write_count()` for TIM [#677]
22+
- add "Fast start" section in README [#678]
23+
1524
[#526]: https://github.com/stm32-rs/stm32f4xx-hal/pull/526
1625
[#666]: https://github.com/stm32-rs/stm32f4xx-hal/pull/666
1726
[#677]: https://github.com/stm32-rs/stm32f4xx-hal/pull/677
@@ -21,11 +30,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
2130

2231
### Changed
2332

24-
- implement `embedded_hal::blocking::i2c::Transactional` for `I2c` [#671]
33+
- implement `embedded_hal::blocking::i2c::Transactional` for `I2c` [#671]
2534

2635
### Fixed
2736

28-
- reset timer interrupt in `Counter::start` [#670]
37+
- reset timer interrupt in `Counter::start` [#670]
2938

3039
[#670]: https://github.com/stm32-rs/stm32f4xx-hal/pull/670
3140
[#671]: https://github.com/stm32-rs/stm32f4xx-hal/pull/671

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ rtic-monotonic = { version = "1.0", optional = true }
4848
systick-monotonic = { version = "1.0", optional = true }
4949
bitflags = "2.2"
5050
embedded-storage = "0.2"
51+
vcell = "0.1.3"
5152

5253
[dependencies.time]
5354
version = "0.3.14"

src/serial.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ impl<UART: CommonPins, WORD> Serial<UART, WORD> {
192192
}
193193

194194
macro_rules! halUsart {
195-
($USART:ty, $Serial:ident, $Tx:ident, $Rx:ident) => {
195+
($USART:ty, $Serial:ident, $Rx:ident, $Tx:ident) => {
196196
pub type $Serial<WORD = u8> = Serial<$USART, WORD>;
197197
pub type $Tx<WORD = u8> = Tx<$USART, WORD>;
198198
pub type $Rx<WORD = u8> = Rx<$USART, WORD>;

src/spi.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use core::marker::PhantomData;
22
use core::ops::{Deref, DerefMut};
3-
use core::ptr;
43

54
use crate::dma::traits::{DMASet, PeriAddress};
65
use crate::dma::{MemoryToPeripheral, PeripheralToMemory};
@@ -739,12 +738,14 @@ impl<SPI: Instance> Inner<SPI> {
739738
fn read_data_reg<W: FrameSize>(&mut self) -> W {
740739
// NOTE(read_volatile) read only 1 byte (the svd2rust API only allows
741740
// reading a half-word)
742-
unsafe { ptr::read_volatile(&self.spi.dr as *const _ as *const W) }
741+
unsafe { (*(&self.spi.dr as *const pac::spi1::DR).cast::<vcell::VolatileCell<W>>()).get() }
743742
}
744743

745744
fn write_data_reg<W: FrameSize>(&mut self, data: W) {
746745
// NOTE(write_volatile) see note above
747-
unsafe { ptr::write_volatile(&self.spi.dr as *const _ as *mut W, data) }
746+
unsafe {
747+
(*(&self.spi.dr as *const pac::spi1::DR).cast::<vcell::VolatileCell<W>>()).set(data)
748+
}
748749
}
749750

750751
#[inline(always)]

src/uart.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pub use embedded_hal_one::serial::ErrorKind as Error;
2525

2626
#[cfg(not(any(feature = "stm32f413", feature = "stm32f423",)))]
2727
macro_rules! halUart {
28-
($UART:ty, $Serial:ident, $Tx:ident, $Rx:ident) => {
28+
($UART:ty, $Serial:ident, $Rx:ident, $Tx:ident) => {
2929
pub type $Serial<WORD = u8> = Serial<$UART, WORD>;
3030
pub type $Tx<WORD = u8> = Tx<$UART, WORD>;
3131
pub type $Rx<WORD = u8> = Rx<$UART, WORD>;

src/watchdog.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl IndependentWatchdog {
4646
fn setup(&self, timeout_ms: MilliSeconds) {
4747
assert!(timeout_ms.ticks() < (1 << 15), "Watchdog timeout to high");
4848
let pr = match timeout_ms.ticks() {
49-
t if t == 0 => 0b000, // <= (MAX_PR + 1) * 4 / LSI_KHZ => 0b000,
49+
0 => 0b000, // <= (MAX_PR + 1) * 4 / LSI_KHZ => 0b000,
5050
t if t <= (MAX_PR + 1) * 8 / LSI_KHZ => 0b001,
5151
t if t <= (MAX_PR + 1) * 16 / LSI_KHZ => 0b010,
5252
t if t <= (MAX_PR + 1) * 32 / LSI_KHZ => 0b011,

0 commit comments

Comments
 (0)