Comments (2)
The short answer is: yes.
The long answer is: but probably not the lowest level traits because they are tailored for MCUs where non-blocking operations are retry-able without having to track state in the program (the state is in the registers). That form of non-blocking operation is covered by the nb
crate and the block!
, try_nb!
macros.
More concretely apart from the low level traits which are already in tree we want to add traits tailored for blocking operation and another set of traits for interoperation with futures. Where possible we want those traits to built on top of the existing low level traits to avoid rewriting register manipulation code in the implementation of the higher level traits.
I was originally envisioning something like this:
// write half the Serial trait we already have
trait Write<Word> {
type Error;
fn write(&self, word: Word) -> nb::Result<(), Self::Error>;
}
// Blocking write operations
trait BWrite {
type Error;
fn bwrite_all(&self, buffer: &[u8]) -> Result<(), Self::Error>;
// ..
}
// overridable blanket implementation
default impl<S> BWrite for S where S: Write<u8> {
type Error = S::Error;
fn write_all(&self, buffer: &[u8]) -> Result<(), S::Error> {
for byte in buffer {
block!(self.write(*byte))?;
}
Ok(())
}
}
However the default impl
doesn't work today because of limitations of the feature (it doesn't work when associated types are involved) which throws a wrench into my plans. However, I think I have come up with a reasonable workaround. I'll test it and send a PR to show the approach.
from embedded-hal.
Closing as this now exists in the form of the linux-embedded-hal
crate.
from embedded-hal.
Related Issues (20)
- guidance on error handling/propagation of drivers HOT 3
- Handling of parity and framing errors in embedded-io / embedded-io-async
- CAN FD support HOT 1
- unable to return error with embedded hal i2c example HOT 1
- HAL-Bus SPI Exclusive Device Unsatisfied Traits HOT 5
- i2c: Merging of consecutive operations in transaction contract
- SpiDevice's interface can't be used for streaming transactions HOT 6
- SpiDevice implementations in embedded-hal-bus don't provide a way to use active-high chip select HOT 3
- Create an I3C Trait
- Read not implemented for &mut [u8] HOT 1
- README: Links to LICENSE-APACHE and LICENSE-MIT are not found
- How do I share an I2c bus between tasks?
- Implment `Clone` for async DelayNs HOT 2
- Multipin serial spi interface trait
- embedded-hal-bus no longer builds with target thumbv6m-none-eabi HOT 5
- Split embedded-can? HOT 3
- feature request: embedded_io_async::try_read HOT 2
- Upstreaming some concepts built up in `embedded-time` HOT 1
- Why was ADC removed? HOT 2
- [Discussion] Should sensor driver developers target `embedded-hal-async` only?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from embedded-hal.