Skip to content

Commit c877f5a

Browse files
committed
[Fixes #74] Address changelog and formatting
1 parent c380e0e commit c877f5a

File tree

7 files changed

+20
-19
lines changed

7 files changed

+20
-19
lines changed

hal/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ The datasheet (DS60001527F) is available via [Microchip](https://ww1.microchip.c
3434
#![deny(rustdoc::invalid_rust_codeblocks)]
3535
#![deny(rustdoc::bare_urls)]
3636

37-
pub use embedded_hal_1 as ehal;
3837
pub use embedded_hal_02 as legacy_ehal;
38+
pub use embedded_hal_1 as ehal;
3939
pub use fugit;
4040
pub use nb;
4141

hal/src/pwm.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ ch.set_freq(2.kHz());
5050
use core::marker::PhantomData;
5151

5252
use crate::clocks::{Clock, HostClock, PeripheralIdentifier};
53-
use crate::legacy_ehal::PwmPin;
5453
use crate::fugit::HertzU32 as Hertz;
54+
use crate::legacy_ehal::PwmPin;
5555
use crate::pac::{
5656
pwm0::{RegisterBlock, PWM_CH_NUM as ChannelRegister},
5757
PWM0, PWM1,
@@ -730,7 +730,8 @@ impl<M: PwmMeta, I: ChannelId> ErrorType for Channel<M, I> {
730730
}
731731

732732
impl<M: PwmMeta, I: ChannelId> SetDutyCycle for Channel<M, I> {
733-
fn max_duty_cycle(&self) -> u16 { // TODO: we need to be smarter with scaling
733+
fn max_duty_cycle(&self) -> u16 {
734+
// TODO: we need to be smarter with scaling
734735
let max = self.reg().cprd().read().cprd().bits();
735736
let shift = max.leading_zeros().saturating_sub(16);
736737
(self.reg().cprd().read().cprd().bits() >> shift & 0xFFFF) as u16 // ? what if frequency changes
@@ -744,13 +745,13 @@ impl<M: PwmMeta, I: ChannelId> SetDutyCycle for Channel<M, I> {
744745
let max = self.reg().cprd().read().cprd().bits();
745746
let shift = max.leading_zeros().saturating_sub(16);
746747
if duty > (max >> (shift & 0xFFFF)) as u16 {
747-
return core::result::Result::Err(Self::Error::InvalidDutyCycle)
748+
return core::result::Result::Err(Self::Error::InvalidDutyCycle);
748749
}
749750
// TODO: that's copy&paste from `self.apply_duty()`, consider commonalization
750751
if self.is_enabled() {
751-
self.reg()
752-
.cdtyupd()
753-
.write(|w| unsafe { w.cdtyupd().bits((duty as u32) << shift) });
752+
self.reg()
753+
.cdtyupd()
754+
.write(|w| unsafe { w.cdtyupd().bits((duty as u32) << shift) });
754755
} else {
755756
self.reg()
756757
.cdty()
@@ -759,4 +760,4 @@ impl<M: PwmMeta, I: ChannelId> SetDutyCycle for Channel<M, I> {
759760
core::result::Result::Ok(())
760761
}
761762
}
762-
}
763+
}

hal/src/rtt.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,14 @@ timer.disable();
5454
*/
5555

5656
use crate::clocks::{Clock, SlowClock, SlowClockSource};
57-
use crate::legacy_ehal::{blocking::delay as legacy_delay, timer};
5857
use crate::ehal::delay;
5958
use crate::generics::CountDownError;
59+
use crate::legacy_ehal::{blocking::delay as legacy_delay, timer};
6060
use crate::pac::{rtt::sr::R as StatusRegister, RTT};
6161
pub use fugit::{ExtU32, RateExtU32};
6262
use fugit::{
63-
HertzU32 as Hertz, MicrosDurationU32 as MicrosDuration, MillisDurationU32 as MillisDuration, NanosDurationU32 as NanosDuration, TimerDurationU32 as Duration, TimerInstantU32 as Instant
63+
HertzU32 as Hertz, MicrosDurationU32 as MicrosDuration, MillisDurationU32 as MillisDuration,
64+
NanosDurationU32 as NanosDuration, TimerDurationU32 as Duration, TimerInstantU32 as Instant,
6465
};
6566
use rtic_monotonic::Monotonic;
6667

@@ -378,7 +379,7 @@ impl<const FREQ_HZ: u32> legacy_delay::DelayMs<u32> for Timer<FREQ_HZ> {
378379

379380
impl<const FREQ_HZ: u32> delay::DelayNs for Timer<FREQ_HZ> {
380381
fn delay_ns(&mut self, ns: u32) {
381-
use timer::CountDown;
382+
use timer::CountDown;
382383

383384
self.start(NanosDuration::from_ticks(ns).convert());
384385
nb::block!(self.wait()).unwrap()

hal/src/serial/spi.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@ client.write(b"Hello").unwrap();
6161

6262
use super::Bps;
6363
use crate::clocks::{Clock, HostClock, PeripheralIdentifier};
64-
use crate::legacy_ehal::blocking; // TODO:: implement embedded_hal 1.0 traits
6564
use crate::fugit::{ExtU32, NanosDurationU32 as NanosDuration};
65+
use crate::legacy_ehal::blocking; // TODO:: implement embedded_hal 1.0 traits
6666
#[cfg(feature = "__pins-144")]
6767
use crate::pac::SPI1;
6868
use crate::pac::{spi0::tdr::PCSSELECT_A as HwChipSelect, spi0::RegisterBlock, SPI0};
69-
use crate::{legacy_ehal, nb};
7069
use crate::{generics, pio::*};
70+
use crate::{legacy_ehal, nb};
7171
use core::marker::PhantomData;
7272
use legacy_ehal::spi::Mode;
7373
use strum::FromRepr;

hal/src/serial/twi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ twi.write_read(0x0, &[0b1000_0000], &mut buffer).unwrap();
4343
*/
4444

4545
use crate::clocks::{Clock, Hertz, HostClock, PeripheralIdentifier};
46-
use crate::legacy_ehal::blocking; // TODO: address I²C from embedded-hal 1.0
4746
use crate::generics;
47+
use crate::legacy_ehal::blocking; // TODO: address I²C from embedded-hal 1.0
4848
#[cfg(feature = "reconfigurable-system-pins")]
4949
use crate::pac::TWIHS1;
5050
#[cfg(not(feature = "__pins-64"))]

hal/src/serial/uart.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ assert_eq!(uart.read().unwrap(), 0xff);
6767
*/
6868

6969
use crate::clocks::{Clock, HostClock, Pck, Pck4, PeripheralClock, PeripheralIdentifier};
70-
use crate::legacy_ehal::{self, blocking}; // TODO: embedded-hal 1.0 doesn't have traits for U(S)ART
7170
use crate::fugit::HertzU32 as Hertz;
71+
use crate::legacy_ehal::{self, blocking}; // TODO: embedded-hal 1.0 doesn't have traits for U(S)ART
7272
use crate::pac::uart0::mr::{CHMODESELECT_A as ChannelModeInner, PARSELECT_A as ParityModeInner};
7373
use crate::pac::{uart0::RegisterBlock, UART0, UART1, UART2};
7474
#[cfg(all(

hal/src/tc/mod.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,16 +187,15 @@ interrupt:
187187
*/
188188

189189
use crate::clocks::{Clock, Hertz, HostClock, PeripheralIdentifier};
190-
use crate::legacy_ehal::blocking::delay as legacy_delay;
191190
use crate::ehal::delay;
192-
use crate::legacy_ehal::timer;
193191
pub use crate::fugit::{ExtU32, RateExtU32};
194192
use crate::fugit::{
195193
MicrosDurationU32 as MicrosDuration, MillisDurationU32 as MillisDuration,
196-
NanosDurationU32 as NanosDuration,
197-
TimerDurationU32 as Duration, TimerInstantU32 as Instant,
194+
NanosDurationU32 as NanosDuration, TimerDurationU32 as Duration, TimerInstantU32 as Instant,
198195
};
199196
use crate::generics::{self, CountDownError};
197+
use crate::legacy_ehal::blocking::delay as legacy_delay;
198+
use crate::legacy_ehal::timer;
200199
use crate::pac::tc0::{
201200
tc_channel::{
202201
cmr_capture_mode::{LDRASELECT_A, LDRBSELECT_A, SBSMPLRSELECT_A},

0 commit comments

Comments
 (0)