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

HardwareCard

Struct HardwareCard 

Source
pub struct HardwareCard<P = ControllerPort> { /* private fields */ }
Expand description

A physical memory card reached over SIO0.

P is how the card holds the port: the ControllerPort token (the default) or a &mut ControllerPort borrowed from the program for the length of the card’s use. While a card holds the port, a pad poll cannot borrow it:

ⓘ
use psx_mc::{HardwareCard, Slot};
use psx_io::periph::ControllerPort;

// SAFETY: the doctest never touches the port; it only has to compile.
let mut port = unsafe { ControllerPort::steal() };
let mut card = HardwareCard::on_port(&mut port, Slot::One);
let other_driver = &mut port; // the card still holds the borrow
let _ = card.last_trace();
let _ = other_driver;

Implementations§

Source§

impl HardwareCard<ControllerPort>

Source

pub fn new(slot: Slot) -> Self

👎Deprecated:

use HardwareCard::on_port with the ControllerPort token

A card on the given slot with default timing.

Source§

impl<P: BorrowMut<ControllerPort>> HardwareCard<P>

Source

pub fn on_port(port: P, slot: Slot) -> Self

A card on slot, reached through port (the token, or a borrow of it), with the memory card’s default Timing.

Source

pub fn on_port_with_timing(port: P, slot: Slot, timing: Timing) -> Self

on_port with custom Timing, for tuning against real silicon.

Source

pub fn release(self) -> P

Give the port back: the token when the card owned it, the borrow otherwise.

Source

pub fn last_trace(&self) -> TransportTrace

Diagnostic evidence from the most recent frame read or write.

Source

pub fn controller_port(&mut self) -> &mut ControllerPort

The port, between transactions, for another driver that shares it (a pad poll). Every frame read or write finishes inside its own call, so the card is never mid-transaction when this is reachable.

Trait Implementations§

Source§

impl<P: BorrowMut<ControllerPort>> Block for HardwareCard<P>

Source§

fn read_frame(&mut self, frame: u16, out: &mut [u8; 128]) -> Result<()>

Read frame frame (0..FRAME_COUNT) into out.
Source§

fn write_frame(&mut self, frame: u16, data: &[u8; 128]) -> Result<()>

Write data to frame frame (0..FRAME_COUNT).

Auto Trait Implementations§

§

impl<P> Freeze for HardwareCard<P>
where P: Freeze,

§

impl<P> RefUnwindSafe for HardwareCard<P>
where P: RefUnwindSafe,

§

impl<P> Send for HardwareCard<P>
where P: Send,

§

impl<P> Sync for HardwareCard<P>
where P: Sync,

§

impl<P> Unpin for HardwareCard<P>
where P: Unpin,

§

impl<P> UnsafeUnpin for HardwareCard<P>
where P: UnsafeUnpin,

§

impl<P> UnwindSafe for HardwareCard<P>
where P: UnwindSafe,

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.