improve PAC API
This commit is contained in:
parent
e8be7b1dc4
commit
f098689875
@ -10,7 +10,7 @@ rustflags = [
|
|||||||
|
|
||||||
# Tier 3 target, so no pre-compiled artifacts included.
|
# Tier 3 target, so no pre-compiled artifacts included.
|
||||||
[unstable]
|
[unstable]
|
||||||
# build-std = ["core", "alloc"]
|
build-std = ["core", "alloc"]
|
||||||
|
|
||||||
[build]
|
[build]
|
||||||
# target = "armv7a-none-eabihf"
|
target = "armv7a-none-eabihf"
|
||||||
|
@ -54,18 +54,8 @@ impl ResetControl {
|
|||||||
///
|
///
|
||||||
/// If you create multiple instances of this handle at the same time, you are responsible for
|
/// If you create multiple instances of this handle at the same time, you are responsible for
|
||||||
/// ensuring that there are no read-modify-write races on any of the registers.
|
/// ensuring that there are no read-modify-write races on any of the registers.
|
||||||
pub fn new_mmio_fixed() -> MmioResetControl<'static> {
|
pub unsafe fn new_mmio() -> MmioResetControl<'static> {
|
||||||
MmioResetControl {
|
unsafe { Self::_new_mmio((SLCR_BASE_ADDR + RESET_BLOCK_OFFSET) as *mut ResetControl) }
|
||||||
ptr: (SLCR_BASE_ADDR + RESET_BLOCK_OFFSET) as *mut ResetControl,
|
|
||||||
phantom: core::marker::PhantomData,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn new_mmio(block: *mut ResetControl) -> MmioResetControl<'static> {
|
|
||||||
MmioResetControl {
|
|
||||||
ptr: block,
|
|
||||||
phantom: core::marker::PhantomData,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,18 +115,8 @@ impl ClockControl {
|
|||||||
///
|
///
|
||||||
/// If you create multiple instances of this handle at the same time, you are responsible for
|
/// If you create multiple instances of this handle at the same time, you are responsible for
|
||||||
/// ensuring that there are no read-modify-write races on any of the registers.
|
/// ensuring that there are no read-modify-write races on any of the registers.
|
||||||
pub unsafe fn new_mmio_fixed() -> MmioClockControl<'static> {
|
pub unsafe fn new_mmio() -> MmioClockControl<'static> {
|
||||||
MmioClockControl {
|
unsafe { Self::_new_mmio((SLCR_BASE_ADDR + CLOCK_CONTROL_OFFSET) as *mut _) }
|
||||||
ptr: (SLCR_BASE_ADDR + CLOCK_CONTROL_OFFSET) as *mut ClockControl,
|
|
||||||
phantom: core::marker::PhantomData,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn new_mmio(clk_ctrl: *mut ClockControl) -> MmioClockControl<'static> {
|
|
||||||
MmioClockControl {
|
|
||||||
ptr: clk_ctrl,
|
|
||||||
phantom: core::marker::PhantomData,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,18 +151,8 @@ impl DdrIoB {
|
|||||||
///
|
///
|
||||||
/// If you create multiple instances of this handle at the same time, you are responsible for
|
/// If you create multiple instances of this handle at the same time, you are responsible for
|
||||||
/// ensuring that there are no read-modify-write races on any of the registers.
|
/// ensuring that there are no read-modify-write races on any of the registers.
|
||||||
pub fn new_mmio_fixed() -> MmioDdrIoB<'static> {
|
pub unsafe fn new_mmio() -> MmioDdrIoB<'static> {
|
||||||
MmioDdrIoB {
|
unsafe { Self::_new_mmio((SLCR_BASE_ADDR + DDRIOB_OFFSET) as *mut _) }
|
||||||
ptr: (SLCR_BASE_ADDR + DDRIOB_OFFSET) as *mut _,
|
|
||||||
phantom: core::marker::PhantomData,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn new_mmio(reg: *mut DdrIoB) -> MmioDdrIoB<'static> {
|
|
||||||
MmioDdrIoB {
|
|
||||||
ptr: reg,
|
|
||||||
phantom: core::marker::PhantomData,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,18 +180,8 @@ impl GpiobCtrl {
|
|||||||
///
|
///
|
||||||
/// If you create multiple instances of this handle at the same time, you are responsible for
|
/// If you create multiple instances of this handle at the same time, you are responsible for
|
||||||
/// ensuring that there are no read-modify-write races on any of the registers.
|
/// ensuring that there are no read-modify-write races on any of the registers.
|
||||||
pub fn new_mmio_fixed() -> MmioGpiobCtrl<'static> {
|
pub unsafe fn new_mmio() -> MmioGpiobCtrl<'static> {
|
||||||
MmioGpiobCtrl {
|
unsafe { Self::_new_mmio((SLCR_BASE_ADDR + GPIOB_OFFSET) as *mut _) }
|
||||||
ptr: (SLCR_BASE_ADDR + GPIOB_OFFSET) as *mut _,
|
|
||||||
phantom: core::marker::PhantomData,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn new_mmio(reg: *mut Self) -> MmioGpiobCtrl<'static> {
|
|
||||||
MmioGpiobCtrl {
|
|
||||||
ptr: reg,
|
|
||||||
phantom: core::marker::PhantomData,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ impl Uart {
|
|||||||
/// from multiple threads. The user must ensure that concurrent accesses are safe and do not
|
/// from multiple threads. The user must ensure that concurrent accesses are safe and do not
|
||||||
/// interfere with each other.
|
/// interfere with each other.
|
||||||
pub const unsafe fn new_mmio_0() -> MmioUart<'static> {
|
pub const unsafe fn new_mmio_0() -> MmioUart<'static> {
|
||||||
MmioUart { ptr: 0xE000_0000 as *mut Uart, phantom: core::marker::PhantomData }
|
unsafe { Self::_new_mmio(UART0_BASE as *mut _) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a new UART MMIO instance for uart1 at address 0xE000_1000.
|
/// Create a new UART MMIO instance for uart1 at address 0xE000_1000.
|
||||||
@ -63,7 +63,7 @@ impl Uart {
|
|||||||
/// This API can be used to potentially create a driver to the same peripheral structure
|
/// This API can be used to potentially create a driver to the same peripheral structure
|
||||||
/// from multiple threads. The user must ensure that concurrent accesses are safe and do not
|
/// from multiple threads. The user must ensure that concurrent accesses are safe and do not
|
||||||
/// interfere with each other.
|
/// interfere with each other.
|
||||||
pub const unsafe fn new_mmio_1() -> MmioUart<'static> {
|
pub const unsafe fn new_mmio_1() -> MmioUart<'static> {
|
||||||
MmioUart { ptr: 0xE000_1000 as *mut Uart, phantom: core::marker::PhantomData }
|
unsafe { Self::_new_mmio(UART1_BASE as *mut _) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user