diff --git a/en/device-dev/bundles/Readme-EN.md b/en/device-dev/bundles/Readme-EN.md
index 2ae8dc847c778c4cef4a191f56f5d3e107a2d1c7..b95e0adea8e0b365a0c1a7736a77c8a8a1643ac2 100644
--- a/en/device-dev/bundles/Readme-EN.md
+++ b/en/device-dev/bundles/Readme-EN.md
@@ -1,20 +1,11 @@
-# Bundle Development
-
-- [Development Specifications](development-specifications.md)
- - [Overview](overview.md)
- - [Bundle Composition](bundle-composition.md)
- - [Bundle Management](bundle-management.md)
- - [Bundle Version](bundle-version.md)
- - [Distribution](distribution.md)
- - [Environment Variables](environment-variables.md)
-
-- [Development Guidelines](development-guidelines.md)
- - [Overview](overview-0.md)
- - [Preparations](preparations.md)
- - [Bundle Development](bundle-development.md)
-
-- [HPM User Guide](hpm-user-guide.md)
- - [Introduction](introduction.md)
- - [Preparations](preparations-1.md)
- - [Development Example](development-example.md)
-
+# Bundle Development
+
+- [Development Specifications](bundles-standard-rules.md)
+- [Development Guidelines](bundles-guide.md)
+ - [Bundle Development](bundles-guide-overview.md)
+ - [Preparations](bundles-guide-prepare.md)
+ - [Bundle Development](bundles-guide-develop.md)
+- [HPM User Guide](bundles-demo.md)
+ - [Introduction](bundles-demo-hpmdescription.md)
+ - [Preparations](bundles-demo-environment.md)
+ - [Development Example](bundles-demo-devsample.md)
\ No newline at end of file
diff --git a/en/device-dev/bundles/bundle-composition.md b/en/device-dev/bundles/bundle-composition.md
deleted file mode 100644
index 754f38a7c428547cacc97f55d0042e6eae62bb75..0000000000000000000000000000000000000000
--- a/en/device-dev/bundles/bundle-composition.md
+++ /dev/null
@@ -1,99 +0,0 @@
-# Bundle Composition
-
-- [Code files](#section101483489110)
-- [README File](#section10519101221211)
-- [Metadata Description File](#section45511827111211)
-
-A bundle contains the following contents:
-
-- **src** directory for storing code files or code library
-- **ohos\_bundles** folder for storing dependent bundles \(It is automatically generated during bundle installation, without the need to submit to the code library.\)
-- **README.md** file for describing the bundle
-- **bundle.json** file for declaring metadata of the bundle
-- **LICENSE** file for open-source code
-
- ```
- my-bundle
- |_ohos_bundles
- |_src
- |_bundle.json
- |_README.md
- |_LICENSE
- ```
-
-
-## Code files
-
-Bundle code files are the same as those in a common code directory. The only difference lies in the open APIs \(declared in header files\) of a bundle, which are likely to be referenced by other bundles and need to be declared in the **dirs** of **bundle.json**.
-
-## README File
-
-**README.md** is a bundle self-description file using the markdown syntax. For details, see [Syntax Reference](https://www.markdownguide.org/getting-started/).
-
-To help you easily find and use the desired bundle on the HarmonyOS Package Manager \(HPM\) platform, a **README** file is provided in the root directory of each bundle.
-
-The **README** file may include instructions on how to install, configure, and use the instance code in the bundle, as well as any other information helpful to you.
-
-The **README** file is available in the bundle details page of the HPM platform.
-
-## Metadata Description File
-
-A **bundle.json** file describes the metadata of a bundle. Each bundle has its own **bundle.json** file.
-
-```
-{
- "name": "@myorg/demo-bundle",
- "version": "1.0.0",
- "license": "MIT",
- "description": "bundle description",
- "keywords": ["hos"],
- "tags": ["applications", "drivers"],
- "author": {"name":"","email":"","url":""},
- "contributors":[{"name":"","email":"","url":""},{"name":"","email":"","url":""}],
- "homepage": "http://www.foo.bar.com",
- "repository": "https://git@gitee.com:foo/bar.git",
- "publishAs": "source",
- "dirs": {
- "src": ["src/**/*.c"],
- "headers": ["headers/**/*.h"],
- "bin": ["bin/**/*.o"]
- },
- "scripts": {
- "build": "make"
- },
- "envs": {},
- "ohos": {
- "os": "2.0.0",
- "board": "hi3516",
- "kernel": "liteos-a"
- },
- "rom": "10240",
- "ram": "1024",
- "dependencies": {
- "@myorg/net":"1.0.0"
- }
-}
-```
-
-Each **bundle.json** file has the following fields:
-
-- **name**: a bundle name, which starts with @ and is separated by /, for example, **@myorg/mybundle**
-
-- **version**: a bundle version number, for example, 1.0.0. The version number must comply with the Semantic Versioning Specification \(SemVer\) standards.
-
-- **description**: a brief description of a bundle
-- **dependencies**: bundles that a bundle depends on
-
-- **envs**: parameters required for bundle compilation, including global parameters and dependency parameters.
-
-- **scripts**: commands executable to a bundle, such as those for compiling, building, testing, and burning
-
-- **publishAs**: bundle publishing type, which can be **source**, **binary**, **distribution**, or **code-segment**
-
-- **dirs**: directory structure \(such as the header file\) generated for publishing
-
-- **ram&rom**: statistical information about the estimated read-only memory \(ROM\) and random access memory \(RAM\) usage
-- **ohos**: mappings among OpenHarmony versions, development boards, and kernels, separated by commas \(,\).
-- Extended information: author, home page, code repository, license, tags, and keywords
-- **base** \(only for a distribution\): a base distribution which others inherit from.
-
diff --git a/en/device-dev/bundles/bundle-development.md b/en/device-dev/bundles/bundle-development.md
deleted file mode 100644
index 09330f69915d1cc850b0125a3e198e4f1c8c163f..0000000000000000000000000000000000000000
--- a/en/device-dev/bundles/bundle-development.md
+++ /dev/null
@@ -1,241 +0,0 @@
-# Bundle Development
-
-- [Developing a OpenHarmony Bundle](#section1976410130540)
-- [Creating a Bundle](#section717481119145)
-- [Modifying a Bundle](#section102861955201410)
-- [Using HPM-provided Template to Create a Bundle](#section15882846181510)
-- [Building a Bundle](#section136732148541)
-- [Defining the Building Script](#section10274147111610)
-- [Executing the Building Script](#section879301916172)
-- [Defining a Distribution](#section413216495619)
-- [Defining Scripts](#section11503171219190)
-- [Distributing](#section4694125521912)
-- [Burning](#section1746331545413)
-- [Debugging](#section6742131615549)
-
-## Developing a OpenHarmony Bundle
-
-You have an option to use any of the following methods to develop an OpenHarmony bundle:
-
-- Develop a brand new bundle from scratch.
-- Rewrite code of an existing non-bundle to develop a bundle.
-
-- Use HPM-provided bundle templates to quickly develop a bundle.
-
-## Creating a Bundle
-
-Generally, you can find commonly used bundles on the [HPM](https://hpm.harmonyos.com/#/en/home) website. If they cannot meet your requirements, you can develop your own bundles.
-
-You can publish bundles in the HPM repository if you like, so that your peers have an option to use them. Assume that you want to create a bundle named **my-bundle** in the **D:/source** directory:
-
-Run the **hpm init** command to create the scaffold code for this bundle. For example, you can go to the **D:/source** directory and run the following command:
-
-```
-hpm init -t default -d demo my-bundle
-```
-
-The following files are generated in the **source** directory:
-
-```
-mybundle
-├── bundle.json # Metadata description file of the bundle
-├── example # Example of testing bundle functions
-│ └── main.c
-├── include # Internal header files of the bundle
-│ └── mybundle.h
-├── README.md # Brief description of the bundle
-└── src # Source code of the bundle
- └─ mybundle.c
-```
-
-Then, complete your coding based on service requirements. Finally, use **git** to commit your code \(including the **bundle.json** file\) to the code hosting repository, such as gitee.
-
-## Modifying a Bundle
-
-If you have code unqualified for the OpenHarmony bundle structure, modify your code to match an HPM bundle. In the code directory \(for example, **mybundle2**\) storing your code, run the following command with the bundle name and version specified:
-
-```
-hpm init
-```
-
-1. Enter a bundle name \(**mybundle2** as an example\) and press **Enter**.
-2. Enter the bundle version \(**1.0.0** as an example\) and press **Enter**. A **bundle.json** file is generated in the current bundle directory.
-3. Add other descriptions in **bundle.json**, which is publishable.
-
- ```
- $ hpm init
- Your bundle will be created in dirname E:\demo\mybundle2
- ? bundle name mybundel2
- ? version 1.0.0
- Init finished!
- ```
-
-
-1. Modify other information \(such as the author, code repository, code directory, command script, and dependent bundles\) in **bundle.json**.
-
- ```
- {
- "name": "mybundle2",
- "version": "1.0.0",
- "publishAs": "source",
- "dirs":{
- ".":[
- "README.md"
- ],
- "src":[
- "test.c"
- ],
- "header":[
- "header/test.h"
- ],
- "src/common":[
- "src/common/foobar.txt"
- ]
- },
- "scripts": {
- "build": "make -${args}"
- },
- "dependencies": {
- "@ohos/cjson": "^1.0.0",
- "@ohos/": "^1.2.0"
- }
- }
- ```
-
-
-## Using HPM-provided Template to Create a Bundle
-
-The HPM provides **default** and **simple** templates as well as other templates that are stored on the server.
-
-You can run the **hpm search -t template** command to search for a template stored on the server.
-
-
-
-Then, select your desired template based on the information below **description**, use the selected template to quickly create the bundle scaffold, and run the following command with the **-t** and **-d** parameters specified:
-
-```
-hpm init -t {templatename} -d dir name
-```
-
-- **\{templatename\}** indicates the template name.
-- **dir** indicates the path for storing the bundle to be created.
-- **name** indicates the name of the bundle to be created.
-
-## Building a Bundle
-
-After completing code development, you need to build the bundle. The HPM supports command integration so that you can select any build tool \(such as **make**, **gcc**, and **gn**\) suitable for your project. You only need to define the **build** command in the **scripts** in the **bundle.json** file of your project, and then you run the hpm command **build** to perform building.
-
-## Defining the Building Script
-
-This section uses how to build an executable file **helloworld** in the **app** directory as an example.
-
-```
-app
-├── BUILD.gn
-├── include
-│ └── helloworld.h
-└── src
- └── helloworld.c
-```
-
-Create a **BUILD.gn** file in the same directory as **helloworld.c**.
-
-```
-touch BUILD.gn
-vim BUILD.gn
-```
-
-The following is an example of **BUILD.gn** for your reference:
-
-```
-executable("hello_world") {
- sources = [
- "src/helloworld.c"
- ]
-
- include_dirs = [
- "include"
- ]
-}
-```
-
-> **NOTE:**
->- **executable** is a built-in template of **gn**. You can run the **gn help executable** command to view how to use this template.
->- **sources** represents the source code path, and **include\_dirs** represents the header file path.
-
-## Executing the Building Script
-
-Run the following command:
-
-```
-hpm build
-```
-
-After all building operations are complete, the message "build succeed" is displayed. You need to check the building result.
-
-
-
-## Defining a Distribution
-
-A distribution refers to an image file of an executable OpenHarmony solution composed of a group of bundles. It contains many dependent bundles and provides scripts to illustrate how to compile and link these bundles.
-
-## Defining Scripts
-
-Define scripts in **bundle.json** as follows:
-
-```
-{
-"name": "my_dist",
-"version": "1.0.0",
-"publishAs": "distribution",
-"scripts": {
-"dist": "make -${args}"
- },
-"base": {
-"name": "dist-bundle",
-"version": "1.0.0"
- },
-"envs": {
-"args": "x86"
- },
-"dependencies": {
-}
-}
-```
-
-## Distributing
-
-Run the following command in the current distribution directory:
-
-```
-hpm dist
-```
-
-The **hpm-cli** tool automatically performs compiling and packing, and generates an image file of the **dist** script defined based on **scripts**. The following is an example:
-
-```
-out
-|-xxdist.img
-|-xx.file
-```
-
-## Burning
-
-The building result of the distribution can be burnt into devices, for example, by using the **hiburn** tool. You need to configure burning parameters in the **bundle.json** file of the distribution.
-
-```
-"scripts": {
-"flash": "{$DEP_HIBURN}/hiburn"
-},
-```
-
-You should set burning parameters by referring to the specific guide on the burning tool you use.
-
-```
-hpm run flash
-```
-
-## Debugging
-
-Start debugging after you have burnt the image file of the distribution into devices. The debugging process varies according to specific development boards and IDE debugging tools.
-
diff --git a/en/device-dev/bundles/bundle-management.md b/en/device-dev/bundles/bundle-management.md
deleted file mode 100644
index 4511f3427ca7e4ba140bc844e3c4450fd545daf8..0000000000000000000000000000000000000000
--- a/en/device-dev/bundles/bundle-management.md
+++ /dev/null
@@ -1,232 +0,0 @@
-# Bundle Management
-
-- [Dependency](#section12657593129)
-- [HPM Command Reference](#section1258849181312)
-
-## Dependency
-
-A basic **bundle.json** file needs to be enriched by bundle dependencies to implement more complex features. Bundle names and version numbers should be defined in the **dependencies** field of **bundle.json**.
-
-```
-{
- "name": "my-bundle",
- "version": "1.0.0",
- "dependencies": {
- "net": "1.0.0"
- }
-}
-```
-
-In this example, **my-bundle** depends on **net 1.0.0**. After you globally install the hpm-cli tool, run the following command to obtain bundle dependencies from the remote repository:
-
-```
-hpm install
-```
-
-Bundle dependencies are then stored in the **ohos\_bundles** folder in the root directory of the current bundle. A tree structure illustrating the bundle and its dependencies will be generated. You need to run the following command in the root directory of the bundle:
-
-```
-username@server MINGW64 /f/showcase/demo/demo
-$ hpm list
-+--demo@1.0.0
-| +--@huawei/media@1.0.2
-| +--@demo/sport_hi3518ev300_liteos_a@1.0.0
-| | +--@demo/app@4.0.1
-| | | +--@demo/build@4.0.1
-| | | +--@demo/arm_harmonyeabi_gcc@4.0.0
-| | +--@demo/liteos_a@4.0.0
-| | | +--@demo/third_party_fatfs@4.0.0
-| | | +--@demo/arm_harmonyeabi_gcc@4.0.0
-| | +--@demo/init@4.0.0
-| | +--@demo/dist_tools@4.0.0
-```
-
-Alternatively, you can view the dependencies of the current bundle in a graph by running the following command:
-
-```
-hpm dependencies
-```
-
-A **deps\_visual** folder is generated in the current directory. The folder contains the **deps.html** and **deps-data.js** files. After you open the **deps.html** file via a browser, you can view bundle dependencies illustrated by a graph, as shown in the following figure.
-
-Each dependency type is indicated by a different color at the corresponding node. You can move the mouse pointer to a node to view the implied information.
-
-**Figure 1** Bundle dependencies
-
-
-## HPM Command Reference
-
-You can use the hpm-cli tool to manage the lifecycle of a bundle. The following table describes available HPM commands. \(You can run the **hpm -h** command to get the command details\).
-
-**Table 1** HPM commands
-
-
-
Function
-
-
Command
-
-
Description
-
-
-
-
Querying version information
-
-
hpm -V or hpm --version
-
-
Queries the hpm-cli version number.
-
-
-
Querying help information
-
-
hpm -h or hpm --version
-
-
Queries the command list and help information.
-
-
-
hpm -h
-
-
Queries command reference.
-
-
-
Creating a project
-
-
-
hpm init bundle
-
-
Creates a bundle project.
-
-
-
hpm init -t template
-
-
Creates a scaffolding project based on the template.
-
-
-
Installing bundles
-
-
-
hpm install or hpm i
-
-
Installs dependent bundles in the bundle.json file.
-
-
-
hpm install bundle@version
-
-
Installs bundles of a specified version.
-
-
-
Uninstalling bundles
-
-
-
hpm uninstall bundle
-
-
Removes dependent bundles.
-
-
-
hpm remove or hpm rm bundlename
-
-
Removes dependent bundles.
-
-
-
Viewing information
-
-
-
hpm list or hpm ls
-
-
Displays the bundle tree of available bundles and distributions.
-
-
-
hpm dependencies
-
-
Generates the dependency diagram (in HTML format) of available bundles and distributions.
-
-
-
Searching for bundles
-
-
hpm search name
-
-
Searches for bundles. --json is used to specify the search result in JSON format, and -type is used to set the target type, which can be bundle, distribution, or code-segment.
-
-
-
Setting HPM configuration items
-
-
hpm config set key value
-
-
Sets configuration items, such as the server address and network proxy.
-
-
-
hpm config delete key
-
-
Deletes configurations.
-
-
-
Updating bundle versions
-
-
-
hpm update
-
-
Updates the versions of dependent bundles.
-
-
-
hpm check-update
-
-
Checks whether version updates are available to dependent bundles.
-
-
-
Building
-
-
-
hpm build
-
-
Builds a bundle or distribution.
-
-
-
hpm dist
-
-
Packs a distribution, depending on the dist script in scripts of bundle.json.
-
-
-
Packing
-
-
hpm pack
-
-
Packs dependencies of local bundles.
-
-
-
Burning
-
-
hpm run flash
-
-
Burns the firmware, depending on the flash script in scripts of bundle.json.
-
-
-
Publishing
-
-
hpm publish
-
-
Publishes a bundle, which must be unique in the repository and has a unique version. (An account is required for login.)
-
-
-
Running extended commands
-
-
hpm run
-
-
Runs the commands in scripts defined in bundle.json. Multiple commands can be executed in batches by using &&.
-
-
-
Generating a key
-
-
hpm gen-keys
-
-
Generates a public-private key pair and configures the public key on the HPM server, achieving password-free hpm-cli login for bundle publishing.
-
-
-
Generating third-party open source notice
-
-
hpm gen-notice
-
-
Generates a joint file describing the notice on third-party open source based on the description of each bundle.
-
-
-
-
-
diff --git a/en/device-dev/bundles/bundle-version.md b/en/device-dev/bundles/bundle-version.md
deleted file mode 100644
index d07118d86a36d626e1ba8a04112560d4fb25d4ad..0000000000000000000000000000000000000000
--- a/en/device-dev/bundles/bundle-version.md
+++ /dev/null
@@ -1,23 +0,0 @@
-# Bundle Version
-
-- [Version Number Naming Specifications](#section16893854141310)
-- [Version Publishing](#section43401320171420)
-
-## Version Number Naming Specifications
-
-Each version name allows only lowercase letters, which can be separated by hyphens \(-\) or underscores \(\_\). For example, **bundle** and **my\_bundle** are allowed.
-
-A bundle version number is in the format of _major version number_._minor version number_._revision version number_ or _major version number_._minor version number_._revision version number_-_pre-release version number_, for example, **1.0.0** and **1.0.0-beta**. For details, see [https://semver.org](https://semver.org/).
-
-## Version Publishing
-
-You should upload bundles to the remote repository so that your peers have an option to use them. You can run the following command to upload the bundles:
-
-```
-hpm publish
-```
-
-After this command is executed, the system checks the bundle dependencies and downloads the missing dependencies. If the bundles you uploaded are in binary, the system compiles the entire bundle, generates a binary file, packs the file, and uploads it. If the bundles you uploaded are in another format, the system packs the bundle file in compliance with the defined packing rules and then uploads the file.
-
-Note: To publish a bundle, you need an HPM account for login. After logging in to the HPM platform, register with an organization and apply for authentication. After successful authentication, you will have the permission to publish the bundle.
-
diff --git a/en/device-dev/bundles/bundles-demo-devsample.md b/en/device-dev/bundles/bundles-demo-devsample.md
new file mode 100644
index 0000000000000000000000000000000000000000..4b896d4811456deb410fab4abbab7baac6e2493c
--- /dev/null
+++ b/en/device-dev/bundles/bundles-demo-devsample.md
@@ -0,0 +1,54 @@
+# Development Example
+
+This following uses the Hi3861 platform as an example to describe how to install, compile, and package components by using HPM.
+
+1. Run the following commands to initialize the installation directory \(whose name can be customized\):
+
+ ```
+ mkdir test3861
+ cd test3861
+ hpm init -t dist
+ ```
+
+ If the following information is displayed, the initialization is successful:
+
+ ```
+ Initialization finished.
+ ```
+
+2. Run the following command to install the **wifi\_iot** distribution:
+
+ ```
+ hpm install @ohos/wifi_iot
+ ```
+
+ If the following information is displayed, the installation is successful:
+
+ ```
+ Installed.
+ ```
+
+ > **NOTE:**
+ >Run the following command for the Hi3516 platform:
+ >```
+ >hpm install @ohos/ip_camera_hi3516dv300
+ >```
+ >Run the following command for the Hi3518 platform:
+ >```
+ >hpm install @ohos/ip_camera_hi3518ev300
+ >```
+
+3. Run the following command to build and package components:
+
+ ```
+ hpm dist
+ ```
+
+ If the building is successful, the following information is displayed:
+
+ ```
+ {{name}}: distribution building completed.
+ ```
+
+4. Check the result in the **./out** directory. You can burn the distribution into the corresponding development board for testing.
+
diff --git a/en/device-dev/bundles/bundles-demo-environment.md b/en/device-dev/bundles/bundles-demo-environment.md
new file mode 100644
index 0000000000000000000000000000000000000000..6780aa705ee1b918dd9f6d748c286b0deae34476
--- /dev/null
+++ b/en/device-dev/bundles/bundles-demo-environment.md
@@ -0,0 +1,139 @@
+# Preparations
+
+- [Linux Server](#section20979554791)
+- [Node.js](#section9954105413153)
+- [HPM](#section15937194904819)
+- [Python Environment](#section1621819180417)
+- [File Packaging Tool](#section77617165913)
+- [SCons](#section20558439191516)
+
+## Linux Server
+
+Prepare a 64-bit Linux server running Ubuntu 16.04 or later. HPM supports Windows Server, but the open-source Hi3861, Hi3516, and Hi3518 solutions support only Ubuntu.
+
+Configure Ubuntu to use bash as the Linux system shell, by performing the following:
+
+```
+ls -l $(which sh)
+# If the file does not point to bash, modify the file using either of the provided methods.
+# Method 1: Run the following command and select no:
+dpkg-reconfigure dash
+# Method 2: Run the following commands to delete /bin/sh and then create a new symbolic link to bash:
+rm -f /bin/sh
+ln -s bash /bin/sh
+```
+
+## Node.js
+
+> **NOTE:**
+>If the Node.js version of the source is outdated, run the following command before running **apt-get install**:
+>```
+>curl -L https://deb.nodesource.com/setup_12.x | bash
+>```
+
+You are advised to install Node.js 12.x \(including npm 6.14.4\) or a later version \(12.13.0 or later is recommended\).
+
+```
+sudo apt-get install nodejs
+sudo apt-get install npm
+```
+
+Run the following commands to view Node.js and NPM versions:
+
+```
+node --version # Check the Node.js version.
+npm --version # Check the NPM version.
+```
+
+## HPM
+
+Install the **hpm-cli** command line tool by using the NPM \(default source: https://registry.npmjs.org/\) provided by the Node.js.
+
+```
+npm install -g @ohos/hpm-cli
+```
+
+After **hpm-cli** is installed, run the following command to view default HPM configurations:
+
+```
+hpm config
+```
+
+You can modify the default configurations as required. The following lists common HPM configurations:
+
+```
+registry = https://hpm.harmonyos.com # Register with the HPM registration center. This is mandatory for downloading components.
+strictSsl = true # Enable strict SSL verification as HTTPS is used for connection.
+http_proxy = http://your-proxy-server:port # Configure the HTTP proxy.
+https_proxy = http://your-proxy-server:port # Configure the HTTPS proxy.
+```
+
+For details about **hpm-cli** commands, see [HPM Commands](bundles-standard-rules.md).
+
+## Python Environment
+
+Run the following commands to install Python later than 3.7:
+
+```
+sudo apt-get install python3.8
+sudo apt-get install python3-pip
+sudo pip3 install setuptools
+sudo pip3 install kconfiglib # Install kconfiglib 13.2.0 or later.
+```
+
+> **NOTE:**
+>The preceding method is applicable to Hi3518 and Hi3516 platforms. For Hi3861, run the following commands to install the Python environment:
+>```
+>sudo apt-get install python3.8
+>sudo apt-get install python3-pip
+>sudo pip3 install setuptools
+>sudo pip3 install kconfiglib # Install kconfiglib 13.2.0 or later.
+>sudo pip3 install pycryptodome
+>sudo pip3 install six --upgrade --ignore-installed six
+>sudo pip3 install ecdsa
+>```
+
+If both Python2 and Python3 have been installed in the current system, run the following commands to set the default Python to Python3:
+
+```
+ll `which python`
+rm /usr/bin/python
+ln -s python3.8 /usr/bin/python
+```
+
+## File Packaging Tool
+
+Run the following commands to install the tool:
+
+```
+which mkfs.vfat # If mkfs.vfat is not found, run the following command:
+sudo apt-get install dosfstools
+which mcopy # If mcopy is not found, run the following command:
+sudo apt-get install mtools
+```
+
+> **NOTE:**
+>Both Hi3518 and Hi3516 platforms require the file packaging tool. For Hi3861, the tool is not required.
+
+## SCons
+
+1. Start a Linux server.
+2. Run the following command to install the SCons installation package:
+
+ ```
+ python3 -m pip install scons
+ ```
+
+3. Run the following command to check whether SCons is successfully installed. If the installation is successful, the query result as shown in [Figure 1](#fig235815252492) is displayed.
+
+ ```
+ scons -v
+ ```
+
+ **Figure 1** Successful installation \(SCons version requirement: 3.0.4 or later\)
+ -25.png "successful-installation-(scons-version-requirement-3-0-4-or-later)-25")
+
+
+> **NOTE:**
+>SCons is required for the Hi3861 platform, but not for the Hi3518 or Hi3516 platform.
+
diff --git a/en/device-dev/bundles/introduction.md b/en/device-dev/bundles/bundles-demo-hpmdescription.md
similarity index 100%
rename from en/device-dev/bundles/introduction.md
rename to en/device-dev/bundles/bundles-demo-hpmdescription.md
diff --git a/en/device-dev/bundles/bundles-demo.md b/en/device-dev/bundles/bundles-demo.md
new file mode 100644
index 0000000000000000000000000000000000000000..846d6b1bde058051ef3212edb3596a2d7ec22396
--- /dev/null
+++ b/en/device-dev/bundles/bundles-demo.md
@@ -0,0 +1,9 @@
+# HPM User Guide
+
+- **[Introduction](bundles-demo-hpmdescription.md)**
+
+- **[Preparations](bundles-demo-environment.md)**
+
+- **[Development Example](bundles-demo-devsample.md)**
+
+
diff --git a/en/device-dev/bundles/bundles-guide-develop.md b/en/device-dev/bundles/bundles-guide-develop.md
new file mode 100644
index 0000000000000000000000000000000000000000..d7f0fdad1f664ab9f46ffbee7f40e07ae024dffb
--- /dev/null
+++ b/en/device-dev/bundles/bundles-guide-develop.md
@@ -0,0 +1,240 @@
+# Bundle Development
+
+- [Developing OpenHarmony Bundles](#section1976410130540)
+- [Creating a Bundle](#section717481119145)
+- [Modifying a Bundle](#section102861955201410)
+- [Using HPM-provided Template to Create a Bundle](#section15882846181510)
+- [Building a Bundle](#section136732148541)
+- [Defining the Building Script](#section10274147111610)
+- [Executing the Building Script](#section879301916172)
+- [Defining a Distribution](#section413216495619)
+- [Defining Scripts](#section11503171219190)
+- [Distributing](#section4694125521912)
+- [Burning](#section1746331545413)
+- [Debugging](#section6742131615549)
+
+## Developing OpenHarmony Bundles
+
+You have an option to use any of the following methods to develop OpenHarmony bundles:
+
+- Develop a brand new bundle from scratch.
+- Rewrite code of an existing non-bundle to develop a bundle.
+- Use HPM-provided bundle templates to quickly develop a bundle.
+
+## Creating a Bundle
+
+Generally, you can find commonly used bundles on the [HPM](https://hpm.harmonyos.com/#/en/home) website. If they cannot meet your requirements, you can develop your own bundles.
+
+You can publish bundles in the HPM repository if you like, so that your peers have an option to use them. Assume that you want to create a bundle named **my-bundle** in the **D:/source** directory:
+
+Run the **hpm init** command to create the scaffold code for this bundle. For example, you can go to the **D:/source** directory and run the following command:
+
+```
+hpm init -t default -d demo my-bundle
+```
+
+The following files are generated in the **source** directory:
+
+```
+mybundle
+├── bundle.json # Metadata description file of the bundle
+├── example # Example of testing bundle functions
+│ └── main.c
+├── include # Internal header files of the bundle
+│ └── mybundle.h
+├── README.md # Brief description of the bundle
+└── src # Source code of the bundle
+ └─ mybundle.c
+```
+
+Then, complete your coding based on service requirements. Finally, use **git** to commit your code \(including the **bundle.json** file\) to the code hosting repository, such as gitee.
+
+## Modifying a Bundle
+
+If you have code unqualified for the OpenHarmony bundle structure, modify your code to match an HPM bundle. In the code directory \(for example, **mybundle2**\) storing your code, run the following command with the bundle name and version specified:
+
+```
+hpm init
+```
+
+1. Enter a bundle name \(**mybundle2** as an example\) and press **Enter**.
+2. Enter the bundle version \(**1.0.0** as an example\) and press **Enter**. A **bundle.json** file is generated in the current bundle directory.
+3. Add other descriptions in **bundle.json**, which is publishable.
+
+ ```
+ $ hpm init
+ Your bundle will be created in dirname E:\demo\mybundle2
+ ? bundle name mybundel2
+ ? version 1.0.0
+ Init finished!
+ ```
+
+
+1. Modify other information \(such as the author, code repository, code directory, command script, and dependent bundles\) in **bundle.json**.
+
+ ```
+ {
+ "name": "mybundle2",
+ "version": "1.0.0",
+ "publishAs": "source",
+ "dirs":{
+ ".":[
+ "README.md"
+ ],
+ "src":[
+ "test.c"
+ ],
+ "header":[
+ "header/test.h"
+ ],
+ "src/common":[
+ "src/common/foobar.txt"
+ ]
+ },
+ "scripts": {
+ "build": "make -${args}"
+ },
+ "dependencies": {
+ "@ohos/cjson": "^1.0.0",
+ "@ohos/": "^1.2.0"
+ }
+ }
+ ```
+
+
+## Using HPM-provided Template to Create a Bundle
+
+The HPM provides **default** and **simple** templates as well as other templates that are stored on the server.
+
+You can run the **hpm search -t template** command to search for a template stored on the server.
+
+
+
+Then, select your desired template based on the information below **description**, use the selected template to quickly create the bundle scaffold, and run the following command with the **-t** and **-d** parameters specified:
+
+```
+hpm init -t {templatename} -d dir name
+```
+
+- **\{templatename\}** indicates the template name.
+- **dir** indicates the path for storing the bundle to be created.
+- **name** indicates the name of the bundle to be created.
+
+## Building a Bundle
+
+After completing code development, you need to build the bundle. The HPM supports command integration so that you can select any build tool \(such as **make**, **gcc**, and **gn**\) suitable for your project. You only need to define the **build** command in the **scripts** in the **bundle.json** file of your project, and then you run the hpm command **build** to perform building.
+
+## Defining the Building Script
+
+This section uses how to build an executable file **helloworld** in the **app** directory as an example.
+
+```
+app
+├── BUILD.gn
+├── include
+│ └── helloworld.h
+└── src
+ └── helloworld.c
+```
+
+Create a **BUILD.gn** file in the same directory as **helloworld.c**.
+
+```
+touch BUILD.gn
+vim BUILD.gn
+```
+
+The following is an example of **BUILD.gn** for your reference:
+
+```
+executable("hello_world") {
+ sources = [
+ "src/helloworld.c"
+ ]
+
+ include_dirs = [
+ "include"
+ ]
+}
+```
+
+> **NOTE:**
+>- **executable** is a built-in template of **gn**. You can run the **gn help executable** command to view how to use this template.
+>- **sources** represents the source code path, and **include\_dirs** represents the header file path.
+
+## Executing the Building Script
+
+Run the following command:
+
+```
+hpm build
+```
+
+After all building operations are complete, the message "build succeed" is displayed. You need to check the building result.
+
+
+
+## Defining a Distribution
+
+A distribution refers to an image file of an executable OpenHarmony solution composed of a group of bundles. It contains many dependent bundles and provides scripts to illustrate how to compile and link these bundles.
+
+## Defining Scripts
+
+Define scripts in **bundle.json** as follows:
+
+```
+{
+"name": "my_dist",
+"version": "1.0.0",
+"publishAs": "distribution",
+"scripts": {
+"dist": "make -${args}"
+ },
+"base": {
+"name": "dist-bundle",
+"version": "1.0.0"
+ },
+"envs": {
+"args": "x86"
+ },
+"dependencies": {
+}
+}
+```
+
+## Distributing
+
+Run the following command in the current distribution directory:
+
+```
+hpm dist
+```
+
+The **hpm-cli** tool automatically performs compiling and packing, and generates an image file of the **dist** script defined based on **scripts**. The following is an example:
+
+```
+out
+|-xxdist.img
+|-xx.file
+```
+
+## Burning
+
+The building result of the distribution can be burnt into devices, for example, by using the **hiburn** tool. You need to configure burning parameters in the **bundle.json** file of the distribution.
+
+```
+"scripts": {
+"flash": "{$DEP_HIBURN}/hiburn"
+},
+```
+
+You should set burning parameters by referring to the specific guide on the burning tool you use.
+
+```
+hpm run flash
+```
+
+## Debugging
+
+Start debugging after you have burnt the image file of the distribution into devices. The debugging process varies according to specific development boards and IDE debugging tools.
+
diff --git a/en/device-dev/bundles/bundles-guide-overview.md b/en/device-dev/bundles/bundles-guide-overview.md
new file mode 100644
index 0000000000000000000000000000000000000000..a6d16e00da5e950294612bc72454fe531fa3bbdf
--- /dev/null
+++ b/en/device-dev/bundles/bundles-guide-overview.md
@@ -0,0 +1,146 @@
+# Bundle Development
+
+- [Overview](#section112136415486)
+- [Preparations](#section12731192104816)
+ - [Hardware Requirements](#section71851750144814)
+ - [Installing Node.js and the hpm-cli Tool](#section675199493)
+ - [\(Optional\) Modifying HPM Configurations](#section1940205015499)
+ - [Downloading OpenHarmony Code](#section42591118155217)
+ - [Installing Dependent Bundles](#section644212530524)
+
+- [Bundle Development](#section15640113715318)
+
+## Overview
+
+This document describes how to develop OpenHarmony bundles and distributions, and how to create, develop, and build code, as well as burn and debug devices by using a command line tool.
+
+- A bundle usually maps onto a code repository, which is a code archive with the **bundle.json**, **README**, and **LICENSE** files.
+- A distribution consists of multiple bundles. Each distribution integrates various bundles of a comprehensive system, such as the driver, kernel, framework, and applications. These bundles can be used for device burning.
+
+**Table 1** Differences between a bundle and a distribution
+
+
+
Aspect
+
+
Bundle
+
+
Distribution
+
+
+
+
Application scenario
+
+
Feature-oriented
+
+
System-oriented
+
+
+
Content
+
+
Codes or a binary library for implementing features
+
+
List of dependent bundles as well as their compiling and building scripts
+
+
+
Integrity
+
+
A part of the operating system
+
+
An entire operating system
+
+
+
Compilation result
+
+
Bundles
+
+
System image
+
+
+
+
+
+**Figure 1** Composition of bundles and distributions
+
+
+
+
+## Preparations
+
+### Hardware Requirements
+
+- Development boards \(examples: Hi3861, Hi3516D V300, and Hi3518E V300\)
+- Host computer \(Windows workstation\)
+- Linux server
+
+**Figure 2** Hardware connections
+
+
+### Installing **Node.js** and the **hpm-cli** Tool
+
+1. Install **Node.js**.
+
+ Download **Node.js** from its official website and install it on your local PC.
+
+ You are advised to install [Node.js](https://nodejs.org/) 12.x \(including npm 6.14.4\) or a later version \(12.13.0 or later is recommended\).
+
+2. Install the **hpm-cli** tool using **npm** delivered with **Node.js**. Run the following command:
+
+ ```
+ npm install -g @ohos/hpm-cli
+ ```
+
+3. Run the following command to check whether the installation is successful. If an HPM version is displayed, the installation is successful.
+
+ ```
+ hpm -V or hpm --version
+ ```
+
+4. \(Optional\) Run the following command to upgrade the HPM version if needed:
+
+ ```
+ npm update -g @ohos/hpm-cli
+ ```
+
+
+### \(Optional\) Modifying HPM Configurations
+
+After the **hpm-cli** tool is installed, run the following command to view HPM configurations:
+
+```
+hpm config
+```
+
+Default HPM configurations are displayed upon the command execution. You can modify the default configurations as required. The following lists common HPM configurations:
+
+```
+registry = https://hpm.harmonyos.com/hpm/registry/api # Configure the address of the HPM registry (mandatory for downloading bundles).
+login = https://hpm.harmonyos.com/hpm/auth/pk # Configure the address for HPM login (mandatory for publishing bundles).
+loginUser = {your-account} # Configure the account for HPM login (mandatory for publishing bundles).
+shellPath = C:\WINDOWS\System32\cmd.exe # Configure the shell for running HPM commands.
+globalRepo = C:\Users\yourname\.global # Configure the path for storing bundles that are installed globally.
+http_proxy = http://your-proxy-server:port # Configure the HTTP proxy.
+https_proxy = http://your-proxy-server:port # Configure the HTTPS proxy.
+```
+
+For details about **hpm-cli** commands, see [HPM Commands](bundles-guide-overview.md).
+
+### Downloading OpenHarmony Code
+
+For details, see [Source Code Acquisition](../get-code/sourcecode-acquire.md).
+
+### Installing Dependent Bundles
+
+The HPM publishes commonly used development tools \(such as those for burning, compiling, and compression\) as bundles. You can run the following command to install these tools. After the command is executed, the system automatically downloads and installs the tools, which need to be installed globally only once.
+
+```
+hpm i -g @ohos/llvm
+hpm i -g @ohos/ninja
+hpm i -g @ohos/gn
+hpm i -g @ohos/hc_gen
+hpm i -g @ohos/sysroot
+```
+
+These are a set of development tools \(such as **gn** and **ninja**\). With these tools, you can start your general bundle development based on source code.
+
+## Bundle Development
+
diff --git a/en/device-dev/bundles/bundles-guide-prepare.md b/en/device-dev/bundles/bundles-guide-prepare.md
new file mode 100644
index 0000000000000000000000000000000000000000..f706e2c2f8ebf2c8307e60a5595d53eb9799d1c1
--- /dev/null
+++ b/en/device-dev/bundles/bundles-guide-prepare.md
@@ -0,0 +1,84 @@
+# Preparations
+
+- [Hardware Requirements](#section98535485518)
+- [Installing Node.js and the hpm-cli Tool](#section106591616205311)
+- [\(Optional\) Modifying HPM Configurations](#section71821165412)
+- [Downloading OpenHarmony Code](#section102338221707)
+- [Installing Dependent Bundles](#section19233183315020)
+
+## Hardware Requirements
+
+- Development boards \(examples: Hi3861, Hi3516D V300, and Hi3518E V300\)
+- Host computer \(Windows workstation\)
+- Linux server
+
+**Figure 1** Hardware connections
+
+
+## Installing **Node.js** and the **hpm-cli** Tool
+
+1. Install **Node.js**.
+
+ Download **Node.js** from its official website and install it on your local PC.
+
+ You are advised to install [Node.js](https://nodejs.org/) 12.x \(including npm 6.14.4\) or a later version \(12.13.0 or later is recommended\).
+
+2. Install the **hpm-cli** tool using **npm** delivered with **Node.js**. Run the following command:
+
+ ```
+ npm install -g @ohos/hpm-cli
+ ```
+
+3. Run the following command to check whether the installation is successful. If an HPM version is displayed, the installation is successful.
+
+ ```
+ hpm -V or hpm --version
+ ```
+
+4. \(Optional\) Run the following command to upgrade the HPM version if needed:
+
+ ```
+ npm update -g @ohos/hpm-cli
+ ```
+
+
+## \(Optional\) Modifying HPM Configurations
+
+After the **hpm-cli** tool is installed, run the following command to view HPM configurations:
+
+```
+hpm config
+```
+
+Default HPM configurations are displayed upon the command execution. You can modify the default configurations as required. The following lists common HPM configurations:
+
+```
+registry = https://hpm.harmonyos.com/hpm/registry/api # Configure the address of the HPM registry, mandatory for downloading bundles.
+login = https://hpm.harmonyos.com/hpm/auth/pk # Configure the address for HPM login, mandatory for publishing bundles.
+loginUser = {your-account} # Configure the account for HPM login, mandatory for publishing bundles.
+shellPath = C:\WINDOWS\System32\cmd.exe # Configure the shell for running HPM commands.
+globalRepo = C:\Users\yourname\.global # Configure the path for storing bundles that are installed globally.
+http_proxy = http://your-proxy-server:port # Configure the HTTP proxy.
+https_proxy = http://your-proxy-server:port # Configure the HTTPS proxy.
+```
+
+For details about **hpm-cli** commands, see [HPM Commands](bundles-guide-overview.md).
+
+## Downloading OpenHarmony Code
+
+For details, see [Source Code Acquisition](../get-code/sourcecode-acquire.md).
+
+## Installing Dependent Bundles
+
+The HPM publishes commonly used development tools \(such as those for burning, compiling, and compression\) as bundles. You can run the following command to install these tools. After the command is executed, the system automatically downloads and installs the tools, which need to be installed globally only once.
+
+```
+hpm i -g @ohos/llvm
+hpm i -g @ohos/ninja
+hpm i -g @ohos/gn
+hpm i -g @ohos/hc_gen
+hpm i -g @ohos/sysroot
+```
+
+These are a set of development tools \(such as **gn** and **ninja**\). With these tools, you can start your general bundle development based on source code.
+
diff --git a/en/device-dev/bundles/bundles-guide.md b/en/device-dev/bundles/bundles-guide.md
new file mode 100644
index 0000000000000000000000000000000000000000..162b7be93ab12c2b1da404fd0fca89f6a3b6e4d4
--- /dev/null
+++ b/en/device-dev/bundles/bundles-guide.md
@@ -0,0 +1,9 @@
+# Development Guidelines
+
+- **[Bundle Development](bundles-guide-overview.md)**
+
+- **[Preparations](bundles-guide-prepare.md)**
+
+- **[Bundle Development](bundles-guide-develop.md)**
+
+
diff --git a/en/device-dev/bundles/bundles-standard-rules.md b/en/device-dev/bundles/bundles-standard-rules.md
new file mode 100644
index 0000000000000000000000000000000000000000..8adaac0e618ca9b141d52d7a4683a8ba3fa086ae
--- /dev/null
+++ b/en/device-dev/bundles/bundles-standard-rules.md
@@ -0,0 +1,549 @@
+# Development Specifications
+
+- [Overview](#section1725818533344)
+ - [Definition](#section4821219183514)
+ - [Bundle Division Principles](#section1089794263513)
+ - [Bundle Dependency](#section25701647163710)
+
+- [Bundle Composition](#section185538333914)
+ - [Code Files](#section8431268393)
+ - [README File](#section168121548173914)
+ - [Metadata Description File](#section7107181819406)
+
+- [Bundle Management](#section32061634104110)
+ - [Dependency](#section791115242423)
+ - [HPM Command Reference](#section1183205411429)
+
+- [Bundle Version](#section12612142864316)
+ - [Version Number Naming Specifications](#section1487612416432)
+ - [Version Publishing](#section1548171014440)
+
+- [Distribution](#section1264139114413)
+- [Environment Variables](#section15352105174512)
+
+## Overview
+
+This document describes the basic concepts of a bundle and how to define it in compliance with specifications.
+
+### Definition
+
+OpenHarmony software is developed on a per-bundle basis. In terms of the operating system, all software running on OpenHarmony are bundles. Generally, bundles are classified into the following types based on their application scopes:
+
+- Board-level bundles: device hardware-specific bundles, such as **board**, **arch**, and **mcu**
+- System-level bundles: a set of bundles with independent features, such as the kernel, file system, and framework
+- Application-level bundles: applications that provide services to users, such as **wifi\_iot** and **ip\_camera**
+
+Bundles are designed for reuse purposes. Any reusable modules can be defined as bundles. They are classified into the following types based on their forms:
+
+- Source code
+- Binary system
+- Code snippet
+- Distribution
+
+### Bundle Division Principles
+
+In principle, bundles should be grouped at a fine-grained granularity as much as possible to achieve maximum reuse. The following factors are taken into account regarding bundle division:
+
+- Independence: Bundles provide relatively independent features and can be independently built. Each bundle is capable of providing its own APIs and services for external systems.
+- Coupling: If a bundle must depend on another bundle to provide services, they can be coupled to one bundle.
+- Correlation: If a group of bundles jointly implement a feature, and if other bundles never depend on them, the group of bundles can be combined into one bundle.
+
+### Bundle Dependency
+
+A bundle dependency can be mandatory or optional.
+
+- Mandatory dependency: If bundle A must depend on bundle B to implement a feature \(the APIs or services specific to bundle B must be invoked\), bundle B is a mandatory dependency of bundle A.
+- Optional dependency: If bundle C or bundle D is required for bundle A to implement a feature and bundle C and bundle D are interchangeable, bundle C and bundle D are optional dependencies of bundle A.
+
+## Bundle Composition
+
+A bundle contains the following:
+
+- **src** directory for storing code files or code library
+- **ohos\_bundles** folder for storing dependent bundles \(It is automatically generated during bundle installation, without the need to submit to the code library.\)
+- **README.md** file for describing the bundle
+- **bundle.json** file for declaring metadata of the bundle
+- **LICENSE** file for open-source code
+
+ ```
+ my-bundle
+ |_ohos_bundles
+ |_src
+ |_bundle.json
+ |_README.md
+ |_LICENSE
+ ```
+
+
+### Code Files
+
+Bundle code files are the same as those in a common code directory. The only difference lies in the open APIs \(declared in header files\) of a bundle, which are likely to be referenced by other bundles and need to be declared in **dirs** of **bundle.json**.
+
+### README File
+
+**README.md** is a bundle self-description file using the markdown syntax. For details, see [Syntax Reference](https://www.markdownguide.org/getting-started/).
+
+To help you easily find and use the desired bundle on the HarmonyOS Package Manager \(HPM\) platform, a **README** file is provided in the root directory of each bundle.
+
+The **README** file may include instructions on how to install, configure, and use the instance code in the bundle, as well as any other information helpful to you.
+
+The **README** file is available in the bundle details page of the HPM platform.
+
+### Metadata Description File
+
+The **bundle.json** file describes the metadata of a bundle. Each bundle has its own **bundle.json** file.
+
+```
+{
+ "name": "@myorg/demo-bundle",
+ "version": "1.0.0",
+ "license": "MIT",
+ "description": "bundle description",
+ "keywords": ["hos"],
+ "tags": ["applications", "drivers"],
+ "author": {"name":"","email":"","url":""},
+ "contributors":[{"name":"","email":"","url":""},{"name":"","email":"","url":""}],
+ "homepage": "http://www.foo.bar.com",
+ "repository": "https://git@gitee.com:foo/bar.git",
+ "publishAs": "code-segment",
+ "segment":{
+ "destPath":"/the/dest/path"
+ },
+ "dirs": {
+ "src": ["src/**/*.c"],
+ "headers": ["headers/**/*.h"],
+ "bin": ["bin/**/*.o"]
+ },
+ "scripts": {
+ "build": "make"
+ },
+ "envs": {},
+ "ohos": {
+ "os": "2.0.0",
+ "board": "hi3516",
+ "kernel": "liteos-a"
+ },
+ "rom": "10240",
+ "ram": "1024",
+ "dependencies": {
+ "@myorg/net":"1.0.0"
+ }
+}
+```
+
+Each **bundle.json** file has the following fields:
+
+- **name**: a bundle name, which starts with @ and is separated by /, for example, **@myorg/mybundle**
+
+- **version**: a bundle version number, for example, 1.0.0. The version number must comply with the Semantic Versioning Specification \(SemVer\) standards.
+
+- **description**: a brief description of a bundle
+- **dependencies**: bundles that a bundle depends on
+
+- **envs**: parameters required for bundle compilation, including global parameters and dependency parameters.
+
+- **scripts**: commands executable to a bundle, such as commands for compiling, building, testing, and burning
+
+- **publishAs**: bundle publishing type, which can be **source**, **binary**, **distribution**, or **code-segment**
+
+- **segment**: destination path of the code-segment bundle. That is, the destination path of the files contained in the bundle package after the bundle is installed.
+- **dirs**: directory structure \(such as the header file\) generated for publishing
+
+- **ram&rom**: statistical information about the estimated read-only memory \(ROM\) and random access memory \(RAM\) usage
+- **ohos**: mappings among OpenHarmony versions, development boards, and kernels, separated by commas \(,\).
+- Extended information: author, home page, code repository, license, tags, and keywords
+- **base** \(only for a distribution\): a base distribution which others inherit from.
+
+## Bundle Management
+
+### Dependency
+
+A basic **bundle.json** file needs to be enriched by bundle dependencies to implement more complex features. Bundle names and version numbers should be defined in the **dependencies** field of **bundle.json**.
+
+```
+{
+ "name": "my-bundle",
+ "version": "1.0.0",
+ "dependencies": {
+ "net": "1.0.0"
+ }
+}
+```
+
+In this example, **my-bundle** depends on **net 1.0.0**. After you globally install the hpm-cli tool, run the following command to obtain bundle dependencies from the remote repository:
+
+```
+hpm install
+```
+
+Bundle dependencies are then stored in the **ohos\_bundles** folder in the root directory of the current bundle. A tree structure illustrating the bundle and its dependencies will be generated. You need to run the following command in the root directory of the bundle:
+
+```
+username@server MINGW64 /f/showcase/demo/demo
+$ hpm list
++--demo@1.0.0
+| +--@huawei/media@1.0.2
+| +--@demo/sport_hi3518ev300_liteos_a@1.0.0
+| | +--@demo/app@4.0.1
+| | | +--@demo/build@4.0.1
+| | | +--@demo/arm_harmonyeabi_gcc@4.0.0
+| | +--@demo/liteos_a@4.0.0
+| | | +--@demo/third_party_fatfs@4.0.0
+| | | +--@demo/arm_harmonyeabi_gcc@4.0.0
+| | +--@demo/init@4.0.0
+| | +--@demo/dist_tools@4.0.0
+```
+
+Alternatively, you can run the following command to view the dependencies of the current bundle in a visualized way:
+
+```
+hpm ui
+```
+
+A web service is started on the local host \(by default, the browser is open and the project page is displayed\). Click the project dependency icon on the sidebar. The list of dependent bundles is displayed. Click the button on the right to switch to the tree view. The bundle dependencies are displayed as shown in the following figure.
+
+**Figure 1** Bundle dependencies
+
+
+
+
+### HPM Command Reference
+
+You can use the hpm-cli tool to manage the lifecycle of a bundle. The following table describes available HPM commands. \(You can run the **hpm -h** command to get the command details\).
+
+**Table 1** HPM commands
+
+
+
Function
+
+
Command Line
+
+
Description
+
+
+
+
Querying version information
+
+
hpm -V or hpm --version
+
+
Displays the hpm-cli version number.
+
+
+
Querying help information
+
+
hpm -h or hpm --version
+
+
Displays the command list and help information.
+
+
+
hpm -h
+
+
Displays command help information.
+
+
+
Creating a project
+
+
+
hpm init bundle
+
+
Creates a bundle project.
+
+
+
hpm init -t template
+
+
Creates a scaffolding project from a template.
+
+
+
Installing bundles
+
+
+
hpm install or hpm i
+
+
Installs dependent bundles in the bundle.json file.
+
+
+
hpm install bundle@version
+
+
Installs bundles of a specified version.
+
+
+
Uninstalling bundles
+
+
+
hpm uninstall bundle
+
+
Uninstalls dependent bundles.
+
+
+
hpm remove or hpm rm bundlename
+
+
Removes dependent bundles.
+
+
+
Viewing information
+
+
+
hpm list or hpm ls
+
+
Displays the bundle tree of available bundles and distributions.
+
+
+
hpm dependencies
+
+
Generates the dependency relationship data of a bundle or distribution. (This command is also integrated in the HPM UI to display the bundle dependencies intuitively.)
+
+
+
Searching for bundles
+
+
hpm search name
+
+
Searches for bundles. --json is used to specify the search result in JSON format, and -type is used to set the target type, which can be bundle, distribution, or code-segment.
+
+
+
Setting HPM configuration items
+
+
hpm config set key value
+
+
Sets configuration items, such as the server address and network proxy.
+
+
+
hpm config delete key
+
+
Deletes configurations.
+
+
+
Updating bundle versions
+
+
+
hpm update
+
+
Updates the versions of dependent bundles.
+
+
+
hpm check-update
+
+
Checks whether version updates are available to dependent bundles.
+
+
+
Building
+
+
+
hpm build
+
+
Builds a bundle or distribution.
+
+
+
hpm dist
+
+
Builds a distribution. The build depends on the dist script in scripts of bundle.json.
+
+
+
Packing
+
+
hpm pack
+
+
Packs dependencies of local bundles.
+
+
+
Burning
+
+
hpm run flash
+
+
Burns the firmware. The firmware burning depends on the flash script in scripts of bundle.json.
+
+
+
Publishing
+
+
hpm publish
+
+
Publishes a bundle, which must be unique in the repository and has a unique version. (An account is required for login.)
+
+
+
Running extended commands
+
+
hpm run
+
+
Runs the commands in scripts defined in bundle.json. Multiple commands can be executed at a time by using &&.
+
+
+
Decompressing
+
+
hpm extract
+
+
Decompresses files in zip, tar, tgz, or .tar.gz format.
+
+
+
Restarting GUI
+
+
hpm ui
+
+
Starts the HPM UI locally. You can use the -p parameter to specify a port. On the Windows platform, the default browser is used to open the HPM UI.
+
+
+
Changing language
+
+
hpm lang
+
+
Alternates between Chinese and English on the CLI and UI.
+
+
+
Converting to HPM format
+
+
hpm x2h
+
+
Converts a Maven or NPM package to an HPM package and publishes it to the HPM.
+
+
+
Code segment restoration or cleanup
+
+
hpm code clean|restore
+
+
Clears or restores the dependent code segment (code-segment). That is, copy or delete the code segment based on segment.destPath.
+
+
+
Generating a key
+
+
hpm gen-keys
+
+
Generates a public-private key pair and configures the public key on the HPM server, which enables password-free hpm-cli login for bundle publishing.
+
+
+
Generating third-party open source notice
+
+
hpm gen-notice
+
+
Generates a file providing the notice on third-party open source by combining the description of each bundle.
+
+
+
+
+
+## Bundle Version
+
+### Version Number Naming Specifications
+
+Each version name allows only lowercase letters, which can be separated by hyphens \(-\) or underscores \(\_\). For example, **bundle** and **my\_bundle** are allowed.
+
+A bundle version number is in the format of _major version number_._minor version number_._revision version number_ or _major version number_._minor version number_._revision version number_-_pre-release version number_, for example, **1.0.0** and **1.0.0-beta**. For details, see [https://semver.org](https://semver.org/).
+
+### Version Publishing
+
+You should upload bundles to the remote repository so that your peers have an option to use them. You can run the following command to upload the bundles:
+
+```
+hpm publish
+```
+
+After this command is executed, the system checks the bundle dependencies and downloads the missing dependencies. If the bundles you uploaded are in binary, the system compiles the entire bundle, generates a binary file, packs the file, and uploads it. If the bundles you uploaded are in another format, the system packs the bundle file in compliance with the defined packing rules and then uploads the file.
+
+Note: To publish a bundle, you need an HPM account for login. After logging in to the HPM platform, register with an organization and apply for authentication. After successful authentication, you will have the permission to publish the bundle.
+
+## Distribution
+
+A distribution refers to an image file of an executable OpenHarmony solution composed of a group of bundles. It contains many dependent bundles and provides scripts to illustrate how to compile and link these bundles.
+
+Generally, a distribution does not require code but contains only the **bundle.json** description \(**publishAs** set to **distribution**\) and some compilation scripts.
+
+As system-provided environment variables are required during distribution compiling, run the **dist** command in **scripts**.
+
+```
+{
+ "publishAs":"distribution",
+ "scripts": {
+ "dist": "script compile command"
+ }
+}
+```
+
+Run the following command:
+
+```
+hpm dist
+```
+
+As it is rather complex to redefine the functionality of a distribution, OpenHarmony allows inheritance from a distribution so that you can make a tailored distribution based on the existing functionality. To inherit from a distribution, you need to define the **base** field in **bundle.json**.
+
+```
+{
+ "base": {
+ "name": "dist_wifi_iot",
+ "version": "1.0.0"
+ }
+}
+```
+
+In this example, the current bundle inherits from the **dist-wifi-iot 1.0.0** bundle of the distribution.
+
+Each distribution consists of many dependent bundles, which are represented by the **dependencies** field in **bundle.json**. Some dependencies are mandatory, and others can be added or removed required. In the **bundle.json** file, bundle names prefixed with a question mark \(?\) represent optional dependent bundles. If you want to inherit from a distribution involving such bundles, you can remove them and then add other bundles.
+
+```
+{
+ "dependencies": {
+ "?my_bundle": "1.0.0"
+ }
+}
+```
+
+In this example, **my\_bundle** is an optional dependent bundle that can be removed by using the keyword **excludes**.
+
+```
+{
+ "excludes": [ "my_bundle" ]
+}
+```
+
+The removed **my-bundle** will not be involved in the build process. If you forcibly remove mandatory dependent bundles, an error message will be displayed.
+
+## Environment Variables
+
+During bundle compilation, system-provided environment variables are required to define the output and link the required binary files. These variables are injected into the context for executing scripts based on service requirements. Therefore, their values can be directly obtained from the scripts. The following environment variables are available:
+
+Global variables are defined by the **envs** attribute in **bundle.json**. All dependent bundles can obtain the values of global variables.
+
+```
+{
+ "envs": {
+ "compileEnv": "arm"
+ }
+}
+```
+
+Different parameters can be passed to bundles when introducing dependencies so that the compilation of dependent bundles can meet the requirements of the current bundle. The parameters defined in the dependencies can be obtained from the context for executing the corresponding scripts.
+
+```
+{
+ "dependencies": {
+ "my-bundle": {
+ "version": "1.0.0",
+ "mode": "debug"
+ }
+ }
+}
+```
+
+When linking to a binary file, the bundle needs to know the file path regarding the dependencies. Therefore, the path \(as an environment variable\) is passed to the bundle for compiling.
+
+The passed environment variable is in **DEP\__BundleName_** format, where **BundleName** indicates the name of the dependent bundle, for example, **DEP\_first\_bundle**.
+
+Tags can be defined to group dependent bundles. You can obtain the path of a group of dependent bundles based on their tag. A tag starts with a number sign \(\#\) and is defined as follows:
+
+```
+{
+ "dependencies": {
+ "#tool": {
+ "first-bundle": "1.0.0",
+ "second-bundle": "1.0.0"
+ },
+ "#drivers": {
+ "xx-bundle": "1.0.0",
+ "yy-bundle": "1.0.0"
+ }
+ }
+}
+```
+
+There are two fixed environment variables:
+
+- **DEP\_OHOS\_BUNDLES**: path of the **ohos\_bundles** folder
+- **DEP\_BUNDLE\_BASE**: path of the outermost bundle
+
diff --git a/en/device-dev/bundles/bundles.md b/en/device-dev/bundles/bundles.md
new file mode 100644
index 0000000000000000000000000000000000000000..21586387bbddd35439986cadb9c812a6d0c58bc3
--- /dev/null
+++ b/en/device-dev/bundles/bundles.md
@@ -0,0 +1,9 @@
+# Bundle Development
+
+- **[Development Specifications](bundles-standard-rules.md)**
+
+- **[Development Guidelines](bundles-guide.md)**
+
+- **[HPM User Guide](bundles-demo.md)**
+
+
diff --git a/en/device-dev/bundles/development-example.md b/en/device-dev/bundles/development-example.md
deleted file mode 100644
index 159de560311c2fe03fd03c947fbfa669c060f3fa..0000000000000000000000000000000000000000
--- a/en/device-dev/bundles/development-example.md
+++ /dev/null
@@ -1,54 +0,0 @@
-# Development Example
-
-This following uses the Hi3861 platform as an example to describe how to install, compile, and package components by using HPM.
-
-1. Run the following commands to initialize the installation directory \(whose name can be customized\):
-
- ```
- mkdir test3861
- cd test3861
- hpm init -t dist
- ```
-
- If the following information is displayed, the initialization is successful:
-
- ```
- Initialization finished.
- ```
-
-2. Run the following command to install the **wifi\_iot** distribution:
-
- ```
- hpm install @ohos/wifi_iot
- ```
-
- If the following information is displayed, the installation is successful:
-
- ```
- Installed.
- ```
-
- > **NOTE:**
- >Run the following command for the Hi3516 platform:
- >```
- >hpm install @ohos/ip_camera_hi3516dv300
- >```
- >Run the following command for the Hi3518 platform:
- >```
- >hpm install @ohos/ip_camera_hi3518ev300
- >```
-
-3. Run the following command to build and package components:
-
- ```
- hpm dist
- ```
-
- If the building is successful, the following information is displayed:
-
- ```
- {{name}}: distribution building completed.
- ```
-
-4. Check the result in the **./out** directory. You can burn the distribution into the corresponding development board for testing.
-
diff --git a/en/device-dev/bundles/development-guidelines.md b/en/device-dev/bundles/development-guidelines.md
deleted file mode 100644
index 6ae82a8f668402df6a4b967fad4fb85af5f59eef..0000000000000000000000000000000000000000
--- a/en/device-dev/bundles/development-guidelines.md
+++ /dev/null
@@ -1,9 +0,0 @@
-# Development Guidelines
-
-- **[Overview](overview-0.md)**
-
-- **[Preparations](preparations.md)**
-
-- **[Bundle Development](bundle-development.md)**
-
-
diff --git a/en/device-dev/bundles/development-specifications.md b/en/device-dev/bundles/development-specifications.md
deleted file mode 100644
index 6f583016abacb71b7bee2f3d550924cac1025286..0000000000000000000000000000000000000000
--- a/en/device-dev/bundles/development-specifications.md
+++ /dev/null
@@ -1,15 +0,0 @@
-# Development Specifications
-
-- **[Overview](overview.md)**
-
-- **[Bundle Composition](bundle-composition.md)**
-
-- **[Bundle Management](bundle-management.md)**
-
-- **[Bundle Version](bundle-version.md)**
-
-- **[Distribution](distribution.md)**
-
-- **[Environment Variables](environment-variables.md)**
-
-
diff --git a/en/device-dev/bundles/distribution.md b/en/device-dev/bundles/distribution.md
deleted file mode 100644
index 426905862509138efe9d65a22ddd1c5bc5b3d3f7..0000000000000000000000000000000000000000
--- a/en/device-dev/bundles/distribution.md
+++ /dev/null
@@ -1,56 +0,0 @@
-# Distribution
-
-A distribution refers to an image file of an executable OpenHarmony solution composed of a group of bundles. It contains many dependent bundles and provides scripts to illustrate how to compile and link these bundles.
-
-Generally, a distribution does not require code but contains only the **bundle.json** description \(**publishAs** set to **distribution**\) and some compilation scripts.
-
-As system-provided environment variables are required during distribution compiling, run the **dist** command in **scripts**.
-
-```
-{
- "publishAs":"distribution",
- "scripts": {
- "dist": "script compile command"
- }
-}
-```
-
-Run the following command:
-
-```
-hpm dist
-```
-
-As it is rather complex to redefine the functionality of a distribution, OpenHarmony allows inheritance from a distribution so that you can make a tailored distribution based on the existing functionality. To inherit from a distribution, you need to define the **base** field in **bundle.json**.
-
-```
-{
- "base": {
- "name": "dist_wifi_iot",
- "version": "1.0.0"
- }
-}
-```
-
-In this example, the current bundle inherits from the **dist-wifi-iot 1.0.0** bundle of the distribution.
-
-Each distribution consists of many dependent bundles, which are represented by the **dependencies** field in **bundle.json**. Some dependencies are mandatory, and others can be added or removed required. In the **bundle.json** file, bundle names prefixed with a question mark \(?\) represent optional dependent bundles. If you want to inherit from a distribution involving such bundles, you can remove them and then add other bundles.
-
-```
-{
- "dependencies": {
- "?my_bundle": "1.0.0"
- }
-}
-```
-
-In this example, **my\_bundle** is an optional dependent bundle that can be removed by using the keyword "excludes".
-
-```
-{
- "excludes": [ "my_bundle" ]
-}
-```
-
-After **my-bundle** is removed, it will not be involved in the building process. If you forcibly remove mandatory dependent bundles, an error message will be displayed.
-
diff --git a/en/device-dev/bundles/environment-variables.md b/en/device-dev/bundles/environment-variables.md
deleted file mode 100644
index 933994a6818205f1a7958390a67876048369f67e..0000000000000000000000000000000000000000
--- a/en/device-dev/bundles/environment-variables.md
+++ /dev/null
@@ -1,53 +0,0 @@
-# Environment Variables
-
-During bundle compilation, system-provided environment variables are required to define the output and link the required binary files. These variables are injected into the context for executing scripts based on service requirements. Therefore, their values can be directly obtained from the scripts. Currently, there are global and fixed environment variables in the system.
-
-Global variables are defined by the **envs** attribute in **bundle.json**. All dependent bundles can obtain the values of global variables.
-
-```
-{
- "envs": {
- "compileEnv": "arm"
- }
-}
-```
-
-Different parameters can be passed to bundles when introducing dependencies so that the compilation of dependent bundles can meet the requirements of the current bundle. The parameters defined in the dependencies can be obtained from the context for executing the corresponding scripts.
-
-```
-{
- "dependencies": {
- "my-bundle": {
- "version": "1.0.0",
- "mode": "debug"
- }
- }
-}
-```
-
-When linking to a binary file, the bundle needs to know the file path regarding the dependencies. Therefore, the path \(as an environment variable\) is passed to the bundle for compiling.
-
-The passed environment variable is in **DEP\__BundleName_** format, where **BundleName** indicates the name of the dependent bundle, for example, **DEP\_first-bundle**.
-
-Tags can be defined to group dependent bundles. You can obtain the path of a group of dependent bundles based on their tag. A tag starts with a number sign \(\#\) and is defined as follows:
-
-```
-{
- "dependencies": {
- "#tool": {
- "first-bundle": "1.0.0",
- "second-bundle": "1.0.0"
- },
- "#drivers": {
- "xx-bundle": "1.0.0",
- "yy-bundle": "1.0.0"
- }
- }
-}
-```
-
-There are two fixed environment variables:
-
-- **DEP\_OHOS\_BUNDLES**: path of the **ohos\_bundles** folder
-- **DEP\_BUNDLE\_BASE**: path of the outermost bundle
-
diff --git a/en/device-dev/bundles/figures/en-us_image_0000001051452177.png b/en/device-dev/bundles/figure/en-us_image_0000001051452177.png
similarity index 100%
rename from en/device-dev/bundles/figures/en-us_image_0000001051452177.png
rename to en/device-dev/bundles/figure/en-us_image_0000001051452177.png
diff --git a/en/device-dev/bundles/figures/en-us_image_0000001051770876.png b/en/device-dev/bundles/figure/en-us_image_0000001051770876.png
similarity index 100%
rename from en/device-dev/bundles/figures/en-us_image_0000001051770876.png
rename to en/device-dev/bundles/figure/en-us_image_0000001051770876.png
diff --git a/en/device-dev/bundles/figure/en-us_image_0000001173313501.png b/en/device-dev/bundles/figure/en-us_image_0000001173313501.png
new file mode 100644
index 0000000000000000000000000000000000000000..52f943be7f91caa887bff689f6c37040858fa8ce
Binary files /dev/null and b/en/device-dev/bundles/figure/en-us_image_0000001173313501.png differ
diff --git a/en/device-dev/bundles/figures/hardware-connections.png b/en/device-dev/bundles/figure/hardware-connections-23.png
similarity index 100%
rename from en/device-dev/bundles/figures/hardware-connections.png
rename to en/device-dev/bundles/figure/hardware-connections-23.png
diff --git a/en/device-dev/bundles/figure/hardware-connections-24.png b/en/device-dev/bundles/figure/hardware-connections-24.png
new file mode 100644
index 0000000000000000000000000000000000000000..c4636401a20e37794d8ec28dc173e9308b2b72db
Binary files /dev/null and b/en/device-dev/bundles/figure/hardware-connections-24.png differ
diff --git a/en/device-dev/bundles/figures/successful-installation-(scons-version-requirement-3-0-4-or-later).png b/en/device-dev/bundles/figure/successful-installation-(scons-version-requirement-3-0-4-or-later)-25.png
similarity index 100%
rename from en/device-dev/bundles/figures/successful-installation-(scons-version-requirement-3-0-4-or-later).png
rename to en/device-dev/bundles/figure/successful-installation-(scons-version-requirement-3-0-4-or-later)-25.png
diff --git "a/en/device-dev/bundles/figures/\347\273\204\344\273\2660924.png" "b/en/device-dev/bundles/figure/\347\273\204\344\273\2660924.png"
similarity index 100%
rename from "en/device-dev/bundles/figures/\347\273\204\344\273\2660924.png"
rename to "en/device-dev/bundles/figure/\347\273\204\344\273\2660924.png"
diff --git a/en/device-dev/bundles/figures/bundle-dependencies.png b/en/device-dev/bundles/figures/bundle-dependencies.png
deleted file mode 100644
index 1b936a2cbc95d3f9d7ddab0187305c3d0c486b0a..0000000000000000000000000000000000000000
Binary files a/en/device-dev/bundles/figures/bundle-dependencies.png and /dev/null differ
diff --git a/en/device-dev/bundles/hpm-user-guide.md b/en/device-dev/bundles/hpm-user-guide.md
deleted file mode 100644
index daaf5734779208bf468d896807d4ecdb3dfc6f6f..0000000000000000000000000000000000000000
--- a/en/device-dev/bundles/hpm-user-guide.md
+++ /dev/null
@@ -1,9 +0,0 @@
-# HPM User Guide
-
-- **[Introduction](introduction.md)**
-
-- **[Preparations](preparations-1.md)**
-
-- **[Development Example](development-example.md)**
-
-
diff --git a/en/device-dev/bundles/overview-0.md b/en/device-dev/bundles/overview-0.md
deleted file mode 100644
index 44fc41de4b49eaf811cc9b139d6751613452c21d..0000000000000000000000000000000000000000
--- a/en/device-dev/bundles/overview-0.md
+++ /dev/null
@@ -1,54 +0,0 @@
-# Overview
-
-This document describes how to develop OpenHarmony bundles and distributions, and how to create, develop, and build code, as well as burn and debug devices by using a command line tool.
-
-- A bundle usually maps onto a code repository, which is a code archive with the **bundle.json**, **README**, and **LICENSE** files.
-- A distribution consists of multiple bundles. Each distribution integrates various bundles of a comprehensive system, such as the driver, kernel, framework, and applications. These bundles can be used for device burning.
-
-**Table 1** Differences between a bundle and a distribution
-
-
-
Aspect
-
-
Bundle
-
-
Distribution
-
-
-
-
Application scenario
-
-
Feature-oriented
-
-
System-oriented
-
-
-
Content
-
-
Codes or a binary library for implementing features
-
-
List of dependent bundles as well as their compiling and building scripts
-
-
-
Integrity
-
-
A part of the operating system
-
-
An entire operating system
-
-
-
Compilation result
-
-
Bundles
-
-
System image
-
-
-
-
-
-**Figure 1** Composition of bundles and distributions
-
-
-
-
diff --git a/en/device-dev/bundles/overview.md b/en/device-dev/bundles/overview.md
deleted file mode 100644
index 3490dd84640d272e6c707c96d35fbee2c71b8da0..0000000000000000000000000000000000000000
--- a/en/device-dev/bundles/overview.md
+++ /dev/null
@@ -1,38 +0,0 @@
-# Overview
-
-- [Definition](#section177563344911)
-- [Bundle Division Principles](#section2487162541016)
-- [Bundle Dependency](#section185955409107)
-
-This document describes the basic concepts of a bundle and how to define it in compliance with specifications.
-
-## Definition
-
-OpenHarmony software is developed on a per-bundle basis. In terms of the operating system, all software running on OpenHarmony are bundles. Generally, bundles are classified into the following types based on their application scopes:
-
-- Board-level bundles: device hardware-specific bundles, such as **board**, **arch**, and **mcu**
-- System-level bundles: a set of bundles with independent features, such as the kernel, file system, and framework
-- Application-level bundles: applications that provide services to users, such as **wifi\_iot** and **ip\_camera**
-
-Bundles are designed for the reuse purpose. Any reusable modules can be defined as bundles. They are classified into the following types based on their forms:
-
-- Source code
-- Binary system
-- Code snippet
-- Distribution
-
-## Bundle Division Principles
-
-In principle, bundles should be grouped at a fine-grained granularity as much as possible to achieve maximum reuse. The following factors are taken into account regarding bundle division:
-
-- Independence: Bundles provide relatively independent features and can be independently compiled. Each of them is capable of providing its own APIs and services for external systems.
-- Coupling: If a bundle must depend on another bundle to provide services, they can be coupled to one bundle.
-- Correlation: If a group of bundles jointly implement a feature, and if other bundles never depend on them, the group of bundles can be combined into one bundle.
-
-## Bundle Dependency
-
-A bundle dependency can be mandatory or optional.
-
-- Mandatory dependency: If bundle A must depend on bundle B to implement a feature, that is, the APIs or services specific to bundle B must be invoked, then bundle B is defined as the mandatory dependency of bundle A.
-- Optional dependency: If either bundle C or bundle D is required for bundle A to implement a feature, and if bundle C and bundle D are interchangeable, then bundle C and bundle D are defined as optional dependencies of bundle A.
-
diff --git a/en/device-dev/bundles/preparations-1.md b/en/device-dev/bundles/preparations-1.md
deleted file mode 100644
index 6a0981f81bc1c1562946a9f1987eaabc30b50439..0000000000000000000000000000000000000000
--- a/en/device-dev/bundles/preparations-1.md
+++ /dev/null
@@ -1,139 +0,0 @@
-# Preparations
-
-- [Linux Server](#section20979554791)
-- [Node.js](#section9954105413153)
-- [HPM](#section15937194904819)
-- [Python Environment](#section1621819180417)
-- [File Packaging Tool](#section77617165913)
-- [SCons](#section20558439191516)
-
-## Linux Server
-
-Prepare a 64-bit Linux server running Ubuntu 16.04 or later. HPM supports Windows Server, but the open-source Hi3861, Hi3516, and Hi3518 solutions support only Ubuntu.
-
-Configure Ubuntu to use bash as the Linux system shell, by performing the following:
-
-```
-ls -l $(which sh)
-# If the file does not point to bash, modify the file using either of the provided methods.
-# Method 1: Run the following command and select no:
-dpkg-reconfigure dash
-# Method 2: Run the following commands to delete /bin/sh and then create a new symbolic link to bash:
-rm -f /bin/sh
-ln -s bash /bin/sh
-```
-
-## Node.js
-
-> **NOTE:**
->If the Node.js version of the source is outdated, run the following command before running **apt-get install**:
->```
->curl -L https://deb.nodesource.com/setup_12.x | bash
->```
-
-You are advised to install Node.js 12.x \(including npm 6.14.4\) or a later version \(12.13.0 or later is recommended\).
-
-```
-sudo apt-get install nodejs
-sudo apt-get install npm
-```
-
-Run the following commands to view Node.js and NPM versions:
-
-```
-node --version # Check the Node.js version.
-npm --version # Check the NPM version.
-```
-
-## HPM
-
-Install the **hpm-cli** command line tool by using the NPM \(default source: https://registry.npmjs.org/\) provided by the Node.js.
-
-```
-npm install -g @ohos/hpm-cli
-```
-
-After **hpm-cli** is installed, run the following command to view default HPM configurations:
-
-```
-hpm config
-```
-
-You can modify the default configurations as required. The following lists common HPM configurations:
-
-```
-registry = https://hpm.harmonyos.com # Register with the HPM registration center. This is mandatory for downloading components.
-strictSsl = true # Enable strict SSL verification as HTTPS is used for connection.
-http_proxy = http://your-proxy-server:port # Configure the HTTP proxy.
-https_proxy = http://your-proxy-server:port # Configure the HTTPS proxy.
-```
-
-For details about **hpm-cli** commands, see [HPM Commands](bundle-management.md).
-
-## Python Environment
-
-Run the following commands to install Python later than 3.7:
-
-```
-sudo apt-get install python3.8
-sudo apt-get install python3-pip
-sudo pip3 install setuptools
-sudo pip3 install kconfiglib # Install kconfiglib 13.2.0 or later.
-```
-
-> **NOTE:**
->The preceding method is applicable to Hi3518 and Hi3516 platforms. For Hi3861, run the following commands to install the Python environment:
->```
->sudo apt-get install python3.8
->sudo apt-get install python3-pip
->sudo pip3 install setuptools
->sudo pip3 install kconfiglib # Install kconfiglib 13.2.0 or later.
->sudo pip3 install pycryptodome
->sudo pip3 install six --upgrade --ignore-installed six
->sudo pip3 install ecdsa
->```
-
-If both Python2 and Python3 have been installed in the current system, run the following commands to set the default Python to Python3:
-
-```
-ll `which python`
-rm /usr/bin/python
-ln -s python3.8 /usr/bin/python
-```
-
-## File Packaging Tool
-
-Run the following commands to install the tool:
-
-```
-which mkfs.vfat # If mkfs.vfat is not found, run the following command:
-sudo apt-get install dosfstools
-which mcopy # If mcopy is not found, run the following command:
-sudo apt-get install mtools
-```
-
-> **NOTE:**
->Both Hi3518 and Hi3516 platforms require the file packaging tool. For Hi3861, the tool is not required.
-
-## SCons
-
-1. Start a Linux server.
-2. Run the following command to install the SCons installation package:
-
- ```
- python3 -m pip install scons
- ```
-
-3. Run the following command to check whether SCons is successfully installed. If the installation is successful, the query result as shown in [Figure 1](#fig235815252492) is displayed.
-
- ```
- scons -v
- ```
-
- **Figure 1** Successful installation \(SCons version requirement: 3.0.4 or later\)
- .png "successful-installation-(scons-version-requirement-3-0-4-or-later)")
-
-
-> **NOTE:**
->SCons is required for the Hi3861 platform, but not for the Hi3518 or Hi3516 platform.
-
diff --git a/en/device-dev/bundles/preparations.md b/en/device-dev/bundles/preparations.md
deleted file mode 100644
index dedd9b41f76f016fd1a33e1a407113feadabff7f..0000000000000000000000000000000000000000
--- a/en/device-dev/bundles/preparations.md
+++ /dev/null
@@ -1,84 +0,0 @@
-# Preparations
-
-- [Hardware Requirements](#section98535485518)
-- [Installing Node.js and the hpm-cli Tool](#section106591616205311)
-- [\(Optional\) Modifying HPM Configurations](#section71821165412)
-- [Downloading OpenHarmony Code](#section102338221707)
-- [Installing Dependent Bundles](#section19233183315020)
-
-## Hardware Requirements
-
-- Development boards \(examples: Hi3861, Hi3516DV300, and Hi3518EV300\)
-- Host computer \(Windows workstation\)
-- Linux server
-
-**Figure 1** Hardware connections
-
-
-## Installing **Node.js** and the **hpm-cli** Tool
-
-1. Install **Node.js**.
-
- Download **Node.js** from its official website and install it on your local PC.
-
- You are advised to install [Node.js](https://nodejs.org/) 12.x \(including npm 6.14.4\) or a later version \(12.13.0 or later is recommended\).
-
-2. Install the **hpm-cli** tool using **npm** delivered with **Node.js**. Run the following command:
-
- ```
- npm install -g @ohos/hpm-cli
- ```
-
-3. Run the following command to check whether the installation is successful. If an HPM version is displayed, the installation is successful.
-
- ```
- hpm -V or hpm --version
- ```
-
-4. \(Optional\) Run the following command to upgrade the HPM version if needed:
-
- ```
- npm update -g @ohos/hpm-cli
- ```
-
-
-## \(Optional\) Modifying HPM Configurations
-
-After the **hpm-cli** tool is installed, run the following command to view HPM configurations:
-
-```
-hpm config
-```
-
-Default HPM configurations are displayed upon the command execution. You can modify the default configurations as required. The following lists common HPM configurations:
-
-```
-registry = https://hpm.harmonyos.com/hpm/registry/api # Configure the address of the HPM registry, mandatory for downloading bundles.
-login = https://hpm.harmonyos.com/hpm/auth/pk # Configure the address for HPM login, mandatory for publishing bundles.
-loginUser = {your-account} # Configure the account for HPM login, mandatory for publishing bundles.
-shellPath = C:\WINDOWS\System32\cmd.exe # Configure the shell for running HPM commands.
-globalRepo = C:\Users\yourname\.global # Configure the path for storing bundles that are installed globally.
-http_proxy = http://your-proxy-server:port # Configure the HTTP proxy.
-https_proxy = http://your-proxy-server:port # Configure the HTTPS proxy.
-```
-
-For details about **hpm-cli** commands, see [HPM Commands](bundle-management.md).
-
-## Downloading OpenHarmony Code
-
-For details, see [Source Code Acquisition](../get-code/source-code-acquisition.md).
-
-## Installing Dependent Bundles
-
-The HPM publishes commonly used development tools \(such as those for burning, compiling, and compression\) as bundles. You can run the following command to install these tools. After the command is executed, the system automatically downloads and installs the tools, which need to be installed globally only once.
-
-```
-hpm i -g @ohos/llvm
-hpm i -g @ohos/ninja
-hpm i -g @ohos/gn
-hpm i -g @ohos/hc_gen
-hpm i -g @ohos/sysroot
-```
-
-These are a set of development tools \(such as **gn** and **ninja**\). With these tools, you can start your general bundle development based on source code.
-
diff --git a/en/device-dev/driver/Readme-EN.md b/en/device-dev/driver/Readme-EN.md
index 18678440ad06c989d251367330af5c65e8d93a59..bbcc73ae3c78709e739d443be1eb9f41329d4390 100644
--- a/en/device-dev/driver/Readme-EN.md
+++ b/en/device-dev/driver/Readme-EN.md
@@ -1,73 +1,23 @@
# Drivers
-- [HDF](hdf.md)
- - [HDF Overview](hdfoverview.md)
- - [Driver Development](driver-development.md)
- - [Driver Service Management](driver-service-management.md)
- - [Driver Message Mechanism Management](driver-message-mechanism-management.md)
- - [Driver Configuration Management](driver-configuration-management.md)
- - [HDF Development Example](hdfdevelopment-example.md)
-
-- [Driver Platform](driver-platform.md)
- - [GPIO](gpio.md)
- - [GPIO Overview](gpiooverview.md)
- - [GPIO Usage Guidelines](gpiousage-guidelines.md)
- - [GPIO Usage Example](gpiousage-example.md)
-
- - [I2C](i2c.md)
- - [I2C Overview](i2c-overview.md)
- - [I2C Usage Guidelines](i2c-usage-guidelines.md)
- - [I2C Usage Example](i2c-usage-example.md)
-
- - [RTC](rtc.md)
- - [RTC Overview](rtc-overview.md)
- - [RTC Usage Guidelines](rtc-usage-guidelines.md)
- - [RTC Usage Example](rtc-usage-example.md)
-
- - [SDIO](sdio.md)
- - [SDIO Overview](sdiooverview.md)
- - [SDIO Usage Guidelines](sdiousage-guidelines.md)
- - [SDIO Usage Example](sdiousage-example.md)
-
- - [SPI](spi.md)
- - [SPI Overview](spioverview.md)
- - [SPI Usage Guidelines](spiusage-guidelines.md)
- - [SPI Usage Example](spiusage-example.md)
-
- - [UART](uart.md)
- - [UART Overview](uartoverview.md)
- - [UART Usage Guidelines](uartusage-guidelines.md)
- - [UART Usage Example](uartusage-example.md)
-
- - [WATCHDOG](watchdog.md)
- - [Watchdog Overview](watchdogoverview.md)
- - [Watchdog Usage Guidelines](watchdogusage-guidelines.md)
- - [Watchdog Usage Example](watchdogusage-example.md)
-
- - [MIPI DSI](mipi-dsi.md)
- - [MIPI DSI Overview](mipi-dsi-overview.md)
- - [Usage Guidelines](usage-guidelines.md)
- - [Usage Example](usage-example.md)
-
-- [Peripherals](peripherals.md)
- - [LCD](lcd.md)
- - [LCD Overview](lcdoverview.md)
- - [LCD Development Guidelines](lcddevelopment-guidelines.md)
- - [LCD Development Example](lcddevelopment-example.md)
-
- - [TOUCHSCREEN](touchscreen.md)
- - [Touchscreen Overview](touchscreenoverview.md)
- - [Touchscreen Development Guidelines](touchscreendevelopment-guidelines.md)
- - [Touchscreen Development Example](touchscreendevelopment-example.md)
-
- - [SENSOR](sensor.md)
- - [Sensor Driver Overview](sensor-driver-overview.md)
- - [Sensor Driver Development Guidelines](sensor-driver-development-guidelines.md)
- - [Sensor Driver Development Example](sensor-driver-development-example.md)
- - [Sensor Driver Test Guidelines](sensor-driver-test-guidelines.md)
-
- - [WLAN](wlan.md)
- - [WLAN Overview](wlanoverview.md)
- - [WLAN Development Guidelines](wlandevelopment-guidelines.md)
- - [WLAN Development Example](wlandevelopment-example.md)
-
+- [HDF](drive-hdf.md)
+ - [HDF Overview](drive-hdf-overview.md)
+ - [Driver Development](drive-hdf-development.md)
+ - [Driver Service Management](drive-hdf-servicemanage.md)
+ - [Driver Message Mechanism Management](drive-hdf-news.md)
+ - [Driver Configuration Management](drive-hdf-manage.md)
+ - [HDF Development Example](drive-hdf-sample.md)
+- [Platform Drivers](drive-platform.md)
+ - [GPIO](drive-platform-gpio-des.md)
+ - [I2C](drive-platform-i2c-des.md)
+ - [RTC](drive-platform-rtc-des.md)
+ - [SDIO](drive-platform-sdio-des.md)
+ - [SPI](drive-platform-spi-des.md)
+ - [UART](drive-platform-uart-des.md)
+ - [Watchdog](drive-platform-watchdog-des.md)
+ - [MIPI DSI](drive-platform-mipidsi-des.md)
+- [Peripherals](drive-peripherals.md)
+ - [LCD](drive-peripherals-lcd-des.md)
+ - [TOUCHSCREEN](drive-peripherals-touch-des.md)
+ - [Sensor](drive-peripherals-sensor-des.md)
+ - [WLAN](drive-peripherals-external-des.md)
\ No newline at end of file
diff --git a/en/device-dev/driver/drive-hdf-development.md b/en/device-dev/driver/drive-hdf-development.md
new file mode 100644
index 0000000000000000000000000000000000000000..3bff3b0910ee0c9506999c6362818cc630423183
--- /dev/null
+++ b/en/device-dev/driver/drive-hdf-development.md
@@ -0,0 +1,175 @@
+# Driver Development
+
+- [Introduction](#section157425168112)
+- [How to Develop](#section1969312275533)
+
+## Introduction
+
+The HDF is designed based on the component-based driver model. It provides more refined driver management to make driver development and deployment more standard. Device drivers of the same type are placed in the same host. You can develop and deploy the drivers separately. One driver can have multiple nodes. [Figure 1](#fig5487113011526) shows the HDF driver model.
+
+**Figure 1** HDF driver model
+
+
+
+
+## How to Develop
+
+Driver development based on the HDF consists of two parts: driver implementation and driver configuration. The details are as follows:
+
+1. Implement driver.
+
+ To implement a driver, compile driver service code and register a driver entry.
+
+ - Driver service code
+
+ ```
+ #include "hdf_device_desc.h" // Header file that describes the APIs provided by the HDF to the driver.
+ #include "hdf_log.h" // Header file that describes the log APIs provided by the HDF.
+
+ #define HDF_LOG_TAG "sample_driver" // Tag contained in logs. If no tag is not specified, the default HDF_TAG is used.
+
+ // The driver service interface must be bound to the HDF for you to use the service capability.
+ int32_t HdfSampleDriverBind(struct HdfDeviceObject *deviceObject)
+ {
+ HDF_LOGD("Sample driver bind success");
+ return 0;
+ }
+
+ // Initialize the driver service.
+ int32_t HdfSampleDriverInit(struct HdfDeviceObject *deviceObject)
+ {
+ HDF_LOGD("Sample driver Init success");
+ return 0;
+ }
+
+ // Release the driver resources.
+ void HdfSampleDriverRelease(struct HdfDeviceObject *deviceObject)
+ {
+ HDF_LOGD("Sample driver release success");
+ return;
+ }
+ ```
+
+ - Registering the driver entry with the HDF
+
+ ```
+ // Define the object of the driver entry. The object must be a global variable of the HdfDriverEntry type (defined in hdf_device_desc.h).
+ struct HdfDriverEntry g_sampleDriverEntry = {
+ .moduleVersion = 1,
+ .moduleName = "sample_driver",
+ .Bind = HdfSampleDriverBind,
+ .Init = HdfSampleDriverInit,
+ .Release = HdfSampleDriverRelease,
+ };
+
+ // Call HDF_INIT to register the driver entry with the HDF framework. When loading the driver, call the Bind function and then the Init function. If the Init function fails to be called, the HDF will call Release to release the driver resource and exit.
+ HDF_INIT(g_sampleDriverEntry);
+ ```
+
+
+2. Compile the driver code.
+ - Use the **Makefile** template provided by the HDF to compile the driver code.
+
+ ```
+ include $(LITEOSTOPDIR)/../../drivers/adapter/lite/khdf/lite.mk # (Mandatory) Import the predefined content of the HDF.
+ MODULE_NAME := # Generated result file
+ LOCAL_INCLUDE: = # Header file directory of the driver
+ LOCAL_SRCS : = # Source code file of the driver
+ LOCAL_CFLAGS : = # Custom compilation options
+ include $(HDF_DRIVER) # Import the template Makefile to complete compilation.
+ ```
+
+ - Link the compilation result file to the kernel image by adding the result file to **hdf\_vendor.mk** in the **vendor** directory. The following is an example:
+
+ ```
+ LITEOS_BASELIB += -lxxx # Static library generated through linking
+ LIB_SUBDIRS += # Directory of Makefile
+ ```
+
+
+3. Configure the driver.
+
+ HDF Configuration Source \(HCS\) is the source code that describes the configuration of the HDF. For details about the HCS, see [Driver Configuration Management](drive-hdf-manage.md).
+
+ The driver configuration consists of the driver device description defined by the HDF and private driver configuration information.
+
+ - \(Mandatory\) Driver device description
+
+ The information required for the HDF to load drivers comes from the driver device description defined by the HDF. Therefore, the device description must be added to the configuration file **device\_info.hcs** defined by the HDF for drivers developed based on the HDF. The following is an example:
+
+ ```
+ root {
+ device_info {
+ match_attr = "hdf_manager";
+ template host { // Host template. If the node (for example, sample_host) that inherits the template uses default values in the template, the values of the node fields can be omitted.
+ hostName = "";
+ priority = 100;
+ template device {
+ template deviceNode {
+ policy = 0;
+ priority = 100;
+ preload = 0;
+ permission = 0664;
+ moduleName = "";
+ serviceName = "";
+ deviceMatchAttr = "";
+ }
+ }
+ }
+ sample_host :: host{
+ hostName = "host0"; // Host name. The host node is used to store a certain type of drivers.
+ priority = 100; // Host startup priority (0-200). A larger value indicates a lower priority. The default value 100 is recommended. If the priorities are the same, the host loading sequence is random.
+ device_sample :: device { // Device node of sample
+ device0 :: deviceNode { // DeviceNode of the sample driver
+ policy = 1; // Driver service release policy. For details, see section Driver Service Management.
+ priority = 100; // Driver startup priority (0-200). A larger value indicates a lower priority. The default value 100 is recommended. If the priorities are the same, the device loading sequence is random.
+ preload = 0; // On-demand loading of the driver. For details, see "NOTE" at the end of this section.
+ permission = 0664; // Permission for the driver to create device nodes.
+ moduleName = "sample_driver"; // Driver name. The value of this field must be the same as the value of moduleName in the driver entry structure.
+ serviceName = "sample_service"; // Name of the service released by the driver. The name must be unique.
+ deviceMatchAttr = "sample_config"; // Keyword matching the private data of the driver. The value must be the same as that of match_attr in the private data configuration table of the driver.
+ }
+ }
+ }
+ }
+ }
+ ```
+
+ - \(Optional\) Private configuration information of the driver
+
+ If the driver has private configurations, you can add a driver configuration file to fill in the default configuration information of the driver. When loading the driver, the HDF obtains the information and saves it in the **property** of **HdfDeviceObject**, and transfers it to the driver using **Bind** and **Init** \(see [1](#li35182436435)\). The following is an example of the driver configuration information:
+
+ ```
+ root {
+ SampleDriverConfig {
+ sample_version = 1;
+ sample_bus = "I2C_0";
+ match_attr = "sample_config"; // The value of this field must be the same as that of deviceMatchAttr in device_info.hcs.
+ }
+ }
+ ```
+
+ After the configuration information is defined, you need to add the configuration file to the board-level configuration entry file **hdf.hcs**. \(You can use the DevEco to perform on-click configuration. For details, see the description about the driver development suite.\) The following is an example:
+
+ ```
+ #include "device_info/device_info.hcs"
+ #include "sample/sample_config.hcs"
+ ```
+
+
+
+> **NOTE:**
+>On-demand loading and sequential loading are supported. The detailed usage is as follows:
+>- On-demand loading
+> ```
+> typedef enum {
+> DEVICE_PRELOAD_ENABLE = 0,
+> DEVICE_PRELOAD_ENABLE_STEP2,
+> DEVICE_PRELOAD_DISABLE,
+> DEVICE_PRELOAD_INVALID
+> } DevicePreload;
+> ```
+> When the **preload** field in the configuration file is set to **0** \(**DEVICE\_PRELOAD\_ENABLE**\), the driver is loaded by default during system startup. When this field is set to **1** \(**DEVICE\_PRELOAD\_ENABLE\_STEP2**\), the driver is loaded after system startup if quick start is enabled; it is loaded during system startup otherwise. When this field is set to **2** \(**DEVICE\_PRELOAD\_DISABLE**\), the driver is not loaded by default during system startup and can be dynamically loaded later. If the driver service does not exist when a user-level application obtains the driver service \(for details about how to obtain the driver service, see [Driver Message Mechanism Management](drive-hdf-news.md)\), the HDF attempts to dynamically load the driver.
+>- Sequential loading \(drivers must be loaded by default\)
+> In the configuration file, the **priority** field \(the value is an integer ranging from 0 to 200\) indicates the priority of the host and driver. For drivers in different hosts, a smaller host priority value indicates a higher driver loading priority; for drivers in the same host, a smaller driver priority value indicates a higher driver loading priority.
+
diff --git a/en/device-dev/driver/drive-hdf-manage.md b/en/device-dev/driver/drive-hdf-manage.md
new file mode 100644
index 0000000000000000000000000000000000000000..08a88cae19f8c85942cfbe4fe6a6bf73585fda77
--- /dev/null
+++ b/en/device-dev/driver/drive-hdf-manage.md
@@ -0,0 +1,437 @@
+# Driver Configuration Management
+
+- [HDF Configuration Overview](#section59914284576)
+- [Configuration Syntax](#section533713333580)
+- [Keywords](#section1316625413586)
+- [Basic Syntax](#section173481622115918)
+- [Data Types](#section96521601302)
+- [Pre-processing](#section8164295515)
+- [Commenting](#section0338205819610)
+- [Modifying a Reference](#section179799204716)
+- [Replicating Node Configuration](#section382424014712)
+- [Deleting a Node or Attribute](#section165211112586)
+- [Referencing an Attribute](#section192841514490)
+- [Keyword Template](#section520134294)
+- [Configuration Generation](#section106152531919)
+- [Introduction to HC-GEN](#section8260625101012)
+
+## HDF Configuration Overview
+
+HCS is the source code that describes the configuration of the HDF using key-value pairs. It decouples the configuration code from driver code, thereby facilitating configuration management.
+
+HDF Configuration Generator \(HC-GEN\) is a tool for converting a configuration file into a file that can be read by the target software.
+
+- In a low-performance system on a chip \(SoC\), this tool can convert a configuration file into the source code of the configuration tree so that the driver can obtain the configuration by directly calling the C library code.
+- In a high-performance SoC, this tool can convert an HCS configuration file into the HDF Configuration Binary \(HCB\) file, allowing the driver to obtain the configuration through the APIs provided by the HDF.
+
+The following figure shows the typical application scenario of the HCB mode.
+
+**Figure 1** Process of using HCS
+
+
+
+
+The HCS is compiled using the HC-GEN tool to generate an HCB file. The HCS Parser module in the HDF recreates a configuration tree using the HCB file. Then, the HDF driver modules obtain the configurations using the API provided by the HCS Paser.
+
+## Configuration Syntax
+
+The HCS syntax is described as follows:
+
+## Keywords
+
+The keywords listed in the following table below are reserved for HCS configuration files.
+
+**Table 1** Reserved keywords for HCS configuration files
+
+
+
Keywords
+
+
Description
+
+
Remarks
+
+
+
+
root
+
+
Configures the root node.
+
+
-
+
+
+
include
+
+
References other HCS configuration files.
+
+
-
+
+
+
delete
+
+
Deletes a node or an attribute.
+
+
This keyword applies only to the configuration tree imported using the include keyword.
+
+
+
template
+
+
Defines a template node.
+
+
-
+
+
+
match_attr
+
+
Marks the node attribute for matching.
+
+
During configuration parsing, the keyword value can be used to find the corresponding node.
+
+
+
+
+
+## Basic Syntax
+
+The HCS configuration file consists of configurations of attributes and nodes.
+
+**Attributes**
+
+An attribute, as the minimum configuration unit, is an independent configuration item. Its syntax is as follows:
+
+```
+ attribute_name = value;
+```
+
+- The value of **attribute\_name** is a case-sensitive string of characters starting with a letter and consisting of letters, digits, and underscores \(\_\).
+
+- Available formats of **value** are as follows:
+
+ - A binary, octal, decimal, or hexadecimal integer. For details, see [Data Types](#section96521601302).
+
+ - A character string. The content should be enclosed in double quotation marks \(" "\).
+
+ - A node reference
+
+
+- An attribute key-value pair must end with a semicolon \(;\) and belong to a node.
+
+
+**Nodes**
+
+A node is a set of attributes. Its syntax is as follows:
+
+```
+ node_name {
+ module = "sample";
+ ...
+ }
+```
+
+- The value of **node\_name** is a case-sensitive string of characters starting with a letter and consisting of letters, digits, and underscores \(\_\).
+
+- A semicolon \(;\) is not required after the curly brace \(\}\).
+
+- The reserved keyword **root** is used to declare the root node of a configuration table.
+
+- The root node must contain a **module** attribute that uses a string to represent the module to which the configuration belongs.
+
+- The **match\_attr** attribute can be added to a node. Its value is a globally unique character string. During configuration parsing, the query interface can be invoked to query the nodes with the attribute based on the attribute value.
+
+## Data Types
+
+Attributes automatically use built-in data types, including integers, strings, arrays, and booleans. You do not need to explicitly specify the data type for the attribute values.
+
+**Integer**
+
+An integer can be binary, octal, decimal, or hexadecimal. The minimum space is automatically allocated to the integer based on the actual data length.
+
+- Binary: prefixed with 0b, for example, 0b1010
+
+- Octal: prefixed with 0, for example, 0664
+- Decimal: either signed or unsigned, without a prefix, for example, 1024 or +1024. Negative integers can be read only via signed interfaces.
+
+- Hexadecimal: prefixed with 0x, for example, 0xff00 and 0xFF
+
+
+**String**
+
+A string is enclosed by double quotation marks \(" "\).
+
+**Array**
+
+The elements in an array can be integers or strings, but cannot be a combination of both. The combination of **uint32\_t** and **uint64\_t** in an integer array will enable up-casting to **uint64**. The following is an example of an integer array and a string array:
+
+```
+attr_foo = [0x01, 0x02, 0x03, 0x04];
+attr_bar = ["hello", "world"];
+```
+
+**Boolean**
+
+A Boolean data type has two possible values: **true** and **false**.
+
+## Pre-processing
+
+**include**
+
+The **include** keyword is used to import other HCS files. The syntax is as follows:
+
+```
+#include "foo.hcs"
+#include "../bar.hcs"
+```
+
+- The file names must be enclosed by double quotation marks \(" "\). Files in different directories can be referenced using relative paths. The file included must be a valid HCS file.
+- In the scenario that multiple HCS files are imported using **include**, if the same nodes exist, the latter node will override the former one, and other nodes are listed in sequence.
+
+## Commenting
+
+Comments can be formatted as follows:
+
+- Single-line comment
+
+ ```
+ // comment
+ ```
+
+- Multi-line comment
+
+ ```
+ /*
+ comment
+ */
+ ```
+
+ > **NOTE:**
+ >Multi-line comments cannot be nested.
+
+
+## Modifying a Reference
+
+You can use the following syntax to modify the content of any other node:
+
+```
+ node :& source_node
+```
+
+This syntax indicates that the node value is a modification of the source\_node value. Example:
+
+```
+root {
+ module = "sample";
+ foo {
+ foo_ :& root.bar{
+ attr = "foo";
+ }
+ foo1 :& foo2 {
+ attr = 0x2;
+ }
+ foo2 {
+ attr = 0x1;
+ }
+ }
+
+ bar {
+ attr = "bar";
+ }
+}
+```
+
+The following configuration tree is generated:
+
+```
+root {
+ module = "sample";
+ foo {
+ foo2 {
+ attr = 0x2;
+ }
+ }
+ bar {
+ attr = "foo";
+ }
+}
+```
+
+In the preceding example, the **foo.foo\_** node changes the value of the referenced **bar.attr** to "**foo**", and the **foo.foo1** node changes the value of the referenced **foo.foo2.attr** to **0x2**. In the generated configuration tree, **foo.foo\_** and **foo.foo1** are not displayed, but their configuration modifications are presented by their referenced nodes.
+
+- A node of the same level can be referenced simply using the node name. A node of a different level must be referenced by the absolute path, and node names are separated using a period \(.\). **root** indicates the root node. The path format is the node path sequence starting with root. For example, **root.foo.bar** is a valid absolute path.
+- If multiple modifications are made to the same attribute, only one uncertain modification can take effect, and a warning will be displayed.
+
+## Replicating Node Configuration
+
+The content of a node can be replicated to another node to define the node with similar content. The syntax is as follows:
+
+```
+ node : source_node
+```
+
+The preceding statement indicates that the attributes of **source\_node** are replicated to **node**. Example:
+
+```
+root {
+ module = "sample";
+ foo {
+ attr_0 = 0x0;
+ }
+ bar:foo {
+ attr_1 = 0x1;
+ }
+}
+```
+
+The following configuration tree is generated:
+
+```
+root {
+ module = "sample";
+ foo {
+ attr_0 = 0x0;
+ }
+ bar {
+ attr_1 = 0x1;
+ attr_0 = 0x0;
+ }
+}
+```
+
+In the preceding example, the **bar** node configuration includes both the **attr\_0** and **attr\_1** values. The modification to **attr\_0** in the **bar** node does not affect the **foo** node.
+
+The path of the **foo** node is not required if the **foo** node and the **bar** node are of the same level. Otherwise, the absolute path must be used. For details, see [Modifying a Reference](#section179799204716).
+
+## Deleting a Node or Attribute
+
+You can use the keyword **delete** to delete unnecessary nodes or attributes in the base configuration tree imported by the **include** keyword. In the following example, **sample1.hcs** imports the configuration of **sample2.hcs** using **include**, and deletes the **attribute2** attribute and the **foo\_2** node using the **delete** keyword.
+
+```
+// sample2.hcs
+root {
+ attr_1 = 0x1;
+ attr_2 = 0x2;
+ foo_2 {
+ t = 0x1;
+ }
+}
+
+// sample1.hcs
+#include "sample2.hcs"
+root {
+ attr_2 = delete;
+ foo_2 : delete {
+ }
+}
+```
+
+The following configuration tree is generated:
+
+```
+root {
+ attr_1 = 0x1;
+}
+```
+
+> **NOTE:**
+>The **delete** keyword cannot be used in the same HCS file. It is recommended that you delete unnecessary attributes directly from the configuration source code.
+
+## Referencing an Attribute
+
+To quickly locate the associated node during configuration parsing, you can use the node as the value of the attribute and read the attribute to find the corresponding node. The syntax is as follows:
+
+```
+ attribute = &node;
+```
+
+This syntax indicates that the **attribute** value is a reference to **node**. During code parsing, you can quickly locate the node using this attribute. Example:
+
+```
+node1 {
+ attributes;
+}
+
+node2 {
+ attr_1 = &node1;
+}
+```
+
+## Keyword Template
+
+The **template** keyword is used to generate nodes with strictly consistent syntax, thereby facilitating the traverse and management of nodes of the same type.
+
+If a node is defined using the keyword **template**, its child nodes inherit the node configuration through the double colon operator \(::\). The child nodes can modify but cannot add or delete attributes in **template**. The attributes not defined in the child nodes will use the attributes defined in **template** as the default values. Example:
+
+```
+root {
+ module = "sample";
+ template foo {
+ attr_1 = 0x1;
+ attr_2 = 0x2;
+ }
+
+ bar :: foo {
+ }
+
+ bar_1 :: foo {
+ attr_1 = 0x2;
+ }
+}
+```
+
+The following configuration tree is generated:
+
+```
+root {
+ module = "sample";
+ bar {
+ attr_1 = 0x1;
+ attr_2 = 0x2;
+ }
+ bar_1 {
+ attr_1 = 0x2;
+ attr_2 = 0x2;
+ }
+}
+```
+
+In the preceding example, the **bar** and **bar\_1** nodes inherit the **foo** node. The structures of the generated configuration tree nodes are the same as that of the **foo** node, but the attribute values are different.
+
+## Configuration Generation
+
+The HC-GEN tool is used to generate configurations. It checks the HCS configuration syntax and converts HCS source files into HCB files.
+
+## Introduction to HC-GEN
+
+Parameter description:
+
+```
+Usage: hc-gen [Options] [File]
+options:
+ -o output file name, default same as input
+ -a hcb align with four bytes
+ -b output binary output, default enable
+ -t output config in C language source file style
+ -i output binary hex dump in C language source file style
+ -p prefix of generated symbol name
+ -d decompile hcb to hcs
+ -V show verbose info
+ -v show version
+ -h show this help message
+```
+
+Generate a **.c** or **.h** configuration file.
+
+```
+hc-gen -o [OutputCFileName] -t [SourceHcsFileName]
+```
+
+Generate an HCB file.
+
+```
+hc-gen -o [OutputHcbFileName] -b [SourceHcsFileName]
+```
+
+Compile an **HCB** file to an **HCS** file:
+
+```
+hc-gen -o [OutputHcsFileName] -d [SourceHcbFileName]
+```
+
diff --git a/en/device-dev/driver/drive-hdf-news.md b/en/device-dev/driver/drive-hdf-news.md
new file mode 100644
index 0000000000000000000000000000000000000000..90f70d1aa93f3c0964e923e24b16c9b42c16171a
--- /dev/null
+++ b/en/device-dev/driver/drive-hdf-news.md
@@ -0,0 +1,193 @@
+# Driver Message Mechanism Management
+
+- [When to Use](#section33014541954)
+- [Available APIs](#section538852311616)
+- [How to Develop](#section946912121153)
+
+## When to Use
+
+When user-level applications need to interact with kernel-level drivers, the driver message mechanism of the HDF can be used.
+
+## Available APIs
+
+The message mechanism provides the following features:
+
+1. User-level applications send messages to drivers.
+2. User-level applications receive events sent by the drivers.
+
+**Table 1** APIs for the driver message mechanism
+
+
+
+
+The WLAN driver module provides APIs for driver developers, such as initializing/deregistering, opening/stopping a **NetDevice**, and obtaining the state of a **NetDevice**. [Table 2](#table74613501475) describes some APIs.
+
+**Table 2** APIs for driver developers of WLAN vendors to implement
+
+
+
+
+The WLAN driver provides the HDI layer with the APIs for creating and destroying an **IWiFi** object and setting the MAC address. [Table 3](#table141076311618) describes some APIs.
+
+**Table 3** APIs provided by the WLAN HAL module
+
+
+
Obtains information about all sensors in the system. The information about a sensor generally includes the sensor name, sensor vendor, firmware version, hardware version, sensor type ID, sensor ID, maximum measurement range, accuracy, and power.
+
+
+
Setting
+
+
int32_t Enable(int32_t sensorId)
+
+
Enables the sensor that has been subscribed to. The subscriber can obtain the sensor data only after the sensor is enabled.
+
+The following table lists the APIs provided by the sensor driver model for driver developers. You can directly call these APIs without any implementations.
+
+**Table 2** APIs provided by the sensor driver model for driver developers
+
+
+
Obtains basic configuration information such as sensor, bus, and attribute configurations based on the HCS resource configuration of the sensor device, and initializes the basic configuration data structure.
+
+The following table lists the APIs that need to be implemented by driver developers.
+
+**Table 3** APIs that need to be implemented by driver developers
+
+
+
Category
+
+
API
+
+
Description
+
+
+
+
Basic functions
+
+
int32_t init(void)
+
+
Initializes the configuration of a sensor device after it is detected.
+
+
+
int32_t GetInfo(struct SensorBasicInfo *info)
+
+
Obtains the basic information about the current sensor device from the HCS of sensor devices.
+
+
+
int32_t Enable(void)
+
+
Enables the current sensor device by delivering the register configuration in the operation group based on the HCS of the current sensor device.
+
+
+
int32_t Disable(void)
+
+
Disables the current sensor device by delivering the register configuration in the operation group based on the HCS of the current sensor device.
Sets the processing time of the data reporting thread for the current sensor device based on the data sampling interval and data reporting interval.
+
+
+
int32_t SetMode(int32_t mode)
+
+
Sets the data reporting mode of the current sensor device.
+
+
+
int32_t SetOption(uint32_t option)
+
+
Sets the register configuration such as the measurement range and accuracy based on sensor options.
+
+
+
void ReadSensorData(void)
+
+
Reads sensor data.
+
+
+
+
+
+For details about the API implementation, see [Development Example](#section257750691).
+
+## Development Guidelines
+
+Regardless of the OS and system on a chip \(SoC\), the sensor driver is developed based on the HDF, platform, and OSAL APIs to provide a unified driver model for sensor devices. This section uses the acceleration sensor as an example to describe how to develop a sensor driver.
+
+### How to Develop
+
+1. Register the acceleration sensor driver. The HDF provides a unified driver management model. The HDF identifies and loads the target module driver based on the configuration of the acceleration sensor module.
+2. Initialize and deinitialize the acceleration sensor driver. Using the **init** function, the HDF starts loading the sensor device driver and allocating configuration resources for sensor device data, respectively. Using the **release** function, the HDF releases the resources and configurations loaded by the driver.
+3. Parse the configurations of the acceleration sensor register group. For different types of sensors, you must configure their respective HCS configuration files in the HCS, check whether the sensor device is in position during the device driver startup, and then load the corresponding configuration file to generate the configuration structure object.
+4. Implement APIs for acceleration sensor driver operations. The driver APIs for various types of sensors, such as **init**, **GetInfo**, **Enable**, **Disable**, **SetBatch**, **SetMode**, **SetOption**, and **ReadSensorData**, are normalized to deliver sensor driver configurations and report sensor data.
+
+> **NOTE:**
+>The sensor driver model provides a collection of APIs to implement sensor driver capabilities, including the driver device management, abstract bus and platform operation, general configuration, and configuration parsing capabilities. For details about the APIs, see [Table 2](#table1156812588320). You need to implement the following APIs: some operations to perform on sensors \([Table 3](#table1083014911336)\), differentiated data configuration of the sensor HCS, and verification of basic driver functions.
+
+## Development Example
+
+This section uses a code example to demonstrate how to load and start the acceleration sensor driver based on the HDF driver model. For details about the mechanism, see [Driver Development](drive-hdf-development.md). This example uses the Bosch BMI160 acceleration sensor that communicates over I2C.
+
+1. Register the driver entry of the acceleration sensor.
+
+- Implementation of the entry function
+
+```
+/* Register the entry structure object of the acceleration sensor. */
+struct HdfDriverEntry g_sensorAccelDevEntry = {
+ .moduleVersion = 1, /* Version of the acceleration sensor module */
+ .moduleName = "HDF_SENSOR_ACCEL", /* Name of the acceleration sensor module. The value must be the same as that of moduleName in the device_info.hcs file. */
+ .Bind = BindAccelDriver, /* Binding function of the acceleration sensor */
+ .Init = InitAccelDriver, /* Initialization function of the acceleration sensor */
+ .Release = ReleaseAccelDriver, /* Resource release function of the acceleration sensor */
+};
+
+/* Call HDF_INIT to register the driver entry with the HDF. When loading the driver, the HDF calls the Bind function first and then the Init function. If the Init function fails to be called, the HDF will call Release to release the driver resource and exit.
+HDF_INIT(g_sensorAccelDevEntry);
+```
+
+- Acceleration sensor configuration
+
+The acceleration sensor model uses the HCS as the configuration source code. For details about the HCS configuration fields, see [Driver Configuration Management](drive-hdf-manage.md).
+
+```
+/* HCS configuration of the acceleration sensor device */
+device_sensor_accel :: device {
+ device0 :: deviceNode {
+ policy = 1; /* Policy for providing the driver service */
+ priority = 105; /* Driver startup priority (0–200). A larger value indicates a lower priority. The default value 100 is recommended. The sequence for loading devices with the same priority is random. */
+ preload = 2; /* Field for specifying whether to load the driver. The value 0 means to load the driver, and 2 means the opposite. */
+ permission = 0664; /* Permission for the driver to create device nodes */
+ moduleName = "HDF_SENSOR_ACCEL"; /* Driver name. The value must be the same as that of moduleName in the driver entry structure. */
+ serviceName = "sensor_accel"; /* Name of the service provided by the driver. The name must be unique. */
+ deviceMatchAttr = "hdf_sensor_accel_driver"; /* Keyword matching the private data of the driver. The value must be the same as that of match_attr in the private data configuration table of the driver. */
+ }
+}
+```
+
+1. Initialize and deinitialize the acceleration sensor driver.
+
+- Initialization entry function **init**
+
+```
+/* Bind the service provided by the acceleration sensor driver to the HDF. */
+int32_t BindAccelDriver(struct HdfDeviceObject *device)
+{
+ CHECK_NULL_PTR_RETURN_VALUE(device, HDF_ERR_INVALID_PARAM);
+
+ static struct IDeviceIoService service = {
+ .object = {0},
+ .Dispatch = DispatchAccel,
+ };
+ device->service = &service;
+
+ return HDF_SUCCESS;
+}
+/* After detecting that the device is in position, call RegisterAccelChipOps to register the differentiation adaptation function. */
+int32_t RegisterAccelChipOps(struct AccelOpsCall *ops)
+{
+ struct AccelDrvData *drvData = NULL;
+
+ CHECK_NULL_PTR_RETURN_VALUE(ops, HDF_ERR_INVALID_PARAM);
+
+ drvData = AccelGetDrvData();
+ drvData->ops.Init = ops->Init;
+ drvData->ops.ReadData = ops->ReadData;
+ return HDF_SUCCESS;
+}
+/* Hook the acceleration sensor driver normalization function. */
+static int32_t InitAccelOps(struct SensorDeviceInfo *deviceInfo)
+{
+ struct AccelDrvData *drvData = AccelGetDrvData();
+
+ (void)memset_s((void *)deviceInfo, sizeof(*deviceInfo), 0, sizeof(*deviceInfo));
+ deviceInfo->ops.GetInfo = SetAccelInfo;
+ deviceInfo->ops.Enable = SetAccelEnable;
+ deviceInfo->ops.Disable = SetAccelDisable;
+ deviceInfo->ops.SetBatch = SetAccelBatch;
+ deviceInfo->ops.SetMode = SetAccelMode;
+ deviceInfo->ops.SetOption = SetAccelOption;
+
+ if (memcpy_s(&deviceInfo->sensorInfo, sizeof(deviceInfo->sensorInfo),
+ &drvData->accelCfg->sensorInfo, sizeof(drvData->accelCfg->sensorInfo)) != EOK) {
+ HDF_LOGE("%s: copy sensor info failed", __func__);
+ return HDF_FAILURE;
+ }
+ /* The sensor type ID can be configured in the HCS configuration file or here. */
+ drvData->accelCfg->sensorInfo.sensorTypeId = SENSOR_TAG_ACCELEROMETER;
+ drvData->accelCfg->sensorInfo.sensorId = SENSOR_TAG_ACCELEROMETER;
+
+ return HDF_SUCCESS;
+}
+/* Initialize the sensor register. */
+static int32_t InitAccelAfterConfig(void)
+{
+ struct SensorDeviceInfo deviceInfo;
+
+ if (InitAccelConfig() != HDF_SUCCESS) {
+ HDF_LOGE("%s: init accel config failed", __func__);
+ return HDF_FAILURE;
+ }
+
+ if (InitAccelOps(&deviceInfo) != HDF_SUCCESS) {
+ HDF_LOGE("%s: init accel ops failed", __func__);
+ return HDF_FAILURE;
+ }
+
+ if (AddSensorDevice(&deviceInfo) != HDF_SUCCESS) {
+ HDF_LOGE("%s: add accel device failed", __func__);
+ return HDF_FAILURE;
+ }
+
+ return HDF_SUCCESS;
+}
+/* Call the device detection function to hook the differentiated device function. */
+static int32_t DetectAccelChip(void)
+{
+ int32_t num;
+ int32_t ret;
+ int32_t loop;
+ struct AccelDrvData *drvData = AccelGetDrvData();
+ CHECK_NULL_PTR_RETURN_VALUE(drvData->accelCfg, HDF_ERR_INVALID_PARAM);
+
+ num = sizeof(g_accelDetectIfList) / sizeof(g_accelDetectIfList[0]);
+ for (loop = 0; loop < num; ++loop) {
+ if (g_accelDetectIfList[loop].DetectChip != NULL) {
+ ret = g_accelDetectIfList[loop].DetectChip(drvData->accelCfg);
+ if (ret == HDF_SUCCESS) {
+ drvData->detectFlag = true;
+ break;
+ }
+ }
+ }
+
+ if (loop == num) {
+ HDF_LOGE("%s: detect accel device failed", __func__);
+ drvData->detectFlag = false;
+ return HDF_FAILURE;
+ }
+ return HDF_SUCCESS;
+}
+/* The entry function of the acceleration sensor driver is used to initialize the structure object of the sensor private data, allocate space for the HCS data configuration object of the sensor, invoke the entry function for initializing the sensor HCS data configuration, detect whether the sensor device is in position, create the sensor data reporting timer, implement the sensor normalization API, and register the sensor device. */
+int32_t InitAccelDriver(struct HdfDeviceObject *device)
+{
+ /* Obtain the private data structure object of the sensor. */
+ struct AccelDrvData *drvData = AccelGetDrvData();
+
+ /* When detecting sensors of the same type from different vendors, the function checks whether this type of sensors is in position. If yes, it no longer detects the other sensors of this type and directly returns the result. */
+ if (drvData->detectFlag) {
+ HDF_LOGE("%s: accel sensor have detected", __func__);
+ return HDF_SUCCESS;
+ }
+
+ CHECK_NULL_PTR_RETURN_VALUE(device, HDF_ERR_INVALID_PARAM);
+ /* Allocate space for the private data structure objects for storing sensor data configurations. The allocated space needs to be released when the driver is released. */
+ drvData->accelCfg = (struct SensorCfgData *)OsalMemCalloc(sizeof(*cfg));
+ if (drvData->accelCfg == NULL) {
+ HDF_LOGE("%s: malloc sensor config data failed", __func__);
+ return HDF_FAILURE;
+ }
+
+ drvData->accelCfg->regCfgGroup = &g_regCfgGroup[0];
+ /* Initializing the sensor configuration data aims to parse the configuration information of the sensor communication bus, basic sensor information, sensor attributes, whether the sensor is in position, and register group information. */
+ if (GetSensorBaseConfigData(device->property, drvData->accelCfg) != HDF_SUCCESS) {
+ HDF_LOGE("%s: get sensor base config failed", __func__);
+ goto Base_CONFIG_EXIT;
+ }
+
+ if (DetectAccelChip() != HDF_SUCCESS) {
+ HDF_LOGE("%s: accel sensor detect device no exist", __func__);
+ goto DETECT_CHIP_EXIT;
+ }
+ drvData->detectFlag = true;
+ if (ParseSensorRegConfig(drvData->accelCfg) != HDF_SUCCESS) {
+ HDF_LOGE("%s: detect sensor device failed", __func__);
+ goto REG_CONFIG_EXIT;
+ }
+
+ if (InitAccelAfterConfig() != HDF_SUCCESS) {
+ HDF_LOGE("%s: init accel after config failed", __func__);
+ goto INIT_EXIT;
+ }
+
+ HDF_LOGI("%s: init accel driver success", __func__);
+ return HDF_SUCCESS;
+
+INIT_EXIT:
+ DestroySensorThread(&drvData->thread, &drvData->threadStatus);
+ (void)DeleteSensorDevice(SENSOR_TAG_ACCELEROMETER);
+REG_CONFIG_EXIT:
+ ReleaseSensorAllRegConfig(drvData->accelCfg);
+ (void)ReleaseSensorBusHandle(&drvData->accelCfg->busCfg);
+DETECT_CHIP_EXIT:
+ drvData->detectFlag = false;
+BASE_CONFIG_EXIT:
+ drvData->accelCfg->root = NULL;
+ drvData->accelCfg->regCfgGroup = NULL;
+ OsalMemFree(drvData->accelCfg);
+ drvData->accelCfg = NULL;
+ return HDF_FAILURE;
+}
+
+/* Release the resources allocated during driver initialization. */
+void ReleaseAccelDriver(struct HdfDeviceObject *device)
+{
+ (void)device;
+ struct AccelDrvData *drvData = NULL;
+
+ drvData = AccelGetDrvData();
+ (void)DestroySensorThread(&drvData->thread, &drvData->threadStatus);
+ (void)DeleteSensorDevice(SENSOR_TAG_ACCELEROMETER);
+ drvData->detectFlag = false;
+
+ if (drvData->accelCfg != NULL) {
+ drvData->accelCfg->root = NULL;
+ drvData->accelCfg->regCfgGroup = NULL;
+ ReleaseSensorAllRegConfig(drvData->accelCfg);
+ (void)ReleaseSensorBusHandle(&drvData->accelCfg->busCfg);
+ OsalMemFree(drvData->accelCfg);
+ drvData->accelCfg = NULL;
+ }
+
+ drvData->initStatus = false;
+}
+```
+
+1. Configure the acceleration sensor register group.
+
+You only need to configure the acceleration sensor data according to the template. Template configuration parsing has been implemented via the **InitSensorConfigData** function and only needs to be called during initialization. If new configuration items are added, you need to modify this function accordingly.
+
+```
+Acceleration sensor data configuration template (accel_config.hcs)
+root {
+ sensorAccelConfig {
+ accelChipConfig {
+ /* Sensor information template */
+ template sensorInfo {
+ sensorName = "accelerometer"; /* Acceleration sensor name. The value contains a maximum of 16 bytes. */
+ vendorName = "borsh_bmi160"; /* Sensor vendor name. The value contains a maximum of 16 bytes. */
+ firmwareVersion = "1.0"; /* Sensor firmware version. The default value is 1.0. The value contains a maximum of 16 bytes. */
+ hardwareVersion = "1.0"; /* Sensor hardware version. The default value is 1.0. The value contains a maximum of 16 bytes. */
+ sensorTypeId = 1; /* Sensor type ID. For details, see SensorTypeTag. */
+ sensorId = 1; /* Sensor ID, which is defined by the sensor driver developer. The SensorTypeTag enums are recommended. */
+ maxRange = 8; /* Maximum measurement range of the sensor. Set this parameter based on your business requirements. */
+ precision = 0; /* Sensor accuracy, which is used together with sensor data reporting. For details, see SensorEvents. */
+ power = 230; /* Power consumption of the sensor */
+ }
+ /* Template of the bus type and configuration information used by the sensor */
+ template sensorBusConfig {
+ busType = 0; /* 0:i2c 1:spi */
+ busNum = 6; /* Device ID allocated to the sensor on the chip */
+ busAddr = 0; /* Address allocated to the sensor on the chip */
+ regWidth = 1; /* Width of the sensor register address */
+ regBigEndian = 0; /* Endian mode of the sensor register */
+ }
+ /* Sensor attribute template */
+ template sensorAttr {
+ chipName = ""; /* Sensor chip name */
+ chipIdRegister = 0xf; /* Address of the register detecting whether the sensor is in position */
+ chipIdValue = 0xd1; /* Value of the register detecting whether the sensor is in position */
+ }
+ }
+ }
+}
+
+/* You can modify the template configuration based on the differences of sensor devices. If no modification is made, the default template configuration is used. */
+root {
+ sensorAccelConfig {
+ accel_bmi160_chip_config : accelChipConfig {
+ match_attr = "hdf_sensor_accel_driver"; /* The value must be the same as the match_attr field configured for the acceleration sensor. */
+ accelInfo :: sensorInfo {
+ vendorName = "borsh_bmi160";
+ sensorTypeId = 1;
+ sensorId = 1;
+ }
+ accelBusConfig :: sensorBusConfig {
+ busType = 0; /* I2C communication mode */
+ busNum = 6;
+ busAddr = 0x68;
+ regWidth = 1; /* 1-byte bit width */
+ }
+ accelAttr :: sensorAttr {
+ chipName = "bmi160";
+ chipIdRegister = 0x00;
+ chipIdValue = 0xd1;
+ }
+ accelRegConfig {
+ /* regAddr: Register address
+ value: Register value
+ mask: Mask of the register value
+ len: Length (in bytes) of the register value
+ delay: Register delay (in milliseconds)
+ opsType: Operation type. The options can be 0 (no operation), 1 (read), 2 (write), 3 (read and check), and 4 (bit update).
+ calType: Calculation type. The options can be 0 (none), 1 (write), 2 (negate), 3 (XOR) 4, (left shift), and 5 (right shift).
+ shiftNum: Number of shifts
+ debug: Debugging switch. The value can be 0 (disabled) or 1 (enabled).
+ save: Data saving switch. The value can be 0 (not save data) or 1 (save data).
+ */
+ /* Groups of sensor register operations. Registers can be configured in sequence based on the groups. */
+ /* Register address, register value, mask of the register value, data length of the register value, register delay, operation type, calculation type, number of shifts, debugging switch, data saving switch */
+ /* Initialize the register groups. */
+ initSeqConfig = [
+ 0x7e, 0xb6, 0xff, 1, 5, 2, 0, 0, 0, 0,
+ 0x7e, 0x10, 0xff, 1, 5, 2, 0, 0, 0, 0
+ ];
+ /* Enable the register groups. */
+ enableSeqConfig = [
+ 0x7e, 0x11, 0xff, 1, 5, 2, 0, 0, 0, 0,
+ 0x41, 0x03, 0xff, 1, 0, 2, 0, 0, 0, 0,
+ 0x40, 0x08, 0xff, 1, 0, 2, 0, 0, 0, 0
+ ];
+ /* Disable the register groups. */
+ disableSeqConfig = [
+ 0x7e, 0x10, 0xff, 1, 5, 2, 0, 0, 0, 0
+ ];
+ }
+ }
+ }
+}
+```
+
+1. Implement APIs for acceleration sensor driver operations.
+
+You need to implement normalized APIs based on sensor types.
+
+```
+/* Leave a function empty if it is not used. */
+static int32_t SetAccelInfo(struct SensorBasicInfo *info)
+{
+ (void)info;
+
+ return HDF_ERR_NOT_SUPPORT;
+}
+/* Deliver the configuration of enabling the register groups. */
+static int32_t SetAccelEnable(void)
+{
+ int32_t ret;
+ struct AccelDrvData *drvData = AccelGetDrvData();
+
+ CHECK_NULL_PTR_RETURN_VALUE(drvData->accelCfg, HDF_ERR_INVALID_PARAM);
+ ret = SetSensorRegCfgArray(&drvData->accelCfg->busCfg, drvData->accelCfg->regCfgGroup[SENSOR_ENABLE_GROUP]);
+ if (ret != HDF_SUCCESS) {
+ HDF_LOGE("%s: accel sensor disable config failed", __func__);
+ return HDF_FAILURE;
+ }
+
+ drvData->threadStatus = SENSOR_THREAD_RUNNING;
+
+ return HDF_SUCCESS;
+}
+/* Deliver the configuration of disabling the register groups. */
+static int32_t SetAccelDisable(void)
+{
+ int32_t ret;
+ struct AccelDrvData *drvData = AccelGetDrvData();
+
+ CHECK_NULL_PTR_RETURN_VALUE(drvData->accelCfg, HDF_ERR_INVALID_PARAM);
+
+ ret = SetSensorRegCfgArray(&drvData->accelCfg->busCfg, drvData->accelCfg->regCfgGroup[SENSOR_DISABLE_GROUP]);
+ if (ret != HDF_SUCCESS) {
+ HDF_LOGE("%s: accel sensor disable config failed", __func__);
+ return HDF_FAILURE;
+ }
+
+ drvData->threadStatus = SENSOR_THREAD_STOPPED;
+
+ return HDF_SUCCESS;
+}
+/* Set the sampling interval and data reporting interval of the sensor. */
+static int32_t SetAccelBatch(int64_t samplingInterval, int64_t interval)
+{
+ (void)interval;
+
+ struct AccelDrvData *drvData = AccelGetDrvData();
+ drvData->interval = samplingInterval;
+
+ return HDF_SUCCESS;
+}
+/* Set the data reporting mode of the sensor. Currently, the real-time mode is supported. */
+static int32_t SetAccelMode(int32_t mode)
+{
+ return (mode == SENSOR_WORK_MODE_REALTIME) ? HDF_SUCCESS : HDF_FAILURE;
+}
+/* Set the sensor options. */
+static int32_t SetAccelOption(uint32_t option)
+{
+ (void)option;
+ return HDF_ERR_NOT_SUPPORT;
+}
+```
+
+- Differentiated processing APIs
+
+ ```
+ /* If a device is detected, register the differentiated processing function to the accel driver model. */
+ int32_t DetectAccelBim160Chip(struct SensorCfgData *data)
+ {
+ int32_t ret;
+ struct AccelOpsCall ops;
+ CHECK_NULL_PTR_RETURN_VALUE(data, HDF_ERR_INVALID_PARAM);
+
+ if (strcmp(ACCEL_CHIP_NAME_BMI160, data->sensorAttr.chipName) != 0) {
+ return HDF_SUCCESS;
+ }
+ ret = InitAccelPreConfig();
+ if (ret != HDF_SUCCESS) {
+ HDF_LOGE("%s: init BMI160 bus mux config", __func__);
+ return HDF_FAILURE;
+ }
+ if (DetectSensorDevice(data) != HDF_SUCCESS) {
+ return HDF_FAILURE;
+ }
+
+ /* Differentiated processing function */
+ ops.Init = InitBmi160;
+ ops.ReadData = ReadBmi160Data;
+ ret = RegisterAccelChipOps(&ops);
+ if (ret != HDF_SUCCESS) {
+ HDF_LOGE("%s: register BMI160 accel failed", __func__);
+ (void)ReleaseSensorBusHandle(&data->busCfg);
+ return HDF_FAILURE;
+ }
+ return HDF_SUCCESS;
+ }
+ /* Initialization processing function */
+ static int32_t InitBmi160(struct SensorCfgData *data)
+ {
+ int32_t ret;
+
+ CHECK_NULL_PTR_RETURN_VALUE(data, HDF_ERR_INVALID_PARAM);
+ ret = SetSensorRegCfgArray(&data->busCfg, data->regCfgGroup[SENSOR_INIT_GROUP]);
+ if (ret != HDF_SUCCESS) {
+ HDF_LOGE("%s: bmi160 sensor init config failed", __func__);
+ return HDF_FAILURE;
+ }
+ return HDF_SUCCESS;
+ }
+ /* Data processing function */
+ int32_t ReadBmi160Data(struct SensorCfgData *data)
+ {
+ int32_t ret;
+ struct AccelData rawData = { 0, 0, 0 };
+ int32_t tmp[ACCEL_AXIS_NUM];
+ struct SensorReportEvent event;
+
+ (void)memset_s(&event, sizeof(event), 0, sizeof(event));
+
+ ret = ReadBmi160RawData(data, &rawData, &event.timestamp);
+ if (ret != HDF_SUCCESS) {
+ return HDF_FAILURE;
+ }
+
+ event.sensorId = SENSOR_TAG_ACCELEROMETER;
+ event.option = 0;
+ event.mode = SENSOR_WORK_MODE_REALTIME;
+
+ rawData.x = rawData.x * BMI160_ACC_SENSITIVITY_2G;
+ rawData.y = rawData.y * BMI160_ACC_SENSITIVITY_2G;
+ rawData.z = rawData.z * BMI160_ACC_SENSITIVITY_2G;
+
+ tmp[ACCEL_X_AXIS] = (rawData.x * SENSOR_1K_UNIT) / SENSOR_CONVERT_UNIT;
+ tmp[ACCEL_Y_AXIS] = (rawData.y * SENSOR_1K_UNIT) / SENSOR_CONVERT_UNIT;
+ tmp[ACCEL_Z_AXIS] = (rawData.z * SENSOR_1K_UNIT) / SENSOR_CONVERT_UNIT;
+
+ event.dataLen = sizeof(tmp);
+ event.data = (uint8_t *)&tmp;
+ ret = ReportSensorEvent(&event);
+ return ret;
+ }
+ ```
+
+- Data processing function
+
+Create a sensor timer to periodically sample data based on the configured sampling interval and report the data to the data subscriber.
+
+```
+/* Scheduled working thread of the sensor */
+static int32_t ReadAccelDataThreadWorker(void *arg)
+{
+ (void)arg;
+ int64_t interval;
+ struct AccelDrvData *drvData = AccelGetDrvData();
+
+ drvData->threadStatus = SENSOR_THREAD_START;
+ while (true) {
+ if (drvData->threadStatus == SENSOR_THREAD_RUNNING) {
+ if (drvData->ops.ReadData != NULL) {
+ (void)drvData->ops.ReadData(drvData->accelCfg);
+ }
+ interval = OsalDivS64(drvData->interval, (SENSOR_CONVERT_UNIT * SENSOR_CONVERT_UNIT));
+ OsalMSleep(interval);
+ } else if (drvData->threadStatus == SENSOR_THREAD_DESTROY) {
+ break;
+ } else {
+ OsalMSleep(ACC_DEFAULT_SAMPLING_200_MS / SENSOR_CONVERT_UNIT / SENSOR_CONVERT_UNIT);
+ }
+
+ if ((!drvData->initStatus) || (drvData->interval < 0) || drvData->threadStatus != SENSOR_THREAD_RUNNING) {
+ continue;
+ }
+ }
+
+ return HDF_SUCCESS;
+}
+/* Create a sensor timer and initialize the sensor device. */
+static int32_t InitAccelConfig(void)
+{
+ int32_t ret;
+ struct AccelDrvData *drvData = AccelGetDrvData();
+
+ if (drvData->threadStatus != SENSOR_THREAD_NONE && drvData->threadStatus != SENSOR_THREAD_DESTROY) {
+ HDF_LOGE("%s: accel thread have created", __func__);
+ return HDF_SUCCESS;
+ }
+
+ ret = CreateSensorThread(&drvData->thread, ReadAccelDataThreadWorker, "hdf_sensor_accel", drvData);
+ if (ret != HDF_SUCCESS) {
+ HDF_LOGE("%s: accel create thread failed", __func__);
+ drvData->threadStatus = SENSOR_THREAD_NONE;
+ return HDF_FAILURE;
+ }
+
+ CHECK_NULL_PTR_RETURN_VALUE(drvData->ops.Init, HDF_ERR_INVALID_PARAM);
+
+ ret = drvData->ops.Init(drvData->accelCfg);
+ if (ret != HDF_SUCCESS) {
+ HDF_LOGE("%s: accel create thread failed", __func__);
+ drvData->threadStatus = SENSOR_THREAD_NONE;
+ return HDF_FAILURE;
+ }
+ drvData->initStatus = true;
+ return HDF_SUCCESS;
+}
+```
+
+- Major data structures
+
+```
+/* Sensor conversion units */
+#define SENSOR_CONVERT_UNIT 1000
+#define SENSOR_1K_UNIT 1024
+/* Sensitivity conversion value of the sensor with a 2g measurement range */
+#define BMI160_ACC_SENSITIVITY_2G 61
+/* Address of the sensor data sampling register */
+#define BMI160_ACCEL_X_LSB_ADDR 0X12
+#define BMI160_ACCEL_X_MSB_ADDR 0X13
+#define BMI160_ACCEL_Y_LSB_ADDR 0X14
+#define BMI160_ACCEL_Y_MSB_ADDR 0X15
+#define BMI160_ACCEL_Z_LSB_ADDR 0X16
+#define BMI160_ACCEL_Z_MSB_ADDR 0X17
+/* Data dimension of the sensor */
+enum AccelAxisNum {
+ ACCEL_X_AXIS = 0,
+ ACCEL_Y_AXIS = 1,
+ ACCEL_Z_AXIS = 2,
+ ACCEL_AXIS_NUM = 3,
+};
+/* Each dimension of the sensor */
+struct AccelData {
+ int32_t x;
+ int32_t y;
+ int32_t z;
+};
+/* Private data structure of the sensor */
+struct AccelDrvData {
+ bool detectFlag;
+ uint8_t threadStatus;
+ uint8_t initStatus;
+ int64_t interval;
+ struct SensorCfgData *accelCfg;
+ struct OsalThread thread;
+ struct AccelOpsCall ops;
+};
+/* Differentiation adaptation function */
+struct AccelOpsCall {
+ int32_t (*Init)(struct SensorCfgData *data);
+ int32_t (*ReadData)(struct SensorCfgData *data);
+};
+```
+
+## Test Guidelines
+
+After the driver is developed, you can develop self-test cases in the sensor unit test to verify the basic functions of the driver. The developer self-test platform is used as the test environment.
+
+```
+/* Specify whether to report sensor data. */
+static int32_t g_sensorDataFlag = 0;
+/* Retain the address of the sensor interface instance. */
+static const struct SensorInterface *g_sensorDev = nullptr;
+
+/* Register the data reporting function. */
+static int SensorTestDataCallback(struct SensorEvents *event)
+{
+ if (event == nullptr) {
+ return -1;
+ }
+ float *data = (float*)event->data;
+ printf("time [%lld] sensor id [%d] x-[%f] y-[%f] z-[%f]\n\r", event->timestamp,
+ event->sensorId, (*data), *(data + 1), *(data + g_axisZ));
+ if (*data > 1e-5) {
+ g_sensorDataFlag = 1;
+ }
+ return 0;
+}
+/* Initialize the sensor interface instance before executing the test cases. */
+void HdfSensorTest::SetUpTestCase()
+{
+ g_sensorDev = NewSensorInterfaceInstance();
+ if (g_sensorDev == nullptr) {
+ printf("test sensorHdi get Module instace failed\n\r");
+ }
+}
+/* Release case resources. */
+void HdfSensorTest::TearDownTestCase()
+{
+ if (g_sensorDev != nullptr) {
+ FreeSensorInterfaceInstance();
+ g_sensorDev = nullptr;
+ }
+}
+/* Verify the sensor driver. */
+HWTEST_F(HdfSensorTest,TestAccelDriver_001, TestSize.Level0)
+{
+ int32_t sensorInterval = 1000000000; /* Data sampling interval, in nanoseconds */
+ int32_t pollTime = 5; /* Data sampling duration, in seconds */
+ int32_t accelSensorId = 1; /* Acceleration sensor type ID, which is 1 */
+ int32_t count = 0;
+ int ret;
+ struct SensorInformation *sensorInfo = nullptr;
+
+ ret = g_sensorDev->Register(SensorTestDataCallback)
+ EXPECT_EQ(SENSOR_NULL_PTR, ret);
+
+ ret = g_sensorDev->GetAllSensors(&sensorInfo, &count);
+ EXPECT_EQ(0, ret);
+ if (sensorInfo == nullptr) {
+ EXPECT_NE(nullptr, sensorInfo);
+ return;
+ }
+ /* Print the obtained sensor list. */
+ for (int i = 0; i < count; i++) {
+ printf("get sensoriId[%d], info name[%s]\n\r", sensorInfo[i]->sensorId, sensorInfo[i]->sensorName);
+ }
+ ret = g_sensorDev->Enable(accelSensorId);
+ EXPECT_EQ(0, ret);
+ g_sensorDataFlag = 0;
+
+ ret = g_sensorDev->SetBatch(accelSensorId, sensorInterval, pollTime);
+ EXPECT_EQ(0, ret);
+ /* Observe the printed data within the period specified by pollTime. */
+ OsalSleep(pollTime);
+ EXPECT_EQ(1, g_sensorDataFlag);
+
+ ret = g_sensorDev->Disable(accelSensorId);
+ g_sensorDataFlag = 0;
+ EXPECT_EQ(0, ret);
+
+ ret = g_sensorDev->Unregister();
+ EXPECT_EQ(0, ret);
+}
+```
+
diff --git a/en/device-dev/driver/drive-peripherals-touch-des.md b/en/device-dev/driver/drive-peripherals-touch-des.md
new file mode 100644
index 0000000000000000000000000000000000000000..274355990ed1ba5a507fee12cb95c853d772dc60
--- /dev/null
+++ b/en/device-dev/driver/drive-peripherals-touch-des.md
@@ -0,0 +1,410 @@
+# TOUCHSCREEN
+
+- [Overview](#section175431838101617)
+ - [Available APIs](#section17667171301711)
+
+- [Development Guidelines](#section65745222184)
+ - [How to Develop](#section865734181916)
+
+- [Development Example](#section263714411191)
+ - [Add the touchscreen driver-related descriptions.](#section18249155619195)
+ - [Board-level Hardware Configuration and Private Data Configuration](#section3571192072014)
+ - [Adding the Touchscreen Driver](#section6356758162015)
+
+
+## Overview
+
+- **Functions of the Touchscreen driver**
+
+ The Touchscreen driver is used to power on its integrated circuit \(IC\), configure and initialize hardware pins, register interrupts, configure Inter-Integrated Circuit \(I2C\) or SPI APIs, set input-related configurations, and download and update firmware.
+
+
+- **Layers of the Touchscreen driver**
+
+ This section describes how to develop the touchscreen driver based on the input driver model. [Figure 1](#fig6251184817261) shows an overall architecture of the touchscreen driver.
+
+ The input driver is developed based on the hardware driver foundation \(HDF\), platform APIs, and operating system abstraction layer \(OSAL\) APIs. It provides hardware driver capabilities through the input Hardware Driver Interfaces \(HDIs\) for upper-layer input services to control the touchscreen.
+
+
+**Figure 1** Architecture of the input driver model
+
+
+- **Input driver model**
+
+ The input driver model mainly consists of the device manager, common drivers, and chip drivers. The platform data channel provides capabilities for sending data generated by the touchscreen from the kernel to the user space. The driver model adapts to different touchscreen devices and hardware platforms via the configuration file, improving the efficiency of the touchscreen development. The description for each part of the input driver model is as follows:
+
+ - Input device manager: provides input device drivers with the APIs for registering or unregistering input devices and manages the input device list.
+
+ - Input common driver: provides common abstract drivers \(such as the touchscreen common driver\) of various input devices for initializing the board-level hardware, processing hardware interrupts, and registering input devices with the input device manager.
+
+ - Input chip driver: provides different chip drivers of each vendor. You can minimize the workload for the input chip driver development by calling differentiated APIs reserved by the input platform driver.
+
+ - Event hub: provides a unified data reporting channel, which enables input devices to report input events.
+
+ - HDF input config: parses and manages the board-level configuration as well as the private configuration of input devices.
+
+
+- **Advantages of developing drivers based on the HDF**
+
+ The touchscreen driver is developed based on the [HDF](drive-hdf-development.md) and is implemented via calls to the OSAL and platform APIs, including bus APIs and OS native APIs \(such as memory, lock, thread, and timer\). The OSAL and platform APIs hide the differences of underlying hardware, so that the touchscreen driver can be migrated across platforms and OSs. In this regard, you can develop the touchscreen driver only once but deploy it on multiple devices.
+
+
+### Available APIs
+
+Based on the attributes of the pins, interfaces on the touchscreens can be classified into the following types:
+
+- Power interfaces
+- I/O control interfaces
+- Communications interfaces
+
+**Figure 2** Common pins of the touchscreen
+
+
+The interfaces shown in the figure are described as follows:
+
+1. **Power interfaces**
+ - LDO\_1P8: 1.8 V digital circuits
+ - LDO\_3P3: 3.3 V analog circuits
+
+ Generally, the touchscreen driver IC is separated from the LCD driver IC. In this case, the touchscreen driver IC requires both 1.8 V and 3.3 V power supplies. Nowadays, the touchscreen driver IC and LCD driver IC can be integrated. Therefore, the touchscreen, requires only the 1.8 V power supply, and the 3.3 V power required internally is supplied by the LCD VSP power \(typical value: 5.5 V\) in the driver IC.
+
+
+2. **I/O control interfaces**
+ - RESET: reset pin, which is used to reset the driver IC on the host when suspending or resuming the system.
+ - INT: interrupt pin, which needs to be set to the input direction and pull-up status during driver initialization. After detecting an external touch signal, the driver triggers the interrupt by operating the interrupt pin. The driver reads the touch reporting data in the ISR function.
+
+3. **Communications interfaces**
+ - I2C: Since only a small amount of touch data is reported by the touchscreen, I2C is used to transmit the reported data. For details about the I2C protocol and interfaces, see [I2C](drive-platform-i2c-des.md#section1695201514281).
+ - SPI: In addition to touch reporting data coordinates, some vendors need to obtain basic capacitance data. Therefore, Serial Peripheral Interface \(SPI\) is used to transmit such huge amount of data. For details about the SPI protocol and interfaces, see [SPI](drive-platform-spi-des.md#section71363452477).
+
+
+## Development Guidelines
+
+Regardless of the OS and system on a chip \(SoC\), the input driver is developed based on the HDF, platform, and OSAL APIs to provide a unified driver model for touchscreen devices.
+
+- The following uses the touchscreen driver as an example to describe the loading process of the input driver model:
+
+ \(1\) Complete the device description configuration, such as the loading priority, board-level hardware information, and private data, by referring to the existing template.
+
+ \(2\) Load the input device management driver. The input management driver is loaded automatically by the HDF to create and initialize the device manager.
+
+ \(3\) Load the platform driver. The platform driver is loaded automatically by the HDF to parse the board-level configuration, initialize the hardware, and provide the API for registering the touchscreen.
+
+ \(4\) Load the touchscreen driver. The touchscreen driver is loaded automatically by the HDF to instantiate the touchscreen device, parse the private data, and implement differentiated APIs provided by the platform.
+
+ \(5\) Register the instantiated touchscreen device with the platform driver. Then bind this device to the platform driver, and complete touchscreen initialization such as interrupt registration and power-on and power-off.
+
+ \(6\) Instantiate the input device and register it with the input manager after the touchscreen is initialized.
+
+
+### How to Develop
+
+1. Add the touchscreen driver-related descriptions.
+
+ Currently, the input driver is developed based on the HDF and is loaded and started by the HDF. Register the driver information, such as whether to load the driver and the loading priority in the configuration file. Then, the HDF starts the registered driver modules one by one. For details about the driver configuration, see [Driver Development](drive-hdf-development.md#section1969312275533).
+
+2. Complete the board-level configuration and private data configuration of the touchscreen.
+
+ Configure the required I/O pins. For example, configure a register for the I2C pin reserved for the touchscreen to use I2C for transmitting data.
+
+3. Implement differentiated adaptation APIs of the touchscreen.
+
+ Use the platform APIs to perform operations for the reset pins, interrupt pins, and power based on the communications interfaces designed for boards. For details about the GPIO-related operations, see [GPIO](drive-platform-gpio-des.md#section259614242196).
+
+
+## Development Example
+
+This example describes how to develop the touchscreen driver.
+
+### Add the touchscreen driver-related descriptions.
+
+The information about modules of the input driver model is shown as follows and enables the HDF to load the modules in sequence. For details, see [Driver Development](drive-hdf-development.md).
+
+```
+input :: host {
+ hostName = "input_host";
+ priority = 100;
+ device_input_manager :: device {
+ device0 :: deviceNode {
+ policy = 2; // Publish services externally.
+ priority = 100; // Loading priority. The input device manager in the input driver has the highest priority.
+ preload = 0; // Value 0 indicates that the driver is to be loaded, and value 1 indicates the opposite.
+ permission = 0660;
+ moduleName = "HDF_INPUT_MANAGER";
+ serviceName = "input_dev_manager";
+ deviceMatchAttr = "";
+ }
+ }
+ device_hdf_touch :: device {
+ device0 :: deviceNode {
+ policy = 2;
+ priority = 120;
+ preload = 0;
+ permission = 0660;
+ moduleName = "HDF_TOUCH";
+ serviceName = "event1";
+ deviceMatchAttr = "touch_device1";
+ }
+ }
+
+ device_touch_chip :: device {
+ device0 :: deviceNode {
+ policy = 0;
+ priority = 130;
+ preload = 0;
+ permission = 0660;
+ moduleName = "HDF_TOUCH_SAMPLE";
+ serviceName = "hdf_touch_sample_service";
+ deviceMatchAttr = "zsj_sample_5p5";
+ }
+ }
+}
+```
+
+### Board-level Hardware Configuration and Private Data Configuration
+
+The following describes the configuration of the board-level hardware and private data of the touchscreen. You can modify the configuration based on service requirements.
+
+```
+root {
+ input_config {
+ touchConfig {
+ touch0 {
+ boardConfig {
+ match_attr = "touch_device1";
+ inputAttr {
+ inputType = 0; // Value 0 indicates that the input device is a touchscreen.
+ solutionX = 480;
+ solutionY = 960;
+ devName = "main_touch"; // Device name
+ }
+ busConfig {
+ busType = 0; // Value 0 indicates the I2C bus.
+ busNum = 6;
+ clkGpio = 86;
+ dataGpio = 87;
+ i2cClkIomux = [0x114f0048, 0x403]; // Register configuration of the i2c_clk pin
+ i2cDataIomux = [0x114f004c, 0x403]; // Register configuration of the i2c_data pin
+ }
+ pinConfig {
+ rstGpio = 3;
+ intGpio = 4;
+ rstRegCfg = [0x112f0094, 0x400]; // Register configuration of the reset pin
+ intRegCfg = [0x112f0098, 0x400]; // Register configuration of the interrupt pin
+ }
+ powerConfig {
+ vccType = 2; // Values 1, 2, and 3 indicate the low-dropout regulator (LDO), GPIO, and PMIC, respectively.
+ vccNum = 20; // The GPIO number is 20.
+ vccValue = 1800; // The voltage amplitude is 1800 mV.
+ vciType = 1;
+ vciNum = 12;
+ vciValue = 3300;
+ }
+ featureConfig {
+ capacitanceTest = 0;
+ gestureMode = 0;
+ gloverMOde = 0;
+ coverMode = 0;
+ chargerMode = 0;
+ knuckleMode = 0;
+ }
+ }
+ chipConfig {
+ template touchChip {
+ match_attr = "";
+ chipName = "sample";
+ vendorName = "zsj";
+ chipInfo = "AAAA11222"; // The first four characters indicate the product name. The fifth and sixth characters indicate the IC model. The last three characters indicate the chip model.
+ busType = 0;
+ deviceAddr = 0x5D;
+ irqFlag = 2; // Values 1 and 2 indicate that the interrupt is triggered on the rising and falling edges, respectively. Values 4 and 8 indicate that the interrupt is triggered by the high and low levels, respectively.
+ maxSpeed = 400;
+ chipVersion = 0;
+ powerSequence {
+ /* Power-on sequence is described as follows:
+ [Type, status, direction, delay]
+ Value 0 indicates the power or pin is empty. Values 1 and 2 indicate the VCC (1.8 V) and VCI (3.3 V) power, respectively. Values 3 and 4 indicate the reset and interrupt pins, respectively.
+ Values 0 and 1 indicate the power-off or pull-down, and the power-on or pull-up, respectively. Value 2 indicates that no operation is performed.
+ Values 0 and 1 indicate the input and output directions, respectively. Value 2 indicates that no operation is performed.
+ Delay time, in milliseconds.
+ */
+ powerOnSeq = [4, 0, 1, 0,
+ 3, 0, 1, 10,
+ 3, 1, 2, 60,
+ 4, 2, 0, 0];
+ suspendSeq = [3, 0, 2, 10];
+ resumeSeq = [3, 1, 2, 10];
+ powerOffSeq = [3, 0, 2, 10,
+ 1, 0, 2, 20];
+ }
+ }
+ chip0 :: touchChip {
+ match_attr = "zsj_sample_5p5";
+ chipInfo = "ZIDN45100";
+ chipVersion = 0;
+ }
+ }
+ }
+ }
+ }
+}
+```
+
+### Adding the Touchscreen Driver
+
+The following example shows how to implement the differentiated APIs provided by the platform driver to obtain and parse the touchscreen data. You can adjust the development process based on the board and touchscreen in use.
+
+```
+/* Parse the touch reporting data read from the touchscreen into coordinates. */
+static void ParsePointData(ChipDevice *device, FrameData *frame, uint8_t *buf, uint8_t pointNum)
+{
+ int32_t resX = device->driver->boardCfg->attr.resolutionX;
+ int32_t resY = device->driver->boardCfg->attr.resolutionY;
+
+ for (int32_t i = 0; i < pointNum; i++) {
+ frame->fingers[i].y = (buf[GT_POINT_SIZE * i + GT_X_LOW] & ONE_BYTE_MASK) |
+ ((buf[GT_POINT_SIZE * i + GT_X_HIGH] & ONE_BYTE_MASK) << ONE_BYTE_OFFSET);
+ frame->fingers[i].x = (buf[GT_POINT_SIZE * i + GT_Y_LOW] & ONE_BYTE_MASK) |
+ ((buf[GT_POINT_SIZE * i + GT_Y_HIGH] & ONE_BYTE_MASK) << ONE_BYTE_OFFSET);
+ frame->fingers[i].valid = true;
+ }
+}
+/* Obtain the touch reporting data from the chip. */
+static int32_t ChipDataHandle(ChipDevice *device)
+{
+ int32_t ret;
+ uint8_t touchStatus = 0;
+ uint8_t pointNum;
+ uint8_t buf[GT_POINT_SIZE * MAX_SUPPORT_POINT] = {0};
+ InputI2cClient *i2cClient = &device->driver->i2cClient;
+ uint8_t reg[GT_ADDR_LEN] = {0};
+ FrameData *frame = &device->driver->frameData;
+ reg[0] = (GT_BUF_STATE_ADDR >> ONE_BYTE_OFFSET) & ONE_BYTE_MASK;
+ reg[1] = GT_BUF_STATE_ADDR & ONE_BYTE_MASK;
+ ret = InputI2cRead(i2cClient, reg, GT_ADDR_LEN, &touchStatus, 1);
+ if (ret < 0 || touchStatus == GT_EVENT_INVALID) {
+ return HDF_FAILURE;
+ }
+ OsalMutexLock(&device->driver->mutex);
+ (void)memset_s(frame, sizeof(FrameData), 0, sizeof(FrameData));
+ if (touchStatus == GT_EVENT_UP) {
+ frame->realPointNum = 0;
+ frame->definedEvent = TOUCH_UP;
+ goto exit;
+ }
+ reg[0] = (GT_X_LOW_BYTE_BASE >> ONE_BYTE_OFFSET) & ONE_BYTE_MASK;
+ reg[1] = GT_X_LOW_BYTE_BASE & ONE_BYTE_MASK;
+ pointNum = touchStatus & GT_FINGER_NUM_MASK;
+ if (pointNum <= 0 || pointNum > MAX_SUPPORT_POINT) {
+ HDF_LOGE("%s: pointNum is invalid, %d", __func__, pointNum);
+ (void)ChipCleanBuffer(i2cClient);
+ OsalMutexUnlock(&device->driver->mutex);
+ return HDF_FAILURE;
+ }
+ frame->realPointNum = pointNum;
+ frame->definedEvent = TOUCH_DOWN;
+ /* Read the touch reporting data from the register. */
+ (void)InputI2cRead(i2cClient, reg, GT_ADDR_LEN, buf, GT_POINT_SIZE * pointNum);
+ /* Parse the touch reporting data. */
+ ParsePointData(device, frame, buf, pointNum);
+exit:
+ OsalMutexUnlock(&device->driver->mutex);
+ if (ChipCleanBuffer(i2cClient) != HDF_SUCCESS) {
+ return HDF_FAILURE;
+ }
+ return HDF_SUCCESS;
+}
+
+static struct TouchChipOps g_sampleChipOps = {
+ .Init = ChipInit,
+ .Detect = ChipDetect,
+ .Resume = ChipResume,
+ .Suspend = ChipSuspend,
+ .DataHandle = ChipDataHandle,
+};
+
+static TouchChipCfg *ChipConfigInstance(struct HdfDeviceObject *device)
+{
+ TouchChipCfg *chipCfg = (TouchChipCfg *)OsalMemAlloc(sizeof(TouchChipCfg));
+ if (chipCfg == NULL) {
+ HDF_LOGE("%s: instance chip config failed", __func__);
+ return NULL;
+ }
+ (void)memset_s(chipCfg, sizeof(TouchChipCfg), 0, sizeof(TouchChipCfg));
+ /* Parse the private configuration of the touchscreen. */
+ if (ParseTouchChipConfig(device->property, chipCfg) != HDF_SUCCESS) {
+ HDF_LOGE("%s: parse chip config failed", __func__);
+ OsalMemFree(chipCfg);
+ chipCfg = NULL;
+ }
+ return chipCfg;
+}
+
+static ChipDevice *ChipDeviceInstance(void)
+{
+ ChipDevice *chipDev = (ChipDevice *)OsalMemAlloc(sizeof(ChipDevice));
+ if (chipDev == NULL) {
+ HDF_LOGE("%s: instance chip device failed", __func__);
+ return NULL;
+ }
+ (void)memset_s(chipDev, sizeof(ChipDevice), 0, sizeof(ChipDevice));
+ return chipDev;
+}
+
+static void FreeChipConfig(TouchChipCfg *config)
+{
+ if (config->pwrSeq.pwrOn.buf != NULL) {
+ OsalMemFree(config->pwrSeq.pwrOn.buf);
+ }
+ if (config->pwrSeq.pwrOff.buf != NULL) {
+ OsalMemFree(config->pwrSeq.pwrOff.buf);
+ }
+ OsalMemFree(config);
+}
+
+static int32_t HdfSampleChipInit(struct HdfDeviceObject *device)
+{
+ TouchChipCfg *chipCfg = NULL;
+ ChipDevice *chipDev = NULL;
+ HDF_LOGE("%s: enter", __func__);
+ if (device == NULL) {
+ return HDF_ERR_INVALID_PARAM;
+ }
+ /* Parse the private configuration of the touchscreen. */
+ chipCfg = ChipConfigInstance(device);
+ if (chipCfg == NULL) {
+ return HDF_ERR_MALLOC_FAIL;
+ }
+ /* Instantiate the touchscreen device. */
+ chipDev = ChipDeviceInstance();
+ if (chipDev == NULL) {
+ goto freeCfg;
+ }
+ chipDev->chipCfg = chipCfg;
+ chipDev->ops = &g_sampleChipOps;
+ chipDev->chipName = chipCfg->chipName;
+ chipDev->vendorName = chipCfg->vendorName;
+
+ /* Register the touchscreen device with the platform driver. */
+ if (RegisterChipDevice(chipDev) != HDF_SUCCESS) {
+ goto freeDev;
+ }
+ HDF_LOGI("%s: exit succ, chipName = %s", __func__, chipCfg->chipName);
+ return HDF_SUCCESS;
+
+freeDev:
+ OsalMemFree(chipDev);
+freeCfg:
+ FreeChipConfig(chipCfg);
+ return HDF_FAILURE;
+}
+
+struct HdfDriverEntry g_touchSampleChipEntry = {
+ .moduleVersion = 1,
+ .moduleName = "HDF_TOUCH_SAMPLE",
+ .Init = HdfSampleChipInit,
+};
+
+HDF_INIT(g_touchSampleChipEntry);
+```
+
diff --git a/en/device-dev/driver/drive-peripherals.md b/en/device-dev/driver/drive-peripherals.md
new file mode 100644
index 0000000000000000000000000000000000000000..074c08226b900cad58231e574606428049bd8224
--- /dev/null
+++ b/en/device-dev/driver/drive-peripherals.md
@@ -0,0 +1,11 @@
+# Peripherals
+
+- **[LCD](drive-peripherals-lcd-des.md)**
+
+- **[TOUCHSCREEN](drive-peripherals-touch-des.md)**
+
+- **[Sensor](drive-peripherals-sensor-des.md)**
+
+- **[WLAN](drive-peripherals-external-des.md)**
+
+
diff --git a/en/device-dev/driver/drive-platform-gpio-des.md b/en/device-dev/driver/drive-platform-gpio-des.md
new file mode 100644
index 0000000000000000000000000000000000000000..045a23db3e998a174fd191525fd04742b9ca86a8
--- /dev/null
+++ b/en/device-dev/driver/drive-platform-gpio-des.md
@@ -0,0 +1,560 @@
+# GPIO
+
+- [Overview](#section1635911016188)
+ - [Available APIs](#section17715915181611)
+
+- [Usage Guidelines](#section259614242196)
+ - [How to Use](#section103477714216)
+ - [Determining a GPIO Pin Number](#section370083272117)
+ - [Using APIs to Operate GPIO Pins](#section13604050132118)
+
+- [Usage Example](#section25941262111)
+
+## Overview
+
+Generally, a general-purpose input/output \(GPIO\) controller manages all GPIO pins by group. Each group of GPIO pins is associated with one or more registers. The GPIO pins are operated by reading data from and writing data to the registers.
+
+The GPIO APIs define a set of standard functions for performing operations on GPIO pins, including:
+
+- Setting the pin direction, which can be input or output \(High impedance is not supported currently.\)
+
+- Reading and writing level values, which can be low or high
+- Setting an interrupt service routine \(ISR\) function and interrupt trigger mode for a pin
+- Enabling or disabling a pin interrupt
+
+### Available APIs
+
+**Table 1** APIs available for the GPIO driver
+
+
+
Capability
+
+
Function
+
+
Description
+
+
+
+
GPIO read/write
+
+
GpioRead
+
+
Reads the level value of a GPIO pin.
+
+
+
GpioWrite
+
+
Writes the level value of a GPIO pin.
+
+
+
GPIO settings
+
+
GpioSetDir
+
+
Sets the direction for a GPIO pin.
+
+
+
GpioGetDir
+
+
Obtains the direction for a GPIO pin.
+
+
+
GPIO interrupt settings
+
+
GpioSetIrq
+
+
Sets the ISR function for a GPIO pin.
+
+
+
GpioUnSetIrq
+
+
Cancels the setting of the ISR function for a GPIO pin.
+
+
+
GpioEnableIrq
+
+
Enables a GPIO interrupt.
+
+
+
GpioDisableIrq
+
+
Disables a GPIO interrupt.
+
+
+
+
+
+> **NOTE:**
+>All functions provided in this document can be called only in kernel mode.
+
+## Usage Guidelines
+
+### How to Use
+
+The GPIO APIs use the GPIO pin number to specify a pin. [Figure 1](#fig1399416053717) shows the general process of using a GPIO.
+
+**Figure 1** Process of using a GPIO
+
+
+
+
+### Determining a GPIO Pin Number
+
+The method for converting GPIO pin numbers varies according to the GPIO controller model, parameters, and controller driver of different system on chips \(SoCs\).
+
+- Hi3516DV300
+
+ A controller manages 12 groups of GPIO pins. Each group contains 8 GPIO pins.
+
+ GPIO pin number = GPIO group index \(0-11\) x Number of GPIO pins in each group \(8\) + Offset in the group
+
+ Example: GPIO number of GPIO10\_3 = 10 x 8 + 3 = 83
+
+- Hi3518EV300
+
+ A controller manages 10 groups of GPIO pins. Each group contains 10 GPIO pins.
+
+ GPIO pin number = GPIO group index \(0–9\) x Number of GPIO pins in each group \(10\) + Offset in the group
+
+ Example: GPIO pin number of GPIO7\_3 = 7 x 10 + 3 = 73
+
+
+### Using APIs to Operate GPIO Pins
+
+- Set the direction for a GPIO pin.
+
+ Before performing read/write operations on a GPIO pin, call the following function to set the direction:
+
+ int32\_t GpioSetDir\(uint16\_t gpio, uint16\_t dir\);
+
+ **Table 2** Description of GpioSetDir
+
+
+
Parameter
+
+
Description
+
+
+
gpio
+
+
GPIO pin number.
+
+
+
dir
+
+
Direction to set.
+
+
+
Return Value
+
+
Description
+
+
+
0
+
+
Succeeded in setting the direction for a GPIO pin.
+
+
+
Negative value
+
+
Failed to set the direction for a GPIO pin.
+
+
+
+
+
+
+- Read or write the level value for a GPIO pin.
+
+ To read the level value of a GPIO pin, call the following function:
+
+ int32\_t GpioRead\(uint16\_t gpio, uint16\_t \*val\);
+
+ **Table 3** Description of GpioRead
+
+
+
Parameter
+
+
Description
+
+
+
gpio
+
+
GPIO pin number.
+
+
+
val
+
+
Pointer to the level value.
+
+
+
Return Value
+
+
Description
+
+
+
0
+
+
Succeeded in reading the level value.
+
+
+
Negative value
+
+
Failed to read the level value.
+
+
+
+
+
+ To write the level value for a GPIO pin, call the following function:
+
+ int32\_t GpioWrite\(uint16\_t gpio, uint16\_t val\);
+
+ **Table 4** Description of GpioWrite
+
+
+
Parameter
+
+
Description
+
+
+
gpio
+
+
GPIO pin number.
+
+
+
val
+
+
Level value to write.
+
+
+
Return Value
+
+
Description
+
+
+
0
+
+
Succeeded in writing the level value.
+
+
+
Negative value
+
+
Failed to write the level value.
+
+
+
+
+
+ Example:
+
+ ```
+ int32_t ret;
+ uint16_t val;
+ /* Set the output direction for GPIO3. */
+ ret = GpioSetDir(3, GPIO_DIR_OUT);
+ if (ret != 0) {
+ HDF_LOGE("GpioSerDir: failed, ret %d\n", ret);
+ return;
+ }
+ /* Write the low level GPIO_VAL_LOW for GPIO3. */
+ ret = GpioWrite(3, GPIO_VAL_LOW);
+ if (ret != 0) {
+ HDF_LOGE("GpioWrite: failed, ret %d\n", ret);
+ return;
+ }
+ /* Set the input direction for GPIO6. */
+ ret = GpioSetDir(6, GPIO_DIR_IN);
+ if (ret != 0) {
+ HDF_LOGE("GpioSetDir: failed, ret %d\n", ret);
+ return;
+ }
+ /* Read the level value of GPIO6. */
+ ret = GpioRead(6, &val);
+ ```
+
+
+- Set the ISR function for a GPIO pin.
+
+ To set the ISR function for a GPIO pin, call the following function:
+
+ int32\_t GpioSetIrq\(uint16\_t gpio, uint16\_t mode, GpioIrqFunc func, void \*arg\);
+
+ **Table 5** Description of GpioSetIrq
+
+
+
Parameter
+
+
Description
+
+
+
gpio
+
+
GPIO pin number.
+
+
+
mode
+
+
Interrupt trigger mode.
+
+
+
func
+
+
ISR function to set.
+
+
+
arg
+
+
Pointer to the parameters passed to the ISR function.
+
+
+
Return Value
+
+
Description
+
+
+
0
+
+
Succeeded in setting the ISR function for a GPIO pin.
+
+
+
Negative value
+
+
Failed to set the ISR function for a GPIO pin.
+
+
+
+
+
+ > **CAUTION:**
+ >Only one ISR function can be set for a GPIO pin at a time. If **GpioSetIrq** is called repeatedly, the previous IRS function will be replaced.
+
+ If the ISR function is no longer required, call the following function to cancel the setting:
+
+ int32\_t GpioUnSetIrq\(uint16\_t gpio\);
+
+ **Table 6** Description of GpioUnSetIrq
+
+
+
Parameter
+
+
Description
+
+
+
gpio
+
+
GPIO pin number.
+
+
+
Return Value
+
+
Description
+
+
+
0
+
+
Succeeded in canceling the ISR function.
+
+
+
Negative value
+
+
Failed to cancel the ISR function.
+
+
+
+
+
+ After the ISR function is set, call the following function to enable a GPIO interrupt:
+
+ int32\_t GpioEnableIrq\(uint16\_t gpio\);
+
+ **Table 7** Description of GpioEnableIrq
+
+
+
Parameter
+
+
Description
+
+
+
gpio
+
+
GPIO pin number.
+
+
+
Return Value
+
+
Description
+
+
+
0
+
+
Succeeded in enabling a GPIO interrupt.
+
+
+
Negative value
+
+
Failed to enable a GPIO interrupt.
+
+
+
+
+
+ > **CAUTION:**
+ >The configured ISR function can be responded only after the GPIO interrupt is enabled.
+
+ Use the following function to disable the GPIO interrupt:
+
+ int32\_t GpioDisableIrq\(uint16\_t gpio\);
+
+ **Table 8** Description of GpioDisableIrq
+
+
+
Parameter
+
+
Description
+
+
+
gpio
+
+
GPIO pin number.
+
+
+
Return Value
+
+
Description
+
+
+
0
+
+
Succeeded in disabling a GPIO interrupt.
+
+
+
Negative value
+
+
Failed to disable a GPIO interrupt.
+
+
+
+
+
+ Example:
+
+ ```
+ /* ISR function */
+ */
+ int32_t MyCallBackFunc(uint16_t gpio, void *data)
+ {
+ HDF_LOGI("%s: gpio:%u interrupt service in! data=%p\n", __func__, gpio, data);
+ return 0;
+ }
+
+ int32_t ret;
+ /* Set the ISR function to MyCallBackFunc, the parameter to NULL, and the interrupt trigger mode to rising edge. */
+ ret = GpioSetIrq(3, OSAL_IRQF_TRIGGER_RISING, MyCallBackFunc, NULL);
+ if (ret != 0) {
+ HDF_LOGE("GpioSetIrq: failed, ret %d\n", ret);
+ return;
+ }
+
+ /* Enable an interrupt for GPIO3. */
+ ret = GpioEnableIrq(3);
+ if (ret != 0) {
+ HDF_LOGE("GpioEnableIrq: failed, ret %d\n", ret);
+ return;
+ }
+
+ /* Disable the interrupt for GPIO3. */
+ ret = GpioDisableIrq(3);
+ if (ret != 0) {
+ HDF_LOGE("GpioDisableIrq: failed, ret %d\n", ret);
+ return;
+ }
+
+ /* Cancel the ISR function for GPIO3. */
+ ret = GpioUnSetIrq(3);
+ if (ret != 0) {
+ HDF_LOGE("GpioUnSetIrq: failed, ret %d\n", ret);
+ return;
+ }
+ ```
+
+
+## Usage Example
+
+In this example, we test the interrupt trigger of a GPIO pin as follows: Set the ISR function for the pin, set the trigger mode to rising edge and failing edge, write high and low levels to the pin alternately to generate level fluctuation, and observe the execution of the ISR function.
+
+Select an idle GPIO pin. This example uses a Hi3516D V300 development board and GPIO pin GPIO10\_3, which is numbered GPIO83.
+
+You can select an idle GPIO pin based on the development board and schematic diagram.
+
+```
+#include "gpio_if.h"
+#include "hdf_log.h"
+#include "osal_irq.h"
+#include "osal_time.h"
+
+static uint32_t g_irqCnt;
+
+/* ISR function */
+static int32_t TestCaseGpioIrqHandler(uint16_t gpio, void *data)
+{
+ HDF_LOGE("%s: irq triggered! on gpio:%u, data=%p", __func__, gpio, data);
+ g_irqCnt++; /* If the ISR function is triggered, the number of global interrupts is incremented by 1. */
+ return GpioDisableIrq(gpio);
+}
+
+/* Test case function */
+static int32_t TestCaseGpioIrqEdge(void)
+{
+ int32_t ret;
+ uint16_t valRead;
+ uint16_t mode;
+ uint16_t gpio = 83; /* Number of the GPIO pin to test */
+ uint32_t timeout;
+
+ /* Set the output direction for the pin. */
+ ret = GpioSetDir(gpio, GPIO_DIR_OUT);
+ if (ret != HDF_SUCCESS) {
+ HDF_LOGE("%s: set dir fail! ret:%d\n", __func__, ret);
+ return ret;
+ }
+
+ /* Disable the interrupt of the pin. */
+ ret = GpioDisableIrq(gpio);
+ if (ret != HDF_SUCCESS) {
+ HDF_LOGE("%s: disable irq fail! ret:%d\n", __func__, ret);
+ return ret;
+ }
+
+ /* Set the ISR function for the pin. The trigger mode is both rising edge and falling edge. */
+ mode = OSAL_IRQF_TRIGGER_RISING | OSAL_IRQF_TRIGGER_FALLING;
+ HDF_LOGE("%s: mode:%0x\n", __func__, mode);
+ ret = GpioSetIrq(gpio, mode, TestCaseGpioIrqHandler, NULL);
+ if (ret != HDF_SUCCESS) {
+ HDF_LOGE("%s: set irq fail! ret:%d\n", __func__, ret);
+ return ret;
+ }
+
+ /* Enable the interrupt for this pin. */
+ ret = GpioEnableIrq(gpio);
+ if (ret != HDF_SUCCESS) {
+ HDF_LOGE("%s: enable irq fail! ret:%d\n", __func__, ret);
+ (void)GpioUnSetIrq(gpio);
+ return ret;
+ }
+
+ g_irqCnt = 0; /* Reset the global counter. */
+ timeout = 0; /* Reset the waiting time. */
+ /* Wait for the ISR function of this pin to trigger. The timeout duration is 1000 ms. */
+ while (g_irqCnt <= 0 && timeout < 1000) {
+ (void)GpioRead(gpio, &valRead);
+ (void)GpioWrite(gpio, (valRead == GPIO_VAL_LOW) ? GPIO_VAL_HIGH : GPIO_VAL_LOW);
+ HDF_LOGE("%s: wait irq timeout:%u\n", __func__, timeout);
+ OsalMDelay(200); /* wait for irq trigger */
+ timeout += 200;
+ }
+ (void)GpioUnSetIrq(gpio);
+ return (g_irqCnt > 0) ? HDF_SUCCESS : HDF_FAILURE;
+}
+```
+
diff --git a/en/device-dev/driver/drive-platform-i2c-des.md b/en/device-dev/driver/drive-platform-i2c-des.md
new file mode 100644
index 0000000000000000000000000000000000000000..7b70a9fbd022795d0bdbfd142626fdeecf61346d
--- /dev/null
+++ b/en/device-dev/driver/drive-platform-i2c-des.md
@@ -0,0 +1,426 @@
+# I2C
+
+- [Overview](#section5361140416)
+ - [Available APIs](#section459052019177)
+
+- [Usage Guidelines](#section1695201514281)
+ - [How to Use](#section1338373417288)
+ - [Opening an I2C Controller](#section13751110132914)
+ - [Performing I2C Communication](#section9202183372916)
+ - [Closing an I2C Controller](#section19481164133018)
+
+- [Usage Example](#section5302202015300)
+
+## Overview
+
+- The Inter-Integrated Circuit \(I2C\) is a simple, bidirectional, and synchronous serial bus that uses merely two wires.
+- In an I2C communication, one controller communicates with one or more devices through the serial data line \(SDA\) and serial clock line \(SCL\), as shown in [Figure 1](#fig1135561232714).
+
+- I2C data transfer must begin with a **START** condition and end with a **STOP** condition. Data is transmitted byte-by-byte from the most significant bit to the least significant bit.
+- Each I2C node is recognized by a unique address and can serve as either a controller or a device. When the controller needs to communicate with a device, it writes the device address to the bus through broadcast. A device matching this address sends a response to set up a data transfer channel.
+
+- The I2C APIs define a set of common functions for I2C data transfer, including:
+
+ - I2C controller management: opening or closing an I2C controller
+ - I2C message transfer: custom transfer by using a message array
+
+ **Figure 1** Physical connection diagram for I2C
+ 
+
+
+### Available APIs
+
+**Table 1** APIs available for the I2C driver
+
+
+
Capability
+
+
Function
+
+
Description
+
+
+
+
I2C controller management
+
+
I2cOpen
+
+
Opens an I2C controller.
+
+
+
I2cClose
+
+
Closes an I2C controller.
+
+
+
I2C message transfer
+
+
I2cTransfer
+
+
Performs a custom transfer.
+
+
+
+
+
+> **NOTE:**
+>All functions provided in this document can be called only in kernel mode.
+
+## Usage Guidelines
+
+### How to Use
+
+[Figure 2](#fig166181128151112) illustrates the process of an I2C device.
+
+**Figure 2** Process of using an I2C device
+
+
+
+
+### Opening an I2C Controller
+
+Call the following function to open an I2C controller:
+
+DevHandle I2cOpen\(int16\_t number\);
+
+**Table 2** Description of I2cOpen
+
+
+
Parameter
+
+
Description
+
+
+
+
number
+
+
I2C controller ID.
+
+
+
Return Value
+
+
Description
+
+
+
NULL
+
+
Failed to open the I2C controller.
+
+
+
Device handle
+
+
Handle of the I2C controller.
+
+
+
+
+
+This example assumes that the system has eight I2C controllers \(numbered from 0 to 7\) and I2C controller 3 is to open.
+
+```
+DevHandle i2cHandle = NULL; /* I2C controller handle */
+
+/* Open an I2C controller. */
+i2cHandle = I2cOpen(3);
+if (i2cHandle == NULL) {
+ HDF_LOGE("I2cOpen: failed\n");
+ return;
+}
+```
+
+### Performing I2C Communication
+
+Use the following function for message transfer:
+
+int32\_t I2cTransfer\(DevHandle handle, struct I2cMsg \*msgs, int16\_t count\);
+
+**Table 3** Description of I2cTransfer
+
+
+
Parameter
+
+
Description
+
+
+
+
handle
+
+
Handle of an I2C controller.
+
+
+
msgs
+
+
Message array of the data to transfer.
+
+
+
count
+
+
Length of the message array.
+
+
+
Return Value
+
+
Description
+
+
+
Positive integer
+
+
Number of message structures that are successfully transmitted.
+
+
+
Negative value
+
+
Failed to perform the message transfer.
+
+
+
+
+
+The type of an I2C message transfer is defined by **I2cMsg**. Each message structure indicates a read or write operation. Multiple read or write operations can be performed by using a message array.
+
+```
+int32_t ret;
+uint8_t wbuff[2] = { 0x12, 0x13 };
+uint8_t rbuff[2] = { 0 };
+struct I2cMsg msgs[2]; /* Custom message array for transfer */
+msgs[0].buf = wbuff; /* Data to write */
+msgs[0].len = 2; /* The length of the data to write is 2. */
+msgs[0].addr = 0x5A; /* The address of the device to write the data is 0x5A. */
+msgs[0].flags = 0; /* The flag is 0, indicating the write operation. */
+msgs[1].buf = rbuff; /* Data to read */
+msgs[1].len = 2; /* The length of the data to read is 2. */
+msgs[1].addr = 0x5A; /* The address of the device to read is 0x5A. */
+msgs[1].flags = I2C_FLAG_READ /* I2C_FLAG_READ is configured, indicating the read operation. */
+/* Perform a custom transfer to transfer two messages. */
+ret = I2cTransfer(i2cHandle, msgs, 2);
+if (ret != 2) {
+ HDF_LOGE("I2cTransfer: failed, ret %d\n", ret);
+ return;
+}
+```
+
+> **CAUTION:**
+>- The device address in the **I2cMsg** structure does not contain the read/write flag bit. The read/write information is transferred by the read/write control bit in the member variable **flags**.
+>- The **I2cTransfer** function does not limit the number of message structures, which is determined by the I2C controller.
+>- The **I2cTransfer** function does not limit the data length of each message structure, which is determined by the I2C controller.
+>- The **I2cTransfer** function may cause the system to sleep and therefore cannot be called in the interrupt context.
+
+### Closing an I2C Controller
+
+Call the following function to close the I2C controller after the communication is complete:
+
+void I2cClose\(DevHandle \*handle\);
+
+**Table 4** Description of I2cClose
+
+
+
Parameter
+
+
Description
+
+
+
+
handle
+
+
Handle of an I2C controller.
+
+
+
+
+
+```
+I2cClose(i2cHandle); /* Close the I2C controller. */
+```
+
+## Usage Example
+
+This example describes how to use I2C APIs with an I2C device on a development board.
+
+This example shows a simple register read/write operation on TouchPad on a Hi3516D V300 development board. The basic hardware information is as follows:
+
+- SoC: hi3516dv300
+
+- Touch IC: The I2C address is 0x38, and the bit width of Touch IC's internal register is 1 byte.
+
+- Schematic diagram: TouchPad is mounted to I2C controller 3. The reset pin of Touch IC is GPIO3.
+
+In this example, first we reset Touch IC. \(The development board supplies power to Touch IC by default after being powered on, and this use case does not consider the power supply\). Then, we perform a read/write operation on an internal register to test whether the I2C channel is normal.
+
+> **NOTE:**
+>The example focuses on I2C device access and verifies the I2C channel. The read and write values of the device register are not concerned. The behavior caused by the read and write operations on the register is determined by the device itself.
+
+Example:
+
+```
+#include "i2c_if.h" /* Header file of I2C APIs */
+#include "gpio_if.h" /* Header file of GPIO APIs */
+#include "hdf_log.h" /* Header file for log APIs */
+#include "osal_io.h" /* Header file of I/O read and write APIs */
+#include "osal_time.h" /* Header file of delay and sleep APIs */
+
+/* Define a TP device structure to store I2C and GPIO hardware information. */
+struct TpI2cDevice {
+ uint16_t rstGpio; /* Reset pin */
+ uint16_t busId; /* I2C bus ID */
+ uint16_t addr; /* I2C device address */
+ uint16_t regLen; /* Register bit width */
+ DevHandle i2cHandle; /* I2C controller handle */
+};
+
+/* I2C pin I/O configuration. For details, see the SoC register manual. */
+#define I2C3_DATA_REG_ADDR 0x112f008c /* Address of the SDA pin configuration register of I2C controller 3
+#define I2C3_CLK_REG_ADDR 0x112f0090 /* Address of the SCL pin configuration register of I2C controller 3
+#define I2C_REG_CFG 0x5f1 /* Configuration values of SDA and SCL pins of I2C controller 3
+
+static void TpSocIoCfg(void)
+{
+ /* Set the I/O function of the two pins corresponding to I2C controller 3 to I2C. */
+ OSAL_WRITEL(I2C_REG_CFG, IO_DEVICE_ADDR(I2C3_DATA_REG_ADDR));
+ OSAL_WRITEL(I2C_REG_CFG, IO_DEVICE_ADDR(I2C3_CLK_REG_ADDR));
+}
+
+/* Initialize the reset pin of the TP. Pull up the pin for 20 ms, pull down the pin for 50 ms, and then pull up the pin for 20 ms to complete the resetting. */
+static int32_t TestCaseGpioInit(struct TpI2cDevice *tpDevice)
+{
+ int32_t ret;
+
+ /* Set the output direction for the reset pin. */
+ ret = GpioSetDir(tpDevice->rstGpio, GPIO_DIR_OUT);
+ if (ret != HDF_SUCCESS) {
+ HDF_LOGE("%s: set rst dir fail!:%d", __func__, ret);
+ return ret;
+ }
+
+ ret = GpioWrite(tpDevice->rstGpio, GPIO_VAL_HIGH);
+ if (ret != HDF_SUCCESS) {
+ HDF_LOGE("%s: set rst hight fail!:%d", __func__, ret);
+ return ret;
+ }
+ OsalMSleep(20);
+
+ ret = GpioWrite(tpDevice->rstGpio, GPIO_VAL_LOW);
+ if (ret != HDF_SUCCESS) {
+ HDF_LOGE("%s: set rst low fail!:%d", __func__, ret);
+ return ret;
+ }
+ OsalMSleep(50);
+
+ ret = GpioWrite(tpDevice->rstGpio, GPIO_VAL_HIGH);
+ if (ret != HDF_SUCCESS) {
+ HDF_LOGE("%s: set rst high fail!:%d", __func__, ret);
+ return ret;
+ }
+ OsalMSleep(20);
+
+ return HDF_SUCCESS;
+}
+
+/* Use I2cTransfer to encapsulate a register read/write auxiliary function. Use flag to indicate the read or write operation. */
+static int TpI2cReadWrite(struct TpI2cDevice *tpDevice, unsigned int regAddr,
+ unsigned char *regData, unsigned int dataLen, uint8_t flag)
+{
+ int index = 0;
+ unsigned char regBuf[4] = {0};
+ struct I2cMsg msgs[2] = {0};
+
+ /* Perform length adaptation for the single- or dual-byte register. */
+ if (tpDevice->regLen == 1) {
+ regBuf[index++] = regAddr & 0xFF;
+ } else {
+ regBuf[index++] = (regAddr >> 8) & 0xFF;
+ regBuf[index++] = regAddr & 0xFF;
+ }
+
+ /* Fill in the I2cMsg message structure. */
+ msgs[0].addr = tpDevice->addr;
+ msgs[0].flags = 0; /* The flag is 0, indicating the write operation. */
+ msgs[0].len = tpDevice->regLen;
+ msgs[0].buf = regBuf;
+
+ msgs[1].addr = tpDevice->addr;
+ msgs[1].flags = (flag == 1)? I2C_FLAG_READ: 0; /* Add the read flag. */
+ msgs[1].len = dataLen;
+ msgs[1].buf = regData;
+
+ if (I2cTransfer(tpDevice->i2cHandle, msgs, 2) != 2) {
+ HDF_LOGE("%s: i2c read err", __func__);
+ return HDF_FAILURE;
+ }
+ return HDF_SUCCESS;
+}
+
+/* TP register read function */
+static inline int TpI2cReadReg(struct TpI2cDevice *tpDevice, unsigned int regAddr,
+ unsigned char *regData, unsigned int dataLen)
+{
+ return TpI2cReadWrite(tpDevice, regAddr, regData, dataLen, 1);
+}
+
+/* TP register write function */
+static inline int TpI2cWriteReg(struct TpI2cDevice *tpDevice, unsigned int regAddr,
+ unsigned char *regData, unsigned int dataLen)
+{
+ return TpI2cReadWrite(tpDevice, regAddr, regData, dataLen, 0);
+}
+
+/* Main entry of I2C */
+static int32_t TestCaseI2c(void)
+{
+ int32_t i;
+ int32_t ret;
+ unsigned char bufWrite[7] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xA, 0xB, 0xC };
+ unsigned char bufRead[7] = {0};
+ static struct TpI2cDevice tpDevice;
+
+ /* I/O pin function configuration */
+ TpSocIoCfg();
+
+ /* Initialize TP device information. */
+ tpDevice.rstGpio = 3;
+ tpDevice.busId = 3;
+ tpDevice.addr = 0x38;
+ tpDevice.regLen = 1;
+ tpDevice.i2cHandle = NULL;
+
+ /* Initialize the GPIO pin. */
+ ret = TestCaseGpioInit(&tpDevice);
+ if (ret != HDF_SUCCESS) {
+ HDF_LOGE("%s: gpio init fail!:%d", __func__, ret);
+ return ret;
+ }
+
+ /* Open an I2C controller. */
+ tpDevice.i2cHandle = I2cOpen(tpDevice.busId);
+ if (tpDevice.i2cHandle == NULL) {
+ HDF_LOGE("%s: Open I2c:%u fail!", __func__, tpDevice.busId);
+ return -1;
+ }
+
+ /* Continuously write 7-byte data to register 0xD5 of TP-IC. */
+ ret = TpI2cWriteReg(&tpDevice, 0xD5, bufWrite, 7);
+ if (ret != HDF_SUCCESS) {
+ HDF_LOGE("%s: tp i2c write reg fail!:%d", __func__, ret);
+ I2cClose(tpDevice.i2cHandle);
+ return -1;
+ }
+ OsalMSleep(10);
+
+ /* Continuously read 7-byte data from register 0xDO of TP-IC. */
+ ret = TpI2cReadReg(&tpDevice, 0xD5, bufRead, 7);
+ if (ret != HDF_SUCCESS) {
+ HDF_LOGE("%s: tp i2c read reg fail!:%d", __func__, ret);
+ I2cClose(tpDevice.i2cHandle);
+ return -1;
+ }
+
+ HDF_LOGE("%s: tp i2c write&read reg success!", __func__);
+ for (i = 0; i < 7; i++) {
+ HDF_LOGE("%s: bufRead[%d] = 0x%x", __func__, i, bufRead[i]);
+ }
+
+ /* Close the I2C controller. */
+ I2cClose(tpDevice.i2cHandle);
+ return ret;
+}
+```
+
diff --git a/en/device-dev/driver/drive-platform-mipidsi-des.md b/en/device-dev/driver/drive-platform-mipidsi-des.md
new file mode 100644
index 0000000000000000000000000000000000000000..250a419f0ee64f2364f03478a247bb11c0ff6d90
--- /dev/null
+++ b/en/device-dev/driver/drive-platform-mipidsi-des.md
@@ -0,0 +1,554 @@
+# MIPI DSI
+
+- [Overview](#section16806142183217)
+ - [Available APIs](#section129611916132011)
+
+- [Usage Guidelines](#section037231715335)
+ - [How to Use](#section49299119344)
+ - [Obtains a MIPI DSI device handle.](#section5126155683811)
+ - [Setting MIPI DSI Configuration Parameters](#section201164274344)
+ - [Sending/Receiving the Pointer to a Command](#section199401342173415)
+ - [Releasing the MIPI DSI Device Handle](#section161011610357)
+
+- [Usage Example](#section17470126123520)
+
+## Overview
+
+- The Display Serial Interface \(DSI\) is a specification stipulated by the Mobile Industry Processor Interface \(MIPI\) Alliance, aiming to reduce the cost of display controllers in a mobile device. It defines a serial bus and communication protocol among the host, the source of image data, and the target device. In this way, the DSI can send pixel data or commands to peripherals \(usually LCDs or similar display devices\) in serial mode, or reads information such as status and pixel from the peripherals.
+
+- MIPI DSI is capable of working in both high speed \(HS\) mode and low power \(LP\) mode. All data lanes can only travel from the DSI host to a peripheral in HS mode, except the first data lane, which can also receive data such as status information and pixels from the peripheral in LP mode. The clock lane is dedicated to transmitting synchronization clock signals in HS mode.
+- [Figure 1](#fig1122611461203) shows a simplified DSI interface. Conceptually, a DSI-compliant interface has the same features as interfaces complying with DBI-2 and DPI-2 standards. It sends pixels or commands to a peripheral and can read status or pixel information from the peripheral. The main difference is that the DSI serializes all pixel data, commands, and events that, in traditional interfaces, are conveyed to and from the peripheral on a parallel data bus with additional control signals.
+
+ **Figure 1** DSI transmitting and receiving interface
+ 
+
+
+### Available APIs
+
+**Table 1** APIs for MIPI DSI
+
+
+
Sets configuration parameters for a MIPI DSI device.
+
+
+
MipiDsiGetCfg
+
+
Obtains configuration parameters of a MIPI DSI device.
+
+
+
Obtaining /Releasing device handles
+
+
MipiDsiOpen
+
+
Obtains a MIPI DSI device handle.
+
+
+
MipiDsiClose
+
+
Releases a specified MIPI DSI device handle.
+
+
+
Setting the LP or HS mode
+
+
MipiDsiSetLpMode
+
+
Sets LP mode for a MIPI DSI device.
+
+
+
MipiDsiSetHsMode
+
+
Sets HS mode for a MIPI DSI device.
+
+
+
Reading/Sending commands
+
+
MipiDsiTx
+
+
Sends a display command set (DCS) command for sending data.
+
+
+
MipiDsiRx
+
+
Receives a DCS command for reading data with the specified length.
+
+
+
+
+
+> **NOTE:**
+>All functions described in this document can be called only in kernel space.
+
+## Usage Guidelines
+
+### How to Use
+
+[Figure 2](#fig99821771782) shows the process of using a MIPI DSI device.
+
+**Figure 2** Process of using a MIPI DSI device
+
+
+
+
+### Obtains a MIPI DSI device handle.
+
+Before performing MIPI DSI communication, obtain a MIPI DSI device handle by calling **MipiDsiOpen**. This function returns a MIPI DSI device handle with a specified channel ID.
+
+DevHandle MipiDsiOpen\(uint8\_t id\);
+
+**Table 2** Description of **MipiDsiOpen**
+
+
+
Parameter
+
+
Description
+
+
+
+
id
+
+
MIPI DSI channel ID.
+
+
+
Return Value
+
+
Description
+
+
+
NULL
+
+
Failed to receive the specified command.
+
+
+
Device handle
+
+
MIPI DSI device handle with a specified channel ID, whose data type is DevHandle.
+
+
+
+
+
+The following example shows how to obtain a MIPI DSI device handle with the channel ID **0**:
+
+```
+DevHandle mipiDsiHandle = NULL; /* Device handle */
+chnId = 0; /* MIPI DSI channel ID */
+
+/* Obtain the MIPI DSI device handle based on a specified channel ID. */
+mipiDsiHandle = MipiDsiOpen(chnId);
+if (mipiDsiHandle == NULL) {
+ HDF_LOGE("MipiDsiOpen: failed\n");
+ return;
+}
+```
+
+### Setting MIPI DSI Configuration Parameters
+
+- Set MIPI DSI configuration parameters by calling the following function:
+
+int32\_t MipiDsiSetCfg\(DevHandle handle, struct MipiCfg \*cfg\);
+
+**Table 3** Description of **MipiDsiSetCfg**
+
+
+
Parameter
+
+
Description
+
+
+
+
handle
+
+
MIPI DSI device handle.
+
+
+
cfg
+
+
Pointer to MIPI DSI configuration parameters.
+
+
+
Return Value
+
+
Description
+
+
+
0
+
+
Succeeded in setting MIPI DSI configuration parameters.
+
+```
+MipiDsiClose(mipiHandle); /* Release the MIPI DSI device handle */
+```
+
+## Usage Example
+
+The following is an example of using a MIPI DSI device:
+
+```
+#include "hdf.h"
+#include "mipi_dsi_if.h"
+
+void PalMipiDsiTestSample(void)
+{
+ uint8_t chnId;
+ int32_t ret;
+ DevHandle handle = NULL;
+
+ /* Device channel ID */
+ chnId = 0;
+ /* Obtain the MIPI DSI device handle based on a specified channel ID. */
+ handle = MipiDsiOpen(chnId);
+ if (handle == NULL) {
+ HDF_LOGE("MipiDsiOpen: failed!\n");
+ return;
+ }
+ /* MIPI DSI configuration parameters */
+ struct MipiCfg cfg = {0};
+ cfg.lane = DSI_4_LANES;
+ cfg.mode = DSI_CMD_MODE;
+ cfg.burstMode = VIDEO_NON_BURST_MODE_SYNC_EVENTS;
+ cfg.format = FORMAT_RGB_24_BIT;
+ cfg.pixelClk = 174;
+ cfg.phyDataRate = 384;
+ cfg.timingInfo.hsaPixels = 50;
+ cfg.timingInfo.hbpPixels = 55;
+ cfg.timingInfo.hlinePixels = 1200;
+ cfg.timingInfo.yResLines = 1800;
+ cfg.timingInfo.vbpLines = 33;
+ cfg.timingInfo.vsaLines = 76;
+ cfg.timingInfo.vfpLines = 120;
+ cfg.timingInfo.xResPixels = 1342;
+ /* Set MIPI DSI configuration parameters. */
+ ret = MipiDsiSetCfg(g_handle, &cfg);
+ if (ret != 0) {
+ HDF_LOGE("%s: SetMipiCfg fail! ret=%d\n", __func__, ret);
+ return;
+ }
+ /* Send the command for initializing the PANEL register. */
+ struct DsiCmdDesc *cmd = OsalMemCalloc(sizeof(struct DsiCmdDesc));
+ if (cmd == NULL) {
+ return;
+ }
+ cmd->dtype = DTYPE_DCS_WRITE;
+ cmd->dlen = 1;
+ cmd->payload = OsalMemCalloc(sizeof(uint8_t));
+ if (cmd->payload == NULL) {
+ HdfFree(cmd);
+ return;
+ }
+ *(cmd->payload) = DTYPE_GEN_LWRITE;
+ MipiDsiSetLpMode(mipiHandle);
+ ret = MipiDsiTx(mipiHandle, cmd);
+ MipiDsiSetHsMode(mipiHandle);
+ if (ret != HDF_SUCCESS) {
+ HDF_LOGE("%s: MipiDsiTx fail! ret=%d\n", __func__, ret);
+ HdfFree(cmd->payload);
+ HdfFree(cmd);
+ return;
+ }
+ HdfFree(cmd->payload);
+ HdfFree(cmd);
+ /* Pointer to the register that reads the PANEL status */
+ uint8_t readVal = 0;
+ struct DsiCmdDesc *cmdRead = OsalMemCalloc(sizeof(struct DsiCmdDesc));
+ if (cmdRead == NULL) {
+ return;
+ }
+ cmdRead->dtype = DTYPE_DCS_READ;
+ cmdRead->dlen = 1;
+ cmdRead->payload = OsalMemCalloc(sizeof(uint8_t));
+ if (cmdRead->payload == NULL) {
+ HdfFree(cmdRead);
+ return;
+ }
+ *(cmdRead->payload) = DDIC_REG_STATUS;
+ MipiDsiSetLpMode(g_handle);
+ ret = MipiDsiRx(g_handle, cmdRead, sizeof(readVal), &readVal);
+ MipiDsiSetHsMode(g_handle);
+ if (ret != HDF_SUCCESS) {
+ HDF_LOGE("%s: MipiDsiRx fail! ret=%d\n", __func__, ret);
+ HdfFree(cmdRead->payload);
+ HdfFree(cmdRead);
+ return;
+ }
+ HdfFree(cmdRead->payload);
+ HdfFree(cmdRead);
+ /* Release the MIPI DSI device handle. */
+ MipiDsiClose(handle);
+}
+```
+
diff --git a/en/device-dev/driver/drive-platform-rtc-des.md b/en/device-dev/driver/drive-platform-rtc-des.md
new file mode 100644
index 0000000000000000000000000000000000000000..66e8a08cf14f76bd8e32165491c4387567db8f66
--- /dev/null
+++ b/en/device-dev/driver/drive-platform-rtc-des.md
@@ -0,0 +1,944 @@
+# RTC
+
+- [Overview](#section104842041574)
+ - [Available APIs](#section3373340142215)
+
+- [Usage Guidelines](#section20636145604113)
+ - [How to Use](#section16919828134215)
+ - [Creating an RTC Device Handle](#section1131212144310)
+ - [Releasing the RTC Device Handle](#section10744117144314)
+ - [Registering RtcAlarmCallback](#section14839440184320)
+ - [Performing RTC-related Operations](#section161927578433)
+
+- [Usage Example](#section1186111020456)
+
+## Overview
+
+The real-time clock \(RTC\) driver provides precise real time for the operating system \(OS\). If the OS is powered off, the RTC driver continues to keep track of the system time using an external battery.
+
+### Available APIs
+
+**Table 1** APIs provided by the RTC driver
+
+
+
Capability
+
+
Function
+
+
Description
+
+
+
+
RTC handle
+
+
RtcOpen
+
+
Opens the RTC device to obtain its handle.
+
+
+
RtcClose
+
+
Releases a specified handle of the RTC device.
+
+
+
RTC time
+
+
RtcReadTime
+
+
Reads time information from the RTC driver, including the year, month, the day of the week, day, hour, minute, second, and millisecond.
+
+
+
RtcWriteTime
+
+
Writes time information from the RTC driver, including the year, month, the day of the week, day, hour, minute, second, and millisecond.
+
+
+
RTC alarm
+
+
RtcReadAlarm
+
+
Reads the RTC alarm time that was set last time.
+
+
+
RtcWriteAlarm
+
+
Writes the RTC alarm time based on the alarm index.
+
+
+
RtcRegisterAlarmCallback
+
+
Registers RtcAlarmCallback that will be invoked when an alarm is generated at the specified time.
+
+
+
RtcAlarmInterruptEnable
+
+
Enables or disables RTC alarm interrupts.
+
+
+
RTC configuration
+
+
RtcGetFreq
+
+
Reads the frequency of the external crystal oscillator connected to the RTC driver.
+
+
+
RtcSetFreq
+
+
Sets the frequency of the external crystal oscillator connected to the RTC driver.
+
+
+
RtcReset
+
+
Resets the RTC.
+
+
+
Custom register
+
+
RtcReadReg
+
+
Reads the configuration of a custom RTC register based on the register index.
+
+
+
RtcWriteReg
+
+
Writes the configuration of a custom RTC register based on the register index.
+
+
+
+
+
+> **NOTE:**
+>All functions provided in this document can be called only in kernel mode.
+
+## Usage Guidelines
+
+### How to Use
+
+During the OS startup, the HDF loads the RTC driver based on the configuration file. The RTC driver detects the RTC component and initializes the driver.
+
+[Figure 1](#fig166181128151112) illustrates the process of using an RTC device.
+
+**Figure 1** Process of using an RTC device
+
+
+
+
+### Creating an RTC Device Handle
+
+After the RTC driver is loaded, you can use the API provided by the HDF and call APIs of the RTC driver.
+
+> **NOTE:**
+>Currently, only one RTC device is supported in the OS.
+
+DevHandle RtcOpen\(void\);
+
+**Table 2** Description of RtcOpen
+
+
+
Parameter
+
+
Description
+
+
+
void
+
+
NA
+
+
+
Return Value
+
+
Description
+
+
+
handle
+
+
Returns the if the operation is successful.
+
+
+
NULL
+
+
The operation fails.
+
+
+
+
+
+```
+DevHandle handle = NULL;
+
+/* Obtain the RTC device handle. */
+handle = RtcOpen();
+if (handle == NULL) {
+ /* Process the error. */
+}
+```
+
+### Releasing the RTC Device Handle
+
+You can call the following function to release the RTC device handle, thereby releasing resources of the device:
+
+void RtcClose\(DevHandle handle\);
+
+**Table 3** Description of RtcClose
+
+
+
Parameter
+
+
Description
+
+
+
handle
+
+
RTC device handle.
+
+
+
+
+
+```
+/* Release the RTC device handle. */
+RtcClose(handle);
+```
+
+### Registering RtcAlarmCallback
+
+After the OS is started, call the following function to register **RtcAlarmCallback**, which will be invoked when an alarm is generated at the specified time:
+
+int32\_t RtcRegisterAlarmCallback\(DevHandle handle, enum RtcAlarmIndex alarmIndex, RtcAlarmCallback cb\);
+
+**Table 4** Description of RtcRegisterAlarmCallback
+
+
+
Parameter
+
+
Description
+
+
+
+
handle
+
+
RTC device handle.
+
+
+
alarmIndex
+
+
Alarm index.
+
+
+
cb
+
+
Callback that will be invoked when an alarm is generated at the specified time.
+
+
+
Return Value
+
+
Description
+
+
+
0
+
+
The operation is successful.
+
+
+
Negative value
+
+
The operation fails.
+
+
+
+
+
+The following is an example of registering **RtcAlarmCallback** for processing alarm **RTC\_ALARM\_INDEX\_A**:
+
+```
+/* Register an RTC alarm callback. */
+int32_t RtcAlarmACallback(enum RtcAlarmIndex alarmIndex)
+{
+ if (alarmIndex == RTC_ALARM_INDEX_A) {
+ /* Process alarm A. */
+ } else if (alarmIndex == RTC_ALARM_INDEX_B) {
+ /* Process alarm B. */
+ } else {
+ /* Process the error. */
+ }
+ return 0;
+}
+int32_t ret;
+/* Register RtcAlarmCallback for alarm A. */
+ret = RtcRegisterAlarmCallback(handle, RTC_ALARM_INDEX_A, RtcAlarmACallback);
+if (ret != 0) {
+ /* Process the error. */
+}
+```
+
+### Performing RTC-related Operations
+
+- Reading RTC time
+
+Call the following function to read time information from the RTC driver, including the year, month, the day of the week, day, hour, minute, second, and millisecond:
+
+int32\_t RtcReadTime\(DevHandle handle, struct RtcTime \*time\);
+
+**Table 5** Description of RtcReadTime
+
+
+
Parameter
+
+
Description
+
+
+
handle
+
+
RTC device handle.
+
+
+
time
+
+
Pointer to the time information read from the RTC driver. The time information includes the year, month, the day of the week, day, hour, minute, second, and millisecond.
+
+
+
Return Value
+
+
Description
+
+
+
0
+
+
The operation is successful.
+
+
+
Negative value
+
+
The operation fails.
+
+
+
+
+
+```
+int32_t ret;
+struct RtcTime tm;
+
+/* Read time information from the RTC driver. */
+ret = RtcReadTime(handle, &tm);
+if (ret != 0) {
+ /* Process the error. */
+}
+```
+
+- Setting RTC time
+
+Call the following function to set the RTC time:
+
+int32\_t RtcWriteTime\(DevHandle handle, struct RtcTime \*time\);
+
+**Table 6** Description of RtcWriteTime
+
+
+
Parameter
+
+
Description
+
+
+
handle
+
+
RTC device handle.
+
+
+
time
+
+
Pointer to the time information written into the RTC driver. The time information includes the year, month, the day of the week, day, hour, minute, second, and millisecond.
+
+
+
Return Value
+
+
Description
+
+
+
0
+
+
The operation is successful.
+
+
+
Negative value
+
+
The operation fails.
+
+
+
+
+
+> **NOTE:**
+>The RTC start time is 1970/01/01 Thursday 00:00:00 \(UTC\). The maximum value of **year** must be set based on the requirements specified in the product manual of the in-use component. You do not need to configure the day of the week.
+
+```
+int32_t ret;
+struct RtcTime tm;
+
+/* Set the RTC time to UTC 2020/01/01 00:59:00 .000. */
+tm.year = 2020;
+tm.month = 01;
+tm.day = 01;
+tm.hour= 00;
+tm.minute = 59;
+tm.second = 00;
+tm.millisecond = 0;
+/* Write the RTC time information. */
+ret = RtcWriteTime(handle, &tm);
+if (ret != 0) {
+ /* Process the error. */
+}
+```
+
+- Reading the RTC alarm time
+
+Call the following function to read the alarm time:
+
+int32\_t RtcReadAlarm\(DevHandle handle, enum RtcAlarmIndex alarmIndex, struct RtcTime \*time\);
+
+**Table 7** Description of RtcReadAlarm
+
+
+
Parameter
+
+
Description
+
+
+
handle
+
+
RTC device handle.
+
+
+
alarmIndex
+
+
Alarm index.
+
+
+
time
+
+
Pointer to the RTC alarm time information. The time information includes the year, month, the day of the week, day, hour, minute, second, and millisecond.
+
+
+
Return Value
+
+
Description
+
+
+
0
+
+
The operation is successful.
+
+
+
Negative value
+
+
The operation fails.
+
+
+
+
+
+```
+int32_t ret;
+struct RtcTime alarmTime;
+
+/* Read the RTC alarm time information of alarm RTC_ALARM_INDEX_A. */
+ret = RtcReadAlarm(handle, RTC_ALARM_INDEX_A, &alarmTime);
+if (ret != 0) {
+ /* Process the error. */
+}
+```
+
+- Setting RTC alarm time
+
+Call the following function to set the RTC alarm time based on the alarm index:
+
+int32\_t RtcWriteAlarm\(DevHandle handle, enum RtcAlarmIndex alarmIndex, struct RtcTime \*time\);
+
+**Table 8** Description of RtcWriteAlarm
+
+
+
Parameter
+
+
Description
+
+
+
handle
+
+
RTC device handle.
+
+
+
alarmIndex
+
+
Alarm index.
+
+
+
time
+
+
Pointer to the RTC alarm time information. The time information includes the year, month, the day of the week, day, hour, minute, second, and millisecond.
+
+
+
Return Value
+
+
Description
+
+
+
0
+
+
The operation is successful.
+
+
+
Negative value
+
+
The operation fails.
+
+
+
+
+
+> **NOTE:**
+>The RTC start time is 1970/01/01 Thursday 00:00:00 \(UTC\). The maximum value of **year** must be set based on the requirements specified in the product manual of the in-use component. You do not need to configure the day of the week.
+
+```
+int32_t ret;
+struct RtcTime alarmTime;
+
+/* Set the RTC alarm time to 2020/01/01 00:59:59 .000. */
+alarmTime.year = 2020;
+alarmTime.month = 01;
+alarmTime.day = 01;
+alarmTime.hour = 00;
+alarmTime.minute = 59;
+alarmTime.second = 59;
+alarmTime.millisecond = 0;
+/* Set the alarm time of alarm RTC_ALARM_INDEX_A. */
+ret = RtcWriteAlarm(handle, RTC_ALARM_INDEX_A, &alarmTime);
+if (ret != 0) {
+ /* Process the error. */
+}
+```
+
+- Enabling or disabling alarm interrupts
+
+Before performing alarm operations, use the following function to enable alarm interrupts, so that **RtcAlarmCallback** will be called when the alarm is not generated upon a timeout:
+
+int32\_t RtcAlarmInterruptEnable\(DevHandle handle, enum RtcAlarmIndex alarmIndex, uint8\_t enable\);
+
+**Table 9** Description of RtcAlarmInterruptEnable
+
+
+
Parameter
+
+
Description
+
+
+
handle
+
+
RTC device handle.
+
+
+
alarmIndex
+
+
Alarm index.
+
+
+
enable
+
+
Whether to enable RTC alarm interrupts. The value 1 means to enable alarm interrupts and 0 means to disable alarm interrupts.
+
+
+
Return Value
+
+
Description
+
+
+
0
+
+
The operation is successful.
+
+
+
Negative value
+
+
The operation fails.
+
+
+
+
+
+```
+int32_t ret;
+
+/* Enable the RTC alarm interrupts. */
+ret = RtcAlarmInterruptEnable(handle, RTC_ALARM_INDEX_A, 1);
+if (ret != 0) {
+ /* Process the error. */
+}
+```
+
+- Reading RTC external frequency
+
+Call the following function to read the frequency of the external crystal oscillator connected to the RTC driver:
+
+int32\_t RtcGetFreq\(DevHandle handle, uint32\_t \*freq\);
+
+**Table 10** Description of RtcGetFreq
+
+
+
Parameter
+
+
Description
+
+
+
handle
+
+
RTC device handle.
+
+
+
freq
+
+
Pointer to the frequency to set for the external crystal oscillator, in Hz.
+
+
+
Return Value
+
+
Description
+
+
+
0
+
+
The operation is successful.
+
+
+
Negative value
+
+
The operation fails.
+
+
+
+
+
+```
+int32_t ret;
+uint32_t freq = 0;
+
+/* Read frequency of the external crystal oscillator connected to the RTC driver */
+ret = RtcGetFreq(handle, &freq);
+if (ret != 0) {
+ /* Process the error. */
+}
+```
+
+- Setting the frequency of the external crystal oscillator connected to the RTC driver
+
+Call the following function to set the frequency of the external crystal oscillator connected to the RTC driver:
+
+int32\_t RtcSetFreq\(DevHandle handle, uint32\_t freq\);
+
+**Table 11** Description of RtcSetFreq
+
+
+
Parameter
+
+
Description
+
+
+
handle
+
+
RTC device handle.
+
+
+
freq
+
+
Frequency to set for the external crystal oscillator, in Hz
+
+
+
Return Value
+
+
Description
+
+
+
0
+
+
The operation is successful.
+
+
+
Negative value
+
+
The operation fails.
+
+
+
+
+
+```
+int32_t ret;
+uint32_t freq = 32768; /* 32768 Hz */
+
+/* Set the frequency of the external crystal oscillator. Note that the frequency must be configured in accordance with the requirements specified in the product manual of the in-use component. */
+ret = RtcSetFreq(handle, freq);
+if (ret != 0) {
+ /* Process the error. */
+}
+```
+
+- Resetting the RTC driver
+
+Call the following function to perform a reset on the RTC driver \(after the reset, the registers are restored to the default values\):
+
+int32\_t RtcReset\(DevHandle handle\);
+
+**Table 12** Description of RtcReset
+
+
+
Parameter
+
+
Description
+
+
+
handle
+
+
RTC device handle.
+
+
+
Return Value
+
+
Description
+
+
+
0
+
+
The operation is successful.
+
+
+
Negative value
+
+
The operation fails.
+
+
+
+
+
+```
+int32_t ret;
+
+/* Reset the RTC driver. After the reset, the configuration registers are restored to the default values. */
+ret = RtcReset(handle);
+if (ret != 0) {
+ /* Process the error. */
+}
+```
+
+- Reading the configuration of a custom RTC register
+
+Call the following function to read the configuration of a custom RTC register based on the register index \(one index corresponds to one byte of the configuration value\):
+
+int32\_t RtcReadReg\(DevHandle handle, uint8\_t usrDefIndex, uint8\_t \*value\);
+
+**Table 13** Description of RtcReadReg
+
+
+
Parameter
+
+
Description
+
+
+
handle
+
+
RTC device handle.
+
+
+
usrDefIndex
+
+
Index of the custom register
+
+
+
value
+
+
Pointer to the register value
+
+
+
Return Value
+
+
Description
+
+
+
0
+
+
The operation is successful.
+
+
+
Negative value
+
+
The operation fails.
+
+
+
+
+
+```
+int32_t ret;
+uint8_t usrDefIndex = 0; /* Define index 0 for the first custom register. */
+uint8_t value = 0;
+
+/* Read the configuration of a custom RTC register based on the register index. One index corresponds to one byte of the configuration value. */
+ret = RtcReadReg(handle, usrDefIndex, &value);
+if (ret != 0) {
+ /* Process the error. */
+}
+```
+
+- Setting the configuration of a custom RTC register
+
+Call the following function to configure a register based on the specified register index \(one index corresponds to one byte of the configuration value\):
+
+int32\_t RtcWriteReg\(DevHandle handle, uint8\_t usrDefIndex, uint8\_t value\);
+
+**Table 14** Description of RtcWriteReg
+
+
+
Parameter
+
+
Description
+
+
+
handle
+
+
RTC device handle.
+
+
+
usrDefIndex
+
+
Index of the custom register
+
+
+
value
+
+
Register value
+
+
+
Return Value
+
+
Description
+
+
+
0
+
+
The operation is successful.
+
+
+
Negative value
+
+
The operation fails.
+
+
+
+
+
+```
+int32_t ret;
+uint8_t usrDefIndex = 0; /* Define index 0 for the first custom register. */
+uint8_t value = 0x10;
+
+/* Configure a register based on the specified register index. One index corresponds to one byte of the configuration value. */
+ret = RtcWriteReg(handle, usrDefIndex, value);
+if (ret != 0) {
+ /* Process the error. */
+}
+```
+
+## Usage Example
+
+This section describes the process of using RTC APIs:
+
+1. During the OS startup, the HDF identifies the RTC component in the system.
+2. The HDF initializes and creates the RTC device.
+3. You can perform operations on the RTC device by calling different APIs.
+4. Call the **RtcClose** function to release the device handle and device resources.
+
+Example:
+
+```
+#include "rtc_if.h"
+int32_t RtcAlarmACallback(enum RtcAlarmIndex alarmIndex)
+{
+ if (alarmIndex == RTC_ALARM_INDEX_A) {
+ /* Process alarm A. */
+ printf("RTC Alarm A callback function\n\r");
+ } else if (alarmIndex == RTC_ALARM_INDEX_B) {
+ /* Process alarm B. */
+ printf("RTC Alarm B callback function\n\r");
+ } else {
+ /* Process the error. */
+ }
+ return 0;
+}
+
+void RtcTestSample(void)
+{
+ int32_t ret;
+ struct RtcTime tm;
+ struct RtcTime alarmTime;
+ uint32_t freq;
+ DevHandle handle = NULL;
+
+ /* Obtain the RTC device handle. */
+ handle = RtcOpen();
+ if (handle == NULL) {
+ /* Process the error. */
+ }
+ /* Register RtcAlarmCallback for alarm A. */
+ ret = RtcRegisterAlarmCallback(handle, RTC_ALARM_INDEX_A, RtcAlarmACallback);
+ if (ret != 0) {
+ /* Process the error. */
+ }
+ /* Set the RTC external crystal frequency. Note that the frequency must be configured in accordance with the requirements specified in the product manual of the in-use component. */
+ freq = 32768; /* 32768 Hz */
+ ret = RtcSetFreq(handle, freq);
+ if (ret != 0) {
+ /* Process the error. */
+ }
+ /* Enable the RTC alarm interrupts. */
+ ret = RtcAlarmInterruptEnable(handle, RTC_ALARM_INDEX_A, 1);
+ if (ret != 0) {
+ /* Process the error. */
+ }
+ /* Set the RTC time to 2020/01/01 00:00:10 .990. */
+ tm.year = 2020;
+ tm.month = 01;
+ tm.day = 01;
+ tm.hour= 0;
+ tm.minute = 0;
+ tm.second = 10;
+ tm.millisecond = 990;
+ /* Write the RTC time information. */
+ ret = RtcWriteTime(handle, &tm);
+ if (ret != 0) {
+ /* Process the error. */
+ }
+ /* Set the RTC alarm time to 2020/01/01 00:00:30 .100. */
+ alarmTime.year = 2020;
+ alarmTime.month = 01;
+ alarmTime.day = 01;
+ alarmTime.hour = 0;
+ alarmTime.minute = 0;
+ alarmTime.second = 30;
+ alarmTime.millisecond = 100;
+ /* Set the alarm time information for RTC_ALARM_INDEX_A. When the specified time is reached, "RTC Alarm A callback function" is printed. */
+ ret = RtcWriteAlarm(handle, RTC_ALARM_INDEX_A, &alarmTime);
+ if (ret != 0) {
+ /* Process the error. */
+ }
+
+ /* Read the RTC real time. */
+ ret = RtcReadTime(handle, &tm);
+ if (ret != 0) {
+ /* Process the error. */
+ }
+ sleep(5)
+ printf("RTC read time:\n\r");
+ printf("year-month-date-weekday hour:minute:second .millisecond %04u-%02u-%02u-%u %02u:%02u:%02u .%03u",
+ tm.year, tm.month, tm.day, tm.weekday, tm.hour, tm.minute, tm.second, tm.millisecond);
+ /* Release the RTC device handle. */
+ RtcClose(handle);
+}
+```
+
diff --git a/en/device-dev/driver/drive-platform-sdio-des.md b/en/device-dev/driver/drive-platform-sdio-des.md
new file mode 100644
index 0000000000000000000000000000000000000000..4b5a27d35334ab5e75cbf0ea3cddffd9fd9341d3
--- /dev/null
+++ b/en/device-dev/driver/drive-platform-sdio-des.md
@@ -0,0 +1,1068 @@
+# SDIO
+
+- [Overview](#section1155271783811)
+ - [Available APIs](#section08064247248)
+
+- [Usage Guidelines](#section1878939192515)
+ - [How to Use](#section1490685512255)
+ - [Opening an SDIO Controller](#section10782428132616)
+ - [Claiming a Host Exclusively](#section11263172312715)
+ - [Enabling the SDIO Device](#section17861486271)
+ - [Claiming an SDIO IRQ](#section521213262286)
+ - [Performing SDIO Communication](#section85661522153420)
+ - [Releasing the SDIO IRQ](#section1683449352)
+ - [Disabling the SDIO Device](#section15379324143611)
+ - [Releasing the Exclusively Claimed Host](#section536018263713)
+ - [Closing an SDIO Controller](#section4752739183716)
+
+- [Usage Example](#section376910122382)
+
+## Overview
+
+- Secure Digital Input/Output \(SDIO\) is a peripheral interface evolved from the Secure Digital \(SD\) memory card interface. The SDIO interface is compatible with SD memory cards and can be connected to devices that support the SDIO interface.
+- SDIO is widely used. Currently, many smartphones support SDIO, and many SDIO peripherals are developed for connections to smartphones. Common SDIO peripherals include WLAN, GPS, cameras, and Bluetooth.
+- The SDIO bus has two ends, named host and device. All communication starts when the host sends a command. The device can communicate with the host as long as it can parse the command of the host. An SDIO host can connect to multiple devices, as shown in the figure below.
+
+ - CLK signal: clock signal sent from the host to the device
+ - VDD signal: power signal
+ - VSS signal: ground signal
+ - D0-3 signal: four data lines. The DAT1 signal cable is multiplexed as the interrupt line. In 1-bit mode, DAT0 is used to transmit data. In 4-bit mode, DAT0 to DAT3 are used to transmit data.
+ - CMD signal: used by the host to send commands and the device to respond to commands.
+
+ **Figure 1** Connections between the host and devices in SDIO
+
+
+ 
+
+- The SDIO interface defines a set of common methods for operating an SDIO device, including opening and closing an SDIO controller, exclusively claiming and releasing the host, enabling and disabling devices, claiming and releasing an SDIO IRQ, reading and writing data based on SDIO, and obtaining and setting common information.
+
+### Available APIs
+
+**Table 1** APIs available for the SDIO driver
+
+
+
Capability
+
+
Function
+
+
Description
+
+
+
+
SDIO device opening/closing
+
+
SdioOpen
+
+
Opens an SDIO controller with a specified bus number.
+
+
+
SdioClose
+
+
Closes an SDIO controller.
+
+
+
SDIO reading/writing
+
+
SdioReadBytes
+
+
Incrementally reads a given length of data from a specified SDIO address.
+
+
+
SdioWriteBytes
+
+
Incrementally writes a given length of data into a specified SDIO address.
+
+
+
SdioReadBytesFromFixedAddr
+
+
Reads a given length of data from a fixed SDIO address.
+
+
+
SdioWriteBytesToFixedAddr
+
+
Writes a given length of data into a fixed SDIO address.
+
+
+
SdioReadBytesFromFunc0
+
+
Reads a given length of data from the address space of SDIO function 0.
+
+
+
SdioWriteBytesToFunc0
+
+
Writes a given length of data into the address space of SDIO function 0.
+
+
+
SDIO block size setting
+
+
SdioSetBlockSize
+
+
Sets the block size.
+
+
+
SDIO common information retrieval/setting
+
+
SdioGetCommonInfo
+
+
Obtains common information.
+
+
+
SdioSetCommonInfo
+
+
Sets common information.
+
+
+
SDIO data flushing
+
+
SdioFlushData
+
+
Flushes data.
+
+
+
SDIO host exclusively claiming or releasing
+
+
SdioClaimHost
+
+
Claims a host exclusively.
+
+
+
SdioReleaseHost
+
+
Releases the exclusively claimed host.
+
+
+
SDIO device enablement
+
+
SdioEnableFunc
+
+
Enables an SDIO device.
+
+
+
SdioDisableFunc
+
+
Disables an SDIO device.
+
+
+
SDIO IRQ claiming/releasing
+
+
SdioClaimIrq
+
+
Claims an SDIO IRQ.
+
+
+
SdioReleaseIrq
+
+
Releases an SDIO IRQ.
+
+
+
+
+
+> **NOTE:**
+>All functions provided in this document can be called only in kernel mode.
+
+## Usage Guidelines
+
+### How to Use
+
+[Figure 2](#fig1343742311264) illustrates the process of using an SDIO.
+
+**Figure 2** Process of using an SDIO
+
+
+
+
+### Opening an SDIO Controller
+
+Before performing SDIO communication, obtain the device handle of an SDIO controller by calling **SdioOpen**. This function returns the device handle of the SDIO controller with a specified bus number.
+
+DevHandle SdioOpen\(int16\_t mmcBusNum, struct SdioFunctionConfig \*config\);
+
+**Table 2** Parameters and return values of SdioOpen
+
+
+
Parameter
+
+
Description
+
+
+
+
mmcBusNum
+
+
Bus number.
+
+
+
config
+
+
SDIO functionality configurations.
+
+
+
Return Value
+
+
Description
+
+
+
NULL
+
+
Failed to obtain the device handle of an SDIO controller.
+
+
+
Device handle
+
+
Device handle of an SDIO controller.
+
+
+
+
+
+The following example shows how to open an SDIO controller.
+
+```
+DevHandle handle = NULL;
+struct SdioFunctionConfig config;
+config.funcNr = 1;
+config.vendorId = 0x123;
+config.deviceId = 0x456;
+/* Open an SDIO controller whose bus number is 1. */
+handle = SdioOpen(1, &config);
+if (handle == NULL) {
+ HDF_LOGE("SdioOpen: failed!\n");
+}
+```
+
+### Claiming a Host Exclusively
+
+After obtaining the device handle of an SDIO controller, exclusively claim the host before performing subsequent operations on the SDIO device.
+
+void SdioClaimHost\(DevHandle handle\);
+
+**Table 3** Parameter description of SdioClaimHost
+
+
+
Parameter
+
+
Description
+
+
+
+
handle
+
+
Device handle of an SDIO controller.
+
+
+
+
+
+The following example shows how to exclusively claim a host.
+
+```
+SdioClaimHost(handle); /* Claim a host exclusively. */
+```
+
+### Enabling the SDIO Device
+
+Before accessing a register, enable the SDIO device.
+
+int32\_t SdioEnableFunc\(DevHandle handle\);
+
+**Table 4** Parameters and return values of SdioEnableFunc
+
+
+
Parameter
+
+
Description
+
+
+
+
handle
+
+
Device handle of an SDIO controller.
+
+
+
Return Value
+
+
Description
+
+
+
0
+
+
The SDIO device is enabled.
+
+
+
Negative value
+
+
Failed to enable the SDIO device.
+
+
+
+
+
+The following example shows how to enable the SDIO device.
+
+```
+int32_t ret;
+/* Enable the SDIO device. */
+ret = SdioEnableFunc(handle);
+if (ret != 0) {
+ HDF_LOGE("SdioEnableFunc: failed, ret %d\n", ret);
+}
+```
+
+### Claiming an SDIO IRQ
+
+Before SDIO communication, claim an SDIO IRQ.
+
+int32\_t SdioClaimIrq\(DevHandle handle, SdioIrqHandler \*handler\);
+
+**Table 5** Parameters and return values of SdioClaimIrq
+
+
+
Parameter
+
+
Description
+
+
+
+
handle
+
+
Device handle of an SDIO controller.
+
+
+
handler
+
+
Pointer to the SDIO IRQ function.
+
+
+
Return Value
+
+
Description
+
+
+
0
+
+
The SDIO IRQ is claimed.
+
+
+
Negative value
+
+
Failed to claim an SDIO IRQ.
+
+
+
+
+
+The following example shows how to claim an SDIO IRQ.
+
+```
+/* Implement the SDIO IRQ function based on the application. */
+static void SdioIrqFunc(void *data)
+{
+ if (data == NULL) {
+ HDF_LOGE("SdioIrqFunc: data is NULL.\n");
+ return;
+ }
+ /* You need to add specific implementations. */
+}
+
+int32_t ret;
+/* Claim an SDIO IRQ. */
+ret = SdioClaimIrq(handle, SdioIrqFunc);
+if (ret != 0) {
+ HDF_LOGE("SdioClaimIrq: failed, ret %d\n", ret);
+}
+```
+
+### Performing SDIO Communication
+
+- Incrementally write a given length of data into the SDIO device.
+
+The corresponding function is as follows:
+
+int32\_t SdioWriteBytes\(DevHandle handle, uint8\_t \*data, uint32\_t addr, uint32\_t size\);
+
+**Table 6** Parameters and return values of SdioWriteBytes
+
+
+
Parameter
+
+
Description
+
+
+
+
handle
+
+
Device handle of an SDIO controller.
+
+
+
data
+
+
Pointer to the data to write.
+
+
+
addr
+
+
Start address where the data is written into.
+
+
+
size
+
+
Length of the data to write.
+
+
+
Return Value
+
+
Description
+
+
+
0
+
+
Data is written into the SDIO device.
+
+
+
Negative value
+
+
Failed to write data into the SDIO device.
+
+
+
+
+
+The following example shows how to incrementally write a given length of data into the SDIO device.
+
+```
+int32_t ret;
+uint8_t wbuff[] = {1,2,3,4,5};
+uint32_t addr = 0x100 + 0x09;
+/* Incrementally write 5-byte data into the start address 0x109 of the SDIO device. */
+ret = SdioWriteBytes(handle, wbuff, addr, sizeof(wbuff) / sizeof(wbuff[0]));
+if (ret != 0) {
+ HDF_LOGE("SdioWriteBytes: failed, ret %d\n", ret);
+}
+```
+
+- Incrementally read a given length of data from the SDIO device.
+
+The corresponding function is as follows:
+
+int32\_t SdioReadBytes\(DevHandle handle, uint8\_t \*data, uint32\_t addr, uint32\_t size\);
+
+**Table 7** Parameters and return values of SdioReadBytes
+
+
+
Parameter
+
+
Description
+
+
+
+
handle
+
+
Device handle of an SDIO controller.
+
+
+
data
+
+
Pointer to the data to read.
+
+
+
addr
+
+
Start address where the data is read from.
+
+
+
size
+
+
Length of the data to read.
+
+
+
Return Value
+
+
Description
+
+
+
0
+
+
Data is read from the SDIO device.
+
+
+
Negative value
+
+
Failed to read data from the SDIO device.
+
+
+
+
+
+The following example shows how to incrementally read a given length of data from the SDIO device.
+
+```
+int32_t ret;
+uint8_t rbuff[5] = {0};
+uint32_t addr = 0x100 + 0x09;
+/* Incrementally read 5-byte data from the start address 0x109 of the SDIO device. */
+ret = SdioReadBytes(handle, rbuff, addr, 5);
+if (ret != 0) {
+ HDF_LOGE("SdioReadBytes: failed, ret %d\n", ret);
+}
+```
+
+- Write a given length of data into the fixed address of an SDIO device.
+
+ The corresponding function is as follows:
+
+ int32\_t SdioWriteBytesToFixedAddr\(DevHandle handle, uint8\_t \*data, uint32\_t addr, uint32\_t size, uint32\_t scatterLen\);
+
+ **Table 8** Parameters and return values of SdioWriteBytesToFixedAddr
+
+
+
Parameter
+
+
Description
+
+
+
+
handle
+
+
Device handle of an SDIO controller.
+
+
+
data
+
+
Pointer to the data to write.
+
+
+
addr
+
+
Fixed address where the data is written into.
+
+
+
size
+
+
Length of the data to write.
+
+
+
scatterLen
+
+
Length of the scatter list. If the value is not 0, the data is of the scatter list type.
+
+
+
Return Value
+
+
Description
+
+
+
0
+
+
Data is written into the SDIO device.
+
+
+
Negative value
+
+
Failed to write data into the SDIO device.
+
+
+
+
+
+ The following example shows how to write a given length of data into the fixed address of an SDIO device.
+
+ ```
+ int32_t ret;
+ uint8_t wbuff[] = {1, 2, 3, 4, 5};
+ uint32_t addr = 0x100 + 0x09;
+ /* Write 5-byte data into the fixed address 0x109 of the SDIO device. */
+ ret = SdioWriteBytesToFixedAddr(handle, wbuff, addr, sizeof(wbuff) / sizeof(wbuff[0]), 0);
+ if (ret != 0) {
+ HDF_LOGE("SdioWriteBytesToFixedAddr: failed, ret %d\n", ret);
+ }
+ ```
+
+- Read a given length of data from the fixed address of an SDIO device.
+
+ The corresponding function is as follows:
+
+ int32\_t SdioReadBytesFromFixedAddr\(DevHandle handle, uint8\_t \*data, uint32\_t addr, uint32\_t size, uint32\_t scatterLen\);
+
+ **Table 9** Parameters and return values of SdioReadBytesFromFixedAddr
+
+
+
Parameter
+
+
Description
+
+
+
+
handle
+
+
Device handle of an SDIO controller.
+
+
+
data
+
+
Pointer to the data to read.
+
+
+
addr
+
+
Start address where the data is read from.
+
+
+
size
+
+
Length of the data to read.
+
+
+
scatterLen
+
+
Length of the scatter list. If the value is not 0, the data is of the scatter list type.
+
+
+
Return Value
+
+
Description
+
+
+
0
+
+
Data is read from the SDIO device.
+
+
+
Negative value
+
+
Failed to read data from the SDIO device.
+
+
+
+
+
+ The following example shows how to read a given length of data from the fixed address of an SDIO device.
+
+ ```
+ int32_t ret;
+ uint8_t rbuff[5] = {0};
+ uint32_t addr = 0x100 + 0x09;
+ /* Read 5-byte data from the fixed address 0x109 of the SDIO device. */
+ ret = SdioReadBytesFromFixedAddr(handle, rbuff, addr, 5, 0);
+ if (ret != 0) {
+ HDF_LOGE("SdioReadBytesFromFixedAddr: failed, ret %d\n", ret);
+ }
+ ```
+
+
+- Writes a given length of data into the address space of SDIO function 0.
+
+Currently, only 1-byte data can be written. The corresponding function is as follows:
+
+int32\_t SdioWriteBytesToFunc0\(DevHandle handle, uint8\_t \*data, uint32\_t addr, uint32\_t size\);
+
+**Table 10** Parameters and return values of SdioWriteBytesToFunc0
+
+
+
Parameter
+
+
Description
+
+
+
+
handle
+
+
Device handle of an SDIO controller.
+
+
+
data
+
+
Pointer to the data to write.
+
+
+
addr
+
+
Start address where the data is written into.
+
+
+
size
+
+
Length of the data to write.
+
+
+
Return Value
+
+
Description
+
+
+
0
+
+
Data is written into the SDIO device.
+
+
+
Negative value
+
+
Failed to write data into the SDIO device.
+
+
+
+
+
+The following example shows how to write a given length of data into the address space of SDIO function 0.
+
+```
+int32_t ret;
+uint8_t wbuff = 1;
+/* Write 1-byte data into the address 0x2 of SDIO function 0. */
+ret = SdioWriteBytesToFunc0(handle, &wbuff, 0x2, 1);
+if (ret != 0) {
+ HDF_LOGE("SdioWriteBytesToFunc0: failed, ret %d\n", ret);
+}
+```
+
+- Reads a given length of data from the address space of SDIO function 0.
+
+Currently, only 1-byte data can be read. The corresponding function is as follows:
+
+int32\_t SdioReadBytesFromFunc0\(DevHandle handle, uint8\_t \*data, uint32\_t addr, uint32\_t size\);
+
+**Table 11** Parameters and return values of SdioReadBytesFromFunc0
+
+
+
Parameter
+
+
Description
+
+
+
+
handle
+
+
Device handle of an SDIO controller.
+
+
+
data
+
+
Pointer to the data to read.
+
+
+
addr
+
+
Start address where the data is read from.
+
+
+
size
+
+
Length of the data to read.
+
+
+
Return Value
+
+
Description
+
+
+
0
+
+
Data is read from the SDIO device.
+
+
+
Negative value
+
+
Failed to read data from the SDIO device.
+
+
+
+
+
+The following example shows how to read a given length of data from the address space of SDIO function 0.
+
+```
+int32_t ret;
+uint8_t rbuff;
+/* Read 1-byte data from the address 0x2 of SDIO function 0. */
+ret = SdioReadBytesFromFunc0(handle, &rbuff, 0x2, 1);
+if (ret != 0) {
+ HDF_LOGE("SdioReadBytesFromFunc0: failed, ret %d\n", ret);
+}
+```
+
+### Releasing the SDIO IRQ
+
+After the SDIO communication, release the SDIO IRQ.
+
+int32\_t SdioReleaseIrq\(DevHandle handle\);
+
+**Table 12** Parameters and return values of SdioReleaseIrq
+
+
+
Parameter
+
+
Description
+
+
+
+
handle
+
+
Device handle of an SDIO controller.
+
+
+
Return Value
+
+
Description
+
+
+
0
+
+
The SDIO IRQ is released.
+
+
+
Negative value
+
+
Failed to release the SDIO IRQ.
+
+
+
+
+
+The following example shows how to release the SDIO IRQ.
+
+```
+int32_t ret;
+/* Release the SDIO IRQ. */
+ret = SdioReleaseIrq(handle);
+if (ret != 0) {
+ HDF_LOGE("SdioReleaseIrq: failed, ret %d\n", ret);
+}
+```
+
+### Disabling the SDIO Device
+
+After the SDIO communication, disable the SDIO device.
+
+int32\_t SdioDisableFunc\(DevHandle handle\);
+
+**Table 13** Parameters and return values of SdioDisableFunc
+
+
+
Parameter
+
+
Description
+
+
+
+
handle
+
+
Device handle of an SDIO controller.
+
+
+
Return Value
+
+
Description
+
+
+
0
+
+
The SDIO device is disabled.
+
+
+
Negative value
+
+
Failed to disable the SDIO device.
+
+
+
+
+
+The following example shows how to disable the SDIO device.
+
+```
+int32_t ret;
+/* Disable the SDIO device. */
+ret = SdioDisableFunc(handle);
+if (ret != 0) {
+ HDF_LOGE("SdioDisableFunc: failed, ret %d\n", ret);
+}
+```
+
+### Releasing the Exclusively Claimed Host
+
+After the SDIO communication, release the exclusively claimed host.
+
+void SdioReleaseHost\(DevHandle handle\);
+
+**Table 14** Parameter description of SdioReleaseHost
+
+
+
Parameter
+
+
Description
+
+
+
+
handle
+
+
Device handle of an SDIO controller.
+
+
+
+
+
+The following example shows how to release the exclusively claimed host.
+
+```
+SdioReleaseHost(handle); /* Release the exclusively claimed host. */
+```
+
+### Closing an SDIO Controller
+
+After the SDIO communication, close the SDIO controller.
+
+void SdioClose\(DevHandle handle\);
+
+This function releases the resources requested.
+
+**Table 15** Parameter description of SdioClose
+
+
+
Parameter
+
+
Description
+
+
+
+
handle
+
+
Device handle of an SDIO controller.
+
+
+
+
+
+The following example shows how to close an SDIO controller.
+
+```
+SdioClose(handle); /* Close an SDIO controller. */
+```
+
+## Usage Example
+
+The following example shows how to use an SDIO device. First, open an SDIO controller whose bus number is 1, exclusively claim a host, enable the SDIO device, claim an SDIO IRQ, and then perform SDIO communication \(such as reading and writing\). After the SDIO communication, release the SDIO IRQ, disable the SDIO device, release the host, and close the SDIO controller.
+
+```
+#include "hdf_log.h"
+#include "sdio_if.h"
+
+#define TEST_FUNC_NUM 1 /* The I/O function whose ID is 1 is used. */
+#define TEST_FBR_BASE_ADDR 0x100 /* FBR base address of the I/O function whose ID is 1 */
+#define TEST_ADDR_OFFSET 9 /* Address offset of the register to read or write */
+#define TEST_DATA_LEN 3 /* Length of the data to read or write */
+#define TEST_BLOCKSIZE 2 /* Size of a data block, in bytes */
+
+/* Implement the SDIO IRQ function based on the application. */
+static void SdioIrqFunc(void *data)
+{
+ if (data == NULL) {
+ HDF_LOGE("SdioIrqFunc: data is NULL.\n");
+ return;
+ }
+ /* You need to add specific implementations. */
+}
+
+void SdioTestSample(void)
+{
+ int32_t ret;
+ DevHandle handle = NULL;
+ uint8_t data[TEST_DATA_LEN] = {0};
+ struct SdioFunctionConfig config = {1, 0x123, 0x456};
+ uint8_t val;
+ uint32_t addr;
+
+ /* Open an SDIO controller whose bus number is 1. */
+ handle = SdioOpen(1, &config);
+ if (handle == NULL) {
+ HDF_LOGE("SdioOpen: failed!\n");
+ return;
+ }
+ /* Claim a host exclusively. */
+ SdioClaimHost(handle);
+ /* Enable the SDIO device. */
+ ret = SdioEnableFunc(handle);
+ if (ret != 0) {
+ HDF_LOGE("SdioEnableFunc: failed, ret %d\n", ret);
+ goto ENABLE_ERR;
+ }
+ /* Claim an SDIO IRQ. */
+ ret = SdioClaimIrq(handle, SdioIrqFunc);
+ if (ret != 0) {
+ HDF_LOGE("SdioClaimIrq: failed, ret %d\n", ret);
+ goto CLAIM_IRQ_ERR;
+ }
+ /* Set the block size to 2 bytes. */
+ ret = SdioSetBlockSize(handle, TEST_BLOCKSIZE);
+ if (ret != 0) {
+ HDF_LOGE("SdioSetBlockSize: failed, ret %d\n", ret);
+ goto COMM_ERR;
+ }
+ /* Read 3-byte data from the incremental address of an SDIO device. */
+ addr = TEST_FBR_BASE_ADDR * TEST_FUNC_NUM + TEST_ADDR_OFFSET;
+ ret = SdioReadBytes(handle, data, addr, TEST_DATA_LEN);
+ if (ret != 0) {
+ HDF_LOGE("SdioReadBytes: failed, ret %d\n", ret);
+ goto COMM_ERR;
+ }
+ /* Write 3-byte data into the incremental address of an SDIO device. */
+ ret = SdioWriteBytes(handle, data, addr, TEST_DATA_LEN);
+ if (ret != 0) {
+ HDF_LOGE("SdioWriteBytes: failed, ret %d\n", ret);
+ goto COMM_ERR;
+ }
+ /* Read 1-byte data from the SDIO device. */
+ ret = SdioReadBytes(handle, &val, addr, 1);
+ if (ret != 0) {
+ HDF_LOGE("SdioReadBytes: failed, ret %d\n", ret);
+ goto COMM_ERR;
+ }
+ /* Write 1-byte data into the SDIO device. */
+ ret = SdioWriteBytes(handle, &val, addr, 1);
+ if (ret != 0) {
+ HDF_LOGE("SdioWriteBytes: failed, ret %d\n", ret);
+ goto COMM_ERR;
+ }
+ /* Read 3-byte data from the fixed address of an SDIO device. */
+ ret = SdioReadBytesFromFixedAddr(handle, data, addr, TEST_DATA_LEN, 0);
+ if (ret != 0) {
+ HDF_LOGE("SdioReadBytesFromFixedAddr: failed, ret %d\n", ret);
+ goto COMM_ERR;
+ }
+ /* Write 1-byte data to the fixed address of an SDIO device. */
+ ret = SdioWriteBytesToFixedAddr(handle, data, addr, 1, 0);
+ if (ret != 0) {
+ HDF_LOGE("SdioWriteBytesToFixedAddr: failed, ret %d\n", ret);
+ goto COMM_ERR;
+ }
+ /* Read 1-byte data from SDIO function 0. */
+ addr = 0x02;
+ ret = SdioReadBytesFromFunc0(handle, &val, addr, 1);
+ if (ret != 0) {
+ HDF_LOGE("SdioReadBytesFromFunc0: failed, ret %d\n", ret);
+ goto COMM_ERR;
+ }
+ /* Write 1-byte data into SDIO function 0. */
+ ret = SdioWriteBytesToFunc0(handle, &val, addr, 1);
+ if (ret != 0) {
+ HDF_LOGE("SdioWriteBytesToFunc0: failed, ret %d\n", ret);
+ goto COMM_ERR;
+ }
+COMM_ERR:
+ /* Release the SDIO IRQ. */
+ ret = SdioReleaseIrq(handle);
+ if (ret != 0) {
+ HDF_LOGE("SdioReleaseIrq: failed, ret %d\n", ret);
+ }
+CLAIM_IRQ_ERR:
+ /* Disable the SDIO device. */
+ ret = SdioDisableFunc(handle);
+ if (ret != 0) {
+ HDF_LOGE("SdioDisableFunc: failed, ret %d\n", ret);
+ }
+ENABLE_ERR:
+ /* Release the exclusively claimed host. */
+ SdioReleaseHost(handle);
+ /* Close an SDIO controller. */
+ SdioClose(handle);
+}
+```
+
diff --git a/en/device-dev/driver/drive-platform-spi-des.md b/en/device-dev/driver/drive-platform-spi-des.md
new file mode 100644
index 0000000000000000000000000000000000000000..b2c1b31147091e2d28ff902727f8ec7c1abfef80
--- /dev/null
+++ b/en/device-dev/driver/drive-platform-spi-des.md
@@ -0,0 +1,566 @@
+# SPI
+
+- [Overview](#section193356154511)
+ - [Available APIs](#section232141411476)
+
+- [Usage Guidelines](#section71363452477)
+ - [How to Use](#section32846814820)
+ - [Obtaining an SPI Device Handle](#section1927265711481)
+ - [Obtaining SPI Device Configuration Parameters](#section541133418493)
+ - [Setting SPI Device Configuration Parameters](#section7870106145010)
+ - [Performing SPI Communication](#section13324155195013)
+ - [Destroying the SPI Device Handle](#section19661632135117)
+
+- [Usage Example](#section06541058155120)
+
+## Overview
+
+- Serial Peripheral Interface \(SPI\) is a serial bus specification used for high-speed, full-duplex, and synchronous communication.
+- SPI is developed by Motorola. It is commonly used for communication with flash memory, real-time clocks, sensors, and analog-to-digital \(A/D\) converters.
+- SPI works in controller/device mode. Generally, there is one SPI controller that controls one or more SPI devices. They are connected via four wires:
+ - SCLK: clock signals output from the SPI controller
+ - MOSI: data output from the SPI controller and input into an SPI device
+ - MISO: data output from an SPI device and input into the SPI controller
+ - CS: signals enabled by an SPI device and controlled by the SPI controller
+
+
+- [Figure 1](#fig15227181812587) shows the connection between one SPI controller and two SPI devices \(device A and device B\). In this figure, device A and device B share three pins \(SCLK, MISO, and MOSI\) of the controller. CS0 of device A and CS1 of device B are connected to CS0 and CS1 of the controller, respectively.
+
+**Figure 1** SPI controller/device connection
+
+
+
+
+- SPI communication is usually initiated by the SPI controller and is operated as follows:
+
+1. A single SPI device is selected at a time via the CS to communicate with the SPI controller.
+2. Clock signals are provided for the selected SPI device via the SCLK.
+3. The SPI controller sends data to SPI devices via the MOSI, and receives data from SPI devices via the MISO.
+
+- SPI can work in one of the following four modes, equivalent to one of the four possible states for Clock Polarity \(CPOL\) and Clock Phase \(CPHA\):
+ - If both CPOL and CPHA are **0**, the clock signal level is low in the idle state and data is sampled on the first clock edge.
+ - If CPOL is **0** and CPHA is **1**, the clock signal level is low in the idle state and data is sampled on the second clock edge.
+ - If CPOL is **1** and CPHA is **0**, the clock signal level is high in the idle state and data is sampled on the first clock edge.
+ - If both CPOL and CPHA are **1**, the clock signal level is high in the idle state and data is sampled on the second clock edge.
+
+
+- SPI defines a set of common functions for operating an SPI device, including those for:
+ - Obtaining and releasing the handle of an SPI device.
+ - Reading or writing data of a specified length from or into an SPI device.
+ - Customizing data reading or writing via **SpiMsg**.
+ - Obtaining and setting SPI device configuration parameters.
+
+
+> **NOTE:**
+>Currently, these functions are only applicable in the communication initiated by the SPI controller.
+
+### Available APIs
+
+**Table 1** APIs for the SPI driver
+
+
+
Capability
+
+
Function
+
+
Description
+
+
+
+
SPI device handle obtaining/releasing
+
+
SpiOpen
+
+
Obtains an SPI device handle.
+
+
+
SpiClose
+
+
Releases an SPI device handle.
+
+
+
SPI reading/writing
+
+
SpiRead
+
+
Reads data of a specified length from an SPI device.
+
+
+
SpiWrite
+
+
Writes data of a specified length into an SPI device.
+
+
+
SpiTransfer
+
+
Transfers SPI data.
+
+
+
SPI device configuration
+
+
+
SpiSetCfg
+
+
Sets configuration parameters for an SPI device.
+
+
+
SpiGetCfg
+
+
Obtains configuration parameters of an SPI device.
+
+
+
+
+
+> **NOTE:**
+>All functions provided in this document can be called only in kernel space.
+
+## Usage Guidelines
+
+### How to Use
+
+[Figure 2](#fig23885455594) shows the process of using an SPI device.
+
+**Figure 2** Process of using an SPI device
+
+
+
+
+### Obtaining an SPI Device Handle
+
+Before performing SPI communication, obtain an SPI device handle by calling **SpiOpen**. This function returns an SPI device handle with a specified bus number and CS number.
+
+DevHandle SpiOpen\(const struct SpiDevInfo \*info\);
+
+**Table 2** Description of **SpiOpen**
+
+
+
Parameter
+
+
Description
+
+
+
info
+
+
Pointer to the SPI device descriptor.
+
+
+
Return Value
+
+
Description
+
+
+
NULL
+
+
Failed to obtain an SPI device handle.
+
+
+
Device handle
+
+
Returns the pointer to the SPI device handle.
+
+
+
+
+
+The following example shows how to obtain an SPI device handle based on the assumption that both the bus number and CS number of the SPI device are **0**.
+
+```
+struct SpiDevInfo spiDevinfo; /* SPI device descriptor */
+DevHandle spiHandle = NULL; /* SPI device handle */
+spiDevinfo.busNum = 0; /* SPI device bus number */
+spiDevinfo.csNum = 0; /* SPI device CS number */
+
+/* Obtain an SPI device handle. */
+spiHandle = SpiOpen(&spiDevinfo);
+if (spiHandle == NULL) {
+ HDF_LOGE("SpiOpen: failed\n");
+ return;
+}
+```
+
+### Obtaining SPI Device Configuration Parameters
+
+After obtaining the SPI device handle, obtain the SPI device configuration parameters by calling the following function:
+
+int32\_t SpiGetCfg\(DevHandle handle, struct SpiCfg \*cfg\);
+
+**Table 3** Description of **SpiGetCfg**
+
+
+
Parameter
+
+
Description
+
+
+
handle
+
+
SPI device handle.
+
+
+
cfg
+
+
Pointer to SPI device configuration parameters.
+
+
+
Return Value
+
+
Description
+
+
+
0
+
+
Succeeded in obtaining SPI device configuration parameters.
+
+
+
Negative value
+
+
Failed to obtain SPI device configuration parameters.
+
+
+
+
+
+```
+int32_t ret;
+struct SpiCfg cfg = {0}; /* SPI configuration information */
+ret = SpiGetCfg(spiHandle, &cfg); /* Set SPI device configuration parameters. */
+if (ret != 0) {
+ HDF_LOGE("SpiGetCfg: failed, ret %d\n", ret);
+}
+```
+
+### Setting SPI Device Configuration Parameters
+
+After obtaining the SPI device handle, set SPI device configuration parameters by calling the following function:
+
+int32\_t SpiSetCfg\(DevHandle handle, struct SpiCfg \*cfg\);
+
+**Table 4** Description of **SpiSetCfg**
+
+
+
Parameter
+
+
Description
+
+
+
handle
+
+
SPI device handle.
+
+
+
cfg
+
+
Pointer to SPI device configuration parameters.
+
+
+
Return Value
+
+
Description
+
+
+
0
+
+
Succeeded in setting SPI device configuration parameters.
+
+
+
Negative value
+
+
Failed to set SPI device configuration parameters.
+
+
+
+
+
+```
+int32_t ret;
+struct SpiCfg cfg = {0}; /* SPI configuration information */
+cfg.mode = SPI_MODE_LOOP; /* Communication in loopback mode */
+cfg.transferMode = PAL_SPI_POLLING_TRANSFER; /* Communication in polling mode */
+cfg.maxSpeedHz = 115200; /* Maximum transmission frequency */
+cfg.bitsPerWord = 8; /* The width of per word to be read or written is 8 bits. */
+ret = SpiSetCfg(spiHandle, &cfg); /* Set SPI device configuration parameters. */
+if (ret != 0) {
+ HDF_LOGE("SpiSetCfg: failed, ret %d\n", ret);
+}
+```
+
+### Performing SPI Communication
+
+- Writing data of a specific length into an SPI device
+
+To write data into an SPI device only once, call the following function:
+
+int32\_t SpiWrite\(DevHandle handle, uint8\_t \*buf, uint32\_t len\);
+
+**Table 5** Description of **SpiWrite**
+
+
+
Parameter
+
+
Description
+
+
+
handle
+
+
SPI device handle.
+
+
+
buf
+
+
Pointer to the data to write.
+
+
+
len
+
+
Length of the data to write.
+
+
+
Return Value
+
+
Description
+
+
+
0
+
+
Succeeded in writing data into an SPI device.
+
+
+
Negative value
+
+
Failed to write data into an SPI device.
+
+
+
+
+
+```
+int32_t ret;
+uint8_t wbuff[4] = {0x12, 0x34, 0x56, 0x78};
+/* Write data of a specific length into an SPI device. */
+ret = SpiWrite(spiHandle, wbuff, 4);
+if (ret != 0) {
+ HDF_LOGE("SpiWrite: failed, ret %d\n", ret);
+}
+```
+
+- Reading data of a specific length from an SPI device
+
+To read data from an SPI device only once, call the following function:
+
+int32\_t SpiRead\(DevHandle handle, uint8\_t \*buf, uint32\_t len\);
+
+**Table 6** Description of **SpiRead**
+
+
+
Parameter
+
+
Description
+
+
+
handle
+
+
SPI device handle.
+
+
+
buf
+
+
Pointer to the data to read.
+
+
+
len
+
+
Length of the data to read.
+
+
+
Return Value
+
+
Description
+
+
+
0
+
+
Succeeded in reading data from an SPI device.
+
+
+
Negative value
+
+
Failed to read data from an SPI device.
+
+
+
+
+
+```
+int32_t ret;
+uint8_t rbuff[4] = {0};
+/* Read data of a specific length from an SPI device. */
+ret = SpiRead(spiHandle, rbuff, 4);
+if (ret != 0) {
+ HDF_LOGE("SpiRead: failed, ret %d\n", ret);
+}
+```
+
+- Launching a custom transfer
+
+To launch a custom transfer, call the following function:
+
+int32\_t SpiTransfer\(DevHandle handle, struct SpiMsg \*msgs, uint32\_t count\);
+
+**Table 7** Description of **SpiTransfer**
+
+
+
Parameter
+
+
Description
+
+
+
handle
+
+
SPI device handle.
+
+
+
msgs
+
+
Pointer to the message array to be transferred.
+
+
+
count
+
+
Number of messages in the message array.
+
+
+
Return Value
+
+
Description
+
+
+
0
+
+
Succeeded in launching the custom transfer.
+
+
+
Negative value
+
+
Failed to launch the custom transfer.
+
+
+
+
+
+```
+int32_t ret;
+uint8_t wbuff[1] = {0x12};
+uint8_t rbuff[1] = {0};
+struct SpiMsg msg; /* Custom message to be transferred */
+msg.wbuf = wbuff; /* Pointer to the data to write */
+msg.rbuf = rbuff; /* Pointer to the data to read */
+msg.len = 1; /* The length of the data to read or write is 1 bit. */
+msg.csChange = 1; /* Disable the CS before the next transfer. */
+msg.delayUs = 0; /* No delay before the next transfer */
+msg.speed = 115200; /* Speed of this transfer */
+/* Launch a custom transfer. The number of messages to be transferred is 1. */
+ret = SpiTransfer(spiHandle, &msg, 1);
+if (ret != 0) {
+ HDF_LOGE("SpiTransfer: failed, ret %d\n", ret);
+}
+```
+
+### Destroying the SPI Device Handle
+
+After the SPI communication, destroy the SPI device handle by calling the following function:
+
+void SpiClose\(DevHandle handle\);
+
+This function will release the resources previously obtained.
+
+**Table 8** Description of **SpiClose**
+
+
+
Parameter
+
+
Description
+
+
+
handle
+
+
SPI device handle.
+
+
+
+
+
+```
+PalHandleDestroy(spiHandle); /* Destroy the SPI device handle. */
+```
+
+## Usage Example
+
+The following example shows how to obtain an SPI device handle, set the configuration parameters, and then read or write data from or into the SPI device, and finally destroy the SPI device handle.
+
+```
+#include "hdf_log.h"
+#include "spi_if.h"
+
+void SpiTestSample(void)
+{
+ int32_t ret;
+ struct SpiCfg cfg; /* SPI device configuration information */
+ struct SpiDevInfo spiDevinfo; /* SPI device descriptor */
+ DevHandle spiHandle = NULL; /* SPI device handle */
+ struct SpiMsg msg; /* Custom message to be transferred */
+ uint8_t rbuff[4] = { 0 };
+ uint8_t wbuff[4] = { 0x12, 0x34, 0x56, 0x78 };
+ uint8_t wbuff2[4] = { 0xa1, 0xb2, 0xc3, 0xd4 };
+
+ spiDevinfo.busNum = 0; /* SPI device bus number */
+ spiDevinfo.csNum = 0; /* SPI device CS number */
+ spiHandle = SpiOpen(&spiDevinfo); /* Obtain an SPI device handle based on spiDevinfo. */
+ if (spiHandle == NULL) {
+ HDF_LOGE("SpiOpen: failed\n");
+ return;
+ }
+ /* Obtain configuration parameters of an SPI device. */
+ ret = SpiGetCfg(spiHandle, &cfg);
+ if (ret != 0) {
+ HDF_LOGE("SpiGetCfg: failed, ret %d\n", ret);
+ goto err;
+ }
+ cfg.maxSpeedHz = 115200; /* Change the maximum clock frequency to 115200. */
+ cfg.bitsPerWord = 8; /* Change the word width to 8 bits. */
+ /* Set configuration parameters for an SPI device. */
+ ret = SpiSetCfg(spiHandle, &cfg);
+ if (ret != 0) {
+ HDF_LOGE("SpiSetCfg: failed, ret %d\n", ret);
+ goto err;
+ }
+ /* Write specified length of data into an SPI device. */
+ ret = SpiWrite(spiHandle, wbuff, 4);
+ if (ret != 0) {
+ HDF_LOGE("SpiWrite: failed, ret %d\n", ret);
+ goto err;
+ }
+ /* Read data of a specified length from an SPI device. */
+ ret = SpiRead(spiHandle, rbuff, 4);
+ if (ret != 0) {
+ HDF_LOGE("SpiRead: failed, ret %d\n", ret);
+ goto err;
+ }
+ msg.wbuf = wbuff2; /* Pointer to the data to write */
+ msg.rbuf = rbuff; /* Pointer to the data to read */
+ msg.len = 4; /* The length of the data to read or write is 4 bits. */
+ msg.csChange = 1; /* Disable the CS before the next transfer. */
+ msg.delayUs = 0; /* No delay before the next transfer */
+ msg.speed = 115200; /* Speed of this transfer */
+ /* Launch a custom transfer. The number of messages to be transferred is 1. */
+ ret = SpiTransfer(spiHandle, &msg, 1);
+ if (ret != 0) {
+ HDF_LOGE("SpiTransfer: failed, ret %d\n", ret);
+ goto err;
+ }
+err:
+ /* Destroy the SPI device handle. */
+ SpiClose(spiHandle);
+}
+```
+
diff --git a/en/device-dev/driver/drive-platform-uart-des.md b/en/device-dev/driver/drive-platform-uart-des.md
new file mode 100644
index 0000000000000000000000000000000000000000..a789594525e5d6ebb9270dadd540a35e3d76f887
--- /dev/null
+++ b/en/device-dev/driver/drive-platform-uart-des.md
@@ -0,0 +1,682 @@
+# UART
+
+- [Overview](#section833012453535)
+ - [Available APIs](#section1680292311549)
+
+- [Usage Guidelines](#section12779050105412)
+ - [How to Use](#section1858116395510)
+ - [Obtaining a UART Device Handle](#section124512065617)
+ - [Setting the UART Baud Rate](#section86881004579)
+ - [Obtaining the UART Baud Rate](#section897032965712)
+ - [Setting the UART Device Attributes](#section129141884588)
+ - [Obtaining UART Device Attributes](#section18689637165812)
+ - [Setting the UART Transmission Mode](#section72713435918)
+ - [Writing Data of a Specified Length into a UART Device](#section128001736155919)
+ - [Reading Data of a Specified Length from a UART Device](#section92851601604)
+ - [Destroying the UART Device Handle](#section1477410521406)
+
+- [Usage Example](#section35404241311)
+
+## Overview
+
+- The Universal Asynchronous Receiver/Transmitter \(UART\) is a universal serial data bus used for asynchronous communication. It enables bi-directional communication between devices in full-duplex mode.
+- UART is widely used to print information for debugging or to connect to various external modules such as GPS and Bluetooth.
+- A UART is connected to other modules through two wires \(as shown in [Figure 1](#fig209936401896)\) or four wires \(as shown in [Figure 2](#fig1435614171015)\).
+ - TX: TX pin of the transmitting UART. It is connected to the RX pin of the peer UART.
+ - RX: RX pin of the receiving UART. It is connected to the TX pin of the peer UART.
+ - RTS: Request to Send signal pin. It is connected to the CTS pin of the peer UART and is used to indicate whether the local UART is ready to receive data.
+ - CTS: Clear to Send signal pin. It is connected to the RTS pin of the peer UART and is used to indicate whether the local UART is allowed to send data to the peer end.
+
+ **Figure 1** 2-wire UART communication
+
+
+ 
+
+ **Figure 2** 4-wire UART communication
+
+
+ 
+
+
+- The transmitting and receiving UARTs must ensure that they have the same settings on particular attributes such as the baud rate and data format \(start bit, data bit, parity bit, and stop bit\) before they start to communicate. During data transmission, a UART sends data to the peer end over the TX pin and receives data from the peer end over the RX pin. When the size of the buffer used by a UART for storing received data reaches the preset threshold, the RTS signal of the UART changes to **1** \(data cannot be received\), and the peer UART stops sending data to it because its CTS signal does not allow it to send data.
+- The UART interface defines a set of common functions for operating a UART port, including obtaining and releasing device handles, reading and writing data of a specified length, and obtaining and setting the baud rate, as well as the device attributes.
+
+### Available APIs
+
+**Table 1** APIs for the UART driver
+
+
+
Capability
+
+
Function
+
+
Description
+
+
+
+
Obtaining and releasing device handles
+
+
+
UartOpen
+
+
Obtains the UART device handle.
+
+
+
UartClose
+
+
Releases a specified UART device handle.
+
+
+
Reading and writing data
+
+
+
UartRead
+
+
Reads data of a specified length from a UART device.
+
+
+
UartWrite
+
+
Writes data of a specified length into a UART device.
+
+
+
Obtaining and setting the baud rate
+
+
UartGetBaud
+
+
Obtains the UART baud rate.
+
+
+
UartSetBaud
+
+
Sets the UART baud rate.
+
+
+
Obtaining and setting device attributes
+
+
+
UartGetAttribute
+
+
Obtains the UART device attributes.
+
+
+
UartSetAttribute
+
+
Sets the UART device attributes.
+
+
+
Setting the transmission mode
+
+
UartSetTransMode
+
+
Sets the UART transmission mode.
+
+
+
+
+
+> **NOTE:**
+>All functions provided in this document can be called only in kernel space.
+
+## Usage Guidelines
+
+### How to Use
+
+[Figure 3](#fig1852173020185) shows the process of using a UART device.
+
+**Figure 3** Process of using a UART device
+
+
+
+
+### Obtaining a UART Device Handle
+
+Before performing UART communication, call **UartOpen** to obtain a UART device handle. This function returns the pointer to the UART device handle with a specified port number.
+
+DevHandle UartOpen\(uint32\_t port\);
+
+**Table 2** Description of UartOpen
+
+
+
Parameter
+
+
Description
+
+
+
+
port
+
+
UART port number.
+
+
+
Return Value
+
+
Description
+
+
+
NULL
+
+
Failed to obtain the UART device handle.
+
+
+
Device handle
+
+
UART device handle.
+
+
+
+
+
+The following example shows how to obtain a UART device handle based on the assumption that the UART port number is **3**:
+
+```
+DevHandle handle = NULL; /* The UART device handle */
+uint32_t port = 3; /* UART port number */
+handle = UartOpen(port);
+if (handle == NULL) {
+ HDF_LOGE("UartOpen: failed!\n");
+ return;
+}
+```
+
+### Setting the UART Baud Rate
+
+After obtaining the UART device handle, set the UART baud rate by calling the following function:
+
+int32\_t UartSetBaud\(DevHandle handle, uint32\_t baudRate\);
+
+**Table 3** Description of UartSetBaud
+
+
+
Parameter
+
+
Description
+
+
+
+
handle
+
+
UART device handle.
+
+
+
baudRate
+
+
Baud rate of the UART to set.
+
+
+
Return Value
+
+
Description
+
+
+
0
+
+
Succeeded in setting the UART baud rate.
+
+
+
Negative value
+
+
Failed to set the UART baud rate.
+
+
+
+
+
+The following example shows how to set the UART baud rate to **9600**:
+
+```
+int32_t ret;
+/* Set the UART baud rate to 9600. */
+ret = UartSetBaud(handle, 9600);
+if (ret != 0) {
+ HDF_LOGE("UartSetBaud: failed, ret %d\n", ret);
+}
+```
+
+### Obtaining the UART Baud Rate
+
+After setting the UART baud rate, obtain the current baud rate by calling the following function:
+
+int32\_t UartGetBaud\(DevHandle handle, uint32\_t \*baudRate\);
+
+**Table 4** Description of UartGetBaud
+
+
+
Parameter
+
+
Description
+
+
+
+
handle
+
+
UART device handle.
+
+
+
baudRate
+
+
Pointer to the UART baud rate.
+
+
+
Return Value
+
+
Description
+
+
+
0
+
+
Succeeded in obtaining the UART baud rate.
+
+
+
Negative value
+
+
Failed to obtain the UART baud rate.
+
+
+
+
+
+The following example shows how to obtain the UART baud rate:
+
+```
+int32_t ret;
+uint32_t baudRate;
+/* Obtain the UART baud rate. */
+ret = UartGetBaud(handle, &baudRate);
+if (ret != 0) {
+ HDF_LOGE("UartGetBaud: failed, ret %d\n", ret);
+}
+```
+
+### Setting the UART Device Attributes
+
+Before performing UART communication, set the UART device attributes by calling the following function:
+
+int32\_t UartSetAttribute\(DevHandle handle, struct UartAttribute \*attribute\);
+
+**Table 5** Description of UartSetAttribute
+
+
+
Parameter
+
+
Description
+
+
+
+
handle
+
+
UART device handle.
+
+
+
attribute
+
+
Pointer to the UART device attributes to set.
+
+
+
Return Value
+
+
Description
+
+
+
0
+
+
Succeeded in setting the UART device attributes.
+
+
+
Negative value
+
+
Failed to set the UART device attributes.
+
+
+
+
+
+The following example shows how to set the UART device attributes:
+
+```
+int32_t ret;
+struct UartAttribute attribute;
+attribute.dataBits = UART_ATTR_DATABIT_7; /* Set the number of data bits to 7. */
+attribute.parity = UART_ATTR_PARITY_NONE; /* Set the parity bit to no parity. */
+attribute.stopBits = UART_ATTR_STOPBIT_1; /* Set the stop bit to 1. */
+attribute.rts = UART_ATTR_RTS_DIS; /* Disable the RTS signal. */
+attribute.cts = UART_ATTR_CTS_DIS; /* Disable the CTS signal. */
+attribute.fifoRxEn = UART_ATTR_RX_FIFO_EN; /* Enable RX FIFO. */
+attribute.fifoTxEn = UART_ATTR_TX_FIFO_EN; /* Enable TX FIFO. */
+/* Set the UART device attributes. */
+ret = UartSetAttribute(handle, &attribute);
+if (ret != 0) {
+ HDF_LOGE("UartSetAttribute: failed, ret %d\n", ret);
+}
+```
+
+### Obtaining UART Device Attributes
+
+After setting the UART device attributes, obtain the current device attributes by calling the following function:
+
+int32\_t UartGetAttribute\(DevHandle handle, struct UartAttribute \*attribute\);
+
+**Table 6** Description of UartGetAttribute
+
+
+
Parameter
+
+
Description
+
+
+
+
handle
+
+
UART device handle.
+
+
+
attribute
+
+
Pointer to the UART device attributes.
+
+
+
Return Value
+
+
Description
+
+
+
0
+
+
Succeeded in obtaining the UART device attributes.
+
+
+
Negative value
+
+
Failed to obtain the UART device attributes.
+
+
+
+
+
+The following example shows how to obtain the UART device attributes:
+
+```
+int32_t ret;
+struct UartAttribute attribute;
+/* Obtain the UART attributes. */
+ret = UartGetAttribute(handle, &attribute);
+if (ret != 0) {
+ HDF_LOGE("UartGetAttribute: failed, ret %d\n", ret);
+}
+```
+
+### Setting the UART Transmission Mode
+
+Before performing UART communication, set the UART transmission mode by calling the following function:
+
+int32\_t UartSetTransMode\(DevHandle handle, enum UartTransMode mode\);
+
+**Table 7** Description of UartSetTransMode
+
+
+
Parameter
+
+
Description
+
+
+
+
handle
+
+
UART device handle.
+
+
+
mode
+
+
UART transmission mode to set.
+
+
+
Return Value
+
+
Description
+
+
+
0
+
+
Succeeded in setting the UART transmission mode.
+
+
+
Negative value
+
+
Failed to set the UART transmission mode.
+
+
+
+
+
+The following example shows how to set the transmission mode to **UART\_MODE\_RD\_BLOCK**:
+
+```
+int32_t ret;
+/* Set the UART transmission mode. */
+ret = UartSetTransMode(handle, UART_MODE_RD_BLOCK);
+if (ret != 0) {
+ HDF_LOGE("UartSetTransMode: failed, ret %d\n", ret);
+}
+```
+
+### Writing Data of a Specified Length into a UART Device
+
+To write data into a UART device, call the following function:
+
+int32\_t UartWrite\(DevHandle handle, uint8\_t \*data, uint32\_t size\);
+
+**Table 8** Description of UartWrite
+
+
+
Parameter
+
+
Description
+
+
+
+
handle
+
+
UART device handle.
+
+
+
data
+
+
Pointer to the data to write.
+
+
+
size
+
+
Length of the data to write.
+
+
+
Return Value
+
+
Description
+
+
+
0
+
+
Succeeded in writing data into the UART device.
+
+
+
Negative value
+
+
Failed to write data into the UART device.
+
+
+
+
+
+The following example shows how to write data of a specified length into the UART device:
+
+```
+int32_t ret;
+uint8_t wbuff[5] = {1, 2, 3, 4, 5};
+/* Write 5-byte data into the UART device. */
+ret = UartWrite(handle, wbuff, 5);
+if (ret != 0) {
+ HDF_LOGE("UartWrite: failed, ret %d\n", ret);
+}
+```
+
+### Reading Data of a Specified Length from a UART Device
+
+To write data into a UART device, call the following function:
+
+int32\_t UartRead\(DevHandle handle, uint8\_t \*data, uint32\_t size\);
+
+**Table 9** Description of UartRead
+
+
+
Parameter
+
+
Description
+
+
+
+
handle
+
+
UART device handle.
+
+
+
data
+
+
Pointer to the buffer for receiving the data.
+
+
+
size
+
+
Length of the data to read.
+
+
+
Return Value
+
+
Description
+
+
+
Non-negative value
+
+
Length of the data read from the UART device.
+
+
+
Negative value
+
+
Failed to read data from the UART device.
+
+
+
+
+
+The following example shows how to read data of a specified length from the UART device:
+
+```
+int32_t ret;
+uint8_t rbuff[5] = {0};
+/* Read 5-byte data from the UART device. */
+ret = UartRead(handle, rbuff, 5);
+if (ret < 0) {
+ HDF_LOGE("UartRead: failed, ret %d\n", ret);
+}
+```
+
+> **CAUTION:**
+>Data is successfully read from the UART device if a non-negative value is returned. If the return value is **0**, no valid data can be read from the UART device. If the return value is greater than **0**, the return value is the length of the data actually read from the UART device. The length is less than or equal to the value of **size** and does not exceed the maximum length of data to read at a time specified by the UART controller in use.
+
+### Destroying the UART Device Handle
+
+After the UART communication, destroy the UART device handle by calling the following function:
+
+void UartClose\(DevHandle handle\);
+
+This function will release the resources previously obtained.
+
+**Table 10** Description of UartClose
+
+
+
Parameter
+
+
Description
+
+
+
+
handle
+
+
UART device handle.
+
+
+
+
+
+The following example shows how to destroy the UART device handle:
+
+```
+UartClose(handle); /* Destroy the UART device handle. */
+```
+
+## Usage Example
+
+The following is a usage example of a UART device, including how to obtain the UART device handle, set the baud rate, device attributes, and transmission mode, read data from or write data into the UART device, and then destroy the UART device handle.
+
+```
+#include "hdf_log.h"
+#include "uart_if.h"
+
+void UartTestSample(void)
+{
+ int32_t ret;
+ uint32_t port;
+ DevHandle handle = NULL;
+ uint8_t wbuff[5] = { 1, 2, 3, 4, 5 };
+ uint8_t rbuff[5] = { 0 };
+ struct UartAttribute attribute;
+ attribute.dataBits = UART_ATTR_DATABIT_7; /* Set the number of data bits to 7. */
+ attribute.parity = UART_ATTR_PARITY_NONE; /* Set the parity bit to no parity. */
+ attribute.stopBits = UART_ATTR_STOPBIT_1; /* Set the stop bit to 1. */
+ attribute.rts = UART_ATTR_RTS_DIS; /* Disable the RTS signal. */
+ attribute.cts = UART_ATTR_CTS_DIS; /* Disable the CTS signal. */
+ attribute.fifoRxEn = UART_ATTR_RX_FIFO_EN; /* Enable RX FIFO. */
+ attribute.fifoTxEn = UART_ATTR_TX_FIFO_EN; /* Enable TX FIFO. */
+ /* Set the UART port number actually used. */
+ port = 1;
+ /* Obtain the UART device handle. */
+ handle = UartOpen(port);
+ if (handle == NULL) {
+ HDF_LOGE("UartOpen: failed!\n");
+ return;
+ }
+ /* Set the UART baud rate to 9600. */
+ ret = UartSetBaud(handle, 9600);
+ if (ret != 0) {
+ HDF_LOGE("UartSetBaud: failed, ret %d\n", ret);
+ goto _ERR;
+ }
+ /* Set the UART device attributes. */
+ ret = UartSetAttribute(handle, &attribute);
+ if (ret != 0) {
+ HDF_LOGE("UartSetAttribute: failed, ret %d\n", ret);
+ goto _ERR;
+ }
+ /* Set the UART transmission mode to non-blocking mode. */
+ ret = UartSetTransMode(handle, UART_MODE_RD_NONBLOCK);
+ if (ret != 0) {
+ HDF_LOGE("UartSetTransMode: failed, ret %d\n", ret);
+ goto _ERR;
+ }
+ /* Write 5-byte data into the UART device. */
+ ret = UartWrite(handle, wbuff, 5);
+ if (ret != 0) {
+ HDF_LOGE("UartWrite: failed, ret %d\n", ret);
+ goto _ERR;
+ }
+ /* Read 5-byte data from the UART device. */
+ ret = UartRead(handle, rbuff, 5);
+ if (ret < 0) {
+ HDF_LOGE("UartRead: failed, ret %d\n", ret);
+ goto _ERR;
+ }
+_ERR:
+ /* Destroy the UART device handle. */
+ UartClose(handle);
+}
+```
+
diff --git a/en/device-dev/driver/drive-platform-watchdog-des.md b/en/device-dev/driver/drive-platform-watchdog-des.md
new file mode 100644
index 0000000000000000000000000000000000000000..ddaddc1abe08efca457b46b26db353dc0df06f2e
--- /dev/null
+++ b/en/device-dev/driver/drive-platform-watchdog-des.md
@@ -0,0 +1,557 @@
+# Watchdog
+
+- [Overview](#section14918241977)
+ - [Available APIs](#section20177131219818)
+
+- [Usage Guidelines](#section10103184312813)
+ - [How to Use](#section10181195910815)
+ - [Opening a Watchdog](#section66089201107)
+ - [Obtaining the Watchdog Status](#section786624341011)
+ - [Setting the Timeout Duration](#section182386137111)
+ - [Obtaining the Timeout Duration](#section1883310371114)
+ - [Starting a Watchdog](#section82501405123)
+ - [Feeding a Watchdog](#section3547530101211)
+ - [Stopping a Watchdog](#section944595841217)
+ - [Closing a Watchdog](#section96561824121311)
+
+- [Usage Example](#section1724514523135)
+
+## Overview
+
+A watchdog, also called a watchdog timer, is a hardware timing device. If an error occurs in the main program of the system and fails to reset the watchdog timer, the watchdog timer sends a reset signal to restore the system to a normal state.
+
+### Available APIs
+
+**Table 1** Watchdog APIs
+
+
+
Capability
+
+
Function
+
+
Description
+
+
+
+
Open/Close
+
+
WatchdogOpen
+
+
Opens a watchdog.
+
+
+
WatchdogClose
+
+
Closes a watchdog.
+
+
+
Start/Stop
+
+
WatchdogStart
+
+
Starts a watchdog.
+
+
+
WatchdogStop
+
+
Stops a watchdog.
+
+
+
Timeout duration
+
+
WatchdogSetTimeout
+
+
Sets the watchdog timeout duration.
+
+
+
WatchdogGetTimeout
+
+
Obtains the watchdog timeout duration.
+
+
+
Status
+
+
WatchdogGetStatus
+
+
Obtains the watchdog status.
+
+
+
Feeding
+
+
WatchdogFeed
+
+
Feeds a watchdog, or resets a watchdog timer.
+
+
+
+
+
+> **NOTE:**
+>All watchdog functions provided in this document can be called only in kernel mode.
+
+## Usage Guidelines
+
+### How to Use
+
+[Figure 1](#fig19134125410189) illustrates the process of using a watchdog.
+
+**Figure 1** Process of using a watchdog
+
+
+
+
+### Opening a Watchdog
+
+Use **WatchdogOpen** to open a watchdog. A system may have multiple watchdogs. You can open the specified watchdog by using the ID.
+
+int32\_t WatchdogOpen\(int16\_t wdtId\);
+
+**Table 2** Description of WatchdogOpen
+
+
+
Parameter
+
+
Description
+
+
+
+
wdtId
+
+
Watchdog ID.
+
+
+
Return Value
+
+
Description
+
+
+
NULL
+
+
Failed to open the watchdog.
+
+
+
DevHandle pointer
+
+
Pointer to the watchdog handle.
+
+
+
+
+
+```
+DevHandle handle = NULL;
+handle = WatchdogOpen(0); /* Open watchdog 0.*/
+if (handle == NULL) {
+ HDF_LOGE("WatchdogOpen: failed, ret %d\n", ret);
+ return;
+}
+```
+
+### Obtaining the Watchdog Status
+
+int32\_t WatchdogGetStatus\(DevHandle handle, int32\_t \*status\);
+
+**Table 3** Description of WatchdogGetStatus
+
+
+
+
+```
+int32_t ret;
+/* Stop the watchdog. */
+ret = WatchdogStop(handle);
+if (ret != 0) {
+ HDF_LOGE("WatchdogStop: failed, ret %d\n", ret);
+ return;
+}
+```
+
+### Closing a Watchdog
+
+If the watchdog is no longer required, call **WatchdogClose** to close the watchdog handle.
+
+void WatchdogClose\(DevHandle handle\);
+
+**Table 9** Description of WatchdogClose
+
+
+
Parameter
+
+
Description
+
+
+
+
handle
+
+
Watchdog handle.
+
+
+
+
+
+```
+/* Close the watchdog. */
+ret = WatchdogClose(handle);
+```
+
+## Usage Example
+
+This example provides a complete process for using a watchdog.
+
+In this example, open a watchdog, set the timeout duration, and start the watchdog.
+
+- Feed the watchdog periodically to ensure that the system is not reset due to timer expiry.
+- Stop feeding the watchdog and check whether the system is reset after the timer expires.
+
+Example:
+
+```
+#include "watchdog_if.h"
+#include "hdf_log.h"
+#include "osal_irq.h"
+#include "osal_time.h"
+
+#define WATCHDOG_TEST_TIMEOUT 2
+#define WATCHDOG_TEST_FEED_TIME 6
+
+static int32_t TestCaseWatchdog(void)
+{
+ int32_t i;
+ int32_t ret;
+ uint32_t timeout;
+ DevHandle handle = NULL;
+
+ /* Open watchdog 0. */
+ handle = WatchdogOpen(0);
+ if (handle == NULL) {
+ HDF_LOGE("Open watchdog fail!");
+ return -1;
+ }
+
+ /* Set the timeout duration. */
+ ret = WatchdogSetTimeout(handle, WATCHDOG_TEST_TIMEOUT);
+ if (ret != HDF_SUCCESS) {
+ HDF_LOGE("%s: set timeout fail! ret:%d\n", __func__, ret);
+ WatchdogClose(handle);
+ return ret;
+ }
+
+ /* Obtain the configured timeout duration. */
+ ret = WatchdogGetTimeout(handle, &timeout);
+ if (ret != HDF_SUCCESS) {
+ HDF_LOGE("%s: get timeout fail! ret:%d\n", __func__, ret);
+ WatchdogClose(handle);
+ return ret;
+ }
+ HDF_LOGI("%s: read timeout back:%u\n", __func__, timeout);
+
+ /* Start the watchdog. The timer starts. */
+ ret = WatchdogStart(handle);
+ if (ret != HDF_SUCCESS) {
+ HDF_LOGE("%s: satrt fail! ret:%d\n", __func__, ret);
+ WatchdogClose(handle);
+ return ret;
+ }
+
+ /* Feed the watchdog every 1s. */
+ for (i = 0; i < WATCHDOG_TEST_FEED_TIME; i++) {
+ HDF_LOGE("%s: feeding watchdog %d times... \n", __func__, i);
+ ret = WatchdogFeed(handle);
+ if (ret != HDF_SUCCESS) {
+ HDF_LOGE("%s: feed dog fail! ret:%d\n", __func__, ret);
+ WatchdogClose(handle);
+ return ret;
+ }
+ OsalSleep(1);
+ }
+ /* Because the interval for feeding the watchdog is shorter than the timeout duration, the system does not reset, and logs can be printed normally. */
+ HDF_LOGE("%s: no reset ... feeding test OK!!!\n", __func__);
+
+ /* Enable the timer to expire by stopping feeding the watchdog. */
+ for (i = 0; i < WATCHDOG_TEST_FEED_TIME; i++) {
+ HDF_LOGE("%s: watiting dog buck %d times... \n", __func__, i);
+ OsalSleep(1);
+ }
+
+ /* The system resets when the timer expires. If the code is correct, the log below is not displayed. */
+ HDF_LOGE("%s: dog has't buck!!! \n", __func__, i);
+ WatchdogClose(handle);
+ return -1;
+}
+```
+
diff --git a/en/device-dev/driver/drive-platform.md b/en/device-dev/driver/drive-platform.md
new file mode 100644
index 0000000000000000000000000000000000000000..98ac4fa19089971aa64c715e266f690fbcf45182
--- /dev/null
+++ b/en/device-dev/driver/drive-platform.md
@@ -0,0 +1,19 @@
+# Platform Drivers
+
+- **[GPIO](drive-platform-gpio-des.md)**
+
+- **[I2C](drive-platform-i2c-des.md)**
+
+- **[RTC](drive-platform-rtc-des.md)**
+
+- **[SDIO](drive-platform-sdio-des.md)**
+
+- **[SPI](drive-platform-spi-des.md)**
+
+- **[UART](drive-platform-uart-des.md)**
+
+- **[Watchdog](drive-platform-watchdog-des.md)**
+
+- **[MIPI DSI](drive-platform-mipidsi-des.md)**
+
+
diff --git a/en/device-dev/driver/drive.md b/en/device-dev/driver/drive.md
new file mode 100644
index 0000000000000000000000000000000000000000..b448704264a04fdcec3dce1e2d7886831d6e5651
--- /dev/null
+++ b/en/device-dev/driver/drive.md
@@ -0,0 +1,9 @@
+# Driver Usage Guidelines
+
+- **[HDF](drive-hdf.md)**
+
+- **[Platform Drivers](drive-platform.md)**
+
+- **[Peripherals](drive-peripherals.md)**
+
+
diff --git a/en/device-dev/driver/driver-configuration-management.md b/en/device-dev/driver/driver-configuration-management.md
deleted file mode 100644
index ed33878be0b20585b044940e475784685e7e1c6a..0000000000000000000000000000000000000000
--- a/en/device-dev/driver/driver-configuration-management.md
+++ /dev/null
@@ -1,437 +0,0 @@
-# Driver Configuration Management
-
-- [HDF Configuration Overview](#section59914284576)
-- [Configuration Syntax](#section533713333580)
-- [Keywords](#section1316625413586)
-- [Basic Syntax](#section173481622115918)
-- [Data Types](#section96521601302)
-- [Pre-processing](#section8164295515)
-- [Commenting](#section0338205819610)
-- [Modifying a Reference](#section179799204716)
-- [Replicating Node Configuration](#section382424014712)
-- [Deleting a Node or Attribute](#section165211112586)
-- [Referencing an Attribute](#section192841514490)
-- [Keyword Template](#section520134294)
-- [Configuration Generation](#section106152531919)
-- [Introduction to HC-GEN](#section8260625101012)
-
-## HDF Configuration Overview
-
-HCS is the source code that describes the configuration of the HDF using key-value pairs. It decouples the configuration code from driver code, thereby facilitating configuration management.
-
-HDF Configuration Generator \(HC-GEN\) is a tool for converting a configuration file into a file that can be read by the target software.
-
-- In a low-performance system on a chip \(SoC\), this tool can convert a configuration file into the source code of the configuration tree so that the driver can obtain the configuration by directly calling the C library code.
-- In a high-performance SoC, this tool can convert an HCS configuration file into the HDF Configuration Binary \(HCB\) file, allowing the driver to obtain the configuration through the APIs provided by the HDF.
-
-The following figure shows the typical application scenario of the HCB mode.
-
-**Figure 1** Process of using HCS
-
-
-
-
-The HCS is compiled using the HC-GEN tool to generate an HCB file. The HCS Parser module in the HDF recreates a configuration tree using the HCB file. Then, the HDF driver modules obtain the configurations using the API provided by the HCS Paser.
-
-## Configuration Syntax
-
-The HCS syntax is described as follows:
-
-## Keywords
-
-The keywords listed in the following table below are reserved for HCS configuration files.
-
-**Table 1** Reserved keywords for HCS configuration files
-
-
-
Keywords
-
-
Description
-
-
Remarks
-
-
-
-
root
-
-
Configures the root node.
-
-
-
-
-
-
include
-
-
References other HCS configuration files.
-
-
-
-
-
-
delete
-
-
Deletes a node or an attribute.
-
-
This keyword applies only to the configuration tree imported using the include keyword.
-
-
-
template
-
-
Defines a template node.
-
-
-
-
-
-
match_attr
-
-
Marks the node attribute for matching.
-
-
During configuration parsing, the keyword value can be used to find the corresponding node.
-
-
-
-
-
-## Basic Syntax
-
-The HCS configuration file consists of configurations of attributes and nodes.
-
-**Attributes**
-
-An attribute, as the minimum configuration unit, is an independent configuration item. Its syntax is as follows:
-
-```
- attribute_name = value;
-```
-
-- The value of **attribute\_name** is a case-sensitive string of characters starting with a letter and consisting of letters, digits, and underscores \(\_\).
-
-- Available formats of **value** are as follows:
-
- - A binary, octal, decimal, or hexadecimal integer. For details, see [Data Types](#section96521601302).
-
- - A character string. The content should be enclosed in double quotation marks \(" "\).
-
- - A node reference
-
-
-- An attribute key-value pair must end with a semicolon \(;\) and belong to a node.
-
-
-**Nodes**
-
-A node is a set of attributes. Its syntax is as follows:
-
-```
- node_name {
- module = "sample";
- ...
- }
-```
-
-- The value of **node\_name** is a case-sensitive string of characters starting with a letter and consisting of letters, digits, and underscores \(\_\).
-
-- A semicolon \(;\) is not required after the curly brace \(\}\).
-
-- The reserved keyword **root** is used to declare the root node of a configuration table.
-
-- The root node must contain a **module** attribute that uses a string to represent the module to which the configuration belongs.
-
-- The **match\_attr** attribute can be added to a node. Its value is a globally unique character string. During configuration parsing, the query interface can be invoked to query the nodes with the attribute based on the attribute value.
-
-## Data Types
-
-Attributes automatically use built-in data types, including integers, strings, arrays, and booleans. You do not need to explicitly specify the data type for the attribute values.
-
-**Integer**
-
-An integer can be binary, octal, decimal, or hexadecimal. The minimum space is automatically allocated to the integer based on the actual data length.
-
-- Binary: prefixed with 0b, for example, 0b1010
-
-- Octal: prefixed with 0, for example, 0664
-- Decimal: either signed or unsigned, without a prefix, for example, 1024 or +1024. Negative integers can be read only via signed interfaces.
-
-- Hexadecimal: prefixed with 0x, for example, 0xff00 and 0xFF
-
-
-**String**
-
-A string is enclosed by double quotation marks \(" "\).
-
-**Array**
-
-The elements in an array can be integers or strings, but cannot be a combination of both. The combination of **uint32\_t** and **uint64\_t** in an integer array will enable up-casting to **uint64**. The following is an example of an integer array and a string array:
-
-```
-attr_foo = [0x01, 0x02, 0x03, 0x04];
-attr_bar = ["hello", "world"];
-```
-
-**Boolean**
-
-A Boolean data type has two possible values: **true** and **false**.
-
-## Pre-processing
-
-**include**
-
-The **include** keyword is used to import other HCS files. The syntax is as follows:
-
-```
-#include "foo.hcs"
-#include "../bar.hcs"
-```
-
-- The file names must be enclosed by double quotation marks \(" "\). Files in different directories can be referenced using relative paths. The file included must be a valid HCS file.
-- In the scenario that multiple HCS files are imported using **include**, if the same nodes exist, the latter node will override the former one, and other nodes are listed in sequence.
-
-## Commenting
-
-Comments can be formatted as follows:
-
-- Single-line comment
-
- ```
- // comment
- ```
-
-- Multi-line comment
-
- ```
- /*
- comment
- */
- ```
-
- > **NOTE:**
- >Multi-line comments cannot be nested.
-
-
-## Modifying a Reference
-
-You can use the following syntax to modify the content of any other node:
-
-```
- node :& source_node
-```
-
-This syntax indicates that the node value is a modification of the source\_node value. Example:
-
-```
-root {
- module = "sample";
- foo {
- foo_ :& root.bar{
- attr = "foo";
- }
- foo1 :& foo2 {
- attr = 0x2;
- }
- foo2 {
- attr = 0x1;
- }
- }
-
- bar {
- attr = "bar";
- }
-}
-```
-
-The following configuration tree is generated:
-
-```
-root {
- module = "sample";
- foo {
- foo2 {
- attr = 0x2;
- }
- }
- bar {
- attr = "foo";
- }
-}
-```
-
-In the preceding example, the **foo.foo\_** node changes the value of the referenced **bar.attr** to "**foo**", and the **foo.foo1** node changes the value of the referenced **foo.foo2.attr** to **0x2**. In the generated configuration tree, **foo.foo\_** and **foo.foo1** are not displayed, but their configuration modifications are presented by their referenced nodes.
-
-- A node of the same level can be referenced simply using the node name. A node of a different level must be referenced by the absolute path, and node names are separated using a period \(.\). **root** indicates the root node. The path format is the node path sequence starting with root. For example, **root.foo.bar** is a valid absolute path.
-- If multiple modifications are made to the same attribute, only one uncertain modification can take effect, and a warning will be displayed.
-
-## Replicating Node Configuration
-
-The content of a node can be replicated to another node to define the node with similar content. The syntax is as follows:
-
-```
- node : source_node
-```
-
-The preceding statement indicates that the attributes of **source\_node** are replicated to **node**. Example:
-
-```
-root {
- module = "sample";
- foo {
- attr_0 = 0x0;
- }
- bar:foo {
- attr_1 = 0x1;
- }
-}
-```
-
-The following configuration tree is generated:
-
-```
-root {
- module = "sample";
- foo {
- attr_0 = 0x0;
- }
- bar {
- attr_1 = 0x1;
- attr_0 = 0x0;
- }
-}
-```
-
-In the preceding example, the **bar** node configuration includes both the **attr\_0** and **attr\_1** values. The modification to **attr\_0** in the **bar** node does not affect the **foo** node.
-
-The path of the **foo** node is not required if the **foo** node and the **bar** node are of the same level. Otherwise, the absolute path must be used. For details, see [Modifying a Reference](#section179799204716).
-
-## Deleting a Node or Attribute
-
-You can use the keyword **delete** to delete unnecessary nodes or attributes in the base configuration tree imported by the **include** keyword. In the following example, **sample1.hcs** imports the configuration of **sample2.hcs** using **include**, and deletes the **attribute2** attribute and the **foo\_2** node using the **delete** keyword.
-
-```
-// sample2.hcs
-root {
- attr_1 = 0x1;
- attr_2 = 0x2;
- foo_2 {
- t = 0x1;
- }
-}
-
-// sample1.hcs
-#include "sample2.hcs"
-root {
- attr_2 = delete;
- foo_2 : delete {
- }
-}
-```
-
-The following configuration tree is generated:
-
-```
-root {
- attr_1 = 0x1;
-}
-```
-
-> **NOTE:**
->The **delete** keyword cannot be used in the same HCS file. It is recommended that you delete unnecessary attributes directly from the configuration source code.
-
-## Referencing an Attribute
-
-To quickly locate the associated node during configuration parsing, you can use the node as the value of the attribute and read the attribute to find the corresponding node. The syntax is as follows:
-
-```
- attribute = &node;
-```
-
-This syntax indicates that the **attribute** value is a reference to **node**. During code parsing, you can quickly locate the node using this attribute. Example:
-
-```
-node1 {
- attributes;
-}
-
-node2 {
- attr_1 = &node1;
-}
-```
-
-## Keyword Template
-
-The **template** keyword is used to generate nodes with strictly consistent syntax, thereby facilitating the traverse and management of nodes of the same type.
-
-If a node is defined using the keyword **template**, its child nodes inherit the node configuration through the double colon operator \(::\). The child nodes can modify but cannot add or delete attributes in **template**. The attributes not defined in the child nodes will use the attributes defined in **template** as the default values. Example:
-
-```
-root {
- module = "sample";
- template foo {
- attr_1 = 0x1;
- attr_2 = 0x2;
- }
-
- bar :: foo {
- }
-
- bar_1 :: foo {
- attr_1 = 0x2;
- }
-}
-```
-
-The following configuration tree is generated:
-
-```
-root {
- module = "sample";
- bar {
- attr_1 = 0x1;
- attr_2 = 0x2;
- }
- bar_1 {
- attr_1 = 0x2;
- attr_2 = 0x2;
- }
-}
-```
-
-In the preceding example, the **bar** and **bar\_1** nodes inherit the **foo** node. The structures of the generated configuration tree nodes are the same as that of the **foo** node, but the attribute values are different.
-
-## Configuration Generation
-
-The HC-GEN tool is used to generate configurations. It checks the HCS configuration syntax and converts HCS source files into HCB files.
-
-## Introduction to HC-GEN
-
-Parameter description:
-
-```
-Usage: hc-gen [Options] [File]
-options:
- -o output file name, default same as input
- -a hcb align with four bytes
- -b output binary output, default enable
- -t output config in C language source file style
- -i output binary hex dump in C language source file style
- -p prefix of generated symbol name
- -d decompile hcb to hcs
- -V show verbose info
- -v show version
- -h show this help message
-```
-
-Generate a **.c** or **.h** configuration file.
-
-```
-hc-gen -o [OutputCFileName] -t [SourceHcsFileName]
-```
-
-Generate an HCB file.
-
-```
-hc-gen -o [OutputHcbFileName] -b [SourceHcsFileName]
-```
-
-Compile an **HCB** file to an **HCS** file:
-
-```
-hc-gen -o [OutputHcsFileName] -d [SourceHcbFileName]
-```
-
diff --git a/en/device-dev/driver/driver-development.md b/en/device-dev/driver/driver-development.md
deleted file mode 100644
index f9c14ec11f06e6f5c5448751c6967e3de0dac1fa..0000000000000000000000000000000000000000
--- a/en/device-dev/driver/driver-development.md
+++ /dev/null
@@ -1,175 +0,0 @@
-# Driver Development
-
-- [Introduction](#section157425168112)
-- [How to Develop](#section1969312275533)
-
-## Introduction
-
-The HDF is designed based on the component-based driver model. It provides more refined driver management to make driver development and deployment more standard. Device drivers of the same type are placed in the same host. You can develop and deploy the drivers separately. One driver can have multiple nodes. The following figure shows the HDF driver management model.
-
-**Figure 1** HDF driver management model
-
-
-
-
-## How to Develop
-
-Driver development based on the HDF consists of two parts: driver implementation and driver configuration. The details are as follows:
-
-1. Implement driver.
-
- To implement a driver, compile driver service code and register a driver entry.
-
- - Driver service code
-
- ```
- #include "hdf_device_desc.h" // Header file that describes the APIs provided by the HDF to the driver.
- #include "hdf_log.h" // Header file of the log interface provided by the HDF.
-
- #define HDF_LOG_TAG "sample_driver" // Tag contained in logs. If the tag is not specified, HDF_TAG is used by default.
-
- // The driver service interface must be bound to the HDF for you to use the service capability.
- int32_t HdfSampleDriverBind(struct HdfDeviceObject *deviceObject)
- {
- HDF_LOGD("Sample driver bind success");
- return 0;
- }
-
- // Initialize the driver service.
- int32_t HdfSampleDriverInit(struct HdfDeviceObject *deviceObject)
- {
- HDF_LOGD("Sample driver Init success");
- return 0;
- }
-
- // Release the driver resources.
- void HdfSampleDriverRelease(struct HdfDeviceObject *deviceObject)
- {
- HDF_LOGD("Sample driver release success");
- return;
- }
- ```
-
- - Registering the driver entry with the HDF
-
- ```
- // Define the object of the driver entry. The object must be a global variable of the HdfDriverEntry type (defined in hdf_device_desc.h).
- struct HdfDriverEntry g_sampleDriverEntry = {
- .moduleVersion = 1,
- .moduleName = "sample_driver",
- .Bind = HdfSampleDriverBind,
- .Init = HdfSampleDriverInit,
- .Release = HdfSampleDriverRelease,
- };
-
- // Call HDF_INIT to register the driver entry with the HDF framework. When loading the driver, call the Bind function and then the Init function. If the Init function fails to be called, the HDF will call Release to release the driver resource and exit.
- HDF_INIT(g_sampleDriverEntry);
- ```
-
-
-2. Compile the driver code.
- - Use the **Makefile** template provided by the HDF to compile the driver code.
-
- ```
- include $(LITEOSTOPDIR)/../../drivers/adapter/lite/khdf/lite.mk # (Mandatory) Import the predefined content of the HDF.
- MODULE_NAME := # Generated result file
- LOCAL_INCLUDE: = # Header file directory of the driver
- LOCAL_SRCS : = # Source code file of the driver
- LOCAL_CFLAGS : = # Custom compilation options
- include $(HDF_DRIVER) # Import the template Makefile to complete compilation.
- ```
-
- - Link the compilation result file to the kernel image by adding the result file to **hdf\_vendor.mk** in the **vendor** directory. The following is an example:
-
- ```
- LITEOS_BASELIB += -lxxx # Static library generated through linking
- LIB_SUBDIRS += # Directory of Makefile
- ```
-
-
-3. Configure the driver.
-
- HDF Configuration Source \(HCS\) is the source code that describes the configuration of the HDF. For details about the HCS, see [Driver Configuration Management](driver-configuration-management.md).
-
- The driver configuration consists of the driver device description defined by the HDF and private driver configuration information.
-
- - \(Mandatory\) Driver device description
-
- The information required for the HDF to load drivers comes from the driver device description defined by the HDF. Therefore, the device description must be added to the configuration file **device\_info.hcs** defined by the HDF for drivers developed based on the HDF. The following is an example:
-
- ```
- root {
- device_info {
- match_attr = "hdf_manager";
- template host { // Host template. If the node (for example, sample_host) that inherits the template uses default values in the template, the values of the node fields can be omitted.
- hostName = "";
- priority = 100;
- template device {
- template deviceNode {
- policy = 0;
- priority = 100;
- preload = 0;
- permission = 0664;
- moduleName = "";
- serviceName = "";
- deviceMatchAttr = "";
- }
- }
- }
- sample_host :: host{
- hostName = "host0"; // Host name. The host node is used to store a certain type of drivers.
- priority = 100; // Host startup priority (0-200). A larger value indicates a lower priority. The default value 100 is recommended. If the priorities are the same, the host loading sequence is random.
- device_sample :: device { // Device node of sample
- device0 :: deviceNode { // DeviceNode of the sample driver
- policy = 1; // Driver service release policy. For details, see section Driver Service Management.
- priority = 100; // Driver startup priority (0-200). A larger value indicates a lower priority. The default value 100 is recommended. If the priorities are the same, the device loading sequence is random.
- preload = 0; // On-demand driver loading. For details, see "NOTE" at the end of this section.
- permission = 0664; // Permission for the driver to create device nodes.
- moduleName = "sample_driver"; // Driver name. The value of this field must be the same as the value of moduleName in the driver entry structure.
- serviceName = "sample_service"; // Name of the service released by the driver. The name must be unique.
- deviceMatchAttr = "sample_config"; // Keyword matching the private data of the driver. The value must be the same as that of match_attr in the private data configuration table of the driver.
- }
- }
- }
- }
- }
- ```
-
- - \(Optional\) Private configuration information of the driver
-
- If the driver has private configurations, you can add a driver configuration file to fill in the default configuration information of the driver. When loading the driver, the HDF obtains the information and saves it in the **property** of **HdfDeviceObject**, and transfers it to the driver using **Bind** and **Init** \(see [1](#li35182436435)\). The following is an example of the driver configuration information:
-
- ```
- root {
- SampleDriverConfig {
- sample_version = 1;
- sample_bus = "I2C_0";
- match_attr = "sample_config"; // The value of this field must be the same as that of deviceMatchAttr in device_info.hcs.
- }
- }
- ```
-
- After the configuration information is defined, you need to add the configuration file to the board-level configuration entry file **hdf.hcs**. \(You can use the DevEco to perform on-click configuration. For details, see the description about the driver development suite.\) The following is an example:
-
- ```
- #include "device_info/device_info.hcs"
- #include "sample/sample_config.hcs"
- ```
-
-
-
-> **NOTE:**
->On-demand loading and sequential loading are supported. The detailed usage is as follows:
->- On-demand loading
-> ```
-> typedef enum {
-> DEVICE_PRELOAD_ENABLE = 0,
-> DEVICE_PRELOAD_ENABLE_STEP2,
-> DEVICE_PRELOAD_DISABLE,
-> DEVICE_PRELOAD_INVALID
-> } DevicePreload;
-> ```
-> When the **preload** field in the configuration file is set to **0** \(**DEVICE\_PRELOAD\_ENABLE**\), the driver is loaded by default during system startup. When this field is set to **1** \(**DEVICE\_PRELOAD\_ENABLE\_STEP2**\), the driver is loaded after system startup if quick start is enabled; it is loaded during system startup otherwise. When this field is set to **2** \(**DEVICE\_PRELOAD\_DISABLE**\), the driver is not loaded by default during system startup and can be dynamically loaded later. If the driver service does not exist when a user-level application obtains the driver service \(for details about how to obtain the driver service, see [Driver Message Mechanism Management](driver-message-mechanism-management.md)\), the HDF attempts to dynamically load the driver.
->- Sequential loading \(drivers must be loaded by default\)
-> In the configuration file, the **priority** field \(the value is an integer ranging from 0 to 200\) indicates the priority of the host and driver. For drivers in different hosts, a smaller host priority value indicates a higher driver loading priority; for drivers in the same host, a smaller driver priority value indicates a higher driver loading priority.
-
diff --git a/en/device-dev/driver/driver-message-mechanism-management.md b/en/device-dev/driver/driver-message-mechanism-management.md
deleted file mode 100644
index 3ea214d2ade48cb8955cd793fd84aadc2cc38d81..0000000000000000000000000000000000000000
--- a/en/device-dev/driver/driver-message-mechanism-management.md
+++ /dev/null
@@ -1,193 +0,0 @@
-# Driver Message Mechanism Management
-
-- [When to Use](#section33014541954)
-- [Available APIs](#section538852311616)
-- [How to Develop](#section946912121153)
-
-## When to Use
-
-When user-level applications need to interact with kernel-level drivers, the driver message mechanism of the HDF can be used.
-
-## Available APIs
-
-The message mechanism provides the following features:
-
-1. User-level applications send messages to drivers.
-2. User-level applications receive events sent by the drivers.
-
-**Table 1** APIs for the driver message mechanism
-
-
-
int HdfDeviceRegisterEventListener(struct HdfIoService *target, struct HdfDevEventlistener *listener);
-
-
Receives events sent by the drivers.
-
-
-
int HdfDeviceSendEvent(struct HdfDeviceObject *deviceObject, uint32_t id, struct HdfSBuf *data);
-
-
Sends events.
-
-
-
-
-
-## How to Develop
-
-1. Set the value of the **policy** field in the driver configuration information to **2** \(SERVICE\_POLICY\_CAPACITY, see [Driver Service Management](driver-service-management.md)\).
-
- ```
- device_sample :: Device {
- policy = 2;
- ...
- }
- ```
-
-2. The **permission** field in the driver configuration information indicates the permission provided for the driver to create device nodes. The default value is **0666**. You can configure the value of this field based on the actual application scenario of the driver.
-3. Implement the **Dispatch** function of the service base member **IDeviceIoService** during service implementation.
-
- ```
- // Process messages delivered by user-level applications.
- int32_t SampleDriverDispatch(struct HdfDeviceObject *device, int cmdCode, struct HdfSBuf *data, struct HdfSBuf *reply)
- {
- HDF_LOGE("sample driver lite A dispatch");
- return 0;
- }
- int32_t SampleDriverBind(struct HdfDeviceObject *device)
- {
- HDF_LOGE("test for lite os sample driver A Open!");
- if (device == NULL) {
- HDF_LOGE("test for lite os sample driver A Open failed!");
- return -1;
- }
- static struct ISampleDriverService sampleDriverA = {
- .ioService.Dispatch = SampleDriverDispatch,
- .ServiceA = SampleDriverServiceA,
- .ServiceB = SampleDriverServiceB,
- };
- device->service = (struct IDeviceIoService *)(&sampleDriverA);
- return 0;
- }
- ```
-
-4. Define the CMD type in the message processing function.
-
- ```
- #define SAMPLE_WRITE_READ 1 // Read and write operation 1
- ```
-
-5. Enable the user-level application to obtain the service interface and send messages to the driver.
-
- ```
- int SendMsg(const char *testMsg)
- {
- if (testMsg == NULL) {
- HDF_LOGE("test msg is null");
- return -1;
- }
- struct HdfIoService *serv = HdfIoServiceBind("sample_driver");
- if (serv == NULL) {
- HDF_LOGE("fail to get service");
- return -1;
- }
- struct HdfSBuf *data = HdfSBufObtainDefaultSize();
- if (data == NULL) {
- HDF_LOGE("fail to obtain sbuf data");
- return -1;
- }
- struct HdfSBuf *reply = HdfSBufObtainDefaultSize();
- if (reply == NULL) {
- HDF_LOGE("fail to obtain sbuf reply");
- ret = HDF_DEV_ERR_NO_MEMORY;
- goto out;
- }
- if (!HdfSbufWriteString(data, testMsg)) {
- HDF_LOGE("fail to write sbuf");
- ret = HDF_FAILURE;
- goto out;
- }
- int ret = serv->dispatcher->Dispatch(&serv->object, SAMPLE_WRITE_READ, data, reply);
- if (ret != HDF_SUCCESS) {
- HDF_LOGE("fail to send service call");
- goto out;
- }
- out:
- HdfSBufRecycle(data);
- HdfSBufRecycle(reply);
- HdfIoServiceRecycle(serv);
- return ret;
- }
- ```
-
-6. Enable the user-level application to receive messages reported by the driver.
- 1. Enable the user-level application to compile the function for processing messages reported by the driver.
-
- ```
- static int OnDevEventReceived(void *priv, uint32_t id, struct HdfSBuf *data)
- {
- OsalTimespec time;
- OsalGetTime(&time);
- HDF_LOGE("%s received event at %llu.%llu", (char *)priv, time.sec, time.usec);
-
- const char *string = HdfSbufReadString(data);
- if (string == NULL) {
- HDF_LOGE("fail to read string in event data");
- return -1;
- }
- HDF_LOGE("%s: dev event received: %d %s", (char *)priv, id, string);
- return 0;
- }
- ```
-
- 2. Enable the user-level application to register the function for receiving messages reported by the driver.
-
- ```
- int RegisterListen()
- {
- struct HdfIoService *serv = HdfIoServiceBind("sample_driver");
- if (serv == NULL) {
- HDF_LOGE("fail to get service");
- return -1;
- }
- static struct HdfDevEventlistener listener = {
- .callBack = OnDevEventReceived,
- .priv ="Service0"
- };
- if (HdfDeviceRegisterEventListener(serv, &listener) != 0) {
- HDF_LOGE("fail to register event listener");
- return -1;
- }
- ......
- HdfDeviceUnregisterEventListener(serv, &listener);
- HdfIoServiceRecycle(serv);
- return 0;
- }
- ```
-
- 3. Enable the driver to report events.
-
- ```
- int32_t SampleDriverDispatch(struct HdfDeviceObject *device, int cmdCode, struct HdfSBuf *data, struct HdfSBuf *reply)
- {
- ... // process api call here
- return HdfDeviceSendEvent(deviceObject, cmdCode, data);
- }
- ```
-
-
-
diff --git a/en/device-dev/driver/driver-platform.md b/en/device-dev/driver/driver-platform.md
deleted file mode 100644
index d75727d7407e71e9088a907083d02278462474e3..0000000000000000000000000000000000000000
--- a/en/device-dev/driver/driver-platform.md
+++ /dev/null
@@ -1,19 +0,0 @@
-# Driver Platform
-
-- **[GPIO](gpio.md)**
-
-- **[I2C](i2c.md)**
-
-- **[RTC](rtc.md)**
-
-- **[SDIO](sdio.md)**
-
-- **[SPI](spi.md)**
-
-- **[UART](uart.md)**
-
-- **[WATCHDOG](watchdog.md)**
-
-- **[MIPI DSI](mipi-dsi.md)**
-
-
diff --git a/en/device-dev/driver/figures/architecture-of-the-display-driver-model.png b/en/device-dev/driver/figure/architecture-of-the-display-driver-model.png
similarity index 100%
rename from en/device-dev/driver/figures/architecture-of-the-display-driver-model.png
rename to en/device-dev/driver/figure/architecture-of-the-display-driver-model.png
diff --git a/en/device-dev/driver/figures/architecture-of-the-input-driver-model.png b/en/device-dev/driver/figure/architecture-of-the-input-driver-model.png
similarity index 100%
rename from en/device-dev/driver/figures/architecture-of-the-input-driver-model.png
rename to en/device-dev/driver/figure/architecture-of-the-input-driver-model.png
diff --git a/en/device-dev/driver/figures/architecture-of-the-sensor-driver-model.png b/en/device-dev/driver/figure/architecture-of-the-sensor-driver-model.png
similarity index 100%
rename from en/device-dev/driver/figures/architecture-of-the-sensor-driver-model.png
rename to en/device-dev/driver/figure/architecture-of-the-sensor-driver-model.png
diff --git a/en/device-dev/driver/figures/common-pins-of-the-touchscreen.png b/en/device-dev/driver/figure/common-pins-of-the-touchscreen.png
similarity index 100%
rename from en/device-dev/driver/figures/common-pins-of-the-touchscreen.png
rename to en/device-dev/driver/figure/common-pins-of-the-touchscreen.png
diff --git a/en/device-dev/driver/figures/dsi-transmitting-and-receiving-interface.png b/en/device-dev/driver/figure/dsi-transmitting-and-receiving-interface.png
similarity index 100%
rename from en/device-dev/driver/figures/dsi-transmitting-and-receiving-interface.png
rename to en/device-dev/driver/figure/dsi-transmitting-and-receiving-interface.png
diff --git a/en/device-dev/driver/figures/en-us_image_0000001053405727.png b/en/device-dev/driver/figure/en-us_image_0000001053405727.png
similarity index 100%
rename from en/device-dev/driver/figures/en-us_image_0000001053405727.png
rename to en/device-dev/driver/figure/en-us_image_0000001053405727.png
diff --git a/en/device-dev/driver/figures/en-us_image_0000001054280608.png b/en/device-dev/driver/figure/en-us_image_0000001054280608.png
similarity index 100%
rename from en/device-dev/driver/figures/en-us_image_0000001054280608.png
rename to en/device-dev/driver/figure/en-us_image_0000001054280608.png
diff --git a/en/device-dev/driver/figures/en-us_image_0000001054564784.png b/en/device-dev/driver/figure/en-us_image_0000001054564784.png
similarity index 100%
rename from en/device-dev/driver/figures/en-us_image_0000001054564784.png
rename to en/device-dev/driver/figure/en-us_image_0000001054564784.png
diff --git a/en/device-dev/driver/figures/en-us_image_0000001057902344.png b/en/device-dev/driver/figure/en-us_image_0000001123509750.png
similarity index 100%
rename from en/device-dev/driver/figures/en-us_image_0000001057902344.png
rename to en/device-dev/driver/figure/en-us_image_0000001123509750.png
diff --git a/en/device-dev/driver/figures/en-us_image_0000001072553354.png b/en/device-dev/driver/figure/en-us_image_0000001123514210.png
similarity index 100%
rename from en/device-dev/driver/figures/en-us_image_0000001072553354.png
rename to en/device-dev/driver/figure/en-us_image_0000001123514210.png
diff --git a/en/device-dev/driver/figures/en-us_image_0000001054440624.png b/en/device-dev/driver/figure/en-us_image_0000001123540984.png
similarity index 100%
rename from en/device-dev/driver/figures/en-us_image_0000001054440624.png
rename to en/device-dev/driver/figure/en-us_image_0000001123540984.png
diff --git a/en/device-dev/driver/figures/en-us_image_0000001054007499.png b/en/device-dev/driver/figure/en-us_image_0000001123582482.png
similarity index 100%
rename from en/device-dev/driver/figures/en-us_image_0000001054007499.png
rename to en/device-dev/driver/figure/en-us_image_0000001123582482.png
diff --git a/en/device-dev/driver/figures/en-us_image_0000001054728498.png b/en/device-dev/driver/figure/en-us_image_0000001123675706.png
similarity index 100%
rename from en/device-dev/driver/figures/en-us_image_0000001054728498.png
rename to en/device-dev/driver/figure/en-us_image_0000001123675706.png
diff --git a/en/device-dev/driver/figures/en-us_image_0000001054726248.png b/en/device-dev/driver/figure/en-us_image_0000001123703482.png
similarity index 100%
rename from en/device-dev/driver/figures/en-us_image_0000001054726248.png
rename to en/device-dev/driver/figure/en-us_image_0000001123703482.png
diff --git a/en/device-dev/driver/figures/en-us_image_0000001054142582.png b/en/device-dev/driver/figure/en-us_image_0000001123742254.png
similarity index 100%
rename from en/device-dev/driver/figures/en-us_image_0000001054142582.png
rename to en/device-dev/driver/figure/en-us_image_0000001123742254.png
diff --git a/en/device-dev/driver/figures/en-us_image_0000001057342245.png b/en/device-dev/driver/figure/en-us_image_0000001170187071.png
similarity index 100%
rename from en/device-dev/driver/figures/en-us_image_0000001057342245.png
rename to en/device-dev/driver/figure/en-us_image_0000001170187071.png
diff --git a/en/device-dev/driver/figures/en-us_image_0000001054006983.png b/en/device-dev/driver/figure/en-us_image_0000001170227689.png
similarity index 100%
rename from en/device-dev/driver/figures/en-us_image_0000001054006983.png
rename to en/device-dev/driver/figure/en-us_image_0000001170227689.png
diff --git a/en/device-dev/driver/figures/en-us_image_0000001057622716.png b/en/device-dev/driver/figure/en-us_image_0000001170229891.png
similarity index 100%
rename from en/device-dev/driver/figures/en-us_image_0000001057622716.png
rename to en/device-dev/driver/figure/en-us_image_0000001170229891.png
diff --git a/en/device-dev/driver/figures/en-us_image_0000001053926237.png b/en/device-dev/driver/figure/en-us_image_0000001170262141.png
similarity index 100%
rename from en/device-dev/driver/figures/en-us_image_0000001053926237.png
rename to en/device-dev/driver/figure/en-us_image_0000001170262141.png
diff --git a/en/device-dev/driver/figures/en-us_image_0000001055299108.png b/en/device-dev/driver/figure/en-us_image_0000001170383063.png
similarity index 100%
rename from en/device-dev/driver/figures/en-us_image_0000001055299108.png
rename to en/device-dev/driver/figure/en-us_image_0000001170383063.png
diff --git a/en/device-dev/driver/figures/mipi-dsi.png b/en/device-dev/driver/figure/mipi-dsi.png
similarity index 100%
rename from en/device-dev/driver/figures/mipi-dsi.png
rename to en/device-dev/driver/figure/mipi-dsi.png
diff --git a/en/device-dev/driver/figures/physical-connection-diagram-for-i2c.png b/en/device-dev/driver/figure/physical-connection-diagram-for-i2c.png
similarity index 100%
rename from en/device-dev/driver/figures/physical-connection-diagram-for-i2c.png
rename to en/device-dev/driver/figure/physical-connection-diagram-for-i2c.png
diff --git a/en/device-dev/driver/figures/ttl-interface.png b/en/device-dev/driver/figure/ttl-interface.png
similarity index 100%
rename from en/device-dev/driver/figures/ttl-interface.png
rename to en/device-dev/driver/figure/ttl-interface.png
diff --git "a/en/device-dev/driver/figures/\346\216\245\345\217\243\345\210\206\345\270\203\345\233\2764.png" "b/en/device-dev/driver/figure/\346\216\245\345\217\243\345\210\206\345\270\203\345\233\2764.png"
similarity index 100%
rename from "en/device-dev/driver/figures/\346\216\245\345\217\243\345\210\206\345\270\203\345\233\2764.png"
rename to "en/device-dev/driver/figure/\346\216\245\345\217\243\345\210\206\345\270\203\345\233\2764.png"
diff --git a/en/device-dev/driver/gpio.md b/en/device-dev/driver/gpio.md
deleted file mode 100644
index a35dc16408feb1ef8d9c6b7ad878a8d99d00fea6..0000000000000000000000000000000000000000
--- a/en/device-dev/driver/gpio.md
+++ /dev/null
@@ -1,9 +0,0 @@
-# GPIO
-
-- **[GPIO Overview](gpiooverview.md)**
-
-- **[GPIO Usage Guidelines](gpiousage-guidelines.md)**
-
-- **[GPIO Usage Example](gpiousage-example.md)**
-
-
diff --git a/en/device-dev/driver/gpiooverview.md b/en/device-dev/driver/gpiooverview.md
deleted file mode 100644
index a05df150d2b1b166350337754bb024e4d58e7e67..0000000000000000000000000000000000000000
--- a/en/device-dev/driver/gpiooverview.md
+++ /dev/null
@@ -1,85 +0,0 @@
-# GPIO Overview
-
-- [Introduction](#section15318165672215)
-- [Available APIs](#section18977142162418)
-
-## Introduction
-
-GPIO is short for general-purpose input/output. Generally, a GPIO controller manages all GPIO pins by group. Each group of GPIO pins is associated with one or more registers. The GPIO pins are operated by reading data from and writing data to the registers.
-
-The GPIO APIs define a set of standard functions for performing operations on GPIO pins, including:
-
-- Setting the pin direction, which can be input or output \(High impedance is not supported currently.\)
-
-- Reading and writing level values, which can be low or high
-- Setting an interrupt service routine \(ISR\) function and interrupt trigger mode for a pin
-- Enabling or disabling a pin interrupt
-
-## Available APIs
-
-**Table 1** APIs available for the GPIO driver
-
-
-
Capability
-
-
Function
-
-
Description
-
-
-
-
GPIO read/write
-
-
GpioRead
-
-
Reads the level value of a GPIO pin.
-
-
-
GpioWrite
-
-
Writes the level value of a GPIO pin.
-
-
-
GPIO settings
-
-
GpioSetDir
-
-
Sets the direction for a GPIO pin.
-
-
-
GpioGetDir
-
-
Obtains the direction for a GPIO pin.
-
-
-
GPIO interrupt settings
-
-
-
-
-
GpioSetIrq
-
-
Sets the ISR function for a GPIO pin.
-
-
-
GpioUnSetIrq
-
-
Cancels the setting of the ISR function for a GPIO pin.
-
-
-
GpioEnableIrq
-
-
Enables a GPIO interrupt.
-
-
-
GpioDisableIrq
-
-
Disables a GPIO interrupt.
-
-
-
-
-
-> **NOTE:**
->All functions provided in this document can be called only in kernel mode.
-
diff --git a/en/device-dev/driver/gpiousage-example.md b/en/device-dev/driver/gpiousage-example.md
deleted file mode 100644
index bfdb21eed1d8feece2e48d130b8d0cea1ae17a58..0000000000000000000000000000000000000000
--- a/en/device-dev/driver/gpiousage-example.md
+++ /dev/null
@@ -1,79 +0,0 @@
-# GPIO Usage Example
-
-In this example, we test the interrupt trigger of a GPIO pin as follows: Set the ISR function for the pin, set the trigger mode to rising edge and failing edge, write high and low levels to the pin alternately to generate level fluctuation, and observe the execution of the ISR function.
-
-Select an idle GPIO pin. This example uses a Hi3516D V300 development board and GPIO pin GPIO10\_3, which is numbered GPIO83.
-
-You can select an idle GPIO pin based on the development board and schematic diagram.
-
-```
-#include "gpio_if.h"
-#include "hdf_log.h"
-#include "osal_irq.h"
-#include "osal_time.h"
-
-static uint32_t g_irqCnt;
-
-/* ISR function */
-static int32_t TestCaseGpioIrqHandler(uint16_t gpio, void *data)
-{
- HDF_LOGE("%s: irq triggered! on gpio:%u, data=%p", __func__, gpio, data);
- g_irqCnt++; /* If the ISR function is triggered, the number of global interrupts is incremented by 1. */
- return GpioDisableIrq(gpio);
-}
-
-/* Test case function */
-static int32_t TestCaseGpioIrqEdge(void)
-{
- int32_t ret;
- uint16_t valRead;
- uint16_t mode;
- uint16_t gpio = 83; /* Number of the GPIO pin to test */
- uint32_t timeout;
-
- /* Set the output direction for the pin. */
- ret = GpioSetDir(gpio, GPIO_DIR_OUT);
- if (ret != HDF_SUCCESS) {
- HDF_LOGE("%s: set dir fail! ret:%d\n", __func__, ret);
- return ret;
- }
-
- /* Disable the interrupt of the pin. */
- ret = GpioDisableIrq(gpio);
- if (ret != HDF_SUCCESS) {
- HDF_LOGE("%s: disable irq fail! ret:%d\n", __func__, ret);
- return ret;
- }
-
- /* Set the ISR function for the pin. The trigger mode is both rising edge and falling edge. */
- mode = OSAL_IRQF_TRIGGER_RISING | OSAL_IRQF_TRIGGER_FALLING;
- HDF_LOGE("%s: mode:%0x\n", __func__, mode);
- ret = GpioSetIrq(gpio, mode, TestCaseGpioIrqHandler, NULL);
- if (ret != HDF_SUCCESS) {
- HDF_LOGE("%s: set irq fail! ret:%d\n", __func__, ret);
- return ret;
- }
-
- /* Enable the interrupt for this pin. */
- ret = GpioEnableIrq(gpio);
- if (ret != HDF_SUCCESS) {
- HDF_LOGE("%s: enable irq fail! ret:%d\n", __func__, ret);
- (void)GpioUnSetIrq(gpio);
- return ret;
- }
-
- g_irqCnt = 0; /* Reset the global counter. */
- timeout = 0; /* Reset the waiting time. */
- /* Wait for the ISR function of this pin to trigger. The timeout duration is 1000 ms. */
- while (g_irqCnt <= 0 && timeout < 1000) {
- (void)GpioRead(gpio, &valRead);
- (void)GpioWrite(gpio, (valRead == GPIO_VAL_LOW) ? GPIO_VAL_HIGH : GPIO_VAL_LOW);
- HDF_LOGE("%s: wait irq timeout:%u\n", __func__, timeout);
- OsalMDelay(200); /* wait for irq trigger */
- timeout += 200;
- }
- (void)GpioUnSetIrq(gpio);
- return (g_irqCnt > 0) ? HDF_SUCCESS : HDF_FAILURE;
-}
-```
-
diff --git a/en/device-dev/driver/gpiousage-guidelines.md b/en/device-dev/driver/gpiousage-guidelines.md
deleted file mode 100644
index 67c29e26454fde7b66ef285e993d01d08f09d8ba..0000000000000000000000000000000000000000
--- a/en/device-dev/driver/gpiousage-guidelines.md
+++ /dev/null
@@ -1,395 +0,0 @@
-# GPIO Usage Guidelines
-
-- [How to Use](#section1583613406410)
-- [Determining a GPIO Pin Number](#section135943361443)
-- [Using APIs to Operate GPIO Pins](#section69151114115315)
-
-## How to Use
-
-The GPIO APIs use the GPIO pin number to specify a pin. [Figure 1](#fig1399416053717) shows the general process of using a GPIO.
-
-**Figure 1** Process of using a GPIO
-
-
-
-
-## Determining a GPIO Pin Number
-
-The method for converting GPIO pin numbers varies according to the GPIO controller model, parameters, and controller driver of different system on chips \(SoCs\).
-
-- Hi3516D V300
-
- A controller manages 12 groups of GPIO pins. Each group contains 8 GPIO pins.
-
- GPIO pin number = GPIO group index \(0-11\) x Number of GPIO pins in each group \(8\) + Offset in the group
-
- Example: GPIO number of GPIO10\_3 = 10 x 8 + 3 = 83
-
-- Hi3518E V300
-
- A controller manages 10 groups of GPIO pins. Each group contains 10 GPIO pins.
-
- GPIO pin number = GPIO group index \(0–9\) x Number of GPIO pins in each group \(10\) + Offset in the group
-
- Example: GPIO pin number of GPIO7\_3 = 7 x 10 + 3 = 73
-
-
-## Using APIs to Operate GPIO Pins
-
-- Set the direction for a GPIO pin.
-
- Before performing read/write operations on a GPIO pin, call the following function to set the direction:
-
- int32\_t GpioSetDir\(uint16\_t gpio, uint16\_t dir\);
-
- **Table 1** Description of GpioSetDir
-
-
-
Parameter
-
-
Description
-
-
-
gpio
-
-
GPIO pin number.
-
-
-
dir
-
-
Direction to set.
-
-
-
Return Value
-
-
Description
-
-
-
0
-
-
The setting is successful.
-
-
-
Negative value
-
-
The setting failed.
-
-
-
-
-
-- Read or write the level value for a GPIO pin.
-
- To read the level value of a GPIO pin, call the following function:
-
- int32\_t GpioRead\(uint16\_t gpio, uint16\_t \*val\);
-
- **Table 2** Description of GpioRead
-
-
-
Parameter
-
-
Description
-
-
-
gpio
-
-
GPIO pin number.
-
-
-
val
-
-
Pointer to the level value.
-
-
-
Return Value
-
-
Description
-
-
-
0
-
-
Succeeded in reading the level value.
-
-
-
Negative value
-
-
Failed to read the level value.
-
-
-
-
-
- To write the level value for a GPIO pin, call the following function:
-
- int32\_t GpioWrite\(uint16\_t gpio, uint16\_t val\);
-
- **Table 3** Description of GpioWrite
-
-
-
Parameter
-
-
Description
-
-
-
gpio
-
-
GPIO pin number.
-
-
-
val
-
-
Level value to write.
-
-
-
Return Value
-
-
Description
-
-
-
0
-
-
Succeeded in writing the level value.
-
-
-
Negative value
-
-
Failed to write the level value.
-
-
-
-
-
- Example:
-
- ```
- int32_t ret;
- uint16_t val;
- /* Set the output direction for GPIO3. */
- ret = GpioSetDir(3, GPIO_DIR_OUT);
- if (ret != 0) {
- HDF_LOGE("GpioSerDir: failed, ret %d\n", ret);
- return;
- }
- /* Write the low level GPIO_VAL_LOW for GPIO3. */
- ret = GpioWrite(3, GPIO_VAL_LOW);
- if (ret != 0) {
- HDF_LOGE("GpioWrite: failed, ret %d\n", ret);
- return;
- }
- /* Set the input direction for GPIO6. */
- ret = GpioSetDir(6, GPIO_DIR_IN);
- if (ret != 0) {
- HDF_LOGE("GpioSetDir: failed, ret %d\n", ret);
- return;
- }
- /* Read the level value of GPIO6. */
- ret = GpioRead(6, &val);
- ```
-
-
-- Set the ISR function for a GPIO pin.
-
- To set the ISR function for a GPIO pin, call the following function:
-
- int32\_t GpioSetIrq\(uint16\_t gpio, uint16\_t mode, GpioIrqFunc func, void \*arg\);
-
- **Table 4** Description of GpioSetIrq
-
-
-
Parameter
-
-
Description
-
-
-
gpio
-
-
GPIO pin number.
-
-
-
mode
-
-
Interrupt trigger mode.
-
-
-
func
-
-
ISR function to set.
-
-
-
arg
-
-
Pointer to the parameters passed to the ISR function.
-
-
-
Return Value
-
-
Description
-
-
-
0
-
-
The setting is successful.
-
-
-
Negative value
-
-
The setting failed.
-
-
-
-
-
- > **CAUTION:**
- >Only one ISR function can be set for a GPIO pin at a time. If **GpioSetIrq** is called repeatedly, the previous IRS function will be replaced.
-
- If the ISR function is no longer required, call the following function to cancel the setting:
-
- int32\_t GpioUnSetIrq\(uint16\_t gpio\);
-
- **Table 5** Description of GpioUnSetIrq
-
-
-
Parameter
-
-
Description
-
-
-
gpio
-
-
GPIO pin number.
-
-
-
Return Value
-
-
Description
-
-
-
0
-
-
The ISR function is canceled.
-
-
-
Negative value
-
-
Failed to cancel the ISR function.
-
-
-
-
-
- After the ISR function is set, call the following function to enable a GPIO interrupt:
-
- int32\_t GpioEnableIrq\(uint16\_t gpio\);
-
- **Table 6** Description of GpioEnableIrq
-
-
-
Parameter
-
-
Description
-
-
-
gpio
-
-
GPIO pin number.
-
-
-
Return Value
-
-
Description
-
-
-
0
-
-
The GPIO interrupt is enabled.
-
-
-
Negative value
-
-
Failed to enable a GPIO interrupt.
-
-
-
-
-
- > **CAUTION:**
- >The configured ISR function can be responded only after the ISR function is enabled.
-
- Use the following function to disable the GPIO interrupt:
-
- int32\_t GpioDisableIrq\(uint16\_t gpio\);
-
- **Table 7** Description of GpioDisableIrq
-
-
-
Parameter
-
-
Description
-
-
-
gpio
-
-
GPIO pin number.
-
-
-
Return Value
-
-
Description
-
-
-
0
-
-
The GPIO interrupt is disabled.
-
-
-
Negative value
-
-
Failed to disable the GPIO interrupt.
-
-
-
-
-
- Example:
-
- ```
- /* ISR function */
- */
- int32_t MyCallBackFunc(uint16_t gpio, void *data)
- {
- HDF_LOGI("%s: gpio:%u interrupt service in! data=%p\n", __func__, gpio, data);
- return 0;
- }
-
- int32_t ret;
- /* Set the ISR function to MyCallBackFunc, the parameter to NULL, and the interrupt trigger mode to rising edge. */
- ret = GpioSetIrq(3, OSAL_IRQF_TRIGGER_RISING, MyCallBackFunc, NULL);
- if (ret != 0) {
- HDF_LOGE("GpioSetIrq: failed, ret %d\n", ret);
- return;
- }
-
- /* Enable an interrupt for GPIO3. */
- ret = GpioEnableIrq(3);
- if (ret != 0) {
- HDF_LOGE("GpioEnableIrq: failed, ret %d\n", ret);
- return;
- }
-
- /* Disable the interrupt for GPIO3. */
- ret = GpioDisableIrq(3);
- if (ret != 0) {
- HDF_LOGE("GpioDisableIrq: failed, ret %d\n", ret);
- return;
- }
-
- /* Cancel the ISR function for GPIO3. */
- ret = GpioUnSetIrq(3);
- if (ret != 0) {
- HDF_LOGE("GpioUnSetIrq: failed, ret %d\n", ret);
- return;
- }
- ```
-
-
diff --git a/en/device-dev/driver/hdf.md b/en/device-dev/driver/hdf.md
deleted file mode 100644
index 05183747d4acb2435125a02035725cedc28b5081..0000000000000000000000000000000000000000
--- a/en/device-dev/driver/hdf.md
+++ /dev/null
@@ -1,15 +0,0 @@
-# HDF
-
-- **[HDF Overview](hdfoverview.md)**
-
-- **[Driver Development](driver-development.md)**
-
-- **[Driver Service Management](driver-service-management.md)**
-
-- **[Driver Message Mechanism Management](driver-message-mechanism-management.md)**
-
-- **[Driver Configuration Management](driver-configuration-management.md)**
-
-- **[HDF Development Example](hdfdevelopment-example.md)**
-
-
diff --git a/en/device-dev/driver/hdfdevelopment-example.md b/en/device-dev/driver/hdfdevelopment-example.md
deleted file mode 100644
index 815706650b3e69638f9310ace1bdd00b93f71e38..0000000000000000000000000000000000000000
--- a/en/device-dev/driver/hdfdevelopment-example.md
+++ /dev/null
@@ -1,238 +0,0 @@
-# HDF Development Example
-
-- [Adding Configurations](#section27261067111)
-- [Compiling the Driver Code](#section177988005)
-- [Compiling the Code for Interaction](#section6205173816412)
-
-The following example shows how to add configurations, implement the driver code, and compile the code for interaction between the user-level applications and the driver.
-
-## Adding Configurations
-
-Add the driver configurations to the HDF configuration file \(for example, **vendor/hisilicon/xxx/config/device\_info**\). Example:
-
-```
-root {
- device_info {
- match_attr = "hdf_manager";
- template host {
- hostName = "";
- priority = 100;
- template device {
- template deviceNode {
- policy = 0;
- priority = 100;
- preload = 0;
- permission = 0664;
- moduleName = "";
- serviceName = "";
- deviceMatchAttr = "";
- }
- }
- }
- sample_host :: host {
- hostName = "sample_host";
- sample_device :: device {
- device0 :: deviceNode {
- policy = 2;
- priority = 100;
- preload = 1;
- permission = 0664;
- moduleName = "sample_driver";
- serviceName = "sample_service";
- }
- }
- }
- }
-}
-```
-
-## Compiling the Driver Code
-
-A sample of driver code compiled based on the HDF is as follows:
-
-```
-#include
-#include
-#include
-#include "hdf_log.h"
-#include "hdf_base.h"
-#include "hdf_device_desc.h"
-
-#define HDF_LOG_TAG "sample_driver"
-
-#define SAMPLE_WRITE_READ 123
-
-int32_t HdfSampleDriverDispatch(
- struct HdfDeviceObject *deviceObject, int id, struct HdfSBuf *data, struct HdfSBuf *reply)
-{
- HDF_LOGE("%s: received cmd %d", __func__, id);
- if (id == SAMPLE_WRITE_READ) {
- const char *readData = HdfSbufReadString(data);
- if (readData != NULL) {
- HDF_LOGE("%s: read data is: %s", __func__, readData);
- }
- if (!HdfSbufWriteInt32(reply, INT32_MAX)) {
- HDF_LOGE("%s: reply int32 fail", __func__);
- }
- return HdfDeviceSendEvent(deviceObject, id, data);
- }
- return HDF_FAILURE;
-}
-
-void HdfSampleDriverRelease(struct HdfDeviceObject *deviceObject)
-{
- // Release resources here
- return;
-}
-
-int HdfSampleDriverBind(struct HdfDeviceObject *deviceObject)
-{
- if (deviceObject == NULL) {
- return HDF_FAILURE;
- }
- static struct IDeviceIoService testService = {
- .Dispatch = HdfSampleDriverDispatch,
- };
- deviceObject->service = &testService;
- return HDF_SUCCESS;
-}
-
-int HdfSampleDriverInit(struct HdfDeviceObject *deviceObject)
-{
- if (deviceObject == NULL) {
- HDF_LOGE("%s::ptr is null!", __func__);
- return HDF_FAILURE;
- }
- HDF_LOGE("Sample driver Init success");
- return HDF_SUCCESS;
-}
-
-struct HdfDriverEntry g_sampleDriverEntry = {
- .moduleVersion = 1,
- .moduleName = "sample_driver",
- .Bind = HdfSampleDriverBind,
- .Init = HdfSampleDriverInit,
- .Release = HdfSampleDriverRelease,
-};
-
-HDF_INIT(g_sampleDriverEntry);
-```
-
-## Compiling the Code for Interaction
-
-A sample code for interaction between the user-level application and driver compiled based on the HDF is as follows:
-
-```
-#include
-#include
-#include
-#include
-#include "hdf_log.h"
-#include "hdf_sbuf.h"
-#include "hdf_io_service_if.h"
-
-#define HDF_LOG_TAG "sample_test"
-#define SAMPLE_SERVICE_NAME "sample_service"
-
-#define SAMPLE_WRITE_READ 123
-
-int g_replyFlag = 0;
-
-static int OnDevEventReceived(void *priv, uint32_t id, struct HdfSBuf *data)
-{
- const char *string = HdfSbufReadString(data);
- if (string == NULL) {
- HDF_LOGE("fail to read string in event data");
- g_replyFlag = 1;
- return HDF_FAILURE;
- }
- HDF_LOGE("%s: dev event received: %u %s", (char *)priv, id, string);
- g_replyFlag = 1;
- return HDF_SUCCESS;
-}
-
-static int SendEvent(struct HdfIoService *serv, char *eventData)
-{
- int ret = 0;
- struct HdfSBuf *data = HdfSBufObtainDefaultSize();
- if (data == NULL) {
- HDF_LOGE("fail to obtain sbuf data");
- return 1;
- }
-
- struct HdfSBuf *reply = HdfSBufObtainDefaultSize();
- if (reply == NULL) {
- HDF_LOGE("fail to obtain sbuf reply");
- ret = HDF_DEV_ERR_NO_MEMORY;
- goto out;
- }
-
- if (!HdfSbufWriteString(data, eventData)) {
- HDF_LOGE("fail to write sbuf");
- ret = HDF_FAILURE;
- goto out;
- }
-
- ret = serv->dispatcher->Dispatch(&serv->object, SAMPLE_WRITE_READ, data, reply);
- if (ret != HDF_SUCCESS) {
- HDF_LOGE("fail to send service call");
- goto out;
- }
-
- int replyData = 0;
- if (!HdfSbufReadInt32(reply, &replyData)) {
- HDF_LOGE("fail to get service call reply");
- ret = HDF_ERR_INVALID_OBJECT;
- goto out;
- }
- HDF_LOGE("Get reply is: %d", replyData);
-out:
- HdfSBufRecycle(data);
- HdfSBufRecycle(reply);
- return ret;
-}
-
-int main()
-{
- char *sendData = "default event info";
- struct HdfIoService *serv = HdfIoServiceBind(SAMPLE_SERVICE_NAME);
- if (serv == NULL) {
- HDF_LOGE("fail to get service %s", SAMPLE_SERVICE_NAME);
- return HDF_FAILURE;
- }
-
- static struct HdfDevEventlistener listener = {
- .callBack = OnDevEventReceived,
- .priv ="Service0"
- };
-
- if (HdfDeviceRegisterEventListener(serv, &listener) != HDF_SUCCESS) {
- HDF_LOGE("fail to register event listener");
- return HDF_FAILURE;
- }
- if (SendEvent(serv, sendData)) {
- HDF_LOGE("fail to send event");
- return HDF_FAILURE;
- }
-
- while (g_replyFlag == 0) {
- sleep(1);
- }
-
- if (HdfDeviceUnregisterEventListener(serv, &listener)) {
- HDF_LOGE("fail to unregister listener");
- return HDF_FAILURE;
- }
-
- HdfIoServiceRecycle(serv);
- return HDF_SUCCESS;
-}
-```
-
-> **NOTE:**
->The code compilation of user-level applications depends on the dynamic libraries **hdf\_core** and **osal** provided by the HDF because user-level applications use the message sending interface of the HDF. In the GN compilation file, add the following dependency relationships:
->deps = \[
->"//drivers/adapter/lite/uhdf/manager:hdf\_core",
->"//drivers/adapter/lite/uhdf/posix:hdf\_posix\_osal",
->\]
-
diff --git a/en/device-dev/driver/i2c-overview.md b/en/device-dev/driver/i2c-overview.md
deleted file mode 100644
index 407a149be21029b30d63559117a93b846ce70c00..0000000000000000000000000000000000000000
--- a/en/device-dev/driver/i2c-overview.md
+++ /dev/null
@@ -1,60 +0,0 @@
-# I2C Overview
-
-- [Introduction](#section5361140416)
-- [Available APIs](#section7606310210)
-
-## Introduction
-
-- The Inter-Integrated Circuit \(I2C\) is a simple, bidirectional, and synchronous serial bus that uses merely two wires.
-- In an I2C communication, one controller communicates with one or more devices through the serial data line \(SDA\) and serial clock line \(SCL\), as shown in [Figure 1](#fig1135561232714).
-
-- I2C data transfer must begin with a **START** condition and end with a **STOP** condition. Data is transmitted byte-by-byte from the most significant bit to the least significant bit.
-- Each I2C node is recognized by a unique address and can serve as either a controller or a device. When the controller needs to communicate with a device, it writes the device address to the bus through broadcast. A device matching this address sends a response to set up a data transfer channel.
-
-- The I2C APIs define a set of common functions for I2C data transfer, including:
-
- - I2C controller management: opening or closing an I2C controller
- - I2C message transfer: custom transfer by using a message array
-
- **Figure 1** Physical connection diagram for I2C
- 
-
-
-## Available APIs
-
-**Table 1** APIs available for the I2C driver
-
-
-
Capability
-
-
Function
-
-
Description
-
-
-
-
I2C controller management
-
-
I2cOpen
-
-
Opens an I2C controller.
-
-
-
I2cClose
-
-
Closes an I2C controller.
-
-
-
I2C message transfer
-
-
I2cTransfer
-
-
Performs a custom transfer.
-
-
-
-
-
-> **NOTE:**
->All functions provided in this document can be called only in kernel mode.
-
diff --git a/en/device-dev/driver/i2c-usage-example.md b/en/device-dev/driver/i2c-usage-example.md
deleted file mode 100644
index 438961611a6aba9bcb7e9a89617650a63e7dcd36..0000000000000000000000000000000000000000
--- a/en/device-dev/driver/i2c-usage-example.md
+++ /dev/null
@@ -1,192 +0,0 @@
-# I2C Usage Example
-
-This example describes how to use I2C APIs by using an I2C device on a development board.
-
-This example shows a simple register read/write operation on TouchPad on a Hi3516D V300 development board. The basic hardware information is as follows:
-
-- SoC: hi3516dv300
-
-- Touch IC: The I2C address is 0x38, and the bit width of Touch IC's internal register is 1 byte.
-
-- Schematic diagram: TouchPad is mounted to I2C controller 3. The reset pin of Touch IC is GPIO3.
-
-In this example, first we reset Touch IC. \(The development board supplies power to Touch IC by default after being powered on, and this use case does not consider the power supply\). Then, we perform a read/wirte operation on an internal register to test whether the I2C channel is normal.
-
-> **NOTE:**
->The example focuses on I2C device access and verifies the I2C channel. The read and write values of the device register are not concerned. The behavior caused by the read and write operations on the register is determined by the device itself.
-
-Example:
-
-```
-#include "i2c_if.h" /* Header file of I2C APIs */
-#include "gpio_if.h" /* Header file of GPIO APIs */
-#include "hdf_log.h" /* Header file for log APIs */
-#include "osal_io.h" /* Header file of I/O read and write APIs */
-#include "osal_time.h" /* Header file of delay and sleep APIs */
-
-/* Define a TP device structure to store I2C and GPIO hardware information. */
-struct TpI2cDevice {
- uint16_t rstGpio; /* Reset pin */
- uint16_t busId; /* I2C bus ID */
- uint16_t addr; /* I2C device address */
- uint16_t regLen; /* Register bit width */
- DevHandle i2cHandle; /* I2C controller handle */
-};
-
-/* I2C pin I/O configuration. For details, see the SoC register manual. */
-#define I2C3_DATA_REG_ADDR 0x112f008c /* Address of the SDA pin configuration register of I2C controller 3
-#define I2C3_CLK_REG_ADDR 0x112f0090 /* Address of the SCL pin configuration register of I2C controller 3
-#define I2C_REG_CFG 0x5f1 /* Configuration values of SDA and SCL pins of I2C controller 3
-
-static void TpSocIoCfg(void)
-{
- /* Set the I/O function of the two pins corresponding to I2C controller 3 to I2C. */
- OSAL_WRITEL(I2C_REG_CFG, IO_DEVICE_ADDR(I2C3_DATA_REG_ADDR));
- OSAL_WRITEL(I2C_REG_CFG, IO_DEVICE_ADDR(I2C3_CLK_REG_ADDR));
-}
-
-/* Initialize the reset pin of the TP. Pull up the pin for 20 ms, pull down the pin for 50 ms, and then pull up the pin for 20 ms to complete the resetting. */
-static int32_t TestCaseGpioInit(struct TpI2cDevice *tpDevice)
-{
- int32_t ret;
-
- /* Set the output direction for the reset pin. */
- ret = GpioSetDir(tpDevice->rstGpio, GPIO_DIR_OUT);
- if (ret != HDF_SUCCESS) {
- HDF_LOGE("%s: set rst dir fail!:%d", __func__, ret);
- return ret;
- }
-
- ret = GpioWrite(tpDevice->rstGpio, GPIO_VAL_HIGH);
- if (ret != HDF_SUCCESS) {
- HDF_LOGE("%s: set rst hight fail!:%d", __func__, ret);
- return ret;
- }
- OsalMSleep(20);
-
- ret = GpioWrite(tpDevice->rstGpio, GPIO_VAL_LOW);
- if (ret != HDF_SUCCESS) {
- HDF_LOGE("%s: set rst low fail!:%d", __func__, ret);
- return ret;
- }
- OsalMSleep(50);
-
- ret = GpioWrite(tpDevice->rstGpio, GPIO_VAL_HIGH);
- if (ret != HDF_SUCCESS) {
- HDF_LOGE("%s: set rst high fail!:%d", __func__, ret);
- return ret;
- }
- OsalMSleep(20);
-
- return HDF_SUCCESS;
-}
-
-/* Use I2cTransfer to encapsulate a register read/write auxiliary function. Use flag to indicate the read or write operation. */
-static int TpI2cReadWrite(struct TpI2cDevice *tpDevice, unsigned int regAddr,
- unsigned char *regData, unsigned int dataLen, uint8_t flag)
-{
- int index = 0;
- unsigned char regBuf[4] = {0};
- struct I2cMsg msgs[2] = {0};
-
- /* Perform length adaptation for the single- or dual-byte register. */
- if (tpDevice->regLen == 1) {
- regBuf[index++] = regAddr & 0xFF;
- } else {
- regBuf[index++] = (regAddr >> 8) & 0xFF;
- regBuf[index++] = regAddr & 0xFF;
- }
-
- /* Fill in the I2cMsg message structure. */
- msgs[0].addr = tpDevice->addr;
- msgs[0].flags = 0; /* The flag is 0, indicating the write operation. */
- msgs[0].len = tpDevice->regLen;
- msgs[0].buf = regBuf;
-
- msgs[1].addr = tpDevice->addr;
- msgs[1].flags = (flag == 1)? I2C_FLAG_READ: 0; /* Add the read flag. */
- msgs[1].len = dataLen;
- msgs[1].buf = regData;
-
- if (I2cTransfer(tpDevice->i2cHandle, msgs, 2) != 2) {
- HDF_LOGE("%s: i2c read err", __func__);
- return HDF_FAILURE;
- }
- return HDF_SUCCESS;
-}
-
-/* TP register read function */
-static inline int TpI2cReadReg(struct TpI2cDevice *tpDevice, unsigned int regAddr,
- unsigned char *regData, unsigned int dataLen)
-{
- return TpI2cReadWrite(tpDevice, regAddr, regData, dataLen, 1);
-}
-
-/* TP register write function */
-static inline int TpI2cWriteReg(struct TpI2cDevice *tpDevice, unsigned int regAddr,
- unsigned char *regData, unsigned int dataLen)
-{
- return TpI2cReadWrite(tpDevice, regAddr, regData, dataLen, 0);
-}
-
-/* Main entry of I2C */
-static int32_t TestCaseI2c(void)
-{
- int32_t i;
- int32_t ret;
- unsigned char bufWrite[7] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xA, 0xB, 0xC };
- unsigned char bufRead[7] = {0};
- static struct TpI2cDevice tpDevice;
-
- /* I/O pin function configuration */
- TpSocIoCfg();
-
- /* Initialize TP device information. */
- tpDevice.rstGpio = 3;
- tpDevice.busId = 3;
- tpDevice.addr = 0x38;
- tpDevice.regLen = 1;
- tpDevice.i2cHandle = NULL;
-
- /* Initialize the GPIO pin. */
- ret = TestCaseGpioInit(&tpDevice);
- if (ret != HDF_SUCCESS) {
- HDF_LOGE("%s: gpio init fail!:%d", __func__, ret);
- return ret;
- }
-
- /* Open an I2C controller. */
- tpDevice.i2cHandle = I2cOpen(tpDevice.busId);
- if (tpDevice.i2cHandle == NULL) {
- HDF_LOGE("%s: Open I2c:%u fail!", __func__, tpDevice.busId);
- return -1;
- }
-
- /* Continuously write 7-byte data to register 0xD5 of TP-IC. */
- ret = TpI2cWriteReg(&tpDevice, 0xD5, bufWrite, 7);
- if (ret != HDF_SUCCESS) {
- HDF_LOGE("%s: tp i2c write reg fail!:%d", __func__, ret);
- I2cClose(tpDevice.i2cHandle);
- return -1;
- }
- OsalMSleep(10);
-
- /* Continuously read 7-byte data from register 0xDO of TP-IC. */
- ret = TpI2cReadReg(&tpDevice, 0xD5, bufRead, 7);
- if (ret != HDF_SUCCESS) {
- HDF_LOGE("%s: tp i2c read reg fail!:%d", __func__, ret);
- I2cClose(tpDevice.i2cHandle);
- return -1;
- }
-
- HDF_LOGE("%s: tp i2c write&read reg success!", __func__);
- for (i = 0; i < 7; i++) {
- HDF_LOGE("%s: bufRead[%d] = 0x%x", __func__, i, bufRead[i]);
- }
-
- /* Close the I2C controller. */
- I2cClose(tpDevice.i2cHandle);
- return ret;
-}
-```
-
diff --git a/en/device-dev/driver/i2c-usage-guidelines.md b/en/device-dev/driver/i2c-usage-guidelines.md
deleted file mode 100644
index 9a207bcc3878e779d7345ae5b14b18b0b4cdc46b..0000000000000000000000000000000000000000
--- a/en/device-dev/driver/i2c-usage-guidelines.md
+++ /dev/null
@@ -1,171 +0,0 @@
-# I2C Usage Guidelines
-
-- [How to Use](#section333203315215)
-- [Opening an I2C Controller](#section123631358135713)
-- [Performing I2C Communication](#section11091522125812)
-- [Closing an I2C Controller](#section13519505589)
-
-## How to Use
-
-[Figure 1](#fig166181128151112) illustrates the process of an I2C device.
-
-**Figure 1** Process of using an I2C device
-
-
-
-
-## Opening an I2C Controller
-
-Call the following function to open an I2C controller:
-
-DevHandle I2cOpen\(int16\_t number\);
-
-**Table 1** Description of I2cOpen
-
-
-
Parameter
-
-
Description
-
-
-
-
number
-
-
I2C controller ID.
-
-
-
Return Value
-
-
Description
-
-
-
NULL
-
-
Failed to open the I2C controller.
-
-
-
Device handle
-
-
Handle of the I2C controller.
-
-
-
-
-
-This example assumes that the system has eight I2C controllers \(numbered from 0 to 7\) and I2C controller 3 is to open.
-
-```
-DevHandle i2cHandle = NULL; /* I2C controller handle */
-
-/* Open an I2C controller. */
-i2cHandle = I2cOpen(3);
-if (i2cHandle == NULL) {
- HDF_LOGE("I2cOpen: failed\n");
- return;
-}
-```
-
-## Performing I2C Communication
-
-Use the following function for message transfer:
-
-int32\_t I2cTransfer\(DevHandle handle, struct I2cMsg \*msgs, int16\_t count\);
-
-**Table 2** Description of I2cTransfer
-
-
-
Parameter
-
-
Description
-
-
-
-
handle
-
-
Handle of an I2C controller.
-
-
-
msgs
-
-
Message array of the data to transfer.
-
-
-
count
-
-
Length of the message array.
-
-
-
Return Value
-
-
Description
-
-
-
Positive integer
-
-
Number of message structures that are successfully transmitted.
-
-
-
Negative value
-
-
Failed to perform the message transfer.
-
-
-
-
-
-The type of an I2C message transfer is defined by **I2cMsg**. Each message structure indicates a read or write operation. Multiple read or write operations can be performed by using a message array.
-
-```
-int32_t ret;
-uint8_t wbuff[2] = { 0x12, 0x13 };
-uint8_t rbuff[2] = { 0 };
-struct I2cMsg msgs[2]; /* Custom message array for transfer */
-msgs[0].buf = wbuff; /* Data to write */
-msgs[0].len = 2; /* The length of the data to write is 2. */
-msgs[0].addr = 0x5A; /* The address of the device to write the data is 0x5A. */
-msgs[0].flags = 0; /* The flag is 0, indicating the write operation. */
-msgs[1].buf = rbuff; /* Data to read */
-msgs[1].len = 2; /* The length of the data to read is 2. */
-msgs[1].addr = 0x5A; /* The address of the device to read the data is 0x5A. */
-msgs[1].flags = I2C_FLAG_READ /* I2C_FLAG_READ is configured, indicating the read operation. */
-/* Perform a custom transfer to transfer two messages. */
-ret = I2cTransfer(i2cHandle, msgs, 2);
-if (ret != 2) {
- HDF_LOGE("I2cTransfer: failed, ret %d\n", ret);
- return;
-}
-```
-
-> **CAUTION:**
->- The device address in the **I2cMsg** structure does not contain the read/write flag bit. The read/write information is transferred by the read/write control bit in the member variable **flags**.
->- The **I2cTransfer** function does not limit the number of message structures, which is determined by the I2C controller.
->- The **I2cTransfer** function does not limit the data length of each message structure, which is determined by the I2C controller.
->- The **I2cTransfer** function may cause the system to sleep and therefore cannot be invoked in the interrupt context.
-
-## Closing an I2C Controller
-
-Call the following function to close the I2C controller after the communication is complete:
-
-void I2cClose\(DevHandle handle\);
-
-**Table 3** Description of I2cClose
-
-
-
Parameter
-
-
Description
-
-
-
-
handle
-
-
Handle of an I2C controller.
-
-
-
-
-
-```
-I2cClose(i2cHandle); /* Close the I2C controller. */
-```
-
diff --git a/en/device-dev/driver/i2c.md b/en/device-dev/driver/i2c.md
deleted file mode 100644
index 12167aeab9625b16e078335a504c96cf4cfe8422..0000000000000000000000000000000000000000
--- a/en/device-dev/driver/i2c.md
+++ /dev/null
@@ -1,9 +0,0 @@
-# I2C
-
-- **[I2C Overview](i2c-overview.md)**
-
-- **[I2C Usage Guidelines](i2c-usage-guidelines.md)**
-
-- **[I2C Usage Example](i2c-usage-example.md)**
-
-
diff --git a/en/device-dev/driver/lcd.md b/en/device-dev/driver/lcd.md
deleted file mode 100644
index 9930511412c592f0dc36c9fe4b50ee9f206944a9..0000000000000000000000000000000000000000
--- a/en/device-dev/driver/lcd.md
+++ /dev/null
@@ -1,9 +0,0 @@
-# LCD
-
-- **[LCD Overview](lcdoverview.md)**
-
-- **[LCD Development Guidelines](lcddevelopment-guidelines.md)**
-
-- **[LCD Development Example](lcddevelopment-example.md)**
-
-
diff --git a/en/device-dev/driver/lcddevelopment-example.md b/en/device-dev/driver/lcddevelopment-example.md
deleted file mode 100644
index 35122ca4fa69878a8c36e658da23082b0c0084e0..0000000000000000000000000000000000000000
--- a/en/device-dev/driver/lcddevelopment-example.md
+++ /dev/null
@@ -1,291 +0,0 @@
-# LCD Development Example
-
-Add the device description.
-
-```
-/* Description of the display driver */
-display :: host {
- hostName = "display_host";
- /* Description of the HDF display driver */
- device_hdf_disp :: device {
- device0 :: deviceNode {
- policy = 2;
- priority = 200;
- permission = 0660;
- moduleName = "HDF_DISP";
- serviceName = "hdf_disp";
- }
- }
- /* Description of the driver device at the SoC adapter layer */
- device_hi35xx_disp :: device {
- device0 :: deviceNode {
- policy = 0;
- priority = 199;
- moduleName = "HI351XX_DISP";
- }
- }
- /* Description of the LCD driver */
- device_lcd :: device {
- device0 :: deviceNode {
- policy = 0;
- priority = 100;
- preload = 0;
- moduleName = "LCD_Sample";
- }
- device1 :: deviceNode {
- policy = 0;
- priority = 100;
- preload = 2;
- moduleName = "LCD_SampleXX";
- }
- }
-}
-```
-
-The following example shows how to adapt to the MIPI device to the Hi35xx series chips at the SoC adapter layer:
-
-```
-static int32_t MipiDsiInit(struct PanelInfo *info)
-{
- int32_t ret;
- struct DevHandle *mipiHandle = NULL;
- struct MipiCfg cfg;
-
- mipiHandle = MipiDsiOpen(0);
- if (mipiHandle == NULL) {
- HDF_LOGE("%s: MipiDsiOpen failure", __func__);
- return HDF_FAILURE;
- }
- cfg.lane = info->mipi.lane;
- cfg.mode = info->mipi.mode;
- cfg.format = info->mipi.format;
- cfg.burstMode = info->mipi.burstMode;
- cfg.timing.xPixels = info->width;
- cfg.timing.hsaPixels = info->hsw;
- cfg.timing.hbpPixels = info->hbp;
- cfg.timing.hlinePixels = info->width + info->hbp + info->hfp + info->hsw;
- cfg.timing.vsaLines = info->vsw;
- cfg.timing.vbpLines = info->vbp;
- cfg.timing.vfpLines = info->vfp;
- cfg.timing.ylines = info->height;
- /* 0 : no care */
- cfg.timing.edpiCmdSize = 0;
- cfg.pixelClk = CalcPixelClk(info);
- cfg.phyDataRate = CalcDataRate(info);
- /* config mipi device */
- ret = MipiDsiSetCfg(mipiHandle, &cfg);
- if (ret != HDF_SUCCESS) {
- HDF_LOGE("%s:MipiDsiSetCfg failure", __func__);
- }
- MipiDsiClose(mipiHandle);
- HDF_LOGI("%s:pixelClk = %d, phyDataRate = %d\n", __func__,
- cfg.pixelClk, cfg.phyDataRate);
- return ret;
-}
-```
-
-The following example shows code for developing an LCD driver:
-
-```
-#define RESET_GPIO 5
-#define MIPI_DSI0 0
-#define BLK_PWM1 1
-#define PWM_MAX_PERIOD 100000
-/* backlight setting */
-#define MIN_LEVEL 0
-#define MAX_LEVEL 255
-#define DEFAULT_LEVEL 100
-
-#define WIDTH 480
-#define HEIGHT 960
-#define HORIZONTAL_BACK_PORCH 20
-#define HORIZONTAL_FRONT_PORCH 20
-#define HORIZONTAL_SYNC_WIDTH 10
-#define VERTIACL_BACK_PORCH 14
-#define VERTIACL_FRONT_PORCH 16
-#define VERTIACL_SYNC_WIDTH 2
-#define FRAME_RATE 60
-
-/* Panel information structure */
-struct PanelInfo {
- uint32_t width;
- uint32_t height;
- uint32_t hbp;
- uint32_t hfp;
- uint32_t hsw;
- uint32_t vbp;
- uint32_t vfp;
- uint32_t vsw;
- uint32_t frameRate;
- enum LcdIntfType intfType;
- enum IntfSync intfSync;
- struct MipiDsiDesc mipi;
- struct BlkDesc blk;
- struct PwmCfg pwm;
-};
-
-/* Initialization sequence of the LCD panel */
-static uint8_t g_payLoad0[] = { 0xF0, 0x5A, 0x5A };
-static uint8_t g_payLoad1[] = { 0xF1, 0xA5, 0xA5 };
-static uint8_t g_payLoad2[] = { 0xB3, 0x03, 0x03, 0x03, 0x07, 0x05, 0x0D, 0x0F, 0x11, 0x13, 0x09, 0x0B };
-static uint8_t g_payLoad3[] = { 0xB4, 0x03, 0x03, 0x03, 0x06, 0x04, 0x0C, 0x0E, 0x10, 0x12, 0x08, 0x0A };
-static uint8_t g_payLoad4[] = { 0xB0, 0x54, 0x32, 0x23, 0x45, 0x44, 0x44, 0x44, 0x44, 0x60, 0x00, 0x60, 0x1C };
-static uint8_t g_payLoad5[] = { 0xB1, 0x32, 0x84, 0x02, 0x87, 0x12, 0x00, 0x50, 0x1C };
-static uint8_t g_payLoad6[] = { 0xB2, 0x73, 0x09, 0x08 };
-static uint8_t g_payLoad7[] = { 0xB6, 0x5C, 0x5C, 0x05 };
-static uint8_t g_payLoad8[] = { 0xB8, 0x23, 0x41, 0x32, 0x30, 0x03 };
-static uint8_t g_payLoad9[] = { 0xBC, 0xD2, 0x0E, 0x63, 0x63, 0x5A, 0x32, 0x22, 0x14, 0x22, 0x03 };
-static uint8_t g_payLoad10[] = { 0xb7, 0x41 };
-static uint8_t g_payLoad11[] = { 0xC1, 0x0c, 0x10, 0x04, 0x0c, 0x10, 0x04 };
-static uint8_t g_payLoad12[] = { 0xC2, 0x10, 0xE0 };
-static uint8_t g_payLoad13[] = { 0xC3, 0x22, 0x11 };
-static uint8_t g_payLoad14[] = { 0xD0, 0x07, 0xFF };
-static uint8_t g_payLoad15[] = { 0xD2, 0x63, 0x0B, 0x08, 0x88 };
-static uint8_t g_payLoad16[] = { 0xC6, 0x08, 0x15, 0xFF, 0x10, 0x16, 0x80, 0x60 };
-static uint8_t g_payLoad17[] = { 0xc7, 0x04 };
-static uint8_t g_payLoad18[] = {
- 0xC8, 0x7C, 0x50, 0x3B, 0x2C, 0x25, 0x16, 0x1C, 0x08, 0x27, 0x2B, 0x2F, 0x52, 0x43, 0x4C, 0x40,
- 0x3D, 0x30, 0x1E, 0x06, 0x7C, 0x50, 0x3B, 0x2C, 0x25, 0x16, 0x1C, 0x08, 0x27, 0x2B, 0x2F, 0x52,
- 0x43, 0x4C, 0x40, 0x3D, 0x30, 0x1E, 0x06
-};
-static uint8_t g_payLoad19[] = { 0x11 };
-static uint8_t g_payLoad20[] = { 0x29 };
-
-struct DsiCmdDesc g_OnCmd[] = {
- { 0x29, 0, sizeof(g_payLoad0), g_payLoad0 },
- { 0x29, 0, sizeof(g_payLoad1), g_payLoad1 },
- { 0x29, 0, sizeof(g_payLoad2), g_payLoad2 },
- { 0x29, 0, sizeof(g_payLoad3), g_payLoad3 },
- { 0x29, 0, sizeof(g_payLoad4), g_payLoad4 },
- { 0x29, 0, sizeof(g_payLoad5), g_payLoad5 },
- { 0x29, 0, sizeof(g_payLoad6), g_payLoad6 },
- { 0x29, 0, sizeof(g_payLoad7), g_payLoad7 },
- { 0x29, 0, sizeof(g_payLoad8), g_payLoad8 },
- { 0x29, 0, sizeof(g_payLoad9), g_payLoad9 },
- { 0x23, 0, sizeof(g_payLoad10), g_payLoad10 },
- { 0x29, 0, sizeof(g_payLoad11), g_payLoad11 },
- { 0x29, 0, sizeof(g_payLoad12), g_payLoad12 },
- { 0x29, 0, sizeof(g_payLoad13), g_payLoad13 },
- { 0x29, 0, sizeof(g_payLoad14), g_payLoad14 },
- { 0x29, 0, sizeof(g_payLoad15), g_payLoad15 },
- { 0x29, 0, sizeof(g_payLoad16), g_payLoad16 },
- { 0x23, 0, sizeof(g_payLoad17), g_payLoad17 },
- { 0x29, 1, sizeof(g_payLoad18), g_payLoad18 },
- { 0x05, 120, sizeof(g_payLoad19), g_payLoad19 },
- { 0x05, 120, sizeof(g_payLoad20), g_payLoad20 },
-};
-static DevHandle g_mipiHandle = NULL;
-static DevHandle g_pwmHandle = NULL;
-
-/* Set the status of the reset pin. */
-static int32_t LcdResetOn(void)
-{
- int32_t ret;
- ret = GpioSetDir(RESET_GPIO, GPIO_DIR_OUT);
- if (ret != HDF_SUCCESS) {
- HDF_LOGE("GpioSetDir failure, ret:%d", ret);
- return HDF_FAILURE;
- }
- ret = GpioWrite(RESET_GPIO, GPIO_VAL_HIGH);
- if (ret != HDF_SUCCESS) {
- HDF_LOGE("GpioWrite failure, ret:%d", ret);
- return HDF_FAILURE;
- }
- /* delay 20ms */
- OsalMSleep(20);
- return HDF_SUCCESS;
-}
-
-static int32_t SampleInit(void)
-{
- /* Obtain the MIPI DSI device handle. */
- g_mipiHandle = MipiDsiOpen(MIPI_DSI0);
- if (g_mipiHandle == NULL) {
- HDF_LOGE("%s: MipiDsiOpen failure", __func__);
- return HDF_FAILURE;
- }
- return HDF_SUCCESS;
-}
-
-static int32_t SampleOn(void)
-{
- int32_t ret;
- /* Power on the LCD. */
- ret = LcdResetOn();
- if (ret != HDF_SUCCESS) {
- HDF_LOGE("%s: LcdResetOn failure", __func__);
- return HDF_FAILURE;
- }
- if (g_mipiHandle == NULL) {
- HDF_LOGE("%s: g_mipiHandle is null", __func__);
- return HDF_FAILURE;
- }
- /* Send the initialization sequence via MIPI. */
- int32_t count = sizeof(g_OnCmd) / sizeof(g_OnCmd[0]);
- int32_t i;
- for (i = 0; i < count; i++) {
- ret = MipiDsiTx(g_mipiHandle, &(g_OnCmd[i]));
- if (ret != HDF_SUCCESS) {
- HDF_LOGE("MipiDsiTx failure");
- return HDF_FAILURE;
- }
- }
- /* Set MIPI to the high speed (HS) mode. */
- MipiDsiSetHsMode(g_mipiHandle);
- return HDF_SUCCESS;
-}
-
-/* PanelInfo structure variables */
-static struct PanelInfo g_panelInfo = {
- .width = WIDTH, /* width */
- .height = HEIGHT, /* height */
- .hbp = HORIZONTAL_BACK_PORCH, /* horizontal back porch */
- .hfp = HORIZONTAL_FRONT_PORCH, /* horizontal front porch */
- .hsw = HORIZONTAL_SYNC_WIDTH, /* horizontal sync width */
- .vbp = VERTIACL_BACK_PORCH, /* vertiacl back porch */
- .vfp = VERTIACL_FRONT_PORCH, /* vertiacl front porch */
- .vsw = VERTIACL_SYNC_WIDTH, /* vertiacl sync width */
- .frameRate = FRAME_RATE, /* frame rate */
- .intfType = MIPI_DSI, /* panel interface type */
- .intfSync = OUTPUT_USER, /* output timming type */
- /* mipi config info */
- .mipi = { DSI_2_LANES, DSI_VIDEO_MODE, VIDEO_BURST_MODE, FORMAT_RGB_24_BIT },
- /* backlight config info */
- .blk = { BLK_PWM, MIN_LEVEL, MAX_LEVEL, DEFAULT_LEVEL },
- .pwm = { BLK_PWM1, PWM_MAX_PERIOD },
-};
-
-/* Basic APIs that need to be adapted for the chip driver */
-static struct PanelData g_panelData = {
- .info = &g_panelInfo,
- .init = SampleInit,
- .on = SampleOn,
- .off = SampleOff,
- .setBacklight = SampleSetBacklight,
-};
-
-/* Entry function of the chip driver */
-int32_t SampleEntryInit(struct HdfDeviceObject *object)
-{
- HDF_LOGI("%s: enter", __func__);
- if (object == NULL) {
- HDF_LOGE("%s: param is null!", __func__);
- return HDF_FAILURE;
- }
- /* Register the chip driver APIs with the platform driver. */
- if (PanelDataRegister(&g_panelData) != HDF_SUCCESS) {
- HDF_LOGE("%s: PanelDataRegister error!", __func__);
- return HDF_FAILURE;
- }
- return HDF_SUCCESS;
-}
-
-struct HdfDriverEntry g_sampleDevEntry = {
- .moduleVersion = 1,
- .moduleName = "LCD_SAMPLE",
- .Init = SampleEntryInit,
-};
-
-HDF_INIT(g_sampleDevEntry);
-```
-
diff --git a/en/device-dev/driver/lcddevelopment-guidelines.md b/en/device-dev/driver/lcddevelopment-guidelines.md
deleted file mode 100644
index a7d0f9cb7453fe32c2c9448eba76bd2cac09ec45..0000000000000000000000000000000000000000
--- a/en/device-dev/driver/lcddevelopment-guidelines.md
+++ /dev/null
@@ -1,23 +0,0 @@
-# LCD Development Guidelines
-
-- [How to Develop](#section3904154911218)
-
-The display driver model is developed based on the HDF, platform APIs, and APIs at the OS abstraction layer \(OSAL\), and provides a unified driver model for the LCD regardless of the OS \(LiteOS or Linux OS\) and chip platforms \(such as Hi35xx, Hi38xx, and V3S\).
-
-## How to Develop
-
-1. Add the LCD driver-related hardware descriptions.
-2. Add a driver that adapts to the chip at the SoC adapter layer.
-3. Add the LCD panel driver and register the panel driver functions in the driver entry function **Init**. The functions provide capabilities for:
- - Powering on/off the LCD device
-
- Based on the LCD hardware connection, use the GPIO interfaces provided by the platform to perform operations on the LCD pins, such as the reset pin and IOVCC pin. For details about the power-on sequence, see the SPEC provided by the LCD supplier.
-
- - Sending the initialization sequence
-
- Based on the LCD hardware interfaces, use the I2C, SPI, and MIPI interfaces provided by the platform to download the LCD initialization sequence. For details, see the SPEC provided by the LCD supplier.
-
-
-4. Implement other HDF interfaces as required, for example, the **Release** interface.
-5. Use the HDF to create other device nodes for implementing service logic or debugging as required.
-
diff --git a/en/device-dev/driver/lcdoverview.md b/en/device-dev/driver/lcdoverview.md
deleted file mode 100644
index 08ba05e1f409a702a3b4334ce7124a4e80f5af57..0000000000000000000000000000000000000000
--- a/en/device-dev/driver/lcdoverview.md
+++ /dev/null
@@ -1,46 +0,0 @@
-# LCD Overview
-
-- [Introduction](#section3781515122118)
-- [API Description](#section20280192712120)
-
-## Introduction
-
-The Liquid Crystal Display \(LCD\) driver powers on the LCD and initializes internal LCD registers APIs to enable the LCD to work properly. The display driver is developed based on the hardware driver foundation \([HDF](hdfoverview.md)\). It provides power-on, power-off, and sending of the initialization sequence for LCD hardware across OSs and platforms. The display driver model is shown in [Figure 1](#fig69138814229).
-
-**Figure 1** Architecture of the display driver model
-
-
-- **Display driver model**
-
- The display driver model consists of the display common driver layer, SoC adapter layer, and third-party chip driver layer. It is developed based on the HDF and hides the differences between kernel forms through platform and OSAL APIs so the LCD driver can be migrated to different OSs and chip platforms. The display driver connects to the display common HAL, supports the implementation of Hardware Driver Interfaces \(HDIs\), and provides various driver interfaces for the graphics service through the display HDI.
-
- - Display common driver layer: connects to the display common HAL through the IOService data channel provided by the HDF to receive and process various upper-layer calls in a centralized manner.
-
- - SoC adapter layer: decouples the display driver from the SoC driver, configures parameters related to the chip platform, and passes the calls at the platform driver layer to the LCD driver layer.
-
- - Third-party chip driver layer: provides LCD-related APIs for sending the LCD initialization sequence, powering on or off the LCD device, and setting the backlight.
-
- Based on the display driver model, various capabilities, and APIs, you can greatly simplify the display driver development and improve the efficiency.
-
-
-## API Description
-
-The LCD interfaces are classified into the Mobile Industry Processor Interface \(MIPI\) Display Serial Interface \(DSI\), Transistor Transistor Logic \(TTL\) interfaces, and Low Voltage Differential Signaling \(LVDS\) interfaces. The MIPI DSI and TTL interfaces are commonly used. Here is a brief introduction to them.
-
-- MIPI DSI
-
- **Figure 2** MIPI DSI
- 
-
- The MIPI DSI is defined by MIPI Alliance. It is mainly used for mobile terminal display. The MIPI DSI is used to transmit image data, in compliance with the MIPI protocol. Generally, control information of the MIPI DSI is sent to the peer IC in the form of MIPI packets through the MIPI DSI. No additional interface is required.
-
-- TTL interface
-
- **Figure 3** TTL interface
- 
-
- TTL level signals are generated by TTL devices, which are a major type of digital integrated circuits. They are manufactured using the bipolar process and feature high speed, low power consumption, and multiple types.
-
- The TTL interface is used to transmit data in parallel mode. It transmits data signals, clock signals, and control signals \(such as line synchronization signals, frame synchronization signals, and data validity signals\) under the control of control signals. Generally, the LCD of the TTL interface and the read/write of internal registers require additional peripheral interfaces, such as the Serial Peripheral Interface \(SPI\) and Inter-Integrated Circuit \(I2C\).
-
-
diff --git a/en/device-dev/driver/mipi-dsi-overview.md b/en/device-dev/driver/mipi-dsi-overview.md
deleted file mode 100644
index ec579fba093ecad64f31fd5d00b429878829a652..0000000000000000000000000000000000000000
--- a/en/device-dev/driver/mipi-dsi-overview.md
+++ /dev/null
@@ -1,84 +0,0 @@
-# MIPI DSI Overview
-
-- [Introduction](#section1369320102013)
-- [Available APIs](#section6577545192317)
-
-## Introduction
-
-- The Display Serial Interface \(DSI\) is a specification stipulated by the Mobile Industry Processor Interface \(MIPI\) Alliance, aiming to reduce the cost of display controllers in a mobile device. It defines a serial bus and communication protocol among the host, the source of image data, and the target device. In this way, the DSI can send pixel data or commands to peripherals \(usually LCDs or similar display devices\) in serial mode, or reads information such as status and pixel from the peripherals.
-
-- MIPI DSI is capable of working in both high speed \(HS\) mode and low power \(LP\) mode. All data lanes can only travel from the DSI host to a peripheral in HS mode, except the first data lane, which can also receive data such as status information and pixels from the peripheral in LP mode. The clock lane is dedicated to transmitting synchronization clock signals in HS mode.
- - [Figure 1](#fig1122611461203) shows a simplified DSI interface. Conceptually, a DSI-compliant interface has the same features as interfaces complying with DBI-2 and DPI-2 standards. It sends pixels or commands to a peripheral and can read status or pixel information from the peripheral. The main difference is that the DSI serializes all pixel data, commands, and events that, in traditional interfaces, are conveyed to and from the peripheral on a parallel data bus with additional control signals.
-
- **Figure 1** DSI transmitting and receiving Interface
- 
-
-
-
-## Available APIs
-
-**Table 1** APIs for MIPI DSI
-
-
-
Sets configuration parameters for a MIPI DSI device.
-
-
-
MipiDsiGetCfg
-
-
Obtains the configuration parameters of a MIPI DSI device.
-
-
-
Obtaining /Releasing device handles
-
-
MipiDsiOpen
-
-
Obtains a MIPI DSI device handle.
-
-
-
MipiDsiClose
-
-
Releases a specified MIPI DSI device handle.
-
-
-
Setting the LP or HS mode
-
-
MipiDsiSetLpMode
-
-
Sets LP mode for a MIPI DSI device.
-
-
-
MipiDsiSetHsMode
-
-
Sets HS mode for a MIPI DSI device.
-
-
-
Reading/Sending commands
-
-
MipiDsiTx
-
-
Sends a display command set (DCS) command for sending data.
-
-
-
MipiDsiRx
-
-
Receives a DCS command for reading data with the specified length.
-
-
-
-
-
-> **NOTE:**
->All functions described in this document can be called only in kernel space.
-
diff --git a/en/device-dev/driver/mipi-dsi.md b/en/device-dev/driver/mipi-dsi.md
deleted file mode 100644
index f50672962f5c2602a93f63821ac290de3271ad02..0000000000000000000000000000000000000000
--- a/en/device-dev/driver/mipi-dsi.md
+++ /dev/null
@@ -1,9 +0,0 @@
-# MIPI DSI
-
-- **[MIPI DSI Overview](mipi-dsi-overview.md)**
-
-- **[Usage Guidelines](usage-guidelines.md)**
-
-- **[Usage Example](usage-example.md)**
-
-
diff --git a/en/device-dev/driver/peripherals.md b/en/device-dev/driver/peripherals.md
deleted file mode 100644
index 42016f572c98cb63bfd17d6994f67367f3c8bc5d..0000000000000000000000000000000000000000
--- a/en/device-dev/driver/peripherals.md
+++ /dev/null
@@ -1,11 +0,0 @@
-# Peripherals
-
-- **[LCD](lcd.md)**
-
-- **[TOUCHSCREEN](touchscreen.md)**
-
-- **[SENSOR](sensor.md)**
-
-- **[WLAN](wlan.md)**
-
-
diff --git a/en/device-dev/driver/public_sys-resources/icon-caution.gif b/en/device-dev/driver/public_sys-resources/icon-caution.gif
deleted file mode 100644
index 6e90d7cfc2193e39e10bb58c38d01a23f045d571..0000000000000000000000000000000000000000
Binary files a/en/device-dev/driver/public_sys-resources/icon-caution.gif and /dev/null differ
diff --git a/en/device-dev/driver/public_sys-resources/icon-danger.gif b/en/device-dev/driver/public_sys-resources/icon-danger.gif
deleted file mode 100644
index 6e90d7cfc2193e39e10bb58c38d01a23f045d571..0000000000000000000000000000000000000000
Binary files a/en/device-dev/driver/public_sys-resources/icon-danger.gif and /dev/null differ
diff --git a/en/device-dev/driver/public_sys-resources/icon-note.gif b/en/device-dev/driver/public_sys-resources/icon-note.gif
deleted file mode 100644
index 6314297e45c1de184204098efd4814d6dc8b1cda..0000000000000000000000000000000000000000
Binary files a/en/device-dev/driver/public_sys-resources/icon-note.gif and /dev/null differ
diff --git a/en/device-dev/driver/public_sys-resources/icon-notice.gif b/en/device-dev/driver/public_sys-resources/icon-notice.gif
deleted file mode 100644
index 86024f61b691400bea99e5b1f506d9d9aef36e27..0000000000000000000000000000000000000000
Binary files a/en/device-dev/driver/public_sys-resources/icon-notice.gif and /dev/null differ
diff --git a/en/device-dev/driver/public_sys-resources/icon-tip.gif b/en/device-dev/driver/public_sys-resources/icon-tip.gif
deleted file mode 100644
index 93aa72053b510e456b149f36a0972703ea9999b7..0000000000000000000000000000000000000000
Binary files a/en/device-dev/driver/public_sys-resources/icon-tip.gif and /dev/null differ
diff --git a/en/device-dev/driver/public_sys-resources/icon-warning.gif b/en/device-dev/driver/public_sys-resources/icon-warning.gif
deleted file mode 100644
index 6e90d7cfc2193e39e10bb58c38d01a23f045d571..0000000000000000000000000000000000000000
Binary files a/en/device-dev/driver/public_sys-resources/icon-warning.gif and /dev/null differ
diff --git a/en/device-dev/driver/rtc-overview.md b/en/device-dev/driver/rtc-overview.md
deleted file mode 100644
index 97aa8a24369a26fed6689751accb5ab46ce7fa89..0000000000000000000000000000000000000000
--- a/en/device-dev/driver/rtc-overview.md
+++ /dev/null
@@ -1,103 +0,0 @@
-# RTC Overview
-
-- [Introduction](#section104842041574)
-- [Available APIs](#section16892932155715)
-
-## Introduction
-
-The real-time clock \(RTC\) driver provides precise real time for the operating system \(OS\). If the OS is powered off, the RTC driver continues to keep track of the system time using an external battery.
-
-## Available APIs
-
-**Table 1** APIs provided by the RTC driver
-
-
-
Capability
-
-
Function
-
-
Description
-
-
-
-
RTC handle
-
-
RtcOpen
-
-
Opens the RTC device to obtain its handle.
-
-
-
RtcClose
-
-
Releases a specified handle of the RTC device.
-
-
-
RTC time
-
-
RtcReadTime
-
-
Reads time information from the RTC driver, including the year, month, the day of the week, day, hour, minute, second, and millisecond.
-
-
-
RtcWriteTime
-
-
Writes time information from the RTC driver, including the year, month, the day of the week, day, hour, minute, second, and millisecond.
-
-
-
RTC alarm
-
-
RtcReadAlarm
-
-
Reads the RTC alarm time that was set last time.
-
-
-
RtcWriteAlarm
-
-
Writes the RTC alarm time based on the alarm index.
-
-
-
RtcRegisterAlarmCallback
-
-
Registers RtcAlarmCallback that will be invoked when an alarm is generated at the specified time.
-
-
-
RtcAlarmInterruptEnable
-
-
Enables or disables RTC alarm interrupts.
-
-
-
RTC configuration
-
-
RtcGetFreq
-
-
Reads the frequency of the external crystal oscillator connected to the RTC driver.
-
-
-
RtcSetFreq
-
-
Sets the frequency of the external crystal oscillator connected to the RTC driver.
-
-
-
RtcReset
-
-
Resets the RTC.
-
-
-
Custom register
-
-
RtcReadReg
-
-
Reads the configuration of a custom RTC register based on the register index.
-
-
-
RtcWriteReg
-
-
Writes the configuration of a custom RTC register based on the register index.
-
-
-
-
-
-> **NOTE:**
->All functions provided in this document can be called only in kernel mode.
-
diff --git a/en/device-dev/driver/rtc-usage-example.md b/en/device-dev/driver/rtc-usage-example.md
deleted file mode 100644
index e546c2f1433a2ce6810b93b43fd26f4c17f8e5a7..0000000000000000000000000000000000000000
--- a/en/device-dev/driver/rtc-usage-example.md
+++ /dev/null
@@ -1,97 +0,0 @@
-# RTC Usage Example
-
-This section describes the process of using RTC APIs:
-
-1. During the OS startup, the HDF identifies the RTC component in the system.
-2. The HDF initializes and creates the RTC device.
-3. You can perform operations on the RTC device by calling different APIs.
-4. Call the **RtcClose** function to release the device handle and device resources.
-
-Example:
-
-```
-#include "rtc_if.h"
-int32_t RtcAlarmACallback(enum RtcAlarmIndex alarmIndex)
-{
- if (alarmIndex == RTC_ALARM_INDEX_A) {
- /* Process alarm A. */
- printf("RTC Alarm A callback function\n\r");
- } else if (alarmIndex == RTC_ALARM_INDEX_B) {
- /* Process alarm B. */
- printf("RTC Alarm B callback function\n\r");
- } else {
- /* Process the error. */
- }
- return 0;
-}
-
-void RtcTestSample(void)
-{
- int32_t ret;
- struct RtcTime tm;
- struct RtcTime alarmTime;
- uint32_t freq;
- DevHandle handle = NULL;
-
- /* Obtain the RTC device handle. */
- handle = RtcOpen();
- if (handle == NULL) {
- /* Process the error. */
- }
- /* Register RtcAlarmCallback for alarm A. */
- ret = RtcRegisterAlarmCallback(handle, RTC_ALARM_INDEX_A, RtcAlarmACallback);
- if (ret != 0) {
- /* Process the error. */
- }
- /* Set the RTC external crystal frequency. Note that the frequency must be configured in accordance with the requirements specified in the product manual of the in-use component. */
- freq = 32768; /* 32768 Hz */
- ret = RtcSetFreq(handle, freq);
- if (ret != 0) {
- /* Process the error. */
- }
- /* Enable the RTC alarm interrupts. */
- ret = RtcAlarmInterruptEnable(handle, RTC_ALARM_INDEX_A, 1);
- if (ret != 0) {
- /* Process the error. */
- }
- /* Set the RTC time to 2020/01/01 00:00:10 .990. */
- tm.year = 2020;
- tm.month = 01;
- tm.day = 01;
- tm.hour= 0;
- tm.minute = 0;
- tm.second = 10;
- tm.millisecond = 990;
- /* Write the RTC time information. */
- ret = RtcWriteTime(handle, &tm);
- if (ret != 0) {
- /* Process the error. */
- }
- /* Set the RTC alarm time to 2020/01/01 00:00:30 .100. */
- alarmTime.year = 2020;
- alarmTime.month = 01;
- alarmTime.day = 01;
- alarmTime.hour = 0;
- alarmTime.minute = 0;
- alarmTime.second = 30;
- alarmTime.millisecond = 100;
- /* Set the alarm time information for RTC_ALARM_INDEX_A. When the specified time is reached, "RTC Alarm A callback function" is printed. */
- ret = RtcWriteAlarm(handle, RTC_ALARM_INDEX_A, &alarmTime);
- if (ret != 0) {
- /* Process the error. */
- }
-
- /* Read the RTC real time. */
- ret = RtcReadTime(handle, &tm);
- if (ret != 0) {
- /* Process the error. */
- }
- sleep(5)
- printf("RTC read time:\n\r");
- printf("year-month-date-weekday hour:minute:second .millisecond %04u-%02u-%02u-%u %02u:%02u:%02u .%03u",
- tm.year, tm.month, tm.day, tm.weekday, tm.hour, tm.minute, tm.second, tm.millisecond);
- /* Release the RTC device handle. */
- RtcClose(handle);
-}
-```
-
diff --git a/en/device-dev/driver/rtc-usage-guidelines.md b/en/device-dev/driver/rtc-usage-guidelines.md
deleted file mode 100644
index 3d0a2f6638021e4ab54ec680a06b134a873685b8..0000000000000000000000000000000000000000
--- a/en/device-dev/driver/rtc-usage-guidelines.md
+++ /dev/null
@@ -1,741 +0,0 @@
-# RTC Usage Guidelines
-
-- [How to Use](#section620515765714)
-- [Creating an RTC Device Handle](#section0702183665711)
-- [Releasing the RTC Device Handle](#section639962619542)
-- [Registering RtcAlarmCallback](#section123631358135713)
-- [Performing RTC-related Operations](#section11091522125812)
-
-## How to Use
-
-During the OS startup, the HDF loads the RTC driver based on the configuration file. The RTC driver detects the RTC component and initializes the driver.
-
-[Figure 1](#fig166181128151112) illustrates the process of an RTC device.
-
-**Figure 1** Process of using an RTC device
-
-
-
-
-## Creating an RTC Device Handle
-
-After the RTC driver is loaded successfully, you can use the API provided by the HDF and call APIs of the RTC driver.
-
-> **NOTE:**
->Currently, only one RTC device is supported in the OS.
-
-DevHandle RtcOpen\(void\);
-
-**Table 1** Description of **RtcOpen**
-
-
-
Parameter
-
-
Description
-
-
-
void
-
-
N/A
-
-
-
Return Value
-
-
Description
-
-
-
handle
-
-
Returns the pointer if the operation is successful.
-
-
-
NULL
-
-
The operation fails.
-
-
-
-
-
-```
-DevHandle handle = NULL;
-
-/* Obtain the RTC device handle. */
-handle = RtcOpen();
-if (handle == NULL) {
- /* Process the error. */
-}
-```
-
-## Releasing the RTC Device Handle
-
-You can call the following function to release the RTC device handle, thereby releasing resources of the device:
-
-void RtcClose\(DevHandle handle\);
-
-**Table 2** Description of **RtcClose**
-
-
-
Parameter
-
-
Description
-
-
-
handle
-
-
Pointer to the RTC device handle
-
-
-
-
-
-```
-/* Release the RTC device handle. */
-RtcClose(handle);
-```
-
-## Registering RtcAlarmCallback
-
-After the OS is started, call the following function to register **RtcAlarmCallback**, which will be invoked when an alarm is generated at the specified time:
-
-int32\_t RtcRegisterAlarmCallback\(DevHandle handle, enum RtcAlarmIndex alarmIndex, RtcAlarmCallback cb\);
-
-**Table 3** Description of **RtcRegisterAlarmCallback**
-
-
-
Parameter
-
-
Description
-
-
-
-
handle
-
-
Pointer to the RTC device handle.
-
-
-
alarmIndex
-
-
Alarm index.
-
-
-
cb
-
-
Callback that will be invoked when an alarm is generated at the specified time.
-
-
-
Return Value
-
-
Description
-
-
-
0
-
-
The operation is successful.
-
-
-
Negative value
-
-
The operation fails.
-
-
-
-
-
-The following is an example of registering **RtcAlarmCallback** for processing alarm **RTC\_ALARM\_INDEX\_A**:
-
-```
-/* Register an RTC alarm callback. */
-int32_t RtcAlarmACallback(enum RtcAlarmIndex alarmIndex)
-{
- if (alarmIndex == RTC_ALARM_INDEX_A) {
- /* Process alarm A. */
- } else if (alarmIndex == RTC_ALARM_INDEX_B) {
- /* Process alarm B. */
- } else {
- /* Process the error. */
- }
- return 0;
-}
-int32_t ret;
-/* Register RtcAlarmCallback for alarm A. */
-ret = RtcRegisterAlarmCallback(handle, RTC_ALARM_INDEX_A, RtcAlarmACallback);
-if (ret != 0) {
- /* Process the error. */
-}
-```
-
-## Performing RTC-related Operations
-
-- Reading RTC time
-
-Call the following function to read time information from the RTC driver, including the year, month, the day fo the week, day, hour, minute, second, and millisecond:
-
-int32\_t RtcReadTime\(DevHandle handle, struct RtcTime \*time\);
-
-**Table 4** Description of **RtcReadTime**
-
-
-
Parameter
-
-
Description
-
-
-
handle
-
-
Pointer to the RTC device handle.
-
-
-
time
-
-
Pointer to the time information read from the RTC driver. The time information includes the year, month, the day of the week, day, hour, minute, second, and millisecond.
-
-
-
Return Value
-
-
Description
-
-
-
0
-
-
The operation is successful.
-
-
-
Negative value
-
-
The operation fails.
-
-
-
-
-
-```
-int32_t ret;
-struct RtcTime tm;
-
-/* Read time information from the RTC driver. */
-ret = RtcReadTime(handle, &tm);
-if (ret != 0) {
- /* Process the error. */
-}
-```
-
-- Setting RTC time
-
-Call the following function to set the RTC time:
-
-int32\_t RtcWriteTime\(DevHandle handle, struct RtcTime \*time\);
-
-**Table 5** Description of **RtcWriteTime**
-
-
-
Parameter
-
-
Description
-
-
-
handle
-
-
Pointer to the RTC device handle.
-
-
-
time
-
-
Pointer to the time information written into the RTC driver. The time information includes the year, month, the day of the week, day, hour, minute, second, and millisecond.
-
-
-
Return Value
-
-
Description
-
-
-
0
-
-
The operation is successful.
-
-
-
Negative value
-
-
The operation fails.
-
-
-
-
-
-> **NOTE:**
->The RTC start time is 1970/01/01 Thursday 00:00:00 \(UTC\). The maximum value of **year** must be set based on the requirements specified in the product manual of the in-use component. You do not need to configure the day of the week.
-
-```
-int32_t ret;
-struct RtcTime tm;
-
-/* Set the RTC time to UTC 2020/01/01 00:59:00 .000. */
-tm.year = 2020;
-tm.month = 01;
-tm.day = 01;
-tm.hour= 00;
-tm.minute = 59;
-tm.second = 00;
-tm.millisecond = 0;
-/* Write the RTC time information. */
-ret = RtcWriteTime(handle, &tm);
-if (ret != 0) {
- /* Process the error. */
-}
-```
-
-- Reading the RTC alarm time
-
-Call the following function to read the alarm time:
-
-int32\_t RtcReadAlarm\(DevHandle handle, enum RtcAlarmIndex alarmIndex, struct RtcTime \*time\);
-
-**Table 6** Description of **RtcReadAlarm**
-
-
-
Parameter
-
-
Description
-
-
-
handle
-
-
Pointer to the RTC device handle.
-
-
-
alarmIndex
-
-
Alarm index.
-
-
-
time
-
-
Pointer to the RTC alarm time information. The time information includes the year, month, the day of the week, day, hour, minute, second, and millisecond.
-
-
-
Return Value
-
-
Description
-
-
-
0
-
-
The operation is successful.
-
-
-
Negative value
-
-
The operation fails.
-
-
-
-
-
-```
-int32_t ret;
-struct RtcTime alarmTime;
-
-/* Read the RTC alarm time information of alarm RTC_ALARM_INDEX_A. */
-ret = RtcReadAlarm(handle, RTC_ALARM_INDEX_A, &alarmTime);
-if (ret != 0) {
- /* Process the error. */
-}
-```
-
-- Setting RTC alarm time
-
-Call the following function to set the RTC alarm time based on the alarm index:
-
-int32\_t RtcWriteAlarm\(DevHandle handle, enum RtcAlarmIndex alarmIndex, struct RtcTime \*time\);
-
-**Table 7** Description of **RtcWriteAlarm**
-
-
-
Parameter
-
-
Description
-
-
-
handle
-
-
Pointer to the RTC device handle.
-
-
-
alarmIndex
-
-
Alarm index.
-
-
-
time
-
-
Pointer to the RTC alarm time information. The time information includes the year, month, the day of the week, day, hour, minute, second, and millisecond.
-
-
-
Return Value
-
-
Description
-
-
-
0
-
-
The operation is successful.
-
-
-
Negative value
-
-
The operation fails.
-
-
-
-
-
-> **NOTE:**
->The RTC start time is 1970/01/01 Thursday 00:00:00 \(UTC\). The maximum value of **year** must be set based on the requirements specified in the product manual of the in-use component. You do not need to configure the day of the week.
-
-```
-int32_t ret;
-struct RtcTime alarmTime;
-
-/* Set the RTC alarm time to 2020/01/01 00:59:59 .000. */
-alarmTime.year = 2020;
-alarmTime.month = 01;
-alarmTime.day = 01;
-alarmTime.hour = 00;
-alarmTime.minute = 59;
-alarmTime.second = 59;
-alarmTime.millisecond = 0;
-/* Set the alarm time of alarm RTC_ALARM_INDEX_A. */
-ret = RtcWriteAlarm(handle, RTC_ALARM_INDEX_A, &alarmTime);
-if (ret != 0) {
- /* Process the error. */
-}
-```
-
-- Enabling or disabling alarm interrupts
-
-Before performing alarm operations, use this function to enable alarm interrupts, so that **RtcAlarmCallback** will be called when the alarm is not generated upon a timeout.
-
-int32\_t RtcAlarmInterruptEnable\(DevHandle handle, enum RtcAlarmIndex alarmIndex, uint8\_t enable\);
-
-**Table 8** Description of **RtcAlarmInterruptEnable**
-
-
-
Parameter
-
-
Description
-
-
-
handle
-
-
Pointer to the RTC device handle.
-
-
-
alarmIndex
-
-
Alarm index.
-
-
-
enable
-
-
Whether to enable RTC alarm interrupts. Value 1 means to enable alarm interrupts and value 0 means to disable alarm interrupts.
-
-
-
Return Value
-
-
Description
-
-
-
0
-
-
The operation is successful.
-
-
-
Negative value
-
-
The operation fails.
-
-
-
-
-
-```
-int32_t ret;
-
-/* Enable the RTC alarm interrupts. */
-ret = RtcAlarmInterruptEnable(handle, RTC_ALARM_INDEX_A, 1);
-if (ret != 0) {
- /* Process the error. */
-}
-```
-
-- Reading RTC external frequency
-
-Call the following function to read the frequency of the external crystal oscillator connected to the RTC driver:
-
-int32\_t RtcGetFreq\(DevHandle handle, uint32\_t \*freq\);
-
-**Table 9** Description of **RtcGetFreq**
-
-
-
Parameter
-
-
Description
-
-
-
handle
-
-
Pointer to the RTC device handle.
-
-
-
freq
-
-
Frequency to set for the external crystal oscillator, in Hz.
-
-
-
Return Value
-
-
Description
-
-
-
0
-
-
The operation is successful.
-
-
-
Negative value
-
-
The operation fails.
-
-
-
-
-
-```
-int32_t ret;
-uint32_t freq = 0;
-
-/* Read frequency of the external crystal oscillator connected to the RTC driver */
-ret = RtcGetFreq(handle, &freq);
-if (ret != 0) {
- /* Process the error. */
-}
-```
-
-- Setting the frequency of the external crystal oscillator connected to the RTC driver
-
-Call the following function to set the frequency of the external crystal oscillator connected to the RTC driver:
-
-int32\_t RtcSetFreq\(DevHandle handle, uint32\_t freq\);
-
-**Table 10** Description of **RtcSetFreq**
-
-
-
Parameter
-
-
Description
-
-
-
handle
-
-
Pointer to the RTC device handle.
-
-
-
freq
-
-
Frequency to set for the external crystal oscillator, in Hz.
-
-
-
Return Value
-
-
Description
-
-
-
0
-
-
The operation is successful.
-
-
-
Negative value
-
-
The operation fails.
-
-
-
-
-
-```
-int32_t ret;
-uint32_t freq = 32768; /* 32768 Hz */
-
-/* Set the frequency of the external crystal oscillator. Note that the frequency must be configured in accordance with the requirements specified in the product manual of the in-use component. */
-ret = RtcSetFreq(handle, freq);
-if (ret != 0) {
- /* Process the error. */
-}
-```
-
-- Resetting the RTC driver
-
-Call the following function to perform a reset on the RTC driver. After the reset, the registers are restored to the default values:
-
-int32\_t RtcReset\(DevHandle handle\);
-
-**Table 11** Description of **RtcReset**
-
-
-
Parameter
-
-
Description
-
-
-
handle
-
-
Pointer to the RTC device handle.
-
-
-
Return Value
-
-
Description
-
-
-
0
-
-
The operation is successful.
-
-
-
Negative value
-
-
The operation fails.
-
-
-
-
-
-```
-int32_t ret;
-
-/* Reset the RTC driver. After the reset, the configuration registers are restored to the default values. */
-ret = RtcReset(handle);
-if (ret != 0) {
- /* Process the error. */
-}
-```
-
-- Reading the configuration of a custom RTC register
-
-Call the following function to read the configuration of a custom RTC register based on the register index \(one index corresponds to one byte of the configuration value\):
-
-int32\_t RtcReadReg\(DevHandle handle, uint8\_t usrDefIndex, uint8\_t \*value\);
-
-**Table 12** Description of **RtcReadReg**
-
-
-
Parameter
-
-
Description
-
-
-
handle
-
-
Pointer to the RTC device handle.
-
-
-
usrDefIndex
-
-
Index of the custom register.
-
-
-
value
-
-
Register value.
-
-
-
Return Value
-
-
Description
-
-
-
0
-
-
The operation is successful.
-
-
-
Negative value
-
-
The operation fails.
-
-
-
-
-
-```
-int32_t ret;
-uint8_t usrDefIndex = 0; /* Define index 0 for the first custom register. */
-uint8_t value = 0;
-
-/* Read the configuration of a custom RTC register based on the register index. One index corresponds to one byte of the configuration value. */
-ret = RtcReadReg(handle, usrDefIndex, &value);
-if (ret != 0) {
- /* Process the error. */
-}
-```
-
-- Setting the configuration of a custom RTC register
-
-Call the following function to configure a register based on the specified register index \(one index corresponds to one byte of the configuration value\):
-
-int32\_t RtcWriteReg\(DevHandle handle, uint8\_t usrDefIndex, uint8\_t value\);
-
-**Table 13** Description of **RtcWriteReg**
-
-
-
Parameter
-
-
Description
-
-
-
handle
-
-
Pointer to the RTC device handle.
-
-
-
usrDefIndex
-
-
Index of the custom register.
-
-
-
value
-
-
Register value.
-
-
-
Return Value
-
-
Description
-
-
-
0
-
-
The operation is successful.
-
-
-
Negative value
-
-
The operation fails.
-
-
-
-
-
-```
-int32_t ret;
-uint8_t usrDefIndex = 0; /* Define index 0 for the first custom register. */
-uint8_t value = 0x10;
-
-/* Configure a register based on the specified register index. One index corresponds to one byte of the configuration value. */
-ret = RtcWriteReg(handle, usrDefIndex, value);
-if (ret != 0) {
- /* Process the error. */
-}
-```
-
diff --git a/en/device-dev/driver/rtc.md b/en/device-dev/driver/rtc.md
deleted file mode 100644
index 50b89f7b7c1fb24aeac3e2922dce7da627864006..0000000000000000000000000000000000000000
--- a/en/device-dev/driver/rtc.md
+++ /dev/null
@@ -1,9 +0,0 @@
-# RTC
-
-- **[RTC Overview](rtc-overview.md)**
-
-- **[RTC Usage Guidelines](rtc-usage-guidelines.md)**
-
-- **[RTC Usage Example](rtc-usage-example.md)**
-
-
diff --git a/en/device-dev/driver/sdio.md b/en/device-dev/driver/sdio.md
deleted file mode 100644
index 43fb762051920268c93821121065cd4ebec24ecb..0000000000000000000000000000000000000000
--- a/en/device-dev/driver/sdio.md
+++ /dev/null
@@ -1,9 +0,0 @@
-# SDIO
-
-- **[SDIO Overview](sdiooverview.md)**
-
-- **[SDIO Usage Guidelines](sdiousage-guidelines.md)**
-
-- **[SDIO Usage Example](sdiousage-example.md)**
-
-
diff --git a/en/device-dev/driver/sdiooverview.md b/en/device-dev/driver/sdiooverview.md
deleted file mode 100644
index 9890cf8f3c60999f90d41db98e8143600066308b..0000000000000000000000000000000000000000
--- a/en/device-dev/driver/sdiooverview.md
+++ /dev/null
@@ -1,149 +0,0 @@
-# SDIO Overview
-
-- [Introduction](#section1155271783811)
-- [Available APIs](#section10204143763819)
-
-## Introduction
-
-- Secure Digital Input/Output \(SDIO\) is a peripheral interface evolved from the Secure Digital \(SD\) memory card interface. The SDIO interface is compatible with SD memory cards and can be connected to devices that support the SDIO interface.
-- SDIO is widely used. Currently, many smartphones support SDIO, and many SDIO peripherals are developed for connections to smartphones. Common SDIO peripherals include WLAN, GPS, cameras, and Bluetooth.
-- The SDIO bus has two ends, named host and device. All communication starts when the host sends a command. The device can communicate with the host as long as it can parse the command of the host. An SDIO host can connect to multiple devices, as shown in the figure below.
-
- - CLK signal: clock signal sent from the host to the device
- - VDD signal: power signal
- - VSS signal: ground signal
- - D0-3 signal: four data lines. The DAT1 signal cable is multiplexed as the interrupt line. In 1-bit mode, DAT0 is used to transmit data. In 4-bit mode, DAT0 to DAT3 are used to transmit data.
- - CMD signal: used by the host to send commands and the device to respond to commands.
-
- **Figure 1** Connections between the host and devices in SDIO
-
-
- 
-
-- The SDIO interface defines a set of common methods for operating an SDIO device, including opening and closing an SDIO controller, exclusively claiming and releasing the host, enabling and disabling devices, claiming and releasing an SDIO IRQ, reading and writing data based on SDIO, and obtaining and setting common information.
-
-## Available APIs
-
-**Table 1** APIs available for the SDIO driver
-
-
-
Capability
-
-
Function
-
-
Description
-
-
-
-
SDIO device opening/closing
-
-
SdioOpen
-
-
Opens an SDIO controller with a specified bus number.
-
-
-
SdioClose
-
-
Closes an SDIO controller.
-
-
-
SDIO reading/writing
-
-
SdioReadBytes
-
-
Incrementally reads a given length of data from a specified SDIO address.
-
-
-
SdioWriteBytes
-
-
Incrementally writes a given length of data into a specified SDIO address.
-
-
-
SdioReadBytesFromFixedAddr
-
-
Reads a given length of data from a fixed SDIO address.
-
-
-
SdioWriteBytesToFixedAddr
-
-
Writes a given length of data into a fixed SDIO address.
-
-
-
SdioReadBytesFromFunc0
-
-
Reads a given length of data from the address space of SDIO function 0.
-
-
-
SdioWriteBytesToFunc0
-
-
Writes a given length of data into the address space of SDIO function 0.
-
-
-
SDIO block size setting
-
-
SdioSetBlockSize
-
-
Sets the block size.
-
-
-
SDIO common information retrieval/setting
-
-
SdioGetCommonInfo
-
-
Obtains common information.
-
-
-
SdioSetCommonInfo
-
-
Sets common information.
-
-
-
SDIO data flushing
-
-
SdioFlushData
-
-
Flushes data.
-
-
-
SDIO host exclusively claiming or releasing
-
-
SdioClaimHost
-
-
Claims a host exclusively.
-
-
-
SdioReleaseHost
-
-
Releases the exclusively claimed host.
-
-
-
SDIO device enablement
-
-
SdioEnableFunc
-
-
Enables an SDIO device.
-
-
-
SdioDisableFunc
-
-
Disables an SDIO device.
-
-
-
SDIO IRQ claiming/releasing
-
-
SdioClaimIrq
-
-
Claims an SDIO IRQ.
-
-
-
SdioReleaseIrq
-
-
Releases an SDIO IRQ.
-
-
-
-
-
-> **NOTE:**
->All functions provided in this document can be called only in kernel mode.
-
diff --git a/en/device-dev/driver/sdiousage-example.md b/en/device-dev/driver/sdiousage-example.md
deleted file mode 100644
index 558f4cf191206f4a01f28850d14d667208b592fc..0000000000000000000000000000000000000000
--- a/en/device-dev/driver/sdiousage-example.md
+++ /dev/null
@@ -1,129 +0,0 @@
-# SDIO Usage Example
-
-The following example shows how to use an SDIO device. First, open an SDIO controller whose bus number is 1, exclusively claim a host, enable the SDIO device, claim an SDIO IRQ, and then perform SDIO communication \(such as reading and writing\). After the SDIO communication, release the SDIO IRQ, disable the SDIO device, release the host, and close the SDIO controller.
-
-```
-#include "hdf_log.h"
-#include "sdio_if.h"
-
-#define TEST_FUNC_NUM 1 /* The I/O function whose ID is 1 is used. */
-#define TEST_FBR_BASE_ADDR 0x100 /* FBR base address of the I/O function whose ID is 1 */
-#define TEST_ADDR_OFFSET 9 /* Address offset of the register to read or write */
-#define TEST_DATA_LEN 3 /* Length of the data to read or write */
-#define TEST_BLOCKSIZE 2 /* Size of a data block, in bytes */
-
-/* Implement the SDIO IRQ function based on the application. */
-static void SdioIrqFunc(void *data)
-{
- if (data == NULL) {
- HDF_LOGE("SdioIrqFunc: data is NULL.\n");
- return;
- }
- /* You need to add specific implementations. */
-}
-
-void SdioTestSample(void)
-{
- int32_t ret;
- DevHandle handle = NULL;
- uint8_t data[TEST_DATA_LEN] = {0};
- struct SdioFunctionConfig config = {1, 0x123, 0x456};
- uint8_t val;
- uint32_t addr;
-
- /* Open an SDIO controller whose bus number is 1. */
- handle = SdioOpen(1, &config);
- if (handle == NULL) {
- HDF_LOGE("SdioOpen: failed!\n");
- return;
- }
- /* Claim a host exclusively. */
- SdioClaimHost(handle);
- /* Enable the SDIO device. */
- ret = SdioEnableFunc(handle);
- if (ret != 0) {
- HDF_LOGE("SdioEnableFunc: failed, ret %d\n", ret);
- goto ENABLE_ERR;
- }
- /* Claim an SDIO IRQ. */
- ret = SdioClaimIrq(handle, SdioIrqFunc);
- if (ret != 0) {
- HDF_LOGE("SdioClaimIrq: failed, ret %d\n", ret);
- goto CLAIM_IRQ_ERR;
- }
- /* Set the block size to 2 bytes. */
- ret = SdioSetBlockSize(handle, TEST_BLOCKSIZE);
- if (ret != 0) {
- HDF_LOGE("SdioSetBlockSize: failed, ret %d\n", ret);
- goto COMM_ERR;
- }
- /* Read 3-byte data from the incremental address of an SDIO device. */
- addr = TEST_FBR_BASE_ADDR * TEST_FUNC_NUM + TEST_ADDR_OFFSET;
- ret = SdioReadBytes(handle, data, addr, TEST_DATA_LEN);
- if (ret != 0) {
- HDF_LOGE("SdioReadBytes: failed, ret %d\n", ret);
- goto COMM_ERR;
- }
- /* Write 3-byte data into the incremental address of an SDIO device. */
- ret = SdioWriteBytes(handle, data, addr, TEST_DATA_LEN);
- if (ret != 0) {
- HDF_LOGE("SdioWriteBytes: failed, ret %d\n", ret);
- goto COMM_ERR;
- }
- /* Read 1-byte data from the SDIO device. */
- ret = SdioReadBytes(handle, &val, addr, 1);
- if (ret != 0) {
- HDF_LOGE("SdioReadBytes: failed, ret %d\n", ret);
- goto COMM_ERR;
- }
- /* Write 1-byte data into the SDIO device. */
- ret = SdioWriteBytes(handle, &val, addr, 1);
- if (ret != 0) {
- HDF_LOGE("SdioWriteBytes: failed, ret %d\n", ret);
- goto COMM_ERR;
- }
- /* Read 3-byte data from the fixed address of an SDIO device. */
- ret = SdioReadBytesFromFixedAddr(handle, data, addr, TEST_DATA_LEN, 0);
- if (ret != 0) {
- HDF_LOGE("SdioReadBytesFromFixedAddr: failed, ret %d\n", ret);
- goto COMM_ERR;
- }
- /* Write 1-byte data to the fixed address of an SDIO device. */
- ret = SdioWriteBytesToFixedAddr(handle, data, addr, 1, 0);
- if (ret != 0) {
- HDF_LOGE("SdioWriteBytesToFixedAddr: failed, ret %d\n", ret);
- goto COMM_ERR;
- }
- /* Read 1-byte data from SDIO function 0. */
- addr = 0x02;
- ret = SdioReadBytesFromFunc0(handle, &val, addr, 1);
- if (ret != 0) {
- HDF_LOGE("SdioReadBytesFromFunc0: failed, ret %d\n", ret);
- goto COMM_ERR;
- }
- /* Write 1-byte data into SDIO function 0. */
- ret = SdioWriteBytesToFunc0(handle, &val, addr, 1);
- if (ret != 0) {
- HDF_LOGE("SdioWriteBytesToFunc0: failed, ret %d\n", ret);
- goto COMM_ERR;
- }
-COMM_ERR:
- /* Release the SDIO IRQ. */
- ret = SdioReleaseIrq(handle);
- if (ret != 0) {
- HDF_LOGE("SdioReleaseIrq: failed, ret %d\n", ret);
- }
-CLAIM_IRQ_ERR:
- /* Disable the SDIO device. */
- ret = SdioDisableFunc(handle);
- if (ret != 0) {
- HDF_LOGE("SdioDisableFunc: failed, ret %d\n", ret);
- }
-ENABLE_ERR:
- /* Release the exclusively claimed host. */
- SdioReleaseHost(handle);
- /* Close an SDIO controller. */
- SdioClose(handle);
-}
-```
-
diff --git a/en/device-dev/driver/sdiousage-guidelines.md b/en/device-dev/driver/sdiousage-guidelines.md
deleted file mode 100644
index 402cf305ebb98196a477530f749e0bc07f9710bd..0000000000000000000000000000000000000000
--- a/en/device-dev/driver/sdiousage-guidelines.md
+++ /dev/null
@@ -1,787 +0,0 @@
-# SDIO Usage Guidelines
-
-- [How to Use](#section1962415610383)
-- [Opening an SDIO Controller](#section814751015461)
-- [Claiming a Host Exclusively](#section49274582455)
-- [Enabling the SDIO Device](#section1431520410489)
-- [Claiming an SDIO IRQ](#section3662781537)
-- [Performing SDIO Communication](#section391941913484)
-- [Releasing the SDIO IRQ](#section56205204481)
-- [Disabling the SDIO Device](#section181181621124815)
-- [Releasing the Exclusively Claimed Host](#section657117215486)
-- [Closing an SDIO Controller](#section1898172114818)
-
-## How to Use
-
-[Figure 1](spiusage-guidelines.md#fig23885455594) illustrates the process of using an SDIO.
-
-**Figure 1** Process of using an SDIO
-
-
-
-
-## Opening an SDIO Controller
-
-Before performing SDIO communication, obtain the device handle of an SDIO controller by calling **SdioOpen**. This function returns the device handle of the SDIO controller with a specified bus number.
-
-DevHandle SdioOpen\(int16\_t mmcBusNum, struct SdioFunctionConfig \*config\);
-
-**Table 1** Parameters and return values of SdioOpen
-
-
-
Parameter
-
-
Description
-
-
-
-
mmcBusNum
-
-
Bus number.
-
-
-
config
-
-
SDIO functionality configurations.
-
-
-
Return Value
-
-
Description
-
-
-
NULL
-
-
Failed to obtain the device handle of an SDIO controller.
-
-
-
Device handle
-
-
Device handle of an SDIO controller.
-
-
-
-
-
-The following example shows how to open an SDIO controller.
-
-```
-DevHandle handle = NULL;
-struct SdioFunctionConfig config;
-config.funcNr = 1;
-config.vendorId = 0x123;
-config.deviceId = 0x456;
-/* Open an SDIO controller whose bus number is 1. */
-handle = SdioOpen(1, &config);
-if (handle == NULL) {
- HDF_LOGE("SdioOpen: failed!\n");
-}
-```
-
-## Claiming a Host Exclusively
-
-After obtaining the device handle of an SDIO controller, exclusively claim the host before performing subsequent operations on the SDIO device.
-
-void SdioClaimHost\(DevHandle handle\);
-
-**Table 2** Parameter description of SdioClaimHost
-
-
-
Parameter
-
-
Description
-
-
-
-
handle
-
-
Device handle of an SDIO controller.
-
-
-
-
-
-The following example shows how to exclusively claim a host.
-
-```
-SdioClaimHost(handle); /* Claim a host exclusively. */
-```
-
-## Enabling the SDIO Device
-
-Before accessing a register, enable the SDIO device.
-
-int32\_t SdioEnableFunc\(DevHandle handle\);
-
-**Table 3** Parameters and return values of SdioEnableFunc
-
-
-
Parameter
-
-
Description
-
-
-
-
handle
-
-
Device handle of an SDIO controller.
-
-
-
Return Value
-
-
Description
-
-
-
0
-
-
The SDIO device is enabled.
-
-
-
Negative value
-
-
Failed to enable the SDIO device.
-
-
-
-
-
-The following example shows how to enable the SDIO device.
-
-```
-int32_t ret;
-/* Enable the SDIO device. */
-ret = SdioEnableFunc(handle);
-if (ret != 0) {
- HDF_LOGE("SdioEnableFunc: failed, ret %d\n", ret);
-}
-```
-
-## Claiming an SDIO IRQ
-
-Before SDIO communication, claim an SDIO IRQ.
-
-int32\_t SdioClaimIrq\(DevHandle handle, SdioIrqHandler \*handler\);
-
-**Table 4** Parameters and return values of SdioClaimIrq
-
-
-
Parameter
-
-
Description
-
-
-
-
handle
-
-
Device handle of an SDIO controller.
-
-
-
handler
-
-
Pointer to the SDIO IRQ function.
-
-
-
Return Value
-
-
Description
-
-
-
0
-
-
The SDIO IRQ is claimed.
-
-
-
Negative value
-
-
Failed to claim an SDIO IRQ.
-
-
-
-
-
-The following example shows how to claim an SDIO IRQ.
-
-```
-/* Implement the SDIO IRQ function based on the application. */
-static void SdioIrqFunc(void *data)
-{
- if (data == NULL) {
- HDF_LOGE("SdioIrqFunc: data is NULL.\n");
- return;
- }
- /* You need to add specific implementations. */
-}
-
-int32_t ret;
-/* Claim an SDIO IRQ. */
-ret = SdioClaimIrq(handle, SdioIrqFunc);
-if (ret != 0) {
- HDF_LOGE("SdioClaimIrq: failed, ret %d\n", ret);
-}
-```
-
-## Performing SDIO Communication
-
-- Incrementally write a given length of data into the SDIO device.
-
-The corresponding function is as follows:
-
-int32\_t SdioWriteBytes\(DevHandle handle, uint8\_t \*data, uint32\_t addr, uint32\_t size\);
-
-**Table 5** Parameters and return values of SdioWriteBytes
-
-
-
Parameter
-
-
Description
-
-
-
-
handle
-
-
Device handle of an SDIO controller.
-
-
-
data
-
-
Pointer to the data to write.
-
-
-
addr
-
-
Start address where the data is written into.
-
-
-
size
-
-
Length of the data to write.
-
-
-
Return Value
-
-
Description
-
-
-
0
-
-
Data is written into the SDIO device.
-
-
-
Negative value
-
-
Failed to write data into the SDIO device.
-
-
-
-
-
-The following example shows how to incrementally write a given length of data into the SDIO device.
-
-```
-int32_t ret;
-uint8_t wbuff[] = {1,2,3,4,5};
-uint32_t addr = 0x100 + 0x09;
-/* Incrementally write 5-byte data into the start address 0x109 of the SDIO device. */
-ret = SdioWriteBytes(handle, wbuff, addr, sizeof(wbuff) / sizeof(wbuff[0]));
-if (ret != 0) {
- HDF_LOGE("SdioWriteBytes: failed, ret %d\n", ret);
-}
-```
-
-- Incrementally read a given length of data from the SDIO device.
-
-The corresponding function is as follows:
-
-int32\_t SdioReadBytes\(DevHandle handle, uint8\_t \*data, uint32\_t addr, uint32\_t size\);
-
-**Table 6** Parameters and return values of SdioReadBytes
-
-
-
Parameter
-
-
Description
-
-
-
-
handle
-
-
Device handle of an SDIO controller.
-
-
-
data
-
-
Pointer to the data to read.
-
-
-
addr
-
-
Start address where the data is read from.
-
-
-
size
-
-
Length of the data to read.
-
-
-
Return Value
-
-
Description
-
-
-
0
-
-
Data is read from the SDIO device.
-
-
-
Negative value
-
-
Failed to read data from the SDIO device.
-
-
-
-
-
-The following example shows how to incrementally read a given length of data from the SDIO device.
-
-```
-int32_t ret;
-uint8_t rbuff[5] = {0};
-uint32_t addr = 0x100 + 0x09;
-/* Incrementally read 5-byte data from the start address 0x109 of the SDIO device. */
-ret = SdioReadBytes(handle, rbuff, addr, 5);
-if (ret != 0) {
- HDF_LOGE("SdioReadBytes: failed, ret %d\n", ret);
-}
-```
-
-- Write a given length of data into the fixed address of an SDIO device.
-
- The corresponding function is as follows:
-
- int32\_t SdioWriteBytesToFixedAddr\(DevHandle handle, uint8\_t \*data, uint32\_t addr, uint32\_t size, uint32\_t scatterLen\);
-
- **Table 7** Parameters and return values of SdioWriteBytesToFixedAddr
-
-
-
Parameter
-
-
Description
-
-
-
-
handle
-
-
Device handle of an SDIO controller.
-
-
-
data
-
-
Pointer to the data to write.
-
-
-
addr
-
-
Fixed address where the data is written into.
-
-
-
size
-
-
Length of the data to write.
-
-
-
scatterLen
-
-
Length of the scatter list. If the value is not 0, the data is of the scatter list type.
-
-
-
Return Value
-
-
Description
-
-
-
0
-
-
Data is written into the SDIO device.
-
-
-
Negative value
-
-
Failed to write data into the SDIO device.
-
-
-
-
-
- The following example shows how to write a given length of data into the fixed address of an SDIO device.
-
- ```
- int32_t ret;
- uint8_t wbuff[] = {1, 2, 3, 4, 5};
- uint32_t addr = 0x100 + 0x09;
- /* Write 5-byte data into the fixed address 0x109 of the SDIO device. */
- ret = SdioWriteBytesToFixedAddr(handle, wbuff, addr, sizeof(wbuff) / sizeof(wbuff[0]), 0);
- if (ret != 0) {
- HDF_LOGE("SdioWriteBytesToFixedAddr: failed, ret %d\n", ret);
- }
- ```
-
-- Read a given length of data from the fixed address of an SDIO device.
-
- The corresponding function is as follows:
-
- int32\_t SdioReadBytesFromFixedAddr\(DevHandle handle, uint8\_t \*data, uint32\_t addr, uint32\_t size, uint32\_t scatterLen\);
-
- **Table 8** Parameters and return values of SdioReadBytesFromFixedAddr
-
-
-
Parameter
-
-
Description
-
-
-
-
handle
-
-
Device handle of an SDIO controller.
-
-
-
data
-
-
Pointer to the data to read.
-
-
-
addr
-
-
Start address where the data is read from.
-
-
-
size
-
-
Length of the data to read.
-
-
-
scatterLen
-
-
Length of the scatter list. If the value is not 0, the data is of the scatter list type.
-
-
-
Return Value
-
-
Description
-
-
-
0
-
-
Data is read from the SDIO device.
-
-
-
Negative value
-
-
Failed to read data from the SDIO device.
-
-
-
-
-
- The following example shows how to read a given length of data from the fixed address of an SDIO device.
-
- ```
- int32_t ret;
- uint8_t rbuff[5] = {0};
- uint32_t addr = 0x100 + 0x09;
- /* Read 5-byte data from the fixed address 0x109 of the SDIO device. */
- ret = SdioReadBytesFromFixedAddr(handle, rbuff, addr, 5, 0);
- if (ret != 0) {
- HDF_LOGE("SdioReadBytesFromFixedAddr: failed, ret %d\n", ret);
- }
- ```
-
-
-- Write a given length of data into the address space of SDIO function 0.
-
-Currently, only 1-byte data can be written. The corresponding function is as follows:
-
-int32\_t SdioWriteBytesToFunc0\(DevHandle handle, uint8\_t \*data, uint32\_t addr, uint32\_t size\);
-
-**Table 9** Parameters and return values of SdioWriteBytesToFunc0
-
-
-
Parameter
-
-
Description
-
-
-
-
handle
-
-
Device handle of an SDIO controller.
-
-
-
data
-
-
Pointer to the data to write.
-
-
-
addr
-
-
Start address where the data is written into.
-
-
-
size
-
-
Length of the data to write.
-
-
-
Return Value
-
-
Description
-
-
-
0
-
-
Data is written into the SDIO device.
-
-
-
Negative value
-
-
Failed to write data into the SDIO device.
-
-
-
-
-
-The following example shows how to write a given length of data into the address space of SDIO function 0.
-
-```
-int32_t ret;
-uint8_t wbuff = 1;
-/* Write 1-byte data into the address 0x2 of SDIO function 0. */
-ret = SdioWriteBytesToFunc0(handle, &wbuff, 0x2, 1);
-if (ret != 0) {
- HDF_LOGE("SdioWriteBytesToFunc0: failed, ret %d\n", ret);
-}
-```
-
-- Read a given length of data from the address space of SDIO function 0.
-
-Currently, only 1-byte data can be read. The corresponding function is as follows:
-
-int32\_t SdioReadBytesFromFunc0\(DevHandle handle, uint8\_t \*data, uint32\_t addr, uint32\_t size\);
-
-**Table 10** Parameters and return values of SdioReadBytesFromFunc0
-
-
-
Parameter
-
-
Description
-
-
-
-
handle
-
-
Device handle of an SDIO controller.
-
-
-
data
-
-
Pointer to the data to read.
-
-
-
addr
-
-
Start address where the data is read from.
-
-
-
size
-
-
Length of the data to read.
-
-
-
Return Value
-
-
Description
-
-
-
0
-
-
Data is read from the SDIO device.
-
-
-
Negative value
-
-
Failed to read data from the SDIO device.
-
-
-
-
-
-The following example shows how to read a given length of data from the address space of SDIO function 0.
-
-```
-int32_t ret;
-uint8_t rbuff;
-/* Read 1-byte data from the address 0x2 of SDIO function 0. */
-ret = SdioReadBytesFromFunc0(handle, &rbuff, 0x2, 1);
-if (ret != 0) {
- HDF_LOGE("SdioReadBytesFromFunc0: failed, ret %d\n", ret);
-}
-```
-
-## Releasing the SDIO IRQ
-
-After the SDIO communication, release the SDIO IRQ.
-
-int32\_t SdioReleaseIrq\(DevHandle handle\);
-
-**Table 11** Parameters and return values of SdioReleaseIrq
-
-
-
Parameter
-
-
Description
-
-
-
-
handle
-
-
Device handle of an SDIO controller.
-
-
-
Return Value
-
-
Description
-
-
-
0
-
-
The SDIO IRQ is released.
-
-
-
Negative value
-
-
Failed to release the SDIO IRQ.
-
-
-
-
-
-The following example shows how to release the SDIO IRQ.
-
-```
-int32_t ret;
-/* Release the SDIO IRQ. */
-ret = SdioReleaseIrq(handle);
-if (ret != 0) {
- HDF_LOGE("SdioReleaseIrq: failed, ret %d\n", ret);
-}
-```
-
-## Disabling the SDIO Device
-
-After the SDIO communication, disable the SDIO device.
-
-int32\_t SdioDisableFunc\(DevHandle handle\);
-
-**Table 12** Parameters and return values of SdioDisableFunc
-
-
-
Parameter
-
-
Description
-
-
-
-
handle
-
-
Device handle of an SDIO controller.
-
-
-
Return Value
-
-
Description
-
-
-
0
-
-
The SDIO device is disabled.
-
-
-
Negative value
-
-
Failed to disable the SDIO device.
-
-
-
-
-
-The following example shows how to disable the SDIO device.
-
-```
-int32_t ret;
-/* Disable the SDIO device. */
-ret = SdioDisableFunc(handle);
-if (ret != 0) {
- HDF_LOGE("SdioDisableFunc: failed, ret %d\n", ret);
-}
-```
-
-## Releasing the Exclusively Claimed Host
-
-After the SDIO communication, release the exclusively claimed host.
-
-void SdioReleaseHost\(DevHandle handle\);
-
-**Table 13** Parameter description of SdioReleaseHost
-
-
-
Parameter
-
-
Description
-
-
-
-
handle
-
-
Device handle of an SDIO controller.
-
-
-
-
-
-The following example shows how to release the exclusively claimed host.
-
-```
-SdioReleaseHost(handle); /* Release the exclusively claimed host. */
-```
-
-## Closing an SDIO Controller
-
-After the SDIO communication, close the SDIO controller.
-
-void SdioClose\(DevHandle handle\);
-
-This function releases the resources requested.
-
-**Table 14** Parameter description of SdioClose
-
-
-
Parameter
-
-
Description
-
-
-
-
handle
-
-
Device handle of an SDIO controller.
-
-
-
-
-
-The following example shows how to close an SDIO controller.
-
-```
-SdioClose(handle); /* Close an SDIO controller. */
-```
-
diff --git a/en/device-dev/driver/sensor-driver-development-example.md b/en/device-dev/driver/sensor-driver-development-example.md
deleted file mode 100644
index acab2c70f8f15eb2f313206a50e289af4ab759db..0000000000000000000000000000000000000000
--- a/en/device-dev/driver/sensor-driver-development-example.md
+++ /dev/null
@@ -1,583 +0,0 @@
-# Sensor Driver Development Example
-
-This section provides a code example of how to load and start the acceleration sensor driver based on the HDF driver model. For details about the mechanism, see [HDF Driver Development](driver-development.md). This example uses the Bosch BMI160 acceleration sensor that communicates over I2C.
-
-1. Register the driver entry of the acceleration sensor.
-
-- Implementation of the entry function
-
-```
-/* Register the entry structure object of the acceleration sensor. */
-struct HdfDriverEntry g_sensorAccelDevEntry = {
- .moduleVersion = 1, /* Version number of the acceleration sensor module */
- .moduleName = "HDF_SENSOR_ACCEL", /* Name of the acceleration sensor module. The value must be the same as that of moduleName in the device_info.hcs file. */
- .Bind = BindAccelDriver, /* Binding function of the acceleration sensor */
- .Init = InitAccelDriver, /* Initialization function of the acceleration sensor */
- .Release = ReleaseAccelDriver, /* Resource release function of the acceleration sensor */
-};
-
-/* Call HDF_INIT to register the driver entry with the HDF. When loading the driver, the HDF calls the Bind function first and then the Init function. If the Init function fails to be called, the HDF will call Release to release the driver resource and exit.
-HDF_INIT(g_sensorAccelDevEntry);
-```
-
-- Acceleration sensor configuration
-
-The acceleration sensor model uses the HCS as the configuration source code. For details about the HCS configuration fields, see [Driver Configuration Management](driver-configuration-management.md).
-
-```
-/* HCS configuration of the acceleration sensor device */
-device_sensor_accel :: device {
- device0 :: deviceNode {
- policy = 1; /* Policy for providing the driver service */
- priority = 105; /* Driver startup priority (0–200). A larger value indicates a lower priority. The default value 100 is recommended. The sequence for loading devices with the same priority is random. */
- preload = 2; /* Field for specifying whether to load the driver. Value 0 means to load the driver, and 2 means the opposite. */
- permission = 0664; /* Permission for the driver to create device nodes */
- moduleName = "HDF_SENSOR_ACCEL"; /* Driver name. The value must be the same as that of moduleName in the driver entry structure. */
- serviceName = "sensor_accel"; /* Name of the service provided by the driver. The name must be unique. */
- deviceMatchAttr = "hdf_sensor_accel_driver"; /* Keyword matching the private data of the driver. The value must be the same as that of match_attr in the private data configuration table of the driver. */
- }
-}
-```
-
-1. Initialize and deinitialize the acceleration sensor driver.
-
-- Initialization entry function **init**
-
-```
-/* Bind the service provided by the acceleration sensor driver to the HDF. */
-int32_t BindAccelDriver(struct HdfDeviceObject *device)
-{
- CHECK_NULL_PTR_RETURN_VALUE(device, HDF_ERR_INVALID_PARAM);
-
- static struct IDeviceIoService service = {
- .object = {0},
- .Dispatch = DispatchAccel,
- };
- device->service = &service;
-
- return HDF_SUCCESS;
-}
-/* After detecting that the device is in position, call RegisterAccelChipOps to register the differentiation adaptation function. */
-int32_t RegisterAccelChipOps(struct AccelOpsCall *ops)
-{
- struct AccelDrvData *drvData = NULL;
-
- CHECK_NULL_PTR_RETURN_VALUE(ops, HDF_ERR_INVALID_PARAM);
-
- drvData = AccelGetDrvData();
- drvData->ops.Init = ops->Init;
- drvData->ops.ReadData = ops->ReadData;
- return HDF_SUCCESS;
-}
-/* Hook the acceleration sensor driver normalization function. */
-static int32_t InitAccelOps(struct SensorDeviceInfo *deviceInfo)
-{
- struct AccelDrvData *drvData = AccelGetDrvData();
-
- (void)memset_s((void *)deviceInfo, sizeof(*deviceInfo), 0, sizeof(*deviceInfo));
- deviceInfo->ops.GetInfo = SetAccelInfo;
- deviceInfo->ops.Enable = SetAccelEnable;
- deviceInfo->ops.Disable = SetAccelDisable;
- deviceInfo->ops.SetBatch = SetAccelBatch;
- deviceInfo->ops.SetMode = SetAccelMode;
- deviceInfo->ops.SetOption = SetAccelOption;
-
- if (memcpy_s(&deviceInfo->sensorInfo, sizeof(deviceInfo->sensorInfo),
- &drvData->accelCfg->sensorInfo, sizeof(drvData->accelCfg->sensorInfo)) != EOK) {
- HDF_LOGE("%s: copy sensor info failed", __func__);
- return HDF_FAILURE;
- }
- /* The sensor type ID can be configured in the HCS configuration file or here. */
- drvData->accelCfg->sensorInfo.sensorTypeId = SENSOR_TAG_ACCELEROMETER;
- drvData->accelCfg->sensorInfo.sensorId = SENSOR_TAG_ACCELEROMETER;
-
- return HDF_SUCCESS;
-}
-/* Initialize the sensor register. */
-static int32_t InitAccelAfterConfig(void)
-{
- struct SensorDeviceInfo deviceInfo;
-
- if (InitAccelConfig() != HDF_SUCCESS) {
- HDF_LOGE("%s: init accel config failed", __func__);
- return HDF_FAILURE;
- }
-
- if (InitAccelOps(&deviceInfo) != HDF_SUCCESS) {
- HDF_LOGE("%s: init accel ops failed", __func__);
- return HDF_FAILURE;
- }
-
- if (AddSensorDevice(&deviceInfo) != HDF_SUCCESS) {
- HDF_LOGE("%s: add accel device failed", __func__);
- return HDF_FAILURE;
- }
-
- return HDF_SUCCESS;
-}
-/* Call the device detection function to hook the differentiated device function. */
-static int32_t DetectAccelChip(void)
-{
- int32_t num;
- int32_t ret;
- int32_t loop;
- struct AccelDrvData *drvData = AccelGetDrvData();
- CHECK_NULL_PTR_RETURN_VALUE(drvData->accelCfg, HDF_ERR_INVALID_PARAM);
-
- num = sizeof(g_accelDetectIfList) / sizeof(g_accelDetectIfList[0]);
- for (loop = 0; loop < num; ++loop) {
- if (g_accelDetectIfList[loop].DetectChip != NULL) {
- ret = g_accelDetectIfList[loop].DetectChip(drvData->accelCfg);
- if (ret == HDF_SUCCESS) {
- drvData->detectFlag = true;
- break;
- }
- }
- }
-
- if (loop == num) {
- HDF_LOGE("%s: detect accel device failed", __func__);
- drvData->detectFlag = false;
- return HDF_FAILURE;
- }
- return HDF_SUCCESS;
-}
-/* The entry function of the acceleration sensor driver is used to initialize the structure object of the sensor private data, allocate space for the HCS data configuration object of the sensor, invoke the entry function for initializing the sensor HCS data configuration, detect whether the sensor device is in position, create the sensor data reporting timer, implement the sensor normalization API, and register the sensor device. */
-int32_t InitAccelDriver(struct HdfDeviceObject *device)
-{
- /* Obtain the private data structure object of the sensor. */
- struct AccelDrvData *drvData = AccelGetDrvData();
-
- /* When detecting sensors of the same type from different vendors, the function checks whether this type of sensors is in position. If yes, it no longer detects the other sensors of this type and directly returns the result. */
- if (drvData->detectFlag) {
- HDF_LOGE("%s: accel sensor have detected", __func__);
- return HDF_SUCCESS;
- }
-
- CHECK_NULL_PTR_RETURN_VALUE(device, HDF_ERR_INVALID_PARAM);
- /* Allocate space for the private data structure objects for storing sensor data configurations. The allocated space needs to be released when the driver is released. */
- drvData->accelCfg = (struct SensorCfgData *)OsalMemCalloc(sizeof(*cfg));
- if (drvData->accelCfg == NULL) {
- HDF_LOGE("%s: malloc sensor config data failed", __func__);
- return HDF_FAILURE;
- }
-
- drvData->accelCfg->regCfgGroup = &g_regCfgGroup[0];
- /* Initializing the sensor configuration data aims to parse the configuration information of the sensor communication bus, basic sensor information, sensor attributes, whether the sensor is in position, and register group information. */
- if (GetSensorBaseConfigData(device->property, drvData->accelCfg) != HDF_SUCCESS) {
- HDF_LOGE("%s: get sensor base config failed", __func__);
- goto Base_CONFIG_EXIT;
- }
-
- if (DetectAccelChip() != HDF_SUCCESS) {
- HDF_LOGE("%s: accel sensor detect device no exist", __func__);
- goto DETECT_CHIP_EXIT;
- }
- drvData->detectFlag = true;
- if (ParseSensorRegConfig(drvData->accelCfg) != HDF_SUCCESS) {
- HDF_LOGE("%s: detect sensor device failed", __func__);
- goto REG_CONFIG_EXIT;
- }
-
- if (InitAccelAfterConfig() != HDF_SUCCESS) {
- HDF_LOGE("%s: init accel after config failed", __func__);
- goto INIT_EXIT;
- }
-
- HDF_LOGI("%s: init accel driver success", __func__);
- return HDF_SUCCESS;
-
-INIT_EXIT:
- DestroySensorThread(&drvData->thread, &drvData->threadStatus);
- (void)DeleteSensorDevice(SENSOR_TAG_ACCELEROMETER);
-REG_CONFIG_EXIT:
- ReleaseSensorAllRegConfig(drvData->accelCfg);
- (void)ReleaseSensorBusHandle(&drvData->accelCfg->busCfg);
-DETECT_CHIP_EXIT:
- drvData->detectFlag = false;
-BASE_CONFIG_EXIT:
- drvData->accelCfg->root = NULL;
- drvData->accelCfg->regCfgGroup = NULL;
- OsalMemFree(drvData->accelCfg);
- drvData->accelCfg = NULL;
- return HDF_FAILURE;
-}
-
-/* Release the resources allocated during driver initialization. */
-void ReleaseAccelDriver(struct HdfDeviceObject *device)
-{
- (void)device;
- struct AccelDrvData *drvData = NULL;
-
- drvData = AccelGetDrvData();
- (void)DestroySensorThread(&drvData->thread, &drvData->threadStatus);
- (void)DeleteSensorDevice(SENSOR_TAG_ACCELEROMETER);
- drvData->detectFlag = false;
-
- if (drvData->accelCfg != NULL) {
- drvData->accelCfg->root = NULL;
- drvData->accelCfg->regCfgGroup = NULL;
- ReleaseSensorAllRegConfig(drvData->accelCfg);
- (void)ReleaseSensorBusHandle(&drvData->accelCfg->busCfg);
- OsalMemFree(drvData->accelCfg);
- drvData->accelCfg = NULL;
- }
-
- drvData->initStatus = false;
-}
-```
-
-1. Configure the acceleration sensor register group.
-
-You only need to configure the acceleration sensor data according to the template. Template configuration parsing has been implemented via the **InitSensorConfigData** function and only needs to be called during initialization. If new configuration items are added, you need to modify this function accordingly.
-
-```
-Acceleration sensor data configuration template (accel_config.hcs)
-root {
- sensorAccelConfig {
- accelChipConfig {
- /* Sensor information template */
- template sensorInfo {
- sensorName = "accelerometer"; /* Acceleration sensor name. The value contains a maximum of 16 bytes. */
- vendorName = "borsh_bmi160"; /* Sensor vendor name. The value contains a maximum of 16 bytes. */
- firmwareVersion = "1.0"; /* Sensor firmware version number. The default value is 1.0. The value contains a maximum of 16 bytes. */
- hardwareVersion = "1.0"; /* Sensor hardware version number. The default value is 1.0. The value contains a maximum of 16 bytes. */
- sensorTypeId = 1; /* Sensor type ID. For details, see SensorTypeTag. */
- sensorId = 1; /* Sensor ID, which is defined by the sensor driver developer. The SensorTypeTag enums are recommended. */
- maxRange = 8; /* Maximum measurement range of the sensor. Set this parameter based on your business requirements. */
- precision = 0; /* Sensor accuracy, which is used together with sensor data reporting. For details, see SensorEvents. */
- power = 230; /* Power consumption of the sensor */
- }
- /* Template of the bus type and configuration information used by the sensor */
- template sensorBusConfig {
- busType = 0; /* 0 for the I2C bus and 1 for the SPI bus */
- busNum = 6; /* Device ID allocated to the sensor on the chip */
- busAddr = 0; /* Address allocated to the sensor on the chip */
- regWidth = 1; /* Width of the sensor register address */
- regBigEndian = 0; /* Endian mode of the sensor register */
- }
- /* Sensor attribute template */
- template sensorAttr {
- chipName = ""; /* Sensor chip name */
- chipIdRegister = 0xf; /* Address of the register detecting whether the sensor is in position */
- chipIdValue = 0xd1; /* Value of the register detecting whether the sensor is in position */
- }
- }
- }
-}
-
-/* You can modify the template configuration based on the differences of sensor devices. If no modification is made, the default template configuration is used. */
-root {
- sensorAccelConfig {
- accel_bmi160_chip_config : accelChipConfig {
- match_attr = "hdf_sensor_accel_driver"; /* The value must be the same as the match_attr field configured for the acceleration sensor. */
- accelInfo :: sensorInfo {
- vendorName = "borsh_bmi160";
- sensorTypeId = 1;
- sensorId = 1;
- }
- accelBusConfig :: sensorBusConfig {
- busType = 0; /* I2C communication mode */
- busNum = 6;
- busAddr = 0x68;
- regWidth = 1; /* 1-byte bit width */
- }
- accelAttr :: sensorAttr {
- chipName = "bmi160";
- chipIdRegister = 0x00;
- chipIdValue = 0xd1;
- }
- accelRegConfig {
- /* regAddr: Register address
- value: Register value
- mask: Mask of the register value
- len: Length (in bytes) of the register value
- delay: Register delay (in milliseconds)
- opsType: Operation type. The options can be 0 (no operation), 1 (read), 2 (write), 3 (read and check), and 4 (bit update).
- calType: Calculation type. The options can be 0 (none), 1 (write), 2 (negate), 3 (XOR) 4, (left shift), and 5 (right shift).
- shiftNum: Number of shifts
- debug: Debugging switch. The value can be 0 (disabled) or 1 (enabled).
- save: Data saving switch. The value can be 0 (not save data) or 1 (save data).
- */
- /* Groups of sensor register operations. Registers can be configured in sequence based on the groups. */
- /* Register address, register value, mask of the register value, data length of the register value, register delay, operation type, calculation type, number of shifts, debugging switch, data saving switch */
- /* Initialize the register groups. */
- initSeqConfig = [
- 0x7e, 0xb6, 0xff, 1, 5, 2, 0, 0, 0, 0,
- 0x7e, 0x10, 0xff, 1, 5, 2, 0, 0, 0, 0
- ];
- /* Enable the register groups. */
- enableSeqConfig = [
- 0x7e, 0x11, 0xff, 1, 5, 2, 0, 0, 0, 0,
- 0x41, 0x03, 0xff, 1, 0, 2, 0, 0, 0, 0,
- 0x40, 0x08, 0xff, 1, 0, 2, 0, 0, 0, 0
- ];
- /* Disable the register groups. */
- disableSeqConfig = [
- 0x7e, 0x10, 0xff, 1, 5, 2, 0, 0, 0, 0
- ];
- }
- }
- }
-}
-```
-
-1. Implement APIs for acceleration sensor driver operations.
-
-You need to implement normalized APIs based on sensor types.
-
-```
-/* Leave a function empty if it is not used. */
-static int32_t SetAccelInfo(struct SensorBasicInfo *info)
-{
- (void)info;
-
- return HDF_ERR_NOT_SUPPORT;
-}
-/* Deliver the configuration of enabling the register groups. */
-static int32_t SetAccelEnable(void)
-{
- int32_t ret;
- struct AccelDrvData *drvData = AccelGetDrvData();
-
- CHECK_NULL_PTR_RETURN_VALUE(drvData->accelCfg, HDF_ERR_INVALID_PARAM);
- ret = SetSensorRegCfgArray(&drvData->accelCfg->busCfg, drvData->accelCfg->regCfgGroup[SENSOR_ENABLE_GROUP]);
- if (ret != HDF_SUCCESS) {
- HDF_LOGE("%s: accel sensor disable config failed", __func__);
- return HDF_FAILURE;
- }
-
- drvData->threadStatus = SENSOR_THREAD_RUNNING;
-
- return HDF_SUCCESS;
-}
-/* Deliver the configuration of disabling the register groups. */
-static int32_t SetAccelDisable(void)
-{
- int32_t ret;
- struct AccelDrvData *drvData = AccelGetDrvData();
-
- CHECK_NULL_PTR_RETURN_VALUE(drvData->accelCfg, HDF_ERR_INVALID_PARAM);
-
- ret = SetSensorRegCfgArray(&drvData->accelCfg->busCfg, drvData->accelCfg->regCfgGroup[SENSOR_DISABLE_GROUP]);
- if (ret != HDF_SUCCESS) {
- HDF_LOGE("%s: accel sensor disable config failed", __func__);
- return HDF_FAILURE;
- }
-
- drvData->threadStatus = SENSOR_THREAD_STOPPED;
-
- return HDF_SUCCESS;
-}
-/* Set the sampling interval and data reporting interval of the sensor. */
-static int32_t SetAccelBatch(int64_t samplingInterval, int64_t interval)
-{
- (void)interval;
-
- struct AccelDrvData *drvData = AccelGetDrvData();
- drvData->interval = samplingInterval;
-
- return HDF_SUCCESS;
-}
-/* Set the data reporting mode of the sensor. Currently, the real-time mode is supported. */
-static int32_t SetAccelMode(int32_t mode)
-{
- return (mode == SENSOR_WORK_MODE_REALTIME) ? HDF_SUCCESS : HDF_FAILURE;
-}
-/* Set the sensor options. */
-static int32_t SetAccelOption(uint32_t option)
-{
- (void)option;
- return HDF_ERR_NOT_SUPPORT;
-}
-```
-
-- Differentiated processing APIs
-
- ```
- /* If a device is successfully detected, register the differentiated processing function to the accel driver model. */
- int32_t DetectAccelBim160Chip(struct SensorCfgData *data)
- {
- int32_t ret;
- struct AccelOpsCall ops;
- CHECK_NULL_PTR_RETURN_VALUE(data, HDF_ERR_INVALID_PARAM);
-
- if (strcmp(ACCEL_CHIP_NAME_BMI160, data->sensorAttr.chipName) != 0) {
- return HDF_SUCCESS;
- }
- ret = InitAccelPreConfig();
- if (ret != HDF_SUCCESS) {
- HDF_LOGE("%s: init BMI160 bus mux config", __func__);
- return HDF_FAILURE;
- }
- if (DetectSensorDevice(data) != HDF_SUCCESS) {
- return HDF_FAILURE;
- }
-
- /* Differentiated processing function */
- ops.Init = InitBmi160;
- ops.ReadData = ReadBmi160Data;
- ret = RegisterAccelChipOps(&ops);
- if (ret != HDF_SUCCESS) {
- HDF_LOGE("%s: register BMI160 accel failed", __func__);
- (void)ReleaseSensorBusHandle(&data->busCfg);
- return HDF_FAILURE;
- }
- return HDF_SUCCESS;
- }
- /* Initialization processing function */
- static int32_t InitBmi160(struct SensorCfgData *data)
- {
- int32_t ret;
-
- CHECK_NULL_PTR_RETURN_VALUE(data, HDF_ERR_INVALID_PARAM);
- ret = SetSensorRegCfgArray(&data->busCfg, data->regCfgGroup[SENSOR_INIT_GROUP]);
- if (ret != HDF_SUCCESS) {
- HDF_LOGE("%s: bmi160 sensor init config failed", __func__);
- return HDF_FAILURE;
- }
- return HDF_SUCCESS;
- }
- /* Data processing function */
- int32_t ReadBmi160Data(struct SensorCfgData *data)
- {
- int32_t ret;
- struct AccelData rawData = { 0, 0, 0 };
- int32_t tmp[ACCEL_AXIS_NUM];
- struct SensorReportEvent event;
-
- (void)memset_s(&event, sizeof(event), 0, sizeof(event));
-
- ret = ReadBmi160RawData(data, &rawData, &event.timestamp);
- if (ret != HDF_SUCCESS) {
- return HDF_FAILURE;
- }
-
- event.sensorId = SENSOR_TAG_ACCELEROMETER;
- event.option = 0;
- event.mode = SENSOR_WORK_MODE_REALTIME;
-
- rawData.x = rawData.x * BMI160_ACC_SENSITIVITY_2G;
- rawData.y = rawData.y * BMI160_ACC_SENSITIVITY_2G;
- rawData.z = rawData.z * BMI160_ACC_SENSITIVITY_2G;
-
- tmp[ACCEL_X_AXIS] = (rawData.x * SENSOR_1K_UNIT) / SENSOR_CONVERT_UNIT;
- tmp[ACCEL_Y_AXIS] = (rawData.y * SENSOR_1K_UNIT) / SENSOR_CONVERT_UNIT;
- tmp[ACCEL_Z_AXIS] = (rawData.z * SENSOR_1K_UNIT) / SENSOR_CONVERT_UNIT;
-
- event.dataLen = sizeof(tmp);
- event.data = (uint8_t *)&tmp;
- ret = ReportSensorEvent(&event);
- return ret;
- }
- ```
-
-- Data processing function
-
-Create a sensor timer to periodically sample data based on the configured sampling interval and report the data to the data subscriber.
-
-```
-/* Scheduled working thread of the sensor */
-static int32_t ReadAccelDataThreadWorker(void *arg)
-{
- (void)arg;
- int64_t interval;
- struct AccelDrvData *drvData = AccelGetDrvData();
-
- drvData->threadStatus = SENSOR_THREAD_START;
- while (true) {
- if (drvData->threadStatus == SENSOR_THREAD_RUNNING) {
- if (drvData->ops.ReadData != NULL) {
- (void)drvData->ops.ReadData(drvData->accelCfg);
- }
- interval = OsalDivS64(drvData->interval, (SENSOR_CONVERT_UNIT * SENSOR_CONVERT_UNIT));
- OsalMSleep(interval);
- } else if (drvData->threadStatus == SENSOR_THREAD_DESTROY) {
- break;
- } else {
- OsalMSleep(ACC_DEFAULT_SAMPLING_200_MS / SENSOR_CONVERT_UNIT / SENSOR_CONVERT_UNIT);
- }
-
- if ((!drvData->initStatus) || (drvData->interval < 0) || drvData->threadStatus != SENSOR_THREAD_RUNNING) {
- continue;
- }
- }
-
- return HDF_SUCCESS;
-}
-/* Create a sensor timer and initialize the sensor device. */
-static int32_t InitAccelConfig(void)
-{
- int32_t ret;
- struct AccelDrvData *drvData = AccelGetDrvData();
-
- if (drvData->threadStatus != SENSOR_THREAD_NONE && drvData->threadStatus != SENSOR_THREAD_DESTROY) {
- HDF_LOGE("%s: accel thread have created", __func__);
- return HDF_SUCCESS;
- }
-
- ret = CreateSensorThread(&drvData->thread, ReadAccelDataThreadWorker, "hdf_sensor_accel", drvData);
- if (ret != HDF_SUCCESS) {
- HDF_LOGE("%s: accel create thread failed", __func__);
- drvData->threadStatus = SENSOR_THREAD_NONE;
- return HDF_FAILURE;
- }
-
- CHECK_NULL_PTR_RETURN_VALUE(drvData->ops.Init, HDF_ERR_INVALID_PARAM);
-
- ret = drvData->ops.Init(drvData->accelCfg);
- if (ret != HDF_SUCCESS) {
- HDF_LOGE("%s: accel create thread failed", __func__);
- drvData->threadStatus = SENSOR_THREAD_NONE;
- return HDF_FAILURE;
- }
- drvData->initStatus = true;
- return HDF_SUCCESS;
-}
-```
-
-- Major data structures
-
-```
-/* Sensor conversion units */
-#define SENSOR_CONVERT_UNIT 1000
-#define SENSOR_1K_UNIT 1024
-/* Sensitivity conversion value of the sensor with a 2g measurement range */
-#define BMI160_ACC_SENSITIVITY_2G 61
-/* Address of the sensor data sampling register */
-#define BMI160_ACCEL_X_LSB_ADDR 0X12
-#define BMI160_ACCEL_X_MSB_ADDR 0X13
-#define BMI160_ACCEL_Y_LSB_ADDR 0X14
-#define BMI160_ACCEL_Y_MSB_ADDR 0X15
-#define BMI160_ACCEL_Z_LSB_ADDR 0X16
-#define BMI160_ACCEL_Z_MSB_ADDR 0X17
-/* Data dimension of the sensor */
-enum AccelAxisNum {
- ACCEL_X_AXIS = 0,
- ACCEL_Y_AXIS = 1,
- ACCEL_Z_AXIS = 2,
- ACCEL_AXIS_NUM = 3,
-};
-/* Each dimension of the sensor */
-struct AccelData {
- int32_t x;
- int32_t y;
- int32_t z;
-};
-/* Private data structure of the sensor */
-struct AccelDrvData {
- bool detectFlag;
- uint8_t threadStatus;
- uint8_t initStatus;
- int64_t interval;
- struct SensorCfgData *accelCfg;
- struct OsalThread thread;
- struct AccelOpsCall ops;
-};
-/* Differentiation adaptation function */
-struct AccelOpsCall {
- int32_t (*Init)(struct SensorCfgData *data);
- int32_t (*ReadData)(struct SensorCfgData *data);
-};
-```
-
diff --git a/en/device-dev/driver/sensor-driver-development-guidelines.md b/en/device-dev/driver/sensor-driver-development-guidelines.md
deleted file mode 100644
index afbb833cac70c19f9612461c6d2f9983f58ef544..0000000000000000000000000000000000000000
--- a/en/device-dev/driver/sensor-driver-development-guidelines.md
+++ /dev/null
@@ -1,16 +0,0 @@
-# Sensor Driver Development Guidelines
-
-- [How to Develop](#section18816105182315)
-
-Regardless of the OS and system on a chip \(SoC\), the sensor driver is developed based on the HDF, platform, and OSAL APIs to provide a unified driver model for sensor devices. This section uses the acceleration sensor as an example to describe how to develop a sensor driver.
-
-## How to Develop
-
-1. Register the acceleration sensor driver. The HDF provides a unified driver management model. The HDF identifies and loads the target module driver based on the configuration information of the acceleration sensor module.
-2. Initialize and deinitialize the acceleration sensor driver. Using the **init** function, the HDF starts loading the sensor device driver and allocating configuration resources for sensor device data, respectively. Using the **release** function, the HDF releases the resources and configurations loaded by the driver.
-3. Parse the configurations of the acceleration sensor register group. For different types of sensors, you need to configure their respective HCS configuration files in the HCS, check whether the sensor device is in position during the device driver startup, and then load the corresponding configuration file to generate the configuration structure object.
-4. Implement APIs for acceleration sensor driver operations. The driver APIs for various types of sensors, such as **init**, **GetInfo**, **Enable**, **Disable**, **SetBatch**, **SetMode**, **SetOption**, and **ReadSensorData**, are normalized to deliver sensor driver configurations and report sensor data.
-
-> **NOTE:**
->The sensor driver model provides a collection of APIs to implement sensor driver capabilities, including the driver device management capabilities, abstract bus and platform operation capabilities, general configuration capabilities, and configuration parsing capabilities. For details about the APIs, see [Table 2](sensor-driver-overview.md#table1156812588320). You need to implement the following APIs: some operations to perform on sensors \([Table 3](sensor-driver-overview.md#table1083014911336)\), differentiated data configuration of the sensor HCS, and verification of basic driver functions.
-
diff --git a/en/device-dev/driver/sensor-driver-overview.md b/en/device-dev/driver/sensor-driver-overview.md
deleted file mode 100644
index b3d5e86797f93b7c753fdece5fa02adb18f8fbba..0000000000000000000000000000000000000000
--- a/en/device-dev/driver/sensor-driver-overview.md
+++ /dev/null
@@ -1,244 +0,0 @@
-# Sensor Driver Overview
-
-- [Introduction](#section667413271505)
-- [Available APIs](#section7255104114110)
-
-## Introduction
-
-The sensor driver module provides APIs for upper-layer sensor services to implement basic sensor capabilities, including querying the sensor list, enabling or disabling a sensor, subscribing to or unsubscribing from sensor data, and setting sensor options. The sensor driver model is developed based on the Hardware Driver Foundation \(HDF\) and supports functions such as cross-OS migration and differentiated device configuration. The following figure shows the architecture of the sensor driver model.
-
-**Figure 1** Architecture of the sensor driver model
-
-
-The sensor driver model offers the following APIs:
-
-- Hardware Driver Interfaces \(HDIs\) for sensors: Facilitate service development.
-- APIs for implementing sensor driver model capabilities: Implement the capabilities of registering, loading, and unregistering sensor drivers as well as detecting sensor devices depending on the HDF, normalize APIs for sensor devices of the same type, and offer APIs for parsing register configurations, abstract APIs for bus access, and abstract platform APIs.
-- APIs to be implemented by developers: Based on the HDF Configuration Source \(HCS\), implement differentiated configuration for sensors of the same type and serialized configuration of sensor device parameters, and offer APIs for some sensor device operations to simplify sensor driver development.
-
-## Available APIs
-
-The following table lists the APIs provided by the sensor driver model.
-
-**Table 1** External APIs provided by the sensor driver model
-
-
-
Obtains information about all sensors in the system. The information about a sensor generally includes the sensor name, sensor vendor, firmware version, hardware version, sensor type ID, sensor ID, maximum measurement range, accuracy, and power.
-
-
-
Setting
-
-
int32_t Enable(int32_t sensorId)
-
-
Enables the sensor that has been subscribed to. The subscriber can obtain the sensor data only after the sensor is enabled.
-
-The following table lists the APIs provided by the sensor driver model for driver developers. You can directly call these APIs without any implementations.
-
-**Table 2** APIs provided by the sensor driver model for driver developers
-
-
-
Obtains basic configuration information such as sensor, bus, and attribute configurations based on the HCS resource configuration of the sensor device, and initializes the basic configuration data structure.
-
-The following table lists the APIs that need to be implemented by driver developers.
-
-**Table 3** APIs that need to be implemented by driver developers
-
-
-
Category
-
-
API
-
-
Description
-
-
-
-
Basic functions
-
-
int32_t init(void)
-
-
Initializes the configuration of a sensor device after it is detected successfully.
-
-
-
int32_t GetInfo(struct SensorBasicInfo *info)
-
-
Obtains the basic information about the current sensor device from the HCS of sensor devices.
-
-
-
int32_t Enable(void)
-
-
Enables the current sensor device by delivering the register configuration in the operation group based on the HCS of the current sensor device.
-
-
-
int32_t Disable(void)
-
-
Disables the current sensor device by delivering the register configuration in the operation group based on the HCS of the current sensor device.
Sets the processing time of the data reporting thread for the current sensor device based on the data sampling interval and data reporting interval.
-
-
-
int32_t SetMode(int32_t mode)
-
-
Sets the data reporting mode of the current sensor device.
-
-
-
int32_t SetOption(uint32_t option)
-
-
Sets the register configuration such as the measurement range and accuracy based on sensor options.
-
-
-
void ReadSensorData(void)
-
-
Reads sensor data.
-
-
-
-
-
-For details about the API implementation, see the [sensor driver development example](sensor-driver-development-example.md).
-
diff --git a/en/device-dev/driver/sensor-driver-test-guidelines.md b/en/device-dev/driver/sensor-driver-test-guidelines.md
deleted file mode 100644
index 042112036cdad78e9aa732e54c8423f8c3ed115e..0000000000000000000000000000000000000000
--- a/en/device-dev/driver/sensor-driver-test-guidelines.md
+++ /dev/null
@@ -1,82 +0,0 @@
-# Sensor Driver Test Guidelines
-
-After the driver is developed, you can develop self-test cases in the sensor unit test to verify the basic functions of the driver. The developer self-test platform is used as the test environment.
-
-```
-/* Specify whether to report sensor data. */
-static int32_t g_sensorDataFlag = 0;
-/* Retain the address of the sensor interface instance. */
-static const struct SensorInterface *g_sensorDev = nullptr;
-
-/* Register the data reporting function. */
-static int SensorTestDataCallback(struct SensorEvents *event)
-{
- if (event == nullptr) {
- return -1;
- }
- float *data = (float*)event->data;
- printf("time [%lld] sensor id [%d] x-[%f] y-[%f] z-[%f]\n\r", event->timestamp,
- event->sensorId, (*data), *(data + 1), *(data + g_axisZ));
- if (*data > 1e-5) {
- g_sensorDataFlag = 1;
- }
- return 0;
-}
-/* Initialize the sensor interface instance before executing the test cases. */
-void HdfSensorTest::SetUpTestCase()
-{
- g_sensorDev = NewSensorInterfaceInstance();
- if (g_sensorDev == nullptr) {
- printf("test sensorHdi get Module instace failed\n\r");
- }
-}
-/* Release case resources. */
-void HdfSensorTest::TearDownTestCase()
-{
- if (g_sensorDev != nullptr) {
- FreeSensorInterfaceInstance();
- g_sensorDev = nullptr;
- }
-}
-/* Verify the sensor driver. */
-HWTEST_F(HdfSensorTest,TestAccelDriver_001, TestSize.Level0)
-{
- int32_t sensorInterval = 1000000000; /* Data sampling interval, in nanoseconds */
- int32_t pollTime = 5; /* Data sampling duration, in seconds */
- int32_t accelSensorId = 1; /* Acceleration sensor type ID, which is 1 */
- int32_t count = 0;
- int ret;
- struct SensorInformation *sensorInfo = nullptr;
-
- ret = g_sensorDev->Register(SensorTestDataCallback)
- EXPECT_EQ(SENSOR_NULL_PTR, ret);
-
- ret = g_sensorDev->GetAllSensors(&sensorInfo, &count);
- EXPECT_EQ(0, ret);
- if (sensorInfo == nullptr) {
- EXPECT_NE(nullptr, sensorInfo);
- return;
- }
- /* Print the obtained sensor list. */
- for (int i = 0; i < count; i++) {
- printf("get sensoriId[%d], info name[%s]\n\r", sensorInfo[i]->sensorId, sensorInfo[i]->sensorName);
- }
- ret = g_sensorDev->Enable(accelSensorId);
- EXPECT_EQ(0, ret);
- g_sensorDataFlag = 0;
-
- ret = g_sensorDev->SetBatch(accelSensorId, sensorInterval, pollTime);
- EXPECT_EQ(0, ret);
- /* Observe the printed data within the period specified by pollTime. */
- OsalSleep(pollTime);
- EXPECT_EQ(1, g_sensorDataFlag);
-
- ret = g_sensorDev->Disable(accelSensorId);
- g_sensorDataFlag = 0;
- EXPECT_EQ(0, ret);
-
- ret = g_sensorDev->Unregister();
- EXPECT_EQ(0, ret);
-}
-```
-
diff --git a/en/device-dev/driver/sensor.md b/en/device-dev/driver/sensor.md
deleted file mode 100644
index f9e8d552c0cbad2c430e9457122a25b1d62ee4df..0000000000000000000000000000000000000000
--- a/en/device-dev/driver/sensor.md
+++ /dev/null
@@ -1,11 +0,0 @@
-# SENSOR
-
-- **[Sensor Driver Overview](sensor-driver-overview.md)**
-
-- **[Sensor Driver Development Guidelines](sensor-driver-development-guidelines.md)**
-
-- **[Sensor Driver Development Example](sensor-driver-development-example.md)**
-
-- **[Sensor Driver Test Guidelines](sensor-driver-test-guidelines.md)**
-
-
diff --git a/en/device-dev/driver/spi.md b/en/device-dev/driver/spi.md
deleted file mode 100644
index c635810c74cbb62be99562f6848983e4b7437058..0000000000000000000000000000000000000000
--- a/en/device-dev/driver/spi.md
+++ /dev/null
@@ -1,9 +0,0 @@
-# SPI
-
-- **[SPI Overview](spioverview.md)**
-
-- **[SPI Usage Guidelines](spiusage-guidelines.md)**
-
-- **[SPI Usage Example](spiusage-example.md)**
-
-
diff --git a/en/device-dev/driver/spioverview.md b/en/device-dev/driver/spioverview.md
deleted file mode 100644
index 46303b336baaec8295a11afacc466aed62809c29..0000000000000000000000000000000000000000
--- a/en/device-dev/driver/spioverview.md
+++ /dev/null
@@ -1,107 +0,0 @@
-# SPI Overview
-
-- [Introduction](#section9202632114011)
-- [Available APIs](#section1859594134119)
-
-## Introduction
-
-- Serial Peripheral Interface \(SPI\) is a serial bus specification used for high-speed, full-duplex, and synchronous communication.
-- SPI is developed by Motorola. It is commonly used for communication with flash memory, real-time clocks, sensors, and analog-to-digital \(A/D\) converters.
-- SPI works in controller/device mode. Generally, there is one SPI controller that controls one or more SPI devices. They are connected via four wires:
- - SCLK: clock signals output from the SPI controller
- - MOSI: data output from the SPI controller and input into an SPI device
- - MISO: data output from an SPI device and input into the SPI controller
- - CS: signals enabled by an SPI device and controlled by the SPI controller
-
-
-- [Figure 1](#fig15227181812587) shows the connection between one SPI controller and two SPI devices \(device A and device B\). In this figure, device A and device B share three pins \(SCLK, MISO, and MOSI\) of the controller. CS0 of device A and CS1 of device B are connected to CS0 and CS1 of the controller, respectively.
-
-**Figure 1** SPI controller/device connection
-
-
-
-
-- SPI communication is usually initiated by the SPI controller and is operated as follows:
-
-1. A single SPI device is selected at a time via the CS to communicate with the SPI controller.
-2. Clock signals are provided for the selected SPI device via the SCLK.
-3. The SPI controller sends data to SPI devices via the MOSI, and receives data from SPI devices via the MISO.
-
-- SPI can work in one of the following four modes, equivalent to one of the four possible states for Clock Polarity \(CPOL\) and Clock Phase \(CPHA\):
- - If both CPOL and CPHA are **0**, the clock signal level is low in the idle state and data is sampled on the first clock edge.
- - If CPOL is **0** and CPHA is **1**, the clock signal level is low in the idle state and data is sampled on the second clock edge.
- - If CPOL is **1** and CPHA is **0**, the clock signal level is high in the idle state and data is sampled on the first clock edge.
- - If both CPOL and CPHA are **1**, the clock signal level is high in the idle state and data is sampled on the second clock edge.
-
-
-- SPI defines a set of common functions for operating an SPI device, including those for:
- - Obtaining and releasing the handle of an SPI device.
- - Reading or writing data of a specified length from or into an SPI device.
- - Customizing data reading or writing via **SpiMsg**.
- - Obtaining and setting SPI device configuration parameters.
-
-
-> **NOTE:**
->Currently, these functions are only applicable in the communication initiated by the SPI controller.
-
-## Available APIs
-
-**Table 1** APIs for the SPI driver
-
-
-
Capability
-
-
Function
-
-
Description
-
-
-
-
SPI device handle obtaining/releasing
-
-
SpiOpen
-
-
Obtains an SPI device handle.
-
-
-
SpiClose
-
-
Releases an SPI device handle.
-
-
-
SPI reading/writing
-
-
SpiRead
-
-
Reads data of a specified length from an SPI device.
-
-
-
SpiWrite
-
-
Writes data of a specified length into an SPI device.
-
-
-
SpiTransfer
-
-
Transfers SPI data.
-
-
-
SPI device configuration
-
-
-
SpiSetCfg
-
-
Sets configuration parameters for an SPI device.
-
-
-
SpiGetCfg
-
-
Obtains configuration parameters of an SPI device.
-
-
-
-
-
-> **NOTE:**
->All functions provided in this document can be called only in kernel space.
-
diff --git a/en/device-dev/driver/spiusage-example.md b/en/device-dev/driver/spiusage-example.md
deleted file mode 100644
index f3d6cb2b6f667233355952efa8c7c91e780bc182..0000000000000000000000000000000000000000
--- a/en/device-dev/driver/spiusage-example.md
+++ /dev/null
@@ -1,70 +0,0 @@
-# SPI Usage Example
-
-The following is a usage example of an SPI device, including how to obtain an SPI device handle, set the configuration parameters, and then read or write data from or into the SPI device, and finally destroy the SPI device handle.
-
-```
-#include "hdf_log.h"
-#include "spi_if.h"
-
-void SpiTestSample(void)
-{
- int32_t ret;
- struct SpiCfg cfg; /* SPI device configuration information */
- struct SpiDevInfo spiDevinfo; /* SPI device descriptor */
- DevHandle spiHandle = NULL; /* SPI device handle */
- struct SpiMsg msg; /* Custom message to be transferred */
- uint8_t rbuff[4] = { 0 };
- uint8_t wbuff[4] = { 0x12, 0x34, 0x56, 0x78 };
- uint8_t wbuff2[4] = { 0xa1, 0xb2, 0xc3, 0xd4 };
-
- spiDevinfo.busNum = 0; /* SPI device bus number */
- spiDevinfo.csNum = 0; /* SPI device CS number */
- spiHandle = SpiOpen(&spiDevinfo); /* Obtain an SPI device handle based on spiDevinfo. */
- if (spiHandle == NULL) {
- HDF_LOGE("SpiOpen: failed\n");
- return;
- }
- /* Obtain configuration parameters of an SPI device. */
- ret = SpiGetCfg(spiHandle, &cfg);
- if (ret != 0) {
- HDF_LOGE("SpiGetCfg: failed, ret %d\n", ret);
- goto err;
- }
- cfg.maxSpeedHz = 115200; /* Change the maximum clock frequency to 115200. */
- cfg.bitsPerWord = 8; /* Change the word width to 8 bits. */
- /* Set configuration parameters for an SPI device. */
- ret = SpiSetCfg(spiHandle, &cfg);
- if (ret != 0) {
- HDF_LOGE("SpiSetCfg: failed, ret %d\n", ret);
- goto err;
- }
- /* Write specified length of data into an SPI device. */
- ret = SpiWrite(spiHandle, wbuff, 4);
- if (ret != 0) {
- HDF_LOGE("SpiWrite: failed, ret %d\n", ret);
- goto err;
- }
- /* Read data of a specified length from an SPI device. */
- ret = SpiRead(spiHandle, rbuff, 4);
- if (ret != 0) {
- HDF_LOGE("SpiRead: failed, ret %d\n", ret);
- goto err;
- }
- msg.wbuf = wbuff2; /* Pointer to the data to write */
- msg.rbuf = rbuff; /* Pointer to the data to read */
- msg.len = 4; /* The length of the data to be read or written is 4 bits. */
- msg.csChange = 1; /* Disable the CS before the next transfer. */
- msg.delayUs = 0; /* No delay before the next transfer */
- msg.speed = 115200; /* Speed of this transfer */
- /* Launch a custom transfer. The number of messages to be transferred is 1. */
- ret = SpiTransfer(spiHandle, &msg, 1);
- if (ret != 0) {
- HDF_LOGE("SpiTransfer: failed, ret %d\n", ret);
- goto err;
- }
-err:
- /* Destroy the SPI device handle. */
- SpiClose(spiHandle);
-}
-```
-
diff --git a/en/device-dev/driver/spiusage-guidelines.md b/en/device-dev/driver/spiusage-guidelines.md
deleted file mode 100644
index f5f9c482c055005b3544881cf16ef8e4e197abc3..0000000000000000000000000000000000000000
--- a/en/device-dev/driver/spiusage-guidelines.md
+++ /dev/null
@@ -1,386 +0,0 @@
-# SPI Usage Guidelines
-
-- [How to Use](#section691514116412)
-- [Obtaining an SPI Device Handle](#section12372204616215)
-- [Obtaining SPI Device Configuration Parameters](#section17121446171311)
-- [Setting SPI Device Configuration Parameters](#section97691946634)
-- [Performing SPI Communication](#section197116254416)
-- [Destroying the SPI Device Handle](#section117661819108)
-
-## How to Use
-
-[Figure 1](#fig23885455594) shows the process of using an SPI device.
-
-**Figure 1** Process of using an SPI device
-
-
-
-
-## Obtaining an SPI Device Handle
-
-Before performing SPI communication, obtain an SPI device handle by calling **SpiOpen**. This function returns an SPI device handle with a specified bus number and CS number.
-
-DevHandle SpiOpen\(const struct SpiDevInfo \*info\);
-
-**Table 1** Description of **SpiOpen**
-
-
-
Parameter
-
-
Description
-
-
-
info
-
-
Pointer to the SPI device descriptor.
-
-
-
Return Value
-
-
Description
-
-
-
NULL
-
-
Failed to obtain an SPI device handle.
-
-
-
Device handle
-
-
Returns the pointer to the SPI device handle.
-
-
-
-
-
-The following example shows how to obtain an SPI device handle based on the assumption that both the bus number and CS number of the SPI device are **0**.
-
-```
-struct SpiDevInfo spiDevinfo; /* SPI device descriptor */
-DevHandle spiHandle = NULL; /* SPI device handle */
-spiDevinfo.busNum = 0; /* SPI device bus number */
-spiDevinfo.csNum = 0; /* SPI device CS number */
-
-/* Obtain an SPI device handle. */
-spiHandle = SpiOpen(&spiDevinfo);
-if (spiHandle == NULL) {
- HDF_LOGE("SpiOpen: failed\n");
- return;
-}
-```
-
-## Obtaining SPI Device Configuration Parameters
-
-After obtaining the SPI device handle, obtain the SPI device configuration parameters by calling the following function:
-
-int32\_t SpiGetCfg\(DevHandle handle, struct SpiCfg \*cfg\);
-
-**Table 2** Description of **SpiGetCfg**
-
-
-
Parameter
-
-
Description
-
-
-
handle
-
-
Pointer to the SPI device handle.
-
-
-
cfg
-
-
Pointer to SPI device configuration parameters.
-
-
-
Return Value
-
-
Description
-
-
-
0
-
-
Succeeded in obtaining SPI device configuration parameters.
-
-
-
Negative value
-
-
Failed to obtain SPI device configuration parameters.
-
-
-
-
-
-```
-int32_t ret;
-struct SpiCfg cfg = {0}; /* SPI configuration information */
-ret = PalSpiSetCfg(spiHandle, &cfg); /* Set SPI device configuration parameters. */
-if (ret != 0) {
- HDF_LOGE("SpiGetCfg: failed, ret %d\n", ret);
-}
-```
-
-## Setting SPI Device Configuration Parameters
-
-After obtaining the SPI device handle, set SPI device configuration parameters by calling the following function:
-
-int32\_t SpiSetCfg\(DevHandle handle, struct SpiCfg \*cfg\);
-
-**Table 3** Description of **SpiSetCfg**
-
-
-
Parameter
-
-
Description
-
-
-
handle
-
-
Pointer to the SPI device handle.
-
-
-
cfg
-
-
Pointer to SPI device configuration parameters.
-
-
-
Return Value
-
-
Description
-
-
-
0
-
-
Succeeded in setting SPI device configuration parameters.
-
-
-
Negative value
-
-
Failed to set SPI device configuration parameters.
-
-
-
-
-
-```
-int32_t ret;
-struct SpiCfg cfg = {0}; /* SPI configuration information */
-cfg.mode = SPI_MODE_LOOP; /* Communicate in loopback mode. */
-cfg.comMode = PAL_SPI_POLLING_TRANSFER; /* Communicate in polling mode. */
-cfg.maxSpeedHz = 115200; /* Maximum transmission frequency */
-cfg.bitsPerWord = 8; /* The width of per word to be read or written is 8 bits. */
-ret = SpiSetCfg(spiHandle, &cfg); /* Set SPI device configuration parameters. */
-if (ret != 0) {
- HDF_LOGE("SpiSetCfg: failed, ret %d\n", ret);
-}
-```
-
-## Performing SPI Communication
-
-- Writing data of a specified length into an SPI device
-
-To write data into an SPI device only once, call the following function:
-
-int32\_t SpiWrite\(DevHandle handle, uint8\_t \*buf, uint32\_t len\);
-
-**Table 4** Description of **SpiWrite**
-
-
-
Parameter
-
-
Description
-
-
-
handle
-
-
Pointer to the SPI device handle.
-
-
-
buf
-
-
Pointer to the data to write.
-
-
-
len
-
-
Length of the data to write.
-
-
-
Return Value
-
-
Description
-
-
-
0
-
-
Succeeded in writing data into an SPI device.
-
-
-
Negative value
-
-
Failed to write data into an SPI device.
-
-
-
-
-
-```
-int32_t ret;
-uint8_t wbuff[4] = {0x12, 0x34, 0x56, 0x78};
-/* Write data of a specified length into an SPI device. */
-ret = SpiWrite(spiHandle, wbuff, 4);
-if (ret != 0) {
- HDF_LOGE("SpiWrite: failed, ret %d\n", ret);
-}
-```
-
-- Reading data of a specified length from an SPI device
-
-To read data from an SPI device only once, call the following function:
-
-int32\_t SpiRead\(DevHandle handle, uint8\_t \*buf, uint32\_t len\);
-
-**Table 5** Description of **SpiRead**
-
-
-
Parameter
-
-
Description
-
-
-
handle
-
-
Pointer to the SPI device handle.
-
-
-
buf
-
-
Pointer to the data to read.
-
-
-
len
-
-
Length of the data to read.
-
-
-
Return Value
-
-
Description
-
-
-
0
-
-
Succeeded in reading data from an SPI device.
-
-
-
Negative value
-
-
Failed to read data from an SPI device.
-
-
-
-
-
-```
-int32_t ret;
-uint8_t rbuff[4] = {0};
-/* Read data of a specified length from an SPI device. */
-ret = SpiRead(spiHandle, rbuff, 4);
-if (ret != 0) {
- HDF_LOGE("SpiRead: failed, ret %d\n", ret);
-}
-```
-
-- Launching a custom transfer
-
-To launch a custom transfer, call the following function:
-
-int32\_t SpiTransfer\(DevHandle handle, struct SpiMsg \*msgs, uint32\_t count\);
-
-**Table 6** Description of **SpiTransfer**
-
-
-
Parameter
-
-
Description
-
-
-
handle
-
-
Pointer to the SPI device handle.
-
-
-
msgs
-
-
Pointer to the message array to be transferred.
-
-
-
count
-
-
Length of the message array.
-
-
-
Return Value
-
-
Description
-
-
-
0
-
-
Succeeded in launching the custom transfer.
-
-
-
Negative value
-
-
Failed to launch the custom transfer.
-
-
-
-
-
-```
-int32_t ret;
-uint8_t wbuff[1] = {0x12};
-uint8_t rbuff[1] = {0};
-struct SpiMsg msg; /* Custom message to be transferred */
-msg.wbuf = wbuff; /* Pointer to the data to read */
-msg.rbuf = rbuff; /* Pointer to the data to read */
-msg.len = 1; /* The length of the data to be read or written is 1 bit. */
-msg.csChange = 1; /* Disable the CS before the next transfer. */
-msg.delayUs = 0; /* No delay before the next transfer */
-msg.speed = 115200; /* Speed of this transfer */
-/* Launch a custom transfer. The number of messages to be transferred is 1. */
-ret = SpiTransfer(spiHandle, &msg, 1);
-if (ret != 0) {
- HDF_LOGE("SpiTransfer: failed, ret %d\n", ret);
-}
-```
-
-## Destroying the SPI Device Handle
-
-After the SPI communication, destroy the SPI device handle by calling the following function:
-
-void SpiClose\(DevHandle handle\);
-
-This function will release the resources previously obtained.
-
-**Table 7** Description of **SpiClose**
-
-
-
Parameter
-
-
Description
-
-
-
handle
-
-
Pointer to the SPI device handle
-
-
-
-
-
-```
-PalHandleDestroy(spiHandle); /* Destroy the SPI device handle. */
-```
-
diff --git a/en/device-dev/driver/touchscreen.md b/en/device-dev/driver/touchscreen.md
deleted file mode 100644
index 49b35d23fb1f1ea0438f92292ae22e794a155dbb..0000000000000000000000000000000000000000
--- a/en/device-dev/driver/touchscreen.md
+++ /dev/null
@@ -1,9 +0,0 @@
-# TOUCHSCREEN
-
-- **[Touchscreen Overview](touchscreenoverview.md)**
-
-- **[Touchscreen Development Guidelines](touchscreendevelopment-guidelines.md)**
-
-- **[Touchscreen Development Example](touchscreendevelopment-example.md)**
-
-
diff --git a/en/device-dev/driver/touchscreendevelopment-example.md b/en/device-dev/driver/touchscreendevelopment-example.md
deleted file mode 100644
index 8d49343af5e1b1c2e1aaaa1fc113d75f2dc8a540..0000000000000000000000000000000000000000
--- a/en/device-dev/driver/touchscreendevelopment-example.md
+++ /dev/null
@@ -1,300 +0,0 @@
-# Touchscreen Development Example
-
-- [Device Description Configuration](#section85281142102317)
-- [Board-level Hardware Configuration and Private Data Configuration](#section189081946192410)
-- [Adding the Touchscreen Driver](#section19856687253)
-
-This example describes how to develop the touchscreen driver.
-
-## Device Description Configuration
-
-The information about modules of the input driver model is shown as follows and enables the HDF to load the modules in sequence. For details, see [Driver Development](driver-development.md).
-
-```
-input :: host {
- hostName = "input_host";
- priority = 100;
- device_input_manager :: device {
- device0 :: deviceNode {
- policy = 2; // Publish services externally.
- priority = 100; // Loading priority. The input device manager in the input driver has the highest priority.
- preload = 0; // Value 0 indicates that the driver is to be loaded, and value 1 indicates the opposite.
- permission = 0660;
- moduleName = "HDF_INPUT_MANAGER";
- serviceName = "input_dev_manager";
- deviceMatchAttr = "";
- }
- }
- device_hdf_touch :: device {
- device0 :: deviceNode {
- policy = 2;
- priority = 120;
- preload = 0;
- permission = 0660;
- moduleName = "HDF_TOUCH";
- serviceName = "event1";
- deviceMatchAttr = "touch_device1";
- }
- }
-
- device_touch_chip :: device {
- device0 :: deviceNode {
- policy = 0;
- priority = 130;
- preload = 0;
- permission = 0660;
- moduleName = "HDF_TOUCH_SAMPLE";
- serviceName = "hdf_touch_sample_service";
- deviceMatchAttr = "zsj_sample_5p5";
- }
- }
-}
-```
-
-## Board-level Hardware Configuration and Private Data Configuration
-
-The following describes the configuration of the board-level hardware and private data of the touchscreen. You can modify the configuration based on the service requirements.
-
-```
-root {
- input_config {
- touchConfig {
- touch0 {
- boardConfig {
- match_attr = "touch_device1";
- inputAttr {
- inputType = 0; // Value 0 indicates that the input device is a touchscreen.
- solutionX = 480;
- solutionY = 960;
- devName = "main_touch"; // Device name
- }
- busConfig {
- busType = 0; // Value 0 indicates the I2C bus.
- busNum = 6;
- clkGpio = 86;
- dataGpio = 87;
- i2cClkIomux = [0x114f0048, 0x403]; // Register configuration of the i2c_clk pin
- i2cDataIomux = [0x114f004c, 0x403]; // Register configuration of the i2c_data pin
- }
- pinConfig {
- rstGpio = 3;
- intGpio = 4;
- rstRegCfg = [0x112f0094, 0x400]; // Register configuration of the reset pin
- intRegCfg = [0x112f0098, 0x400]; // Register configuration of the interrupt pin
- }
- powerConfig {
- vccType = 2; // Values 1, 2, and 3 indicate the low-dropout regulator (LDO), GPIO, and PMIC, respectively.
- vccNum = 20; // The GPIO number is 20.
- vccValue = 1800; // The voltage amplitude is 1800 mV.
- vciType = 1;
- vciNum = 12;
- vciValue = 3300;
- }
- featureConfig {
- capacitanceTest = 0;
- gestureMode = 0;
- gloverMOde = 0;
- coverMode = 0;
- chargerMode = 0;
- knuckleMode = 0;
- }
- }
- chipConfig {
- template touchChip {
- match_attr = "";
- chipName = "sample";
- vendorName = "zsj";
- chipInfo = "AAAA11222"; // The first four characters indicate the product name. The fifth and sixth characters indicate the IC model. The last three characters indicate the chip model.
- busType = 0;
- deviceAddr = 0x5D;
- irqFlag = 2; // Values 1 and 2 indicate that the interrupt is triggered on the rising and falling edges, respectively. Values 4 and 8 indicate that the interrupt is triggered by the high and low levels, respectively.
- maxSpeed = 400;
- chipVersion = 0;
- powerSequence {
- /* Power-on sequence is described as follows:
- [Type, status, direction, delay]
- Value 0 indicates the power or pin is empty. Values 1 and 2 indicate the VCC (1.8 V) and VCI (3.3 V) power, respectively. Values 3 and 4 indicate the reset and interrupt pins, respectively.
- Values 0 and 1 indicate the power-off or pull-down, and the power-on or pull-up, respectively. Value 2 indicates that no operation is performed.
- Values 0 and 1 indicate the input and output directions, respectively. Value 2 indicates that no operation is performed.
- Delay time, in milliseconds.
- */
- powerOnSeq = [4, 0, 1, 0,
- 3, 0, 1, 10,
- 3, 1, 2, 60,
- 4, 2, 0, 0];
- suspendSeq = [3, 0, 2, 10];
- resumeSeq = [3, 1, 2, 10];
- powerOffSeq = [3, 0, 2, 10,
- 1, 0, 2, 20];
- }
- }
- chip0 :: touchChip {
- match_attr = "zsj_sample_5p5";
- chipInfo = "ZIDN45100";
- chipVersion = 0;
- }
- }
- }
- }
- }
-}
-```
-
-## Adding the Touchscreen Driver
-
-The following example shows how to implement the differentiated APIs provided by the platform driver to obtain and parse the touchscreen data. You can adjust the development process based on the board and touchscreen in use.
-
-```
-/* Parse the touch reporting data read from the touchscreen into coordinates. */
-static void ParsePointData(ChipDevice *device, FrameData *frame, uint8_t *buf, uint8_t pointNum)
-{
- int32_t resX = device->driver->boardCfg->attr.resolutionX;
- int32_t resY = device->driver->boardCfg->attr.resolutionY;
-
- for (int32_t i = 0; i < pointNum; i++) {
- frame->fingers[i].y = (buf[GT_POINT_SIZE * i + GT_X_LOW] & ONE_BYTE_MASK) |
- ((buf[GT_POINT_SIZE * i + GT_X_HIGH] & ONE_BYTE_MASK) << ONE_BYTE_OFFSET);
- frame->fingers[i].x = (buf[GT_POINT_SIZE * i + GT_Y_LOW] & ONE_BYTE_MASK) |
- ((buf[GT_POINT_SIZE * i + GT_Y_HIGH] & ONE_BYTE_MASK) << ONE_BYTE_OFFSET);
- frame->fingers[i].valid = true;
- }
-}
-/* Obtain the touch reporting data from the chip. */
-static int32_t ChipDataHandle(ChipDevice *device)
-{
- int32_t ret;
- uint8_t touchStatus = 0;
- uint8_t pointNum;
- uint8_t buf[GT_POINT_SIZE * MAX_SUPPORT_POINT] = {0};
- InputI2cClient *i2cClient = &device->driver->i2cClient;
- uint8_t reg[GT_ADDR_LEN] = {0};
- FrameData *frame = &device->driver->frameData;
- reg[0] = (GT_BUF_STATE_ADDR >> ONE_BYTE_OFFSET) & ONE_BYTE_MASK;
- reg[1] = GT_BUF_STATE_ADDR & ONE_BYTE_MASK;
- ret = InputI2cRead(i2cClient, reg, GT_ADDR_LEN, &touchStatus, 1);
- if (ret < 0 || touchStatus == GT_EVENT_INVALID) {
- return HDF_FAILURE;
- }
- OsalMutexLock(&device->driver->mutex);
- (void)memset_s(frame, sizeof(FrameData), 0, sizeof(FrameData));
- if (touchStatus == GT_EVENT_UP) {
- frame->realPointNum = 0;
- frame->definedEvent = TOUCH_UP;
- goto exit;
- }
- reg[0] = (GT_X_LOW_BYTE_BASE >> ONE_BYTE_OFFSET) & ONE_BYTE_MASK;
- reg[1] = GT_X_LOW_BYTE_BASE & ONE_BYTE_MASK;
- pointNum = touchStatus & GT_FINGER_NUM_MASK;
- if (pointNum <= 0 || pointNum > MAX_SUPPORT_POINT) {
- HDF_LOGE("%s: pointNum is invalid, %d", __func__, pointNum);
- (void)ChipCleanBuffer(i2cClient);
- OsalMutexUnlock(&device->driver->mutex);
- return HDF_FAILURE;
- }
- frame->realPointNum = pointNum;
- frame->definedEvent = TOUCH_DOWN;
- /* Read the touch reporting data from the register. */
- (void)InputI2cRead(i2cClient, reg, GT_ADDR_LEN, buf, GT_POINT_SIZE * pointNum);
- /* Parse the touch reporting data. */
- ParsePointData(device, frame, buf, pointNum);
-exit:
- OsalMutexUnlock(&device->driver->mutex);
- if (ChipCleanBuffer(i2cClient) != HDF_SUCCESS) {
- return HDF_FAILURE;
- }
- return HDF_SUCCESS;
-}
-
-static struct TouchChipOps g_sampleChipOps = {
- .Init = ChipInit,
- .Detect = ChipDetect,
- .Resume = ChipResume,
- .Suspend = ChipSuspend,
- .DataHandle = ChipDataHandle,
-};
-
-static TouchChipCfg *ChipConfigInstance(struct HdfDeviceObject *device)
-{
- TouchChipCfg *chipCfg = (TouchChipCfg *)OsalMemAlloc(sizeof(TouchChipCfg));
- if (chipCfg == NULL) {
- HDF_LOGE("%s: instance chip config failed", __func__);
- return NULL;
- }
- (void)memset_s(chipCfg, sizeof(TouchChipCfg), 0, sizeof(TouchChipCfg));
- /* Parse the private configuration of the touchscreen. */
- if (ParseTouchChipConfig(device->property, chipCfg) != HDF_SUCCESS) {
- HDF_LOGE("%s: parse chip config failed", __func__);
- OsalMemFree(chipCfg);
- chipCfg = NULL;
- }
- return chipCfg;
-}
-
-static ChipDevice *ChipDeviceInstance(void)
-{
- ChipDevice *chipDev = (ChipDevice *)OsalMemAlloc(sizeof(ChipDevice));
- if (chipDev == NULL) {
- HDF_LOGE("%s: instance chip device failed", __func__);
- return NULL;
- }
- (void)memset_s(chipDev, sizeof(ChipDevice), 0, sizeof(ChipDevice));
- return chipDev;
-}
-
-static void FreeChipConfig(TouchChipCfg *config)
-{
- if (config->pwrSeq.pwrOn.buf != NULL) {
- OsalMemFree(config->pwrSeq.pwrOn.buf);
- }
- if (config->pwrSeq.pwrOff.buf != NULL) {
- OsalMemFree(config->pwrSeq.pwrOff.buf);
- }
- OsalMemFree(config);
-}
-
-static int32_t HdfSampleChipInit(struct HdfDeviceObject *device)
-{
- TouchChipCfg *chipCfg = NULL;
- ChipDevice *chipDev = NULL;
- HDF_LOGE("%s: enter", __func__);
- if (device == NULL) {
- return HDF_ERR_INVALID_PARAM;
- }
- /* Parse the private configuration of the touchscreen. */
- chipCfg = ChipConfigInstance(device);
- if (chipCfg == NULL) {
- return HDF_ERR_MALLOC_FAIL;
- }
- /* Instantiate the touchscreen device. */
- chipDev = ChipDeviceInstance();
- if (chipDev == NULL) {
- goto freeCfg;
- }
- chipDev->chipCfg = chipCfg;
- chipDev->ops = &g_sampleChipOps;
- chipDev->chipName = chipCfg->chipName;
- chipDev->vendorName = chipCfg->vendorName;
-
- /* Register the touchscreen device with the platform driver. */
- if (RegisterChipDevice(chipDev) != HDF_SUCCESS) {
- goto freeDev;
- }
- HDF_LOGI("%s: exit succ, chipName = %s", __func__, chipCfg->chipName);
- return HDF_SUCCESS;
-
-freeDev:
- OsalMemFree(chipDev);
-freeCfg:
- FreeChipConfig(chipCfg);
- return HDF_FAILURE;
-}
-
-struct HdfDriverEntry g_touchSampleChipEntry = {
- .moduleVersion = 1,
- .moduleName = "HDF_TOUCH_SAMPLE",
- .Init = HdfSampleChipInit,
-};
-
-HDF_INIT(g_touchSampleChipEntry);
-```
-
diff --git a/en/device-dev/driver/touchscreendevelopment-guidelines.md b/en/device-dev/driver/touchscreendevelopment-guidelines.md
deleted file mode 100644
index 9e1543c1e668c4bdc8aa62be3073a6539ff5f1de..0000000000000000000000000000000000000000
--- a/en/device-dev/driver/touchscreendevelopment-guidelines.md
+++ /dev/null
@@ -1,35 +0,0 @@
-# Touchscreen Development Guidelines
-
-- [How to Develop](#section1255740132616)
-
-Regardless of the OS and system on a chip \(SoC\), the input driver is developed based on the HDF, platform, and OSAL APIs to provide a unified driver model for touchscreen devices.
-
-- The following uses the touchscreen driver as an example to describe the loading process of the input driver model:
- - Add the touchscreen driver-related descriptions: You can add the touchscreen driver-related descriptions, such as the loading priority, board-level hardware information, and private data, by referring to the existing template.
-
- - Load the input device manager driver: The HDF automatically loads the input device manager driver, which then creates the device manager and initializes it.
-
- - Load the touchscreen common driver: The HDF automatically loads the touchscreen common driver, which then parses the board-level configuration, initializes the hardware, and provides the API for registering the touchscreen.
-
- - Load the touchscreen chip driver: The HDF automatically loads the touchscreen chip driver, which then instantiates the touchscreen device, parses the private data, and implements differentiated APIs provided by the platform.
-
- - Register the touchscreen device with the platform driver: Register the instantiated touchscreen device with the platform driver, bind this device to the platform driver, and complete touchscreen initialization such as interrupt registration and power-on and power-off.
-
- - Register the input device: Instantiate the input device and register it with the input manager after the touchscreen is initialized.
-
-
-## How to Develop
-
-1. Add the touchscreen driver-related descriptions.
-
- Currently, the input driver is developed based on the HDF and is loaded and started by the HDF. Register the driver information, such as whether to load the driver and the loading priority in the configuration file. Then, the HDF starts the registered driver modules one by one. For details about the driver configuration, see [How to Develop](driver-development.md#section1969312275533).
-
-2. Complete the board-level configuration and private data configuration of the touchscreen.
-
- Configure the required I/O pins. For example, configure a register for the I2C pin reserved for the touchscreen to use I2C for transmitting data.
-
-3. Implement differentiated adaptation APIs of the touchscreen.
-
- Use the platform APIs to perform operations for the reset pins, interrupt pins and power based on the communications interfaces designed for boards. For details about the GPIO-related operations, see [GPIO Usage Guidelines](gpiousage-guidelines.md).
-
-
diff --git a/en/device-dev/driver/touchscreenoverview.md b/en/device-dev/driver/touchscreenoverview.md
deleted file mode 100644
index b136894e5ade080a07e5ff457b20fd74eefd33b9..0000000000000000000000000000000000000000
--- a/en/device-dev/driver/touchscreenoverview.md
+++ /dev/null
@@ -1,71 +0,0 @@
-# Touchscreen Overview
-
-- [Introduction](#section124332411260)
-- [Available APIs](#section10542625172618)
-
-## Introduction
-
-- **Functions of the Touchscreen driver**
-
- The Touchscreen driver is used to power on its integrated circuit \(IC\), configure and initialize hardware pins, register interrupts, configure Inter-Integrated Circuit \(I2C\) or SPI APIs, set input-related configurations, and download and update firmware.
-
-
-- **Layers of the Touchscreen driver**
-
- This section describes how to develop the touchscreen driver based on the input driver model. [Figure 1](#fig6251184817261) shows an overall architecture of the touchscreen driver.
-
- The input driver is developed based on the hardware driver foundation \(HDF\), platform APIs, and operating system abstraction layer \(OSAL\) APIs. It provides hardware driver capabilities through the input Hardware Driver Interfaces \(HDIs\) for upper-layer input services to control the touchscreen.
-
-
-**Figure 1** Architecture of the input driver model
-
-
-- **Input driver model**
-
- The input driver model mainly consists of the device manager, common drivers, and chip drivers. The platform data channel provides capabilities for sending data generated by the touchscreen from the kernel to the user space. The driver model adapts to different touchscreen devices and hardware platforms via the configuration file, improving the efficiency of the touchscreen development. The description for each part of the input driver model is as follows:
-
- - Input device manager: provides various input device drivers with the APIs for registering or unregistering input devices and manages the input device list.
-
- - Input common driver: provides common abstract drivers \(such as the touchscreen common driver\) of various input devices for initializing the board-level hardware, processing hardware interrupts, and registering input devices with the input device manager.
-
- - Input chip driver: provides different chip drivers of each vendor. You can minimize the workload for the input chip driver development by calling differentiated APIs reserved by the input platform driver.
-
- - Event hub: provides a unified data reporting channel, which enables various input devices to report input events.
-
- - HDF input config: parses and manages the board-level configuration as well as the private configuration of input devices.
-
-
-- **Advantages of developing drivers based on the HDF**
-
- The touchscreen driver is developed based on the HDF and is implemented via calls to the OSAL and platform APIs, including bus APIs and OS native APIs \(such as memory, lock, thread, and timer\). The OSAL and platform APIs hide the differences of underlying hardware, so that the touchscreen driver can be migrated across platforms and OSs. In this regard, you can develop the touchscreen driver only once but deploy it on multiple devices.
-
-
-## Available APIs
-
-Based on the attributes of the pins, interfaces on the touchscreens can be classified into the following types:
-
-- Power interfaces
-- I/O control interfaces
-- Communications interfaces
-
-**Figure 2** Common pins of the touchscreen
-
-
-The interfaces shown in the figure are described as follows:
-
-1. **Power interfaces**
- - LDO\_1P8: 1.8 V digital circuits
- - LDO\_3P3: 3.3 V analog circuits
-
- Generally, the touchscreen driver IC is separated from the LCD driver IC. In this case, the touchscreen driver IC requires both 1.8 V and 3.3 V power supplies. Nowadays, the touchscreen driver IC and LCD driver IC can be integrated. Therefore, the touchscreen, requires only the 1.8 V power supply, and the 3.3 V power required internally is supplied by the LCD VSP power \(typical value: 5.5 V\) in the driver IC.
-
-
-2. **I/O control interfaces**
- - RESET: reset pin, which is used to reset the driver IC on the host when suspending or resuming the system.
- - INT: interrupt pin, which needs to be set to the input direction and pull-up status during driver initialization. After detecting an external touch signal, the driver triggers the interrupt by operating the interrupt pin. The driver reads the touch reporting data in the ISR function.
-
-3. **Communications interfaces**
- - I2C: Since only a small amount of touch data is reported by the touchscreen, I2C is used to transmit the reported data. For details about the I2C protocol and interfaces, see [I2C Usage Guidelines](i2c-usage-guidelines.md).
- - SPI: In addition to touch reporting data coordinates, some vendors need to obtain basic capacitance data. Therefore, Serial Peripheral Interface \(SPI\) is used to transmit such huge amount of data. For details about the SPI protocol and interfaces, see [SPI Usage Guidelines](spiusage-guidelines.md).
-
-
diff --git a/en/device-dev/driver/uart.md b/en/device-dev/driver/uart.md
deleted file mode 100644
index 9abd98bb4e661a01011d233577ae4109bcdd208e..0000000000000000000000000000000000000000
--- a/en/device-dev/driver/uart.md
+++ /dev/null
@@ -1,9 +0,0 @@
-# UART
-
-- **[UART Overview](uartoverview.md)**
-
-- **[UART Usage Guidelines](uartusage-guidelines.md)**
-
-- **[UART Usage Example](uartusage-example.md)**
-
-
diff --git a/en/device-dev/driver/uartoverview.md b/en/device-dev/driver/uartoverview.md
deleted file mode 100644
index 2238f2ca5564f4f1faa35bf16590c51a6492ad07..0000000000000000000000000000000000000000
--- a/en/device-dev/driver/uartoverview.md
+++ /dev/null
@@ -1,106 +0,0 @@
-# UART Overview
-
-- [Introduction](#section14770623164917)
-- [Available APIs](#section149505462492)
-
-## Introduction
-
-- The Universal Asynchronous Receiver/Transmitter \(UART\) is a universal serial data bus used for asynchronous communication. It enables bi-directional communication between devices in full-duplex mode.
-- UART is widely used to print information for debugging or to connect to various external modules such as GPS and Bluetooth.
-- A UART is connected to other modules through two wires \(as shown in [Figure 1](#fig209936401896)\) or four wires \(as shown in [Figure 2](#fig1435614171015)\).
- - TX: TX pin of the transmitting UART. It is connected to the RX pin of the peer UART.
- - RX: RX pin of the receiving UART. It is connected to the TX pin of the peer UART.
- - RTS: Request to Send signal pin. It is connected to the CTS pin of the peer UART and is used to indicate whether the local UART is ready to receive data.
- - CTS: Clear to Send signal pin. It is connected to the RTS pin of the peer UART and is used to indicate whether the local UART is allowed to send data to the peer end.
-
- **Figure 1** 2-wire UART communication
-
-
- 
-
- **Figure 2** 4-wire UART communication
-
-
- 
-
-
-- The transmitting and receiving UARTs must ensure that they have the same settings on particular attributes such as the baud rate and data format \(start bit, data bit, parity bit, and stop bit\) before they start to communicate. During data transmission, a UART sends data to the peer end over the TX pin and receives data from the peer end over the RX pin. When the size of the buffer used by a UART for storing received data reaches the preset threshold, the RTS signal of the UART changes to **1** \(data cannot be received\), and the peer UART stops sending data to it because its CTS signal does not allow it to send data.
-- The UART interface defines a set of common functions for operating a UART port, including obtaining and releasing device handles, reading and writing data of a specified length, and obtaining and setting the baud rate, as well as the device attributes.
-
-## Available APIs
-
-**Table 1** APIs for the UART driver
-
-
-
Capability
-
-
Function
-
-
Description
-
-
-
-
Obtaining and releasing device handles
-
-
-
UartOpen
-
-
Obtains the UART device handle.
-
-
-
UartClose
-
-
Releases a specified UART device handle.
-
-
-
Reading and writing data
-
-
-
UartRead
-
-
Reads data of a specified length from a UART device.
-
-
-
UartWrite
-
-
Writes data of a specified length into a UART device.
-
-
-
Obtaining and setting the baud rate
-
-
UartGetBaud
-
-
Obtains the UART baud rate.
-
-
-
UartSetBaud
-
-
Sets the UART baud rate.
-
-
-
Obtaining and setting device attributes
-
-
-
UartGetAttribute
-
-
Obtains the UART device attributes.
-
-
-
UartSetAttribute
-
-
Sets the UART device attributes.
-
-
-
Setting the transmission mode
-
-
UartSetTransMode
-
-
Sets the UART transmission mode.
-
-
-
-
-
-> **NOTE:**
->All functions provided in this document can be called only in kernel space.
-
diff --git a/en/device-dev/driver/uartusage-example.md b/en/device-dev/driver/uartusage-example.md
deleted file mode 100644
index 32572d405213dc537c54c2dafdd7c1902e64a048..0000000000000000000000000000000000000000
--- a/en/device-dev/driver/uartusage-example.md
+++ /dev/null
@@ -1,67 +0,0 @@
-# UART Usage Example
-
-The following is a usage example of a UART device, including how to obtain the UART device handle, set the baud rate, device attributes, and transmission mode, read data from or write data into the UART device, and then destroy the UART device handle.
-
-```
-#include "hdf_log.h"
-#include "uart_if.h"
-
-void UartTestSample(void)
-{
- int32_t ret;
- uint32_t port;
- DevHandle handle = NULL;
- uint8_t wbuff[5] = { 1, 2, 3, 4, 5 };
- uint8_t rbuff[5] = { 0 };
- struct UartAttribute attribute;
- attribute.dataBits = UART_ATTR_DATABIT_7; /* Set the number of data bits to 7. */
- attribute.parity = UART_ATTR_PARITY_NONE; /* Set the parity bit to no parity. */
- attribute.stopBits = UART_ATTR_STOPBIT_1; /* Set the stop bit to 1. */
- attribute.rts = UART_ATTR_RTS_DIS; /* Disable the RTS signal. */
- attribute.cts = UART_ATTR_CTS_DIS; /* Disable the CTS signal. */
- attribute.fifoRxEn = UART_ATTR_RX_FIFO_EN; /* Enable RX FIFO. */
- attribute.fifoTxEn = UART_ATTR_TX_FIFO_EN; /* Enable TX FIFO. */
- /* Set the UART port number actually used. */
- port = 1;
- /* Obtain the UART device handle. */
- handle = UartOpen(port);
- if (handle == NULL) {
- HDF_LOGE("UartOpen: failed!\n");
- return;
- }
- /* Set the UART baud rate to 9600. */
- ret = UartSetBaud(handle, 9600);
- if (ret != 0) {
- HDF_LOGE("UartSetBaud: failed, ret %d\n", ret);
- goto _ERR;
- }
- /* Set the UART device attributes. */
- ret = UartSetAttribute(handle, &attribute);
- if (ret != 0) {
- HDF_LOGE("UartSetAttribute: failed, ret %d\n", ret);
- goto _ERR;
- }
- /* Set the UART transmission mode to non-blocking mode. */
- ret = UartSetTransMode(handle, UART_MODE_RD_NONBLOCK);
- if (ret != 0) {
- HDF_LOGE("UartSetTransMode: failed, ret %d\n", ret);
- goto _ERR;
- }
- /* Write 5-byte data into the UART device. */
- ret = UartWrite(handle, wbuff, 5);
- if (ret != 0) {
- HDF_LOGE("UartWrite: failed, ret %d\n", ret);
- goto _ERR;
- }
- /* Read 5-byte data from the UART device. */
- ret = UartRead(handle, rbuff, 5);
- if (ret < 0) {
- HDF_LOGE("UartRead: failed, ret %d\n", ret);
- goto _ERR;
- }
-_ERR:
- /* Destroy the UART device handle. */
- UartClose(handle);
-}
-```
-
diff --git a/en/device-dev/driver/uartusage-guidelines.md b/en/device-dev/driver/uartusage-guidelines.md
deleted file mode 100644
index edd894e92db887d324ef8b51934c720791bb8b5e..0000000000000000000000000000000000000000
--- a/en/device-dev/driver/uartusage-guidelines.md
+++ /dev/null
@@ -1,506 +0,0 @@
-# UART Usage Guidelines
-
-- [How to Use](#section47784125013)
-- [Obtaining a UART Device Handle](#section146445153110)
-- [Setting the UART Baud Rate](#section1862705516339)
-- [Obtaining the UART Baud Rate](#section1263651563414)
-- [Setting the UART Device Attributes](#section1770091483814)
-- [Obtaining UART Device Attributes](#section117543316384)
-- [Setting the UART Transmission Mode](#section187233112369)
-- [Writing Data of a Specified Length into a UART Device](#section82416423368)
-- [Reading Data of a Specified Length from a UART Device](#section192177171373)
-- [Destroying the UART Device Handle](#section63131236354)
-
-## How to Use
-
-[Figure 1](#fig1852173020185) shows the process of using a UART device.
-
-**Figure 1** Process of using a UART device
-
-
-
-
-## Obtaining a UART Device Handle
-
-Before performing UART communication, call **UartOpen** to obtain a UART device handle. This function returns the pointer to the UART device handle with a specified port number.
-
-DevHandle UartOpen\(uint32\_t port\);
-
-**Table 1** Description of **UartOpen**
-
-
-
Parameter
-
-
Description
-
-
-
-
port
-
-
UART port number.
-
-
-
Return Value
-
-
Description
-
-
-
NULL
-
-
Failed to obtain the UART device handle.
-
-
-
Device handle
-
-
Pointer to the UART device handle.
-
-
-
-
-
-The following example shows how to obtain a UART device handle based on the assumption that the UART port number is **3**:
-
-```
-DevHandle handle = NULL; /* The UART device handle */
-uint32_t port = 3; /* UART port number */
-handle = UartOpen(port);
-if (handle == NULL) {
- HDF_LOGE("UartOpen: failed!\n");
- return;
-}
-```
-
-## Setting the UART Baud Rate
-
-After obtaining the UART device handle, set the UART baud rate by calling the following function:
-
-int32\_t UartSetBaud\(DevHandle handle, uint32\_t baudRate\);
-
-**Table 2** Description of **UartSetBaud**
-
-
-
Parameter
-
-
Description
-
-
-
-
handle
-
-
Pointer to the UART device handle.
-
-
-
baudRate
-
-
Baud rate of the UART to set.
-
-
-
Return Value
-
-
Description
-
-
-
0
-
-
Succeeded in setting the UART baud rate.
-
-
-
Negative value
-
-
Failed to set the UART baud rate.
-
-
-
-
-
-The following example shows how to set the UART baud rate to **9600**:
-
-```
-int32_t ret;
-/* Set the UART baud rate to 9600. */
-ret = UartSetBaud(handle, 9600);
-if (ret != 0) {
- HDF_LOGE("UartSetBaud: failed, ret %d\n", ret);
-}
-```
-
-## Obtaining the UART Baud Rate
-
-After setting the UART baud rate, obtain the current baud rate by calling the following function:
-
-int32\_t UartGetBaud\(DevHandle handle, uint32\_t \*baudRate\);
-
-**Table 3** Description of **UartGetBaud**
-
-
-
Parameter
-
-
Description
-
-
-
-
handle
-
-
Pointer to the UART device handle.
-
-
-
baudRate
-
-
Pointer to the UART baud rate.
-
-
-
Return Value
-
-
Description
-
-
-
0
-
-
Succeeded in obtaining the UART baud rate.
-
-
-
Negative value
-
-
Failed to obtain the UART baud rate.
-
-
-
-
-
-The following example shows how to obtain the UART baud rate:
-
-```
-int32_t ret;
-uint32_t baudRate;
-/* Obtain the UART baud rate. */
-ret = UartGetBaud(handle, &baudRate);
-if (ret != 0) {
- HDF_LOGE("UartGetBaud: failed, ret %d\n", ret);
-}
-```
-
-## Setting the UART Device Attributes
-
-Before performing UART communication, set the UART device attributes by calling the following function:
-
-int32\_t UartSetAttribute\(DevHandle handle, struct UartAttribute \*attribute\);
-
-**Table 4** Description of **UartSetAttribute**
-
-
-
Parameter
-
-
Description
-
-
-
-
handle
-
-
Pointer to the UART device handle.
-
-
-
attribute
-
-
Pointer to the UART device attributes to set.
-
-
-
Return Value
-
-
Description
-
-
-
0
-
-
Succeeded in setting the UART device attributes.
-
-
-
Negative value
-
-
Failed to set the UART device attributes.
-
-
-
-
-
-The following example shows how to set the UART device attributes:
-
-```
-int32_t ret;
-struct UartAttribute attribute;
-attribute.dataBits = UART_ATTR_DATABIT_7; /* Set the number of data bits to 7. */
-attribute.parity = UART_ATTR_PARITY_NONE; /* Set the parity bit to no parity. */
-attribute.stopBits = UART_ATTR_STOPBIT_1; /* Set the stop bit to 1. */
-attribute.rts = UART_ATTR_RTS_DIS; /* Disable the RTS signal. */
-attribute.cts = UART_ATTR_CTS_DIS; /* Disable the CTS signal. */
-attribute.fifoRxEn = UART_ATTR_RX_FIFO_EN; /* Enable RX FIFO. */
-attribute.fifoTxEn = UART_ATTR_TX_FIFO_EN; /* Enable TX FIFO. */
-/* Set the UART device attributes. */
-ret = UartSetAttribute(handle, &attribute);
-if (ret != 0) {
- HDF_LOGE("UartSetAttribute: failed, ret %d\n", ret);
-}
-```
-
-## Obtaining UART Device Attributes
-
-After setting the UART device attributes, obtain the current device attributes by calling the following function:
-
-int32\_t UartGetAttribute\(DevHandle handle, struct UartAttribute \*attribute\);
-
-**Table 5** Description of **UartGetAttribute**
-
-
-
Parameter
-
-
Description
-
-
-
-
handle
-
-
Pointer to the UART device handle.
-
-
-
attribute
-
-
Pointer to the UART device attributes.
-
-
-
Return Value
-
-
Description
-
-
-
0
-
-
Succeeded in obtaining the UART device attributes.
-
-
-
Negative value
-
-
Failed to obtain the UART device attributes.
-
-
-
-
-
-The following example shows how to obtain the UART device attributes:
-
-```
-int32_t ret;
-struct UartAttribute attribute;
-/* Obtain the UART attributes. */
-ret = UartGetAttribute(handle, &attribute);
-if (ret != 0) {
- HDF_LOGE("UartGetAttribute: failed, ret %d\n", ret);
-}
-```
-
-## Setting the UART Transmission Mode
-
-Before performing UART communication, set the UART transmission mode by calling the following function:
-
-int32\_t UartSetTransMode\(DevHandle handle, enum UartTransMode mode\);
-
-**Table 6** Description of **UartSetTransMode**
-
-
-
Parameter
-
-
Description
-
-
-
-
handle
-
-
Pointer to the UART device handle.
-
-
-
mode
-
-
UART transmission mode to set.
-
-
-
Return Value
-
-
Description
-
-
-
0
-
-
Succeeded in setting the UART transmission mode.
-
-
-
Negative value
-
-
Failed to set the UART transmission mode.
-
-
-
-
-
-The following example shows how to set the transmission mode to **UART\_MODE\_RD\_BLOCK**:
-
-```
-int32_t ret;
-/* Set the UART transmission mode. */
-ret = UartSetTransMode(handle, UART_MODE_RD_BLOCK);
-if (ret != 0) {
- HDF_LOGE("UartSetTransMode: failed, ret %d\n", ret);
-}
-```
-
-## Writing Data of a Specified Length into a UART Device
-
-To write data into a UART device, call the following function:
-
-int32\_t UartWrite\(DevHandle handle, uint8\_t \*data, uint32\_t size\);
-
-**Table 7** Description of **UartWrite**
-
-
-
Parameter
-
-
Description
-
-
-
-
handle
-
-
Pointer to the UART device handle.
-
-
-
data
-
-
Pointer to the data to write.
-
-
-
size
-
-
Length of the data to write.
-
-
-
Return Value
-
-
Description
-
-
-
0
-
-
Succeeded in writing data into the UART device.
-
-
-
Negative value
-
-
Failed to write data into the UART device.
-
-
-
-
-
-The following example shows how to write data of a specified length into the UART device:
-
-```
-int32_t ret;
-uint8_t wbuff[5] = {1, 2, 3, 4, 5};
-/* Write 5-byte data into the UART device. */
-ret = UartWrite(handle, wbuff, 5);
-if (ret != 0) {
- HDF_LOGE("UartWrite: failed, ret %d\n", ret);
-}
-```
-
-## Reading Data of a Specified Length from a UART Device
-
-To read data from a UART device, call the following function:
-
-int32\_t UartRead\(DevHandle handle, uint8\_t \*data, uint32\_t size\);
-
-**Table 8** Description of **UartRead**
-
-
-
Parameter
-
-
Description
-
-
-
-
handle
-
-
Pointer to the UART device handle.
-
-
-
data
-
-
Pointer to the buffer for receiving the data.
-
-
-
size
-
-
Length of the data to read.
-
-
-
Return Value
-
-
Description
-
-
-
Non-negative value
-
-
Length of the data read from the UART device.
-
-
-
Negative value
-
-
Failed to read data from the UART device.
-
-
-
-
-
-The following example shows how to read data of a specified length from the UART device:
-
-```
-int32_t ret;
-uint8_t rbuff[5] = {0};
-/* Read 5-byte data from the UART device. */
-ret = UartRead(handle, rbuff, 5);
-if (ret < 0) {
- HDF_LOGE("UartRead: failed, ret %d\n", ret);
-}
-```
-
-> **CAUTION:**
->Data is successfully read from the UART device if a non-negative value is returned. If the return value is **0**, no valid data can be read from the UART device. If the return value is greater than **0**, the return value is the length of the data actually read from the UART device. The length is less than or equal to the value of **size** and does not exceed the maximum length of data to read at a time specified by the UART controller in use.
-
-## Destroying the UART Device Handle
-
-After the UART communication, destroy the UART device handle by calling the following function:
-
-void UartClose\(DevHandle handle\);
-
-This function will release the resources previously obtained.
-
-**Table 9** Description of **UartClose**
-
-
-
Parameter
-
-
Description
-
-
-
-
handle
-
-
Pointer to the UART device handle
-
-
-
-
-
-The following example shows how to destroy the UART device handle:
-
-```
-UartClose(handle); /* Destroy the UART device handle. */
-```
-
diff --git a/en/device-dev/driver/usage-example.md b/en/device-dev/driver/usage-example.md
deleted file mode 100644
index e16e8f2eeadcc12bd537fa8655692af0e88c9893..0000000000000000000000000000000000000000
--- a/en/device-dev/driver/usage-example.md
+++ /dev/null
@@ -1,98 +0,0 @@
-# Usage Example
-
-The following is an example of using a MIPI DSI device:
-
-```
-#include "hdf.h"
-#include "mipi_dsi_if.h"
-
-void PalMipiDsiTestSample(void)
-{
- uint8_t chnId;
- int32_t ret;
- DevHandle handle = NULL;
-
- /* Device channel ID */
- chnId = 0;
- /* Obtain the MIPI DSI device handle based on a specified channel ID. */
- handle = MipiDsiOpen(chnId);
- if (handle == NULL) {
- HDF_LOGE("MipiDsiOpen: failed!\n");
- return;
- }
- /* MIPI DSI configuration parameters */
- struct MipiCfg cfg = {0};
- cfg.lane = DSI_4_LANES;
- cfg.mode = DSI_CMD_MODE;
- cfg.burstMode = VIDEO_NON_BURST_MODE_SYNC_EVENTS;
- cfg.format = FORMAT_RGB_24_BIT;
- cfg.pixelClk = 174;
- cfg.phyDataRate = 384;
- cfg.timingInfo.hsaPixels = 50;
- cfg.timingInfo.hbpPixels = 55;
- cfg.timingInfo.hlinePixels = 1200;
- cfg.timingInfo.yResLines = 1800;
- cfg.timingInfo.vbpLines = 33;
- cfg.timingInfo.vsaLines = 76;
- cfg.timingInfo.vfpLines = 120;
- cfg.timingInfo.xResPixels = 1342;
- /* Set MIPI DSI configuration parameters. */
- ret = MipiDsiSetCfg(g_handle, &cfg);
- if (ret != 0) {
- HDF_LOGE("%s: SetMipiCfg fail! ret=%d\n", __func__, ret);
- return;
- }
- /* Send the command for initializing the PANEL register. */
- struct DsiCmdDesc *cmd = OsalMemCalloc(sizeof(struct DsiCmdDesc));
- if (cmd == NULL) {
- return;
- }
- cmd->dtype = DTYPE_DCS_WRITE;
- cmd->dlen = 1;
- cmd->payload = OsalMemCalloc(sizeof(uint8_t));
- if (cmd->payload == NULL) {
- HdfFree(cmd);
- return;
- }
- *(cmd->payload) = DTYPE_GEN_LWRITE;
- MipiDsiSetLpMode(mipiHandle);
- ret = MipiDsiTx(mipiHandle, cmd);
- MipiDsiSetHsMode(mipiHandle);
- if (ret != HDF_SUCCESS) {
- HDF_LOGE("%s: MipiDsiTx fail! ret=%d\n", __func__, ret);
- HdfFree(cmd->payload);
- HdfFree(cmd);
- return;
- }
- HdfFree(cmd->payload);
- HdfFree(cmd);
- /* Pointer to the register that reads the PANEL status */
- uint8_t readVal = 0;
- struct DsiCmdDesc *cmdRead = OsalMemCalloc(sizeof(struct DsiCmdDesc));
- if (cmdRead == NULL) {
- return;
- }
- cmdRead->dtype = DTYPE_DCS_READ;
- cmdRead->dlen = 1;
- cmdRead->payload = OsalMemCalloc(sizeof(uint8_t));
- if (cmdRead->payload == NULL) {
- HdfFree(cmdRead);
- return;
- }
- *(cmdRead->payload) = DDIC_REG_STATUS;
- MipiDsiSetLpMode(g_handle);
- ret = MipiDsiRx(g_handle, cmdRead, sizeof(readVal), &readVal);
- MipiDsiSetHsMode(g_handle);
- if (ret != HDF_SUCCESS) {
- HDF_LOGE("%s: MipiDsiRx fail! ret=%d\n", __func__, ret);
- HdfFree(cmdRead->payload);
- HdfFree(cmdRead);
- return;
- }
- HdfFree(cmdRead->payload);
- HdfFree(cmdRead);
- /* Release the MIPI DSI device handle. */
- MipiDsiClose(handle);
-}
-```
-
diff --git a/en/device-dev/driver/usage-guidelines.md b/en/device-dev/driver/usage-guidelines.md
deleted file mode 100644
index 1934eaf6e0bb68cb83d76d0114635f10f5ec59b7..0000000000000000000000000000000000000000
--- a/en/device-dev/driver/usage-guidelines.md
+++ /dev/null
@@ -1,365 +0,0 @@
-# Usage Guidelines
-
-- [How to Use](#section8982671284)
-- [Obtaining a MIPI DSI Device Handle](#section57982569176)
-- [Setting MIPI DSI Configuration Parameters](#section5935410201815)
-- [Sending/Receiving the Pointer to a Command](#section611661316194)
-- [Releasing the MIPI DSI Device Handle](#section217313211199)
-
-## How to Use
-
-[Figure 1](#fig99821771782) shows the process of using a MIPI DSI device.
-
-**Figure 1** Process of using a MIPI DSI device
-
-
-
-
-## Obtaining a MIPI DSI Device Handle
-
-Before performing MIPI DSI communication, obtain a MIPI DSI device handle by calling **MipiDsiOpen**. This function returns a MIPI DSI device handle with a specified channel ID.
-
-DevHandle MipiDsiOpen\(uint8\_t id\);
-
-**Table 1** Description of **MipiDsiOpen**
-
-
-
Parameter
-
-
Description
-
-
-
id
-
-
MIPI DSI channel ID.
-
-
-
Return Value
-
-
Description
-
-
-
NULL
-
-
Failed to obtain the MIPI DSI channel ID.
-
-
-
Device handle
-
-
MIPI DSI device handle with a specified channel ID, whose data type is DevHandle.
-
-
-
-
-
-The following example shows how to obtain a MIPI DSI device handle with the channel ID **0**:
-
-```
-DevHandle mipiDsiHandle = NULL; /* Device handle */
-chnId = 0; /* MIPI DSI channel ID */
-
-/* Obtain the MIPI DSI device handle based on a specified channel ID. */
-mipiDsiHandle = MipiDsiOpen(chnId);
-if (mipiDsiHandle == NULL) {
- HDF_LOGE("MipiDsiOpen: failed\n");
- return;
-}
-```
-
-## Setting MIPI DSI Configuration Parameters
-
-- Set MIPI DSI configuration parameters by calling the following function:
-
-int32\_t MipiDsiSetCfg\(DevHandle handle, struct MipiCfg \*cfg\);
-
-**Table 2** Description of **MipiDsiSetCfg**
-
-
-
Parameter
-
-
Description
-
-
-
handle
-
-
MIPI DSI device handle
-
-
-
cfg
-
-
Pointer to MIPI DSI configuration parameters
-
-
-
Return Value
-
-
Description
-
-
-
0
-
-
Succeeded in setting MIPI DSI configuration parameters.
-
-```
-MipiDsiClose(mipiHandle); /* Release the MIPI DSI device handle */
-```
-
diff --git a/en/device-dev/driver/watchdog.md b/en/device-dev/driver/watchdog.md
deleted file mode 100644
index b8f20d1dad97959da8207df5b166e177854a35a9..0000000000000000000000000000000000000000
--- a/en/device-dev/driver/watchdog.md
+++ /dev/null
@@ -1,9 +0,0 @@
-# WATCHDOG
-
-- **[Watchdog Overview](watchdogoverview.md)**
-
-- **[Watchdog Usage Guidelines](watchdogusage-guidelines.md)**
-
-- **[Watchdog Usage Example](watchdogusage-example.md)**
-
-
diff --git a/en/device-dev/driver/watchdogoverview.md b/en/device-dev/driver/watchdogoverview.md
deleted file mode 100644
index 04b3b373d03c4773f5bc45ba9ef3ca8cabc29a85..0000000000000000000000000000000000000000
--- a/en/device-dev/driver/watchdogoverview.md
+++ /dev/null
@@ -1,78 +0,0 @@
-# Watchdog Overview
-
-- [Introduction](#section3579126111816)
-- [Available APIs](#section17429111981812)
-
-## Introduction
-
-A watchdog, also called a watchdog timer, is a hardware timing device. If an error occurs in the main program of the system and fails to reset the watchdog timer, the watchdog timer sends a reset signal to restore the system to a normal state.
-
-## Available APIs
-
-**Table 1** Watchdog APIs
-
-
-
Capability
-
-
Function
-
-
Description
-
-
-
-
Open/Close
-
-
WatchdogOpen
-
-
Opens a watchdog.
-
-
-
WatchdogClose
-
-
Closes a watchdog.
-
-
-
Start/Stop
-
-
WatchdogStart
-
-
Starts a watchdog.
-
-
-
WatchdogStop
-
-
Stops a watchdog.
-
-
-
Timeout duration
-
-
WatchdogSetTimeout
-
-
Sets the watchdog timeout duration.
-
-
-
WatchdogGetTimeout
-
-
Obtains the watchdog timeout duration.
-
-
-
Status
-
-
WatchdogGetStatus
-
-
Obtains the watchdog status.
-
-
-
Feeding
-
-
WatchdogFeed
-
-
Feeds a watchdog, or resets a watchdog timer.
-
-
-
-
-
-> **NOTE:**
->All watchdog functions provided in this document can be called only in kernel mode.
-
diff --git a/en/device-dev/driver/watchdogusage-example.md b/en/device-dev/driver/watchdogusage-example.md
deleted file mode 100644
index 98f6acfa0e383b059ed257df8411ef03f3f9ee72..0000000000000000000000000000000000000000
--- a/en/device-dev/driver/watchdogusage-example.md
+++ /dev/null
@@ -1,86 +0,0 @@
-# Watchdog Usage Example
-
-This example provides a complete process for using a watchdog.
-
-In this example, open a watchdog, set the timeout duration, and start the watchdog.
-
-- Feed the watchdog periodically to ensure that the system is not reset due to timer expiry.
-- Stop feeding the watchdog and check whether the system is reset after the timer expires.
-
-Example:
-
-```
-#include "watchdog_if.h"
-#include "hdf_log.h"
-#include "osal_irq.h"
-#include "osal_time.h"
-
-#define WATCHDOG_TEST_TIMEOUT 2
-#define WATCHDOG_TEST_FEED_TIME 6
-
-static int32_t TestCaseWatchdog(void)
-{
- int32_t i;
- int32_t ret;
- uint32_t timeout;
- DevHandle handle = NULL;
-
- /* Open watchdog 0. */
- handle = WatchdogOpen(0);
- if (handle == NULL) {
- HDF_LOGE("Open watchdog fail!");
- return -1;
- }
-
- /* Set the timeout duration. */
- ret = WatchdogSetTimeout(handle, WATCHDOG_TEST_TIMEOUT);
- if (ret != HDF_SUCCESS) {
- HDF_LOGE("%s: set timeout fail! ret:%d\n", __func__, ret);
- WatchdogClose(handle);
- return ret;
- }
-
- /* Obtain the configured timeout duration. */
- ret = WatchdogGetTimeout(handle, &timeout);
- if (ret != HDF_SUCCESS) {
- HDF_LOGE("%s: get timeout fail! ret:%d\n", __func__, ret);
- WatchdogClose(handle);
- return ret;
- }
- HDF_LOGI("%s: read timeout back:%u\n", __func__, timeout);
-
- /* Start the watchdog. The timer starts. */
- ret = WatchdogStart(handle);
- if (ret != HDF_SUCCESS) {
- HDF_LOGE("%s: satrt fail! ret:%d\n", __func__, ret);
- WatchdogClose(handle);
- return ret;
- }
-
- /* Feed the watchdog every 1s. */
- for (i = 0; i < WATCHDOG_TEST_FEED_TIME; i++) {
- HDF_LOGE("%s: feeding watchdog %d times... \n", __func__, i);
- ret = WatchdogFeed(handle);
- if (ret != HDF_SUCCESS) {
- HDF_LOGE("%s: feed dog fail! ret:%d\n", __func__, ret);
- WatchdogClose(handle);
- return ret;
- }
- OsalSleep(1);
- }
- /* Because the interval for feeding the watchdog is shorter than the timeout duration, the system does not reset, and logs can be printed normally. */
- HDF_LOGE("%s: no reset ... feeding test OK!!!\n", __func__);
-
- /* Enable the timer to expire by stopping feeding the watchdog. */
- for (i = 0; i < WATCHDOG_TEST_FEED_TIME; i++) {
- HDF_LOGE("%s: watiting dog buck %d times... \n", __func__, i);
- OsalSleep(1);
- }
-
- /* The system resets when the timer expires. If the code is correct, the log below is not displayed. */
- HDF_LOGE("%s: dog has't buck!!! \n", __func__, i);
- WatchdogClose(handle);
- return -1;
-}
-```
-
diff --git a/en/device-dev/driver/watchdogusage-guidelines.md b/en/device-dev/driver/watchdogusage-guidelines.md
deleted file mode 100644
index e3eb5c091fb98497a9bc2f31dfe40cb69df93244..0000000000000000000000000000000000000000
--- a/en/device-dev/driver/watchdogusage-guidelines.md
+++ /dev/null
@@ -1,395 +0,0 @@
-# Watchdog Usage Guidelines
-
-- [How to Use](#section0719414187)
-- [Opening a Watchdog](#section198171379261)
-- [Obtaining the Watchdog Status](#section206592910275)
-- [Setting the Timeout Duration](#section19605128182714)
-- [Obtaining the Timeout Duration](#section11111516208)
-- [Starting a Watchdog](#section141174192814)
-- [Feeding a Watchdog](#section179101435113910)
-- [Stopping a Watchdog](#section15282123192816)
-- [Closing a Watchdog](#section7857850173411)
-
-## How to Use
-
-[Figure 1](#fig19134125410189) illustrates the process of using a watchdog.
-
-**Figure 1** Process of using a watchdog
-
-
-
-
-## Opening a Watchdog
-
-Use **WatchdogOpen** to open a watchdog. A system may have multiple watchdogs. You can open a specified watchdog by using the ID.
-
-int32\_t WatchdogOpen\(int16\_t wdtId\);
-
-.
-
-**Table 1** Description of WatchdogOpen
-
-
-
-
-The WLAN driver module provides APIs for driver developers, such as initializing/deregistering, opening/stopping a **NetDevice**, and obtaining the state of a **NetDevice**. [Table 2](#table74613501475) provides some APIs.
-
-**Table 2** APIs for driver developers of WLAN vendors to implement
-
-
-
-
-The WLAN driver provides the HDI layer with the APIs for creating and destroying an **IWiFi** object and setting the MAC address. [Table 3](#table141076311618) provides some APIs.
-
-**Table 3** APIs provided by the WLAN HAL module
-
-
-
-
-## Preparations
-
-Before using the Docker environment, perform the following operations:
-
-1. Install Docker. For details, see [Install Docker Engine](https://docs.docker.com/engine/install/).
-2. Obtain the OpenHarmony source code. For details, see [Source Code Acquisition](source-code-acquisition.md).
-
- > **NOTE:**
- >You do not need to obtain the source code for the HPM-based Docker environment.
-
-
-## Standalone Docker Environment
-
-The Docker image of OpenHarmony is hosted on [HUAWEI CLOUD SWR](https://console.huaweicloud.com/swr/?region=cn-south-1&locale=en-us#/app/warehouse/warehouseMangeDetail/goldensir/openharmony-docker/openharmony-docker?type=ownImage). Using the Docker image will help simplify environment configurations needed for the building. The following describes the detailed procedure.
-
-### Setting Up the Docker Environment for Mini-System Devices \(reference memory ≥ 128 KB\) and Small-System Devices \(reference memory ≥ 1 MB\)
-
-**Method 1: Obtaining the Docker image from HUAWEI CLOUD SWR**
-
-1. Obtain the Docker image.
-
- ```
- docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:0.0.5
- ```
-
-2. Go to the root directory of OpenHarmony code and run the following command to access the Docker build environment:
-
- Run the following command in Ubuntu:
-
- ```
- docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:0.0.5
- ```
-
- Run the following command in Windows \(assuming that the source code directory is **D:\\OpenHarmony**\):
-
- ```
- docker run -it -v D:\OpenHarmony:/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:0.0.5
- ```
-
-
-**Method 2: Using the Dockerfile to Build a Local Docker Image**
-
-1. Obtain the Dockerfile script for a local Docker image.
-
- ```
- git clone https://gitee.com/openharmony/docs.git
- ```
-
-2. Go to the directory of the Dockerfile code and run the following command to build the Docker image:
-
- ```
- cd docs/docker
- ./build.sh
- ```
-
-3. Go to the root directory of OpenHarmony code and run the following command to access the Docker build environment:
-
- Run the following command in Ubuntu:
-
- ```
- docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:0.0.5
- ```
-
- Run the following command in Windows \(assuming that the source code directory is **D:\\OpenHarmony**\):
-
- ```
- docker run -it -v D:\OpenHarmony:/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:0.0.5
- ```
-
-
-### Building for Mini-System Devices \(reference memory ≥ 128 KB\) and Small-System Devices \(reference memory ≥ 1 MB\)
-
-The following uses the Hi3516 platform as an example to describe the build procedure.
-
-Set the build path to the current path.
-
-```
-hb set
- .
-```
-
-**Figure 1** Setting page
-
-
-
-
-> **NOTE:**
->The mapping between the development board and the building GUI:
->- Hi3861: wifiiot\_hispark\_pegasus@hisilicon
->- Hi3516: ipcamera\_hispark\_taurus@hisilicon
->- Hi3518: ipcamera\_hispark\_aries@hisilicon
-
-1. Select **ipcamera\_hispark\_taurus@hisilicon** and press **Enter**.
-2. Start building.
-
- ```
- hb build -f
- ```
-
-3. View the build result.
-
- The files will be generated in the **out/hispark\_taurus/ipcamera\_hispark\_taurus** directory.
-
-
-### Setting Up the Docker Environment for Standard-System Devices \(reference memory ≥ 128 MB\)
-
-**Method 1: Obtaining the Docker image from HUAWEI CLOUD SWR**
-
-1. Obtain the Docker image.
-
- ```
- docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker-standard:0.0.1
- ```
-
-2. Go to the root directory of OpenHarmony code and run the following command to access the Docker build environment:
-
- ```
- docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker-standard:0.0.1
- ```
-
-
-**Method 2: Using the Dockerfile to Build a Local Docker Image**
-
-1. Obtain the Dockerfile script for a local Docker image.
-
- ```
- git clone https://gitee.com/openharmony/docs.git
- ```
-
-2. Go to the directory of the Dockerfile code and run the following command to build the Docker image:
-
- ```
- cd docs/docker/standard
- ./build.sh
- ```
-
-3. Go to the root directory of OpenHarmony code and run the following command to access the Docker build environment:
-
- ```
- docker run -it -v $(pwd):/home/openharmony openharmony-docker-standard:0.0.1
- ```
-
-
-### Building for Standard-System Devices \(reference memory ≥ 128 MB\)
-
-1. Run the preprocessing script in the root directory of the source code.
-
- ```
- ../scripts/prepare.sh
- ```
-
-2. Run the following script to start building for standard-system devices \(reference memory ≥ 128 MB\).
-
- ```
- ./build.sh --product-name {product_name}
- ```
-
- **product\_name** indicates the platform supported by the current distribution, for example, Hi3516D V300.
-
- Files generated during building are stored in the **out/ohos-arm-release/** directory, and the generated image is stored in the **out/ohos-arm-release/packages/phone/images/** directory.
-
-
-> **NOTE:**
->You can exit Docker by simply running the **exit** command.
-
-## HPM-based Docker Environment
-
-**docker\_dist** is a template component in the [HPM](https://hpm.harmonyos.com/#/en/home) system. It helps to quickly initialize an HPM project and use the Docker image to quickly build a distribution of OpenHarmony, greatly simplifying environment configurations needed for building. After configuring the Ubuntu and [hpm-cli](https://device.harmonyos.com/en/docs/develop/bundles/oem_bundle_guide_prepare-0000001050129846) development environments, perform the following steps to access the Docker environment:
-
-### Setting Up the Docker Environment
-
-1. Initialize the installation template by running the following command in any of the working directories:
-
- ```
- hpm init -t @ohos/docker_dist
- ```
-
-2. Modify the **publishAs** field.
-
- The obtained bundle is of the template type. Open the **bundle.json** file in the current directory and change the value of **publishAs** from **template** to **distribution** as needed.
-
-
-### Obtaining and Building Source Code
-
-Start building. Docker can be automatically installed only in Ubuntu. If you are using any other operating system, manually install Docker before pulling the image.
-
-- **Automatically Installing Docker \(Ubuntu\)**
-
- Running the following command will automatically install Docker, pull the Docker image, and start the pulling and building of the corresponding solution in the container.
-
- **Method 1:**
-
- Add a parameter to specify the solution. For example:
-
- ```
- hpm run docker solution={product}
- ```
-
- **\{product\}** indicates the solution, for example, **@ohos/hispark\_taurus**, **@ohos/hispark\_aries**, and **@ohos/hispark\_pegasus**.
-
- **Method 2:**
-
- Set an environment variable to specify the solution, and then run the build command.
-
- 1. Select the desired solution.
-
- ```
- export solution={product}
- ```
-
- **\{product\}** indicates the solution, for example, **@ohos/hispark\_taurus**, **@ohos/hispark\_aries**, and **@ohos/hispark\_pegasus**.
-
- 2. Obtain and build the source code.
-
- ```
- hpm run docker
- ```
-
-
- This example uses the **@ohos/hispark\_taurus** solution for illustration. If the execution is successful, the output is as follows:
-
- ```
- ...
- ohos ipcamera_hispark_taurus build success!
- @ohos/hispark_taurus: distribution building completed.
- ```
-
-
-- **Manually Installing Docker \(Non-Ubuntu\)**
-
- Perform the following operations to install Docker:
-
- ```
- # Pull the image.
- docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:0.0.3# Compile the Docker image in the Linux environment.
- hpm run distWithDocker solution={product}
- # When using Windows, make sure to configure the Git Bash.
- hpm config set shellPath "Git Bash path"
- hpm run distWithDocker solution={product}
- ```
-
-
diff --git a/en/device-dev/get-code/figures/3.png b/en/device-dev/get-code/figure/3-22.png
similarity index 100%
rename from en/device-dev/get-code/figures/3.png
rename to en/device-dev/get-code/figure/3-22.png
diff --git a/en/device-dev/get-code/figures/en-us_image_0000001101413884.png b/en/device-dev/get-code/figure/en-us_image_0000001101413884.png
similarity index 100%
rename from en/device-dev/get-code/figures/en-us_image_0000001101413884.png
rename to en/device-dev/get-code/figure/en-us_image_0000001101413884.png
diff --git a/en/device-dev/get-code/figures/en-us_image_0000001119755646.png b/en/device-dev/get-code/figure/en-us_image_0000001119755646.png
similarity index 100%
rename from en/device-dev/get-code/figures/en-us_image_0000001119755646.png
rename to en/device-dev/get-code/figure/en-us_image_0000001119755646.png
diff --git a/en/device-dev/get-code/figures/en-us_image_0000001119915556.png b/en/device-dev/get-code/figure/en-us_image_0000001119915556.png
similarity index 100%
rename from en/device-dev/get-code/figures/en-us_image_0000001119915556.png
rename to en/device-dev/get-code/figure/en-us_image_0000001119915556.png
diff --git a/en/device-dev/get-code/figures/en-us_image_0000001166715379.png b/en/device-dev/get-code/figure/en-us_image_0000001166715379.png
similarity index 100%
rename from en/device-dev/get-code/figures/en-us_image_0000001166715379.png
rename to en/device-dev/get-code/figure/en-us_image_0000001166715379.png
diff --git a/en/device-dev/get-code/gettools-acquire.md b/en/device-dev/get-code/gettools-acquire.md
new file mode 100644
index 0000000000000000000000000000000000000000..453cce21c04f24a2a64605a38e8f5f433ffe6994
--- /dev/null
+++ b/en/device-dev/get-code/gettools-acquire.md
@@ -0,0 +1,313 @@
+# Docker Environment
+
+- [Introduction](#section107932281315)
+- [Preparations](#section7337134183512)
+- [Standalone Docker Environment](#section2858536103611)
+ - [Setting Up the Docker Environment for Mini-System Devices \(reference memory ≥ 128 KB\) and Small-System Devices \(reference memory ≥ 1 MB\)](#section319412277287)
+ - [Building for Mini-System Devices \(reference memory ≥ 128 KB\) and Small-System Devices \(reference memory ≥ 1 MB\)](#section631485163615)
+ - [Setting Up the Docker Environment for Standard-System Devices \(reference memory ≥ 128 MB\)](#section13585262391)
+ - [Building for Standard-System Devices \(reference memory ≥ 128 MB\)](#section193711513406)
+
+- [HPM-based Docker Environment](#section485713518337)
+ - [Setting Up the Docker Environment](#section3295842510)
+ - [Obtaining and Building Source Code](#section69141039143518)
+
+
+## Introduction
+
+OpenHarmony provides the following two types of Docker environments for you to quickly get the development environment ready:
+
+- Standalone Docker environment: applicable when using Ubuntu or Windows to build a distribution
+- HPM-based Docker environment: applicable when using the HarmonyOS Package Manager \(HPM\) to build a distribution
+
+**Table 1** Docker image
+
+
+
+
+## Preparations
+
+Before using the Docker environment, perform the following operations:
+
+1. Install Docker. For details, see [Install Docker Engine](https://docs.docker.com/engine/install/).
+2. Obtain the OpenHarmony source code. For details, see [Source Code Acquisition](sourcecode-acquire.md).
+
+ > **NOTE:**
+ >You do not need to obtain the source code for the HPM-based Docker environment.
+
+
+## Standalone Docker Environment
+
+The Docker image of OpenHarmony is hosted on [HUAWEI CLOUD SWR](https://console.huaweicloud.com/swr/?region=cn-south-1&locale=en-us#/app/warehouse/warehouseMangeDetail/goldensir/openharmony-docker/openharmony-docker?type=ownImage). Using the Docker image will help simplify environment configurations needed for the building. The following describes the detailed procedure.
+
+### Setting Up the Docker Environment for Mini-System Devices \(reference memory ≥ 128 KB\) and Small-System Devices \(reference memory ≥ 1 MB\)
+
+**Method 1: Obtaining the Docker image from HUAWEI CLOUD SWR**
+
+1. Obtain the Docker image.
+
+ ```
+ docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:0.0.5
+ ```
+
+2. Go to the root directory of OpenHarmony code and run the following command to access the Docker build environment:
+
+ Run the following command in Ubuntu:
+
+ ```
+ docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:0.0.5
+ ```
+
+ Run the following command in Windows \(assuming that the source code directory is **D:\\OpenHarmony**\):
+
+ ```
+ docker run -it -v D:\OpenHarmony:/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:0.0.5
+ ```
+
+
+**Method 2: Using the Dockerfile to Build a Local Docker Image**
+
+1. Obtain the Dockerfile script for a local Docker image.
+
+ ```
+ git clone https://gitee.com/openharmony/docs.git
+ ```
+
+2. Go to the directory of the Dockerfile code and run the following command to build the Docker image:
+
+ ```
+ cd docs/docker
+ ./build.sh
+ ```
+
+3. Go to the root directory of OpenHarmony code and run the following command to access the Docker build environment:
+
+ Run the following command in Ubuntu:
+
+ ```
+ docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:0.0.5
+ ```
+
+ Run the following command in Windows \(assuming that the source code directory is **D:\\OpenHarmony**\):
+
+ ```
+ docker run -it -v D:\OpenHarmony:/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:0.0.5
+ ```
+
+
+### Building for Mini-System Devices \(reference memory ≥ 128 KB\) and Small-System Devices \(reference memory ≥ 1 MB\)
+
+The following uses the Hi3516 platform as an example to describe the build procedure.
+
+Set the build path to the current path.
+
+```
+hb set
+ .
+```
+
+**Figure 1** Setting page
+
+
+
+
+> **NOTE:**
+>The mapping between the development board and the building GUI:
+>- Hi3861: wifiiot\_hispark\_pegasus@hisilicon
+>- Hi3516: ipcamera\_hispark\_taurus@hisilicon
+>- Hi3518: ipcamera\_hispark\_aries@hisilicon
+
+1. Select **ipcamera\_hispark\_taurus@hisilicon** and press **Enter**.
+2. Start building.
+
+ ```
+ hb build -f
+ ```
+
+3. View the build result.
+
+ The files will be generated in the **out/hispark\_taurus/ipcamera\_hispark\_taurus** directory.
+
+
+### Setting Up the Docker Environment for Standard-System Devices \(reference memory ≥ 128 MB\)
+
+**Method 1: Obtaining the Docker image from HUAWEI CLOUD SWR**
+
+1. Obtain the Docker image.
+
+ ```
+ docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker-standard:0.0.1
+ ```
+
+2. Go to the root directory of OpenHarmony code and run the following command to access the Docker build environment:
+
+ ```
+ docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker-standard:0.0.1
+ ```
+
+
+**Method 2: Using the Dockerfile to Build a Local Docker Image**
+
+1. Obtain the Dockerfile script for a local Docker image.
+
+ ```
+ git clone https://gitee.com/openharmony/docs.git
+ ```
+
+2. Go to the directory of the Dockerfile code and run the following command to build the Docker image:
+
+ ```
+ cd docs/docker/standard
+ ./build.sh
+ ```
+
+3. Go to the root directory of OpenHarmony code and run the following command to access the Docker build environment:
+
+ ```
+ docker run -it -v $(pwd):/home/openharmony openharmony-docker-standard:0.0.1
+ ```
+
+
+### Building for Standard-System Devices \(reference memory ≥ 128 MB\)
+
+1. Run the preprocessing script in the root directory of the source code.
+
+ ```
+ ../scripts/prepare.sh
+ ```
+
+2. Run the following script to start building for standard-system devices \(reference memory ≥ 128 MB\).
+
+ ```
+ ./build.sh --product-name {product_name}
+ ```
+
+ **product\_name** indicates the platform supported by the current distribution, for example, Hi3516D V300.
+
+ Files generated during building are stored in the **out/ohos-arm-release/** directory, and the generated image is stored in the **out/ohos-arm-release/packages/phone/images/** directory.
+
+
+> **NOTE:**
+>You can exit Docker by simply running the **exit** command.
+
+## HPM-based Docker Environment
+
+**docker\_dist** is a template component in the [HPM](https://hpm.harmonyos.com/#/en/home) system. It helps to quickly initialize an HPM project and use the Docker image to quickly build a distribution of OpenHarmony, greatly simplifying environment configurations needed for building. After configuring the Ubuntu and [hpm-cli](../bundles/bundles-guide-prepare.md) development environments, perform the following steps to access the Docker environment:
+
+### Setting Up the Docker Environment
+
+1. Initialize the installation template by running the following command in any of the working directories:
+
+ ```
+ hpm init -t @ohos/docker_dist
+ ```
+
+2. Modify the **publishAs** field.
+
+ The obtained bundle is of the template type. Open the **bundle.json** file in the current directory and change the value of **publishAs** from **template** to **distribution** as needed.
+
+
+### Obtaining and Building Source Code
+
+Start building. Docker can be automatically installed only in Ubuntu. If you are using any other operating system, manually install Docker before pulling the image.
+
+- **Automatically Installing Docker \(Ubuntu\)**
+
+ Running the following command will automatically install Docker, pull the Docker image, and start the pulling and building of the corresponding solution in the container.
+
+ **Method 1:**
+
+ Add a parameter to specify the solution. For example:
+
+ ```
+ hpm run docker solution={product}
+ ```
+
+ **\{product\}** indicates the solution, for example, **@ohos/hispark\_taurus**, **@ohos/hispark\_aries**, and **@ohos/hispark\_pegasus**.
+
+ **Method 2:**
+
+ Set an environment variable to specify the solution, and then run the build command.
+
+ 1. Select the desired solution.
+
+ ```
+ export solution={product}
+ ```
+
+ **\{product\}** indicates the solution, for example, **@ohos/hispark\_taurus**, **@ohos/hispark\_aries**, and **@ohos/hispark\_pegasus**.
+
+ 2. Obtain and build the source code.
+
+ ```
+ hpm run docker
+ ```
+
+
+ This example uses the **@ohos/hispark\_taurus** solution for illustration. If the execution is successful, the output is as follows:
+
+ ```
+ ...
+ ohos ipcamera_hispark_taurus build success!
+ @ohos/hispark_taurus: distribution building completed.
+ ```
+
+
+- **Manually Installing Docker \(Non-Ubuntu\)**
+
+ Perform the following operations to install Docker:
+
+ ```
+ # Pull the image.
+ docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:0.0.3# Compile the Docker image in the Linux environment.
+ hpm run distWithDocker solution={product}
+ # When using Windows, make sure to configure the Git Bash.
+ hpm config set shellPath "Git Bash path"
+ hpm run distWithDocker solution={product}
+ ```
+
+
diff --git a/en/device-dev/get-code/gettools-ide.md b/en/device-dev/get-code/gettools-ide.md
new file mode 100644
index 0000000000000000000000000000000000000000..ec5de1cf9a48fb2b4039f55dbd702de396b4e2c0
--- /dev/null
+++ b/en/device-dev/get-code/gettools-ide.md
@@ -0,0 +1,17 @@
+# IDE
+
+- [Acquiring the Device Development Tool \(HUAWEI DevEco Device Tool\)](#section2452141120244)
+- [Acquiring the Application Development Tool \(HUAWEI DevEco Studio\)](#section0904101019258)
+
+## Acquiring the Device Development Tool \(HUAWEI DevEco Device Tool\)
+
+HUAWEI DevEco Device Tool is a one-stop integrated development environment \(IDE\) provided to develop applications for OpenHarmony devices. It allows on-demand customization of OpenHarmony components, code editing, building, burning, and debugging, and supports C and C++ languages. This tool is installed in Visual Studio Code as a plug-in. For details, see [HUAWEI DevEco Device Tool](https://device.harmonyos.com/en/ide) and [HUAWEI DevEco Device Tool User Guide](https://device.harmonyos.com/en/docs/ide/user-guides/service_introduction-0000001050166905).
+
+The roadmap of Huawei DevEco Device Tool for supporting OpenHarmony device development is shown in the figure below.
+
+
+
+## Acquiring the Application Development Tool \(HUAWEI DevEco Studio\)
+
+HUAWEI DevEco Studio \(DevEco Studio for short\) is a one-stop IDE oriented to Huawei devices in all scenarios. It provides E2E OpenHarmony application development services, ranging from project template creation to development, building, debugging, and release. With DevEco Studio, you will be able to efficiently develop OpenHarmony applications with distributed capabilities while speeding up innovation. For details, see [HUAWEI DevEco Studio](https://developer.harmonyos.com/en/develop/deveco-studio) and [HUAWEI DevEco Studio User Guide](https://developer.harmonyos.com/en/docs/documentation/doc-guides/tools_overview-0000001053582387).
+
diff --git a/en/device-dev/get-code/gettools.md b/en/device-dev/get-code/gettools.md
new file mode 100644
index 0000000000000000000000000000000000000000..95366cdb4c3f08c8783e132e5489b026622d262a
--- /dev/null
+++ b/en/device-dev/get-code/gettools.md
@@ -0,0 +1,7 @@
+# Tool Acquisition
+
+- **[Docker Environment](gettools-acquire.md)**
+
+- **[IDE](gettools-ide.md)**
+
+
diff --git a/en/device-dev/get-code/ide.md b/en/device-dev/get-code/ide.md
deleted file mode 100644
index f3551de3126341e207afe450d509d8d37cc0979a..0000000000000000000000000000000000000000
--- a/en/device-dev/get-code/ide.md
+++ /dev/null
@@ -1,17 +0,0 @@
-# IDE
-
-- [Acquiring the Device Development Tool \(HUAWEI DevEco Device Tool\)](#section2452141120244)
-- [Acquiring the Application Development Tool \(HUAWEI DevEco Studio\)](#section0904101019258)
-
-## Acquiring the Device Development Tool \(HUAWEI DevEco Device Tool\)
-
-HUAWEI DevEco Device Tool is a one-stop integrated development environment \(IDE\) provided to develop applications for OpenHarmony devices. It allows on-demand customization of OpenHarmony components, code editing, building, burning, and debugging, and supports C and C++ languages. This tool is installed in Visual Studio Code as a plug-in. For details, see [HUAWEI DevEco Device Tool](https://device.harmonyos.com/en/ide) and [HUAWEI DevEco Device Tool User Guide](https://device.harmonyos.com/en/docs/ide/user-guides/service_introduction-0000001050166905).
-
-The roadmap of Huawei DevEco Device Tool for supporting OpenHarmony device development is shown in the figure below.
-
-
-
-## Acquiring the Application Development Tool \(HUAWEI DevEco Studio\)
-
-HUAWEI DevEco Studio \(DevEco Studio for short\) is a one-stop IDE oriented to Huawei devices in all scenarios. It provides E2E OpenHarmony application development services, ranging from project template creation to development, building, debugging, and release. With DevEco Studio, you will be able to efficiently develop OpenHarmony applications with distributed capabilities while speeding up innovation. For details, see [HUAWEI DevEco Studio](https://developer.harmonyos.com/en/develop/deveco-studio) and [HUAWEI DevEco Studio User Guide](https://developer.harmonyos.com/en/docs/documentation/doc-guides/tools_overview-0000001053582387).
-
diff --git a/en/device-dev/get-code/public_sys-resources/icon-caution.gif b/en/device-dev/get-code/public_sys-resources/icon-caution.gif
deleted file mode 100644
index 6e90d7cfc2193e39e10bb58c38d01a23f045d571..0000000000000000000000000000000000000000
Binary files a/en/device-dev/get-code/public_sys-resources/icon-caution.gif and /dev/null differ
diff --git a/en/device-dev/get-code/public_sys-resources/icon-danger.gif b/en/device-dev/get-code/public_sys-resources/icon-danger.gif
deleted file mode 100644
index 6e90d7cfc2193e39e10bb58c38d01a23f045d571..0000000000000000000000000000000000000000
Binary files a/en/device-dev/get-code/public_sys-resources/icon-danger.gif and /dev/null differ
diff --git a/en/device-dev/get-code/public_sys-resources/icon-note.gif b/en/device-dev/get-code/public_sys-resources/icon-note.gif
deleted file mode 100644
index 6314297e45c1de184204098efd4814d6dc8b1cda..0000000000000000000000000000000000000000
Binary files a/en/device-dev/get-code/public_sys-resources/icon-note.gif and /dev/null differ
diff --git a/en/device-dev/get-code/public_sys-resources/icon-notice.gif b/en/device-dev/get-code/public_sys-resources/icon-notice.gif
deleted file mode 100644
index 86024f61b691400bea99e5b1f506d9d9aef36e27..0000000000000000000000000000000000000000
Binary files a/en/device-dev/get-code/public_sys-resources/icon-notice.gif and /dev/null differ
diff --git a/en/device-dev/get-code/public_sys-resources/icon-tip.gif b/en/device-dev/get-code/public_sys-resources/icon-tip.gif
deleted file mode 100644
index 93aa72053b510e456b149f36a0972703ea9999b7..0000000000000000000000000000000000000000
Binary files a/en/device-dev/get-code/public_sys-resources/icon-tip.gif and /dev/null differ
diff --git a/en/device-dev/get-code/public_sys-resources/icon-warning.gif b/en/device-dev/get-code/public_sys-resources/icon-warning.gif
deleted file mode 100644
index 6e90d7cfc2193e39e10bb58c38d01a23f045d571..0000000000000000000000000000000000000000
Binary files a/en/device-dev/get-code/public_sys-resources/icon-warning.gif and /dev/null differ
diff --git a/en/device-dev/get-code/source-code-acquisition.md b/en/device-dev/get-code/source-code-acquisition.md
deleted file mode 100644
index a7d68fe82d7e7b64663197b7d915710410e46069..0000000000000000000000000000000000000000
--- a/en/device-dev/get-code/source-code-acquisition.md
+++ /dev/null
@@ -1,429 +0,0 @@
-# Source Code Acquisition
-
-- [About OpenHarmony](#section6370143622110)
-- [Overview of Source Code Acquisition](#section12763342204)
-- [Method 1: Acquiring Source Code from a Code Repository](#section537312010229)
- - [When to Use](#section10881513459)
- - [Prerequisites](#section102871547153314)
- - [How to Use](#section429012478331)
-
-- [Method 2: Acquiring Source Code from HPM](#section463013147412)
- - [When to Use](#section26661067443)
- - [Prerequisites](#section17544943123315)
- - [How to Use](#section954619433333)
-
-- [Method 3: Acquiring Source Code from Image Sites](#section1186691118430)
-- [Source Code Directories](#section1072115612811)
-
-## About OpenHarmony
-
-OpenHarmony is an open-source project launched by the OpenAtom Foundation. The purpose of this project is to build an open, distributed operating system \(OS\) framework for smart IoT devices in the full-scenario, full-connectivity, and full-intelligence era.
-
-The open-source code repositories are available at [https://openharmony.gitee.com](https://openharmony.gitee.com).
-
-> **NOTE:**
->At present, OpenHarmony source code can only be compiled in the Linux environment.
-
-## Overview of Source Code Acquisition
-
-This document describes how to acquire OpenHarmony source code and provides its directory structure. The OpenHarmony code is open to you as [bundles](../bundles/overview.md), which can be obtained in any of the following ways:
-
-- **Method 1**: Acquire the source code from a code repository. You can use the **repo** or **git** tool to download the latest code from the code repository.
-- **Method 2**: Obtain the source code from the HarmonyOS Package Manager \(HPM\). Visit the [HPM](https://hpm.harmonyos.com/#/en/home) website, search for your desired open-source distribution, and download the bundle list \(or customize bundles and download the bundle list\). Then use **hpm-cli** to download and install the bundles and compilation toolchain on your local PC.
-- **Method 3**: Download the compressed file of a distribution from an image site. This method provides a fast download speed, so you can also use this method for obtaining the source code of an earlier version.
-
-## Method 1: Acquiring Source Code from a Code Repository
-
-### When to Use
-
-- You want to establish a baseline based on stable OpenHarmony releases and distribute the baseline to your customers.
-
-- You have interconnected your software with OpenHarmony and need official certification from OpenHarmony.
-
-- You want to contribute code to the OpenHarmony community after chips, modules, and applications are certified by OpenHarmony.
-
-- You need to address OpenHarmony issues.
-
-- You want to learn OpenHarmony source code.
-
-
-### Prerequisites
-
-1. Register your account with Gitee.
-2. Register an SSH public key for access to Gitee.
-3. Install the [git client](http://git-scm.com/book/en/v2/Getting-Started-Installing-Git) and [git-lfs](https://gitee.com/vcs-all-in-one/git-lfs?_from=gitee_search#downloading), and configure basic user information.
-
- ```
- git config --global user.name "yourname"
- git config --global user.email "your-email-address"
- git config --global credential.helper store
- ```
-
-4. Run the following commands to install the **repo** tool:
-
- ```
- curl -s https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 > /usr/local/bin/repo # If you do not have the access permission to this directory, download the tool to any other accessible directory and configure the directory to the environment variable.
- chmod a+x /usr/local/bin/repo
- pip3 install -i https://repo.huaweicloud.com/repository/pypi/simple requests
- ```
-
-
-### How to Use
-
-**Obtaining the Source Code for Mini, Small, and Standard Systems \(2.0 Canary\)**
-
-> **NOTE:**
->You can obtain the latest features from the master code, and develop commercial functionalities based on the release code, which is more stable.
-
-- **Obtaining OpenHarmony master code**
-
- Method 1 \(recommended\): Use the **repo** tool to download the source code over SSH. \(You must have registered an SSH public key for access to Gitee.\)
-
- ```
- repo init -u git@gitee.com:openharmony/manifest.git -b master --no-repo-verify
- repo sync -c
- repo forall -c 'git lfs pull'
- ```
-
- Method 2 \(recommended\): Use the **repo** tool to download the source code over HTTPS.
-
- ```
- repo init -u https://gitee.com/openharmony/manifest.git -b master --no-repo-verify
- repo sync -c
- repo forall -c 'git lfs pull'
- ```
-
-
-- **Obtaining Latest OpenHarmony\_1.0.1\_release code**
-
- > **NOTE:**
- >Currently, only the source code for mini and small systems can be obtained through this release.
-
- Use the **repo** tool to download the release code.
-
- ```
- repo init -u https://gitee.com/openharmony/manifest.git -b OpenHarmony_1.0.1_release --no-repo-verify
- repo sync -c
- repo forall -c 'git lfs pull'
- ```
-
-- Obtaining the source code of other OpenHarmony releases
-
- For details about how to obtain the source code of other releases, see the [Release Notes](https://gitee.com/openharmony/docs/blob/master/en/release-notes/OpenHarmony-Release-Notes.md).
-
-
-## Method 2: Acquiring Source Code from HPM
-
-### When to Use
-
-If OpenHarmony is new to you, sample solutions are helpful to your development. You can obtain an open-source distribution from the [HPM](https://hpm.harmonyos.com/#/en/home) website, or customize a distribution by adding or deleting bundles of an open-source distribution. Then use **hpm-cli** to download and install the bundles and compilation toolchain on your local PC.
-
-### Prerequisites
-
-You must install **Node.js** and HPM on your local PC. The installation procedure is as follows:
-
-1. Install **Node.js**.
-
- Download **Node.js** from its official website and install it on your local PC.
-
- You are advised to install [Node.js](https://nodejs.org/) 12.x \(including npm 6.14.4\) or a later version \(12.13.0 or later is recommended\).
-
-2. Install the hpm-cli tool using **npm** delivered with **Node.js**.
-
- Open the CMD window and run the following command:
-
- ```
- npm install -g @ohos/hpm-cli
- ```
-
-3. Run the following command to check whether the installation is successful. If the HPM version is displayed, the installation is successful.
-
- ```
- hpm -V or hpm --version
- ```
-
-4. Run the following command to upgrade the HPM version:
-
- ```
- npm update -g @ohos/hpm-cli
- ```
-
-
-### How to Use
-
-1. Search for distributions.
- 1. Access the [HPM](https://hpm.harmonyos.com/#/en/home) page, and click the **Distribution** tab, as shown in the following figure.
- 2. Enter a keyword \(for example: **camera**\) in the search box. All matched distributions are found.
- 3. Specify filter criteria, such as the bundle type \(for example: **Board support** and **Kernel support**\), to further filter the distributions.
- 4. Locate your desired distribution and click it to view details.
-
- **Figure 1** HPM page
-
-
- 
-
-
-2. Learn more about the distribution.
-
- 1. Read carefully the information about the distribution to learn its application scenarios, features, bundles, usage, and customization methods, as shown in the following figure.
- 2. Click **Download** to download the distribution to your local PC.
- 3. Click **Custom** to add or delete bundles of the distribution.
-
- **Figure 2** Example distribution
-
-
- 
-
-3. Customize bundles.
- 1. Access the **Custom solution** page, as shown in the following figure.
- 2. Set the toggle switch next to a specific optional bundle to delete it from the distribution, or click **Add bundle** to add new bundles.
- 3. Enter the basic information about your project, including the bundle name, version, and description, on the right pane.
- 4. Click **Download**. The system then generates the OpenHarmony code structure file \(for example, **my\_cust\_dist.zip**\) and saves it to your local PC.
-
- **Figure 3** Customizing bundles
-
-
- 
-
-
-4. Download and install bundles.
- 1. Decompress the downloaded file using the CLI tool CMD \(shell in Linux\).
- 2. In the generated directory, run the **hpm install** command.
- 3. The downloaded bundles are stored in the **ohos\_bundles** folder under the project directory. \(The source code of some bundles will be copied to a specified directory after the bundles are installed.\)
-
-
-## Method 3: Acquiring Source Code from Image Sites
-
-To ensure the download performance, you are advised to download the source code or the corresponding solution from the image library of the respective site listed in the table below.
-
-> **NOTE:**
->- The table below provides only the sites for downloading the source code of the latest OpenHarmony Master and LTS versions. For details about earlier versions and how to obtain their source code, see the [Release Notes](https://gitee.com/openharmony/docs/tree/master/en/release-notes).
->- The Master 1.0 version is no longer maintained.
-
-**Table 1** Sites for acquiring source code from image sites
-
-
-
Basic software service subsystem set and hardware service subsystem set
-
-
-
build
-
-
Bundle-based compilation, building, and configuration scripts
-
-
-
docs
-
-
Reference documents
-
-
-
domains
-
-
Enhanced software service subsystem set
-
-
-
drivers
-
-
Driver subsystem
-
-
-
foundation
-
-
Basic system capability subsystem set
-
-
-
kernel
-
-
Kernel subsystem
-
-
-
prebuilts
-
-
Compiler and tool chain subsystem
-
-
-
test
-
-
Testing subsystem
-
-
-
third_party
-
-
Open-source third-party software
-
-
-
utils
-
-
Commonly used development tools
-
-
-
vendor
-
-
Vendor-provided software
-
-
-
build.py
-
-
Compilation script file
-
-
-
-
-
diff --git a/en/device-dev/get-code/sourcecode-acquire.md b/en/device-dev/get-code/sourcecode-acquire.md
new file mode 100644
index 0000000000000000000000000000000000000000..5fc6a1f3a1274206f8863b147f40401c031ab7e0
--- /dev/null
+++ b/en/device-dev/get-code/sourcecode-acquire.md
@@ -0,0 +1,429 @@
+# Source Code Acquisition
+
+- [About OpenHarmony](#section6370143622110)
+- [Overview of Source Code Acquisition](#section12763342204)
+- [Method 1: Acquiring Source Code from a Code Repository](#section537312010229)
+ - [When to Use](#section10881513459)
+ - [Prerequisites](#section102871547153314)
+ - [How to Use](#section429012478331)
+
+- [Method 2: Acquiring Source Code from HPM](#section463013147412)
+ - [When to Use](#section26661067443)
+ - [Prerequisites](#section17544943123315)
+ - [How to Use](#section954619433333)
+
+- [Method 3: Acquiring Source Code from Image Sites](#section1186691118430)
+- [Source Code Directories](#section1072115612811)
+
+## About OpenHarmony
+
+OpenHarmony is an open-source project launched by the OpenAtom Foundation. The purpose of this project is to build an open, distributed operating system \(OS\) framework for smart IoT devices in the full-scenario, full-connectivity, and full-intelligence era.
+
+The open-source code repositories are available at [https://openharmony.gitee.com](https://openharmony.gitee.com).
+
+> **NOTE:**
+>At present, OpenHarmony source code can only be compiled in the Linux environment.
+
+## Overview of Source Code Acquisition
+
+This document describes how to acquire OpenHarmony source code and provides its directory structure. The OpenHarmony code is open to you as [bundles](../bundles/bundles-standard-rules.md), which can be obtained in any of the following ways:
+
+- **Method 1**: Acquire the source code from a code repository. You can use the **repo** or **git** tool to download the latest code from the code repository.
+- **Method 2**: Obtain the source code from the HarmonyOS Package Manager \(HPM\). Visit the [HPM](https://hpm.harmonyos.com/#/en/home) website, search for your desired open-source distribution, and download the bundle list \(or customize bundles and download the bundle list\). Then use **hpm-cli** to download and install the bundles and compilation toolchain on your local PC.
+- **Method 3**: Download the compressed file of a distribution from an image site. This method provides a fast download speed, so you can also use this method for obtaining the source code of an earlier version.
+
+## Method 1: Acquiring Source Code from a Code Repository
+
+### When to Use
+
+- You want to establish a baseline based on stable OpenHarmony releases and distribute the baseline to your customers.
+
+- You have interconnected your software with OpenHarmony and need official certification from OpenHarmony.
+
+- You want to contribute code to the OpenHarmony community after obtaining official OpenHarmony certification for chips, modules, and applications.
+
+- You need to rectify OpenHarmony issues.
+
+- You want to learn OpenHarmony source code.
+
+
+### Prerequisites
+
+1. Register your account with Gitee.
+2. Register an SSH public key for access to Gitee.
+3. Install the [git client](http://git-scm.com/book/en/v2/Getting-Started-Installing-Git) and [git-lfs](https://gitee.com/vcs-all-in-one/git-lfs?_from=gitee_search#downloading)), and configure basic user information.
+
+ ```
+ git config --global user.name "yourname"
+ git config --global user.email "your-email-address"
+ git config --global credential.helper store
+ ```
+
+4. Run the following commands to install the **repo** tool:
+
+ ```
+ curl -s https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 > /usr/local/bin/repo # If you do not have the access permission to this directory, download the tool to any other accessible directory and configure the directory to the environment variable.
+ chmod a+x /usr/local/bin/repo
+ pip3 install -i https://repo.huaweicloud.com/repository/pypi/simple requests
+ ```
+
+
+### How to Use
+
+**Obtaining the Source Code for Mini/Small/Standard Systems \(2.0 Canary\)**
+
+> **NOTE:**
+>You can obtain the latest features from the master code, and develop commercial functionalities based on the release code, which is more stable.
+
+- **Obtaining OpenHarmony master code**
+
+ Method 1 \(recommended\): Use the **repo** tool to download the source code over SSH. \(You must have registered an SSH public key for access to Gitee.\)
+
+ ```
+ repo init -u git@gitee.com:openharmony/manifest.git -b master --no-repo-verify
+ repo sync -c
+ repo forall -c 'git lfs pull'
+ ```
+
+ Method 2 \(recommended\): Use the **repo** tool to download the source code over HTTPS.
+
+ ```
+ repo init -u https://gitee.com/openharmony/manifest.git -b master --no-repo-verify
+ repo sync -c
+ repo forall -c 'git lfs pull'
+ ```
+
+
+- **Obtaining Latest OpenHarmony\_1.0.1\_release code**
+
+ > **NOTE:**
+ >Currently, only the source code for mini and small systems can be obtained through this release.
+
+ Use the **repo** tool to download the release code.
+
+ ```
+ repo init -u https://gitee.com/openharmony/manifest.git -b OpenHarmony_1.0.1_release --no-repo-verify
+ repo sync -c
+ repo forall -c 'git lfs pull'
+ ```
+
+- Obtaining the source code of other OpenHarmony releases
+
+ For details about how to obtain the source code of other OpenHarmony releases, see the [Release Notes](https://gitee.com/openharmony/docs/blob/master/en/release-notes/OpenHarmony-Release-Notes.md).
+
+
+## Method 2: Acquiring Source Code from HPM
+
+### When to Use
+
+If OpenHarmony is new to you, sample solutions are helpful to your development. You can obtain an open-source distribution from the [HPM](https://hpm.harmonyos.com/#/en/home) website, or customize a distribution by adding or deleting bundles of an open-source distribution. Then use **hpm-cli** to download and install the bundles and compilation toolchain on your local PC.
+
+### Prerequisites
+
+You must install **Node.js** and HPM on your local PC. The installation procedure is as follows:
+
+1. Install **Node.js**.
+
+ Download **Node.js** from its official website and install it on your local PC.
+
+ You are advised to install [Node.js](https://nodejs.org/) 12.x \(including npm 6.14.4\) or a later version \(12.13.0 or later is recommended\).
+
+2. Install the hpm-cli tool using **npm** delivered with **Node.js**.
+
+ Open the CMD window and run the following command:
+
+ ```
+ npm install -g @ohos/hpm-cli
+ ```
+
+3. Run the following command to check whether the installation is successful. If the HPM version is displayed, the installation is successful.
+
+ ```
+ hpm -V or hpm --version
+ ```
+
+4. Run the following command to upgrade the HPM version:
+
+ ```
+ npm update -g @ohos/hpm-cli
+ ```
+
+
+### How to Use
+
+1. Search for distributions.
+ 1. Access the [HPM](https://hpm.harmonyos.com/#/en/home) page, and click the **Distribution** tab, as shown in the following figure.
+ 2. Enter a keyword \(for example: **camera**\) in the search box. All matched distributions are found.
+ 3. Specify filter criteria, such as the bundle type \(for example: **Board support** and **Kernel support**\), to further filter the distributions.
+ 4. Locate your desired distribution and click it to view details.
+
+ **Figure 1** HPM page
+
+
+ 
+
+
+2. Learn more about the distribution.
+
+ 1. Read carefully the information about the distribution to learn its application scenarios, features, bundles, usage, and customization methods, as shown in the following figure.
+ 2. Click **Download** to download the distribution to your local PC.
+ 3. Click **Custom** to add or delete bundles of the distribution.
+
+ **Figure 2** Example distribution
+
+
+ 
+
+3. Customize bundles.
+ 1. Access the **Custom solution** page, as shown in the following figure.
+ 2. Set the toggle switch next to a specific optional bundle to delete it from the distribution, or click **Add bundle** to add new bundles.
+ 3. Enter the basic information about your project, including the bundle name, version, and description, on the right pane.
+ 4. Click **Download**. The system then generates the OpenHarmony code structure file \(for example, **my\_cust\_dist.zip**\) and saves it to your local PC.
+
+ **Figure 3** Customizing bundles
+
+
+ 
+
+
+4. Download and install bundles.
+ 1. Decompress the downloaded file using the CLI tool CMD \(shell in Linux\).
+ 2. In the generated directory, run the **hpm install** command.
+ 3. The downloaded bundles are stored in the **ohos\_bundles** folder under the project directory. \(The source code of some bundles will be copied to a specified directory after the bundles are installed.\)
+
+
+## Method 3: Acquiring Source Code from Image Sites
+
+To ensure the download performance, you are advised to download the source code or the corresponding solution from the image library of the respective site listed in the table below.
+
+> **NOTE:**
+>- The table below provides only the sites for downloading the latest OpenHarmony master and LTS code. For details about how to obtain the source code of earlier versions, see the [Release Notes](https://gitee.com/openharmony/docs/tree/master/en/release-notes).
+>- The Master 1.0 version is no longer maintained.
+
+**Table 1** Sites for acquiring source code from image sites
+
+
+
Basic software service subsystem set and hardware service subsystem set
+
+
+
build
+
+
Bundle-based compilation, building, and configuration scripts
+
+
+
docs
+
+
Reference documents
+
+
+
domains
+
+
Enhanced software service subsystem set
+
+
+
drivers
+
+
Driver subsystem
+
+
+
foundation
+
+
Basic system capability subsystem set
+
+
+
kernel
+
+
Kernel subsystem
+
+
+
prebuilts
+
+
Compiler and tool chain subsystem
+
+
+
test
+
+
Testing subsystem
+
+
+
third_party
+
+
Open-source third-party software
+
+
+
utils
+
+
Commonly used development tools
+
+
+
vendor
+
+
Vendor-provided software
+
+
+
build.py
+
+
Compilation script file
+
+
+
+
+
diff --git a/en/device-dev/get-code/sourcecode.md b/en/device-dev/get-code/sourcecode.md
new file mode 100644
index 0000000000000000000000000000000000000000..5e118ce26fcaab05055610b3ca990fd6c3f676b0
--- /dev/null
+++ b/en/device-dev/get-code/sourcecode.md
@@ -0,0 +1,5 @@
+# Source Code Acquisition
+
+- **[Source Code Acquisition](sourcecode-acquire.md)**
+
+
diff --git a/en/device-dev/get-code/tool-acquisition.md b/en/device-dev/get-code/tool-acquisition.md
deleted file mode 100644
index dd1797b10426918c0921386817fb51c1b9e83a3b..0000000000000000000000000000000000000000
--- a/en/device-dev/get-code/tool-acquisition.md
+++ /dev/null
@@ -1,7 +0,0 @@
-# Tool Acquisition
-
-- **[Docker Environment](docker-environment.md)**
-
-- **[IDE](ide.md)**
-
-
diff --git a/en/device-dev/glossary/Readme-EN.md b/en/device-dev/glossary/Readme-EN.md
new file mode 100644
index 0000000000000000000000000000000000000000..1e7ccafe473286de0e48494b45a313bedad2c4e1
--- /dev/null
+++ b/en/device-dev/glossary/Readme-EN.md
@@ -0,0 +1,4 @@
+# Glossary
+
+[Glossary](glossary.md)
+
diff --git a/en/device-dev/guide/Readme-EN.md b/en/device-dev/guide/Readme-EN.md
index 31bb3cfd5f930e15379766651d890690ab24f29c..f5cbdaea83a60faf5a5aefe3efc7c9c7e0c2d7b2 100644
--- a/en/device-dev/guide/Readme-EN.md
+++ b/en/device-dev/guide/Readme-EN.md
@@ -1,72 +1,32 @@
# Development Examples
-- [WLAN-connected Products](wlan-connected-products.md)
- - [LED Peripheral Control](led-peripheral-control.md)
- - [Overview](overview.md)
- - [Development](development.md)
- - [Verification](verification.md)
-
-- [Cameras Without a Screen](cameras-without-a-screen.md)
- - [Camera Control](camera-control.md)
- - [Overview](overview-0.md)
- - [Development Guidelines](development-guidelines.md)
- - [Photographing](photographing.md)
- - [Video Recording](video-recording.md)
-
- - [Use Case](use-case.md)
-
-- [Cameras with a Screen](cameras-with-a-screen.md)
- - [Screen and Camera Control](screen-and-camera-control.md)
- - [Overview](overview-1.md)
- - [Development Guidelines](development-guidelines-2.md)
- - [Photographing](photographing-3.md)
- - [Video Recording](video-recording-4.md)
- - [Previewing](previewing.md)
-
- - [Use Case](use-case-5.md)
-
- - [Visual Application Development](visual-application-development.md)
- - [Overview](overview-6.md)
- - [Preparations](preparations.md)
- - [Adding Pages](adding-pages.md)
- - [Building the Home Page](building-the-home-page.md)
- - [Building the Details Page](building-the-details-page.md)
- - [Debugging and Packaging](debugging-and-packaging.md)
- - [Running on the Device](running-on-the-device.md)
- - [FAQs](faqs.md)
-
-- [Development Example for Clock Apps](development-example-for-clock-apps.md)
- - [Overview](overview-7.md)
- - [Preparations](preparations-8.md)
- - [How to Develop](how-to-develop.md)
- - [Signing and Packaging](signing-and-packaging.md)
- - [Running on the Device](running-on-the-device-9.md)
-
-- [Development Example for Platform Drivers](development-example-for-platform-drivers.md)
- - [Overview](overview-10.md)
- - [Preparations](preparations-11.md)
- - [Development](development-12.md)
- - [Building and Burning](building-and-burning.md)
-
-- [Development Example for Peripheral Drivers](development-example-for-peripheral-drivers.md)
- - [Overview](overview-13.md)
- - [Hardware Resources](hardware-resources.md)
- - [Input Driver Model](input-driver-model.md)
-
- - [Setting Up the Environment](setting-up-the-environment.md)
- - [Developing a Touchscreen Driver](developing-a-touchscreen-driver.md)
- - [Configuring Device Driver Descriptions](configuring-device-driver-descriptions.md)
- - [Configuring the Touchscreen](configuring-the-touchscreen.md)
- - [Adapting to the Private Drivers of the Touchscreen](adapting-to-the-private-drivers-of-the-touchscreen.md)
-
- - [Building and Burning](building-and-burning-14.md)
- - [Debugging and Verification](debugging-and-verification.md)
- - [Startup Log Analysis](startup-log-analysis.md)
-
- - [Input Driver Model Workflow Analysis](input-driver-model-workflow-analysis.md)
- - [Parsing Private Configuration Data](parsing-private-configuration-data.md)
- - [Initializing the Input Device Manager and Registering the Driver with the HDF](initializing-the-input-device-manager-and-registering-the-driver-with-the-hdf.md)
- - [Initializing the Input Common Driver and Registering the Driver with the HDF](initializing-the-input-common-driver-and-registering-the-driver-with-the-hdf.md)
- - [Initializing the Input Chip Driver and Registering the Driver with the HDF](initializing-the-input-chip-driver-and-registering-the-driver-with-the-hdf.md)
- - [Function Invocation Logic](function-invocation-logic.md)
-
+- [WLAN-connected Products](device-wifi.md)
+ - [LED Peripheral Control](device-wifi-led-outcontrol.md)
+ - [Third-Party SDK Integration](device-wifi-sdk.md)
+- [Cameras Without a Screen](device-iotcamera.md)
+ - [Camera Control](device-iotcamera-control.md)
+ - [Overview](device-iotcamera-control-overview.md)
+ - [Development Guidelines](device-iotcamera-control-demo.md)
+ - [Photographing](device-iotcamera-control-demo-photodevguide.md)
+ - [Video Recording](device-iotcamera-control-demo-videodevguide.md)
+ - [Use Case](device-iotcamera-control-example.md)
+- [Cameras with a Screen](device-camera.md)
+ - [Screen and Camera Control](device-camera-control.md)
+ - [Overview](device-camera-control-overview.md)
+ - [Development Guidelines](device-camera-control-demo.md)
+ - [Photographing](device-camera-control-demo-photoguide.md)
+ - [Video Recording](device-camera-control-demo-videoguide.md)
+ - [Previewing](device-camera-control-demo-previewguide.md)
+ - [Use Case](device-camera-control-example.md)
+ - [Visual Application Development](device-camera-visual.md)
+ - [Overview](device-camera-visual-overview.md)
+ - [Preparations](device-camera-visual-prepare.md)
+ - [Adding Pages](device-camera-visual-addpage.md)
+ - [Building the Home Page](device-camera-visual-first-page.md)
+ - [Building the Details Page](device-camera-visual-details.md)
+ - [Debugging and Packaging](device-camera-visual-debug.md)
+ - [Running on the Device](device-camera-visual-run.md)
+ - [FAQs](device-camera-visual-faqs.md)
+- [Development Guidelines on Clock Apps](oem_device_clockapp_des.md)
+- [Development Example for Platform Drivers](device-drive-demo.md)
+- [Development Example for Peripheral Drivers](device-outerdrive-demo.md)
\ No newline at end of file
diff --git a/en/device-dev/guide/adapting-to-the-private-drivers-of-the-touchscreen.md b/en/device-dev/guide/adapting-to-the-private-drivers-of-the-touchscreen.md
deleted file mode 100644
index 80f6ba5513c1e2db8ecb7d566f91c82536311a5f..0000000000000000000000000000000000000000
--- a/en/device-dev/guide/adapting-to-the-private-drivers-of-the-touchscreen.md
+++ /dev/null
@@ -1,99 +0,0 @@
-# Adapting to the Private Drivers of the Touchscreen
-
-The input driver model consists of three parts of drivers. To develop a brand-new touchscreen driver, you only need to adapt your code with the input chip driver and implement differentiated APIs. The sample code in this section illustrates how you will complete the adaptation.
-
-1. Implement differentiated APIs for the touchscreen to adapt to the input chip driver.
-
- You can obtain the sample code at **./drivers/framework/model/input/driver/touchscreen/touch\_gt911.c**.
-
- ```
- static struct TouchChipOps g_gt911ChipOps = { // IC options of the touchscreen
- .Init = ChipInit, // Initialize the chip.
- .Detect = ChipDetect, // Detect the chip.
- .Resume = ChipResume, // Resume the chip.
- .Suspend = ChipSuspend, // Suspend the chip.
- .DataHandle = ChipDataHandle, // Read the chip data.
- .UpdateFirmware = UpdateFirmware, // Update the firmware.
- };
-
- /* The ICs may be different depending on the touchscreen vendors, and the corresponding register operations are also different. Therefore, the code for the input chip driver focuses only on the adaptation of differentiated APIs. The following sample code demonstrates the data parsing of GT911. */
-
- static int32_t ChipDataHandle(ChipDevice *device)
- {
- ...
- /* Read the status register before GT911 obtains coordinates. */
- reg[0] = (GT_BUF_STATE_ADDR >> ONE_BYTE_OFFSET) & ONE_BYTE_MASK;
- reg[1] = GT_BUF_STATE_ADDR & ONE_BYTE_MASK;
- ret = InputI2cRead(i2cClient, reg, GT_ADDR_LEN, &touchStatus, 1);
- if (ret < 0 || touchStatus == GT_EVENT_INVALID) {
- return HDF_FAILURE;
- }
- ...
- /* Read data from the data register based on the value of the status register. */
- reg[0] = (GT_X_LOW_BYTE_BASE >> ONE_BYTE_OFFSET) & ONE_BYTE_MASK;
- reg[1] = GT_X_LOW_BYTE_BASE & ONE_BYTE_MASK;
- pointNum = touchStatus & GT_FINGER_NUM_MASK;
- if (pointNum == 0 || pointNum > MAX_SUPPORT_POINT) {
- HDF_LOGE("%s: pointNum is invalid, %u", __func__, pointNum);
- (void)ChipCleanBuffer(i2cClient);
- OsalMutexUnlock(&device->driver->mutex);
- return HDF_FAILURE;
- }
- frame->realPointNum = pointNum;
- frame->definedEvent = TOUCH_DOWN;
- (void)InputI2cRead(i2cClient, reg, GT_ADDR_LEN, buf, GT_POINT_SIZE * pointNum);
- /* Parse the obtained data. */
- ParsePointData(device, frame, buf, pointNum);
- ...
- }
- static void ParsePointData(ChipDevice *device, FrameData *frame, uint8_t *buf, uint8_t pointNum)
- {
- ...
- /* Each coordinate value consists of two bytes. Obtain the final coordinate value by combining the obtained single-byte data. */
- for (i = 0; i < pointNum; i++) {
- frame->fingers[i].trackId = buf[GT_POINT_SIZE * i + GT_TRACK_ID];
- frame->fingers[i].y = (buf[GT_POINT_SIZE * i + GT_X_LOW] & ONE_BYTE_MASK) |
- ((buf[GT_POINT_SIZE * i + GT_X_HIGH] & ONE_BYTE_MASK) << ONE_BYTE_OFFSET);
- frame->fingers[i].x = (buf[GT_POINT_SIZE * i + GT_Y_LOW] & ONE_BYTE_MASK) |
- ((buf[GT_POINT_SIZE * i + GT_Y_HIGH] & ONE_BYTE_MASK) << ONE_BYTE_OFFSET);
- /* Print the parsed coordinate value. */
- HDF_LOGD("%s: x = %d, y = %d", __func__, frame->fingers[i].x, frame->fingers[i].y);
- }
- }
- ```
-
-2. Initialize the input chip driver and register the driver with the HDF.
-
- You can obtain the sample code at **./drivers/framework/model/input/driver/touchscreen/touch\_gt911.c**.
-
- ```
- static int32_t HdfGoodixChipInit(struct HdfDeviceObject *device)
- {
- ...
- /* Use the chipCfg structure to allocate memory, parse the configuration information, and mount the parsed data. */
- chipCfg = ChipConfigInstance(device);
- ...
- /* Instantiate the touchscreen device. */
- chipDev = ChipDeviceInstance();
- ...
- /* Mount touchscreen chip configuration and private operation data. */
- chipDev->chipCfg = chipCfg;
- chipDev->ops = &g_gt911ChipOps;
- ...
- /* Register the chip driver with the platform driver. */
- RegisterChipDevice(chipDev);
- ...
- }
- struct HdfDriverEntry g_touchGoodixChipEntry = {
- .moduleVersion = 1,
- .moduleName = "HDF_TOUCH_GT911", // The value must match the moduleName field of the chip driver in the device_info.hcs file.
- .Init = HdfGoodixChipInit, // Initialize the touchscreen chip driver.
- };
- HDF_INIT(g_touchGoodixChipEntry); // Register the touchscreen chip driver with the HDF.
- ```
-
- The private chip drivers present the major differentiations among chip vendors, such as hibernation and wakeup, data parsing, and firmware update.
-
- Now, you have completed the adaptation for the touchscreen driver based on the HDF and input driver model.
-
-
diff --git a/en/device-dev/guide/adding-pages.md b/en/device-dev/guide/adding-pages.md
deleted file mode 100644
index 42eae0107fbdff36aff7879586df0fedebc792b2..0000000000000000000000000000000000000000
--- a/en/device-dev/guide/adding-pages.md
+++ /dev/null
@@ -1,34 +0,0 @@
-# Adding Pages
-
-- [Creating the Home Page](#section16935511143715)
-- [Creating the Details Page](#section122131729173819)
-
-## Creating the Home Page
-
-Upon creation of the project, the **index** page is automatically generated, which is the home page of AirQuality. [Figure 1](#fig16545205773718) shows the project directory.
-
-**Figure 1** Project directory
-
-
-## Creating the Details Page
-
-To the details page, perform the following steps:
-
-1. Right-click **pages** and choose **New** \> **JS Page** from the shortcut menu.
-
- **Figure 2** Adding a page
- 
-
-2. Enter the page name.
-
- **Figure 3** Entering the page name
- 
-
-3. Confirm the creation.
-
- The following figure shows the application project directory after the **detail** page is created. It contains a **.hml** layout file, a **.css** file, and a **.js** file \(containing service logic code\).
-
- **Figure 4** Complete project directory
- 
-
-
diff --git a/en/device-dev/guide/building-and-burning-14.md b/en/device-dev/guide/building-and-burning-14.md
deleted file mode 100644
index d905b787acbb3639912138621c808faa46645a10..0000000000000000000000000000000000000000
--- a/en/device-dev/guide/building-and-burning-14.md
+++ /dev/null
@@ -1,17 +0,0 @@
-# Building and Burning
-
-1. Compile the Makefile and add the following content in this example.
-
- The file is available at **./drivers/adapter/khdf/linux/model/input/Makefile**.
-
- Add the following content:
-
- ```
- obj-$(CONFIG_DRIVERS_HDF_TP_5P5_GT911) += \
- $(INPUT_ROOT_DIR)/touchscreen/touch_gt911.o
- ```
-
- **touch\_gt911.o** is the content added in this example.
-
-2. Conduct building and burn. For details about the building and burning operations, see [Build and Burn in Getting Started with Standard System](../quick-start/standard-system.md).
-
diff --git a/en/device-dev/guide/building-and-burning.md b/en/device-dev/guide/building-and-burning.md
deleted file mode 100644
index 25f895cc93816b552eee5058a96b098ec7fdf7e9..0000000000000000000000000000000000000000
--- a/en/device-dev/guide/building-and-burning.md
+++ /dev/null
@@ -1,20 +0,0 @@
-# Building and Burning
-
-1. Edit the Makefile and add a source file to it, as shown in the following example:
-
- ```
- include drivers/hdf/khdf/platform/platform.mk
-
- obj-y += $(HDF_PLATFORM_FRAMEWORKS_ROOT)/src/i2c_core.o \
- $(HDF_PLATFORM_FRAMEWORKS_ROOT)/src/i2c_if.o \
- ./i2c_adapter.o \
- ./i2c_sample.o
- ```
-
- **./i2c\_sample.o** is the source file added to the Makefile in this example.
-
-2. Build the version and burn the system image to the development board.
-
- For details about the building and burning operations, see [Build and Burn in Getting Started with Standard System](../quick-start/standard-system.md).
-
-
diff --git a/en/device-dev/guide/building-the-details-page.md b/en/device-dev/guide/building-the-details-page.md
deleted file mode 100644
index 915c74a318163d6a50cab13e46f919b129690d1d..0000000000000000000000000000000000000000
--- a/en/device-dev/guide/building-the-details-page.md
+++ /dev/null
@@ -1,396 +0,0 @@
-# Building the Details Page
-
-- [detail.hml](#section275215487291)
-- [detail.css](#section2589154215301)
-- [detail.js](#section163410883117)
-
-The **detail** page displays the air quality data of a week in a chart. There are two parts on the page: title bar and chart bar. Considering the display effect of the chart bar, use multiple **
** components in stead of one **** component.
-
-Add a root **
**, set the **flex-direction** attribute to **column** to arrange the two bars vertically. The example code is as follows:
-
-```
-
-
-
-
- History
-
-
-
-
-
-```
-
-In the preceding example, **onclick="backMain"** indicates that the application returns to the home page when the click event is triggered. The example code for **detail.js** is as follows:
-
-```
-import router from '@system.router'
-
-export default {
- backMain() {
- router.replace({
- // Home page URL
- uri: 'pages/index/index',
- params: {
- // Parameters to pass to the home page
- selectedCityIndex: this.selectedCityIndex
- }
- });
- }
-}
-```
-
-Add **
** components to the **** component to form a chart.
-
-The complete example code in the three files is as follows.
-
-## detail.hml
-
-```
-
-```
-
-## detail.css
-
-```
-.location {
- text-align: center;
- color: #ffffff;
- width: 960px;
- height: 52px;
- font-size: 40px;
-}
-.container {
- height: 480px;
- width: 960px;
- flex-direction: column;
-}
-
-.header {
- width: 960px;
- height: 72px;
-}
-
-.back {
- width: 36px;
- height: 36px;
- margin-left: 39px;
- margin-top: 23px;
-}
-
-.title {
- width: 296px;
- height: 40px;
- margin-top: 20px;
- margin-left: 21px;
- color: #e6e6e6;
-}
-
-.chart-list {
- width: 960px;
- height: 408px;
-}
-
-.list-item-title {
- width: 960px;
- height: 52px;
-}
-
-.list-item-chart {
- width: 960px;
- height: 280px;
-}
-
-.chart-wrapper {
- width: 308px;
- height: 256px;
- flex-direction: column;
-}
-
-.gas-name {
- width: 308px;
- height: 35px;
- text-align: left;
-}
-
-.chart {
- width: 308px;
- height: 155px;
- margin-top: 10px;
- justify-content: flex-start;
- align-items: flex-end;
-}
-
-.chart-item {
- width: 24px;
- margin-left: 18px;
- border-radius: 3px;
-}
-
-.white-line {
- width: 308px;
- height: 2px;
- background-color: #ffffff;
- margin-top: 22px;
-}
-
-.week {
- width: 308px;
- height: 17px;
- margin-top: 6px;
- border-color: #ffffff;
- border-radius: 2px;
- margin-top: 6px;
-}
-
-.day {
- width: 26px;
- height: 17px;
- font-size: 10px;
- margin-left: 16px;
- text-align: center;
-}
-```
-
-## detail.js
-
-```
-import router from '@system.router'
-
-export default {
- data: {
- location: ''
- },
- onInit() {
- if (this.selectedCityIndex === 0) {
- this.location = 'Dongguan';
- } else {
- this.location = 'Shenzhen';
- }
- },
- backMain() {
- router.replace({
- uri: 'pages/index/index',
- params: {
- selectedCityIndex: this.selectedCityIndex
- }
- });
- }
-}
-```
-
diff --git a/en/device-dev/guide/building-the-home-page.md b/en/device-dev/guide/building-the-home-page.md
deleted file mode 100644
index e50391cee73cb565eb6537ec06a70eb53ee996aa..0000000000000000000000000000000000000000
--- a/en/device-dev/guide/building-the-home-page.md
+++ /dev/null
@@ -1,581 +0,0 @@
-# Building the Home Page
-
-The application home page displays air quality information of different cities. The home page provides two screens \(for two information bars\), which can be added as required. Each screen displays the air quality information of one city, including the Air Quality Index \(AQI\), city name, pollution level, update time, and data source.
-
-The home page of AirQuality consists of three parts:
-
-- Title bar: displays the page title and provides an exit button. The title bar is fixed at the top of the page.
-- Information bar: displays air quality information. Multiple information bars can be added based on user requirements and support looping scroll.
-- Indicator bar: shows the position of the current screen among all screens. The indicator bar is fixed at the bottom of the page.
-
-The following steps describe how to build the home page with a flexible layout that has three rows vertically arranged.
-
-1. Add a root **
** to the **.hml** file. Note that each **.hml** file can contain only one root component. The example code is as follows:
-
- ```
-
-
- ```
-
- **class="container"** indicates the style used by the component. The **container** is a style class defined in the **index.css** file.
-
- ```
- .container {
- flex-direction: column;
- height: 480px;
- width: 960px;
- }
- ```
-
- The height and width of the root component **
** are set in the style class. Note that the height and width must be explicitly specified \(except for some components, such as ****\). Otherwise, the component may fail to display. In the **container** style class, the **flex-direction** attribute is set to **column**, which means that child components of **
** are vertically arranged from top to bottom for implementing the flexible page layout.
-
-2. Add the title bar. The title bar consists of an exit button and title text that are horizontally arranged. Add a **
** to hold the title bar and set the **flex-direction** attribute to **row** to arrange the child components from left to right. Add an **** and a **** component in sequence. The example code is as follows:
-
- ```
-
-
-
-
- Air quality
-
-
-
- ```
-
- Set component attributes, including the height, width, margin, and color.
-
- ```
- .header {
- width: 960px;
- height: 72px;
- }
- .back {
- width: 36px;
- height: 36px;
- margin-left: 39px;
- margin-top: 23px;
- }
- .title {
- width: 296px;
- height: 40px;
- margin-top: 20px;
- margin-left: 21px;
- color: #e6e6e6;
- }
- ```
-
- In the **.hml** file, **onclick="exitApp"** sets the click event for the **
** component. When the click event is triggered, the **exitApp\(\)** function is executed. The example definition of **exitApp\(\)** in **index.js** is as follows:
-
- ```
- exitApp() {
- console.log('start exit');
- app.terminate();
- console.log('end exit');
- }
- ```
-
- The **app.terminate\(\)** function is used to exit the program. Before using this function, you must import the **app** module by adding the following code at the beginning of **index.js**:
-
- ```
- import app from '@system.app'
- ```
-
- After the code is compiled, run the project on the simulator. The following figure shows the display effect.
-
- **Figure 1** Title bar
- 
-
-3. The **** component is required to implement the switching between screens.
-
- Add a **** to the root node.
-
- ```
-
-
-
-
- Air quality
-
-
-
-
-
- ```
-
- - Use **class="**swiper**"** to set the height and width of the component. The sample code is as follows:
-
- ```
- .swiper {
- height: 385px;
- width: 960px;
- }
- ```
-
-
- - **index="\{\{swiperPage\}\}" duration="500" onchange="swiperChange"** sets the component attribute and event. **duration="500"** indicates that the duration of the swiping animation is 500 ms.
- - **index="\{\{swiperPage\}\}"** specifies the index of the child component of ****. **\{\{swiperPage\}\}** indicates that the index value is dynamically bound to the **swiperPage** variable in the JavaScript code. The index value changes with the **swiperPage** value.
- - **onchange="swiperChange"** binds the change event of the **** component to the **swiperChange** function. The JavaScript code is as follows:
-
- ```
- // Import the router module for page switching.
- import router from'@system.router'
- import app from '@system.app'
-
- export default {
- // Define parameters.
- data: {
- // By default, the first page is displayed.
- swiperPage: 0
- },
- onInit () {
- },
- exitApp(){
- console.log('start exit');
- app.terminate();
- console.log('end exit');
- },
- // Swiping event, which saves the index value of the current . The index value is saved to the swiperPage variable each time a swiping occurs.
- swiperChange (e) {
- this.swiperPage = e.index;
- }
- }
- ```
-
-
-4. Set the information about a city to be displayed on a screen. On each screen, information of different types is displayed using different components.
-
- Add two **** as child components \(directional layout\) to ****. Add ****, ****, **