esp_rom_sys/
lib.rs

1#![doc = include_str!("../README.md")]
2//! ## Feature Flags
3#![doc = document_features::document_features!()]
4#![doc(html_logo_url = "https://avatars.githubusercontent.com/u/46717278")]
5#![allow(rustdoc::bare_urls)]
6#![no_std]
7
8#[doc(hidden)]
9/// Helper macro for checking doctest code snippets
10#[macro_export]
11macro_rules! before_snippet {
12    () => {
13        r#"
14# #![no_std]
15# use procmacros::handler;
16# use esp_hal::{interrupt::{self, InterruptConfigurable}, time::{Duration, Instant, Rate}};
17# macro_rules! println {
18#     ($($tt:tt)*) => { };
19# }
20# macro_rules! print {
21#     ($($tt:tt)*) => { };
22# }
23# #[panic_handler]
24# fn panic(_ : &core::panic::PanicInfo) -> ! {
25#     loop {}
26# }
27# fn main() {
28#   let _ = example();
29# }
30# struct ExampleError {}
31# impl <T> From<T> for ExampleError where T: core::fmt::Debug {
32#   fn from(_value: T) -> Self {
33#       Self{}
34#   }
35# }
36# async fn example() -> Result<(), ExampleError> {
37#   let mut peripherals = esp_hal::init(esp_hal::Config::default());
38"#
39    };
40}
41
42pub mod rom;
43
44/// This is needed by `libesp_rom.a` (if used)
45/// Other crates (i.e. esp-wifi) also rely on this being defined somewhere
46#[unsafe(no_mangle)]
47unsafe extern "C" fn __assert_func(
48    file: *const core::ffi::c_char,
49    line: u32,
50    func: *const core::ffi::c_char,
51    expr: *const core::ffi::c_char,
52) {
53    unsafe {
54        panic!(
55            "__assert_func in {}:{} ({}): {}",
56            core::ffi::CStr::from_ptr(file).to_str().unwrap(),
57            line,
58            core::ffi::CStr::from_ptr(func).to_str().unwrap(),
59            core::ffi::CStr::from_ptr(expr).to_str().unwrap(),
60        );
61    }
62}