Giter Site home page Giter Site logo

eldruin / pcf857x-rs Goto Github PK

View Code? Open in Web Editor NEW
8.0 4.0 3.0 86 KB

Platform agnostic driver for the PCF8574, PCF8574A and PCF8575 I/O expanders written in Rust using embedded-hal

License: Apache License 2.0

Rust 100.00%
rust embedded embedded-hal embedded-hal-driver no-std io-expander rust-library driver expander i2c

pcf857x-rs's Issues

Pins don't implement Peripheral

Looks like there is a lack of impl DerefMut for pins.
Example:

fn main() -> eyre::Result<()> {
    // It is necessary to call this function once. Otherwise some patches to the runtime
    // implemented by esp-idf-sys might not link properly. See https://github.com/esp-rs/esp-idf-template/issues/71
    esp_idf_svc::sys::link_patches();

    let peripherals = Peripherals::take().unwrap();

    let i2c = peripherals.i2c0;
    let sda = peripherals.pins.gpio5;
    let scl = peripherals.pins.gpio6;

    let config = I2cConfig::new().baudrate(100.kHz().into());
    let i2c = I2cDriver::new(i2c, sda, scl, &config)?;
    let mut expander: Pcf8574<I2cDriver> = pcf857x::Pcf8574::new(i2c, SlaveAddr::Alternative(true, true, true));
    let parts = expander.split();

    fn test<'d>(p: impl Peripheral<P = impl OutputPin> + 'd) {
        todo!()
    }
    
    test(parts.p0); // doesn't work
}

Error:

error[E0277]: the trait bound `P0<'_, Pcf8574<I2cDriver<'_>>, I2cError>: DerefMut` is not satisfied
  --> examples/uln2003_via_pcf8574.rs:42:10
   |
42 |     test(parts.p0);
   |     ---- ^^^^^^^^ the trait `DerefMut` is not implemented for `P0<'_, Pcf8574<I2cDriver<'_>>, I2cError>`
   |     |
   |     required by a bound introduced by this call
   |
   = help: the following other types implement trait `Peripheral`:
             AnyIOPin
             AnyInputPin
             AnyOutputPin
             Modem
             ADC1
             ADC2
             CAN
             Gpio0
           and 46 others
   = note: required for `P0<'_, Pcf8574<I2cDriver<'_>>, I2cError>` to implement `Peripheral`
note: required by a bound in `test`
  --> examples/uln2003_via_pcf8574.rs:38:25
   |
38 |     fn test<'d>(p: impl Peripheral<P = impl OutputPin> + 'd) {
   |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `test`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.