aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Allen <[email protected]>2025-03-07 10:41:36 -0500
committerGitHub <[email protected]>2025-03-07 10:41:36 -0500
commit5e3cfc7b5c3b0dbadb37870462741d6b417cf028 (patch)
treefb8910f376b975cc687261e6e6a72ae8777ccd72
parent91d8175f6270530203b073d754ea1200243dc08f (diff)
parent7c49f482d71d594d7b48c3393cc98d03a9e7c9e2 (diff)
Merge branch 'embassy-rs:main' into stm32-pwm-pin-config
-rw-r--r--README.md1
-rw-r--r--cyw43-pio/src/lib.rs13
-rw-r--r--docs/pages/hal.adoc2
-rw-r--r--docs/pages/overview.adoc1
-rw-r--r--embassy-rp/src/pio/mod.rs10
-rw-r--r--embassy-rp/src/pio_programs/hd44780.rs4
-rw-r--r--embassy-rp/src/pio_programs/i2s.rs2
-rw-r--r--embassy-rp/src/pio_programs/ws2812.rs2
-rw-r--r--embassy-stm32/src/usart/mod.rs5
-rw-r--r--embassy-stm32/src/usart/ringbuffered.rs13
-rw-r--r--examples/rp/src/bin/pio_dma.rs4
-rw-r--r--examples/rp235x/src/bin/pio_dma.rs4
12 files changed, 42 insertions, 19 deletions
diff --git a/README.md b/README.md
index 374133c4b..ee5c42245 100644
--- a/README.md
+++ b/README.md
@@ -18,6 +18,7 @@ Rust's <a href="https://rust-lang.github.io/async-book/">async/await</a> allows
18 - <a href="https://github.com/esp-rs">esp-rs</a>, for the Espressif Systems ESP32 series of chips. 18 - <a href="https://github.com/esp-rs">esp-rs</a>, for the Espressif Systems ESP32 series of chips.
19 - Embassy HAL support for Espressif chips, as well as Async WiFi, Bluetooth and ESP-NOW, is being developed in the [esp-rs/esp-hal](https://github.com/esp-rs/esp-hal) repository. 19 - Embassy HAL support for Espressif chips, as well as Async WiFi, Bluetooth and ESP-NOW, is being developed in the [esp-rs/esp-hal](https://github.com/esp-rs/esp-hal) repository.
20 - <a href="https://github.com/ch32-rs/ch32-hal">ch32-hal</a>, for the WCH 32-bit RISC-V(CH32V) series of chips. 20 - <a href="https://github.com/ch32-rs/ch32-hal">ch32-hal</a>, for the WCH 32-bit RISC-V(CH32V) series of chips.
21 - <a href="https://github.com/AlexCharlton/mpfs-hal">mpfs-hal</a>, for the Microchip PolarFire SoC.
21 22
22- **Time that Just Works** - 23- **Time that Just Works** -
23No more messing with hardware timers. <a href="https://docs.embassy.dev/embassy-time">embassy_time</a> provides Instant, Duration and Timer types that are globally available and never overflow. 24No more messing with hardware timers. <a href="https://docs.embassy.dev/embassy-time">embassy_time</a> provides Instant, Duration and Timer types that are globally available and never overflow.
diff --git a/cyw43-pio/src/lib.rs b/cyw43-pio/src/lib.rs
index d0d504395..c1b301547 100644
--- a/cyw43-pio/src/lib.rs
+++ b/cyw43-pio/src/lib.rs
@@ -169,12 +169,12 @@ where
169 169
170 self.sm.set_enable(true); 170 self.sm.set_enable(true);
171 171
172 self.sm.tx().dma_push(self.dma.reborrow(), write).await; 172 self.sm.tx().dma_push(self.dma.reborrow(), write, false).await;
173 173
174 let mut status = 0; 174 let mut status = 0;
175 self.sm 175 self.sm
176 .rx() 176 .rx()
177 .dma_pull(self.dma.reborrow(), slice::from_mut(&mut status)) 177 .dma_pull(self.dma.reborrow(), slice::from_mut(&mut status), false)
178 .await; 178 .await;
179 status 179 status
180 } 180 }
@@ -201,13 +201,16 @@ where
201 // self.cs.set_low(); 201 // self.cs.set_low();
202 self.sm.set_enable(true); 202 self.sm.set_enable(true);
203 203
204 self.sm.tx().dma_push(self.dma.reborrow(), slice::from_ref(&cmd)).await; 204 self.sm
205 self.sm.rx().dma_pull(self.dma.reborrow(), read).await; 205 .tx()
206 .dma_push(self.dma.reborrow(), slice::from_ref(&cmd), false)
207 .await;
208 self.sm.rx().dma_pull(self.dma.reborrow(), read, false).await;
206 209
207 let mut status = 0; 210 let mut status = 0;
208 self.sm 211 self.sm
209 .rx() 212 .rx()
210 .dma_pull(self.dma.reborrow(), slice::from_mut(&mut status)) 213 .dma_pull(self.dma.reborrow(), slice::from_mut(&mut status), false)
211 .await; 214 .await;
212 215
213 #[cfg(feature = "defmt")] 216 #[cfg(feature = "defmt")]
diff --git a/docs/pages/hal.adoc b/docs/pages/hal.adoc
index 14b85e1f1..e1a29751e 100644
--- a/docs/pages/hal.adoc
+++ b/docs/pages/hal.adoc
@@ -12,3 +12,5 @@ async traits in `embedded-hal` and `embedded-hal-async`. You can also use these
12For the ESP32 series, there is an link:https://github.com/esp-rs/esp-hal[esp-hal] which you can use. 12For the ESP32 series, there is an link:https://github.com/esp-rs/esp-hal[esp-hal] which you can use.
13 13
14For the WCH 32-bit RISC-V series, there is an link:https://github.com/ch32-rs/ch32-hal[ch32-hal], which you can use. 14For the WCH 32-bit RISC-V series, there is an link:https://github.com/ch32-rs/ch32-hal[ch32-hal], which you can use.
15
16For the Microchip PolarFire SoC, there is link:https://github.com/AlexCharlton/mpfs-hal[mpfs-hal]. \ No newline at end of file
diff --git a/docs/pages/overview.adoc b/docs/pages/overview.adoc
index a1bf180cd..9b93ba10c 100644
--- a/docs/pages/overview.adoc
+++ b/docs/pages/overview.adoc
@@ -31,6 +31,7 @@ The Embassy project maintains HALs for select hardware, but you can still use HA
31* link:https://docs.embassy.dev/embassy-rp/[embassy-rp], for the Raspberry Pi RP2040 microcontroller. 31* link:https://docs.embassy.dev/embassy-rp/[embassy-rp], for the Raspberry Pi RP2040 microcontroller.
32* link:https://github.com/esp-rs[esp-rs], for the Espressif Systems ESP32 series of chips. 32* link:https://github.com/esp-rs[esp-rs], for the Espressif Systems ESP32 series of chips.
33* link:https://github.com/ch32-rs/ch32-hal[ch32-hal], for the WCH 32-bit RISC-V(CH32V) series of chips. 33* link:https://github.com/ch32-rs/ch32-hal[ch32-hal], for the WCH 32-bit RISC-V(CH32V) series of chips.
34* link:https://github.com/AlexCharlton/mpfs-hal[mpfs-hal], for the Microchip PolarFire SoC.
34 35
35NOTE: A common question is if one can use the Embassy HALs standalone. Yes, it is possible! There are no dependency on the executor within the HALs. You can even use them without async, 36NOTE: A common question is if one can use the Embassy HALs standalone. Yes, it is possible! There are no dependency on the executor within the HALs. You can even use them without async,
36as they implement both the link:https://github.com/rust-embedded/embedded-hal[Embedded HAL] blocking and async traits. 37as they implement both the link:https://github.com/rust-embedded/embedded-hal[Embedded HAL] blocking and async traits.
diff --git a/embassy-rp/src/pio/mod.rs b/embassy-rp/src/pio/mod.rs
index 880d6effd..fd09d4bba 100644
--- a/embassy-rp/src/pio/mod.rs
+++ b/embassy-rp/src/pio/mod.rs
@@ -362,6 +362,7 @@ impl<'d, PIO: Instance, const SM: usize> StateMachineRx<'d, PIO, SM> {
362 &'a mut self, 362 &'a mut self,
363 ch: PeripheralRef<'a, C>, 363 ch: PeripheralRef<'a, C>,
364 data: &'a mut [W], 364 data: &'a mut [W],
365 bswap: bool,
365 ) -> Transfer<'a, C> { 366 ) -> Transfer<'a, C> {
366 let pio_no = PIO::PIO_NO; 367 let pio_no = PIO::PIO_NO;
367 let p = ch.regs(); 368 let p = ch.regs();
@@ -379,6 +380,7 @@ impl<'d, PIO: Instance, const SM: usize> StateMachineRx<'d, PIO, SM> {
379 w.set_chain_to(ch.number()); 380 w.set_chain_to(ch.number());
380 w.set_incr_read(false); 381 w.set_incr_read(false);
381 w.set_incr_write(true); 382 w.set_incr_write(true);
383 w.set_bswap(bswap);
382 w.set_en(true); 384 w.set_en(true);
383 }); 385 });
384 compiler_fence(Ordering::SeqCst); 386 compiler_fence(Ordering::SeqCst);
@@ -447,7 +449,12 @@ impl<'d, PIO: Instance, const SM: usize> StateMachineTx<'d, PIO, SM> {
447 } 449 }
448 450
449 /// Prepare a DMA transfer to TX FIFO. 451 /// Prepare a DMA transfer to TX FIFO.
450 pub fn dma_push<'a, C: Channel, W: Word>(&'a mut self, ch: PeripheralRef<'a, C>, data: &'a [W]) -> Transfer<'a, C> { 452 pub fn dma_push<'a, C: Channel, W: Word>(
453 &'a mut self,
454 ch: PeripheralRef<'a, C>,
455 data: &'a [W],
456 bswap: bool,
457 ) -> Transfer<'a, C> {
451 let pio_no = PIO::PIO_NO; 458 let pio_no = PIO::PIO_NO;
452 let p = ch.regs(); 459 let p = ch.regs();
453 p.read_addr().write_value(data.as_ptr() as u32); 460 p.read_addr().write_value(data.as_ptr() as u32);
@@ -464,6 +471,7 @@ impl<'d, PIO: Instance, const SM: usize> StateMachineTx<'d, PIO, SM> {
464 w.set_chain_to(ch.number()); 471 w.set_chain_to(ch.number());
465 w.set_incr_read(true); 472 w.set_incr_read(true);
466 w.set_incr_write(false); 473 w.set_incr_write(false);
474 w.set_bswap(bswap);
467 w.set_en(true); 475 w.set_en(true);
468 }); 476 });
469 compiler_fence(Ordering::SeqCst); 477 compiler_fence(Ordering::SeqCst);
diff --git a/embassy-rp/src/pio_programs/hd44780.rs b/embassy-rp/src/pio_programs/hd44780.rs
index 70129318b..6997b91f3 100644
--- a/embassy-rp/src/pio_programs/hd44780.rs
+++ b/embassy-rp/src/pio_programs/hd44780.rs
@@ -173,7 +173,7 @@ impl<'l, P: Instance, const S: usize> PioHD44780<'l, P, S> {
173 sm.set_enable(true); 173 sm.set_enable(true);
174 174
175 // display on and cursor on and blinking, reset display 175 // display on and cursor on and blinking, reset display
176 sm.tx().dma_push(dma.reborrow(), &[0x81u8, 0x0f, 1]).await; 176 sm.tx().dma_push(dma.reborrow(), &[0x81u8, 0x0f, 1], false).await;
177 177
178 Self { 178 Self {
179 dma: dma.map_into(), 179 dma: dma.map_into(),
@@ -198,6 +198,6 @@ impl<'l, P: Instance, const S: usize> PioHD44780<'l, P, S> {
198 // set cursor to 1:15 198 // set cursor to 1:15
199 self.buf[38..].copy_from_slice(&[0x80, 0xcf]); 199 self.buf[38..].copy_from_slice(&[0x80, 0xcf]);
200 200
201 self.sm.tx().dma_push(self.dma.reborrow(), &self.buf).await; 201 self.sm.tx().dma_push(self.dma.reborrow(), &self.buf, false).await;
202 } 202 }
203} 203}
diff --git a/embassy-rp/src/pio_programs/i2s.rs b/embassy-rp/src/pio_programs/i2s.rs
index a7b4f46a6..17e321405 100644
--- a/embassy-rp/src/pio_programs/i2s.rs
+++ b/embassy-rp/src/pio_programs/i2s.rs
@@ -90,6 +90,6 @@ impl<'a, P: Instance, const S: usize> PioI2sOut<'a, P, S> {
90 90
91 /// Return an in-prograss dma transfer future. Awaiting it will guarentee a complete transfer. 91 /// Return an in-prograss dma transfer future. Awaiting it will guarentee a complete transfer.
92 pub fn write<'b>(&'b mut self, buff: &'b [u32]) -> Transfer<'b, AnyChannel> { 92 pub fn write<'b>(&'b mut self, buff: &'b [u32]) -> Transfer<'b, AnyChannel> {
93 self.sm.tx().dma_push(self.dma.reborrow(), buff) 93 self.sm.tx().dma_push(self.dma.reborrow(), buff, false)
94 } 94 }
95} 95}
diff --git a/embassy-rp/src/pio_programs/ws2812.rs b/embassy-rp/src/pio_programs/ws2812.rs
index 875f0209f..2462a64e6 100644
--- a/embassy-rp/src/pio_programs/ws2812.rs
+++ b/embassy-rp/src/pio_programs/ws2812.rs
@@ -111,7 +111,7 @@ impl<'d, P: Instance, const S: usize, const N: usize> PioWs2812<'d, P, S, N> {
111 } 111 }
112 112
113 // DMA transfer 113 // DMA transfer
114 self.sm.tx().dma_push(self.dma.reborrow(), &words).await; 114 self.sm.tx().dma_push(self.dma.reborrow(), &words, false).await;
115 115
116 Timer::after_micros(55).await; 116 Timer::after_micros(55).await;
117 } 117 }
diff --git a/embassy-stm32/src/usart/mod.rs b/embassy-stm32/src/usart/mod.rs
index de7b3c8df..568067360 100644
--- a/embassy-stm32/src/usart/mod.rs
+++ b/embassy-stm32/src/usart/mod.rs
@@ -85,6 +85,7 @@ unsafe fn on_interrupt(r: Regs, s: &'static State) {
85 85
86 compiler_fence(Ordering::SeqCst); 86 compiler_fence(Ordering::SeqCst);
87 s.rx_waker.wake(); 87 s.rx_waker.wake();
88 s.tx_waker.wake();
88} 89}
89 90
90#[derive(Clone, Copy, PartialEq, Eq, Debug)] 91#[derive(Clone, Copy, PartialEq, Eq, Debug)]
@@ -592,7 +593,7 @@ async fn flush(info: &Info, state: &State) -> Result<(), Error> {
592 593
593 // future which completes when Transmission complete is detected 594 // future which completes when Transmission complete is detected
594 let abort = poll_fn(move |cx| { 595 let abort = poll_fn(move |cx| {
595 state.rx_waker.register(cx.waker()); 596 state.tx_waker.register(cx.waker());
596 597
597 let sr = sr(r).read(); 598 let sr = sr(r).read();
598 if sr.tc() { 599 if sr.tc() {
@@ -2019,6 +2020,7 @@ enum Kind {
2019 2020
2020struct State { 2021struct State {
2021 rx_waker: AtomicWaker, 2022 rx_waker: AtomicWaker,
2023 tx_waker: AtomicWaker,
2022 tx_rx_refcount: AtomicU8, 2024 tx_rx_refcount: AtomicU8,
2023} 2025}
2024 2026
@@ -2026,6 +2028,7 @@ impl State {
2026 const fn new() -> Self { 2028 const fn new() -> Self {
2027 Self { 2029 Self {
2028 rx_waker: AtomicWaker::new(), 2030 rx_waker: AtomicWaker::new(),
2031 tx_waker: AtomicWaker::new(),
2029 tx_rx_refcount: AtomicU8::new(0), 2032 tx_rx_refcount: AtomicU8::new(0),
2030 } 2033 }
2031 } 2034 }
diff --git a/embassy-stm32/src/usart/ringbuffered.rs b/embassy-stm32/src/usart/ringbuffered.rs
index 560ce4e8f..3631888e4 100644
--- a/embassy-stm32/src/usart/ringbuffered.rs
+++ b/embassy-stm32/src/usart/ringbuffered.rs
@@ -8,12 +8,12 @@ use embassy_hal_internal::PeripheralRef;
8use embedded_io_async::ReadReady; 8use embedded_io_async::ReadReady;
9use futures_util::future::{select, Either}; 9use futures_util::future::{select, Either};
10 10
11use super::{ 11use super::{rdr, reconfigure, set_baudrate, sr, Config, ConfigError, Error, Info, State, UartRx};
12 clear_interrupt_flags, rdr, reconfigure, set_baudrate, sr, Config, ConfigError, Error, Info, State, UartRx,
13};
14use crate::dma::ReadableRingBuffer; 12use crate::dma::ReadableRingBuffer;
15use crate::gpio::{AnyPin, SealedPin as _}; 13use crate::gpio::{AnyPin, SealedPin as _};
16use crate::mode::Async; 14use crate::mode::Async;
15#[cfg(any(usart_v3, usart_v4))]
16use crate::pac::usart::regs;
17use crate::time::Hertz; 17use crate::time::Hertz;
18use crate::usart::{Regs, Sr}; 18use crate::usart::{Regs, Sr};
19 19
@@ -254,7 +254,12 @@ fn clear_idle_flag(r: Regs) -> Sr {
254 254
255 // This read also clears the error and idle interrupt flags on v1. 255 // This read also clears the error and idle interrupt flags on v1.
256 unsafe { rdr(r).read_volatile() }; 256 unsafe { rdr(r).read_volatile() };
257 clear_interrupt_flags(r, sr); 257 #[cfg(any(usart_v3, usart_v4))]
258 {
259 let mut clear_idle = regs::Icr(0);
260 clear_idle.set_idle(true);
261 r.icr().write_value(clear_idle);
262 }
258 263
259 r.cr1().modify(|w| w.set_idleie(true)); 264 r.cr1().modify(|w| w.set_idleie(true));
260 265
diff --git a/examples/rp/src/bin/pio_dma.rs b/examples/rp/src/bin/pio_dma.rs
index d00ed2142..da6e47a1b 100644
--- a/examples/rp/src/bin/pio_dma.rs
+++ b/examples/rp/src/bin/pio_dma.rs
@@ -72,8 +72,8 @@ async fn main(_spawner: Spawner) {
72 loop { 72 loop {
73 let (rx, tx) = sm.rx_tx(); 73 let (rx, tx) = sm.rx_tx();
74 join( 74 join(
75 tx.dma_push(dma_out_ref.reborrow(), &dout), 75 tx.dma_push(dma_out_ref.reborrow(), &dout, false),
76 rx.dma_pull(dma_in_ref.reborrow(), &mut din), 76 rx.dma_pull(dma_in_ref.reborrow(), &mut din, false),
77 ) 77 )
78 .await; 78 .await;
79 for i in 0..din.len() { 79 for i in 0..din.len() {
diff --git a/examples/rp235x/src/bin/pio_dma.rs b/examples/rp235x/src/bin/pio_dma.rs
index d00ed2142..da6e47a1b 100644
--- a/examples/rp235x/src/bin/pio_dma.rs
+++ b/examples/rp235x/src/bin/pio_dma.rs
@@ -72,8 +72,8 @@ async fn main(_spawner: Spawner) {
72 loop { 72 loop {
73 let (rx, tx) = sm.rx_tx(); 73 let (rx, tx) = sm.rx_tx();
74 join( 74 join(
75 tx.dma_push(dma_out_ref.reborrow(), &dout), 75 tx.dma_push(dma_out_ref.reborrow(), &dout, false),
76 rx.dma_pull(dma_in_ref.reborrow(), &mut din), 76 rx.dma_pull(dma_in_ref.reborrow(), &mut din, false),
77 ) 77 )
78 .await; 78 .await;
79 for i in 0..din.len() { 79 for i in 0..din.len() {