Skip to main content

UartPort

Trait UartPort 

Source
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§

Source

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.

Source

fn shutdown(&mut self)

Source

fn set_config(&mut self, config: &Config) -> Result<(), ConfigError>

Source

fn read_rx(&mut self) -> Option<RxSample>

Reads one normalized hardware sample without consulting IRQ state.

Source

fn discard_rx(&mut self)

Discards bytes and error state pending in the hardware receiver.

Source

fn write_tx(&mut self, bytes: &[u8]) -> usize

Writes as much of bytes as the hardware can currently accept.

Source

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.

Source

fn tx_idle(&mut self) -> bool

Returns whether both the FIFO and transmitter shift register are empty.

Source

fn mask(&mut self, sources: SerialEventSet)

Masks only the requested device-local interrupt sources.

Source

fn mask_all(&mut self)

Source

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".

Implementors§