Device Drivers
This chapter summarizes LibXR's abstract interfaces for common hardware peripherals.
LibXR device interfaces share these properties:
- Abstract classes use unified naming and behavior; platform differences live in the backends.
- Transfers describe completion with an
Operation(blocking, callback, or polling): UART transfers go throughReadPort/WritePortqueues, while each I2C or SPI transfer takes aReadOperation/WriteOperationdirectly; backends may complete them from interrupts or DMA. - Interface parameters and configuration structures are strongly typed.
- They depend on C++20 and the LibXR core API and run on bare metal and RTOSes.
- Each peripheral is implemented according to platform capabilities, including shared resources such as shared buses.
Contents
- GPIO (General Purpose Input/Output)
- UART (Serial Communication)
- I2C (I2C Bus)
- SPI (SPI Interface)
- CAN / FDCAN (Controller Area Network)
- ADC (Analog-to-Digital Conversion)
- DAC (Digital-to-Analog Conversion)
- PWM (Pulse-Width Modulation)
- Flash (Flash Interface)
- Power (Power Management)
- Timebase (Time Base)
- Watchdog (Watchdog Timer)
- USB (Universal Serial Bus)
- Network and Wi-Fi
- Debug Interfaces (SWD / JTAG)
Interface structure
Many peripheral abstraction classes include some of the following building blocks, but not every driver exposes the full set:
- a
Configurationstructure and a matchingSetConfig()interface Read()/Write()style data-transfer interfaces where the peripheral is stream- or transaction-oriented- control interfaces such as
Enable()/Disable()when the hardware model requires them - callback registration for event-driven paths such as interrupts or asynchronous completions
For Read() / Write() that go through ReadPort / WritePort, as on UART, when the call returns, what each return code means and how long buffers must stay valid are described in IO Read/Write Abstraction; SPI and I2C transfers are described in the "Behavior" section of their pages.
ADC, DAC, PowerManager, Timebase, and Flash expose only the few calls their devices need.
Upper-layer code calls the interface through a base-class pointer or reference, so the same code works with STM32UART, ESP32UART, LinuxUART, and other backends.