Peripheral Drivers
Driver Architecture
LL (Low Layer)
Used for encapsulating the operations of various chip registers to prevent the application layer from directly calling register interfaces.
HAL (Hardware Adaption Layer)
Implements basic hardware functions based on LL layer interfaces.
Controller Driver
Implements various functionalities of controllers within the Chip based on HAL layer interfaces. It is OS-dependent and capable of executing mutex, semaphore, and other resource protection functions. (Types of controllers include: I2C, SPI, DMA, Timer, WDT, I2S, Clock, USB, SDIO, IRQ, PWM, ADC, LCD, Touch, Uart, RTC, PMU, Crypto Engine, GPIO, etc.)
Device Driver
Implements the driving functions of external devices of the chip based on Controller Driver interfaces (e.g., sensors, EEPROM, SIP Flash, TFT screens, etc.).
Device Manager
A device management unit used for unified management of the configurations of all devices (controllers and external devices) in the current project, similar to the Linux device tree function.
Users can refer to Examples and use Controller Driver APIs for application development.
Driver Introduction
How to Add a New Device Driver
Based on the current driver architecture, adding a new device driver generally involves the following steps and considerations
Research and Configure Pinmux Requirements,Refer to Pinmux
Add New Device Configuration in the Device Table,Refer to Device Table
Plan the
wm_device_t
Structure for the New Device, For example :
Plan the New Device Driver Architecture, Including Ops Definition and Reentrant Mechanism Design : For example
File Directory Management
Note
In peripheral drivers, it is advisable to avoid calling HAL interfaces directly. The reason is that HAL interfaces lack reentrant protection, and direct calls from multiple tasks may lead to resource access conflicts or deadlock