Skip to main content

device_envoy/
lib.rs

1//! Device abstractions for peripherals for Pico 1 and 2 (with and without WiFi).
2//!
3//! # Glossary
4//!
5//! Resources available on the Pico 1 and Pico 2:
6//!
7//! - **PIO ([Programmable I/O](https://medium.com/data-science/nine-pico-pio-wats-with-rust-part-1-9d062067dc25)):** Pico 1 has 2. Pico 2 has 3.
8//! - **DMA ([Direct Memory Access](https://en.wikipedia.org/wiki/Direct_memory_access)):** Both Pico 1 and 2 have 12 channels.
9//! - **PWM ([Pulse Width Modulation](https://en.wikipedia.org/wiki/Pulse-width_modulation)) Slices:** Both  Pico 1 and 2 have 8 slices (& 16 channels). These "slices"
10//!   are unrelated Rust slices.
11#![cfg_attr(not(feature = "host"), no_std)]
12#![cfg_attr(not(feature = "host"), no_main)]
13#![cfg_attr(docsrs, feature(doc_cfg))]
14#![allow(async_fn_in_trait, reason = "single-threaded embedded")]
15
16// Compile-time checks: exactly one board must be selected (unless testing with host feature)
17#[cfg(all(not(any(feature = "pico1", feature = "pico2")), not(feature = "host")))]
18compile_error!("Must enable exactly one board feature: 'pico1' or 'pico2'");
19
20#[cfg(all(feature = "pico1", feature = "pico2"))]
21compile_error!("Cannot enable both 'pico1' and 'pico2' features simultaneously");
22
23// Compile-time checks: exactly one architecture must be selected (unless testing with host feature)
24#[cfg(all(not(any(feature = "arm", feature = "riscv")), not(feature = "host")))]
25compile_error!("Must enable exactly one architecture feature: 'arm' or 'riscv'");
26
27#[cfg(all(feature = "arm", feature = "riscv"))]
28compile_error!("Cannot enable both 'arm' and 'riscv' features simultaneously");
29
30// Compile-time check: pico1 only supports ARM
31#[cfg(all(feature = "pico1", feature = "riscv"))]
32compile_error!("Pico 1 (RP2040) only supports ARM architecture, not RISC-V");
33
34// PIO interrupt bindings - shared by led_strip::strip and led_strip
35#[cfg(not(feature = "host"))]
36#[doc(hidden)]
37// Only include modules that work without embassy when host feature is enabled
38#[cfg(feature = "host")]
39pub(crate) mod bit_matrix_led4;
40#[cfg(not(feature = "host"))]
41#[doc(hidden)]
42pub mod pio_irqs;
43#[cfg(feature = "host")]
44/// Utilities for converting frames to PNG images (host testing only).
45pub mod to_png;
46// These modules require embassy_rp and are excluded when testing on host
47#[cfg(not(feature = "host"))]
48pub(crate) mod bit_matrix_led4;
49#[cfg(not(feature = "host"))]
50pub mod button;
51#[cfg(not(feature = "host"))]
52pub mod char_lcd;
53#[cfg(all(feature = "wifi", not(feature = "host")))]
54pub(crate) mod clock;
55#[cfg(all(feature = "wifi", not(feature = "host")))]
56pub mod clock_sync;
57mod error;
58#[cfg(not(feature = "host"))]
59pub mod flash_array;
60#[cfg(not(feature = "host"))]
61pub mod ir;
62#[cfg(not(feature = "host"))]
63pub mod led;
64pub mod led2d;
65#[cfg(not(feature = "host"))]
66pub mod led4;
67pub mod led_strip;
68#[cfg(not(feature = "host"))]
69pub mod rfid;
70#[cfg(not(feature = "host"))]
71pub mod servo;
72#[cfg(not(feature = "host"))]
73pub mod servo_player;
74#[cfg(not(feature = "host"))]
75pub(crate) mod time_sync;
76#[cfg(all(feature = "wifi", not(feature = "host")))]
77pub mod wifi_auto;
78
79// Re-export error types and result (used throughout)
80pub use crate::error::{Error, Result};