[package]
name          = "esp-hal"
version       = "0.22.0"
edition       = "2021"
rust-version  = "1.83.0"
description   = "Bare-metal HAL for Espressif devices"
documentation = "https://docs.esp-rs.org/esp-hal/"
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"

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

[dependencies]
bitflags                 = "2.6.0"
bytemuck                 = "1.19.0"
bitfield                 = "0.17.0"
cfg-if                   = "1.0.0"
chrono                   = { version = "0.4.38", default-features = false }
critical-section         = "1.2.0"
defmt                    = { version = "0.3.8", optional = true }
delegate                 = "0.13.1"
digest                   = { version = "0.10.7", default-features = false, optional = true }
document-features        = "0.2.10"
embassy-embedded-hal     = { version = "0.2.0", optional = true }
embassy-futures          = "0.1.1"
embassy-sync             = "0.6.1"
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 }
embedded-hal             = "1.0.0"
embedded-hal-async       = "1.0.0"
embedded-hal-nb          = "1.0.0"
embedded-io              = { version = "0.6.1", optional = true }
embedded-io-async        = { version = "0.6.1", optional = true }
enumset                  = "1.1.5"
esp-build                = { version = "0.1.0", path = "../esp-build" }
esp-synopsys-usb-otg     = { version = "0.4.2", optional = true, features = ["fs", "esp32sx"] }
fugit                    = "0.3.7"
instability              = "0.3"
log                      = { version = "0.4.22", optional = true }
nb                       = "1.1.0"
paste                    = "1.0.15"
portable-atomic          = { version = "1.9.0", default-features = false }
procmacros               = { version = "0.15.0", package = "esp-hal-procmacros", path = "../esp-hal-procmacros" }
strum                    = { version = "0.26.3", default-features = false, features = ["derive"] }
void                     = { version = "1.0.2", default-features = false }
usb-device               = { version = "0.3.2", optional = true }
rand_core                = "0.6.4"
ufmt-write               = "0.1.0"

# IMPORTANT:
# Each supported device MUST have its PAC included below along with a
# corresponding feature.
esp32   = { version = "0.34.0", features = ["critical-section", "rt"], git = "https://github.com/esp-rs/esp-pacs", rev = "ffbee35069d137ef611097d39fa7734c299ce124", optional = true }
esp32c2 = { version = "0.23.0", features = ["critical-section", "rt"], git = "https://github.com/esp-rs/esp-pacs", rev = "ffbee35069d137ef611097d39fa7734c299ce124", optional = true }
esp32c3 = { version = "0.26.0", features = ["critical-section", "rt"], git = "https://github.com/esp-rs/esp-pacs", rev = "ffbee35069d137ef611097d39fa7734c299ce124", optional = true }
esp32c6 = { version = "0.17.0", features = ["critical-section", "rt"], git = "https://github.com/esp-rs/esp-pacs", rev = "ffbee35069d137ef611097d39fa7734c299ce124", optional = true }
esp32h2 = { version = "0.13.0", features = ["critical-section", "rt"], git = "https://github.com/esp-rs/esp-pacs", rev = "ffbee35069d137ef611097d39fa7734c299ce124", optional = true }
esp32s2 = { version = "0.25.0", features = ["critical-section", "rt"], git = "https://github.com/esp-rs/esp-pacs", rev = "ffbee35069d137ef611097d39fa7734c299ce124", optional = true }
esp32s3 = { version = "0.29.0", features = ["critical-section", "rt"], git = "https://github.com/esp-rs/esp-pacs", rev = "ffbee35069d137ef611097d39fa7734c299ce124", optional = true }

[target.'cfg(target_arch = "riscv32")'.dependencies]
riscv            = { version = "0.12.1" }
esp-riscv-rt     = { version = "0.9.1", path = "../esp-riscv-rt" }
critical-section = { version = "1.2.0", features = ["restore-state-u8"] }

[target.'cfg(target_arch = "xtensa")'.dependencies]
xtensa-lx        = { version = "0.9.0", path = "../xtensa-lx" }
xtensa-lx-rt     = { version = "0.17.2", path = "../xtensa-lx-rt" }
critical-section = { version = "1.2.0", features = ["restore-state-u32"] }

[build-dependencies]
basic-toml   = "0.1.9"
cfg-if       = "1.0.0"
esp-build    = { version = "0.1.0", path = "../esp-build" }
esp-metadata = { version = "0.4.0", path = "../esp-metadata" }
esp-config   = { version = "0.2.0", path = "../esp-config", features = ["build"] }
serde        = { version = "1.0.215", features = ["derive"] }

[features]
default = []

bluetooth = []

usb-otg = ["dep:embassy-usb-driver", "dep:embassy-usb-synopsys-otg", "dep:esp-synopsys-usb-otg", "dep:usb-device"]

__esp_hal_embassy = []

## Enable debug features in the HAL (used for development).
debug = [
    "esp32?/impl-register-debug",
    "esp32c2?/impl-register-debug",
    "esp32c3?/impl-register-debug",
    "esp32c6?/impl-register-debug",
    "esp32h2?/impl-register-debug",
    "esp32s2?/impl-register-debug",
    "esp32s3?/impl-register-debug",
]
## Enable logging output using the `log` crate.
log = ["dep:log"]

# 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/critical-section", "procmacros/has-ulp-core", "procmacros/rtc-slow", "usb-otg", "xtensa-lx-rt/esp32s2"]
# Target the ESP32-S3.
esp32s3 = ["dep:esp32s3", "procmacros/has-ulp-core", "procmacros/rtc-slow", "usb-otg", "xtensa-lx-rt/esp32s3"]

#! ### RISC-V Exclusive Feature Flags
## Move the stack to start of RAM to get zero-cost stack overflow protection
## (ESP32-C6 and ESPS32-H2 only!).
flip-link = ["esp-riscv-rt/fix-sp"]

#! ### Trait Implementation Feature Flags
## 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",
    "esp32?/defmt",
    "esp32c2?/defmt",
    "esp32c3?/defmt",
    "esp32c6?/defmt",
    "esp32h2?/defmt",
    "esp32s2?/defmt",
    "esp32s3?/defmt",
    "fugit/defmt",
]

#! ### PSRAM Feature Flags
## Use externally connected Quad PSRAM
quad-psram = []

## Use externally connected Octal RAM
octal-psram = []

# This feature is intended for testing; you probably don't want to enable it:
ci = ["defmt", "bluetooth"]

#! ### 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:embassy-embedded-hal",
    "dep:embedded-can",
    "dep:embedded-io",
    "dep:embedded-io-async",
]

[lints.clippy]
mixed_attributes_style = "allow"

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