Skip to content

Commit

Permalink
fixes...
Browse files Browse the repository at this point in the history
  • Loading branch information
AdinAck committed Oct 7, 2024
1 parent b8c950a commit 772b101
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
20 changes: 4 additions & 16 deletions content/assignments/spinning-and-blinking/rust/blinking.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;
```
Expand Down Expand Up @@ -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" >}}
Expand Down
3 changes: 2 additions & 1 deletion content/assignments/spinning-and-blinking/rust/spinning.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);
```

Expand All @@ -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
Expand Down

0 comments on commit 772b101

Please sign in to comment.