some more const improvements
This commit is contained in:
parent
7d6f69d808
commit
e8e7ea9b1c
@ -38,6 +38,21 @@ pub enum Bank {
|
||||
Uart2 = 2,
|
||||
}
|
||||
|
||||
impl Bank {
|
||||
/// Retrieve the peripheral register block.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// Circumvents the HAL safety guarantees.
|
||||
pub const unsafe fn reg_block(&self) -> &'static uart_base::RegisterBlock {
|
||||
match self {
|
||||
Bank::Uart0 => unsafe { &(*pac::Uart0::ptr()) },
|
||||
Bank::Uart1 => unsafe { &(*pac::Uart1::ptr()) },
|
||||
Bank::Uart2 => unsafe { &(*pac::Uart2::ptr()) },
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//==================================================================================================
|
||||
// Type-Level support
|
||||
//==================================================================================================
|
||||
@ -421,21 +436,6 @@ impl Instance for Uart2 {
|
||||
}
|
||||
}
|
||||
|
||||
impl Bank {
|
||||
/// Retrieve the peripheral register block.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// Circumvents the HAL safety guarantees.
|
||||
pub unsafe fn reg_block(&self) -> &'static uart_base::RegisterBlock {
|
||||
match self {
|
||||
Bank::Uart0 => unsafe { pac::Uart0::reg_block() },
|
||||
Bank::Uart1 => unsafe { pac::Uart1::reg_block() },
|
||||
Bank::Uart2 => unsafe { pac::Uart2::reg_block() },
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//==================================================================================================
|
||||
// UART implementation
|
||||
//==================================================================================================
|
||||
|
Loading…
x
Reference in New Issue
Block a user