Skip to content

Commit

Permalink
Merge #66
Browse files Browse the repository at this point in the history
66: Updates for v0.3.x r=ryankurte a=eldruin

Fixes #64 

Co-authored-by: Diego Barrios Romero <[email protected]>
  • Loading branch information
bors[bot] and eldruin authored Sep 27, 2021
2 parents 25bf2be + 6f1a516 commit 72af109
Show file tree
Hide file tree
Showing 17 changed files with 275 additions and 136 deletions.
6 changes: 5 additions & 1 deletion .github/bors.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
block_labels = ["needs-decision"]
delete_merged_branches = true
required_approvals = 1
status = ["continuous-integration/travis-ci/push"]
status = [
"CI (stable, x86_64-unknown-linux-gnu)",
"CI (stable, armv7-unknown-linux-gnueabihf)",
"CI (1.46.0, x86_64-unknown-linux-gnu)",
]
55 changes: 55 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
on:
push:
branches: [ staging, trying, master ]
pull_request:

name: Continuous integration

jobs:
ci-linux:
name: CI
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
# All generated code should be running on stable now
rust: [stable]

# The default target we're compiling on and for
TARGET: [x86_64-unknown-linux-gnu, armv7-unknown-linux-gnueabihf]

include:
# Test MSRV
- rust: 1.46.0
TARGET: x86_64-unknown-linux-gnu

# Test nightly but don't fail
- rust: nightly
experimental: true
TARGET: x86_64-unknown-linux-gnu

steps:
- uses: actions/checkout@v2

- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
target: ${{ matrix.TARGET }}
override: true

- name: Install armv7 libraries
if: ${{ matrix.TARGET == 'armv7-unknown-linux-gnueabihf' }}
run: sudo apt-get install -y libc6-armhf-cross libc6-dev-armhf-cross gcc-arm-linux-gnueabihf

- uses: actions-rs/cargo@v1
with:
command: build
args: --target=${{ matrix.TARGET }}

- uses: actions-rs/cargo@v1
if: ${{ matrix.TARGET == 'x86_64-unknown-linux-gnu' }}
with:
command: test
args: --target=${{ matrix.TARGET }}
20 changes: 20 additions & 0 deletions .github/workflows/clippy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
on:
push:
branches: [ staging, trying, master ]
pull_request:

name: Clippy check
jobs:
clippy_check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.55.0
override: true
components: clippy
- uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
23 changes: 23 additions & 0 deletions .github/workflows/rustfmt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
on:
push:
branches: [ staging, trying, master ]
pull_request:

name: Code formatting check

jobs:
fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
components: rustfmt
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
78 changes: 0 additions & 78 deletions .travis.yml

This file was deleted.

33 changes: 27 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,29 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]


## [v0.3.1] - 2021-09-27
### Added

- Added implementation of transactional SPI and I2C traits.
- `CountDown` implementation for `SysTimer`.
- `Default` implementation for `SysTimer`.

### Changed

- Set default features to build both sysfs and cdev pin types
- Removed `Pin` export, use `CdevPin` or `SysfsPin`
- Set default features to build both sysfs and cdev pin types.
- Removed `Pin` export, use `CdevPin` or `SysfsPin`.
- Updated `embedded-hal` to version `0.2.6`.
- Updated `nb` to version `0.1.3`.
- Updated `gpio-cdev` to version `0.5`.
- Updated `i2cdev` to version `0.5`.
- Updated `spidev` to version `0.5`.
- Updated `sysfs-gpio` to version `0.6`.
- Updated `cast` to version `0.3`.

### Fixed

- Modified `OutputPin` behavior for active-low pins to match `InputPin` behavior.

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

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

### Added

- implementation of the unproven `embedded_hal::::digital::InputPin` trait.
- implementation of the unproven `embedded_hal::::digital::InputPin` trait.

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

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

Initial release

[Unreleased]: https://github.com/japaric/linux-embedded-hal/compare/v0.2.1...HEAD
[v0.2.2]: https://github.com/japaric/linux-embedded-hal/compare/v0.2.1...v0.2.2
[Unreleased]: https://github.com/rust-embedded/linux-embedded-hal/compare/v0.3.1...HEAD
[v0.3.1]: https://github.com/rust-embedded/linux-embedded-hal/compare/v0.3.0...v0.3.1
[v0.3.0]: https://github.com/rust-embedded/linux-embedded-hal/compare/v0.2.2...v0.3.0
[v0.2.2]: https://github.com/rust-embedded/linux-embedded-hal/compare/v0.2.1...v0.2.2
[v0.2.1]: https://github.com/rust-embedded/linux-embedded-hal/compare/v0.2.0...v0.2.1
[v0.2.0]: https://github.com/rust-embedded/linux-embedded-hal/compare/v0.1.1...v0.2.0
[v0.1.1]: https://github.com/japaric/linux-embedded-hal/compare/v0.1.0...v0.1.1
[v0.1.1]: https://github.com/rust-embedded/linux-embedded-hal/compare/v0.1.0...v0.1.1
24 changes: 14 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
[package]
authors = ["Jorge Aparicio <[email protected]>"]
authors = [
"Jorge Aparicio <[email protected]>",
"The Embedded Linux Team <[email protected]>",
]
categories = ["embedded", "hardware-support"]
description = "Implementation of the `embedded-hal` traits for Linux devices"
keywords = ["Linux", "hal"]
license = "MIT OR Apache-2.0"
name = "linux-embedded-hal"
repository = "https://github.com/japaric/linux-embedded-hal"
version = "0.3.0"
repository = "https://github.com/rust-embedded/linux-embedded-hal"
version = "0.3.1"
readme = "README.md"

[features]
gpio_sysfs = ["sysfs_gpio"]
Expand All @@ -15,15 +19,15 @@ gpio_cdev = ["gpio-cdev"]
default = [ "gpio_cdev", "gpio_sysfs" ]

[dependencies]
embedded-hal = { version = "0.2.3", features = ["unproven"] }
gpio-cdev = { version = "0.3", optional = true }
sysfs_gpio = { version = "0.5", optional = true }
embedded-hal = { version = "0.2.6", features = ["unproven"] }
gpio-cdev = { version = "0.5", optional = true }
sysfs_gpio = { version = "0.6", optional = true }

i2cdev = "0.4.3"
nb = "0.1.1"
i2cdev = "0.5"
nb = "0.1.3"
serial-core = "0.4.0"
serial-unix = "0.4.0"
spidev = "0.4"
spidev = "0.5"
void = "1"

[dev-dependencies]
Expand All @@ -32,4 +36,4 @@ openpty = "0.1.0"
[dependencies.cast]
# we don't need the `Error` implementation
default-features = false
version = "0.2.2"
version = "0.3"
1 change: 1 addition & 0 deletions LICENSE-MIT
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Copyright (c) 2018 Jorge Aparicio
Copyright (c) 2021 The Rust Embedded Linux Team <[email protected]>

Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ linux-embedded-hal = { version = "0.3", features = ["gpio_cdev"] }

# Minimum Supported Rust Version (MSRV)

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

## License
Expand Down
9 changes: 0 additions & 9 deletions ci/install.sh

This file was deleted.

7 changes: 0 additions & 7 deletions ci/script.sh

This file was deleted.

35 changes: 35 additions & 0 deletions examples/transactional-i2c.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
extern crate embedded_hal;
extern crate linux_embedded_hal;
use embedded_hal::blocking::i2c::{Operation as I2cOperation, Transactional};
use linux_embedded_hal::I2cdev;

const ADDR: u8 = 0x12;

struct Driver<I2C> {
i2c: I2C,
}

impl<I2C> Driver<I2C>
where
I2C: Transactional,
{
pub fn new(i2c: I2C) -> Self {
Driver { i2c }
}

fn read_something(&mut self) -> Result<u8, I2C::Error> {
let mut read_buffer = [0];
let mut ops = [
I2cOperation::Write(&[0xAB]),
I2cOperation::Read(&mut read_buffer),
];
self.i2c.exec(ADDR, &mut ops).and(Ok(read_buffer[0]))
}
}

fn main() {
let dev = I2cdev::new("/dev/i2c-1").unwrap();
let mut driver = Driver::new(dev);
let value = driver.read_something().unwrap();
println!("Read value: {}", value);
}
16 changes: 12 additions & 4 deletions src/cdev_pin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
/// Newtype around [`gpio_cdev::LineHandle`] that implements the `embedded-hal` traits
///
/// [`gpio_cdev::LineHandle`]: https://docs.rs/gpio-cdev/0.2.0/gpio_cdev/struct.LineHandle.html
/// [`gpio_cdev::LineHandle`]: https://docs.rs/gpio-cdev/0.5.0/gpio_cdev/struct.LineHandle.html
pub struct CdevPin(pub gpio_cdev::LineHandle, bool);

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

fn set_low(&mut self) -> Result<(), Self::Error> {
self.0.set_value(0)
if self.1 {
self.0.set_value(1)
} else {
self.0.set_value(0)
}
}

fn set_high(&mut self) -> Result<(), Self::Error> {
self.0.set_value(1)
if self.1 {
self.0.set_value(0)
} else {
self.0.set_value(1)
}
}
}

Expand Down
Loading

0 comments on commit 72af109

Please sign in to comment.