Skip to content

Commit 40b5a14

Browse files
committed
peri-address auto-impl
1 parent 262cb0c commit 40b5a14

File tree

3 files changed

+4
-9
lines changed

3 files changed

+4
-9
lines changed

src/serial.rs

-4
Original file line numberDiff line numberDiff line change
@@ -277,10 +277,6 @@ macro_rules! halUsart {
277277
});
278278
}
279279

280-
fn peri_address() -> u32 {
281-
unsafe { (*(<$USART>::ptr() as *const Self::RegisterBlock)).peri_address() }
282-
}
283-
284280
unsafe fn steal() -> Self {
285281
Self::steal()
286282
}

src/serial/uart_impls.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ pub trait Instance:
3737
#[doc(hidden)]
3838
fn set_stopbits(&self, bits: config::StopBits);
3939
#[doc(hidden)]
40-
fn peri_address() -> u32;
40+
#[inline(always)]
41+
fn peri_address() -> u32 {
42+
unsafe { &*Self::ptr() }.peri_address()
43+
}
4144
#[doc(hidden)]
4245
unsafe fn steal() -> Self;
4346
}

src/uart.rs

-4
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,6 @@ macro_rules! halUart {
5252
});
5353
}
5454

55-
fn peri_address() -> u32 {
56-
unsafe { (*Self::ptr()).peri_address() }
57-
}
58-
5955
unsafe fn steal() -> Self {
6056
Self::steal()
6157
}

0 commit comments

Comments
 (0)