device-kit 0.0.1-alpha

Experimental composable, async device abstractions for Raspberry Pi Pico using Embassy (use from GitHub for latest features)
[workspace]
members = ["xtask"]
default-members = ["."]

[package]
edition = "2024"
# if this changes, update .vscode/launch.json and .cargo/config.toml
name = "device-kit"
version = "0.0.1-alpha"
authors = ["Carl M. Kadie"]
description = "Experimental composable, async device abstractions for Raspberry Pi Pico using Embassy (use from GitHub for latest features)"
repository = "https://github.com/CarlKCarlK/device-kit"
license = "MIT OR Apache-2.0"
keywords = ["embedded", "pico", "embassy", "async", "no-std"]
categories = ["embedded", "no-std", "hardware-support"]
readme = "README.md"

# Pure library crate - all applications are in examples/
[lib]
name = "device_kit"
path = "src/lib.rs"

# Compile-only tests (not run, just type-checked)
[[bin]]
name = "led12x4"
path = "tests-compile-only/led12x4.rs"
required-features = ["pico1"]

[[bin]]
name = "led2d_custom_mapping"
path = "tests-compile-only/led2d_custom_mapping.rs"
required-features = ["pico1"]

[[bin]]
name = "led2d_multiple"
path = "tests-compile-only/led2d_multiple.rs"
required-features = ["pico1"]

[features]
default = ["defmt", "pico1", "arm"]
defmt = []
pico1 = ["dep:embassy-rp"]
pico2 = ["dep:embassy-rp", "dep:rp235x-hal"]
arm = [
    "dep:cortex-m",
    "dep:cortex-m-rt",
    "embassy-executor/arch-cortex-m",
    "dep:embassy-hal-internal",
    "embassy-hal-internal/cortex-m",
    "embassy-hal-internal/prio-bits-2",
    "critical-section/restore-state-u8",
]
riscv = [
    "dep:riscv",
    "dep:riscv-rt",
    "embassy-executor/arch-riscv32",
    "dep:embassy-hal-internal",
    "critical-section/restore-state-bool",
]
host = ["dep:png", "dep:tempfile"] # For testing on host platform without hardware dependencies
# Note: wifi features require git dependencies - use from GitHub for WiFi support
# wifi = ["dep:cyw43", "dep:cyw43-pio", "dep:cyw43-firmware", "dep:embassy-net"]
display-trace = []

[dependencies]
defmt = "0.3.10"
defmt-rtt = "1.1.0"
panic-probe = { version = "1.0.0", features = ["print-defmt"] }

# ARM Cortex-M dependencies (for Pico 1 and Pico 2 ARM core)
cortex-m-rt = { version = "0.7.5", optional = true }
cortex-m = { version = "0.7.7", optional = true }

# RISC-V dependencies (for Pico 2 RISC-V core)
riscv-rt = { version = "0.12", optional = true }
riscv = { version = "0.11", features = [
    "critical-section-single-hart",
], optional = true }

embassy-executor = { version = "0.9", default-features = false, features = [
    "executor-thread",
    "defmt",
] }
embassy-sync = { version = "0.6" }
embassy-rp = { version = "0.2", default-features = false, features = [
    "rt",
    "defmt",
    "time-driver",
    "critical-section-impl",
], optional = true }
embassy-futures = { version = "0.1" }
embassy-time = { version = "0.3", features = [
    "defmt",
] }
derive_more = { version = "2.0.1", default-features = false, features = [
    "debug",
    "display",
    "error",
    "from",
] }
# num-bigint = { version = "0.4.6", default-features = false }
heapless = { version = "0.8.0", features = ["serde"] }
time = { version = "0.3", default-features = false }
serde = { version = "1.0", default-features = false, features = ["derive"] }
postcard = { version = "1.0", default-features = false }
rp235x-hal = { version = "0.3", package = "rp235x-hal", features = [
    "rt",
], optional = true }
smart-leds = "0.4.0"
itertools = { version = "0.13.0", default-features = false }
crc32fast = { version = "1.4.0", default-features = false }
critical-section = { version = "1.2.0", default-features = false }
embedded-hal = "1.0.0"
embedded-hal-async = "1.0.0"
embedded-io-async = "0.6.1"
embedded-hal-bus = { version = "0.3.0", features = [
    "async",
    "portable-atomic",
] }
portable-atomic = { version = "1.11.1", features = ["critical-section"] }
hd44780-driver = "0.4.0"
esp-hal-mfrc522 = "0.3.2"
fixed = "1.28.0"
# WiFi dependencies require git versions - use from GitHub for WiFi support
# cyw43 = { version = "0.6", features = [
#     "defmt",
#     "firmware-logs",
# ], optional = true }
# cyw43-pio = { version = "0.2", features = [
#     "defmt",
# ], optional = true }
# cyw43-firmware = { version = "0.1", features = ["wifi"], optional = true }
# embassy-net = { version = "0.5", features = [
#     "defmt",
#     "tcp",
#     "udp",
#     "dhcpv4",
#     "dns",
#     "medium-ethernet",
# ], optional = true }
static_cell = "2.1.0"
embassy-hal-internal = { version = "0.2", default-features = false, optional = true }
paste = "1.0"
embedded-graphics = { version = "0.8", default-features = false }
png = { version = "0.17", optional = true }
tempfile = { version = "3.13", optional = true }

# Integration tests
[[test]]
name = "led2d_text_render"
path = "tests/led2d_text_render.rs"
required-features = ["host"]

# Note: [patch.crates-io] section removed for crates.io publishing
# Use the main branch from GitHub for latest Embassy features

[lints.rust]
# To use the `unsafe` keyword, do not remove the `unsafe_code = "forbid"` entry.
# Instead, prefer to change it to `unsafe_code = "deny"` + opt-in with local use of
# `#[expect(unsafe_code)]`'s on an as needed basis.
bare_trait_objects = "forbid"
rust_2018_idioms = { level = "warn", priority = -2 }
# TODO: Remove when this is stabilized and/or works better. It's giving many false positives at time of writing (2024-08).
unfulfilled_lint_expectations = "warn"
unknown_lints = "warn"
unsafe_code = "deny"
unused_variables = "warn"
# TODO: Determine why `#[expect(unexpected_cfgs)]` at the site of the problem
#       (`target_pointer_width = 128`) is ineffective; the setting below is overly broad
unexpected_cfgs = "warn"

# Uncomment before ship to reconcile use of possibly redundant crates, debug remnants, missing
# license files and more
#missing_docs = "warn"
#warnings = "deny"

[lints.clippy]
# Safety-critical application lints
arithmetic_side_effects = "deny"
float_cmp_const = "deny"
indexing_slicing = "deny"
pedantic = { level = "deny", priority = -2 }
semicolon_if_nothing_returned = "warn"
semicolon_inside_block = "warn"
str_to_string = "warn"
unwrap_used = "deny"
unused_result = "deny"
wildcard_imports = "deny"

all = { level = "warn", priority = -2 }
nursery = { level = "warn", priority = -2 }
# End of safety-critical application lints

allow_attributes = "warn"
allow_attributes_without_reason = "deny"
# TODO cargo_common_metadata = { level = "warn", priority = -1 }
# TODO doc_markdown = "warn"
enum_glob_use = "forbid"
enum_variant_names = "warn"
equatable_if_let = "warn"
error_impl_error = "allow"
implicit_return = "allow"
integer_division_remainder_used = "warn"
items-after-statements = "warn"
iter_nth_zero = "warn"
match_bool = "warn"
match-same-arms = "warn"
min_ident_chars = "warn"
missing_docs_in_private_items = { level = "allow", priority = -1 }
missing_errors_doc = "warn"
missing_trait_methods = "warn"
module_name_repetitions = "warn"
multiple_crate_versions = "allow"
obfuscated_if_else = "warn"
pub_use = "allow"
pub_with_shorthand = "warn"
question_mark_used = "allow"
self_named_module_files = "warn"
semicolon_outside_block = "warn"
separated_literal_suffix = "warn"
shadow_reuse = "warn"
shadow_unrelated = "warn"
similar_names = "warn"
single_call_fn = "allow"
std_instead_of_alloc = "warn"
std_instead_of_core = "warn"
too_long_first_doc_paragraph = "warn"
unnecessary_wraps = "warn"
unreachable = "warn"
must_use_candidate = "warn"
unused_must_use = "warn"
# TODO: Uncomment before ship to reconcile use of possibly redundant crates, debug remnants, missing
# license files and more
# blanket_clippy_restriction_lints = "warn"
#cargo = "warn"
# restriction = "warn"

# BUGBUG cmk: Revisit if binaries get too large - debug symbols increase binary size
# but are needed for defmt to show proper file locations instead of frame indexes
[profile.dev]
panic = "abort"

[profile.release]
debug = 2
panic = "abort"