Inhaltsverzeichnis

std.hardware

Das std.hardware-Paket enthält Treiber und Protokoll-Implementierungen für Hardware-Schnittstellen. Alle Units setzen direkt auf Kernel-Syscalls, AF_BLUETOOTH-Sockets, usbdevfs-ioctls oder MMIO-Register auf — keine externen Bibliotheken.

Einsatzbereiche: IoT-Geräte, eingebettete Linux-Systeme (Raspberry Pi 4), BLE-Sensoren, Classic-Bluetooth-Peripherie, USB-HID-Geräte, virtuelle serielle Ports (CDC/ACM), GPIO-Steuerung, Automotive-Systeme.

Standard Library · std.android · std.net


Units im Überblick

Alle Units dieses Pakets im Überblick:

Unit Import Beschreibung
std.hardware.bluetooth import std.hardware.bluetooth; Nativer Bluetooth-Stack: AF_BLUETOOTH-Sockets, BlueZ-D-Bus, BLE GATT, Classic RFCOMM — 9 Sub-Units
std.hardware.usb import std.hardware.usb_discovery; Nativer USB-Stack: usbdevfs-ioctls, Control/Bulk/Interrupt/ISO-Transfers, typsichere EP-Wrapper, URB-Pool — 13 Sub-Units
std.hardware.gpio import std.hardware.gpio_mmio; GPIO-Stack (RPi4/BCM2711): MMIO-Direktzugriff, Linux GPIO-v2 ioctl, SoftPWM, Edge-Detection — 8 Sub-Units

std.hardware.bluetooth — Architektur

Die Bluetooth-Unit deckt den gesamten Protokoll-Stack in Lyx-nativen Implementierungen ab:

Schicht Sub-Unit Beschreibung
AI / Profile bluetooth_ai Typsichere GATT-Characteristic-Wrapper: ReadableChar, WritableChar, NotifiableChar
BLE GATT Client bluetooth_gattc GATT-Client: Services, Characteristics, Descriptors lesen/schreiben
BLE GATT Server bluetooth_gatts GATT-Server: GattServerRegister, GattServerHandleNext, GattServerSendNotification
BLE L2CAP + ATT bluetooth_l2cap L2CAP-Verbindungen + vollständiges ATT-Protokoll (Opcodes, Read/Write/Notify)
Classic RFCOMM bluetooth_rfcomm Serielle Verbindungen: RFCommConnect, RFCommSend, RFCommRecv, RFCommListen
BLE Scanner / Advertising / Mesh bluetooth_ext BLE Scanner, BLE Advertising, Mesh-Stub (BleScannerStart, BleAdvertisementRegister)
BlueZ D-Bus Steuerung bluetooth_dbus Discovery, Pairing, Connect via D-Bus: BlueZOpenConnection, BlueZStartDiscovery
Adresstypen bluetooth_types BDADDR-Typen, sockaddr_rc/l2, BTAddrFromBytes, BTAddrToStr
Socket-Grundschicht bluetooth AF_BLUETOOTH-Konstanten, HCI-ioctls, BTPROTO_*, poll-Flags

std.hardware.usb — Architektur

Der USB-Stack deckt alle Host-Transfers in 13 Sub-Units ab:

Schicht Sub-Unit Beschreibung
High-Level / Sicherheit usb_endpoint_types Typsichere Endpoint-Wrapper (Bulk OUT/IN, Interrupt IN)
High-Level / Sicherheit usb_endpoint_bind Endpoint-Registry: Adressen per Schlüssel binden
Async-Infrastruktur usb_urb_pool URB-Pool (4 Slots) für überlappende Interrupt-Transfers
Async-Infrastruktur usb_ifc_mgr Idempotenter Interface-Claim/Release-Manager
Transfer-Schicht usb_interrupt Asynchrone Interrupt-Transfers (URB-basiert)
Transfer-Schicht usb_iso Isochronous Transfers (Audio/Video)
Transfer-Schicht usb_bulk Synchrone Bulk-Transfers
Transfer-Schicht usb_control Control-Transfers + Interface-Claim/Release-IOCTLs
Erkennung usb_discovery Geräteerkennung via /dev/bus/usb/ (VID/PID-Scan)
Descriptor-Parsing usb_parse Configuration-Descriptor-Strom → Config/Iface/EP-Baum
Typen & Accessoren usb_types Descriptor-Konstanten, Lyx-Structs, Accessor-Funktionen
Hilfstypen usb_util Dirent64-Parser, String-Utilities, Pfad-Builder
Grundschicht usb_syscalls open/read/write/ioctl/close/lseek/getdents64/poll-Wrapper

std.hardware.gpio — Architektur

Der GPIO-Stack unterstützt zwei komplementäre Zugriffsmodi für den Raspberry Pi 4 (BCM2711):

Schicht Sub-Unit Beschreibung
Typsichere Wrapper gpio_pin OutputPin (nur Write) / InputPin (nur Read) — Compile-Time-Schutz
Erweiterungen gpio_ext Alt-Funktionen (ALT0–ALT5), Edge-Detection (poll), Software-PWM
Variante A: MMIO gpio_mmio Direktzugriff auf BCM2711-Register — kein Syscall nach GpioInit
Variante B: ioctl gpio_ioctl Linux GPIO-v2 API (Kernel ≥ 5.10) — Multi-Pin atomar, Consumer-Labels
Hilfsfunktionen gpio_util GpioDelayMicroseconds (CLOCK_MONOTONIC), GpioCopyStringToBuf
Plattform-Konstanten rpi4 BCM2711 Register-Offsets, Pin-Modi, Pull-Codes (nur Konstanten)
Grundschicht gpio_syscalls open/close/ioctl/poll/mmap/munmap-Wrapper
Grundschicht gpio_barriers ARM64 DMB SY (mem_barrier) / ISB SY (inst_barrier)

Letzte Aktualisierung: 2026-06-07