Solution
This is my solution:
#![no_std] #![no_main] extern crate panic_semihosting; extern crate cortex_m_rt as rt; extern crate cortex_m_semihosting as sh; extern crate microbit; use core::fmt::Write; use rt::entry; use sh::hio; use microbit::hal::prelude::*; use microbit::hal::serial; use microbit::hal::serial::BAUD115200; #[entry] fn main() -> ! { let mut stdout = hio::hstdout().unwrap(); writeln!(stdout, "Start").unwrap(); if let Some(p) = microbit::Peripherals::take() { // Split GPIO let mut gpio = p.GPIO.split(); // Configure RX and TX pins accordingly let tx = gpio.pin24.into_push_pull_output().downgrade(); let rx = gpio.pin25.into_floating_input().downgrade(); // Configure serial communication let (mut tx, _) = serial::Serial::uart0(p.UART0, tx, rx, BAUD115200).split(); write!(tx, "serial - start\r\n"); // Get row and column for display let mut led = gpio.pin13.into_push_pull_output(); let _ = gpio.pin4.into_push_pull_output(); // Set row high (column starts low) led.set_high(); // Write string with newline and carriage return write!(tx, "serial - LED on\r\n"); } panic!("End"); }
It is worth noting that pin4 starts low, so does not need to be explicitly set low.
You now know enough to start playing around with the micro:bit's LED display and GPIO, as well as logging data back to the host.
You should know that the microbit crate already includes an abstraction for the LED display for you to use. How to implemented a simple blocking display driver is demonstrated in the LED display chapter.