{"id":25694586,"url":"https://github.com/tinygo-org/pio","last_synced_at":"2025-07-23T14:34:11.202Z","repository":{"id":204068961,"uuid":"711032138","full_name":"tinygo-org/pio","owner":"tinygo-org","description":"Programmable I/O API for RP2040/RP2350 using TinyGo","archived":false,"fork":false,"pushed_at":"2025-03-29T15:59:10.000Z","size":116,"stargazers_count":32,"open_issues_count":5,"forks_count":0,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-06-06T03:43:21.683Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://tinygo.org/","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tinygo-org.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-10-28T02:41:20.000Z","updated_at":"2025-05-06T19:49:09.000Z","dependencies_parsed_at":"2023-11-10T22:21:57.852Z","dependency_job_id":"1d259f3b-d355-46dd-a496-23fcaa426000","html_url":"https://github.com/tinygo-org/pio","commit_stats":null,"previous_names":["tinygo-org/pio"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tinygo-org/pio","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinygo-org%2Fpio","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinygo-org%2Fpio/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinygo-org%2Fpio/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinygo-org%2Fpio/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tinygo-org","download_url":"https://codeload.github.com/tinygo-org/pio/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinygo-org%2Fpio/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266694573,"owners_count":23969795,"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","status":"online","status_checked_at":"2025-07-23T02:00:09.312Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2025-02-25T00:01:12.729Z","updated_at":"2025-07-23T14:34:11.180Z","avatar_url":"https://github.com/tinygo-org.png","language":"Go","funding_links":[],"categories":["Embedded Systems"],"sub_categories":["General use"],"readme":"# pio\n\n[![Build](https://github.com/tinygo-org/pio/actions/workflows/build.yml/badge.svg)](https://github.com/tinygo-org/pio/actions/workflows/build.yml)\n\nProvides clean API to interact with RP2040/RP2350 on-board Programable Input/Output (PIO) block.\nSee chapter 3 of the [RP2040 datasheet](https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf#page=310) for more information.\n\n\n### piolib\nThis module contains the [piolib](./rp2-pio/piolib) package which contains importable drivers for use with a PIO such as:\n\n- SPI driver\n- 8-pin send-only parallel bus\n- WS2812 (Neopixel) driver\n- A pulse-constrained square wave generator (Pulsar)\n\n\n## Introduction to PIO\nThe PIO is a versatile hardware interface. It can support a variety of IO standards,\nincluding:\n- 8080 and 6800 parallel bus\n- I2C\n- 3-pin I2S\n- SDIO\n- SPI, DSPI, QSPI\n- UART\n- DPI or VGA (via resistor DAC)\n\nPIO is programmable in the same sense as a processor and has a total of nine instructions: JMP, WAIT, IN, OUT, PUSH, PULL, MOV, IRQ, and SET. These are programmed in PIO assembly format describing a PIO program, where each command corresponds to one instruction in the output binary. Below is an example program in PIO assembly:\n\n```pio\n.program squarewave\nagain:\n    set pins, 1 [1] ; Drive pin high and then delay for one cycle\n    set pins, 0     ; Drive pin low\n    jmp again       ; Set PC to label `again`\n```\n\n### How to install pioasm\n\nTo develop new code using PIO with this package, you must build and install the `pioasm` tool. It can be be built from the pico-sdk:\n\n```shell\ngit clone git@github.com:raspberrypi/pico-sdk.git\ncd pico-sdk/tools/pioasm\ncmake .\nmake\nsudo make install\n```\n\n### How to develop a PIO program\n\nTo develop a PIO program you first start out with the .pio file. Let's look at the Pulsar example first.\n\n1. [`pulsar.pio`](./rp2-pio/piolib/pulsar.pio): specifies a binary PIO program that can be loaded to the PIO program memory.\n2. [`all_generate.go`](./rp2-pio/piolib/all_generate.go): holds the code generation command on the line with `//go:generate pioasm -o go pulsar.pio     pulsar_pio.go` which by itself generates the raw binary code that can be loaded onto the PIO along with helper code to load it correctly inside `pulsar_pio.go`.\n3. [`pulsar_pio.go`](./rp2-pio/piolib/pulsar_pio.go): contains the generated code by the `pioasm` tool.\n4. [`pulsar.go`](./rp2-pio/piolib/pulsar.go): contains the User facing code that allows using the PIO as intended by the author.\n\n### Regenerating piolib\n\n```shell\ngo generate ./...\n```\n\n### Other notes\n\nKeep in mind PIO programs are very finnicky, especially differentiating between SetOutPins and SetSetPins. The difference is subtle but it can be the difference between spending days debugging a silly conceptual mistake. Have fun!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftinygo-org%2Fpio","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftinygo-org%2Fpio","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftinygo-org%2Fpio/lists"}