pub trait UartPort: Send + 'static {
// Required methods
fn startup(&mut self, config: &Config) -> Result<(), ConfigError>;
fn shutdown(&mut self);
fn set_config(&mut self, config: &Config) -> Result<(), ConfigError>;
fn read_rx(&mut self) -> Option<RxSample>;
fn discard_rx(&mut self);
fn write_tx(&mut self, bytes: &[u8]) -> usize;
fn discard_tx(&mut self) -> bool;
fn tx_idle(&mut self) -> bool;
fn mask(&mut self, sources: SerialEventSet);
fn mask_all(&mut self);
fn rearm(&mut self, sources: SerialEventSet) -> SerialEventSet;
}Expand description
UART data/control endpoint owned by one runtime maintenance task.
All calls must run on the same CPU as the associated UartIrq with local
device IRQ delivery excluded. This is a device-serialization contract, not
a memory-safety precondition.
Required Methods§
Sourcefn startup(&mut self, config: &Config) -> Result<(), ConfigError>
fn startup(&mut self, config: &Config) -> Result<(), ConfigError>
Initializes the UART while leaving every device interrupt source masked.
On error, implementations must restore the configuration registers they
changed so a transactional early-console handoff can safely roll back.
ConfigError::RegisterError is reserved for failures where hardware
state cannot be proven restored and the caller must fail closed.
fn shutdown(&mut self)
fn set_config(&mut self, config: &Config) -> Result<(), ConfigError>
Sourcefn read_rx(&mut self) -> Option<RxSample>
fn read_rx(&mut self) -> Option<RxSample>
Reads one normalized hardware sample without consulting IRQ state.
Sourcefn discard_rx(&mut self)
fn discard_rx(&mut self)
Discards bytes and error state pending in the hardware receiver.
Sourcefn write_tx(&mut self, bytes: &[u8]) -> usize
fn write_tx(&mut self, bytes: &[u8]) -> usize
Writes as much of bytes as the hardware can currently accept.
Sourcefn discard_tx(&mut self) -> bool
fn discard_tx(&mut self) -> bool
Discards bytes queued in the hardware transmitter. A byte already in the shift register may still complete. Returns whether the hardware supports an independent TX-only discard.
Sourcefn tx_idle(&mut self) -> bool
fn tx_idle(&mut self) -> bool
Returns whether both the FIFO and transmitter shift register are empty.
Sourcefn mask(&mut self, sources: SerialEventSet)
fn mask(&mut self, sources: SerialEventSet)
Masks only the requested device-local interrupt sources.
fn mask_all(&mut self)
Sourcefn rearm(&mut self, sources: SerialEventSet) -> SerialEventSet
fn rearm(&mut self, sources: SerialEventSet) -> SerialEventSet
Rearms sources and closes the enable/readiness race.
Sources that are already ready after being enabled are masked again and returned so the maintenance task can immediately continue servicing them instead of relying on a possibly lost edge.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".