Skip to main content
← PSoXide SDK guides and examples · SDK f2fec1c301f1 · All Cargo features enabled; check feature gates before use.

Peripherals

Struct Peripherals 

Source
#[non_exhaustive]
pub struct Peripherals { pub gpu_dma: GpuDma, pub ordering_table_clear_dma: OrderingTableClearDma, pub mdec_dma: MdecDma, pub spu_dma: SpuDma, pub cd: Cd, pub controller_port: ControllerPort, }
Expand description

Every shared-state peripheral token, handed out once.

ⓘ
let p = psx_rt::Peripherals::take().unwrap();
let mut gpu = psx_gpu::Gpu::new(p.gpu_dma, display);
let mut port = p.controller_port; // pads and memory cards borrow it
let mut spu = psx_spu::Spu::new(p.spu_dma);
let cd = p.cd; // or `SectorReader::with_cd(cd)`, `xa::Player::new(cd)`

Each token is owned by the driver that programs its device; see psx_io::periph for who that is.

The tokens are zero-sized, so Peripherals is too; moving it or its fields around costs nothing.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§gpu_dma: GpuDma

DMA channel 2 and the GP0 stream it feeds.

§ordering_table_clear_dma: OrderingTableClearDma

DMA channel 6, the ordering-table clear.

§mdec_dma: MdecDma

DMA channels 0 and 1 (MDEC in and out).

§spu_dma: SpuDma

DMA channel 4 and the SPU transfer port.

§cd: Cd

The CD-ROM controller and DMA channel 3.

§controller_port: ControllerPort

The pad and memory-card port (SIO0).

Implementations§

Source§

impl Peripherals

Source

pub fn take() -> Option<Self>

The token set, the first time this is called; None after that.

One flag test inside a short critical section.

Source

pub unsafe fn steal() -> Self

The token set, whether or not take already ran.

§Safety

The caller must not use a token from this set while the same token from another set is in use (see psx_io::periph).

Trait Implementations§

Source§

impl Debug for Peripherals

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Peripherals

§

impl RefUnwindSafe for Peripherals

§

impl Send for Peripherals

§

impl Sync for Peripherals

§

impl Unpin for Peripherals

§

impl UnsafeUnpin for Peripherals

§

impl UnwindSafe for Peripherals

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.