esp_hal/rom/mod.rs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
//! # ESP ROM libraries
//!
//! ## Overview
//! The `rom` driver provides functionality related to the ROM (Read-Only
//! Memory) on ESP chips. It includes implementations for the [CRC (Cyclic
//! Redundancy Check)] and [MD5 (Message Digest 5)] algorithms.
//!
//! The driver's functionality allows users to perform CRC calculations and MD5
//! hashing using the ROM functions provided by the ESP chip. This can be useful
//! for various applications that require data integrity checks or cryptographic
//! operations.
//!
//! It uses `CRC` error-checking techniques to detect changes in data during
//! transmission or storage.
//!
//! This module also implements the `MD5` algorithm, which is widely used for
//! cryptographic hash function. It's commonly used to verify data integrity and
//! to check whether the data has been modified.
//!
//! Safe abstractions to the additional libraries provided in the ESP's
//! Read-Only Memory.
//!
//! [CRC (Cyclic Redundancy Check)]: ./crc/index.html
//! [MD5 (Message Digest 5)]: ./md5/index.html
#![allow(unused_macros)]
#[cfg(any(rom_crc_be, rom_crc_le))]
pub mod crc;
#[cfg(any(rom_md5_bsd, rom_md5_mbedtls))]
pub mod md5;
#[allow(unused)]
extern "C" {
pub(crate) fn rom_i2c_writeReg(block: u32, block_hostid: u32, reg_add: u32, indata: u32);
pub(crate) fn rom_i2c_writeReg_Mask(
block: u32,
block_hostid: u32,
reg_add: u32,
reg_add_msb: u32,
reg_add_lsb: u32,
indata: u32,
);
}
macro_rules! regi2c_write {
( $block: ident, $reg_add: ident, $indata: expr ) => {
paste::paste! {
#[allow(unused_unsafe)]
unsafe {
$crate::rom::rom_i2c_writeReg(
$block as u32,
[<$block _HOSTID>] as u32,
$reg_add as u32,
$indata as u32
)
}
}
};
}
#[allow(unused_imports)]
pub(crate) use regi2c_write;
macro_rules! regi2c_write_mask {
( $block: ident, $reg_add: ident, $indata: expr ) => {
paste::paste! {
#[allow(unused_unsafe)]
unsafe {
$crate::rom::rom_i2c_writeReg_Mask(
$block as u32,
[<$block _HOSTID>] as u32,
$reg_add as u32,
[<$reg_add _MSB>] as u32,
[<$reg_add _LSB>] as u32,
$indata as u32
)
}
}
};
}
#[allow(unused_imports)]
pub(crate) use regi2c_write_mask;
#[inline(always)]
pub(crate) fn ets_delay_us(us: u32) {
extern "C" {
fn ets_delay_us(us: u32);
}
unsafe { ets_delay_us(us) };
}
#[allow(unused)]
#[inline(always)]
pub(crate) fn ets_update_cpu_frequency_rom(ticks_per_us: u32) {
extern "C" {
fn ets_update_cpu_frequency(ticks_per_us: u32);
}
unsafe { ets_update_cpu_frequency(ticks_per_us) };
}
#[inline(always)]
pub(crate) fn rtc_get_reset_reason(cpu_num: u32) -> u32 {
extern "C" {
fn rtc_get_reset_reason(cpu_num: u32) -> u32;
}
unsafe { rtc_get_reset_reason(cpu_num) }
}
#[inline(always)]
pub(crate) fn software_reset_cpu(cpu_num: u32) {
extern "C" {
fn software_reset_cpu(cpu_num: u32);
}
unsafe { software_reset_cpu(cpu_num) };
}
#[inline(always)]
pub(crate) fn software_reset() -> ! {
extern "C" {
fn software_reset() -> !;
}
unsafe { software_reset() }
}
#[cfg(esp32s3)]
#[inline(always)]
pub(crate) fn ets_set_appcpu_boot_addr(boot_addr: u32) {
extern "C" {
fn ets_set_appcpu_boot_addr(boot_addr: u32);
}
unsafe { ets_set_appcpu_boot_addr(boot_addr) };
}