Skip to content

Commit

Permalink
can: make traits public
Browse files Browse the repository at this point in the history
  • Loading branch information
maximeborges committed Nov 7, 2024
1 parent 9e2d75a commit f4c37e4
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions hal/src/peripherals/can.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use crate::{
Source,
},
gpio::*,
typelevel::{Decrement, Increment},
typelevel::{Decrement, Increment, Sealed},
};
use atsamd_hal_macros::hal_cfg;

Expand Down Expand Up @@ -121,24 +121,30 @@ unsafe impl CanId for Can1 {
const ADDRESS: *const () = crate::pac::Can1::PTR as *const _;
}

trait OwnedPeripheral {
/// Trait representing a CAN peripheral
pub trait OwnedPeripheral: Sealed {
type Represents: CanId;
}

impl Sealed for crate::pac::Can0 {}
impl OwnedPeripheral for crate::pac::Can0 {
type Represents = Can0;
}

#[hal_cfg("can1")]
impl Sealed for crate::pac::Can1 {}
#[hal_cfg("can1")]
impl OwnedPeripheral for crate::pac::Can1 {
type Represents = Can1;
}

trait RxPin {
/// Trait implemented on pins that can be set as RX pins for CAN
pub trait RxPin: Sealed {
type ValidFor: CanId;
}

trait TxPin {
/// Trait implemented on pins that can be set as TX pins for CAN
pub trait TxPin: Sealed {
type ValidFor: CanId;
}

Expand Down

0 comments on commit f4c37e4

Please sign in to comment.