Skip to content

Commit 72e8f70

Browse files
committed
Merge branch 'master' into prove-inputpin
2 parents 7f059f2 + 96f8f61 commit 72e8f70

21 files changed

+489
-178
lines changed

.github/CODEOWNERS

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @rust-embedded/hal @ilya-epifanov @thejpster

.github/bors.toml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
block_labels = ["needs-decision"]
2+
delete_merged_branches = true
3+
required_approvals = 1
4+
status = ["continuous-integration/travis-ci/push"]

.travis.yml

+14-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,20 @@ language: rust
22

33
matrix:
44
include:
5+
- env: TARGET=x86_64-unknown-linux-gnu
6+
if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master)
7+
8+
- env: TARGET=thumbv6m-none-eabi
9+
rust: beta
10+
if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master)
11+
12+
- env: TARGET=thumbv7m-none-eabi
13+
rust: beta
14+
if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master)
15+
516
- env: TARGET=x86_64-unknown-linux-gnu
617
rust: nightly
18+
if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master)
719

820
before_install: set -e
921

@@ -25,9 +37,9 @@ before_cache:
2537

2638
branches:
2739
only:
28-
- auto
2940
- master
30-
- try
41+
- staging
42+
- trying
3143

3244
notifications:
3345
email:

CHANGELOG.md

+39-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,42 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased]
99

10+
## [v0.2.1] - 2018-05-14
11+
12+
### Changed
13+
14+
- Auto-generated documentation (docs.rs) now includes the unproven traits.
15+
16+
## [v0.2.0] - 2018-05-12
17+
18+
### Added
19+
20+
- A `ToggeableOutputPin` trait has been added. This trait contains a single method: `toggle` that
21+
can be used to toggle the state of a push-pull pin.
22+
23+
### Changed
24+
25+
- [breaking-change] The signature of `CountDown.wait` changed; it now returns `nb::Result<(),
26+
Void>`. Where [`Void`] is the stable alternative to the never type, `!`, provided by the stable
27+
[`void`] crate. Implementations of the `CountDown` trait will have to be updated to use the new
28+
signature. With this change this crate compiles on the stable and beta channels.
29+
30+
[`Void`]: https://docs.rs/void/1.0.2/void/enum.Void.html
31+
[`void`]: https://crates.io/crates/void
32+
33+
- [breaking-change] the `OutputPin.is_{low,high}` methods have been moved into its own trait
34+
`StatefulOutputPin` and renamed to `is_set_{low,high}`.
35+
36+
- It has been clarified in the documentation that `OutputPin` must be implemented for push-pull
37+
output pins (and e.g. not for open drain output pins).
38+
39+
## [v0.1.3] - 2018-05-14
40+
41+
### Changed
42+
43+
- Re-export most / unchanged traits from embedded-hal v0.2.x to allow inter-operation between HAL
44+
implementations and drivers that are using different minor versions.
45+
1046
## [v0.1.2] - 2018-02-14
1147

1248
### Added
@@ -23,6 +59,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
2359

2460
Initial release
2561

26-
[Unreleased]: https://github.com/japaric/embedded-hal/compare/v0.1.2...HEAD
62+
[Unreleased]: https://github.com/japaric/embedded-hal/compare/v0.2.1...HEAD
63+
[v0.2.1]: https://github.com/japaric/embedded-hal/compare/v0.2.0...v0.2.1
64+
[v0.2.0]: https://github.com/japaric/embedded-hal/compare/v0.1.2...v0.2.0
2765
[v0.1.2]: https://github.com/japaric/embedded-hal/compare/v0.1.1...v0.1.2
2866
[v0.1.1]: https://github.com/japaric/embedded-hal/compare/v0.1.0...v0.1.1

CODE_OF_CONDUCT.md

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# The Rust Code of Conduct
2+
3+
## Conduct
4+
5+
**Contact**: [HAL team][team]
6+
7+
* We are committed to providing a friendly, safe and welcoming environment for all, regardless of level of experience, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, religion, nationality, or other similar characteristic.
8+
* On IRC, please avoid using overtly sexual nicknames or other nicknames that might detract from a friendly, safe and welcoming environment for all.
9+
* Please be kind and courteous. There's no need to be mean or rude.
10+
* Respect that people have differences of opinion and that every design or implementation choice carries a trade-off and numerous costs. There is seldom a right answer.
11+
* Please keep unstructured critique to a minimum. If you have solid ideas you want to experiment with, make a fork and see how it works.
12+
* We will exclude you from interaction if you insult, demean or harass anyone. That is not welcome behavior. We interpret the term "harassment" as including the definition in the [Citizen Code of Conduct](http://citizencodeofconduct.org/); if you have any lack of clarity about what might be included in that concept, please read their definition. In particular, we don't tolerate behavior that excludes people in socially marginalized groups.
13+
* Private harassment is also unacceptable. No matter who you are, if you feel you have been or are being harassed or made uncomfortable by a community member, please contact one of the channel ops or any of the [HAL team][team] immediately. Whether you're a regular contributor or a newcomer, we care about making this community a safe place for you and we've got your back.
14+
* Likewise any spamming, trolling, flaming, baiting or other attention-stealing behavior is not welcome.
15+
16+
## Moderation
17+
18+
These are the policies for upholding our community's standards of conduct.
19+
20+
1. Remarks that violate the Rust standards of conduct, including hateful, hurtful, oppressive, or exclusionary remarks, are not allowed. (Cursing is allowed, but never targeting another user, and never in a hateful manner.)
21+
2. Remarks that moderators find inappropriate, whether listed in the code of conduct or not, are also not allowed.
22+
3. Moderators will first respond to such remarks with a warning.
23+
4. If the warning is unheeded, the user will be "kicked," i.e., kicked out of the communication channel to cool off.
24+
5. If the user comes back and continues to make trouble, they will be banned, i.e., indefinitely excluded.
25+
6. Moderators may choose at their discretion to un-ban the user if it was a first offense and they offer the offended party a genuine apology.
26+
7. If a moderator bans someone and you think it was unjustified, please take it up with that moderator, or with a different moderator, **in private**. Complaints about bans in-channel are not allowed.
27+
8. Moderators are held to a higher standard than other community members. If a moderator creates an inappropriate situation, they should expect less leeway than others.
28+
29+
In the Rust community we strive to go the extra step to look out for each other. Don't just aim to be technically unimpeachable, try to be your best self. In particular, avoid flirting with offensive or sensitive issues, particularly if they're off-topic; this all too often leads to unnecessary fights, hurt feelings, and damaged trust; worse, it can drive people away from the community entirely.
30+
31+
And if someone takes issue with something you said or did, resist the urge to be defensive. Just stop doing what it was they complained about and apologize. Even if you feel you were misinterpreted or unfairly accused, chances are good there was something you could've communicated better — remember that it's your responsibility to make your fellow Rustaceans comfortable. Everyone wants to get along and we are all here first and foremost because we want to talk about cool technology. You will find that people will be eager to assume good intent and forgive as long as you earn their trust.
32+
33+
The enforcement policies listed above apply to all official embedded WG venues; including official IRC channels (#rust-embedded); GitHub repositories under rust-embedded; and all forums under rust-embedded.org (forum.rust-embedded.org).
34+
35+
*Adapted from the [Node.js Policy on Trolling](http://blog.izs.me/post/30036893703/policy-on-trolling) as well as the [Contributor Covenant v1.3.0](https://www.contributor-covenant.org/version/1/3/0/).*
36+
37+
[team]: https://github.com/rust-embedded/wg#the-hal-team

Cargo.toml

+8-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ license = "MIT OR Apache-2.0"
1111
name = "embedded-hal"
1212
readme = "README.md"
1313
repository = "https://github.com/japaric/embedded-hal"
14-
version = "0.1.2"
14+
version = "0.2.1"
15+
16+
[dependencies.void]
17+
default-features = false
18+
version = "1.0.2"
1519

1620
[dependencies.nb]
1721
version = "0.1.1"
@@ -22,3 +26,6 @@ futures = "0.1.17"
2226

2327
[features]
2428
unproven = ["nb/unstable"]
29+
30+
[package.metadata.docs.rs]
31+
features = ["unproven"]

README.md

+15-91
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
> A Hardware Abstraction Layer (HAL) for embedded systems
44
5+
This project is developed and maintained by the [HAL team][team].
6+
57
## [API reference]
68

79
[API reference]: https://docs.rs/embedded-hal
@@ -51,99 +53,12 @@ Issues used to track unproven APIs will be labeled as `unproven-api`s in the iss
5153
may also include the labels `needs-impl` and `needs-driver` to signal what's required for them to
5254
move to the set of proven traits.
5355

54-
## Implementations
55-
56-
These are (WIP) implementations of `embedded-hal` for various platforms. Feel free to send a PR
57-
adding yours to the list!
58-
59-
You may be able to find even more implementations by searching for the [`embedded-hal-impl`] keyword
60-
an crates.io. If you publish a `embedded-hal` implementation to crates.io please use that keyword to
61-
let others more easily find your crate!
62-
63-
[`embedded-hal-impl`]: https://crates.io/keywords/embedded-hal-driver
64-
65-
### Linux
66-
67-
- [`linux-embedded-hal`]. For the Raspberry Pi and other SBC that expose pins with embedded
68-
functionality (SPI, I2C, etc.)
69-
70-
[`linux-embedded-hal`]: https://crates.io/crates/linux-embedded-hal
71-
72-
### Nordic
73-
74-
- [`nrf51-hal`]. Check the [`microbit`] crate for examples that can be run on the [micro:bit]
75-
76-
[`nrf51-hal`]: https://crates.io/crates/nrf51-hal
77-
[`microbit`]: https://crates.io/crates/microbit
78-
[micro:bit]: http://microbit.org/
79-
80-
### NXP
81-
82-
- [`lpc82x-hal`]
83-
84-
[`lpc82x-hal`]: https://github.com/braun-robotics/rust-lpc82x-hal
85-
86-
### ST Microelectronics
87-
88-
- [`stm32f103xx-hal`]. Contains examples that can be run on the [Blue pill] and similar boards.
89-
90-
[`stm32f103xx-hal`]: https://github.com/japaric/stm32f103xx-hal
91-
[Blue pill]: wiki.stm32duino.com/index.php?title=Blue_Pill
92-
93-
- [`stm32f30x-hal`]. Check the [`f3`] crate for examples that can be run on the STM32F3DISCOVERY.
94-
95-
[`stm32f30x-hal`]: https://crates.io/crates/stm32f30x-hal
96-
[`f3`]: https://crates.io/crates/f3
97-
98-
### Texas Instruments
99-
100-
- [`tm4c123x-hal`]
101-
102-
[`tm4c123x-hal`]: https://github.com/thejpster/tm4c123x-hal
56+
## Implementations and drivers
10357

104-
## Drivers
58+
For a list of `embedded-hal` implementations and driver crates check the [awesome-embedded-rust]
59+
list.
10560

106-
These are (WIP) platform agnostic drivers that can be used with any of the above implementations to
107-
interface all sort of external devices like sensors and actuators. Feel free to send a PR adding
108-
yours to the list!
109-
110-
You may be able to find even more implementations by searching for the [`embedded-hal-driver`]
111-
keyword an crates.io. If you publish a driver to crates.io please use that keyword to let others
112-
more easily find your crate!
113-
114-
- [`l3gd20`]. Gyroscope
115-
116-
[`l3gd20`]: https://crates.io/crates/l3gd20
117-
118-
- [`lsm303dlhc`]. Accelerometer + compass
119-
120-
[`lsm303dlhc`]: https://crates.io/crates/lsm303dlhc
121-
122-
- [`mag3110`]. Magnetometer
123-
124-
[`mag3110`]: https://crates.io/crates/mag3110
125-
126-
- [`mfrc522`].` RFID reader / writer
127-
128-
[`mfrc522`]: https://crates.io/crates/mfrc522
129-
130-
- [`motor-driver`]. Motor drivers like the L298N and the TB6612FNG
131-
132-
[`motor-driver`]: https://github.com/japaric/motor-driver
133-
134-
- [`mpu9250`]. Accelerometer + gyroscope + magnetometer IMU
135-
136-
[`mpu9250`]: https://github.com/japaric/mpu9250
137-
138-
- [`si5351`]. Clock generator
139-
140-
[`si5351`]: https://github.com/ilya-epifanov/si5351
141-
142-
- [`si7021`]. Humidity and temperature sensor
143-
144-
[`si7021`]: https://github.com/wose/si7021
145-
146-
[`embedded-hal-driver`]: https://crates.io/keywords/embedded-hal-driver
61+
[awesome-embedded-rust]: https://github.com/rust-embedded/awesome-embedded-rust#driver-crates
14762

14863
## License
14964

@@ -160,3 +75,12 @@ at your option.
16075
Unless you explicitly state otherwise, any contribution intentionally submitted
16176
for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
16277
dual licensed as above, without any additional terms or conditions.
78+
79+
## Code of Conduct
80+
81+
Contribution to this crate is organized under the terms of the [Rust Code of
82+
Conduct][CoC], the maintainer of this crate, the [HAL team][team], promises
83+
to intervene to uphold that code of conduct.
84+
85+
[CoC]: CODE_OF_CONDUCT.md
86+
[team]: https://github.com/rust-embedded/wg#the-hal-team

ci/after_success.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ main() {
1515
echo OK
1616
}
1717

18-
if [ $TRAVIS_BRANCH = master ]; then
18+
if [ "$TRAVIS_EVENT_TYPE" == "push" ] && [ "$TRAVIS_BRANCH" == "master" ]; then
1919
main
2020
fi

ci/install.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
set -euxo pipefail
22

33
main() {
4-
return
4+
if [ $TARGET != x86_64-unknown-linux-gnu ]; then
5+
rustup target add $TARGET
6+
fi
57
}
68

79
main

ci/script.sh

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ set -euxo pipefail
22

33
main() {
44
cargo check --target $TARGET
5-
cargo test --target $TARGET --features unproven
5+
cargo check --target $TARGET --features unproven
6+
7+
if [ $TRAVIS_RUST_VERSION = nightly ]; then
8+
cargo test --target $TARGET --features unproven
9+
fi
610
}
711

812
main

src/blocking/i2c.rs

+47-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
//! Blocking I2C API
2+
//!
3+
//! Slave addresses used by this API are 7-bit I2C addresses ranging from 0 to 127.
4+
//!
5+
//! Operations on 10-bit slave addresses are not supported by the API yet (but applications might
6+
//! be able to emulate some operations).
27
38
/// Blocking read
49
pub trait Read {
@@ -17,7 +22,7 @@ pub trait Read {
1722
/// Where
1823
///
1924
/// - `ST` = start condition
20-
/// - `SAD+R` = slave address with 8th bit set to 1
25+
/// - `SAD+R` = slave address followed by bit 1 to indicate reading
2126
/// - `SAK` = slave acknowledge
2227
/// - `Bi` = ith byte of data
2328
/// - `MAK` = master acknowledge
@@ -43,13 +48,29 @@ pub trait Write {
4348
/// Where
4449
///
4550
/// - `ST` = start condition
46-
/// - `SAD+W` = slave address with 8th bit set to 0
51+
/// - `SAD+W` = slave address followed by bit 0 to indicate writing
4752
/// - `SAK` = slave acknowledge
4853
/// - `Bi` = ith byte of data
4954
/// - `SP` = stop condition
5055
fn write(&mut self, addr: u8, bytes: &[u8]) -> Result<(), Self::Error>;
5156
}
5257

58+
/// Blocking write (iterator version)
59+
#[cfg(feature = "unproven")]
60+
pub trait WriteIter {
61+
/// Error type
62+
type Error;
63+
64+
/// Sends bytes to slave with address `addr`
65+
///
66+
/// # I2C Events (contract)
67+
///
68+
/// Same as `Write`
69+
fn write<B>(&mut self, addr: u8, bytes: B) -> Result<(), Self::Error>
70+
where
71+
B: IntoIterator<Item = u8>;
72+
}
73+
5374
/// Blocking write + read
5475
pub trait WriteRead {
5576
/// Error type
@@ -68,11 +89,11 @@ pub trait WriteRead {
6889
/// Where
6990
///
7091
/// - `ST` = start condition
71-
/// - `SAD+W` = slave address with 8th bit set to 0
92+
/// - `SAD+W` = slave address followed by bit 0 to indicate writing
7293
/// - `SAK` = slave acknowledge
7394
/// - `Oi` = ith outgoing byte of data
7495
/// - `SR` = repeated start condition
75-
/// - `SAD+R` = slave address with 8th bit set to 1
96+
/// - `SAD+R` = slave address followed by bit 1 to indicate reading
7697
/// - `Ii` = ith incoming byte of data
7798
/// - `MAK` = master acknowledge
7899
/// - `NMAK` = master no acknowledge
@@ -84,3 +105,25 @@ pub trait WriteRead {
84105
buffer: &mut [u8],
85106
) -> Result<(), Self::Error>;
86107
}
108+
109+
/// Blocking write (iterator version) + read
110+
#[cfg(feature = "unproven")]
111+
pub trait WriteIterRead {
112+
/// Error type
113+
type Error;
114+
115+
/// Sends bytes to slave with address `addr` and then reads enough bytes to fill `buffer` *in a
116+
/// single transaction*
117+
///
118+
/// # I2C Events (contract)
119+
///
120+
/// Same as the `WriteRead` trait
121+
fn write_iter_read<B>(
122+
&mut self,
123+
address: u8,
124+
bytes: B,
125+
buffer: &mut [u8],
126+
) -> Result<(), Self::Error>
127+
where
128+
B: IntoIterator<Item = u8>;
129+
}

0 commit comments

Comments
 (0)