From 5ef5e5130ed9d5b106c6052a72fd0f0f61ba0bc8 Mon Sep 17 00:00:00 2001 From: Johnathan Van Why Date: Wed, 12 Jan 2022 15:11:29 -0800 Subject: [PATCH] Add the first libtock2 example. This example just tries to print 2 numbers using the LowLevelDebug capsule. It's primary benefit is as a testing and debugging tool, as it is almost as simple as possible while still providing enough output to know it's working. --- libtock2/Cargo.toml | 4 ++++ libtock2/examples/low_level_debug.rs | 16 ++++++++++++++++ libtock2/src/lib.rs | 2 ++ 3 files changed, 22 insertions(+) create mode 100644 libtock2/examples/low_level_debug.rs diff --git a/libtock2/Cargo.toml b/libtock2/Cargo.toml index 4a4f302d..e4b37d2a 100644 --- a/libtock2/Cargo.toml +++ b/libtock2/Cargo.toml @@ -13,3 +13,7 @@ version = "0.1.0" libtock_platform = { path = "../platform" } libtock_runtime = { path = "../runtime" } libtock_low_level_debug = { path = "../apis/low_level_debug" } + +# TODO: Implement a panic handler with more debugging functionality, then +# replace libtock_small_panic with the debug-heavy panic handler here. +libtock_small_panic = { path = "../panic_handlers/small_panic" } diff --git a/libtock2/examples/low_level_debug.rs b/libtock2/examples/low_level_debug.rs new file mode 100644 index 00000000..c4351b09 --- /dev/null +++ b/libtock2/examples/low_level_debug.rs @@ -0,0 +1,16 @@ +//! An extremely simple libtock-rs example. Just prints out a few numbers using +//! the LowLevelDebug capsule then terminates. + +#![no_main] +#![no_std] + +use libtock2::low_level_debug::LowLevelDebug; +use libtock2::runtime::{set_main, stack_size}; + +set_main! {main} +stack_size! {0x100} + +fn main() { + LowLevelDebug::print_1(1); + LowLevelDebug::print_2(2, 3); +} diff --git a/libtock2/src/lib.rs b/libtock2/src/lib.rs index 9694779f..616a5d40 100644 --- a/libtock2/src/lib.rs +++ b/libtock2/src/lib.rs @@ -1,6 +1,8 @@ #![forbid(unsafe_code)] #![no_std] +extern crate libtock_small_panic; + pub use libtock_platform as platform; pub use libtock_runtime as runtime;