pub struct ControllerPort { /* private fields */ }Expand description
The token a HardwareCard drives the port through.
The controller and memory-card port.
Implementations§
Source§impl ControllerPort
impl ControllerPort
Sourcepub const unsafe fn steal() -> ControllerPort
pub const unsafe fn steal() -> ControllerPort
Make a token without going through psx_rt::Peripherals::take().
§Safety
The caller must not use this token while another one of the same type is in use: two owners of one device each assume they are the only driver programming it.
Trait Implementations§
Source§impl Debug for ControllerPort
impl Debug for ControllerPort
Source§impl Transport for ControllerPort
impl Transport for ControllerPort
Source§fn set_control(&mut self, value: u16)
fn set_control(&mut self, value: u16)
Write the control register.
Source§fn select_with(&mut self, port: Port, arm_ack_irq: bool)
fn select_with(&mut self, port: Port, arm_ack_irq: bool)
select with the /ACK interrupt armed when
arm_ack_irq is set, so STAT latches each pulse. Memory cards use
this because a CPU interrupt can hide a complete short ACK pulse.Source§fn reset(&mut self)
fn reset(&mut self)
Reset the port’s UART. A deselect alone need not cancel a late reply
still in the shifter, so a failed transaction ends with this.
Source§fn drain_receive(&mut self)
fn drain_receive(&mut self)
Pop up to a few stale bytes so the next reply lines up with the
first byte of the transaction. Bounded, so a stuck “RX not empty” flag
cannot spin forever.
Source§fn delay(&mut self, spins: u32)
fn delay(&mut self, spins: u32)
Burn time with
spins status reads, which the compiler cannot remove.Source§fn wait_status_set(&mut self, mask: u32, spins: u32) -> bool
fn wait_status_set(&mut self, mask: u32, spins: u32) -> bool
Spin until any bit of
mask is set in the status register, at most
spins reads after the first. false on timeout.Source§fn wait_status_clear(&mut self, mask: u32, spins: u32) -> bool
fn wait_status_clear(&mut self, mask: u32, spins: u32) -> bool
Spin until every bit of
mask is clear in the status register, at most
spins reads after the first. false on timeout.Source§fn begin(&mut self, port: Port, timing: Timing) -> bool
fn begin(&mut self, port: Port, timing: Timing) -> bool
Start a transaction: select
port, wait out the setup time, drop
stale bytes, and wait for an /ACK left asserted by an aborted
transaction to release, so it is not counted as the first byte’s. Read moreSource§fn begin_card(&mut self, port: Port, timing: Timing) -> bool
fn begin_card(&mut self, port: Port, timing: Timing) -> bool
Begin a memory-card transaction with the SIO ACK interrupt latch
armed. The card’s short pulse can fall entirely inside an unrelated
CPU interrupt, after which the live DSR level no longer records it.
Source§fn finish_begin(&mut self, timing: Timing) -> bool
fn finish_begin(&mut self, timing: Timing) -> bool
Shared setup, stale RX drain and live ACK release check after select.
Source§fn finish(&mut self, succeeded: bool)
fn finish(&mut self, succeeded: bool)
End a transaction: release
/CS, and after a failed one reset the
UART as well. The next select restores mode and baud.Source§fn exchange(
&mut self,
byte: u8,
is_last: bool,
timing: Timing,
) -> Result<u8, ExchangeError>
fn exchange( &mut self, byte: u8, is_last: bool, timing: Timing, ) -> Result<u8, ExchangeError>
Clock one byte and wait for the device’s
/ACK. Read moreSource§fn exchange_card(
&mut self,
port: Port,
byte: u8,
is_last: bool,
timing: Timing,
) -> Result<u8, ExchangeError>
fn exchange_card( &mut self, port: Port, byte: u8, is_last: bool, timing: Timing, ) -> Result<u8, ExchangeError>
Card byte exchange. STAT.IRQ latches an ACK edge across a CPU
interrupt; the live DSR level still has to release before the next
byte, and CTRL.ACK clears only this byte’s latch while /CS stays low.