Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
RPSP
RP2040 Platform Support Package
Rust library for easy methods to program and design programs for RP2040 devices.
Device Selection
To select the proper pin layout, you must specify the device in the "features" when declaring this crate as a depdency.
Example for the PiPico
rpsp = { version = "0.1.0", features = [ "pico" ] }
Supported Devices
The following device pinouts are supported:
- Pico / PicoW (
pico) - Tiny2040 (
tiny2040) - Seed Studio 2040 (
xiao2040)
If your device has no support, you can still use the pico deice, but BE CAREFUL
OF THE PINS USED.
I'm open to more devices, I just don't have examples to use _
Note
You'll need to make sure you have the flip-link linker installed before compiling.
To do this, use the command cargo install cargo-expand to install it.
Additional Cargo Configuration
For best results, create a .cargo/config.toml file in your project root directory
and specify somthing like this:
[]
= [
"-C", "linker=flip-link",
"-C", "link-arg=--nmagic",
"-C", "link-arg=-Tlink.x",
"-Z", "trap-unreachable=no",
"-C", "no-vectorize-loops",
]
[]
= "thumbv6m-none-eabi"
Requires the nightly version of the compiler to use "-Z", "trap-unreachable=no",
and can be removed, but will increase binary size slightly.
Extra bonus points if you add:
= "probe-rs run --chip RP2040"
Under the rustflags option. This allows you to flash the firmware on the device
directly from cargo run. (Pico debug probe probe and probe-rs required. Can be
installed using cargo install probe-rs-tools. Pico probe can be made from another
Pico! see here).
Lastly, these are the recommended profile settings for best program results. These
go inside the Cargo.toml file in the project root directory.
[]
= 2
= false
= 3
= false
= 1
= true
= true
[]
= "fat"
= "abort"
= false
= true
= 3
= false
= 1
= false
= false
Usage
To use this library, just import rpsp::Pico and call Pico::get(). On the first
call, the device and it's clocks will be initialized and setup fully.
The configuration is automatic and uses the ROSC as the system clock, disables the XOSC and PLLs and allows for DORMANT sleep, for maximum power savings.
To supply main, you must setup the main function with the #[rpsp::entry] macro,
which will setup the locks and properly redirect execution to the selected function.
Basic programs should look something like this:
!
If you're not using something like defmt, (which is not included by default)
you'll need a panic_handler. The example below is a pretty basic one that just
loops the CPU:
!
For the below examples, the panic_handler is omitted, so if you want to use
these, you'll need to add it in order for it to compile.
GPIO
Control Pin output:
use Pico
use PinID;
!
Read Pin output:
use Pico
use PinID;
!
UART
use Pico
use PinID;
use ;
!
Time and Sleep
use Pico
!
Watchdog
use Pico
!
Theres alot of more examples I need to add..
TODO
- CYW Driver
- Networking??
License for the CYW driver is here