Skip to content

Commit

Permalink
Merge pull request #680 from stm32-rs/fix-txrx-aliases
Browse files Browse the repository at this point in the history
fix rx tx aliases
  • Loading branch information
burrbull authored Sep 16, 2023
2 parents 6a05a0e + b120fc8 commit 858163f
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 11 deletions.
19 changes: 14 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,20 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

- complete and rework Dma Stream API [#666]
- add `.set_count()` for QEI, add `.write_count()` for TIM [#677]
- add "Fast start" section in README [#678]
### Changed

- complete and rework Dma Stream API [#666]
- SPI bidi takes 2 pins [#526]

### Fixed

- fix serial RxN & TxN alises

### Added

- add `.set_count()` for QEI, add `.write_count()` for TIM [#677]
- add "Fast start" section in README [#678]

[#526]: https://github.com/stm32-rs/stm32f4xx-hal/pull/526
[#666]: https://github.com/stm32-rs/stm32f4xx-hal/pull/666
[#677]: https://github.com/stm32-rs/stm32f4xx-hal/pull/677
Expand All @@ -21,11 +30,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

### Changed

- implement `embedded_hal::blocking::i2c::Transactional` for `I2c` [#671]
- implement `embedded_hal::blocking::i2c::Transactional` for `I2c` [#671]

### Fixed

- reset timer interrupt in `Counter::start` [#670]
- reset timer interrupt in `Counter::start` [#670]

[#670]: https://github.com/stm32-rs/stm32f4xx-hal/pull/670
[#671]: https://github.com/stm32-rs/stm32f4xx-hal/pull/671
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ rtic-monotonic = { version = "1.0", optional = true }
systick-monotonic = { version = "1.0", optional = true }
bitflags = "2.2"
embedded-storage = "0.2"
vcell = "0.1.3"

[dependencies.time]
version = "0.3.14"
Expand Down
2 changes: 1 addition & 1 deletion src/serial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ impl<UART: CommonPins, WORD> Serial<UART, WORD> {
}

macro_rules! halUsart {
($USART:ty, $Serial:ident, $Tx:ident, $Rx:ident) => {
($USART:ty, $Serial:ident, $Rx:ident, $Tx:ident) => {
pub type $Serial<WORD = u8> = Serial<$USART, WORD>;
pub type $Tx<WORD = u8> = Tx<$USART, WORD>;
pub type $Rx<WORD = u8> = Rx<$USART, WORD>;
Expand Down
7 changes: 4 additions & 3 deletions src/spi.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use core::marker::PhantomData;
use core::ops::{Deref, DerefMut};
use core::ptr;

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

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

#[inline(always)]
Expand Down
2 changes: 1 addition & 1 deletion src/uart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub use embedded_hal_one::serial::ErrorKind as Error;

#[cfg(not(any(feature = "stm32f413", feature = "stm32f423",)))]
macro_rules! halUart {
($UART:ty, $Serial:ident, $Tx:ident, $Rx:ident) => {
($UART:ty, $Serial:ident, $Rx:ident, $Tx:ident) => {
pub type $Serial<WORD = u8> = Serial<$UART, WORD>;
pub type $Tx<WORD = u8> = Tx<$UART, WORD>;
pub type $Rx<WORD = u8> = Rx<$UART, WORD>;
Expand Down
2 changes: 1 addition & 1 deletion src/watchdog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl IndependentWatchdog {
fn setup(&self, timeout_ms: MilliSeconds) {
assert!(timeout_ms.ticks() < (1 << 15), "Watchdog timeout to high");
let pr = match timeout_ms.ticks() {
t if t == 0 => 0b000, // <= (MAX_PR + 1) * 4 / LSI_KHZ => 0b000,
0 => 0b000, // <= (MAX_PR + 1) * 4 / LSI_KHZ => 0b000,
t if t <= (MAX_PR + 1) * 8 / LSI_KHZ => 0b001,
t if t <= (MAX_PR + 1) * 16 / LSI_KHZ => 0b010,
t if t <= (MAX_PR + 1) * 32 / LSI_KHZ => 0b011,
Expand Down

0 comments on commit 858163f

Please sign in to comment.