Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- USB device support is working again (#656)
- Add missing interrupt status read for esp32s3, which fixes USB-SERIAL-JTAG interrupts (#664)
- GPIO interrupt status bits are now properly cleared (#670)
- Increase frequency resolution in `set_periodic` (#686)

### Removed

Expand Down
8 changes: 4 additions & 4 deletions esp-hal-common/src/systimer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use core::{intrinsics::transmute, marker::PhantomData};

use fugit::MillisDurationU32;
use fugit::MicrosDurationU32;

use crate::{
peripheral::{Peripheral, PeripheralRef},
Expand Down Expand Up @@ -202,14 +202,14 @@ impl<const CHANNEL: u8> Alarm<Target, CHANNEL> {

impl<const CHANNEL: u8> Alarm<Periodic, CHANNEL> {
pub fn set_period(&self, period: fugit::HertzU32) {
let time_period: MillisDurationU32 = period.into_duration();
let cycles = time_period.ticks();
let time_period: MicrosDurationU32 = period.into_duration();
let us = time_period.ticks();
self.configure(|tconf, hi, lo| unsafe {
tconf.write(|w| {
w.target0_period_mode()
.set_bit()
.target0_period()
.bits(cycles * (SystemTimer::TICKS_PER_SECOND as u32 / 1000))
.bits(us * (SystemTimer::TICKS_PER_SECOND as u32 / 1000_000))
});
hi.write(|w| w.timer_target0_hi().bits(0));
lo.write(|w| w.timer_target0_lo().bits(0));
Expand Down