Skip to content

Commit 72af109

Browse files
bors[bot]eldruin
andauthored
Merge #66
66: Updates for v0.3.x r=ryankurte a=eldruin Fixes #64 Co-authored-by: Diego Barrios Romero <[email protected]>
2 parents 25bf2be + 6f1a516 commit 72af109

17 files changed

+275
-136
lines changed

.github/bors.toml

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
block_labels = ["needs-decision"]
22
delete_merged_branches = true
33
required_approvals = 1
4-
status = ["continuous-integration/travis-ci/push"]
4+
status = [
5+
"CI (stable, x86_64-unknown-linux-gnu)",
6+
"CI (stable, armv7-unknown-linux-gnueabihf)",
7+
"CI (1.46.0, x86_64-unknown-linux-gnu)",
8+
]

.github/workflows/ci.yml

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
on:
2+
push:
3+
branches: [ staging, trying, master ]
4+
pull_request:
5+
6+
name: Continuous integration
7+
8+
jobs:
9+
ci-linux:
10+
name: CI
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
# All generated code should be running on stable now
17+
rust: [stable]
18+
19+
# The default target we're compiling on and for
20+
TARGET: [x86_64-unknown-linux-gnu, armv7-unknown-linux-gnueabihf]
21+
22+
include:
23+
# Test MSRV
24+
- rust: 1.46.0
25+
TARGET: x86_64-unknown-linux-gnu
26+
27+
# Test nightly but don't fail
28+
- rust: nightly
29+
experimental: true
30+
TARGET: x86_64-unknown-linux-gnu
31+
32+
steps:
33+
- uses: actions/checkout@v2
34+
35+
- uses: actions-rs/toolchain@v1
36+
with:
37+
profile: minimal
38+
toolchain: ${{ matrix.rust }}
39+
target: ${{ matrix.TARGET }}
40+
override: true
41+
42+
- name: Install armv7 libraries
43+
if: ${{ matrix.TARGET == 'armv7-unknown-linux-gnueabihf' }}
44+
run: sudo apt-get install -y libc6-armhf-cross libc6-dev-armhf-cross gcc-arm-linux-gnueabihf
45+
46+
- uses: actions-rs/cargo@v1
47+
with:
48+
command: build
49+
args: --target=${{ matrix.TARGET }}
50+
51+
- uses: actions-rs/cargo@v1
52+
if: ${{ matrix.TARGET == 'x86_64-unknown-linux-gnu' }}
53+
with:
54+
command: test
55+
args: --target=${{ matrix.TARGET }}

.github/workflows/clippy.yml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
on:
2+
push:
3+
branches: [ staging, trying, master ]
4+
pull_request:
5+
6+
name: Clippy check
7+
jobs:
8+
clippy_check:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v2
12+
- uses: actions-rs/toolchain@v1
13+
with:
14+
profile: minimal
15+
toolchain: 1.55.0
16+
override: true
17+
components: clippy
18+
- uses: actions-rs/clippy-check@v1
19+
with:
20+
token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/rustfmt.yml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
on:
2+
push:
3+
branches: [ staging, trying, master ]
4+
pull_request:
5+
6+
name: Code formatting check
7+
8+
jobs:
9+
fmt:
10+
name: Rustfmt
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v2
14+
- uses: actions-rs/toolchain@v1
15+
with:
16+
profile: minimal
17+
toolchain: stable
18+
override: true
19+
components: rustfmt
20+
- uses: actions-rs/cargo@v1
21+
with:
22+
command: fmt
23+
args: --all -- --check

.travis.yml

-78
This file was deleted.

CHANGELOG.md

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

88
## [Unreleased]
99

10+
11+
## [v0.3.1] - 2021-09-27
12+
### Added
13+
14+
- Added implementation of transactional SPI and I2C traits.
15+
- `CountDown` implementation for `SysTimer`.
16+
- `Default` implementation for `SysTimer`.
17+
1018
### Changed
1119

12-
- Set default features to build both sysfs and cdev pin types
13-
- Removed `Pin` export, use `CdevPin` or `SysfsPin`
20+
- Set default features to build both sysfs and cdev pin types.
21+
- Removed `Pin` export, use `CdevPin` or `SysfsPin`.
22+
- Updated `embedded-hal` to version `0.2.6`.
23+
- Updated `nb` to version `0.1.3`.
24+
- Updated `gpio-cdev` to version `0.5`.
25+
- Updated `i2cdev` to version `0.5`.
26+
- Updated `spidev` to version `0.5`.
27+
- Updated `sysfs-gpio` to version `0.6`.
28+
- Updated `cast` to version `0.3`.
29+
30+
### Fixed
31+
32+
- Modified `OutputPin` behavior for active-low pins to match `InputPin` behavior.
1433

1534
## [v0.3.0] - 2019-11-25
1635

@@ -41,7 +60,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
4160

4261
### Added
4362

44-
- implementation of the unproven `embedded_hal::::digital::InputPin` trait.
63+
- implementation of the unproven `embedded_hal::::digital::InputPin` trait.
4564

4665
## [v0.2.0] - 2018-05-14
4766

@@ -62,8 +81,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
6281

6382
Initial release
6483

65-
[Unreleased]: https://github.com/japaric/linux-embedded-hal/compare/v0.2.1...HEAD
66-
[v0.2.2]: https://github.com/japaric/linux-embedded-hal/compare/v0.2.1...v0.2.2
84+
[Unreleased]: https://github.com/rust-embedded/linux-embedded-hal/compare/v0.3.1...HEAD
85+
[v0.3.1]: https://github.com/rust-embedded/linux-embedded-hal/compare/v0.3.0...v0.3.1
86+
[v0.3.0]: https://github.com/rust-embedded/linux-embedded-hal/compare/v0.2.2...v0.3.0
87+
[v0.2.2]: https://github.com/rust-embedded/linux-embedded-hal/compare/v0.2.1...v0.2.2
6788
[v0.2.1]: https://github.com/rust-embedded/linux-embedded-hal/compare/v0.2.0...v0.2.1
6889
[v0.2.0]: https://github.com/rust-embedded/linux-embedded-hal/compare/v0.1.1...v0.2.0
69-
[v0.1.1]: https://github.com/japaric/linux-embedded-hal/compare/v0.1.0...v0.1.1
90+
[v0.1.1]: https://github.com/rust-embedded/linux-embedded-hal/compare/v0.1.0...v0.1.1

Cargo.toml

+14-10
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
[package]
2-
authors = ["Jorge Aparicio <[email protected]>"]
2+
authors = [
3+
"Jorge Aparicio <[email protected]>",
4+
"The Embedded Linux Team <[email protected]>",
5+
]
36
categories = ["embedded", "hardware-support"]
47
description = "Implementation of the `embedded-hal` traits for Linux devices"
58
keywords = ["Linux", "hal"]
69
license = "MIT OR Apache-2.0"
710
name = "linux-embedded-hal"
8-
repository = "https://github.com/japaric/linux-embedded-hal"
9-
version = "0.3.0"
11+
repository = "https://github.com/rust-embedded/linux-embedded-hal"
12+
version = "0.3.1"
13+
readme = "README.md"
1014

1115
[features]
1216
gpio_sysfs = ["sysfs_gpio"]
@@ -15,15 +19,15 @@ gpio_cdev = ["gpio-cdev"]
1519
default = [ "gpio_cdev", "gpio_sysfs" ]
1620

1721
[dependencies]
18-
embedded-hal = { version = "0.2.3", features = ["unproven"] }
19-
gpio-cdev = { version = "0.3", optional = true }
20-
sysfs_gpio = { version = "0.5", optional = true }
22+
embedded-hal = { version = "0.2.6", features = ["unproven"] }
23+
gpio-cdev = { version = "0.5", optional = true }
24+
sysfs_gpio = { version = "0.6", optional = true }
2125

22-
i2cdev = "0.4.3"
23-
nb = "0.1.1"
26+
i2cdev = "0.5"
27+
nb = "0.1.3"
2428
serial-core = "0.4.0"
2529
serial-unix = "0.4.0"
26-
spidev = "0.4"
30+
spidev = "0.5"
2731
void = "1"
2832

2933
[dev-dependencies]
@@ -32,4 +36,4 @@ openpty = "0.1.0"
3236
[dependencies.cast]
3337
# we don't need the `Error` implementation
3438
default-features = false
35-
version = "0.2.2"
39+
version = "0.3"

LICENSE-MIT

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
Copyright (c) 2018 Jorge Aparicio
2+
Copyright (c) 2021 The Rust Embedded Linux Team <[email protected]>
23

34
Permission is hereby granted, free of charge, to any
45
person obtaining a copy of this software and associated

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ linux-embedded-hal = { version = "0.3", features = ["gpio_cdev"] }
2424

2525
# Minimum Supported Rust Version (MSRV)
2626

27-
This crate is guaranteed to compile on stable Rust 1.36.0 and up. It *might*
27+
This crate is guaranteed to compile on stable Rust 1.46.0 and up. It *might*
2828
compile with older versions but that may change in any new patch release.
2929

3030
## License

ci/install.sh

-9
This file was deleted.

ci/script.sh

-7
This file was deleted.

examples/transactional-i2c.rs

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
extern crate embedded_hal;
2+
extern crate linux_embedded_hal;
3+
use embedded_hal::blocking::i2c::{Operation as I2cOperation, Transactional};
4+
use linux_embedded_hal::I2cdev;
5+
6+
const ADDR: u8 = 0x12;
7+
8+
struct Driver<I2C> {
9+
i2c: I2C,
10+
}
11+
12+
impl<I2C> Driver<I2C>
13+
where
14+
I2C: Transactional,
15+
{
16+
pub fn new(i2c: I2C) -> Self {
17+
Driver { i2c }
18+
}
19+
20+
fn read_something(&mut self) -> Result<u8, I2C::Error> {
21+
let mut read_buffer = [0];
22+
let mut ops = [
23+
I2cOperation::Write(&[0xAB]),
24+
I2cOperation::Read(&mut read_buffer),
25+
];
26+
self.i2c.exec(ADDR, &mut ops).and(Ok(read_buffer[0]))
27+
}
28+
}
29+
30+
fn main() {
31+
let dev = I2cdev::new("/dev/i2c-1").unwrap();
32+
let mut driver = Driver::new(dev);
33+
let value = driver.read_something().unwrap();
34+
println!("Read value: {}", value);
35+
}

src/cdev_pin.rs

+12-4
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
33
/// Newtype around [`gpio_cdev::LineHandle`] that implements the `embedded-hal` traits
44
///
5-
/// [`gpio_cdev::LineHandle`]: https://docs.rs/gpio-cdev/0.2.0/gpio_cdev/struct.LineHandle.html
5+
/// [`gpio_cdev::LineHandle`]: https://docs.rs/gpio-cdev/0.5.0/gpio_cdev/struct.LineHandle.html
66
pub struct CdevPin(pub gpio_cdev::LineHandle, bool);
77

88
impl CdevPin {
99
/// See [`gpio_cdev::Line::request`][0] for details.
1010
///
11-
/// [0]: https://docs.rs/gpio-cdev/0.2.0/gpio_cdev/struct.Line.html#method.request
11+
/// [0]: https://docs.rs/gpio-cdev/0.5.0/gpio_cdev/struct.Line.html#method.request
1212
pub fn new(handle: gpio_cdev::LineHandle) -> Result<Self, gpio_cdev::errors::Error> {
1313
let info = handle.line().info()?;
1414
Ok(CdevPin(handle, info.is_active_low()))
@@ -19,11 +19,19 @@ impl hal::digital::v2::OutputPin for CdevPin {
1919
type Error = gpio_cdev::errors::Error;
2020

2121
fn set_low(&mut self) -> Result<(), Self::Error> {
22-
self.0.set_value(0)
22+
if self.1 {
23+
self.0.set_value(1)
24+
} else {
25+
self.0.set_value(0)
26+
}
2327
}
2428

2529
fn set_high(&mut self) -> Result<(), Self::Error> {
26-
self.0.set_value(1)
30+
if self.1 {
31+
self.0.set_value(0)
32+
} else {
33+
self.0.set_value(1)
34+
}
2735
}
2836
}
2937

0 commit comments

Comments
 (0)