Skip to content

Release 0.2.3 preparation #28

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,23 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

## [v0.2.3] - 2019-11-26

### Added

- Added serial::Read/Write implementation.

### Fixed

- Do write and read in one transaction in WriteRead implementation.
- Removed #[deny(warnings)]

### Changed

- Use embedded-hal::digital::v2 traits.
- Updated to i2cdev 0.4.3 (necessary for trasactional write-read).
- Updated to spidev 0.4

## [v0.2.2] - 2018-12-21

### Changed
Expand Down
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ keywords = ["Linux", "hal"]
license = "MIT OR Apache-2.0"
name = "linux-embedded-hal"
repository = "https://github.com/japaric/linux-embedded-hal"
version = "0.2.2"
version = "0.2.3"

[dependencies]
embedded-hal = { version = "0.2.0", features = ["unproven"] }
i2cdev = "0.4"
embedded-hal = { version = "0.2.3", features = ["unproven"] }
i2cdev = "0.4.3"
spidev = "0.4"
sysfs_gpio = "0.5"
serial-unix = "0.4.0"
Expand Down
12 changes: 8 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ use std::time::Duration;
use std::{ops, thread};

use cast::{u32, u64};
use i2cdev::core::I2CDevice;
use i2cdev::core::{I2CDevice, I2CMessage, I2CTransfer};
use i2cdev::linux::LinuxI2CMessage;
use spidev::SpidevTransfer;

mod serial;
Expand Down Expand Up @@ -184,7 +185,7 @@ impl I2cdev {

fn set_address(&mut self, address: u8) -> Result<(), i2cdev::linux::LinuxI2CError> {
if self.address != Some(address) {
self.inner = i2cdev::linux::LinuxI2CDevice::new(&self.path, address as u16)?;
self.inner = i2cdev::linux::LinuxI2CDevice::new(&self.path, u16::from(address))?;
self.address = Some(address);
}
Ok(())
Expand Down Expand Up @@ -219,8 +220,11 @@ impl hal::blocking::i2c::WriteRead for I2cdev {
buffer: &mut [u8],
) -> Result<(), Self::Error> {
self.set_address(address)?;
self.inner.write(bytes)?;
self.inner.read(buffer)
let mut messages = [
LinuxI2CMessage::write(bytes),
LinuxI2CMessage::read(buffer),
];
self.inner.transfer(&mut messages).map(drop)
}
}

Expand Down