最小のアプリケーション
これは、可能な限り最小の RTIC アプリケーションです。
//! examples/smallest.rs
#![no_main]
#![no_std]
#![deny(warnings)]
#![deny(unsafe_code)]
#![deny(missing_docs)]
use core::panic::PanicInfo;
use cortex_m_semihosting::debug;
use rtic::app;
#[app(device = lm3s6965)]
mod app {
use super::*;
#[shared]
struct Shared {}
#[local]
struct Local {}
#[init]
fn init(_: init::Context) -> (Shared, Local) {
debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator
(Shared {}, Local {})
}
}
#[panic_handler]
fn panic_handler(_: &PanicInfo) -> ! {
debug::exit(debug::EXIT_FAILURE);
loop {}
}
RTIC は、リソース効率を念頭に置いて設計されています。RTIC 自体はいかなる動的メモリ割り当てにも依存しないため、必要な RAM 量はアプリケーションのみに依存します。割り込みベクタテーブルを含めても、フラッシュメモリの使用量は 1kB 未満です。
最小の例では、次のようなものが想定されます。
$ cargo xtask size --example smallest --backend thumbv7
text data bss dec hex filename
604 0 4 608 260 smallest