mark code

This commit is contained in:
Mirabellensaft 2023-03-07 16:45:34 +01:00
parent 166550667b
commit cd345aad95

View file

@ -30,16 +30,16 @@ use defmt_rtt as _; // global logger
pub struct Board { pub struct Board {
/// LEDs /// LEDs
pub leds: Leds, pub leds: Leds,
// --- Exercise --- 🔽 // 🔽 --- Exercise Button --- 🔽
/// Buttons /// Buttons
pub buttons: Buttons, pub buttons: Buttons,
// --- Exercise --- 🔼 // 🔼 --- Exercise Button --- 🔼
/// Timer /// Timer
pub timer: Timer, pub timer: Timer,
// --- Exercise --- 🔽 // 🔽 --- Exercise UARTE --- 🔽
/// uarte interface /// uarte interface
pub uarte: Uarte, pub uarte: Uarte,
// --- Exercise --- 🔼 // 🔼 --- Exercise UARTE --- 🔼
} }
/// All LEDs on the board /// All LEDs on the board
@ -103,7 +103,7 @@ impl Led {
} }
} }
} }
// --- Exercise --- 🔽 // 🔽 --- Exercise Button --- 🔽
/// All buttons on the board /// All buttons on the board
pub struct Buttons { pub struct Buttons {
/// BUTTON1: pin P0.11, green LED /// BUTTON1: pin P0.11, green LED
@ -127,7 +127,7 @@ impl Button {
self.inner.is_low() == Ok(true) self.inner.is_low() == Ok(true)
} }
} }
// --- Exercise --- 🔼 // 🔼 --- Exercise Button --- 🔼
/// A timer for creating blocking delays /// A timer for creating blocking delays
pub struct Timer { pub struct Timer {
@ -184,6 +184,7 @@ impl ops::DerefMut for Timer {
} }
} }
// 🔽 --- Exercise UARTE --- 🔽
/// Uarte peripheral /// Uarte peripheral
pub struct Uarte { pub struct Uarte {
inner: hal::Uarte<hal::pac::UARTE1>, inner: hal::Uarte<hal::pac::UARTE1>,
@ -203,6 +204,7 @@ impl fmt::Write for Uarte {
Ok(()) Ok(())
} }
} }
// 🔼 --- Exercise UARTE --- 🔼
/// Initializes the board /// Initializes the board
/// ///
@ -218,19 +220,19 @@ pub fn init() -> Result<Board, ()> {
let led_3 = pins.p0_15.degrade().into_push_pull_output(Level::High); let led_3 = pins.p0_15.degrade().into_push_pull_output(Level::High);
let led_4 = pins.p0_16.degrade().into_push_pull_output(Level::High); let led_4 = pins.p0_16.degrade().into_push_pull_output(Level::High);
// --- Exercise --- 🔽 // 🔽 --- Exercise Button --- 🔽
// Buttons // Buttons
let b_1 = pins.p0_11.degrade().into_pullup_input(); let b_1 = pins.p0_11.degrade().into_pullup_input();
let b_2 = pins.p0_12.degrade().into_pullup_input(); let b_2 = pins.p0_12.degrade().into_pullup_input();
let b_3 = pins.p0_24.degrade().into_pullup_input(); let b_3 = pins.p0_24.degrade().into_pullup_input();
let b_4 = pins.p0_25.degrade().into_pullup_input(); let b_4 = pins.p0_25.degrade().into_pullup_input();
// --- Exercise --- 🔼 // 🔼 --- Exercise Button --- 🔼
defmt::debug!("I/O pins have been configured for digital output"); defmt::debug!("I/O pins have been configured for digital output");
let timer = hal::Timer::new(periph.TIMER0); let timer = hal::Timer::new(periph.TIMER0);
// --- Exercise --- 🔽 // 🔽 --- Exercise UARTE --- 🔽
// Uarte // Uarte
let pins = hal::uarte::Pins { let pins = hal::uarte::Pins {
rxd: pins.p0_08.degrade().into_floating_input(), rxd: pins.p0_08.degrade().into_floating_input(),
@ -241,7 +243,7 @@ pub fn init() -> Result<Board, ()> {
let uarte = hal::uarte::Uarte::new(periph.UARTE1, pins, Parity::INCLUDED, Baudrate::BAUD115200); let uarte = hal::uarte::Uarte::new(periph.UARTE1, pins, Parity::INCLUDED, Baudrate::BAUD115200);
// --- Exercise --- 🔼 // 🔼 --- Exercise UARTE --- 🔼
Ok(Board { Ok(Board {
leds: Leds { leds: Leds {
@ -251,20 +253,20 @@ pub fn init() -> Result<Board, ()> {
led_4: Led { inner: led_4 }, led_4: Led { inner: led_4 },
}, },
// --- Exercise --- 🔽 // 🔽 --- Exercise Button --- 🔽
buttons: Buttons { buttons: Buttons {
b_1: Button { inner: b_1}, b_1: Button { inner: b_1},
b_2: Button { inner: b_2}, b_2: Button { inner: b_2},
b_3: Button { inner: b_3}, b_3: Button { inner: b_3},
b_4: Button { inner: b_4}, b_4: Button { inner: b_4},
}, },
// --- Exercise --- 🔼 // 🔼 --- Exercise Button --- 🔼
timer: Timer { inner: timer }, timer: Timer { inner: timer },
// --- Exercise --- 🔽 // 🔽 --- Exercise UARTE --- 🔽
uarte: Uarte { inner: uarte }, uarte: Uarte { inner: uarte },
// --- Exercise --- 🔼 // 🔼 --- Exercise UARTE --- 🔼
}) })
} else { } else {
Err(()) Err(())