Skip to content

Commit 598fb34

Browse files
authored
Merge pull request #260 from richard7770/Cross-clocked-USART
USART1 connects to PCLK1.
2 parents ee27f32 + b47f14b commit 598fb34

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
3232
features, can no longer be disabled. ([#259])
3333
1. The "unproven" features are no longer unproven and used anywhere anyways.
3434
2. This crate was not building successfully without the unproven feature.
35+
- Set the correct baud rate for chips where `USART1SW_A::PCLK` leads to a
36+
baud rate derived from PCLK1, rather than the ports own bus clock, PCLK2.
37+
([#260])
3538

3639
### Breaking Changes
3740

@@ -367,6 +370,7 @@ let clocks = rcc
367370
[defmt]: https://github.com/knurling-rs/defmt
368371
[filter]: https://defmt.ferrous-systems.com/filtering.html
369372

373+
[#260]: https://github.com/stm32-rs/stm32f3xx-hal/pull/260
370374
[#259]: https://github.com/stm32-rs/stm32f3xx-hal/pull/259
371375
[#257]: https://github.com/stm32-rs/stm32f3xx-hal/pull/257
372376
[#255]: https://github.com/stm32-rs/stm32f3xx-hal/pull/255

src/serial.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -869,8 +869,22 @@ macro_rules! usart_var_clock {
869869
}
870870

871871
cfg_if::cfg_if! {
872-
if #[cfg(any(feature = "svd-f301", feature = "svd-f3x4"))] {
873-
usart_var_clock!([(1,2)]);
872+
if #[cfg(any(
873+
feature = "stm32f301x6",
874+
feature = "stm32f301x8",
875+
feature = "stm32f318x8",
876+
feature = "stm32f302x6",
877+
feature = "stm32f302x8",
878+
feature = "stm32f303x6",
879+
feature = "stm32f303x8",
880+
feature = "stm32f328x8",
881+
feature = "stm32f334x4",
882+
feature = "stm32f334x6",
883+
feature = "stm32f334x8",
884+
))] {
885+
// USART1 is accessed through APB2,
886+
// but USART1SW_A::PCLK will connect its phy to PCLK1.
887+
usart_var_clock!([(1,1)]);
874888
// These are uart peripherals, where the only clock source
875889
// is the PCLK (peripheral clock).
876890
usart_static_clock!([(2,1), (3,1)]);

0 commit comments

Comments
 (0)