mirror of
https://github.com/ferrous-systems/embedded-trainings-2020.git
synced 2025-01-10 16:25:37 +00:00
mark expected exercise solution
This commit is contained in:
parent
028a850596
commit
3f56cd66d8
1 changed files with 21 additions and 4 deletions
|
@ -43,8 +43,10 @@ pub mod usbd;
|
||||||
pub struct Board {
|
pub struct Board {
|
||||||
/// LEDs
|
/// LEDs
|
||||||
pub leds: Leds,
|
pub leds: Leds,
|
||||||
|
// --- Exercise --- 🔽
|
||||||
/// Buttons
|
/// Buttons
|
||||||
pub buttons: Buttons,
|
pub buttons: Buttons,
|
||||||
|
// --- Exercise --- 🔼
|
||||||
/// Timer
|
/// Timer
|
||||||
pub timer: Timer,
|
pub timer: Timer,
|
||||||
|
|
||||||
|
@ -56,8 +58,10 @@ pub struct Board {
|
||||||
pub power: POWER,
|
pub power: POWER,
|
||||||
/// USB control endpoint 0
|
/// USB control endpoint 0
|
||||||
pub ep0in: Ep0In,
|
pub ep0in: Ep0In,
|
||||||
|
// --- Exercise --- 🔽
|
||||||
/// uarte interface
|
/// uarte interface
|
||||||
pub uarte: Uarte,
|
pub uarte: Uarte,
|
||||||
|
// --- Exercise --- 🔼
|
||||||
}
|
}
|
||||||
|
|
||||||
/// All LEDs on the board
|
/// All LEDs on the board
|
||||||
|
@ -129,7 +133,7 @@ impl Led {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// --- Exercise --- 🔽
|
||||||
/// 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
|
||||||
|
@ -153,11 +157,14 @@ impl Button {
|
||||||
self.inner.is_low() == Ok(true)
|
self.inner.is_low() == Ok(true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// --- Exercise --- 🔼
|
||||||
|
|
||||||
/// A timer for creating blocking delays
|
/// A timer for creating blocking delays
|
||||||
pub struct Timer {
|
pub struct Timer {
|
||||||
inner: hal::Timer<hal::pac::TIMER0, OneShot>,
|
inner: hal::Timer<hal::pac::TIMER0, OneShot>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl Timer {
|
impl Timer {
|
||||||
/// Blocks program execution for at least the specified `duration`
|
/// Blocks program execution for at least the specified `duration`
|
||||||
pub fn wait(&mut self, duration: Duration) {
|
pub fn wait(&mut self, duration: Duration) {
|
||||||
|
@ -275,16 +282,20 @@ pub fn init() -> Result<Board, ()> {
|
||||||
let led_2 = pins.p0_14.degrade().into_push_pull_output(Level::High);
|
let led_2 = pins.p0_14.degrade().into_push_pull_output(Level::High);
|
||||||
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 --- 🔽
|
||||||
// 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 --- 🔼
|
||||||
|
|
||||||
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 --- 🔽
|
||||||
// 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(),
|
||||||
|
@ -295,6 +306,7 @@ pub fn init() -> Result<Board, ()> {
|
||||||
|
|
||||||
|
|
||||||
let uarte = hal::uarte::Uarte::new(periph.UARTE0, pins, Parity::INCLUDED, Baudrate::BAUD115200);
|
let uarte = hal::uarte::Uarte::new(periph.UARTE0, pins, Parity::INCLUDED, Baudrate::BAUD115200);
|
||||||
|
// --- Exercise --- 🔼
|
||||||
|
|
||||||
// Radio
|
// Radio
|
||||||
let radio = {
|
let radio = {
|
||||||
|
@ -315,19 +327,24 @@ pub fn init() -> Result<Board, ()> {
|
||||||
led_3: Led { inner: led_3 },
|
led_3: Led { inner: led_3 },
|
||||||
led_4: Led { inner: led_4 },
|
led_4: Led { inner: led_4 },
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// --- Exercise --- 🔽
|
||||||
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 --- 🔼
|
||||||
radio,
|
radio,
|
||||||
timer: Timer { inner: timer },
|
timer: Timer { inner: timer },
|
||||||
usbd: periph.USBD,
|
usbd: periph.USBD,
|
||||||
power: periph.POWER,
|
power: periph.POWER,
|
||||||
ep0in: unsafe { Ep0In::new(&mut EP0IN_BUF) },
|
ep0in: unsafe { Ep0In::new(&mut EP0IN_BUF) },
|
||||||
|
|
||||||
|
// --- Exercise --- 🔽
|
||||||
uarte: Uarte { inner: uarte },
|
uarte: Uarte { inner: uarte },
|
||||||
|
// --- Exercise --- 🔼
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
Err(())
|
Err(())
|
||||||
|
|
Loading…
Reference in a new issue