[package]
name          = "esp-println"
version       = "0.14.0"
edition       = "2024"
rust-version  = "1.86.0"
description   = "Provides `print!` and `println!` implementations various Espressif devices"
documentation = "https://docs.espressif.com/projects/rust/esp-println/latest/"
keywords      = ["defmt", "embedded", "esp32", "espressif", "logging"]
categories    = ["embedded", "hardware-support", "no-std"]
repository    = "https://github.com/esp-rs/esp-hal"
license       = "MIT OR Apache-2.0"
links         = "esp-println"

[package.metadata.docs.rs]
cargo-args     = ["-Z", "build-std=core"]
default-target = "riscv32imc-unknown-none-elf"
features       = ["esp32c3"]

[lib]
bench = false
test  = false

[dependencies]
document-features = "0.2.11"

# Optional dependencies
critical-section = { version = "1.2.0", optional = true }
portable-atomic  = { version = "1.11.0", optional = true, default-features = false }

# 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 }

[build-dependencies]
esp-build    = { version = "0.3.0", path = "../esp-build" }
esp-metadata = { version = "0.7.0", path = "../esp-metadata" }
log-04       = { package = "log", version = "0.4.27" }

[features]
default          = ["auto", "colors", "critical-section"]

esp32   = []
esp32c2 = []
esp32c3 = []
esp32c6 = []
esp32h2 = []
esp32p4 = []
esp32s2 = []
esp32s3 = []

## Use a critical section around print calls. This ensures that the output is consistent.
critical-section = ["dep:critical-section"]
## Prints the timestamp in the log message.
##
## This option requires the following function to be implemented:
##
## ```rust
## extern "Rust" {
##     fn _esp_println_timestamp() -> u64;
## }
## ```
##
## This function should return the current timestamp in milliseconds since power on.
## When using [`esp_hal`], you can define this function as follows:
##
## ```rust
## #[no_mangle]
## pub extern "Rust" fn _esp_println_timestamp() -> u64 {
##     esp_hal::time::Instant::now()
##         .duration_since_epoch()
##         .as_millis()
## }
## ```
##
## [`esp_hal`]: https://crates.io/crates/esp-hal
timestamp = []

#! ### Output interfaces
#! You must enable exactly 1 of the below features to enable to intended
#! communication method.

## Automatically select the best output interface for the target.
auto        = ["dep:portable-atomic"]
## Use the `USB_SERIAL_JTAG` interface for printing. Available on ESP32-C3, ESP32-C6, ESP32-H2, ESP32-P4, and ESP32-S3.
jtag-serial = ["dep:portable-atomic"]
## Use the `UART0` peripehral for printing. Available on all devices.
uart        = []
## Don't print anything
no-op       = []

#! ### Logging framework features
## Enables using the `log` crate for logging.
log-04         = ["dep:log-04"]
## Enables printing using `defmt`.
##
## defmt-encoded output can only be read using espflash. With esp_hal, this works out of the box.
## Without esp_hal, you need to set the `--log-format defmt` argument for espflash.
defmt-espflash = ["dep:defmt", "defmt?/encoding-rzcobs"]

#! ### `log`-specific features
## Colors the message severity in the terminal.
colors = []

[lints.rust]
static_mut_refs = "allow"
