Skip to content

Commit

Permalink
Split UART into Rx and Tx halves
Browse files Browse the repository at this point in the history
  • Loading branch information
jbeaurivage committed May 26, 2021
1 parent 158a10b commit a37e161
Show file tree
Hide file tree
Showing 2 changed files with 267 additions and 37 deletions.
12 changes: 12 additions & 0 deletions hal/src/sercom/v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ pub trait Sercom: Sealed + Deref<Target = sercom0::RegisterBlock> {
const NUM: usize;
/// Enable the corresponding APB clock
fn enable_apb_clock(&mut self, ctrl: &APB_CLK_CTRL);
/// Get a copy of the corresponding PAC struct
///
/// # Safety
///
/// If a PAC struct is stolen, an interface should be designed
/// to ensure that two objects holding the same PAC struct
/// may not write to the same registers.
unsafe fn steal() -> Self;
}

macro_rules! sercom {
Expand All @@ -62,6 +70,10 @@ macro_rules! sercom {
fn enable_apb_clock(&mut self, ctrl: &APB_CLK_CTRL) {
ctrl.$apbmask.modify(|_, w| w.[<sercom#N _>]().set_bit());
}
#[inline]
unsafe fn steal() -> Self {
pac::Peripherals::steal().SERCOM#N
}
}
}
});
Expand Down

0 comments on commit a37e161

Please sign in to comment.