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

Seal all Instance traits #1346

Merged
merged 2 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions esp-hal/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Enable `embedded-hal` feature by default, instead of the `embedded-hal-02` feature (#1313)
- `Uart` structs now take a `Mode` parameter which defines how the driver is initialized (#1294)
- `Rmt` can be created in async or blocking mode. The blocking constructor takes an optional interrupt handler argument. (#1341)
- All `Instance` traits are now sealed, and can no longer be implemented for arbitrary types (#1346)

### Removed

Expand Down
2 changes: 1 addition & 1 deletion esp-hal/src/i2c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ mod asynch {
}

/// I2C Peripheral Instance
pub trait Instance {
pub trait Instance: crate::private::Sealed {
fn scl_output_signal(&self) -> OutputSignal;
fn scl_input_signal(&self) -> InputSignal;
fn sda_output_signal(&self) -> OutputSignal;
Expand Down
2 changes: 1 addition & 1 deletion esp-hal/src/spi/master.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1988,7 +1988,7 @@ pub trait ExtendedInstance: Instance {
fn sio3_input_signal(&self) -> InputSignal;
}

pub trait Instance {
pub trait Instance: crate::private::Sealed {
fn register_block(&self) -> &RegisterBlock;

fn sclk_signal(&self) -> OutputSignal;
Expand Down
2 changes: 1 addition & 1 deletion esp-hal/src/spi/slave.rs
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ where
{
}

pub trait Instance {
pub trait Instance: crate::private::Sealed {
fn register_block(&self) -> &RegisterBlock;

fn sclk_signal(&self) -> InputSignal;
Expand Down
7 changes: 6 additions & 1 deletion esp-hal/src/timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ where
}

/// Timer peripheral instance
pub trait Instance {
pub trait Instance: crate::private::Sealed {
fn reset_counter(&mut self);

fn set_counter_active(&mut self, state: bool);
Expand Down Expand Up @@ -305,6 +305,8 @@ pub struct Timer0<TG> {
phantom: PhantomData<TG>,
}

impl<TG> crate::private::Sealed for Timer0<TG> {}

impl<TG> Timer0<TG>
where
TG: TimerGroupInstance,
Expand Down Expand Up @@ -474,6 +476,9 @@ pub struct Timer1<TG> {
phantom: PhantomData<TG>,
}

#[cfg(not(any(esp32c2, esp32c3, esp32c6, esp32h2)))]
impl<TG> crate::private::Sealed for Timer1<TG> {}

#[cfg(not(any(esp32c2, esp32c3, esp32c6, esp32h2)))]
impl<TG> Timer1<TG>
where
Expand Down
2 changes: 1 addition & 1 deletion esp-hal/src/trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ where
}
}

pub trait Instance {
pub trait Instance: crate::private::Sealed {
fn register_block(&self) -> &RegisterBlock;
}

Expand Down
2 changes: 1 addition & 1 deletion esp-hal/src/twai/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ where
}
}

pub trait Instance {
pub trait Instance: crate::private::Sealed {
const SYSTEM_PERIPHERAL: system::Peripheral;
const NUMBER: usize;

Expand Down
2 changes: 1 addition & 1 deletion esp-hal/src/uart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1053,7 +1053,7 @@ where
}

/// UART peripheral instance
pub trait Instance {
pub trait Instance: crate::private::Sealed {
fn register_block() -> &'static RegisterBlock;
fn uart_number() -> usize;
fn interrupt() -> Interrupt;
Expand Down
2 changes: 1 addition & 1 deletion esp-hal/src/usb_serial_jtag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ impl<'d> UsbSerialJtag<'d> {
}

/// USB Serial JTAG peripheral instance
pub trait Instance {
pub trait Instance: crate::private::Sealed {
fn register_block() -> &'static RegisterBlock;

fn disable_tx_interrupts() {
Expand Down
Loading