コンテンツにスキップ

cortex-m-rt — Crate 詳細

cortex-m-rt

Mature no_std

Cortex-M 向けランタイム(スタートアップ)crate。リセットベクタ・例外ベクタの定義、#[entry] によるエントリポイント指定、例外ハンドラ登録などを提供します。

Runtime and startup support for Cortex-M microcontrollers (reset/exception vectors, #[entry], exception handlers).

バージョン
0.7.4
ライセンス
MIT OR Apache-2.0
メンテナンス
活発に開発中

コード例

#[entry] でエントリポイントを定義し、#[exception] で例外ハンドラを登録できます。

例外ハンドラを定義する
#![no_std]
#![no_main]
use cortex_m_rt::{entry, exception, ExceptionFrame};
use {defmt_rtt as _, panic_probe as _};
#[entry]
fn main() -> ! {
defmt::info!("boot");
loop {
cortex_m::asm::wfi();
}
}
#[exception]
fn HardFault(ef: &ExceptionFrame) -> ! {
defmt::error!("HardFault: pc={=u32}", ef.pc);
loop {
cortex_m::asm::bkpt();
}
}

関連 Crates

関連記事