提交 637b9510 编写于 作者: A annie_wangli

update docs

Signed-off-by: Nannie_wangli <annie.wangli@huawei.com>
上级 cc862674
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
- [HDF Development Example](driver-hdf-sample.md) - [HDF Development Example](driver-hdf-sample.md)
- [Platform Driver Development](driver-develop.md) - [Platform Driver Development](driver-develop.md)
- [ADC](driver-platform-adc-develop.md) - [ADC](driver-platform-adc-develop.md)
- [DAC](driver-platform-dac-develop.md)
- [GPIO](driver-platform-gpio-develop.md) - [GPIO](driver-platform-gpio-develop.md)
- [HDMI](driver-platform-hdmi-develop.md) - [HDMI](driver-platform-hdmi-develop.md)
- [I2C](driver-platform-i2c-develop.md) - [I2C](driver-platform-i2c-develop.md)
...@@ -26,6 +27,7 @@ ...@@ -26,6 +27,7 @@
- [Watchdog](driver-platform-watchdog-develop.md) - [Watchdog](driver-platform-watchdog-develop.md)
- [Platform Driver Usage](driver-platform.md) - [Platform Driver Usage](driver-platform.md)
- [ADC](driver-platform-adc-des.md) - [ADC](driver-platform-adc-des.md)
- [DAC](driver-platform-dac-des.md)
- [GPIO](driver-platform-gpio-des.md) - [GPIO](driver-platform-gpio-des.md)
- [HDMI](driver-platform-hdmi-des.md) - [HDMI](driver-platform-hdmi-des.md)
- [I2C](driver-platform-i2c-des.md) - [I2C](driver-platform-i2c-des.md)
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
- **[ADC](driver-platform-adc-develop.md)** - **[ADC](driver-platform-adc-develop.md)**
- **[DAC](driver-platform-dac-develop.md)**
- **[GPIO](driver-platform-gpio-develop.md)** - **[GPIO](driver-platform-gpio-develop.md)**
- **[HDMI](driver-platform-hdmi-develop.md)** - **[HDMI](driver-platform-hdmi-develop.md)**
......
# DAC
## Overview
### DAC
A digit-to-analog converter (DAC) is a device that converts a digital signal into an analog signal in electronics.
The DAC APIs provide a set of methods for DAC data transfer, including:
- Opening or closing a DAC device
- Setting the target digital-to-analog (DA) value
### Basic Concepts
The DAC module provides the output channel for the process control computer system. It connects to the executor to implement automatic control of the production process. It is also an important module in the analog-to-digital converter using feedback technologies.
- Resolution
The number of binary bits that can be converted by a DAC. A greater number of bits indicates a higher resolution.
- Conversion precision
Difference between the actual output value of the DAC and the theoretical value when the maximum value is added to the input end. The conversion precision of a DAC converter varies depending on the structure of the chip integrated on the DAC and the interface circuit configuration. The ideal conversion precision value should be as small as possible. To achieve optimal DAC conversion precision, the DAC must have high resolution. In addition, errors in the devices or power supply of the interface circuits will affect the conversion precision. When the error exceeds a certain degree, a DAC conversion error will be caused.
- Conversion speed
The conversion speed is determined by the setup time. The setup time is the period from the time the input suddenly changes from all 0s to all 1s to the time the output voltage remains within the FSR ± ½LSB (or FSR ± x%FSR). It is the maximum response time of the DAC, and hence used to measure the conversion speed.
The full scale range (FSR) is the maximum range of the output signal amplitude of a DAC. Different DACs have different FSRs, which can be limited by positive and negative currents or voltages.
The least significant byte (LSB) refers to bit 0 (the least significant bit) in a binary number.
### Working Principles
In the Hardware Driver Foundation (HDF), the DAC module uses the unified service mode for API adaptation. In this mode, a device service is used as the DAC manager to handle access requests from the devices of the same type in a unified manner. The unified service mode applies to the scenario where there are many device objects of the same type. If the independent service mode is used, more device nodes need to be configured and memory resources will be consumed by services. The figure below shows the unified service mode.
The DAC module is divided into the following layers:
- The interface layer provides APIs for opening or closing a device and writing data.
- The core layer provides the capabilities of binding, initializing, and releasing devices.
- The adaptation layer implements other functions.
![](../public_sys-resources/icon-note.gif)NOTE<br/>The core layer can call the functions of the interface layer and uses the hook to call functions of the adaptation layer. In this way, the adaptation layer can indirectly call the functions of the interface layer, but the interface layer cannot call the functions of the adaptation layer.
**Figure 1** Unified service mode
![Unified service mode](figures/Unified_service_mode.png "DAC unified service mode")
### Constraints
Currently, the DAC module supports only the kernels (LiteOS) of mini and small systems.
## Development Guidelines
### When to Use
The DAC module converts digital signals into analog signals in the form of current, voltage, or charge. It is mainly used in audio devices. Audio players and headsets use the DAC module as the digital-to-analog conversion channels.
### Available APIs
The table below describes the APIs of the DAC module. For more details, see API Reference.
**Table 1** DAC driver APIs
| API | Description |
| :------------------------------------------------------------| :------------ |
| DevHandle DacOpen(uint32_t number) | Opens a DAC device. |
| void DacClose(DevHandle handle) | Closes a DAC device. |
| int32_t DacWrite(DevHandle handle, uint32_t channel, uint32_t val) | Sets the target DA value. |
### How to Develop
The figure below illustrates the process of using a DAC device.
**Figure 2** Process of using a DAC device
![Process of using a DAC](figures/process_of_using_DAC.png "Process of using a DAC")
#### Opening a DAC Device
Call **DacOpen()** to open a DAC device before performing the DA conversion.
```
DevHandle DacOpen(uint32_t number);
```
**Table 2** Description of DacOpen
| **Parameter** | Description |
| ---------- | ----------------- |
| number | DAC device number. |
| **Return Value**| **Description** |
| NULL | Failed to open the DAC device. |
| Device handle | Handle of the DAC device opened.|
Open device 1 of the two ADC devices (numbered 0 and 1) in the system.
```
DevHandle dacHandle = NULL; /* DAC device handle /
/* Open the DAC device. */
dacHandle = DacOpen(1);
if (dacHandle == NULL) {
HDF_LOGE("DacOpen: failed\n");
return;
}
```
#### Setting the Target DA Value
```
int32_t DacWrite(DevHandle handle, uint32_t channel, uint32_t val);
```
**Table 3** Description of DacWrite
| **Parameter** | Description |
| ---------- | -------------- |
| handle | DAC device handle. |
| channel | DAC channel number. |
| val | DA value to set. |
| **Return Value**| **Description**|
| 0 | The operation is successful. |
| Negative value | The operation failed. |
```
/* Write the target DA value through the DAC_CHANNEL_NUM channel. */
ret = DacWrite(dacHandle, DAC_CHANNEL_NUM, val);
if (ret != HDF_SUCCESS) {
HDF_LOGE("%s: tp DAC write reg fail!:%d", __func__, ret);
DacClose(dacHandle);
return -1;
}
```
#### Closing a DAC Device
After the DAC communication is complete, call **DacClose()** to close the DAC device.
```
void DacClose(DevHandle handle);
```
**Table 4** Description of DacClose
| **Parameter** | Description |
| ---------- | -------------- |
| handle | DAC device handle. |
| **Return Value**| **Description**|
| void | - |
Example:
```
DacClose(dacHandle); /* Close the DAC device. */
```
## Development Example
The procedure is as follows:
1. Open the DAC device based on the device number and obtain the device handle.
2. Set the DA value. If the operation fails, close the device handle.
3. Close the DAC device handle if the access to the DAC is complete.
You can obtain the operation result by printing the log information based on the **val**.
```
#include "hdmi_if.h" /* Header file for DAC APIs */
#include "hdf_log.h" /* Header file for log APIs */
/* Define device 0, channel 1. */
#define DAC_DEVICE_NUM 0
#define DAC_CHANNEL_NUM 1
/* Main entry of DAC routines. */
static int32_t TestCaseDac(void)
{
// Set the target DA value.
uint32_t val = 2;
int32_t ret;
DevHandle dacHandle;
/* Open the DAC device. */
dacHandle = DacOpen(DAC_DEVICE_NUM);
if (dacHandle == NULL) {
HDF_LOGE("%s: Open DAC%u fail!", __func__, DAC_DEVICE_NUM);
return -1;
}
/* Write data. */
ret = DacWrite(dacHandle, DAC_CHANNEL_NUM, val);
if (ret != HDF_SUCCESS) {
HDF_LOGE("%s: tp DAC write reg fail!:%d", __func__, ret);
DacClose(dacHandle);
return -1;
}
/* Close the DAC device. */
DacClose(dacHandle);
return 0;
}
```
# DAC
## Overview<a name="1"></a>
### DAC<a name="2"></a>
A digit-to-analog converter (DAC) is a device that converts a digital signal into an analog signal in electronics.
### Basic Concepts<a name="3"></a>
The DAC module supports development of digital-to-analog conversion. The DAC module provides the output channel for the process control computer system. It connects to the executor to implement automatic control of the production process. It is also an important module in the analog-to-digital converter using feedback technologies.
- Resolution
The number of binary bits that can be converted by a DAC. A greater number of bits indicates a higher resolution.
- Conversion precision
Difference between the actual output value of the DAC and the theoretical value when the maximum value is added to the input end. The conversion precision of a DAC converter varies depending on the structure of the chip integrated on the DAC and the interface circuit configuration. The ideal conversion precision value should be as small as possible. To achieve optimal DAC conversion precision, the DAC must have high resolution. In addition, errors in the devices or power supply of the interface circuits will affect the conversion precision. When the error exceeds a certain degree, a DAC conversion error will be caused.
- Conversion speed
The conversion speed is determined by the setup time. The setup time is the period from the time the input suddenly changes from all 0s to all 1s to the time the output voltage remains within the FSR ± ½LSB (or FSR ± x%FSR). It is the maximum response time of the DAC, and hence used to measure the conversion speed.
The full scale range (FSR) is the maximum range of the output signal amplitude of a DAC. Different DACs have different FSRs, which can be limited by positive and negative currents or voltages.
The least significant byte (LSB) refers to bit 0 (the least significant bit) in a binary number.
### Working Principles<a name="4"></a>
In the Hardware Driver Foundation (HDF), the DAC module uses the unified service mode for API adaptation. In this mode, a device service is used as the DAC manager to handle access requests from the devices of the same type in a unified manner. The unified service mode applies to the scenario where there are many device objects of the same type. If the independent service mode is used, more device nodes need to be configured and memory resources will be consumed by services. The figure below shows the unified service mode.
The DAC module is divided into the following layers:
- The interface layer provides APIs for opening or closing a device and writing data.
- The core layer provides the capabilities of binding, initializing, and releasing devices.
- The adaptation layer implements other functions.
![](../public_sys-resources/icon-note.gif)NOTE<br/>The core layer can call the functions of the interface layer and uses the hook to call functions of the adaptation layer. In this way, the adaptation layer can indirectly call the functions of the interface layer, but the interface layer cannot call the functions of the adaptation layer.
**Figure 1** Unified service mode<a name="fig14423182615525"></a>
![](figures/unified-service-mode.png "DAC unified service mode")
### Constraints<a name="5"></a>
Currently, the DAC module supports only the kernels (LiteOS) of mini and small systems.
## Development Guidelines<a name="6"></a>
### When to Use<a name="7"></a>
The DAC module is used for digital-to-analog conversion, audio output, and motor control. The DAC driver is used when the digital signals input by the DAC module are converted into analog signals to output.
### Available APIs<a name="8"></a>
The **DacMethod** is used to call the DAC driver functions.
**DacMethod** definition:
```
struct DacMethod {
// Hook used to write data.
int32_t (*write)(struct DacDevice *device, uint32_t channel, uint32_t val);
// Hook used to start a DAC device.
int32_t (*start)(struct DacDevice *device);
// Hook used to stop a DAC device
int32_t (*stop)(struct DacDevice *device);
};
```
**Table 1** Description of the DacMethod structure
<a name="table27410339187"></a>
| Function| Input Parameter | Output Parameter| Return Value | Description |
| -------- | ------------------------------------------------------------ | ---- | ------------------ | -------------- |
| write | **device**: pointer to the DAC controller at the core layer.<br>**channel**: channel ID, which is of the uint32_t type.<br>val: data to write, which is of the uint32_t type.| - | HDF_STATUS| Writes the target digit-to-analog (DA) value.|
| start | **device**: pointer to the DAC controller at the core layer. | - | HDF_STATUS| Starts a DAC device. |
| stop | **device**: pointer to the DAC controller at the core layer. | - | HDF_STATUS| Stops a device. |
### How to Develop<a name="9"></a>
The DAC module adaptation procedure is as follows:
- Instantiate the driver entry.
- Configure attribute files.
- Instantiate the APIs of the core layer.
- Debug the driver.
1. Instantiate the driver entry.
Instantiate the driver entry. The driver entry must be a global variable of the **HdfDriverEntry** type (defined in **hdf_device_desc.h**), and the value of **moduleName** must be the same as that in **device_info.hcs**. In the HDF, the start address of each **HdfDriverEntry** object of all loaded drivers are collected to form a segment address space similar to an array for the upper layer to invoke.
Generally, the HDF calls the **Init()** function to load the driver. If **Init()** fails to be called, the HDF calls **Release()** to release driver resources and exit.
```
static struct HdfDriverEntry g_dacDriverEntry = {
.moduleVersion = 1,
.Init = VirtualDacInit,
.Release = VirtualDacRelease,
.moduleName = "virtual_dac_driver",// (Mandatory) The value must be the same as that in the .hcs file.
};
HDF_INIT(g_dacDriverEntry); // Call HDF_INIT to register the driver entry with the HDF.
```
2. Configure attribute files.
- Add the device node description to the **vendor/hisilicon/hispark_taurus/hdf_config/device_info/device_info.hcs** file.
The device attribute values are closely related to the driver implementation and the default values or restriction ranges of the **DacDevice** members at the core layer, for example, the number of device channels and the maximum transmission speed.
In the unified service mode, the first device node in the **device_info.hcs** file must be the DAC manager. The parameters must be set as follows:
| Member | Value |
| --------------- | ------------------------------------------------------------ |
| policy | **0**, which indicates that no service is published.|
| priority | Driver startup priority. The value range is 0 to 200. A larger value indicates a lower priority. If the priorities are the same, the device loading sequence is not ensured.|
| permission | Driver permission.|
| moduleName | The value is **HDF_PLATFORM_DAC_MANAGER**.|
| serviceName | The value is **HDF_PLATFORM_DAC_MANAGER**.|
| deviceMatchAttr | Reserved.|
Configure DAC controller information from the second node. This node specifies a type of DAC controllers rather than a specific DAC controller. In this example, there is only one DAC device. If there are multiple DAC devices, you need to add the **deviceNode** information to the **device_info** file and add the corresponding device attributes to the **dac_config** file.
**device_info.hcs** configuration reference
```
root {
device_dac :: device {
// device0 is the DAC manager.
device0 :: deviceNode {
policy = 0;
priority = 52;
permission = 0644;
serviceName = "HDF_PLATFORM_DAC_MANAGER";
moduleName = "HDF_PLATFORM_DAC_MANAGER";
}
}
// dac_virtual is the DAC controller.
dac_virtual :: deviceNode {
policy = 0;
priority = 56;
permission = 0644;
moduleName = "virtual_dac_driver"; // (Mandatory) Driver name, which must be the same as moduleName in the driver entry.
serviceName = "VIRTUAL_DAC_DRIVER"; // (Mandatory) Unique name of the service published by the driver.
deviceMatchAttr = "virtual_dac"; // (Mandatory) Controller private data, which must be same as that of the corresponding controller in dac_config.hcs.
}
}
```
- Configure the **dac_test_config.hcs** file.
Add a file, for example, **vendor/vendor_hisilicon/hispark_taurus/hdf_config/hdf_test/dac_test_config.hcs** and configure driver parameters.
```
root {
platform {
dac_config {
match_attr = "virtual_dac"; // (Mandatory) The value must be the same as that of deviceMatchAttr in device_info.hcs.
template dac_device {
deviceNum = 0; // Device number.
validChannel = 0x1; // Valid channel 1.
rate = 20000; // Transmission speed.
}
device_0 :: dac_device {
deviceNum = 0; // Device number.
validChannel = 0x2; // Valid channel 2.
}
}
}
}
```
3. Instantiate the APIs of the core layer.
- Initialize the **DacDevice** object.
Initialize the **DacDevice** member in the **VirtualDacParseAndInit** function.
```
// Custom structure of the virtual driver
struct VirtualDacDevice {
// DAC device structure
struct DacDevice device;
// DAC device number
uint32_t deviceNum;
// Valid channel
uint32_t validChannel;
// DAC rate
uint32_t rate;
};
// Parse and initialize the **DacDevice** object of the core layer.
static int32_t VirtualDacParseAndInit(struct HdfDeviceObject *device, const struct DeviceResourceNode *node)
{
// Define the return values.
int32_t ret;
// Virtual pointer to the DAC device
struct VirtualDacDevice *virtual = NULL;
(void)device;
// Allocate space for the virtual pointer.
virtual = (struct VirtualDacDevice *)OsalMemCalloc(sizeof(*virtual));
if (virtual == NULL) {
// If the value is null, return an error code.
HDF_LOGE("%s: Malloc virtual fail!", __func__);
return HDF_ERR_MALLOC_FAIL;
}
// Read the configuration of the attribute file.
ret = VirtualDacReadDrs(virtual, node);
if (ret != HDF_SUCCESS) {
// Failed to read the file.
HDF_LOGE("%s: Read drs fail! ret:%d", __func__, ret);
// Release the virtual space.
OsalMemFree(virtual);
// Set the pointer to 0.
virtual = NULL;
return ret;
}
// Initialize the virtual pointer.
VirtualDacDeviceInit(virtual);
// Initialize the priv object in DacDevice.
virtual->device.priv = (void *)node;
// Initialize the devNum object in DacDevice.
virtual->device.devNum = virtual->deviceNum;
// Initialize the ops object in DacDevice.
virtual->device.ops = &g_method;
// Add a DAC device.
ret = DacDeviceAdd(&virtual->device);
if (ret != HDF_SUCCESS) {
// Failed to add the device.
HDF_LOGE("%s: add Dac controller failed! ret = %d", __func__, ret);
// Release the virtual space.
OsalMemFree(virtual);
// Set the virtual pointer to null.
virtual = NULL;
return ret;
}
return HDF_SUCCESS;
}
```
- Custom structure reference
The custom structure holds parameters and data for the driver. Define the custom structure based on the function parameters of the device. The HDF reads the values in the **dac_config.hcs** file using the **DacTestReadConfig()** function and initializes the structure members using **DeviceResourceIface()**. Some important values, such as the device number and bus number, are also passed to the **DacDevice** object at the core layer.
```
struct VirtualDacDevice {
struct DacDevice device;// (Mandatory) Control object at the core layer. For details, see the description below.
uint32_t deviceNum; // (Mandatory) Device number.
uint32_t validChannel; // (Mandatory) Valid channel.
uint32_t rate; // (Mandatory) Sampling rate.
};
// DacDevice is the core layer controller structure. Its members are assigned with values in the Init() function.
struct DacDevice {
const struct DacMethod *ops;
OsalSpinlock spin; // Spinlock.
uint32_t devNum; // Device number.
uint32_t chanNum; // Device channel number.
const struct DacLockMethod *lockOps;
void *priv;
};
```
- Instantiate the **DacDevice** in **DacMethod**.
The **VirtualDacWrite**, **VirtualDacStop**, and **VirtualDacStart** functions are instantiated in **dac_virtual.c**.
```
static const struct DacMethod g_method = {
.write = VirtualDacWrite, // Write data to a DAC device.
.stop = VirtualDacStop, // Stop a DAC device.
.start = VirtualDacStart, // Start a DAC device.
};
```
![](../public_sys-resources/icon-note.gif) **NOTE**<br/>
For details about **DacMethod**, see [Available APIs](#section752964871810).
- **Init** function
Input parameters:
**HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information.
Return value:
HDF_STATUS (The table below lists some status. For details about other status, see HDF_STATUS in the /drivers/framework/include/utils/hdf_base.h file.)
| State | Description |
| ---------------------- | -------------- |
| HDF_ERR_INVALID_OBJECT | Invalid controller object.|
| HDF_ERR_INVALID_PARAM | Invalid parameter. |
| HDF_ERR_MALLOC_FAIL | Failed to allocate memory. |
| HDF_ERR_IO | I/O error. |
| HDF_SUCCESS | Transmission successful. |
| HDF_FAILURE | Transmission failed. |
Function description:
Initializes the custom structure object and **DacDevice**, and calls the **AdcDeviceAdd** function at the core layer.
```
static int32_t VirtualDacParseAndInit(struct HdfDeviceObject *device, const struct DeviceResourceNode *node)
{
// Define return value parameters.
int32_t ret;
// Pointer to the DAC device.
struct VirtualDacDevice *virtual = NULL;
(void)device;
// Allocate memory of the specified size.
virtual = (struct VirtualDacDevice *)OsalMemCalloc(sizeof(*virtual));
if (virtual == NULL) {
// Failed to allocate memory.
HDF_LOGE("%s: Malloc virtual fail!", __func__);
return HDF_ERR_MALLOC_FAIL;
}
// Read the node parameters in the .hcs file.
ret = VirtualDacReadDrs(virtual, node);
if (ret != HDF_SUCCESS) {
// Failed to read the node data.
HDF_LOGE("%s: Read drs fail! ret:%d", __func__, ret);
goto __ERR__;
}
// Initialize the DAC device pointer.
VirtualDacDeviceInit(virtual);
// Pass private node data.
virtual->device.priv = (void *)node;
// Pass the device number.
virtual->device.devNum = virtual->deviceNum;
// Pass the method.
virtual->device.ops = &g_method;
// Add a DAC device.
ret = DacDeviceAdd(&virtual->device);
if (ret != HDF_SUCCESS) {
// Failed to add the DAC device.
HDF_LOGE("%s: add Dac controller failed! ret = %d", __func__, ret);
goto __ERR__;
}
// The DAC device is added.
return HDF_SUCCESS;
__ERR__:
// If the pointer is null
if (virtual != NULL) {
// Release the memory.
OsalMemFree(virtual);
// Set the pointer to null.
virtual = NULL;
}
return ret;
}
static int32_t VirtualDacInit(struct HdfDeviceObject *device)
{
// Define return value parameters.
int32_t ret;
// Child node of the device structure
const struct DeviceResourceNode *childNode = NULL;
// Check the input parameter pointer.
if (device == NULL || device->property == NULL) {
// The input parameter pointer is null.
HDF_LOGE("%s: device or property is NULL", __func__);
return HDF_ERR_INVALID_OBJECT;
}
// The input parameter pointer is not null.
ret = HDF_SUCCESS;
DEV_RES_NODE_FOR_EACH_CHILD_NODE(device->property, childNode) {
// Parse the child node.
ret = VirtualDacParseAndInit(device, childNode);
if (ret != HDF_SUCCESS) {
// Failed to parse the child node.
break;
}
}
// The child node is parsed.
return ret;
}
```
- **Release** function
Input parameters:
**HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information.
Return value
Function description:
Releases memory and deletes the controller. This function assigns a value to the **Release** API in the driver entry structure. If the HDF fails to call the **Init** function to initialize the driver, the **Release** function can be called to release driver resources. All forced conversion operations for obtaining the corresponding object can be successful only when the **Init** function has the corresponding value assignment operations.
```
static void VirtualDacRemoveByNode(const struct DeviceResourceNode *node)
{
// Define return value parameters.
int32_t ret;
// Define the DAC device number.
int16_t devNum;
// Pointer of the DacDevice structure.
struct DacDevice *device = NULL;
// Pointer of the VirtualDacDevice structure.
struct VirtualDacDevice *virtual = NULL;
// Pointer of the DeviceResourceIface structure.
struct DeviceResourceIface *drsOps = NULL;
// Obtain device resources through the instance entry.
drsOps = DeviceResourceGetIfaceInstance(HDF_CONFIG_SOURCE);
// Check the input parameter pointer.
if (drsOps == NULL || drsOps->GetUint32 == NULL) {
// The pointer is null.
HDF_LOGE("%s: invalid drs ops fail!", __func__);
return;
}
// Obtain data of the devNum node.
ret = drsOps->GetUint16(node, "devNum", (uint16_t *)&devNum, 0);
if (ret != HDF_SUCCESS) {
// Failed to obtain node data.
HDF_LOGE("%s: read devNum fail!", __func__);
return;
}
// Obtain the DAC device number.
device = DacDeviceGet(devNum);
// Check whether the DAC device number and data are null.
if (device != NULL && device->priv == node) {
// Release the DAC device number if the device data is null.
DacDevicePut(device);
// Remove the DAC device number.
DacDeviceRemove(device);
virtual = (struct VirtualDacDevice *)device;
// Release the virtual pointer.
OsalMemFree(virtual);
}
return;
}
static void VirtualDacRelease(struct HdfDeviceObject *device)
{
// Define the child node structure pointer of the DeviceResourceNode.
const struct DeviceResourceNode *childNode = NULL;
// Check whether the input parameter pointer is null.
if (device == NULL || device->property == NULL) {
// The input parameter pointer is null.
HDF_LOGE("%s: device or property is NULL", __func__);
return;
}
DEV_RES_NODE_FOR_EACH_CHILD_NODE(device->property, childNode) {
// Remove the DAC through the node.
VirtualDacRemoveByNode(childNode);
}
}
```
4. Debug the driver.
(Optional) Verify the basic functions of the new driver, for example, whether the test cases are successful after the driver is loaded.
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
- **[ADC](driver-platform-adc-des.md)** - **[ADC](driver-platform-adc-des.md)**
- **[DAC](driver-platform-dac-des.md)**
- **[GPIO](driver-platform-gpio-des.md)** - **[GPIO](driver-platform-gpio-des.md)**
- **[HDMI](driver-platform-hdmi-des.md)** - **[HDMI](driver-platform-hdmi-des.md)**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册