Skip to main content

Crate drivers_peripherals

Crate drivers_peripherals 

Source
Expand description

Shared base for peripheral device nodes.

A class adapter (UART, I2C, SPI, …) implements PeripheralHandle over the embedded-hal or embedded-io handle it owns, then wraps it in PeripheralDevice and mounts it under /devices/<class>/<name> with mount_peripheral. Applications use the ordinary File API (open, read, write, poll, close) and receive no new public API from this crate.

The base defines no control commands. Each class defines its own commands with file_system::define_command! using a distinct kind byte (for example b'u' for UART, b'i' for I2C, b's' for SPI and b'a' for ADC). Command input and output structs must be versioned, #[repr(C)], and live in the class module.

Structs§

PeripheralDevice
Character device exposing a PeripheralHandle through the VFS polling contract.

Traits§

PeripheralHandle
Class-specific handle wrapped by PeripheralDevice.

Functions§

mount_peripheral
Mounts handle as a character device at path, for example /devices/uart/uart0, with the default device permissions. The caller chooses the class directory; this helper adds no permission policy beyond the VFS mount defaults.
mount_peripheral_with_permissions
Mounts handle as a character device at path with explicit permissions, for device classes whose writes are reserved to the mounting user (for example the real-time clock with [Permissions::PRIVILEGED_DEVICE]).