Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: make traits public in the CAN module #778

Merged
merged 1 commit into from
Nov 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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