SerialPortDevice

Trait SerialPortDevice 

Source
pub trait SerialPortDevice {
    type Timestamp: Sized;

    // Required methods
    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§

Source

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.

Source

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.

Source

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.

Source

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.

Source

fn next_frame(&mut self, eof_timestamp: Self::Timestamp)

Called when the current frame ends to allow emulators to wrap stored timestamps.

Implementors§