Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added default transactional spi impl #167

Closed
wants to merge 4 commits into from

Conversation

ryankurte
Copy link
Contributor

@ryankurte ryankurte commented May 26, 2020

Added transactional SPI implementation (see: rust-embedded/embedded-hal#191)

This also includes a switch from Void to Infallible to be compatible with the updated hal.

Depends on: #172
Blocked on: rust-embedded/embedded-hal#191
Notes: Remove patch prior-to-merge

Cargo.toml Outdated Show resolved Hide resolved
@ryankurte ryankurte force-pushed the feature/spi-transactions branch from 133aef1 to b4bfd53 Compare May 26, 2020 23:48
@ryankurte ryankurte force-pushed the feature/spi-transactions branch from a5a2329 to bd3cb5f Compare June 28, 2020 09:33
@ryankurte ryankurte force-pushed the feature/spi-transactions branch from 1522c6a to 61e6130 Compare July 6, 2020 06:33
@ryankurte ryankurte force-pushed the feature/spi-transactions branch from e3a3f8c to e110483 Compare July 13, 2020 12:09
bors bot added a commit to rust-embedded/embedded-hal that referenced this pull request Oct 28, 2020
191: Added transactional SPI interface r=therealprof a=ryankurte

This PR adds a transactional interface for SPI devices (#94), compatible with linux spidev.

Split from #178 as I believe this is complete and useful, but that there is more experimentation required before (if?) the I2C component is landed, check there for previous reviews / discussion.

**Demonstrated in:**
- Linux embedded hal: rust-embedded/linux-embedded-hal#35
- STM32F4xx-hal: stm32-rs/stm32f4xx-hal#167
- embedded-spi driver abstraction (previously provided a polyfill for equivalent transactional functionality) https://github.com/ryankurte/rust-embedded-spi/pull/4/files#diff-74eea42f4e5e15399ac9184c8f2727a9R344
- sx128x radio driver: rust-iot/rust-radio-sx128x#5


**Notes:**
- `Operation::Transfer` uses one buffer to allow polyfill using the existing `Transfer` trait (with the convenient side effect of reducing memory requirements)
- `W` has a static bound as it _should_ only ever be a type with static lifetime (u8, u16 etc., not a reference), and to differentiate this from `'a` which is the lifetime of the data in the object and only bound to the function
- `exec(.., &mut [Operation])` is chosen over `exec<O: AsMut<[Operation]>(..)` as the latter imposes limits on generic types using this trait (which i ran into, see [E0038](https://doc.rust-lang.org/error-index.html#E0038))

cc. @rust-embedded/hal folks, @eldruin, @RandomInsano, @Rahix, @austinglaser for opinions / review

Co-authored-by: Ryan Kurte <[email protected]>
Co-authored-by: ryan <[email protected]>
@burrbull burrbull closed this Aug 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants