{"id":16064655,"url":"https://github.com/eldruin/mcp4x-rs","last_synced_at":"2025-03-17T16:32:38.876Z","repository":{"id":57637359,"uuid":"168989110","full_name":"eldruin/mcp4x-rs","owner":"eldruin","description":"Rust MCP4x SPI digital potentiometer (digipot) driver","archived":false,"fork":false,"pushed_at":"2024-08-12T20:10:08.000Z","size":47,"stargazers_count":1,"open_issues_count":3,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-16T05:27:59.872Z","etag":null,"topics":["digipot","digital","driver","embedded","embedded-hal","embedded-hal-driver","no-std","potentiometer","rust","spi"],"latest_commit_sha":null,"homepage":null,"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/eldruin.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}},"created_at":"2019-02-03T20:19:00.000Z","updated_at":"2024-06-24T07:05:19.000Z","dependencies_parsed_at":"2022-09-02T03:20:51.384Z","dependency_job_id":null,"html_url":"https://github.com/eldruin/mcp4x-rs","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eldruin%2Fmcp4x-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eldruin%2Fmcp4x-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eldruin%2Fmcp4x-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eldruin%2Fmcp4x-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eldruin","download_url":"https://codeload.github.com/eldruin/mcp4x-rs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221697166,"owners_count":16865554,"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":["digipot","digital","driver","embedded","embedded-hal","embedded-hal-driver","no-std","potentiometer","rust","spi"],"created_at":"2024-10-09T05:09:00.674Z","updated_at":"2024-10-27T15:19:05.083Z","avatar_url":"https://github.com/eldruin.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Rust MCP4x digital potentiometer (digipot) driver\n\n[![crates.io](https://img.shields.io/crates/v/mcp4x.svg)](https://crates.io/crates/mcp4x)\n[![Docs](https://docs.rs/mcp4x/badge.svg)](https://docs.rs/mcp4x)\n![Minimum Supported Rust Version](https://img.shields.io/badge/rustc-1.62+-blue.svg)\n[![Build Status](https://github.com/eldruin/mcp4x-rs/workflows/Build/badge.svg)](https://github.com/eldruin/mcp4x-rs/actions?query=workflow%3ABuild)\n[![Coverage Status](https://coveralls.io/repos/github/eldruin/mcp4x-rs/badge.svg?branch=master)](https://coveralls.io/github/eldruin/mcp4x-rs?branch=master)\n\nThis is a platform-agnostic Rust driver for the MCP41xxx and MCP42xxx SPI\ndigital potentiometers (digipot), based on the [`embedded-hal`] traits.\n\n[`embedded-hal`]: https://github.com/rust-embedded/embedded-hal\n\nThis driver allows you to:\n- Set a channel (or all of them) to a position. See: `set_position()`.\n- Shutdown a channel (or all of them). See: `shutdown()`.\n\n## The devices\nThe MCP41XXX and MCP42XXX devices are 256-position, digital potentiometers\navailable in 10 kΩ, 50 kΩ and 100 kΩ resistance versions. The MCP41XXX is\na single-channel device and is offered in an 8-pin PDIP or SOIC package.\nThe MCP42XXX contains two independent channels in a 14-pin PDIP, SOIC or\nTSSOP package. The wiper position of the MCP41XXX/42XXX varies linearly\nand is controlled via an industry-standard SPI interface.\n\nThe devices consume \u003c1 μA during static operation. A software shutdown\nfeature is provided that disconnects the \"A\" terminal from the resistor\nstack and simultaneously connects the wiper to the \"B\" terminal.\nIn addition, the dual MCP42XXX has a SHDN pin that performs the same\nfunction in hardware. During shutdown mode, the contents of the wiper\nregister can be changed and the potentiometer returns from shutdown to the\nnew value. The wiper is reset to the mid-scale position (80h) upon\npower-up. The RS (reset) pin implements a hardware reset and also returns\nthe wiper to mid-scale.\n\nThe MCP42XXX SPI interface includes both the SI and SO pins, allowing\ndaisy-chaining of multiple devices. Channel-to-channel resistance matching\non the MCP42XXX varies by less than 1%.\n\nThis driver should be compatible at least with the devices: MCP41010, MCP41050,\nMCP41100, MCP42010, MCP42050 and MCP42100.\n\nDatasheet:\n- [MCP41XXX/MCP42XXX](http://ww1.microchip.com/downloads/en/DeviceDoc/11195c.pdf)\n\n## Usage\n\nTo use this driver, import this crate and an `embedded_hal` implementation,\nthen instantiate the appropriate device.\nIn the following examples an instance of the device MCP41x will be created\nas an example. Other devices can be created with similar methods like:\n`Mcp4x::new_mcp42x(...)`.\n\nPlease find additional examples using hardware in this repository: [driver-examples]\n\n[driver-examples]: https://github.com/eldruin/driver-examples\n\n```rust\nuse mcp4x::{Channel, Mcp4x};\nuse embedded_hal_bus::spi::ExclusiveDevice;\nuse linux_embedded_hal::{Delay, SpidevBus, SysfsPin};\n\nfn main() {\n    let spi = SpidevBus::open(\"/dev/spidev0.0\").unwrap();\n    let chip_select = SysfsPin::new(25);\n    let dev = ExclusiveDevice::new(spi, chip_select, Delay);\n    let mut mcp41x = Mcp4x::new_mcp41x(dev);\n\n    mcp41x.set_position(Channel::Ch0, 50).unwrap();\n\n    // Get SPI device back\n    let _dev = mcp41x.destroy_mcp41x();\n}\n```\n\n## Support\n\nFor questions, issues, feature requests like compatibility with similar devices and other changes, please file an\n[issue in the github project](https://github.com/eldruin/mcp4x-rs/issues).\n\n## License\n\nLicensed under either of\n\n * Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or\n   http://www.apache.org/licenses/LICENSE-2.0)\n * MIT license ([LICENSE-MIT](LICENSE-MIT) or\n   http://opensource.org/licenses/MIT)\n\nat your option.\n\n### Contributing\n\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\nbe dual licensed as above, without any additional terms or conditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feldruin%2Fmcp4x-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feldruin%2Fmcp4x-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feldruin%2Fmcp4x-rs/lists"}