From 772b10153f584fc008c6e9380121cff7f62cddba Mon Sep 17 00:00:00 2001 From: Adin Ackerman <adinackerman@gmail.com> Date: Mon, 7 Oct 2024 14:37:49 -0700 Subject: [PATCH] fixes... --- .../spinning-and-blinking/rust/blinking.md | 20 ++++--------------- .../spinning-and-blinking/rust/spinning.md | 3 ++- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/content/assignments/spinning-and-blinking/rust/blinking.md b/content/assignments/spinning-and-blinking/rust/blinking.md index 186730f..6822f45 100644 --- a/content/assignments/spinning-and-blinking/rust/blinking.md +++ b/content/assignments/spinning-and-blinking/rust/blinking.md @@ -39,12 +39,8 @@ use embassy_executor::Spawner; use embassy_time::Timer; use esp_backtrace as _; use esp_hal::{ - clock::ClockControl, gpio::{Io, Level, Output}, - peripherals::Peripherals, - prelude::*, - system::SystemControl, - timer::{timg::TimerGroup}, + timer::timg::TimerGroup, }; use esp_println::println; ``` @@ -89,28 +85,20 @@ Next, we take ownership of all peripherals. This operation can only be done once, per RAII, we may only have *one* binding for *one* resource: ```rust -let peripherals = Peripherals::take(); -let system = SystemControl::new(peripherals.SYSTEM); - -let clocks = ClockControl::max(system.clock_control).freeze(); +let peripherals = esp_hal::init(esp_hal::Config::default()); ``` -In the second line we create a binding to specifically the system peripheral, which controls -clocks, interconnects, etc. - -And on the third line, configure the system clocks to run at their maximum frequency. - Then we initialize the 0th timer group (which we can use to provide Embassy with a means for keeping time): ```rust -let timg0 = TimerGroup::new(peripherals.TIMG0, &clocks); +let timg0 = TimerGroup::new(peripherals.TIMG0); ``` Embassy needs a `impl TimerCollection` (some timer that implements the trait `TimerCollection`) to provide monotonics[^10]: ```rust -esp_hal_embassy::init(&clocks, timg0.timer0); +esp_hal_embassy::init(timg0.timer0); ``` {{< callout type="info" >}} diff --git a/content/assignments/spinning-and-blinking/rust/spinning.md b/content/assignments/spinning-and-blinking/rust/spinning.md index b1579b1..1c64418 100644 --- a/content/assignments/spinning-and-blinking/rust/spinning.md +++ b/content/assignments/spinning-and-blinking/rust/spinning.md @@ -107,6 +107,7 @@ The MCPWM peripheral's clock is sourced from the `crypto_pwm_clock`, we can veri its speed: ```rust +let clocks = Clocks::get(); println!("src clock: {}", clocks.crypto_pwm_clock); ``` @@ -126,7 +127,7 @@ default prescaler is `Div1`. Now, we configure our peripheral (the MCPWM) clock: ```rust -let clock_cfg = PeripheralClockConfig::with_frequency(&clocks, 32.MHz()).unwrap(); +let clock_cfg = PeripheralClockConfig::with_frequency(32.MHz()).unwrap(); ``` > If we hadn't imported the fugit integer extension trait, we would have encountered