{"id":16221594,"url":"https://github.com/rahix/port-expander","last_synced_at":"2025-04-06T22:08:08.576Z","repository":{"id":40477143,"uuid":"361163735","full_name":"Rahix/port-expander","owner":"Rahix","description":"Abstraction for I²C port-expanders","archived":false,"fork":false,"pushed_at":"2025-02-01T14:09:36.000Z","size":107,"stargazers_count":20,"open_issues_count":6,"forks_count":15,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-04T12:53:23.678Z","etag":null,"topics":["embedded-hal","i2c","rust-embedded"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Rahix.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-04-24T13:05:02.000Z","updated_at":"2025-03-27T22:22:12.000Z","dependencies_parsed_at":"2023-11-30T01:42:15.087Z","dependency_job_id":"68023ad3-d9f5-47b9-93bf-5d38dc3c401d","html_url":"https://github.com/Rahix/port-expander","commit_stats":{"total_commits":57,"total_committers":3,"mean_commits":19.0,"dds":0.07017543859649122,"last_synced_commit":"6fef833d328c3b6ff3ed042c5fb54c3b09c011f3"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rahix%2Fport-expander","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rahix%2Fport-expander/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rahix%2Fport-expander/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rahix%2Fport-expander/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Rahix","download_url":"https://codeload.github.com/Rahix/port-expander/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247557767,"owners_count":20958047,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["embedded-hal","i2c","rust-embedded"],"created_at":"2024-10-10T12:09:02.102Z","updated_at":"2025-04-06T22:08:08.555Z","avatar_url":"https://github.com/Rahix.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"`port-expander` [![crates.io page](https://img.shields.io/crates/v/port-expander.svg)](https://crates.io/crates/port-expander) [![docs.rs page](https://docs.rs/port-expander/badge.svg)](https://docs.rs/port-expander)\n===============\nThis is a crate providing a common abstraction for I²C port-expanders.  This\nabstraction is not necessarily the most performant, but it allows using the pins\njust like direct GPIOs.  Because the pin types also implement the `embedded-hal`\ndigital IO traits, they can also be passed to further drivers downstream (e.g.\nas a reset or chip-select pin).\n\n## Example\n```rust\n// Initialize I2C peripheral from HAL\nlet i2c = todo!();\n\n// A0: HIGH, A1: LOW, A2: LOW\nlet mut pca9555 = port_expander::Pca9555::new(i2c, true, false, false);\nlet pca_pins = pca9555.split();\n\nlet io0_0 = pca_pins.io0_0.into_output().unwrap();\nlet io1_5 = pca_pins.io0_1; // default is input\n\nio0_0.set_high().unwrap();\nassert!(io1_5.is_high().unwrap());\n```\n\n## Accessing multiple pins at the same time\nSometimes timing constraints mandate that multiple pin accesses (reading or\nwriting) happen at the same time.  The [`write_multiple()`][write-multiple] and\n[`read_multiple()`][read-multiple] methods are designed for doing this.\n\n[write-multiple]: https://docs.rs/port-expander/latest/port_expander/fn.write_multiple.html\n[read-multiple]: https://docs.rs/port-expander/latest/port_expander/fn.read_multiple.html\n\n## Supported Devices\nThe following list is what `port-expander` currently supports.  If you needs\nsupport for an additional device, it should be easy to add.  It's best to take\na similar existing implementation as inspiration.  Contributions welcome!\n\n- [`MAX7321`](https://docs.rs/port-expander/latest/port_expander/dev/max7321/struct.Max7321.html)\n- [`PCA9536`](https://docs.rs/port-expander/latest/port_expander/dev/pca9536/struct.Pca9536.html)\n- [`PCA9538`](https://docs.rs/port-expander/latest/port_expander/dev/pca9538/struct.Pca9538.html)\n- [`PCA9554`](https://docs.rs/port-expander/latest/port_expander/dev/pca9554/struct.Pca9554.html)\n- [`PCA9554A`](https://docs.rs/port-expander/latest/port_expander/dev/pca9554/struct.Pca9554A.html)\n- [`PCA9555`](https://docs.rs/port-expander/latest/port_expander/dev/pca9555/struct.Pca9555.html)\n- [`PCF8574A`](https://docs.rs/port-expander/latest/port_expander/dev/pcf8574/struct.Pcf8574a.html)\n- [`PCF8574`](https://docs.rs/port-expander/latest/port_expander/dev/pcf8574/struct.Pcf8574.html)\n- [`PCF8575`](https://docs.rs/port-expander/latest/port_expander/dev/pcf8575/struct.Pcf8575.html)\n- [`TCA6408A`](https://docs.rs/port-expander/latest/port_expander/dev/tca6408a/struct.Tca6408a.html)\n- [`PI4IOE5V6408`](https://docs.rs/port-expander/latest/port_expander/dev/pi4ioe5v6408/struct.Pi4ioe5v6408.html)\n\n## Non-local sharing\n`port-expander` uses a custom trait for abstracting different kinds of mutexes:\n[`PortMutex`](https://docs.rs/port-expander/latest/port_expander/trait.PortMutex.html).\nThis means you can also make the pins shareable across task/thread boundaries,\ngiven that you provide an appropriate mutex type:\n\n```rust\n// Initialize I2C peripheral from HAL\nlet i2c = todo!();\n\n// A0: HIGH, A1: LOW, A2: LOW\nlet mut pca9555: port_expander::Pca9555\u003cstd::sync::Mutex\u003c_\u003e\u003e =\n    port_expander::Pca9555::with_mutex(i2c, true, false, false);\nlet pca_pins = pca9555.split();\n```\n\n## License\nLicensed under either of\n\n * Apache License, Version 2.0\n   ([LICENSE-APACHE](LICENSE-APACHE) or \u003chttp://www.apache.org/licenses/LICENSE-2.0\u003e)\n * MIT license\n   ([LICENSE-MIT](LICENSE-MIT) or \u003chttp://opensource.org/licenses/MIT\u003e)\n\nat your option.\n\n## Contribution\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in the work by you, as defined in the Apache-2.0 license, shall be\ndual licensed as above, without any additional terms or conditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frahix%2Fport-expander","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frahix%2Fport-expander","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frahix%2Fport-expander/lists"}