aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlf Lilleengen <[email protected]>2025-11-03 08:17:07 +0000
committerGitHub <[email protected]>2025-11-03 08:17:07 +0000
commit836b46f8df59ed22d13d11833b66397a26d89eed (patch)
tree4a2cb242c9fbc99b4fdd32551cc13ebbe32bbe56
parent7ca443734578bac0f9870b59f11adad66b4e98c7 (diff)
parent97b53b9f7a36a81b7afe9f2024de72a121ccb33d (diff)
Merge pull request #4824 from mikeytdisco/onewire_fix
Disable PIO SM before setting Y register
-rw-r--r--embassy-rp/CHANGELOG.md1
-rw-r--r--embassy-rp/src/pio_programs/onewire.rs18
2 files changed, 16 insertions, 3 deletions
diff --git a/embassy-rp/CHANGELOG.md b/embassy-rp/CHANGELOG.md
index 57ec13658..4fab20f08 100644
--- a/embassy-rp/CHANGELOG.md
+++ b/embassy-rp/CHANGELOG.md
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
15- add `wait_for_alarm` and `alarm_scheduled` methods to rtc module ([#4216](https://github.com/embassy-rs/embassy/pull/4216)) 15- add `wait_for_alarm` and `alarm_scheduled` methods to rtc module ([#4216](https://github.com/embassy-rs/embassy/pull/4216))
16- rp235x: use msplim for stack guard instead of MPU 16- rp235x: use msplim for stack guard instead of MPU
17- Add reset_to_usb_boot for rp235x ([#4705](https://github.com/embassy-rs/embassy/pull/4705)) 17- Add reset_to_usb_boot for rp235x ([#4705](https://github.com/embassy-rs/embassy/pull/4705))
18- Add fix #4822 in PIO onewire. Change to disable the state machine before setting y register ([#4824](https://github.com/embassy-rs/embassy/pull/4824))
18 19
19## 0.8.0 - 2025-08-26 20## 0.8.0 - 2025-08-26
20 21
diff --git a/embassy-rp/src/pio_programs/onewire.rs b/embassy-rp/src/pio_programs/onewire.rs
index 09babc229..3adab3b79 100644
--- a/embassy-rp/src/pio_programs/onewire.rs
+++ b/embassy-rp/src/pio_programs/onewire.rs
@@ -163,7 +163,11 @@ impl<'d, PIO: Instance, const SM: usize> PioOneWire<'d, PIO, SM> {
163 163
164 /// Write bytes to the onewire bus 164 /// Write bytes to the onewire bus
165 pub async fn write_bytes(&mut self, data: &[u8]) { 165 pub async fn write_bytes(&mut self, data: &[u8]) {
166 unsafe { self.sm.set_y(u32::MAX as u32) }; 166 unsafe {
167 self.sm.set_enable(false);
168 self.sm.set_y(u32::MAX as u32);
169 self.sm.set_enable(true);
170 }
167 let (rx, tx) = self.sm.rx_tx(); 171 let (rx, tx) = self.sm.rx_tx();
168 for b in data { 172 for b in data {
169 tx.wait_push(*b as u32).await; 173 tx.wait_push(*b as u32).await;
@@ -175,7 +179,11 @@ impl<'d, PIO: Instance, const SM: usize> PioOneWire<'d, PIO, SM> {
175 179
176 /// Write bytes to the onewire bus, then apply a strong pullup 180 /// Write bytes to the onewire bus, then apply a strong pullup
177 pub async fn write_bytes_pullup(&mut self, data: &[u8], pullup_time: embassy_time::Duration) { 181 pub async fn write_bytes_pullup(&mut self, data: &[u8], pullup_time: embassy_time::Duration) {
178 unsafe { self.sm.set_y(data.len() as u32 * 8 - 1) }; 182 unsafe {
183 self.sm.set_enable(false);
184 self.sm.set_y(data.len() as u32 * 8 - 1);
185 self.sm.set_enable(true);
186 };
179 let (rx, tx) = self.sm.rx_tx(); 187 let (rx, tx) = self.sm.rx_tx();
180 for b in data { 188 for b in data {
181 tx.wait_push(*b as u32).await; 189 tx.wait_push(*b as u32).await;
@@ -195,7 +203,11 @@ impl<'d, PIO: Instance, const SM: usize> PioOneWire<'d, PIO, SM> {
195 203
196 /// Read bytes from the onewire bus 204 /// Read bytes from the onewire bus
197 pub async fn read_bytes(&mut self, data: &mut [u8]) { 205 pub async fn read_bytes(&mut self, data: &mut [u8]) {
198 unsafe { self.sm.set_y(u32::MAX as u32) }; 206 unsafe {
207 self.sm.set_enable(false);
208 self.sm.set_y(u32::MAX as u32);
209 self.sm.set_enable(true);
210 };
199 let (rx, tx) = self.sm.rx_tx(); 211 let (rx, tx) = self.sm.rx_tx();
200 for b in data { 212 for b in data {
201 // Write all 1's so that we can read what the device responds 213 // Write all 1's so that we can read what the device responds