Skip to content
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

Update to embedded-hal 1.0 #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ exclude = [
]

[dependencies]
embedded-hal = "0.2.3"
embedded-hal = "1.0"
10 changes: 5 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

extern crate embedded_hal as ehal;

use ehal::blocking::i2c::{Write, WriteRead};
use ehal::i2c::I2c;

/// The default I2C address of the MCP23017.
const DEFAULT_ADDRESS: u8 = 0x20;
Expand All @@ -38,7 +38,7 @@ const LOW: bool = false;
/// See the crate-level documentation for general info on the device and the operation of this
/// driver.
#[derive(Clone, Copy, Debug)]
pub struct MCP23017<I2C: Write + WriteRead> {
pub struct MCP23017<I2C: I2c> {
com: I2C,
/// The I2C slave address of this device.
pub address: u8,
Expand All @@ -61,20 +61,20 @@ impl<E> From<E> for Error<E> {

impl<I2C, E> MCP23017<I2C>
where
I2C: WriteRead<Error = E> + Write<Error = E>,
I2C: I2c<Error = E>,
{
/// Creates an expander with the default configuration.
pub fn default(i2c: I2C) -> Result<MCP23017<I2C>, Error<E>>
where
I2C: Write<Error = E> + WriteRead<Error = E>,
I2C: I2c<Error = E>,
{
MCP23017::new(i2c, DEFAULT_ADDRESS)
}

/// Creates an expander with specific address.
pub fn new(i2c: I2C, address: u8) -> Result<MCP23017<I2C>, Error<E>>
where
I2C: Write<Error = E> + WriteRead<Error = E>,
I2C: I2c<Error = E>,
{
let chip = MCP23017 { com: i2c, address };

Expand Down