From 026cdca2b73ae2cced526b04b72151bc0d9b1721 Mon Sep 17 00:00:00 2001 From: Andrew Walbran Date: Tue, 14 Feb 2023 04:26:39 +0000 Subject: [PATCH] Use micro:bit v2 for temperature logger example. --- .../temperature-logger/.cargo/config.toml | 2 + .../bare-metal/temperature-logger/Cargo.lock | 260 ++++++++++++++++++ .../bare-metal/temperature-logger/Cargo.toml | 1 + .../bare-metal/temperature-logger/src/main.rs | 28 ++ 4 files changed, 291 insertions(+) create mode 100644 src/exercises/bare-metal/temperature-logger/.cargo/config.toml diff --git a/src/exercises/bare-metal/temperature-logger/.cargo/config.toml b/src/exercises/bare-metal/temperature-logger/.cargo/config.toml new file mode 100644 index 00000000..9d7c3443 --- /dev/null +++ b/src/exercises/bare-metal/temperature-logger/.cargo/config.toml @@ -0,0 +1,2 @@ +[build] +target = "thumbv7em-none-eabihf" # Cortex-M4F diff --git a/src/exercises/bare-metal/temperature-logger/Cargo.lock b/src/exercises/bare-metal/temperature-logger/Cargo.lock index b3c7cdc5..ec3da7b5 100644 --- a/src/exercises/bare-metal/temperature-logger/Cargo.lock +++ b/src/exercises/bare-metal/temperature-logger/Cargo.lock @@ -2,6 +2,63 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "az" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b7e4c2464d97fe331d41de9d5db0def0a96f4d823b8b32a2efd503578988973" + +[[package]] +name = "bare-metal" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5deb64efa5bd81e31fcd1938615a6d98c82eafcbcd787162b6f63b91d6bac5b3" +dependencies = [ + "rustc_version", +] + +[[package]] +name = "bare-metal" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8fe8f5a8a398345e52358e18ff07cc17a568fbca5c6f73873d3a62056309603" + +[[package]] +name = "bitfield" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46afbd2983a5d5a7bd740ccb198caf5b82f45c40c09c0eed36052d91cb92e719" + +[[package]] +name = "bytemuck" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c041d3eab048880cb0b86b256447da3f18859a163c3b8d8893f4e6368abe6393" + +[[package]] +name = "cast" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "cortex-m" +version = "0.7.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ec610d8f49840a5b376c69663b6369e71f4b34484b9b2eb29fb918d92516cb9" +dependencies = [ + "bare-metal 0.2.5", + "bitfield", + "embedded-hal", + "volatile-register", +] + [[package]] name = "cortex-m-rt" version = "0.7.2" @@ -22,6 +79,37 @@ dependencies = [ "syn", ] +[[package]] +name = "critical-section" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1706d332edc22aef4d9f23a6bb1c92360a403013c291af51247a737472dcae6" +dependencies = [ + "bare-metal 1.0.0", + "critical-section 1.1.1", +] + +[[package]] +name = "critical-section" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6548a0ad5d2549e111e1f6a11a6c2e2d00ce6a3dafe22948d67c2b443f775e52" + +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + +[[package]] +name = "embedded-dma" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46c8c02e4347a0267ca60813c952017f4c5948c232474c6010a381a337f1bda4" +dependencies = [ + "stable_deref_trait", +] + [[package]] name = "embedded-hal" version = "0.2.7" @@ -32,6 +120,53 @@ dependencies = [ "void", ] +[[package]] +name = "embedded-storage" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "723dce4e9f25b6e6c5f35628e144794e5b459216ed7da97b7c4b66cdb3fa82ca" + +[[package]] +name = "fixed" +version = "1.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55f3be4cf4fc227d3a63bb77512a2b7d364200b2a715f389155785c4d3345495" +dependencies = [ + "az", + "bytemuck", + "half", + "typenum", +] + +[[package]] +name = "half" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02b4af3693f1b705df946e9fe5631932443781d0aabb423b62fcd4d73f6d2fd0" +dependencies = [ + "crunchy", +] + +[[package]] +name = "microbit-common" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45651d001be4281a6f4536c30f3d8522f231bc56fd58d5baf2c630f565d31256" +dependencies = [ + "embedded-hal", + "nrf52833-hal", + "tiny-led-matrix", +] + +[[package]] +name = "microbit-v2" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9895242259950730bc112623e4a2e37345dc51ddb5fc8878c110489260d84e7" +dependencies = [ + "microbit-common", +] + [[package]] name = "nb" version = "0.1.3" @@ -47,6 +182,61 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "546c37ac5d9e56f55e73b677106873d9d9f5190605e41a856503623648488cae" +[[package]] +name = "nrf-hal-common" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd37b3fd039327b4005cc0d4ef20bce0a41bf521071774d5adb854e4b1230639" +dependencies = [ + "cast", + "cfg-if", + "cortex-m", + "embedded-dma", + "embedded-hal", + "embedded-storage", + "fixed", + "nb 1.0.0", + "nrf-usbd", + "nrf52833-pac", + "rand_core", + "void", +] + +[[package]] +name = "nrf-usbd" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "640e88d4c108743c667f03320d0c9ab24a20f183a7a1b18bde7891ee13fd92c5" +dependencies = [ + "bare-metal 1.0.0", + "cortex-m", + "critical-section 0.2.8", + "usb-device", + "vcell", +] + +[[package]] +name = "nrf52833-hal" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87f76d269c9a239ffe24edaa5ee0972b102c04e898b464e3e9a12ab0eacd5f76" +dependencies = [ + "embedded-hal", + "nrf-hal-common", + "nrf52833-pac", +] + +[[package]] +name = "nrf52833-pac" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd69bdb25903e18e098c040ef31dc863814437af010dea8bd55aa31f686cb461" +dependencies = [ + "cortex-m", + "cortex-m-rt", + "vcell", +] + [[package]] name = "panic-halt" version = "0.2.0" @@ -71,6 +261,42 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" + +[[package]] +name = "rustc_version" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +dependencies = [ + "semver", +] + +[[package]] +name = "semver" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" +dependencies = [ + "semver-parser", +] + +[[package]] +name = "semver-parser" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" + +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + [[package]] name = "syn" version = "1.0.107" @@ -88,17 +314,51 @@ version = "0.1.0" dependencies = [ "cortex-m-rt", "embedded-hal", + "microbit-v2", "panic-halt", ] +[[package]] +name = "tiny-led-matrix" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a718c727b686154a7c7913f70d7ebc8956f701cbab466bc22035cb27f378882b" + +[[package]] +name = "typenum" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" + [[package]] name = "unicode-ident" version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" +[[package]] +name = "usb-device" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f6cc3adc849b5292b4075fc0d5fdcf2f24866e88e336dd27a8943090a520508" + +[[package]] +name = "vcell" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77439c1b53d2303b20d9459b1ade71a83c716e3f9c34f3228c00e6f185d6c002" + [[package]] name = "void" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" + +[[package]] +name = "volatile-register" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ee8f19f9d74293faf70901bc20ad067dc1ad390d2cbf1e3f75f721ffee908b6" +dependencies = [ + "vcell", +] diff --git a/src/exercises/bare-metal/temperature-logger/Cargo.toml b/src/exercises/bare-metal/temperature-logger/Cargo.toml index 7e0ff6d8..27c51475 100644 --- a/src/exercises/bare-metal/temperature-logger/Cargo.toml +++ b/src/exercises/bare-metal/temperature-logger/Cargo.toml @@ -8,4 +8,5 @@ edition = "2021" [dependencies] cortex-m-rt = "0.7.0" embedded-hal = "0.2.6" +microbit-v2 = "0.13.0" panic-halt = "0.2.0" diff --git a/src/exercises/bare-metal/temperature-logger/src/main.rs b/src/exercises/bare-metal/temperature-logger/src/main.rs index e69de29b..51462370 100644 --- a/src/exercises/bare-metal/temperature-logger/src/main.rs +++ b/src/exercises/bare-metal/temperature-logger/src/main.rs @@ -0,0 +1,28 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#![no_main] +#![no_std] + +extern crate panic_halt as _; + +use cortex_m_rt::entry; +use microbit::Board; + +#[entry] +fn main() -> ! { + let board = Board::take().unwrap(); + + loop {} +}