Trait spectrusty::peripherals::bus::zxinterface1::SerialPortDevice
source · pub trait SerialPortDevice {
type Timestamp: Sized;
fn write_data(
&mut self,
rxd: DataState,
timestamp: Self::Timestamp
) -> ControlState;
fn poll_ready(&mut self, timestamp: Self::Timestamp) -> ControlState;
fn update_cts(&mut self, cts: ControlState, timestamp: Self::Timestamp);
fn read_data(&mut self, timestamp: Self::Timestamp) -> DataState;
fn next_frame(&mut self, eof_timestamp: Self::Timestamp);
}
Expand description
An interface for emulating communication between a ZX Spectrum’s hardware port and remote devices.
Emulators of peripheral devices should implement this trait.
Methods of this trait are being called by bus devices implementing serial port communication.
Required Associated Types§
Required Methods§
sourcefn write_data(
&mut self,
rxd: DataState,
timestamp: Self::Timestamp
) -> ControlState
fn write_data(
&mut self,
rxd: DataState,
timestamp: Self::Timestamp
) -> ControlState
A device receives a current RxD
state from Spectrum and should output a DTR
line state.
This method is being called when a CPU
writes (OUT) to a port and only when the CTS
line isn’t
changed by the write.
sourcefn poll_ready(&mut self, timestamp: Self::Timestamp) -> ControlState
fn poll_ready(&mut self, timestamp: Self::Timestamp) -> ControlState
This method is being called once every frame, near the end of it, and should return a DTR
line state.
sourcefn update_cts(&mut self, cts: ControlState, timestamp: Self::Timestamp)
fn update_cts(&mut self, cts: ControlState, timestamp: Self::Timestamp)
Receives an updated CTS
line state.
This method is being called when a CPU
writes (OUT) to a port and only when the value of CTS
changes.
sourcefn read_data(&mut self, timestamp: Self::Timestamp) -> DataState
fn read_data(&mut self, timestamp: Self::Timestamp) -> DataState
Should return a TxD
line state.
This method is being called when a CPU
reads (IN) from a port.
sourcefn next_frame(&mut self, eof_timestamp: Self::Timestamp)
fn next_frame(&mut self, eof_timestamp: Self::Timestamp)
Called when the current frame ends to allow emulators to wrap stored timestamps.