Commit Graph

661 Commits

Author SHA1 Message Date
Dario Nieuwenhuis
9ac61a73d7 Add + ?Sized to all blanket impls. 2023-07-12 17:44:09 +02:00
Diego Barrios Romero
64b66b5abb Merge pull request #466 from rust-embedded/io
Add embedded-io, embedded-io-async, remove serial traits.
2023-07-12 15:40:14 +00:00
Dario Nieuwenhuis
7aaa585c63 Rename trait Io to ErrorType. 2023-07-12 13:26:23 +02:00
Dario Nieuwenhuis
e36386845c Apply suggestions from code review
Co-authored-by: Diego Barrios Romero <eldruin@gmail.com>
2023-07-12 13:25:39 +02:00
Dario Nieuwenhuis
5df51e56da ci: test io with std and alloc features, update nightly. 2023-07-05 00:19:27 +02:00
Dario Nieuwenhuis
31b62d3a07 io: add ReadReady, WriteReady. 2023-07-05 00:19:25 +02:00
Dario Nieuwenhuis
931dd37ad6 Remove serial traits (blocking and async). 2023-07-05 00:19:25 +02:00
Dario Nieuwenhuis
2c818b8b09 io-async: add std/alloc features, add Box/Vec impls. 2023-07-05 00:16:32 +02:00
Dario Nieuwenhuis
a105876f16 io-async: add impls for slices. 2023-07-05 00:16:32 +02:00
Dario Nieuwenhuis
d6f641995f Add embedded-io-async. 2023-07-05 00:16:32 +02:00
Dario Nieuwenhuis
1b5a858b12 io: add adapters to/from std::io. 2023-07-04 22:32:39 +02:00
Dario Nieuwenhuis
eb6e078b26 io: add std/alloc features, add Box/Vec impls. 2023-07-04 22:31:46 +02:00
Dario Nieuwenhuis
6eb30c50d1 io: add impls for slices. 2023-07-04 22:27:59 +02:00
Dario Nieuwenhuis
6e27094671 Add embedded-io. 2023-07-04 22:25:50 +02:00
Diego Barrios Romero
7e119bdb52 Merge pull request #465 from rust-embedded/release3
Release e-h 1.0-alpha.11, e-h-async 0.2-alpha.2, e-h-bus 0.1-alpha.3, e-h-nb 1.0-alpha.3
embedded-hal-async-v0.2.0-alpha.2 embedded-hal-bus-v0.1.0-alpha.3 embedded-hal-nb-v1.0.0-alpha.3 v1.0.0-alpha.11
2023-07-04 16:02:48 +00:00
Dario Nieuwenhuis
851dae5ec7 Release e-h 1.0-alpha.11, e-h-async 0.2-alpha.2, e-h-bus 0.1-alpha.3, e-h-nb v1.0-alpha.3 2023-07-04 18:00:15 +02:00
Dario Nieuwenhuis
a8ff64fadb Merge pull request #462 from Dirbaio/spi-delay
spi: add Operation::DelayUs(u32).
2023-06-20 21:43:53 +00:00
Dario Nieuwenhuis
3620083e28 Merge pull request #464 from eldruin/switch-to-ghmq
Prepare switch to GHMQ
2023-06-20 21:39:12 +00:00
Diego Barrios Romero
50cceacf46 Switch to GHMQ 2023-06-20 10:20:00 +02:00
bors[bot]
7e24e0c136 Merge #463
463: embedded-hal: digital: add #[inline] hints for PinState functions r=Dirbaio a=luojia65

Add inline hints for:

- `<PinState as Not>::not`
- `<PinState as From<bool>>::from`
- `<bool as From<PinState>>::from`

Those hints would allow further optimizations if PinState structure functions is used on embedded-hal projects.

Co-authored-by: Luo Jia / Zhouqi Jiang <luojia@hust.edu.cn>
2023-05-31 12:30:36 +00:00
Luo Jia / Zhouqi Jiang
d500bfa661 embedded-hal: digital: add #[inline] hints for PinState functions
Add inline hints for:

- <PinState as Not>::not
- <PinState as From<bool>>::from
- <bool as From<PinState>>::from

Those hints would allow further optimizations if PinState structure functions is used on embedded-hal projects.

Signed-off-by: Zhouqi Jiang <luojia@hust.edu.cn>
2023-05-31 20:17:50 +08:00
Dario Nieuwenhuis
d07d39e359 spi: add Operation::DelayUs(u32). 2023-05-24 13:59:38 +02:00
bors[bot]
30a8190703 Merge #461
461: spi: remove write-only and read-only traits. r=Dirbaio a=Dirbaio

When introducing the Bus/Device split in #351, I kept the ability to represent "read-only" and "write-only" buses, with separate `SpiBusRead`, `SpiBusWrite` buses. This didn't have much discussion, as it was the logical consequence of keeping the separation in the already existing traits (`Read`, `Write`, `Transfer`, ...).

Later, in #443, when switching from the closure-based API to the operation-slice-based API, this required adding `SpiDeviceRead`, `SpiDeviceWrite` as well, because you can no longer put a bound on the underlying bus with the new API.

This means we now have *seven* traits, which we can reduce to *two* if we drop the distinction. So, is the distinction worth it?

I've always been on the fence about it, now I'm sort of leaning towards no.

First, using write-only or read-only SPI is rare. 
- write-only SPI: for SPI displays you don't want to read from, or to abuse it to bitbang stuff like ws2812b,
- read-only SPI: some ADCs that can't be configured at all, you just clock out bits. Or even weirder abuses, like to build a logic analyzer

Second, for it to be useful HALs have to track "read-onlyness / write-onlyness" in the type signature, so a read-only SPI really only implements `SpiBusRead` and not `SpiBus`. HALs already have enough generics. For example, Embassy HALs don't implement the distinction (you can create MOSI-only or MISO-only SPIs, but they all impl the full `SpiBus`, because I didn't want to make the types carry pin information).

Third, it makes the API easier to use. Simpler, users only have to import one trait, docs have all the methods in one place. Much less boilerplate to impl the traits (look at how shorter `embedded-hal-bus` gets!).

So I think we should remove them.

Co-authored-by: Dario Nieuwenhuis <dirbaio@dirbaio.net>
2023-05-19 11:25:29 +00:00
Dario Nieuwenhuis
1567f258bf spi: remove write-only and read-only traits. 2023-05-10 22:43:52 +02:00
bors[bot]
804e1de2df Merge #456
456: spi: clarify flushing/blocking behavior. r=eldruin a=Dirbaio



Co-authored-by: Dario Nieuwenhuis <dirbaio@dirbaio.net>
2023-05-09 16:12:04 +00:00
bors[bot]
800eefdf28 Merge #457
457: embedded-can: make `StandardId::as_raw` and `ExtendedId::as_raw` const r=ryankurte a=dimpolo



Co-authored-by: dimpolo <33688001+dimpolo@users.noreply.github.com>
2023-05-04 22:23:45 +00:00
bors[bot]
1439504832 Merge #458
458: bus: Add a doc example for i2c::RefCellDevice r=Dirbaio a=tomgilligan

`embedded-hal-bus` is turning out to be very useful for something I'm working on.  It wasn't too hard to work out how to use it but it feels like an example would still be helpful here.  Not sure:

- is this the best place to put such an example?
- how much of the example should be hidden with `#`?

Co-authored-by: Thomas Gilligan <thomas.gilligan@icloud.com>
2023-05-03 16:43:00 +00:00
Thomas Gilligan
6a0c442fc9 Actually commit doc test fix 🥲 2023-05-04 01:49:06 +10:00
Thomas Gilligan
baefcf241b Put i2c bus example on struct, fix doc test 2023-05-03 20:52:23 +10:00
Thomas Gilligan
d187dc0fcb Add a doc example for i2c::RefCellDevice 2023-05-03 19:31:29 +10:00
dimpolo
215d7b4fa0 embedded-can: make StandardId::as_raw and ExtendedId::as_raw const 2023-05-02 22:20:10 +02:00
Dario Nieuwenhuis
28df44c1f7 spi: clarify flushing/blocking behavior.
Fixes #455.
2023-05-02 20:08:00 +02:00
bors[bot]
3a7c3cad28 Merge #449
449: Release e-h v1.0.0-alpha.10, e-h-async v0.2.0-alpha.1, e-h-bus v0.1.0… r=eldruin a=Dirbaio

…-alpha.2, e-h-nb v1.0.0-alpha.2.

lots of crates, whew 😅 

Co-authored-by: Dario Nieuwenhuis <dirbaio@dirbaio.net>
embedded-hal-nb-v1.0.0-alpha.2 embedded-hal-bus-v0.1.0-alpha.2 embedded-hal-async-v0.2.0-alpha.1 v1.0.0-alpha.10
2023-04-05 06:53:27 +00:00
Dario Nieuwenhuis
76c66f3799 Release e-h v1.0.0-alpha.10, e-h-async v0.2.0-alpha.1, e-h-bus v0.1.0-alpha.2, e-h-nb v1.0.0-alpha.2. 2023-04-04 22:09:17 +02:00
bors[bot]
0c98b79766 Merge #444
444: bus/spi: add RefCell, CriticalSection and Mutex shared bus implementations. r=eldruin a=Dirbaio

Requires #443 

This adds a few bus sharing implementations, with varying tradeoffs:
- `RefCellDevice`: single thread only
- `CriticalSectionDevice`: thread-safe, coarse locking, nostd.
- `MutexDevice`: thread-safe, fine-grained locking, std only.

Co-authored-by: Dario Nieuwenhuis <dirbaio@dirbaio.net>
2023-04-01 09:05:22 +00:00
Dario Nieuwenhuis
756b05519e spi: Add changelog for transaction changes. 2023-04-01 10:52:48 +02:00
Dario Nieuwenhuis
76541e0766 bus/spi: add RefCell, CriticalSection and Mutex shared bus implementations. 2023-04-01 10:50:42 +02:00
bors[bot]
a8ea55f888 Merge #443
443: spi: make SpiDevice transaction take an operation slice instead of a closure. r=eldruin a=Dirbaio

As discussed in [today's WG meeting](https://matrix.to/#/!BHcierreUuwCMxVqOf:matrix.org/$l3MzRbzKQ0LGOops0ioYfM2kEr6-eT7ODboDj9iiCfY?via=matrix.org&via=psion.agg.io&via=tchncs.de).

- Fixes https://github.com/rust-embedded/linux-embedded-hal/issues/87
- Gets rid of the cursed borrow issues in async.
- Makes the trait more consistent with I2C.


Co-authored-by: Dario Nieuwenhuis <dirbaio@dirbaio.net>
2023-04-01 07:01:16 +00:00
Dario Nieuwenhuis
b6764ecd57 spi: SpiDevice transactiontake an operation slice instead of a closure. 2023-03-28 14:41:54 +02:00
bors[bot]
8aaa48b6d3 Merge #448
448: Misc doc fixes. r=eldruin a=Dirbaio

- Switch from GAT to AFIT has already happened.
- We're no longer planning to integrate EHA into EH
- Fix all broken links.

Co-authored-by: Dario Nieuwenhuis <dirbaio@dirbaio.net>
2023-03-28 12:28:57 +00:00
Dario Nieuwenhuis
0584ebe8fb Misc doc fixes. 2023-03-28 13:57:56 +02:00
bors[bot]
a0f24262f7 Merge #445
445: bus/i2c: add RefCell, CriticalSection and Mutex shared bus implementations. r=eldruin a=Dirbaio

Requires #440 

Same as #443 but for I2C.


This adds a few bus sharing implementations, with varying tradeoffs:
- `RefCellDevice`: single thread only
- `CriticalSectionDevice`: thread-safe, coarse locking, nostd.
- `MutexDevice`: thread-safe, fine-grained locking, std only.

Co-authored-by: Dario Nieuwenhuis <dirbaio@dirbaio.net>
2023-03-28 11:45:54 +00:00
Dario Nieuwenhuis
16ac2e68df bus: update docs, document features. 2023-03-28 13:31:11 +02:00
Dario Nieuwenhuis
37a8e614f0 bus/i2c: add RefCell, CriticalSection and Mutex shared bus implementations. 2023-03-28 13:13:42 +02:00
bors[bot]
1d74e8927d Merge #440
440: I2c: simplify, expand docs, document shared bus usage. r=eldruin a=Dirbaio

~Depends on #441 -- check that one out first.~

This does some simplifications to the trait that I think we should do:

- Implement all methods in terms of `transaction`. This way HALs have to implement just that.
- Removed byte-wise-iteration methods: `write_iter` and `write_iter_read`. The reason is that they're quite inefficient, especially with DMA implementations. We've already removed these on other traits, so I think we should do as well here.
- Removed `transaction_iter`. I don't think it's much useful in practice, because the way iterators work all the yielded `Operation`s must have the same lifetime. This means that, even if the user can generate the `Operation`s on the fly, they can't allocate buffers for these on the fly, all buffers must be pre-allocated. So it's not useful for, say, streaming a large transfer by reusing some small buffer repeatedly. See #367 
- Removed useless lifetimes
- Standardized buffer names on `read` and `write`, I think they're clearer.

It also specifies how i2c bus sharing is supposed to work. This is an alternative to #392 . After the discussions there, I don't think we should split I2C into Bus and Device anymore. For SPI it makes sense, because drivers want to enforce that there's a CS pin (`SpiDevice`) or not (`SpiBus`). This is not the case with I2C, the API is exactly the same in the shared and non-shared case. Drivers shouldn't care which case it is.

So all we have to do to "support" bus sharing is docs, This PR does:

- Document that it's allowed for implementations to be either shared or not.
- Document some guidelines for drivers and HALs on how to best use the traits, expand the examples.


Co-authored-by: Dario Nieuwenhuis <dirbaio@dirbaio.net>
2023-03-28 06:59:51 +00:00
bors[bot]
3250073f96 Merge #446
446: Update changelog after #442 r=Dirbaio a=eldruin

This was forgotten in #442 

Co-authored-by: Diego Barrios Romero <eldruin@gmail.com>
2023-03-15 11:16:22 +00:00
Dario Nieuwenhuis
7b42f2430f i2c: changelog. 2023-03-15 12:08:28 +01:00
Dario Nieuwenhuis
147aee2ffc I2c: expand docs, document shared bus usage. 2023-03-15 12:07:17 +01:00
Dario Nieuwenhuis
8b984d299a i2c: implement all operations in terms of transaction. 2023-03-15 12:07:17 +01:00
Dario Nieuwenhuis
f644e8225f i2c: rename args to write/read. 2023-03-15 12:07:17 +01:00