more safety
shared-hal-ci / Check build (push) Has been cancelled
shared-hal-ci / Check formatting (push) Has been cancelled
shared-hal-ci / Check Documentation Build (push) Has been cancelled
shared-hal-ci / Clippy (push) Has been cancelled
va108xx-ci / Run Tests (push) Has been cancelled
va108xx-ci / Check formatting (push) Has been cancelled
va108xx-ci / Check Documentation Build (push) Has been cancelled
va108xx-ci / Clippy (push) Has been cancelled
va416xx-ci / Run Tests (push) Has been cancelled
va416xx-ci / Check formatting (push) Has been cancelled
va416xx-ci / Check Documentation Build (push) Has been cancelled
va416xx-ci / Clippy (push) Has been cancelled
shared-hal-ci / Check build (pull_request) Has been cancelled
shared-hal-ci / Check formatting (pull_request) Has been cancelled
shared-hal-ci / Check Documentation Build (pull_request) Has been cancelled
shared-hal-ci / Clippy (pull_request) Has been cancelled
va108xx-ci / Run Tests (pull_request) Has been cancelled
va108xx-ci / Check formatting (pull_request) Has been cancelled
va108xx-ci / Check Documentation Build (pull_request) Has been cancelled
va108xx-ci / Clippy (pull_request) Has been cancelled
va416xx-ci / Run Tests (pull_request) Has been cancelled
va416xx-ci / Check formatting (pull_request) Has been cancelled
va416xx-ci / Check Documentation Build (pull_request) Has been cancelled
va416xx-ci / Clippy (pull_request) Has been cancelled
va108xx-ci / Check build (push) Has been cancelled
va416xx-ci / Check build (push) Has been cancelled
va108xx-ci / Check build (pull_request) Has been cancelled
va416xx-ci / Check build (pull_request) Has been cancelled
shared-hal-ci / Check build (push) Has been cancelled
shared-hal-ci / Check formatting (push) Has been cancelled
shared-hal-ci / Check Documentation Build (push) Has been cancelled
shared-hal-ci / Clippy (push) Has been cancelled
va108xx-ci / Run Tests (push) Has been cancelled
va108xx-ci / Check formatting (push) Has been cancelled
va108xx-ci / Check Documentation Build (push) Has been cancelled
va108xx-ci / Clippy (push) Has been cancelled
va416xx-ci / Run Tests (push) Has been cancelled
va416xx-ci / Check formatting (push) Has been cancelled
va416xx-ci / Check Documentation Build (push) Has been cancelled
va416xx-ci / Clippy (push) Has been cancelled
shared-hal-ci / Check build (pull_request) Has been cancelled
shared-hal-ci / Check formatting (pull_request) Has been cancelled
shared-hal-ci / Check Documentation Build (pull_request) Has been cancelled
shared-hal-ci / Clippy (pull_request) Has been cancelled
va108xx-ci / Run Tests (pull_request) Has been cancelled
va108xx-ci / Check formatting (pull_request) Has been cancelled
va108xx-ci / Check Documentation Build (pull_request) Has been cancelled
va108xx-ci / Clippy (pull_request) Has been cancelled
va416xx-ci / Run Tests (pull_request) Has been cancelled
va416xx-ci / Check formatting (pull_request) Has been cancelled
va416xx-ci / Check Documentation Build (pull_request) Has been cancelled
va416xx-ci / Clippy (pull_request) Has been cancelled
va108xx-ci / Check build (push) Has been cancelled
va416xx-ci / Check build (push) Has been cancelled
va108xx-ci / Check build (pull_request) Has been cancelled
va416xx-ci / Check build (pull_request) Has been cancelled
This commit is contained in:
@@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
### Fixed
|
||||
|
||||
- Asynch drivers now borrow the buffers properly for the lifetime of the future.
|
||||
- Asynch UART TX driver now borrows the TX peripheral for the duration of the future.
|
||||
|
||||
## [v0.4.0] 2026-05-19
|
||||
|
||||
|
||||
@@ -113,19 +113,19 @@ impl TxContext {
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct TxFuture<'buf> {
|
||||
pub struct TxFuture<'uart, 'buf> {
|
||||
id: Bank,
|
||||
empty_buffer: bool,
|
||||
// Phantom used to borrow the buffer for the lifetime of the future.
|
||||
phantom: core::marker::PhantomData<&'buf ()>,
|
||||
phantom: core::marker::PhantomData<(&'uart (), &'buf ())>,
|
||||
}
|
||||
|
||||
impl<'buf> TxFuture<'buf> {
|
||||
impl<'uart, 'buf> TxFuture<'uart, 'buf> {
|
||||
/// # Safety
|
||||
///
|
||||
/// This function stores the raw pointer of the passed data slice. The user MUST ensure
|
||||
/// that the slice outlives the data structure.
|
||||
pub unsafe fn new(tx: &mut Tx, data: &'buf [u8]) -> Self {
|
||||
pub unsafe fn new(tx: &'uart mut Tx, data: &'buf [u8]) -> Self {
|
||||
if data.is_empty() {
|
||||
// We can just return a dummy future which is immediately ready, no need to set up
|
||||
// interrupts etc.
|
||||
@@ -168,7 +168,7 @@ impl<'buf> TxFuture<'buf> {
|
||||
}
|
||||
}
|
||||
|
||||
impl Future for TxFuture<'_> {
|
||||
impl Future for TxFuture<'_, '_> {
|
||||
type Output = Result<usize, TxOverrunError>;
|
||||
|
||||
fn poll(
|
||||
@@ -193,7 +193,7 @@ impl Future for TxFuture<'_> {
|
||||
///
|
||||
/// It is imperative that this `Drop` method is executed to avoid undefined behaviour on
|
||||
/// transfer. Do *NOT* use `core::mem::forget` on the `TxFuture`.
|
||||
impl Drop for TxFuture<'_> {
|
||||
impl Drop for TxFuture<'_, '_> {
|
||||
fn drop(&mut self) {
|
||||
let mut reg_block = unsafe { self.id.steal_regs() };
|
||||
if !TX_DONE[self.id as usize].load(core::sync::atomic::Ordering::Relaxed)
|
||||
@@ -226,7 +226,7 @@ impl TxAsync {
|
||||
///
|
||||
/// This implementation is not side effect free, and a started future might have already
|
||||
/// written part of the passed buffer.
|
||||
pub fn write<'buf>(&mut self, buf: &'buf [u8]) -> TxFuture<'buf> {
|
||||
pub fn write<'buf>(&mut self, buf: &'buf [u8]) -> TxFuture<'_, 'buf> {
|
||||
unsafe { TxFuture::new(&mut self.0, buf) }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user