Skip to content
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions embedded-can/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Added

- `as_raw_unchecked` getter function for `Id`
- Add async API.

## [v0.4.1] - 2022-09-28

Expand Down
28 changes: 28 additions & 0 deletions embedded-can/src/asynch.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//! Async CAN API

use core::future::Future;

/// An async CAN interface that is able to transmit frames.
pub trait CanTx {
/// Associated frame type.
type Frame: crate::Frame;

/// Associated error type.
type Error: crate::Error;

/// Puts a frame in the transmit buffer or awaits until space is available
/// in the transmit buffer.
fn transmit(&mut self, frame: &Self::Frame) -> impl Future<Output = Result<(), Self::Error>>;
}

/// An async CAN interface that is able to receive frames.
pub trait CanRx {
/// Associated frame type.
type Frame: crate::Frame;

/// Associated error type.
type Error: crate::Error;

/// Awaits until a frame was received or an error occurs.
fn receive(&mut self) -> impl Future<Output = Result<Self::Frame, Self::Error>>;
}
1 change: 1 addition & 0 deletions embedded-can/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#![warn(missing_docs)]
#![no_std]

pub mod asynch;
pub mod blocking;
pub mod nb;

Expand Down