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

Adding support for transactional SPI #5

Merged
merged 2 commits into from
Mar 12, 2020
Merged

Adding support for transactional SPI #5

merged 2 commits into from
Mar 12, 2020

Conversation

ryankurte
Copy link
Member

@ryankurte ryankurte commented Jan 27, 2020

Inherited from: ryankurte/rust-driver-pal#3
Blocked on: rust-embedded/embedded-hal#191

Aside, need to configure tests to use all features to enable embedded-spi/mocks only for test running

@ryankurte ryankurte merged commit 0608fda into master Mar 12, 2020
@ryankurte ryankurte deleted the spi-transactions branch March 12, 2020 01:18
@ryankurte ryankurte restored the spi-transactions branch March 12, 2020 01:40
@ryankurte ryankurte deleted the spi-transactions branch March 12, 2020 01:42
@ryankurte ryankurte restored the spi-transactions branch May 26, 2020 22:46
@ryankurte ryankurte deleted the spi-transactions branch July 13, 2020 02:22
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]>
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.

1 participant