From 6718872aed4f3d23d9903ce92da3a1bd849d3c6b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 8 Dec 2025 15:03:08 +0100 Subject: [PATCH] added steal API for RxWithInterrupt --- vorago-shared-hal/CHANGELOG.md | 7 +++++++ vorago-shared-hal/src/uart/mod.rs | 12 ++++++++++++ 2 files changed, 19 insertions(+) diff --git a/vorago-shared-hal/CHANGELOG.md b/vorago-shared-hal/CHANGELOG.md index 432a211..da85f39 100644 --- a/vorago-shared-hal/CHANGELOG.md +++ b/vorago-shared-hal/CHANGELOG.md @@ -8,6 +8,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [unreleased] +### Added + +### Changed + +- Added `RxWithInterrupt::steal`. +- Improved type level support for resource management for SPI, PWM, UART. + ## [v0.2.0] 2025-09-03 Renamed to `vorago-shared-hal` diff --git a/vorago-shared-hal/src/uart/mod.rs b/vorago-shared-hal/src/uart/mod.rs index 8f7181c..6ef5515 100644 --- a/vorago-shared-hal/src/uart/mod.rs +++ b/vorago-shared-hal/src/uart/mod.rs @@ -1306,6 +1306,18 @@ impl RxWithInterrupt { Self(rx) } + /// Steal the RX peripheral with interrupt support for the given UART bank. + /// + /// Can be useful to retrieve an instance in an interrupt if this instance is not used in the + /// main thread after initialization time. + /// + /// # Safety + /// + /// Circumvents the HAL ownership and safety guarantees. + pub unsafe fn steal(id: Bank) -> Self { + Self(unsafe { Rx::steal(id) }) + } + /// This function should be called once at initialization time if the regular /// [Self::on_interrupt] is used to read the UART receiver to enable and start the receiver. pub fn start(&mut self) {