Skip to content

Update docs #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BSD 3-Clause License

Copyright (c) 2023, TinyGo
Copyright (c) 2023-2025 The TinyGo Authors. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Expand Down
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# pio

[![Build](https://github.com/tinygo-org/pio/actions/workflows/build.yml/badge.svg)](https://github.com/tinygo-org/pio/actions/workflows/build.yml)

Provides clean API to interact with RP2040's on-board Programable Input/Output (PIO) block.
See chapter 3 of the [RP2040 datasheet](https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf#page=310) for more information.

Expand Down Expand Up @@ -32,3 +35,34 @@ again:
set pins, 0 ; Drive pin low
jmp again ; Set PC to label `again`
```

### How to install pioasm

To 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:

```shell
git clone [email protected]:raspberrypi/pico-sdk.git
cd pico-sdk/tools/pioasm
cmake .
make
sudo make install
```

### How to develop a PIO program

To develop a PIO program you first start out with the .pio file. Let's look at the Pulsar example first.

1. [`pulsar.pio`](./rp2-pio/piolib/pulsar.pio): specifies a binary PIO program that can be loaded to the PIO program memory.
2. [`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`.
3. [`pulsar_pio.go`](./rp2-pio/piolib/pulsar_pio.go): contains the generated code by the `pioasm` tool.
4. [`pulsar.go`](./rp2-pio/piolib/pulsar.go): contains the User facing code that allows using the PIO as intended by the author.

### Regenerating piolib

```shell
go generate ./...
```

### Other notes

Keep 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!