Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jbeaurivage committed Oct 24, 2022
1 parent 2cc2da1 commit 44e6126
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
10 changes: 8 additions & 2 deletions hal/src/async_hal/timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,18 @@ mod impl_ehal {
type Error = Infallible;
type DelayMsFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a;
fn delay_ms(&mut self, ms: u32) -> Self::DelayMsFuture<'_> {
async move { Ok(self.delay(ms.ms()).await) }
async move {
self.delay(ms.ms()).await;
Ok(())
}
}

type DelayUsFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a;
fn delay_us(&mut self, us: u32) -> Self::DelayUsFuture<'_> {
async move { Ok(self.delay(us.us()).await) }
async move {
self.delay(us.us()).await;
Ok(())
}
}
}
}
Expand Down
11 changes: 11 additions & 0 deletions hal/src/sercom/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,11 @@ macro_rules! sercom {
use self::uart::Flags;
unsafe {
let mut peripherals = crate::pac::Peripherals::steal();

#[cfg(any(feature = "samd11", feature = "samd21"))]
let uart = Self::reg_block(&mut peripherals).usart();
#[cfg(feature = "min-samd51g")]
let uart = Self::reg_block(&mut peripherals).usart_ext();

let flags_pending = Flags::from_bits_unchecked(uart.intflag.read().bits());
let enabled_flags = Flags::from_bits_unchecked(uart.intenset.read().bits());
Expand Down Expand Up @@ -203,12 +207,19 @@ sercom!(apbdmask: (4, 5));
#[cfg(feature = "min-samd51n")]
sercom!(apbdmask: (6, 7));

#[allow(dead_code)]
#[cfg(feature = "samd11")]
const NUM_SERCOM: usize = 2;

#[allow(dead_code)]
#[cfg(feature = "samd21e")]
const NUM_SERCOM: usize = 4;

#[allow(dead_code)]
#[cfg(any(feature = "min-samd21g", feature = "samd51g", feature = "samd51j"))]
const NUM_SERCOM: usize = 6;

#[allow(dead_code)]
#[cfg(feature = "min-samd51n")]
const NUM_SERCOM: usize = 8;

Expand Down
2 changes: 1 addition & 1 deletion hal/src/sercom/uart/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ impl<P: ValidPads> Config<P> {

// Enable internal clock mode
registers.configure_mode();
registers.configure_pads(P::RXPO as u8, P::TXPO as u8);
registers.configure_pads(P::RXPO, P::TXPO);
registers.set_char_size(EightBit::SIZE);

Self {
Expand Down

0 comments on commit 44e6126

Please sign in to comment.