Skip to content

Commit

Permalink
wip: skelton for PD peripheral
Browse files Browse the repository at this point in the history
  • Loading branch information
andelf committed May 19, 2024
1 parent 5ff0577 commit a20adf0
Show file tree
Hide file tree
Showing 5 changed files with 426 additions and 1 deletion.
3 changes: 3 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,9 @@ fn main() {
// USB is splitted into multiple impls
(("usbd", "DP"), quote!(crate::usbd::DpPin)),
(("usbd", "DM"), quote!(crate::usbd::DmPin)),
// USBPD
(("usbpd", "CC1"), quote!(crate::usbpd::Cc1Pin)),
(("usbpd", "CC2"), quote!(crate::usbpd::Cc2Pin)),
]
.into();

Expand Down
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ pub mod usb;
#[cfg(usbd)]
pub mod usbd;

#[cfg(usbpd)]
pub mod usbpd;

#[cfg(feature = "embassy")]
pub mod embassy;

Expand Down
2 changes: 1 addition & 1 deletion src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ macro_rules! dma_trait {

macro_rules! pin_trait {
($signal:ident, $instance:path) => {
pub trait $signal<T: $instance, const REMAP: u8>: crate::gpio::Pin {}
pub trait $signal<T: $instance, const REMAP: u8 = 0>: crate::gpio::Pin {}
};
}
macro_rules! pin_trait_impl {
Expand Down
14 changes: 14 additions & 0 deletions src/usart/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1027,6 +1027,20 @@ fn configure(
Ok(())
}

impl<'d, T: Instance> core::fmt::Write for UartTx<'d, T, Blocking> {
fn write_str(&mut self, s: &str) -> core::fmt::Result {
self.blocking_write(s.as_bytes()).map_err(|_| core::fmt::Error)?;
Ok(())
}
}
impl<'d, T: Instance> core::fmt::Write for Uart<'d, T, Blocking> {
fn write_str(&mut self, s: &str) -> core::fmt::Result {
self.blocking_write(s.as_bytes()).map_err(|_| core::fmt::Error)?;
Ok(())
}
}


// Peripheral traits
struct State {
rx_waker: AtomicWaker,
Expand Down
Loading

0 comments on commit a20adf0

Please sign in to comment.