{"id":16064668,"url":"https://github.com/eldruin/mcp49xx-rs","last_synced_at":"2025-06-28T09:36:17.952Z","repository":{"id":34179134,"uuid":"170000022","full_name":"eldruin/mcp49xx-rs","owner":"eldruin","description":"Platform-agnostic Rust driver for the MCP49xx digital-to-analog converters (DAC).","archived":false,"fork":false,"pushed_at":"2022-06-13T20:20:43.000Z","size":63,"stargazers_count":5,"open_issues_count":0,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-09T18:49:49.009Z","etag":null,"topics":["analog","converter","dac","digital","embedded","embedded-hal","embedded-hal-driver","no-std","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-10T16:39:20.000Z","updated_at":"2023-07-25T14:23:32.000Z","dependencies_parsed_at":"2022-09-02T03:20:43.955Z","dependency_job_id":null,"html_url":"https://github.com/eldruin/mcp49xx-rs","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/eldruin/mcp49xx-rs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eldruin%2Fmcp49xx-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eldruin%2Fmcp49xx-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eldruin%2Fmcp49xx-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eldruin%2Fmcp49xx-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eldruin","download_url":"https://codeload.github.com/eldruin/mcp49xx-rs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eldruin%2Fmcp49xx-rs/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262406945,"owners_count":23306285,"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":["analog","converter","dac","digital","embedded","embedded-hal","embedded-hal-driver","no-std","rust","spi"],"created_at":"2024-10-09T05:09:03.261Z","updated_at":"2025-06-28T09:36:17.935Z","avatar_url":"https://github.com/eldruin.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Rust MCP49xx and MCP48xx digital-to-analog converter (DAC) driver\n\n[![crates.io](https://img.shields.io/crates/v/mcp49xx.svg)](https://crates.io/crates/mcp49xx)\n[![Docs](https://docs.rs/mcp49xx/badge.svg)](https://docs.rs/mcp49xx)\n[![Build Status](https://github.com/eldruin/mcp49xx-rs/workflows/Build/badge.svg)](https://github.com/eldruin/mcp49xx-rs/actions?query=workflow%3ABuild)\n[![Coverage Status](https://coveralls.io/repos/github/eldruin/mcp49xx-rs/badge.svg?branch=master)](https://coveralls.io/github/eldruin/mcp49xx-rs?branch=master)\n\nThis is a platform-agnostic Rust driver for the MCP49xx and MCP48xx SPI\ndigital-to-analog converters (DAC), 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 to a value.\n- Shutdown a channel.\n- Use buffering on commands.\n- Select gain.\n\n## The devices\nThe Microchip Technology Inc. MCP49xx devices are single/dual channel 8-bit,\n10-bit and 12-bit buffered voltage output Digital-to-Analog Converters\n(DACs). The devices operate from a single 2.7V to 5.5V supply with an SPI\ncompatible Serial Peripheral Interface. The user can configure the\nfull-scale range of the device to be Vref or 2*Vref by setting the gain\nselection option bit (gain of 1 of 2).\n\nThe user can shut down the device by setting the Configuration Register bit.\nIn Shutdown mode, most of the internal circuits are turned off for power\nsavings, and the output amplifier is configured to present a known high\nresistance output load (500 kΩ, typical).\n\nThe devices include double-buffered registers, allowing synchronous updates\nof the DAC output using the LDAC pin. These devices also incorporate a\nPower-on Reset (POR) circuit to ensure reliable power-up.\n\nThe devices utilize a resistive string architecture, with its inherent\nadvantages of low Differential Non-Linearity (DNL) error and fast settling\ntime. These devices are specified over the extended temperature range (+125°C).\n\nThe devices provide high accuracy and low noise performance for consumer\nand industrial applications where calibration or compensation of signals\n(such as temperature, pressure and humidity) are required.\n\nThis driver is compatible with these devices:\n\n| Device  | Resolution | Channels | Buffering     |\n|---------|------------|----------|---------------|\n| MCP4801 | 8-bit      | 1        | Not available |\n| MCP4802 | 8-bit      | 2        | Not available |\n| MCP4811 | 10-bit     | 1        | Not available |\n| MCP4812 | 10-bit     | 2        | Not available |\n| MCP4821 | 12-bit     | 1        | Not available |\n| MCP4822 | 12-bit     | 2        | Not available |\n| MCP4901 | 8-bit      | 1        | Available     |\n| MCP4902 | 8-bit      | 2        | Available     |\n| MCP4911 | 10-bit     | 1        | Available     |\n| MCP4912 | 10-bit     | 2        | Available     |\n| MCP4921 | 12-bit     | 1        | Available     |\n| MCP4922 | 12-bit     | 2        | Available     |\n\nDatasheets:\n- [MCP48x1](http://ww1.microchip.com/downloads/en/DeviceDoc/22244B.pdf)\n- [MCP48x2](http://ww1.microchip.com/downloads/en/DeviceDoc/20002249B.pdf)\n- [MCP49x1](http://ww1.microchip.com/downloads/en/DeviceDoc/22248a.pdf)\n- [MCP49x2](http://ww1.microchip.com/downloads/en/DeviceDoc/22250A.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 MCP4921 will be created\nas an example. Other devices can be created with similar methods like:\n`Mcp49xx::new_mcp4822(...)`.\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 linux_embedded_hal::{Pin, Spidev};\nuse mcp49xx::{Command, Mcp49xx};\n\nfn main() {\n    let spi = Spidev::open(\"/dev/spidev0.0\").unwrap();\n    let cs = Pin::new(25);\n    let mut mcp4921 = Mcp49xx::new_mcp4921(cs);\n\n    let cmd = Command::default();\n    let cmd = cmd.double_gain().value(50);\n\n    // enable double gain and set value\n    mcp4921.send(\u0026mut spi, cmd).unwrap();\n\n    // keeps double gain enabled but changes value\n    mcp4921.send(\u0026mut spi, cmd.value(100)).unwrap();\n\n    // Get CS pin back\n    let _chip_select = mcp4921.destroy();\n}\n```\n\n## Support\n\nFor questions, issues, feature requests, and other changes, please file an\n[issue in the github project](https://github.com/eldruin/mcp49xx-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\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feldruin%2Fmcp49xx-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feldruin%2Fmcp49xx-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feldruin%2Fmcp49xx-rs/lists"}