[package]
name          = "esp-hal"
version       = "1.0.0-beta.1"
edition       = "2024"
rust-version  = "1.86.0"
description   = "Bare-metal HAL for Espressif devices"
documentation = "https://docs.espressif.com/projects/rust/esp-hal/latest/"
keywords      = ["embedded", "embedded-hal", "esp32", "espressif", "hal"]
categories    = ["embedded", "hardware-support", "no-std"]
repository    = "https://github.com/esp-rs/esp-hal"
license       = "MIT OR Apache-2.0"
links         = "esp-hal"

exclude = [ "api-baseline", "MIGRATING-*", "CHANGELOG.md" ]

[package.metadata.docs.rs]
default-target = "riscv32imac-unknown-none-elf"
features       = ["esp32c6"]
rustdoc-args   = ["--cfg", "docsrs"]

[lib]
bench = false
test  = false

[dependencies]
bitflags                 = "2.9.0"
bytemuck                 = "1.22.0"
cfg-if                   = "1.0.0"
critical-section         = { version = "1.2.0", features = ["restore-state-u32"] }
embedded-hal             = "1.0.0"
embedded-hal-async       = "1.0.0"
enumset                  = "1.1.6"
paste                    = "1.0.15"
portable-atomic          = { version = "1.11.0", default-features = false }

# Unstable dependencies that are not (strictly) part of the public API
bitfield                 = "0.19.0"
delegate                 = "0.13.3"
document-features        = "0.2.11"
embassy-futures          = "0.1.1"
embassy-sync             = "0.6.2"
fugit                    = "0.3.7"
instability              = "0.3.7"
strum                    = { version = "0.27.1", default-features = false, features = ["derive"] }

esp-build                = { version = "0.3.0", path = "../esp-build" }
esp-config               = { version = "0.4.0", path = "../esp-config" }
esp-metadata             = { version = "0.7.0", path = "../esp-metadata", default-features = false }
procmacros               = { version = "0.18.0", package = "esp-hal-procmacros", path = "../esp-hal-procmacros" }

# Dependencies that are optional because they are used by unstable drivers.
# They are needed when using the `unstable` feature.
digest                   = { version = "0.10.7", default-features = false, optional = true }
embassy-usb-driver       = { version = "0.1.0", optional = true }
embassy-usb-synopsys-otg = { version = "0.2.0", optional = true }
embedded-can             = { version = "0.4.1", optional = true }
esp-synopsys-usb-otg     = { version = "0.4.2", optional = true }
nb                       = { version = "1.1.0", optional = true }

# Logging interfaces, they are mutually exclusive so they need to be behind separate features.
defmt                    = { version = "1.0.1", optional = true }
log-04                   = { package = "log", version = "0.4.27", optional = true }

# Optional dependencies that enable ecosystem support.
# We could support individually enabling them, but there is no big downside to just
# enabling them all via the `unstable` feature.
embassy-embedded-hal     = { version = "0.3.0", optional = true }
embedded-io              = { version = "0.6.1", optional = true }
embedded-io-async        = { version = "0.6.1", optional = true }
rand_core-06             = { package = "rand_core", version = "0.6.4", optional = true }
rand_core-09             = { package = "rand_core", version = "0.9.0", optional = true }
ufmt-write               = { version = "0.1.0", optional = true }

# IMPORTANT:
# Each supported device MUST have its PAC included below along with a
# corresponding feature.
esp32   = { version = "0.37.0", features = ["critical-section", "rt"], optional = true }
esp32c2 = { version = "0.26.0", features = ["critical-section", "rt"], optional = true }
esp32c3 = { version = "0.29.0", features = ["critical-section", "rt"], optional = true }
esp32c6 = { version = "0.20.0", features = ["critical-section", "rt"], optional = true }
esp32h2 = { version = "0.16.0", features = ["critical-section", "rt"], optional = true }
esp32s2 = { version = "0.28.0", features = ["critical-section", "rt"], optional = true }
esp32s3 = { version = "0.32.0", features = ["critical-section", "rt"], optional = true }

[target.'cfg(target_arch = "riscv32")'.dependencies]
riscv            = { version = "0.12.1" }
esp-riscv-rt     = { version = "0.11.0", path = "../esp-riscv-rt" }

[target.'cfg(target_arch = "xtensa")'.dependencies]
xtensa-lx        = { version = "0.11.0", path = "../xtensa-lx" }
xtensa-lx-rt     = { version = "0.19.0", path = "../xtensa-lx-rt" }

[build-dependencies]
basic-toml   = "0.1.10"
cfg-if       = "1.0.0"
esp-build    = { version = "0.3.0", path = "../esp-build" }
esp-metadata = { version = "0.7.0", path = "../esp-metadata" }
esp-config   = { version = "0.4.0", path = "../esp-config", features = ["build"] }
serde        = { version = "1.0.219", features = ["derive"] }

[dev-dependencies]
jiff = { version = "0.2.10", default-features = false, features = ["static"] }

[features]
default = []

# These features are considered private and unstable. They are not covered by
# semver guarantees and may change or be removed without notice.
__bluetooth = []
# Reserves FROM_CPU_INTR3 for multi-core MCUs.
__esp_hal_embassy = []
# Reserves FROM_CPU_INTR2 for RISC-V MCUs.
__esp_wifi_builtin_scheduler = []
__usb_otg = [
    "dep:embassy-usb-driver",
    "dep:embassy-usb-synopsys-otg",
    "dep:esp-synopsys-usb-otg",
    "esp-synopsys-usb-otg/esp32sx",
    "esp-synopsys-usb-otg/fs",
]

# Chip Support Feature Flags
# Target the ESP32.
esp32   = [
    "dep:esp32",
    "procmacros/rtc-slow",
    "xtensa-lx-rt/esp32",
]
# Target the ESP32-C2.
esp32c2 = [
    "dep:esp32c2",
    "portable-atomic/unsafe-assume-single-core",
]
# Target the ESP32-C3.
esp32c3 = [
    "dep:esp32c3",
    "esp-riscv-rt/rtc-ram",
    "portable-atomic/unsafe-assume-single-core",
]
# Target the ESP32-C6.
esp32c6 = [
    "dep:esp32c6",
    "esp-riscv-rt/rtc-ram",
    "procmacros/has-lp-core",
]
# Target the ESP32-H2.
esp32h2 = [
    "dep:esp32h2",
    "esp-riscv-rt/rtc-ram",
]
# Target the ESP32-S2.
esp32s2 = [
    "dep:esp32s2",
    "portable-atomic/unsafe-assume-single-core",
    "procmacros/has-ulp-core",
    "procmacros/rtc-slow",
    "xtensa-lx-rt/esp32s2",
    "__usb_otg",
]
# Target the ESP32-S3.
esp32s3 = [
    "dep:esp32s3",
    "procmacros/has-ulp-core",
    "procmacros/rtc-slow",
    "xtensa-lx-rt/esp32s3",
    "__usb_otg",
]


#! ### Logging Feature Flags
## Enable logging output using version 0.4 of the `log` crate.
log-04 = ["dep:log-04"]

## Enable logging output using `defmt` and implement `defmt::Format` on certain types.
defmt = [
    "dep:defmt",
    "embassy-futures/defmt",
    "embassy-sync/defmt",
    "embedded-hal/defmt-03",
    "embedded-io?/defmt-03",
    "embedded-io-async?/defmt-03",
    "enumset/defmt",
    "esp32?/defmt",
    "esp32c2?/defmt",
    "esp32c3?/defmt",
    "esp32c6?/defmt",
    "esp32h2?/defmt",
    "esp32s2?/defmt",
    "esp32s3?/defmt",
    "fugit/defmt",
]

#! ### PSRAM Feature Flags

## Use externally connected PSRAM (`quad` by default, can be configured to `octal` via ESP_HAL_CONFIG_PSRAM_MODE)
psram = []

#! ### Unstable APIs
#! Unstable APIs are drivers and features that are not yet ready for general use.
#! They may be incomplete, have bugs, or be subject to change without notice.
#! Unstable APIs are not covered by semver guarantees.

## Enables APIs that are not stable and thus come with no stability guarantees.
unstable = [
    "dep:digest",
    "dep:embassy-embedded-hal",
    "dep:embedded-can",
    "dep:embedded-io",
    "dep:embedded-io-async",
    "dep:rand_core-06",
    "dep:rand_core-09",
    "dep:nb",
    "dep:ufmt-write",
]

[lints.clippy]
mixed_attributes_style = "allow"

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(host_os, values("windows"))'] }
