{"id":13713999,"url":"https://github.com/ardnew/mcp2221a","last_synced_at":"2026-04-03T16:03:20.030Z","repository":{"id":57510953,"uuid":"236803868","full_name":"ardnew/mcp2221a","owner":"ardnew","description":"Go module for the MCP2221A USB to I²C/UART Protocol Converter with GPIO","archived":false,"fork":false,"pushed_at":"2020-05-18T02:45:13.000Z","size":1418,"stargazers_count":20,"open_issues_count":2,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-05-07T00:37:27.877Z","etag":null,"topics":["adc","dac","go","golang","gpio","i2c","mcp2221","mcp2221a","protocol-converter","usb","usb-c","usb-hid"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ardnew.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-01-28T18:08:39.000Z","updated_at":"2025-01-30T20:45:53.000Z","dependencies_parsed_at":"2022-09-26T17:51:02.511Z","dependency_job_id":null,"html_url":"https://github.com/ardnew/mcp2221a","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/ardnew/mcp2221a","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ardnew%2Fmcp2221a","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ardnew%2Fmcp2221a/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ardnew%2Fmcp2221a/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ardnew%2Fmcp2221a/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ardnew","download_url":"https://codeload.github.com/ardnew/mcp2221a/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ardnew%2Fmcp2221a/sbom","scorecard":{"id":205914,"data":{"date":"2025-08-11","repo":{"name":"github.com/ardnew/mcp2221a","commit":"58d45b65c21cc4c61dd3264869456460757b73fb"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.3,"checks":[{"name":"Code-Review","score":0,"reason":"Found 1/28 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":2,"reason":"3 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 2","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 3 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-16T23:45:05.722Z","repository_id":57510953,"created_at":"2025-08-16T23:45:05.722Z","updated_at":"2025-08-16T23:45:05.722Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31362712,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-03T15:19:21.178Z","status":"ssl_error","status_checked_at":"2026-04-03T15:19:20.670Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["adc","dac","go","golang","gpio","i2c","mcp2221","mcp2221a","protocol-converter","usb","usb-c","usb-hid"],"created_at":"2024-08-02T23:01:49.688Z","updated_at":"2026-04-03T16:03:20.006Z","avatar_url":"https://github.com/ardnew.png","language":"Go","funding_links":[],"categories":["Repositories"],"sub_categories":[],"readme":"[![GoDoc][docimg]][docurl]\n\n[docimg]:https://godoc.org/github.com/ardnew/mcp2221a?status.svg\n[docurl]:https://godoc.org/github.com/ardnew/mcp2221a\n\n# mcp2221a\nGo **[module](https://blog.golang.org/using-go-modules)** for the MCP2221A USB to I²C/UART Protocol Converter with GPIO (**[datasheet](http://ww1.microchip.com/downloads/en/DeviceDoc/20005565B.pdf)**)\n\n## Features\n- [x] **[Fully-documented API](https://godoc.org/github.com/ardnew/mcp2221a)**\n- [x] Compliant Go module (see below: **[Installation](#installation)**)\n- [x] Supports multiple MCP2221A devices simultaneously\n   - Define custom USB device VID/PID\n- [x] GPIO input/output\n   - All dedicated and alternate functions (see below: **[GP operating modes](#gp-operating-modes)**)\n- [x] ADC read (10-bit, 3 channels/pins), configurable reference voltage\n- [x] DAC write (5-bit, 2 pins, shared output), configurable reference voltage and default output\n- [x] Dedicated UART/I²C activity LED modes with configurable polarity\n- [x] Rising/falling/both edge interrupt detection\n- [x] Clock output on 1 pin (up to 12 MHz)\n- [x] Save default/power-on configuration to flash memory (GPIO mode/value, DAC output, etc.)\n   - Password-protected flash support\n   - Configure minimum required operating current (510 mA max)\n- [x] I²C read/write (configurable bit rate, up to 400 kHz)\n   - I²C address scanner discovers all slaves on the bus\n   - Convenience routines for reading registers from devices with 8-bit and 16-bit subaddressing\n\nNote that **UART support** is provided natively through the USB interface as a CDC device and is not handled by this module. It should show up in your OS as a regular TTY serial interface (`/dev/tty*` on Linux/macOS, COM on Windows).\n\n#### Dependencies\n- [github.com/karalabe/hid](https://github.com/karalabe/hid) - USB HID interface\n\n## Installation\nIf you are not using Go modules (or are unsure), just use the `go` built-in package manager:\n```sh\ngo get -u -v github.com/ardnew/mcp2221a\n```\n\n#### Installation using modules\nEither use the built-in package manager as above (and drop the `-u`):\n```sh\ngo get -v github.com/ardnew/mcp2221a\n```\n\nOr simply add the import statement to your Go package's source code:\n```go\nimport (\n  // ... other imports ...\n  mcp \"github.com/ardnew/mcp2221a\"\n)\n```\nThe next time you run `go build`, the appropriate package will be downloaded automatically! Gee whiz!\n\n## Examples\nSee [examples](examples) for some demo applications:\n- [GPIO](examples/gpio/main.go) - classic \"Blink\" demo, toggles an LED connected to GPIO pin GP0\n- [I²C](examples/i2c/main.go) - I²C address scanner, and also reads and prints the \"Device ID\" register contents from an INA260 power sensor\n- [ADC](examples/adc/main.go) - continuously reads and prints an analog value on GPIO pin GP1\n- [DAC](examples/dac/main.go) - continuously writes and prints an always-incrementing 5-bit value on GPIO pin GP2\n- [Flash](examples/flash/main.go) - prints the USB product descriptors from flash memory, and toggles power-up GPIO output value on pin GP0\n\n## Notes\n#### GP operating modes\nAll of the available operating modes for the general-purpose (GP) pins:\n\n- `GPIO`: Operate as a digital input or a digital output pin.\n- `SSPND`: Reflects the USB state (`Suspend`/`Resume`); active-low when `Suspend` has been issued by the USB host, and driven high on `Resume`.\n   - This lets the application react (e.g enter a low-power mode) when USB communication has been suspended or resumed.\n   - The pin value can be inverted (high on `Suspend`, low on `Resume`) using the `Flash` module.\n- `USBCFG`: Starts out low during power-up/reset and goes high after successfully enumerating on the USB host.\n   - The pin will also go low when in `Suspend` mode and high on `Resume`.\n   - The pin value can be inverted (start high, low after enumeration) using the `Flash` module.\n- `LED_URX`,`LED_UTX`: Indicates UART (Rx/Tx) data being received/transmitted by pulsing the pin high for a few milliseconds.\n   - The pin value can be inverted (pulse low on receive/transmit) using the `Flash` module.\n- `LED_I2C`: Indicates I²C (Rx **and** Tx) data being received **and** transmitted by pulsing the pin high for a few milliseconds.\n   - The pin value can be inverted (pulse low on receive **and** transmit) using the `Flash` module.\n- `CLKR`: Digital output, providing a clock signal derived from the device’s internal clock.\n   - The clock’s nominal frequency is 12 MHz ± 0.25%.\n   - Other clock values and duty cycles can be configured using the `Flash` module.\n- `IOC`: Digital input (\"Interrupt-on-Change\") that is sensitive to rising, falling, or both edges.\n   - The desired edge can be configured using the `Flash` and `SRAM` modules.\n\n###### Supported modes\nHowever, only certain pins support each of the operating modes listed above — per the following matrix yanked from the datasheet:\n\n|             |**GP0**|**GP1**|**GP2**|**GP3**|\n|------------:|:-----:|:-----:|:-----:|:-----:|\n|  **Default**| GPIO  | GPIO  | GPIO  | GPIO  |\n|**Dedicated**| SSPND | CLKR  |USBCFG |LED_I2C|\n|    **Alt 1**|LED_URX| ADC1  | ADC2  | ADC3  |\n|    **Alt 2**|  --   |LED_UTX| DAC1  | DAC2  |\n|    **Alt 3**|  --   |  IOC  |  --   |  --   |\n\nNo idea why the first row of alternate functions is named **Dedicated**, that's how they are identified in the datasheet...\n\n#### Datasheet\nPlease refer to this before sending me a confusing question:\n- **[http://ww1.microchip.com/downloads/en/DeviceDoc/20005565B.pdf](http://ww1.microchip.com/downloads/en/DeviceDoc/20005565B.pdf)**\n\nTo get started reading this thing, and easier grokking, note that:\n   - *The first half* of the datasheet (.pdf) defines internal registers and inter-component behaviors which are all but completely transparent to us. This info can be ignored, but be sure to read the front-matter and any component descriptions.\n   - *The second half* of the datasheet (.pdf) defines the USB HID command and response formats. This is the good stuff that pertains to developers of or using this Go module.\n\n#### Where to get one\nAdafruit makes a crazy cheap, snazzy breakout with built-in 3.3V regulator (with VBUS/5V and 3.3V output pins), an I²C Qwiic/Stemma QT connector (as well as the regular SDA/SCL pins), and best of all a USB-C connector as its programming interface:\n- https://www.adafruit.com/product/4471\n- Only _**$6.50 USD**_ (5 Feb 2020), wow!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fardnew%2Fmcp2221a","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fardnew%2Fmcp2221a","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fardnew%2Fmcp2221a/lists"}