Struct spectrusty_peripherals::network::zxnet::ZxNet
source · pub struct ZxNet<T, S> {
pub socket: S,
/* private fields */
}
Expand description
Implementation of this struct decodes and encodes ZX-NET packets from Spectrum’s I/O port signals.
An implementation of ZxNetSocket should be provided as its S
type parameter.
Fields§
§socket: S
Direct access to the underlying ZxNetSocket implementation.
Implementations§
source§impl<T: TimestampOps, S: ZxNetSocket> ZxNet<T, S>
impl<T: TimestampOps, S: ZxNetSocket> ZxNet<T, S>
sourcepub fn send_state(&mut self, net: bool, timestamp: T)
pub fn send_state(&mut self, net: bool, timestamp: T)
Examples found in repository?
src/bus/zxinterface1.rs (line 322)
313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348
fn write_io(&mut self, port: u16, data: u8, timestamp: Self::Timestamp) -> Option<u16> {
match port & IF1_MASK {
IF1_SERN_BITS => {
let data = If1SerNetIo::from_bits_truncate(data);
if self.ctrl_out.is_comms_out_ser() {
self.ctrl_in.set_dtr(self.serial.write_data(data.rxd(), timestamp));
}
else {
// println!("net write rxs: {:?} {:?}", (rxd as u8)^1, timestamp);
self.network.send_state(data.net(), timestamp);
// TODO: handle network
}
Some(0)
}
IF1_CTRL_BITS => {
let data = If1ControlOut::from_bits_truncate(data);
let diff = self.ctrl_out ^ data;
// println!("ctrl write: {:?}", data);
self.ctrl_out ^= diff;
if !(diff & If1ControlOut::MD_MASK).is_empty() {
self.microdrives.write_control(timestamp,
data.erase(), data.write(), data.comms_clk(), data.comms_out());
}
if !(diff & If1ControlOut::SER_CTS).is_empty() {
self.serial.update_cts(data.cts(), timestamp);
}
if data.wait() {
self.network.wait_data(timestamp);
// TODO: handle network
}
Some(0)
}
IF1_DATA_BITS => Some(self.microdrives.write_data(data, timestamp)),
_ => self.bus.write_io(port, data, timestamp)
}
}
sourcepub fn poll_state(&mut self, timestamp: T) -> bool
pub fn poll_state(&mut self, timestamp: T) -> bool
Examples found in repository?
src/bus/zxinterface1.rs (line 294)
289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310
fn read_io(&mut self, port: u16, timestamp: Self::Timestamp) -> Option<(u8, Option<NonZeroU16>)> {
match port & IF1_MASK {
IF1_SERN_BITS => {
self.sernet.set_txd(self.serial.read_data(timestamp));
if self.ctrl_out.cts().is_inactive() {
self.sernet.set_net(self.network.poll_state(timestamp));
}
// println!("net read: {:02x} {:?}", self.sernet.bits(), timestamp);
Some((self.sernet.bits(), None))
}
IF1_CTRL_BITS => {
self.ctrl_in.set_md_state(self.microdrives.read_state(timestamp));
// println!("ctrl read: {:02x} {:?}", self.ctrl_in.bits(), timestamp);
// TODO: poll busy?
Some((self.ctrl_in.bits(), None))
}
IF1_DATA_BITS => {
Some(self.microdrives.read_data(timestamp))
}
_ => self.bus.read_io(port, timestamp)
}
}
sourcepub fn wait_data(&mut self, timestamp: T)
pub fn wait_data(&mut self, timestamp: T)
Examples found in repository?
src/bus/zxinterface1.rs (line 340)
313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348
fn write_io(&mut self, port: u16, data: u8, timestamp: Self::Timestamp) -> Option<u16> {
match port & IF1_MASK {
IF1_SERN_BITS => {
let data = If1SerNetIo::from_bits_truncate(data);
if self.ctrl_out.is_comms_out_ser() {
self.ctrl_in.set_dtr(self.serial.write_data(data.rxd(), timestamp));
}
else {
// println!("net write rxs: {:?} {:?}", (rxd as u8)^1, timestamp);
self.network.send_state(data.net(), timestamp);
// TODO: handle network
}
Some(0)
}
IF1_CTRL_BITS => {
let data = If1ControlOut::from_bits_truncate(data);
let diff = self.ctrl_out ^ data;
// println!("ctrl write: {:?}", data);
self.ctrl_out ^= diff;
if !(diff & If1ControlOut::MD_MASK).is_empty() {
self.microdrives.write_control(timestamp,
data.erase(), data.write(), data.comms_clk(), data.comms_out());
}
if !(diff & If1ControlOut::SER_CTS).is_empty() {
self.serial.update_cts(data.cts(), timestamp);
}
if data.wait() {
self.network.wait_data(timestamp);
// TODO: handle network
}
Some(0)
}
IF1_DATA_BITS => Some(self.microdrives.write_data(data, timestamp)),
_ => self.bus.write_io(port, data, timestamp)
}
}
sourcepub fn next_frame(&mut self, eof_timestamp: T)
pub fn next_frame(&mut self, eof_timestamp: T)
Trait Implementations§
Auto Trait Implementations§
impl<T, S> RefUnwindSafe for ZxNet<T, S>where
S: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, S> Send for ZxNet<T, S>where
S: Send,
T: Send,
impl<T, S> Sync for ZxNet<T, S>where
S: Sync,
T: Sync,
impl<T, S> Unpin for ZxNet<T, S>where
S: Unpin,
T: Unpin,
impl<T, S> UnwindSafe for ZxNet<T, S>where
S: UnwindSafe,
T: UnwindSafe,
Blanket Implementations§
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
Causes
self
to use its Binary
implementation when Debug
-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
Causes
self
to use its Octal
implementation when Debug
-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
Formats each item in a sequence. Read more
source§impl<S, T> IntoSample<S> for Twhere
S: FromSample<T>,
impl<S, T> IntoSample<S> for Twhere
S: FromSample<T>,
source§fn into_sample(self) -> S
fn into_sample(self) -> S
Convert to
S
a sample type from self
.§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Pipes by value. This is generally the method you want to use. Read more
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
Borrows
self
and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
Mutably borrows
self
and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> Rwhere
Self: BorrowMut<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> Rwhere
Self: BorrowMut<B>,
B: 'a + ?Sized,
R: 'a,
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
Borrows
self
, then passes self.as_ref()
into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
Immutable access to the
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
Mutable access to the
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
Immutable access to the
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
Mutable access to the
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere
Self: Deref<Target = T>,
T: ?Sized,
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere
Self: Deref<Target = T>,
T: ?Sized,
Immutable access to the
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
Mutable access to the
Deref::Target
of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
Calls
.tap()
only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
Calls
.tap_mut()
only in debug builds, and is erased in release
builds. Read more§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
Calls
.tap_borrow()
only in debug builds, and is erased in release
builds. Read more§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
Calls
.tap_borrow_mut()
only in debug builds, and is erased in release
builds. Read more§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
Calls
.tap_ref()
only in debug builds, and is erased in release
builds. Read more§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
Calls
.tap_ref_mut()
only in debug builds, and is erased in release
builds. Read more