Skip to content

Commit bb89a07

Browse files
authored
Try #66:
2 parents 25bf2be + a93e5ec commit bb89a07

16 files changed

+257
-122
lines changed

.github/bors.toml

Lines changed: 5 additions & 1 deletion
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

Lines changed: 55 additions & 0 deletions
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

Lines changed: 20 additions & 0 deletions
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

Lines changed: 23 additions & 0 deletions
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

Lines changed: 0 additions & 78 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,27 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- Added implementation of transactional SPI and I2C traits.
13+
- `CountDown` implementation for `SysTimer`.
14+
- `Default` implementation for `SysTimer`.
15+
1016
### Changed
1117

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

1532
## [v0.3.0] - 2019-11-25
1633

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

4259
### Added
4360

44-
- implementation of the unproven `embedded_hal::::digital::InputPin` trait.
61+
- implementation of the unproven `embedded_hal::::digital::InputPin` trait.
4562

4663
## [v0.2.0] - 2018-05-14
4764

Cargo.toml

Lines changed: 13 additions & 9 deletions
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"
11+
repository = "https://github.com/rust-embedded/linux-embedded-hal"
912
version = "0.3.0"
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 0 additions & 9 deletions
This file was deleted.

ci/script.sh

Lines changed: 0 additions & 7 deletions
This file was deleted.

examples/transactional-i2c.rs

Lines changed: 35 additions & 0 deletions
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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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)