Comments (8)
I think one of the main advantages from a non-destructive variant would be to allow directly passing constant data for the write. On some architectures (ARM Cortex-M, at least), the this would allow write data to be read directly out of program memory. This won't actually save memory -- since a mutable buffer of the same length would still have to be allocated -- but it might have an ergonomic benefit, and possible a correctness one (allowing more use of non-mutable data is always a win, in my book).
It would avoid the necessity of two buffer-length copies per transaction (for repeated transfers, i.e. polling). I'm hesitant to assert that this would be a large gain in performance, though, since accessing memory is nearly always much faster than the serial transaction itself.
I think it would be a reasonable addition, and simple enough to add a default implementation for as with the current blocking transfer. I may take some time to throw a proof-of-concept together and open a pull request, so we can see how we like it in practice.
from embedded-hal.
@RandomInsano You can avoid the byte_copy()
function by sub-slicing your data to an equal length slice before calling copy_from_slice()
.
from embedded-hal.
There’s thinking... thanks!
from embedded-hal.
Heh. Now, how about avoiding the copy altogether?
from embedded-hal.
I'm not really a SPI aficionado so I don't have any real world based opinion about whether that would generally be useful or more addressing of a corner case.
from embedded-hal.
Oh, yeah. No problem there @therealprof. I just re-asked to address the larger audience. If I hadn’t, people who skim usually assume this issue is addressed and move on.
A bit of detail here is that the Linux-embedded-hal is using Spidev from the kernel which itself can does save the buffer, the embedded-hal API doesn’t usually support that.
I think some data diving is required here. I’ll go skim the other crates to see who’s fought with this.
from embedded-hal.
I ended up abstracting away the ugliness, and really you’re right that memory isn’t going to be the bottleneck.
I’ll close it out if I ages out past 30 days with no real interest here.
from embedded-hal.
Closing in favour of #94
from embedded-hal.
Related Issues (20)
- 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? HOT 1
- 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?
- Shared SPI bus between devices with different SPI modes HOT 2
- The Crate Does not Compile when the `defmt-03` Feature is Enabled HOT 4
- honor `ErrorKind::Interrupted` in `write_all()`? HOT 4
- Revisiting the possibility of including generic sensor traits HOT 1
- Generic bus traits HOT 4
- e-h-async and e-io-async broken on stable due to unexpected cfg "nightly" HOT 1
- Add `BlockDevice` trait to embedded-io HOT 1
- Clarification Needed for I2C Transaction Contract
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.