未验证 提交 55e3b7ca 编写于 作者: O openharmony_ci 提交者: Gitee

!4294 #I57OCC完成+修改断链问题

Merge pull request !4294 from Annie_wang/OpenHarmony-3.1-Release
......@@ -2,7 +2,7 @@
## When to Use
The distributed data objects allow data across devices to be processed like local variables by shielding complex data interaction between devices. For the devices that form a Super Device, when data in the distributed data object of an application is added, deleted, or modified on a device, the data for the same application is also updated on the other devices. The devices can listen for the data changes and online and offline states of other devices. The distributed data objects support basic data types, such as number, string, and Boolean, as well as complex data types, such as array and nested basic types.
The distributed data objects allow data across devices to be processed like local variables by shielding complex data interaction between devices. For the devices that form a Super Device, when data in the distributed data object of an application is added, deleted, or modified on a device, the data for the same application is also updated on the other devices. The devices can listen for the data changes and online and offline status of other devices. The distributed data objects support basic data types, such as number, string, and Boolean, as well as complex data types, such as array and nested basic types.
## Available APIs
......@@ -15,7 +15,7 @@ Call **createDistributedObject()** to create a distributed data object instance.
**Table 1** API for creating a distributed data object instance
| Package| API| Description|
| -------- | -------- | -------- |
| ohos.data.distributedDataObject| createDistributedObject(source: object): DistributedObject | Creates a distributed data object instance for data operations.<br>- &nbsp;**source**: attributes of the **distributedObject** set.<br>- &nbsp;**DistributedObject**: returns the distributed object created.|
| ohos.data.distributedDataObject| createDistributedObject(source: object): DistributedObject | Creates a distributed data object instance for data operations.<br>-&nbsp;**source**: attributes of the **distributedObject** set.<br>-&nbsp;**DistributedObject**: returns the distributed object created.|
### Generating a Session ID
......@@ -28,12 +28,12 @@ Call **genSessionId()** to generate a session ID randomly. The generated session
### Setting a SessionID for Distributed Data Objects
Call setSessionId() to set the session ID for a distributed data object. The session ID is a unique identifier for one collaboration across devices. The distributed data objects to be synchronized must be associated with the same session ID.
Call **setSessionId()** to set a session ID for a distributed data object. The session ID is a unique identifier for one collaboration across devices. The distributed data objects to be synchronized must be associated with the same session ID.
**Table 3** API for setting a session ID
| Class| API| Description|
| -------- | -------- | -------- |
| DistributedDataObject | setSessionId(sessionId?: string): boolean | Sets a session ID for distributed data objects.<br>&nbsp;**sessionId**: ID of a distributed object in a trusted network. To remove a distributed data object from the network, set this parameter to "" or leave it empty.|
| DistributedDataObject | setSessionId(sessionId?: string): boolean | Sets a session ID for distributed data objects.<br>&nbsp;**sessionId**: session ID of a distributed object in a trusted network. To remove a distributed data object from the network, set this parameter to "" or leave it empty.|
### Observing Data Changes
......@@ -43,7 +43,7 @@ Call **on()** to subscribe to data changes of a distributed data object. When th
| Class| API| Description|
| -------- | -------- | -------- |
| DistributedDataObject| on(type: 'change', callback: Callback<{ sessionId: string, fields: Array&lt;string&gt; }>): void | Subscribes to data changes.|
| DistributedDataObject| off(type: 'change', callback?: Callback<{ sessionId: string, fields: Array&lt;string&gt; }>): void | Unsubscribes from data changes. Callback used to return changes of the distributed object. If this parameter is not specified, all callbacks related to data changes will be unregistered.|
| DistributedDataObject| off(type: 'change', callback?: Callback<{ sessionId: string, fields: Array&lt;string&gt; }>): void | Unsubscribes from data changes. <br>**Callback**: specifies callback used to return changes of the distributed data object. If this parameter is not specified, all callbacks related to data changes will be unregistered.|
### Observing Online or Offline Status
......@@ -90,10 +90,10 @@ The following example shows how to implement a distributed data object synchroni
var remote_object = distributedObject.createDistributedObject({name:undefined, age:undefined, isVis:true,
parent:undefined, list:undefined});
remote_object.setSessionId(sessionId);
// After obtaining that the device status goes online, the remote object synchronizes data. That is, name changes to jack and age to 18.
// After learning that the device goes online, the remote object synchronizes data. That is, name changes to jack and age to 18.
```
4. Observe the data changes of the distributed data object. Subscribe to data changes of the remote end. When the data is the peer end changes, a callback will be called to return the data changes.
4. Observe the data changes of the distributed data object. You can subscribe to data changes of the remote object. When the data in the remote object changes, a callback will be called to return the data changes.
The sample code is as follows:
......@@ -108,8 +108,8 @@ The following example shows how to implement a distributed data object synchroni
}
}
// To refresh the page in changeCallback, correctly set this.changeCallback.bind(this) in
changeCallback.
// To refresh the page in changeCallback, correctly bind (this) to the changeCallback.
local_object.on("change", this.changeCallback.bind(this));
```
5. Modify object attributes. The object attributes support basic data types (such as number, Boolean, and string) and complex data types (array and nested basic types).
......@@ -123,7 +123,7 @@ The following example shows how to implement a distributed data object synchroni
local_object.list = [{mother:"jack mom"}, {father:"jack Dad"}];
```
> ![icon-note.gif](../public_sys-resources/icon-note.gif) **NOTE**<br/>
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> For the distributed data object of the complex type, only the root attribute can be modified. The subordinate attributes cannot be modified. Example:
```js
// Supported modification.
......@@ -142,7 +142,7 @@ The following example shows how to implement a distributed data object synchroni
The sample code is as follows:
```js
// Unsubscribe from changeCallback.
// Unsubscribe from the specified data change callback.
local_object.off("change", changeCallback);
// Unsubscribe from all data change callbacks.
local_object.off("change");
......@@ -156,27 +156,27 @@ The following example shows how to implement a distributed data object synchroni
local_object.on("status", this.statusCallback);
```
9. Unsubscribe from the status changes of the distributed data object. You can specify the callback to unsubscribe from. If you do not specify the callback, all status change callbacks will be unsubscribe from.
9. Unsubscribe from the status changes of the distributed data object. You can specify the callback to unsubscribe from. If you do not specify the callback, this API unsubscribes from all callbacks of this distributed data object.
The sample code is as follows:
```js
// Unsubscribe from the online status change callback.
// Unsubscribe from the specified status change callback.
local_object.off("status", statusCallback);
// Unsubscribe from all online status change callbacks.
// Unsubscribe from all status change callbacks.
local_object.off("status");
```
10. Remove a distributed data object from the synchronization network. After the distributed data object is removed from the network, the data changes on the local end will not be synchronized to the remote end.
10. Remove a distributed data object from the synchronization network. Data changes on the local object will not be synchronized to the removed distributed data object.
The sample code is as follows:
```js
local_object.setSessionId("");
```
## Development Example
## Samples
The following example is provided for you to better understand the development of distributed data object:
The following example is provided for you to better understand the development of distributed data objects:
- [Distributed Notepad](https://gitee.com/openharmony/distributeddatamgr_objectstore/tree/master/samples/distributedNotepad)
When an event occurs on a device, for example, a note is added, the tile or content of a note is changed, or the event list is cleared, the change will be synchronized to other devices in the trusted network by the Notepad app.
When an event of the Notepad app occurs on a device, such as a note is added, the tile or content of a note is changed, or the event list is cleared, the change will be synchronized to other devices in the trusted network.
......@@ -2,7 +2,7 @@
## When to Use
The Distributed Data Service (DDS) implements synchronization of application data across user devices. When data is added, deleted, or modified for an application on a device, the same application on another device can obtain the updated data. The DDS applies to the distributed gallery, messages, Contacts, and file manager.
The Distributed Data Service (DDS) implements synchronization of application data across user devices. When data is added, deleted, or modified for an application on a device, the same application on another device can obtain the updated data. The DDS applies to the distributed gallery, messages, contacts, and file manager.
## Available APIs
......@@ -15,7 +15,7 @@ The table below describes the APIs provided by the OpenHarmony DDS module.
| -------------------------- | ------------------------------------------------------------ | ----------------------------------------------- |
| Creating a distributed database | createKVManager(config:&nbsp;KVManagerConfig,&nbsp;callback:&nbsp;AsyncCallback&lt;KVManager&gt;):&nbsp;void<br>createKVManager(config:&nbsp;KVManagerConfig):&nbsp;Promise&lt;KVManager> | Creates a **KVManager** object for database management.|
| Obtaining a distributed KV store | getKVStore&lt;T&nbsp;extends&nbsp;KVStore&gt;(storeId:&nbsp;string,&nbsp;options:&nbsp;Options,&nbsp;callback:&nbsp;AsyncCallback&lt;T&gt;):&nbsp;void<br>getKVStore&lt;T&nbsp;extends&nbsp;KVStore&gt;(storeId:&nbsp;string,&nbsp;options:&nbsp;Options):&nbsp;Promise&lt;T&gt; | Obtains the KV store with the specified **Options** and **storeId**.|
| Managing data in a distributed KV store| put(key:&nbsp;string,&nbsp;value:&nbsp;Uint8Array&nbsp;\|&nbsp;string&nbsp;\|&nbsp;number&nbsp;\|&nbsp;boolean,&nbsp;callback:&nbsp;AsyncCallback&lt;void&gt;):&nbsp;void<br>put(key:&nbsp;string,&nbsp;value:&nbsp;Uint8Array&nbsp;\|&nbsp;string&nbsp;\|&nbsp;number&nbsp;\|&nbsp;boolean):&nbsp;Promise&lt;void> | Inserts or updates data. |
| Managing data in a distributed KV store| put(key:&nbsp;string,&nbsp;value:&nbsp;Uint8Array&nbsp;\|&nbsp;string&nbsp;\|&nbsp;number&nbsp;\|&nbsp;boolean,&nbsp;callback:&nbsp;AsyncCallback&lt;void&gt;):&nbsp;void<br>put(key:&nbsp;string,&nbsp;value:&nbsp;Uint8Array&nbsp;\|&nbsp;string&nbsp;\|&nbsp;number&nbsp;\|&nbsp;boolean):&nbsp;Promise&lt;void> | Inserts and updates data. |
| Managing data in a distributed KV store| delete(key:&nbsp;string,&nbsp;callback:&nbsp;AsyncCallback&lt;void&gt;):&nbsp;void<br>delete(key:&nbsp;string):&nbsp;Promise&lt;void> | Deletes data. |
| Managing data in a distributed KV store| get(key:&nbsp;string,&nbsp;callback:&nbsp;AsyncCallback&lt;Uint8Array&nbsp;\|&nbsp;string&nbsp;\|&nbsp;boolean&nbsp;\|&nbsp;number&gt;):&nbsp;void<br>get(key:&nbsp;string):&nbsp;Promise&lt;Uint8Array&nbsp;\|&nbsp;string&nbsp;\|&nbsp;boolean&nbsp;\|&nbsp;number> | Queries data. |
| Subscribing to changes in the distributed data | on(event:&nbsp;'dataChange',&nbsp;type:&nbsp;SubscribeType,&nbsp;observer:&nbsp;Callback&lt;ChangeNotification&gt;):&nbsp;void<br>on(event:&nbsp;'syncComplete',&nbsp;syncCallback:&nbsp;Callback&lt;Array&lt;[string,&nbsp;number]&gt;&gt;):&nbsp;void | Subscribes to data changes in the KV store. |
......@@ -63,7 +63,7 @@ The following uses a single KV store as an example to describe the development p
3. Create and obtain a single KV store.
1. Declare the ID of the single KV store to create.
2. Create a single KV store. You are advised to disable automatic synchronization (**autoSync:false**) and call **sync** if a synchronization is required.
2. Create a single KV store. You are advised to disable automatic synchronization (**autoSync:false**) and call **sync** when a synchronization is required.
The sample code is as follows:
```js
......@@ -159,7 +159,7 @@ The following uses a single KV store as an example to describe the development p
deviceManager.createDeviceManager("bundleName", (err, value) => {
if (!err) {
devManager = value;
// get deviceIds
// Obtain deviceIds.
let deviceIds = [];
if (devManager != null) {
var devices = devManager.getTrustedDeviceListSync();
......@@ -177,5 +177,5 @@ The following uses a single KV store as an example to describe the development p
```
## Samples
The following samples are provided to help you better understand the distributed data development:
- [`KvStore`: distributed database (eTS) (API8)](https://gitee.com/openharmony/app_samples/tree/master/data/Kvstore)
- [Distributed Database](https://gitee.com/openharmony/codelabs/tree/master/Data/JsDistributedData)
- [`KvStore`: Distributed Data Management (eTS) (API8)](https://gitee.com/openharmony/app_samples/tree/master/data/Kvstore)
- [Distributed Data Service](https://gitee.com/openharmony/codelabs/tree/master/Data/JsDistributedData)
......@@ -116,8 +116,8 @@ The RDB provides **RdbPredicates** for you to set database operation conditions.
A result set can be regarded as a row of data in the queried results. It allows you to traverse and access the data you have queried. The following table describes the external APIs of **ResultSet**.
> ![icon-notice.gif](../public_sys-resources/icon-notice.gif) **NOTICE**<br/>
> After a result set is used, you must call the **close()** method to close it explicitly.**
> ![icon-notice.gif](public_sys-resources/icon-notice.gif) **NOTICE**<br>
> After a result set is used, you must call the **close()** method to close it explicitly.
**Table 7** APIs for using the result set
......@@ -306,3 +306,8 @@ You can obtain the distributed table name for a remote device based on the local
let tableName = rdbStore.obtainDistributedTableName(deviceId, "test");
let resultSet = rdbStore.querySql("SELECT * FROM " + tableName)
```
## Samples
The following samples are provided for you to better understand the RDB development:
- [`Rdb`: eTS RDB (API8)](https://gitee.com/openharmony/app_samples/tree/master/data/Rdb)
- [`DistributedRdb`: eTS Distributed Relational Database (API8)](https://gitee.com/openharmony/app_samples/tree/master/data/DistributedRdb)
- [Relational Database](https://gitee.com/openharmony/codelabs/tree/master/Data/JSRelationshipData)
# DataAbilityPredicates
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> **NOTE**<br/>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
......@@ -22,6 +22,7 @@ Creates an **RdbPredicates** object based on a **DataAabilityPredicates** object
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| name | string | Yes| Table name in the RDB store.|
......
# Distributed Data Object
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> **NOTE**<br/>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
......@@ -10,8 +10,6 @@
import distributedObject from '@ohos.data.distributedDataObject';
```
## distributedDataObject.createDistributedObject
createDistributedObject(source: object): DistributedObject
......
# Result Set
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> **NOTE**<br/>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
......
......@@ -3,11 +3,11 @@
Lightweight storage provides applications with data processing capability and allows applications to perform lightweight data storage and query. Data is stored in key-value (KV) pairs. Keys are of the string type, and values can be of the number, string, or Boolean type.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> **NOTE**<br/>
>
> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> - The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> - The APIs of this module are no longer maintained since API Version 9. You are advised to use [`@ohos.data.preferences`](js-apis-data-preferences.md).
## Modules to Import
......@@ -30,7 +30,7 @@ import dataStorage from '@ohos.data.storage';
getStorageSync(path: string): Storage
Reads a file and loads the data to the **Storage** instance in synchronous mode.
Reads the specified file and load its data to the **Storage** instance for data operations.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
......@@ -67,7 +67,7 @@ Reads a file and loads the data to the **Storage** instance in synchronous mode.
getStorage(path: string, callback: AsyncCallback&lt;Storage&gt;): void
Reads a file and loads the data to the **Storage** instance. This API uses an asynchronous callback to return the execution result.
Reads the specified file and loads its data to the **Storage** instance for data operations. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
......@@ -105,7 +105,7 @@ Reads a file and loads the data to the **Storage** instance. This API uses an as
getStorage(path: string): Promise&lt;Storage&gt;
Reads a file and loads the data to the **Storage** instance. This API uses a promise to return the execution result.
Reads the specified file and loads its data to the **Storage** instance for data operations. This API uses a promise to return the result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
......@@ -146,7 +146,7 @@ Reads a file and loads the data to the **Storage** instance. This API uses a pro
deleteStorageSync(path: string): void
Deletes the singleton **Storage** instance of a file from the memory, and deletes the specified file, its backup file, and damaged files. After the specified files are deleted, the **Storage** instance cannot be used for data operations. Otherwise, data inconsistency will occur. This API uses a synchronous mode.
Deletes the singleton **Storage** instance of a file from the memory, and deletes the specified file, its backup file, and damaged files. After the specified files are deleted, the **Storage** instance cannot be used for data operations. Otherwise, data inconsistency will occur.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
......@@ -165,7 +165,7 @@ Deletes the singleton **Storage** instance of a file from the memory, and delete
deleteStorage(path: string, callback: AsyncCallback&lt;void&gt;): void
Deletes the singleton **Storage** instance of a file from the memory, and deletes the specified file, its backup file, and damaged files. After the specified files are deleted, the **Storage** instance cannot be used for data operations. Otherwise, data inconsistency will occur. This API uses an asynchronous callback to return the execution result.
Deletes the singleton **Storage** instance of a file from the memory, and deletes the specified file, its backup file, and damaged files. After the specified files are deleted, the **Storage** instance cannot be used for data operations. Otherwise, data inconsistency will occur. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
......@@ -191,7 +191,7 @@ Deletes the singleton **Storage** instance of a file from the memory, and delete
deleteStorage(path: string): Promise&lt;void&gt;
Deletes the singleton **Storage** instance of a file from the memory, and deletes the specified file, its backup file, and damaged files. After the specified files are deleted, the **Storage** instance cannot be used for data operations. Otherwise, data inconsistency will occur. This API uses a promise to return the execution result.
Deletes the singleton **Storage** instance of a file from the memory, and deletes the specified file, its backup file, and damaged files. After the specified files are deleted, the **Storage** instance cannot be used for data operations. Otherwise, data inconsistency will occur. This API uses a promise to return the result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
......@@ -222,8 +222,6 @@ removeStorageFromCacheSync(path: string): void
Removes the singleton **Storage** instance of a file from the cache. The removed instance cannot be used for data operations. Otherwise, data inconsistency will occur.
This API uses a synchronous mode.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Parameters**
......@@ -241,9 +239,7 @@ This API uses a synchronous mode.
removeStorageFromCache(path: string, callback: AsyncCallback&lt;void&gt;): void
Removes the singleton **Storage** instance of a file from the cache. The removed instance cannot be used for data operations. Otherwise, data inconsistency will occur.
This API uses an asynchronous callback to return the result.
Removes the singleton **Storage** instance of a file from the cache. The removed instance cannot be used for data operations. Otherwise, data inconsistency will occur. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
......@@ -269,9 +265,7 @@ This API uses an asynchronous callback to return the result.
removeStorageFromCache(path: string): Promise&lt;void&gt;
Removes the singleton **Storage** instance of a file from the cache. The removed instance cannot be used for data operations. Otherwise, data inconsistency will occur.
This API uses a promise to return the result.
Removes the singleton **Storage** instance of a file from the cache. The removed instance cannot be used for data operations. Otherwise, data inconsistency will occur. This API uses a promise to return the result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
......@@ -307,8 +301,6 @@ getSync(key: string, defValue: ValueType): ValueType
Obtains the value corresponding to a key. If the value is null or not in the default value format, the default value is returned.
This API uses a synchronous mode.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Parameters**
......@@ -333,9 +325,7 @@ This API uses a synchronous mode.
get(key: string, defValue: ValueType, callback: AsyncCallback&lt;ValueType&gt;): void
Obtains the value corresponding to a key. If the value is null or not in the default value format, the default value is returned.
This API uses an asynchronous callback to return the result.
Obtains the value corresponding to a key. If the value is null or not in the default value format, the default value is returned. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
......@@ -362,9 +352,7 @@ This API uses an asynchronous callback to return the result.
get(key: string, defValue: ValueType): Promise&lt;ValueType&gt;
Obtains the value corresponding to a key. If the value is null or not in the default value format, the default value is returned.
This API uses a promise to return the result.
Obtains the value corresponding to a key. If the value is null or not in the default value format, the default value is returned. This API uses a promise to return the result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
......@@ -397,8 +385,6 @@ putSync(key: string, value: ValueType): void
Obtains the **Storage** instance corresponding to the specified file, writes data to the **Storage** instance using a **Storage** API, and saves the modification using **flush()** or **flushSync()**.
This API uses a synchronous mode.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Parameters**
......@@ -417,9 +403,7 @@ This API uses a synchronous mode.
put(key: string, value: ValueType, callback: AsyncCallback&lt;void&gt;): void
Obtains the **Storage** instance corresponding to the specified file, writes data to the **Storage** instance using a **Storage** API, and saves the modification using **flush()** or **flushSync()**.
This API uses an asynchronous callback to return the result.
Obtains the **Storage** instance corresponding to the specified file, writes data to the **Storage** instance using a **Storage** API, and saves the modification using **flush()** or **flushSync()**. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
......@@ -446,9 +430,7 @@ This API uses an asynchronous callback to return the result.
put(key: string, value: ValueType): Promise&lt;void&gt;
Obtains the **Storage** instance corresponding to the specified file, writes data to the **Storage** instance using a **Storage** API, and saves the modification using **flush()** or **flushSync()**.
This API uses a promise to return the result.
Obtains the **Storage** instance corresponding to the specified file, writes data to the **Storage** instance using a **Storage** API, and saves the modification using **flush()** or **flushSync()**. This API uses a promise to return the result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
......@@ -480,8 +462,6 @@ hasSync(key: string): boolean
Checks whether the storage object contains data with a given key.
This API uses a synchronous mode.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Parameters**
......@@ -507,9 +487,7 @@ This API uses a synchronous mode.
has(key: string, callback: AsyncCallback&lt;boolean&gt;): boolean
Checks whether the storage object contains data with a given key.
This API uses an asynchronous callback to return the result.
Checks whether the storage object contains data with a given key. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
......@@ -542,9 +520,7 @@ This API uses an asynchronous callback to return the result.
has(key: string): Promise&lt;boolean&gt;
Checks whether the storage object contains data with a given key.
This API uses a promise to return the result.
Checks whether the storage object contains data with a given key. This API uses a promise to return the result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
......@@ -577,8 +553,6 @@ deleteSync(key: string): void
Deletes data with the specified key from this storage object.
This API uses a synchronous mode.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Parameters**
......@@ -592,13 +566,11 @@ This API uses a synchronous mode.
```
### deletej
### delete
delete(key: string, callback: AsyncCallback&lt;void&gt;): void
Deletes data with the specified key from this storage object.
This API uses an asynchronous callback to return the result.
Deletes data with the specified key from this storage object. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
......@@ -624,9 +596,7 @@ This API uses an asynchronous callback to return the result.
delete(key: string): Promise&lt;void&gt;
Deletes data with the specified key from this storage object.
This API uses a promise to return the result.
Deletes data with the specified key from this storage object. This API uses a promise to return the result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
......@@ -657,8 +627,6 @@ flushSync(): void
Saves the modification of this object to the **Storage** instance and synchronizes the modification to the file.
This API uses a synchronous mode.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Example**
......@@ -671,9 +639,7 @@ This API uses a synchronous mode.
flush(callback: AsyncCallback&lt;void&gt;): void
Saves the modification of this object to the **Storage** instance and synchronizes the modification to the file.
This API uses an asynchronous callback to return the result.
Saves the modification of this object to the **Storage** instance and synchronizes the modification to the file. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
......@@ -698,9 +664,7 @@ This API uses an asynchronous callback to return the result.
flush(): Promise&lt;void&gt;
Saves the modification of this object to the **Storage** instance and synchronizes the modification to the file.
This API uses a promise to return the result.
Saves the modification of this object to the **Storage** instance and synchronizes the modification to the file. This API uses a promise to return the result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
......@@ -726,8 +690,6 @@ clearSync(): void
Clears this **Storage** object.
This API uses a synchronous mode.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Example**
......@@ -740,9 +702,7 @@ This API uses a synchronous mode.
clear(callback: AsyncCallback&lt;void&gt;): void
Clears this **Storage** object.
This API uses an asynchronous callback to return the result.
Clears this **Storage** object. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
......@@ -767,9 +727,7 @@ This API uses an asynchronous callback to return the result.
clear(): Promise&lt;void&gt;
Clears this **Storage** object.
This API uses a promise to return the result.
Clears this **Storage** object. This API uses a promise to return the result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
......
......@@ -2,7 +2,7 @@
Distributed data management provides collaboration between databases of different devices for applications. The APIs provided by distributed data management can be used to save data to the distributed database and perform operations such as adding, deleting, modifying, and querying data in the distributed database.
>![](../../public_sys-resources/icon-note.gif) **NOTE**<br/>
>**NOTE**<br/>
>The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
......@@ -2922,6 +2922,7 @@ These value types can be used only by internal applications.
| BOOLEAN |4 |Boolean. |
| DOUBLE |5 |Double (double-precision floating point). |
## SingleKVStore
Provides methods to query and synchronize data in a single KV store. This class inherits from **KVStore**. Before calling any method in **SingleKVStore**, you must use [getKVStore](#getkvstore) to obtain a **SingleKVStore** object.
......@@ -3447,7 +3448,7 @@ Closes the **KvStoreResultSet** object obtained by **getResultSet**. This API us
| Name | Type| Mandatory | Description |
| ----- | ------ | ---- | ----------------------- |
| resultSet |[KvStoreResultSet](#kvstoreresultset8) | Yes |**KvStoreResultSet** object to close. |
| callback |AsyncCallback&lt;void&gt; | Yes |Callback used to return the execution result. |
| callback |AsyncCallback&lt;void&gt; | Yes |Callback used to return the result. |
**Example**
......
# Data Storage
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> **NOTE**<br/>
>
> - The APIs of this module are no longer maintained since API Version 6, and you are advised to use [`@ohos.data.storage`](js-apis-data-storage.md). From API Version 9, you are advised to use [`@ohos.data.preferences`](js-apis-data-preferences.md).
> - The APIs of this module are no longer maintained since API Version 6, and you are advised to use [`@ohos.data.storage`](js-apis-data-storage.md).
>
> - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version.
......@@ -67,7 +67,7 @@ Sets the value in the cache based on the specified key.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| key | string | Yes| Key of the value to set.|
| key | string | Yes| Key of the data to set.|
| value | string | Yes| New value to set. The maximum length is 128 bytes.|
| success | Function | No| Called when **storage.set()** is successful.|
| fail | Function | No| Called when **storage.set()** fails. In the callback, **data** indicates the error information, and **code** indicates the error code.|
......
......@@ -157,7 +157,7 @@ The following two comment formats are supported:
*/
```
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> ![icon-note.gif](../public_sys-resources/icon-note.gif) **NOTE**<br/>
> Multi-line comments cannot be nested.
......@@ -301,7 +301,7 @@ root {
}
```
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> ![icon-note.gif](../public_sys-resources/icon-note.gif) **NOTE**<br/>
> The keyword **delete** cannot be used to delete nodes or attributes in the same HCS file. In an HCS file, you can directly delete unnecessary attributes.
......
......@@ -50,17 +50,17 @@ Based on the attributes of the pins, interfaces on the touchscreens can be class
The interfaces shown in the figure are described as follows:
1. **Power interfaces**
- **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**
- **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**
- **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](driver-platform-i2c-des.md#section5361140416).
- 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](driver-platform-spi-des.md#section193356154511).
......@@ -88,7 +88,7 @@ Perform the following steps:
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](driver-hdf-development.md#how-to-develop).
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/driver-hdf-development.md#how-to-develop).
2. Complete the board-level configuration and private data configuration of the touchscreen.
......
......@@ -2,13 +2,14 @@
## Overview<a name="section1"></a>
- An analog-to-digital converter (ADC) is a device that converts analog signals into digital signals.
An analog-to-digital converter (ADC) is a device that converts analog signals into digital signals.
- The ADC APIs provide a set of common functions for ADC data transfer, including:
- Opening or closing an ADC device
- Obtaining the analog-to-digital (AD) conversion result
The ADC APIs provide a set of common functions for ADC data transfer, including:
- Opening or closing an ADC device
**Figure 1** ADC physical connection<a name="fig1"></a>
- Obtaining the analog-to-digital (AD) conversion result
**Figure 1** ADC physical connection<br/>
![](figures/ADC_physical_connection.png "ADC_physical_connection")
......@@ -51,11 +52,11 @@
### How to Use<a name="section4"></a>
[Figure 2](#fig2) shows how an ADC device works.
The figure below illustrates how to use the APIs.
**Figure 2** How ADC works<a name="fig2"></a>
**Figure 2** Using ADC driver APIs<br/>
![](figures/ADC_flowchart.png "ADC_flowchart")
![](figures/using-ADC-process.png "using-ADC-process.png")
### Opening an ADC Device<a name="section5"></a>
......
......@@ -42,7 +42,8 @@ The DAC module is divided into the following layers:
- The core layer provides the capabilities of binding, initializing, and releasing devices.
- The adaptation layer implements other functions.
![](../public_sys-resources/icon-note.gif)NOTE<br/>The core layer can call the functions of the interface layer and uses the hook to call functions of the adaptation layer. In this way, the adaptation layer can indirectly call the functions of the interface layer, but the interface layer cannot call the functions of the adaptation layer.
>![](../public_sys-resources/icon-note.gif) **NOTE**<br>
>The core layer can call the functions of the interface layer and uses the hook to call functions of the adaptation layer. In this way, the adaptation layer can indirectly call the functions of the interface layer, but the interface layer cannot call the functions of the adaptation layer.
**Figure 1** Unified service mode
......@@ -68,15 +69,15 @@ The table below describes the APIs of the DAC module. For more details, see API
| :------------------------------------------------------------| :------------ |
| DevHandle DacOpen(uint32_t number) | Opens a DAC device. |
| void DacClose(DevHandle handle) | Closes a DAC device. |
| int32_t DacWrite(DevHandle handle, uint32_t channel, uint32_t val) | Sets the target DA value. |
| int32_t DacWrite(DevHandle handle, uint32_t channel, uint32_t val) | Sets a target DA value. |
### How to Develop
The figure below illustrates the process of using a DAC device.
The figure below illustrates how to use the APIs.
**Figure 2** Process of using a DAC device
**Figure 2** Using DAC driver APIs<br/>
![](figures/process-of-using-DAC.png "Process of using a DAC")
![](figures/using-DAC-process.png "using-DAC-process.png")
#### Opening a DAC Device
......@@ -110,7 +111,7 @@ if (dacHandle == NULL) {
}
```
#### Setting the Target DA Value
#### Setting a Target DA Value
```
int32_t DacWrite(DevHandle handle, uint32_t channel, uint32_t val);
......
......@@ -2,19 +2,20 @@
## Overview<a name="section5361140416"></a>
- 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).
The Inter-Integrated Circuit \(I2C\) is a simple, bidirectional, and synchronous serial bus that uses merely two wires.
- 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.
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).
- The I2C APIs define a set of common functions for I2C data transfer, including:
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.
- I2C controller management: opening or closing an I2C controller
- I2C message transfer: custom transfer by using a message array
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.
**Figure 1** Physical connection diagram for I2C<a name="fig1135561232714"></a>
![](figures/physical-connection-diagram-for-i2c.png "physical-connection-diagram-for-i2c")
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<br/>![](figures/physical-connection-diagram-for-i2c.png "physical-connection-diagram-for-i2c")
## Available APIs<a name="section545869122317"></a>
......@@ -52,21 +53,22 @@
</tbody>
</table>
>![](../public_sys-resources/icon-note.gif) **NOTE:**
>![](../public_sys-resources/icon-note.gif) **NOTE**<br/>
>All functions provided in this document can be called only in kernel mode.
## Usage Guidelines<a name="section1695201514281"></a>
### How to Use<a name="section1338373417288"></a>
[Figure 2](#fig183017194234) illustrates the process of an I2C device.
The figure below illustrates how to use the APIs.
**Figure 2** Process of using an I2C device<a name="fig183017194234"></a>
![](figures/process-of-using-an-i2c-device.png "process-of-using-an-i2c-device")
**Figure 2** Using I2C driver APIs
![](figures/using-i2c-process.png "process-of-using-an-i2c-device")
### Opening an I2C Controller<a name="section13751110132914"></a>
Call the following function to open an I2C controller:
Call the **I2cOpen()** function to open an I2C controller.
DevHandle I2cOpen\(int16\_t number\);
......@@ -117,7 +119,7 @@ if (i2cHandle == NULL) {
### Performing I2C Communication<a name="section9202183372916"></a>
Use the following function for message transfer:
Call the **I2cTransfer()** function to transfer messages.
int32\_t I2cTransfer\(DevHandle handle, struct I2cMsg \*msgs, int16\_t count\);
......@@ -186,15 +188,14 @@ if (ret != 2) {
}
```
>![](../public_sys-resources/icon-caution.gif) **CAUTION:**
>![](../public_sys-resources/icon-caution.gif) **CAUTION**<br/>
>- 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 does not limit the number of message structures and the data length of each message structure, which are 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<a name="section19481164133018"></a>
Call the following function to close the I2C controller after the communication is complete:
Call the **I2cClose()** function to close the I2C controller after the communication is complete.
void I2cClose\(DevHandle \*handle\);
......@@ -209,12 +210,13 @@ void I2cClose\(DevHandle \*handle\);
</thead>
<tbody><tr id="row1926109193116"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p105419317318"><a name="p105419317318"></a><a name="p105419317318"></a>handle</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p1213245577"><a name="p1213245577"></a><a name="p1213245577"></a>Handle of an I2C controller.</p>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p1213245577"><a name="p1213245577"></a><a name="p1213245577"></a>Handle of the I2C controller to close.</p>
</td>
</tr>
</tbody>
</table>
```
I2cClose(i2cHandle); /* Close the I2C controller. */
```
......@@ -233,7 +235,7 @@ This example shows a simple register read/write operation on TouchPad on a Hi351
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.
>![](../public_sys-resources/icon-note.gif) **NOTE:**
>![](../public_sys-resources/icon-note.gif) **NOTE** <br/>
>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:
......
......@@ -59,12 +59,11 @@ The figure below shows a simplified CSI. The D-PHY transmits data by using one p
### How to Use<a name="section2.1_MIPI_CSIDes"></a>
The figure below shows the process of using a MIPI CSI device.
The figure below illustrates how to use the APIs.
**Figure 2** MIPI CSI usage process<a name="fig2_MIPI_CSIDes"></a>
**Figure 2** Using MIPI CSI driver APIs
![](figures/process-of-using-MIPI-CSI.png)
![](figures/using-MIPI-CSI-process.png)
### Opening the MIPI CSI Controller Operation Handle<a name="section2.2_MIPI_CSIDes"></a>
......
# MIPI DSI<a name="EN-US_TOPIC_0000001160971534"></a>
# MIPI DSI
## Overview<a name="section16806142183217"></a>
## 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.
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.
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<a name="fig1122611461203"></a>
![](figures/dsi-transmitting-and-receiving-interface.png "dsi-transmitting-and-receiving-interface")
## Available APIs<a name="section12720125432316"></a>
## Available APIs
**Table 1** APIs for MIPI DSI
......@@ -75,17 +75,17 @@
</tbody>
</table>
>![](../public_sys-resources/icon-note.gif) **NOTE:**
>All functions described in this document can be called only in kernel space.
>![](../public_sys-resources/icon-note.gif) **NOTE**<br> All functions described in this document can be called only in kernel space.
## Usage Guidelines<a name="section037231715335"></a>
## Usage Guidelines
### How to Use<a name="section49299119344"></a>
### How to Use
[Figure 2](#fig129103491241) shows the process of using a MIPI DSI device.
The figure below illustrates how to use the APIs.
**Figure 2** Process of using a MIPI DSI device<a name="fig129103491241"></a>
![](figures/process-of-using-a-mipi-dsi-device.png)
**Figure 2** Using MIPI DSI driver APIs
![](figures/using-mipi-dsi-process.png)
### Obtaining a MIPI DSI Device Handle<a name="section5126155683811"></a>
......@@ -537,4 +537,3 @@ void PalMipiDsiTestSample(void)
MipiDsiClose(handle);
}
```
\ No newline at end of file
......@@ -5,12 +5,12 @@
### Pin<a name="section2"></a>
- The pin, also called pin controller, manages pin resources of system on a chip (SoC) vendors and provides the pin multiplexing function.
- The pin module defines a set of common methods for managing pins, including:
The pin module, also called pin controller, manages pin resources of system on a chip (SoC) vendors and provides the pin multiplexing function.
The module defines a set of common methods for managing pins, including:
- Obtaining or releasing the pin description handle: The kernel compares the pin name passed in with the pin names of each controller in the linked list. If a match is found, a pin description handle is obtained. After the operation on the pin is complete, the pin description handle will be released.
- Setting or obtaining the pull type of a pin: The pull type can be pull-up, pull-down, or floating.
- Setting or obtaining the pull strength of a pin: You can set the pull strength as required.
- Setting or obtaining the functions of a pin to implement pin multiplexing
- Setting or obtaining the pull type of a pin: The pull type can be pull-up, pull-down, or floating.
- Setting or obtaining the pull strength of a pin: You can set the pull strength as required.
- Setting or obtaining the functions of a pin to implement pin multiplexing
### Basic Concepts<a name="section3"></a>
Pin, as a software concept, provides APIs for uniformly managing the pins from different SoC vendors, providing the pin multiplexing function, and configuring the electrical features of pins.
......@@ -68,10 +68,11 @@ The table below describes the APIs of the pin module. For more details, see API
### How to Develop<a name="section9"></a>
The figure below shows the process.
The figure below illustrates how to use the APIs.
**Figure 2** Process of using the pin module<a name="fig2"></a>
![](figures/process-of-using-pin.png "Process of using the pin module")
**Figure 2** Using the pin driver APIs
![](figures/using-pin-process.png "Process of using the pin module")
#### Obtaining the Pin Description Handle
......@@ -122,7 +123,7 @@ int32_t PinSetPull(DevHandle handle, enum PinPullType pullType);
| pullType | Pull type to set. |
| **Return Value**| **Description** |
| 0 | The operation is successful.|
| Negative value | The operation fails.|
| Negative value | The operation failed.|
Example: Set the pull type to pull-up.
......@@ -156,7 +157,7 @@ int32_t PinGetPull(DevHandle handle, enum PinPullType *pullType);
| pullType | Pointer to the pull type obtained.|
| **Return Value**| **Description** |
| 0 | The operation is successful. |
| Negative value | The operation fails. |
| Negative value | The operation failed. |
Example: Obtain the pull type of a pin.
......@@ -189,7 +190,7 @@ int32_t PinSetStrength(DevHandle handle, uint32_t strength);
| strength | Pull strength to set. |
| **Return Value**| **Description** |
| 0 | The operation is successful.|
| Negative value | The operation fails.|
| Negative value | The operation failed.|
Example: Set the pull strength of the pin to 2.
......@@ -223,7 +224,7 @@ int32_t PinGetStrength(DevHandle handle, uint32_t *strength);
| strength | Pointer to the pull strength obtained.|
| **Return Value**| **Description** |
| 0 | The operation is successful. |
| Negative value | The operation fails. |
| Negative value | The operation failed. |
Example: Obtain the pull strength of a pin.
......@@ -258,7 +259,7 @@ int32_t PinSetFunc(DevHandle handle, const char *funcName);
| funcName | Pointer to the pin function to set. |
| **Return Value**| **Description** |
| 0 | The operation is successful.|
| Negative value | The operation fails.|
| Negative value | The operation failed.|
Example: Set the pin function to LSADC_CH1 (ADC channel 1).
......@@ -291,7 +292,7 @@ int32_t PinGetFunc(DevHandle handle, const char **funcName);
| funcName | Pointer to the function name obtained.|
| **Return Value**| **Description** |
| 0 | The operation is successful. |
| Negative value | The operation fails. |
| Negative value | The operation failed. |
Example: Obtain the pin function.
......
......@@ -48,11 +48,11 @@ Pulse width modulation (PWM) is a technology that digitally encodes analog signa
### How to Use
The figure below shows the general process of using the PWM.
The figure below illustrates how to use the APIs.
**Figure 1** Process of using the PWM module
**Figure 1** Using the PWM driver APIs
![](figures/process-of-using-PWM.png)
![](figures/using-PWM-process.png)
### Opening a PWM Device Handle
......@@ -71,7 +71,7 @@ DevHandle PwmOpen(uint32_t num);
| num | PWM device number. |
| **Return Value** | **Description** |
| handle | Handle of the PWM device obtained.|
| NULL | The operation fails. |
| NULL | The operation failed. |
Example: Open the device handle of PWM device 0.
......@@ -126,7 +126,7 @@ int32_t PwmEnable(DevHandle handle);
| handle | PWM device handle. |
| **Return Value** | **Description** |
| 0 | The operation is successful. |
| Negative number | The operation fails. |
| Negative number | The operation failed. |
```
......@@ -156,7 +156,7 @@ int32_t PwmDisable(DevHandle handle);
| handle | PWM device handle. |
| **Return Value** | **Description** |
| 0 | The operation is successful. |
| Negative number | The operation fails. |
| Negative number | The operation failed. |
```
......@@ -187,7 +187,7 @@ int32_t PwmSetPeriod(DevHandle handle, uint32_t period);
| period | PWM period to set, in ns.|
| **Return Value**| **Description** |
| 0 | The operation is successful. |
| Negative number | The operation fails. |
| Negative number | The operation failed. |
```
......@@ -218,7 +218,7 @@ int32_t PwmSetDuty(DevHandle handle, uint32_t duty);
| duty | Time that the signal is in the ON state, in ns.|
| **Return Value**| **Description** |
| 0 | The operation is successful. |
| Negative number | The operation fails. |
| Negative number | The operation failed. |
```
......@@ -249,7 +249,7 @@ int32_t PwmSetPolarity(DevHandle handle, uint8_t polarity);
| polarity | Polarity to set, which can be **PWM\_NORMAL\_POLARITY** or **PWM\_INVERTED\_POLARITY**.|
| **Return Value**| **Description** |
| 0 | The operation is successful. |
| Negative number | The operation fails. |
| Negative number | The operation failed. |
```
......@@ -280,7 +280,7 @@ int32_t PwmSetConfig(DevHandle handle, struct PwmConfig *config);
| \*config | Pointer to PWM parameters. |
| **Return Value**| **Description** |
| 0 | The operation is successful. |
| Negative number | The operation fails. |
| Negative number | The operation failed. |
```
......@@ -317,7 +317,7 @@ int32_t PwmGetConfig(DevHandle handle, struct PwmConfig *config);
| \*config | Pointer to PWM parameters. |
| **Return Value**| **Description** |
| 0 | The operation is successful. |
| Negative number | The operation fails. |
| Negative number | The operation failed. |
```
......
......@@ -42,7 +42,8 @@ The regulator module is divided into the following layers:
- The core layer provides the capabilities of binding, initializing, and releasing devices.
- The adaptation layer implements other functions.
![](../public_sys-resources/icon-note.gif)NOTE<br/>The core layer can call the functions of the interface layer and uses the hook to call functions of the adaptation layer. In this way, the adaptation layer can indirectly call the functions of the interface layer, but the interface layer cannot call the functions of the adaptation layer.
> ![icon-note.gif](../public_sys-resources/icon-note.gif) **NOTE**<br/>
> The core layer can call the functions of the interface layer and uses the hook to call functions of the adaptation layer. In this way, the adaptation layer can indirectly call the functions of the interface layer, but the interface layer cannot call the functions of the adaptation layer.
**Figure 1** Unified service mode
......@@ -84,11 +85,11 @@ Regulators are used to:
During the OS startup process, the driver management module loads the regulator driver based on the configuration file. Then, the regulator driver detects the regulator devices and initializes the driver.
The figure below illustrates the process of using a regulator.
The figure below illustrates how to use the APIs.
**Figure 2** Process of using a regulator
**Figure 2** Using regulator driver APIs
![](figures/process-of-using-regulator.png)
![](figures/using-regulator-process.png)
#### Opening a Regulator Device Handle
......@@ -105,7 +106,7 @@ DevHandle RegulatorOpen(const char *name);
| name | Name of the target regulator. |
| **Return Value**| **Description** |
| handle | The regulator device handle is returned if the operation is successful.|
| NULL | The operation fails. |
| NULL | The operation failed. |
......@@ -155,7 +156,7 @@ int32_t RegulatorEnable(DevHandle handle);
| handle | Device handle of the target regulator.|
| **Return Value**| **Description** |
| 0 | The operation is successful. |
| Negative value | The operation fails. |
| Negative value | The operation failed. |
......@@ -184,7 +185,7 @@ int32_t RegulatorDisable(DevHandle handle);
| handle | Device handle of the target regulator.|
| **Return Value**| **Description** |
| 0 | The operation is successful. |
| Negative value | The operation fails. |
| Negative value | The operation failed. |
```
int32_t ret;
......@@ -212,7 +213,7 @@ int32_t RegulatorForceDisable(DevHandle handle);
| handle | Device handle of the target regulator.|
| **Return Value**| **Description** |
| 0 | The operation is successful. |
| Negative value | The operation fails. |
| Negative value | The operation failed. |
```
int32_t ret;
......@@ -241,7 +242,7 @@ int32_t RegulatorSetVoltage(DevHandle handle, uint32_t minUv, uint32_t maxUv);
| maxUv | Maximum voltage to set. |
| **Return Value**| **Description** |
| 0 | The operation is successful. |
| Negative value | The operation fails. |
| Negative value | The operation failed. |
```
int32_t ret;
......@@ -272,7 +273,7 @@ int32_t RegulatorGetVoltage(DevHandle handle, uint32_t *voltage);
| *voltage | Pointer to the regulator voltage information. |
| **Return Value**| **Description** |
| 0 | The operation is successful. |
| Negative value | The operation fails. |
| Negative value | The operation failed. |
```
int32_t ret;
......@@ -302,7 +303,7 @@ int32_t RegulatorSetCurrent(DevHandle handle, uint32_t minUa, uint32_t maxUa);
| maxUa | Maximum current to set. |
| **Return Value**| **Description** |
| 0 | The operation is successful. |
| Negative value | The operation fails. |
| Negative value | The operation failed. |
```
int32_t ret;
......@@ -332,7 +333,7 @@ int32_t RegulatorGetCurrent(DevHandle handle, uint32_t *regCurrent);
| *regCurrent | Pointer to the regulator current information. |
| **Return Value** | **Description** |
| 0 | The operation is successful. |
| Negative value | The operation fails. |
| Negative value | The operation failed. |
```
int32_t ret;
......@@ -361,7 +362,7 @@ int32_t RegulatorGetStatus(DevHandle handle, uint32_t *status);
| *status | Pointer to the regulator status information. |
| **Return Value**| **Description** |
| 0 | The operation is successful. |
| Negative value | The operation fails. |
| Negative value | The operation failed. |
```
int32_t ret;
......
......@@ -95,7 +95,7 @@ The real-time clock \(RTC\) driver provides precise real time for the operating
</tbody>
</table>
>![](../public_sys-resources/icon-note.gif) **NOTE:**
>![](../public_sys-resources/icon-note.gif) **NOTE**<br>
>All functions provided in this document can be called only in kernel mode.
## Usage Guidelines<a name="section20636145604113"></a>
......@@ -104,16 +104,16 @@ The real-time clock \(RTC\) driver provides precise real time for the operating
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](#fig1610020107333) illustrates the process of using an RTC device.
The figure below illustrates how to use the APIs.
**Figure 1** Process of using an RTC device<a name="fig1610020107333"></a>
![](figures/process-of-using-an-rtc-device.png "process-of-using-an-rtc-device")
**Figure 1** Process of using an RTC device
![](figures/using-rtc-process.png "process-of-using-an-rtc-device")
### Creating an RTC Device Handle<a name="section1131212144310"></a>
### Opening the RTC Device Handle<a name="section1131212144310"></a>
After the RTC driver is loaded, you can use the API provided by the HDF and call APIs of the RTC driver.
>![](../public_sys-resources/icon-note.gif) **NOTE:**
>![](../public_sys-resources/icon-note.gif) **NOTE**<br>
>Currently, only one RTC device is supported in the OS.
DevHandle RtcOpen\(void\);
......@@ -138,17 +138,18 @@ DevHandle RtcOpen\(void\);
</tr>
<tr id="row2808192935615"><td class="cellrowborder" valign="top" width="21.45%"><p id="p380852915567"><a name="p380852915567"></a><a name="p380852915567"></a>handle</p>
</td>
<td class="cellrowborder" valign="top" width="78.55%"><p id="p26881319114110"><a name="p26881319114110"></a><a name="p26881319114110"></a>Returns the if the operation is successful.</p>
<td class="cellrowborder" valign="top" width="78.55%"><p id="p26881319114110"><a name="p26881319114110"></a><a name="p26881319114110"></a>The operation is successful.</p>
</td>
</tr>
<tr id="row4808142945615"><td class="cellrowborder" valign="top" width="21.45%"><p id="p188084291561"><a name="p188084291561"></a><a name="p188084291561"></a>NULL</p>
</td>
<td class="cellrowborder" valign="top" width="78.55%"><p id="p780852912566"><a name="p780852912566"></a><a name="p780852912566"></a>The operation fails.</p>
<td class="cellrowborder" valign="top" width="78.55%"><p id="p780852912566"><a name="p780852912566"></a><a name="p780852912566"></a>The operation failed.</p>
</td>
</tr>
</tbody>
</table>
```
DevHandle handle = NULL;
......@@ -161,7 +162,7 @@ if (handle == NULL) {
### Releasing the RTC Device Handle<a name="section10744117144314"></a>
You can call the following function to release the RTC device handle, thereby releasing resources of the device:
You can call **RtcClose()** function to release the RTC device handle, thereby releasing resources of the device.
void RtcClose\(DevHandle handle\);
......@@ -186,7 +187,7 @@ void RtcClose\(DevHandle handle\);
RtcClose(handle);
```
### Registering RtcAlarmCallback<a name="section14839440184320"></a>
### 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:
......@@ -228,7 +229,7 @@ int32\_t RtcRegisterAlarmCallback\(DevHandle handle, enum RtcAlarmIndex alarmInd
</tr>
<tr id="row1241081213303"><td class="cellrowborder" valign="top" width="21.36%" headers="mcps1.2.3.1.1 "><p id="p1123362173010"><a name="p1123362173010"></a><a name="p1123362173010"></a>Negative value</p>
</td>
<td class="cellrowborder" valign="top" width="78.64%" headers="mcps1.2.3.1.2 "><p id="p1723362153010"><a name="p1723362153010"></a><a name="p1723362153010"></a>The operation fails.</p>
<td class="cellrowborder" valign="top" width="78.64%" headers="mcps1.2.3.1.2 "><p id="p1723362153010"><a name="p1723362153010"></a><a name="p1723362153010"></a>The operation failed.</p>
</td>
</tr>
</tbody>
......@@ -257,11 +258,11 @@ if (ret != 0) {
}
```
### Performing RTC-related Operations<a name="section161927578433"></a>
### 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:
Call the **RtcReadTime()** 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\);
......@@ -295,7 +296,7 @@ int32\_t RtcReadTime\(DevHandle handle, struct RtcTime \*time\);
</tr>
<tr id="row15393184519323"><td class="cellrowborder" valign="top" width="21.45%"><p id="p13521182309"><a name="p13521182309"></a><a name="p13521182309"></a>Negative value</p>
</td>
<td class="cellrowborder" valign="top" width="78.55%"><p id="p1035216186309"><a name="p1035216186309"></a><a name="p1035216186309"></a>The operation fails.</p>
<td class="cellrowborder" valign="top" width="78.55%"><p id="p1035216186309"><a name="p1035216186309"></a><a name="p1035216186309"></a>The operation failed.</p>
</td>
</tr>
</tbody>
......@@ -314,7 +315,7 @@ if (ret != 0) {
- Setting RTC time
Call the following function to set the RTC time:
Call the **RtcWriteTime()** function to set the RTC time.
int32\_t RtcWriteTime\(DevHandle handle, struct RtcTime \*time\);
......@@ -348,13 +349,13 @@ int32\_t RtcWriteTime\(DevHandle handle, struct RtcTime \*time\);
</tr>
<tr id="row024153123616"><td class="cellrowborder" valign="top" width="21.54%"><p id="p5602191619300"><a name="p5602191619300"></a><a name="p5602191619300"></a>Negative value</p>
</td>
<td class="cellrowborder" valign="top" width="78.46%"><p id="p12602131643015"><a name="p12602131643015"></a><a name="p12602131643015"></a>The operation fails.</p>
<td class="cellrowborder" valign="top" width="78.46%"><p id="p12602131643015"><a name="p12602131643015"></a><a name="p12602131643015"></a>The operation failed.</p>
</td>
</tr>
</tbody>
</table>
>![](../public_sys-resources/icon-note.gif) **NOTE:**
>![](../public_sys-resources/icon-note.gif) **NOTE**<br>
>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.
```
......@@ -378,7 +379,7 @@ if (ret != 0) {
- Reading the RTC alarm time
Call the following function to read the alarm time:
Call the **RtcReadAlarm()** function to read the alarm time.
int32\_t RtcReadAlarm\(DevHandle handle, enum RtcAlarmIndex alarmIndex, struct RtcTime \*time\);
......@@ -417,7 +418,7 @@ int32\_t RtcReadAlarm\(DevHandle handle, enum RtcAlarmIndex alarmIndex, struct R
</tr>
<tr id="row016911915461"><td class="cellrowborder" valign="top" width="21.54%"><p id="p6833213133013"><a name="p6833213133013"></a><a name="p6833213133013"></a>Negative value</p>
</td>
<td class="cellrowborder" valign="top" width="78.46%"><p id="p168341213143015"><a name="p168341213143015"></a><a name="p168341213143015"></a>The operation fails.</p>
<td class="cellrowborder" valign="top" width="78.46%"><p id="p168341213143015"><a name="p168341213143015"></a><a name="p168341213143015"></a>The operation failed.</p>
</td>
</tr>
</tbody>
......@@ -436,7 +437,7 @@ if (ret != 0) {
- Setting RTC alarm time
Call the following function to set the RTC alarm time based on the alarm index:
Call the **RtcWriteAlarm()** function to set the RTC alarm time based on the alarm index.
int32\_t RtcWriteAlarm\(DevHandle handle, enum RtcAlarmIndex alarmIndex, struct RtcTime \*time\);
......@@ -475,13 +476,13 @@ int32\_t RtcWriteAlarm\(DevHandle handle, enum RtcAlarmIndex alarmIndex, struct
</tr>
<tr id="row1686918225483"><td class="cellrowborder" valign="top" width="21.62%"><p id="p16246181033012"><a name="p16246181033012"></a><a name="p16246181033012"></a>Negative value</p>
</td>
<td class="cellrowborder" valign="top" width="78.38000000000001%"><p id="p3246111019309"><a name="p3246111019309"></a><a name="p3246111019309"></a>The operation fails.</p>
<td class="cellrowborder" valign="top" width="78.38000000000001%"><p id="p3246111019309"><a name="p3246111019309"></a><a name="p3246111019309"></a>The operation failed.</p>
</td>
</tr>
</tbody>
</table>
>![](../public_sys-resources/icon-note.gif) **NOTE:**
>![](../public_sys-resources/icon-note.gif) **NOTE**<br>
>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.
```
......@@ -505,7 +506,7 @@ if (ret != 0) {
- 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:
Before performing alarm operations, use the **RtcAlarmInterruptEnable()** 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\);
......@@ -544,7 +545,7 @@ int32\_t RtcAlarmInterruptEnable\(DevHandle handle, enum RtcAlarmIndex alarmInde
</tr>
<tr id="row2347115321514"><td class="cellrowborder" valign="top" width="21.36%"><p id="p324855163018"><a name="p324855163018"></a><a name="p324855163018"></a>Negative value</p>
</td>
<td class="cellrowborder" valign="top" width="78.64%"><p id="p7248857302"><a name="p7248857302"></a><a name="p7248857302"></a>The operation fails.</p>
<td class="cellrowborder" valign="top" width="78.64%"><p id="p7248857302"><a name="p7248857302"></a><a name="p7248857302"></a>The operation failed.</p>
</td>
</tr>
</tbody>
......@@ -562,7 +563,7 @@ if (ret != 0) {
- Reading RTC external frequency
Call the following function to read the frequency of the external crystal oscillator connected to the RTC driver:
Call the **RtcGetFreq()** function to read the frequency of the external crystal oscillator connected to the RTC driver.
int32\_t RtcGetFreq\(DevHandle handle, uint32\_t \*freq\);
......@@ -596,7 +597,7 @@ int32\_t RtcGetFreq\(DevHandle handle, uint32\_t \*freq\);
</tr>
<tr id="row135892261811"><td class="cellrowborder" valign="top" width="21.36%"><p id="p152692538292"><a name="p152692538292"></a><a name="p152692538292"></a>Negative value</p>
</td>
<td class="cellrowborder" valign="top" width="78.64%"><p id="p327015313294"><a name="p327015313294"></a><a name="p327015313294"></a>The operation fails.</p>
<td class="cellrowborder" valign="top" width="78.64%"><p id="p327015313294"><a name="p327015313294"></a><a name="p327015313294"></a>The operation failed.</p>
</td>
</tr>
</tbody>
......@@ -615,7 +616,7 @@ if (ret != 0) {
- 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:
Call the **RtcSetFreq()** function to set the frequency of the external crystal oscillator connected to the RTC driver.
int32\_t RtcSetFreq\(DevHandle handle, uint32\_t freq\);
......@@ -649,7 +650,7 @@ int32\_t RtcSetFreq\(DevHandle handle, uint32\_t freq\);
</tr>
<tr id="row10702194313201"><td class="cellrowborder" valign="top" width="21.36%"><p id="p165182216306"><a name="p165182216306"></a><a name="p165182216306"></a>Negative value</p>
</td>
<td class="cellrowborder" valign="top" width="78.64%"><p id="p651815219302"><a name="p651815219302"></a><a name="p651815219302"></a>The operation fails.</p>
<td class="cellrowborder" valign="top" width="78.64%"><p id="p651815219302"><a name="p651815219302"></a><a name="p651815219302"></a>The operation failed.</p>
</td>
</tr>
</tbody>
......@@ -668,7 +669,7 @@ if (ret != 0) {
- 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\):
Call the **RtcReset()** 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\);
......@@ -697,7 +698,7 @@ int32\_t RtcReset\(DevHandle handle\);
</tr>
<tr id="row16990133152516"><td class="cellrowborder" valign="top" width="21.36%"><p id="p17536173573015"><a name="p17536173573015"></a><a name="p17536173573015"></a>Negative value</p>
</td>
<td class="cellrowborder" valign="top" width="78.64%"><p id="p1153623503014"><a name="p1153623503014"></a><a name="p1153623503014"></a>The operation fails.</p>
<td class="cellrowborder" valign="top" width="78.64%"><p id="p1153623503014"><a name="p1153623503014"></a><a name="p1153623503014"></a>The operation failed.</p>
</td>
</tr>
</tbody>
......@@ -715,7 +716,7 @@ if (ret != 0) {
- 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\):
Call the **RtcReadReg()** 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\);
......@@ -754,7 +755,7 @@ int32\_t RtcReadReg\(DevHandle handle, uint8\_t usrDefIndex, uint8\_t \*value\);
</tr>
<tr id="row1424719410333"><td class="cellrowborder" valign="top" width="21.62%"><p id="p112477417335"><a name="p112477417335"></a><a name="p112477417335"></a>Negative value</p>
</td>
<td class="cellrowborder" valign="top" width="78.38000000000001%"><p id="p7247547338"><a name="p7247547338"></a><a name="p7247547338"></a>The operation fails.</p>
<td class="cellrowborder" valign="top" width="78.38000000000001%"><p id="p7247547338"><a name="p7247547338"></a><a name="p7247547338"></a>The operation failed.</p>
</td>
</tr>
</tbody>
......@@ -774,7 +775,7 @@ if (ret != 0) {
- 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\):
Call the **RtcWriteReg()** 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\);
......@@ -813,7 +814,7 @@ int32\_t RtcWriteReg\(DevHandle handle, uint8\_t usrDefIndex, uint8\_t value\);
</tr>
<tr id="row127231848123615"><td class="cellrowborder" valign="top" width="21.62%"><p id="p197231148173613"><a name="p197231148173613"></a><a name="p197231148173613"></a>Negative value</p>
</td>
<td class="cellrowborder" valign="top" width="78.38000000000001%"><p id="p16723134823618"><a name="p16723134823618"></a><a name="p16723134823618"></a>The operation fails.</p>
<td class="cellrowborder" valign="top" width="78.38000000000001%"><p id="p16723134823618"><a name="p16723134823618"></a><a name="p16723134823618"></a>The operation failed.</p>
</td>
</tr>
</tbody>
......@@ -927,4 +928,3 @@ void RtcTestSample(void)
RtcClose(handle);
}
```
\ No newline at end of file
# SDIO<a name="EN-US_TOPIC_0000001160653028"></a>
# SDIO
## Overview<a name="section1155271783811"></a>
- 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.
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.
- 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.
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.
**Figure 1** Connections between the host and devices in SDIO<a name="fig1185316527498"></a>
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
![](figures/en-us_image_0000001160971556.png)
![](figures/en-us_image_0000001160971556.png)
- 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.
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<a name="section12601496259"></a>
......@@ -141,19 +141,21 @@
</tbody>
</table>
>![](../public_sys-resources/icon-note.gif) **NOTE:**
>![](../public_sys-resources/icon-note.gif) **NOTE:**<br>
>All functions provided in this document can be called only in kernel mode.
## Usage Guidelines<a name="section1878939192515"></a>
### How to Use<a name="section1490685512255"></a>
[Figure 2](#fig1343742311264) illustrates the process of using an SDIO.
The figure below illustrates how to use the APIs.
**Figure 2** Process of using an SDIO<a name="fig1343742311264"></a>
**Figure 2** Using SDIO driver APIs
![](figures/en-us_image_0000001206291517.png)
![](figures/using-SDIO-process.png)
### Opening an SDIO Controller<a name="section10782428132616"></a>
......@@ -1048,4 +1050,3 @@ ENABLE_ERR:
SdioClose(handle);
}
```
\ No newline at end of file
......@@ -2,21 +2,21 @@
## Overview<a name="section193356154511"></a>
- 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
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](#fig89085710359) 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](#fig89085710359) 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<a name="fig89085710359"></a>
![](figures/spi-controller-device-connection.png "spi-controller-device-connection")
- SPI communication is usually initiated by the SPI controller and is operated as follows:
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.
......@@ -36,7 +36,7 @@
- Obtaining and setting SPI device configuration parameters.
>![](../public_sys-resources/icon-note.gif) **NOTE:**
>![](../public_sys-resources/icon-note.gif) **NOTE**<br>
>Currently, these functions are only applicable in the communication initiated by the SPI controller.
## Available APIs<a name="section1325964832615"></a>
......@@ -104,10 +104,10 @@
### How to Use<a name="section32846814820"></a>
[Figure 2](#fig1586912310348) shows the process of using an SPI device.
The figure below illustrates how to use the APIs.
**Figure 2** Process of using an SPI device<a name="fig1586912310348"></a>
![](figures/process-of-using-an-spi-device.png "process-of-using-an-spi-device")
**Figure 2** Using SPI driver APIs<a name="fig1586912310348"></a>
![](figures/using-spi-process.png "process-of-using-an-spi-device")
### Obtaining an SPI Device Handle<a name="section1927265711481"></a>
......@@ -546,4 +546,3 @@ err:
SpiClose(spiHandle);
}
```
\ No newline at end of file
......@@ -2,13 +2,13 @@
## Overview<a name="section833012453535"></a>
- 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](#fig68294715408)\) or four wires \(as shown in [Figure 2](#fig179241542163112)\).
- 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.
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](#fig68294715408)\) or four wires \(as shown in [Figure 2](#fig179241542163112)\).
- 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<a name="fig68294715408"></a>
![](figures/2-wire-uart-communication.png "2-wire-uart-communication")
......@@ -17,11 +17,13 @@
![](figures/4-wire-uart-communication.png "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.
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.
## Available APIs<a name="section1928742202715"></a>
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.
**Table 1** APIs for the UART driver
<a name="table1731550155318"></a>
......@@ -94,17 +96,17 @@
</tbody>
</table>
>![](../public_sys-resources/icon-note.gif) **NOTE:**
>![](../public_sys-resources/icon-note.gif) **NOTE**<br>
>All functions provided in this document can be called only in kernel space.
## Usage Guidelines<a name="section12779050105412"></a>
### How to Use<a name="section1858116395510"></a>
[Figure 3](#fig99673244388) shows the process of using a UART device.
The figure below illustrates how to use the APIs.
**Figure 3** Process of using a UART device<a name="fig99673244388"></a>
![](figures/process-of-using-a-uart-device.png "process-of-using-a-uart-device")
**Figure 3** Using UART driver APIs<a name="fig99673244388"></a>
![](figures/using-uart-process.png "process-of-using-a-uart-device")
### Obtaining a UART Device Handle<a name="section124512065617"></a>
......@@ -656,4 +658,3 @@ _ERR:
UartClose(handle);
}
```
\ No newline at end of file
......@@ -70,17 +70,17 @@ A watchdog, also called a watchdog timer, is a hardware timing device. If an err
</tbody>
</table>
>![](../public_sys-resources/icon-note.gif) **NOTE:**
>![](../public_sys-resources/icon-note.gif) **NOTE**<br>
>All watchdog functions provided in this document can be called only in kernel mode.
## Usage Guidelines<a name="section10103184312813"></a>
### How to Use<a name="section10181195910815"></a>
[Figure 1](#fig430533913392) illustrates the process of using a watchdog.
The figure below illustrates how to use the APIs.
**Figure 1** Process of using a watchdog<a name="fig430533913392"></a>
![](figures/process-of-using-a-watchdog.png "process-of-using-a-watchdog")
**Figure 1** Using watchdog driver APIs
![](figures/using-watchdog-process.png "process-of-using-a-watchdog")
### Opening a Watchdog<a name="section66089201107"></a>
......@@ -536,4 +536,3 @@ static int32_t TestCaseWatchdog(void)
return -1;
}
```
\ No newline at end of file
......@@ -27,7 +27,7 @@
- Kernel Debugging
- [Memory Debugging](kernel-mini-memory-debug.md)
- [Memory Information Statistics](kernel-mini-memory-debug-mes.md)
- [Memory Leak Check](kernel-mini-imemory-debug-det.md)
- [Memory Leak Check](kernel-mini-memory-debug-det.md)
- [Memory Corruption Check](kernel-mini-memory-debug-cet.md)
- [Exception Debugging](kernel-mini-memory-exception.md)
- [Trace](kernel-mini-memory-trace.md)
......@@ -181,4 +181,3 @@
- [Task Scheduling](kernel-standard-sched.md)
- [Related Thread Group](kernel-standard-sched-rtg.md)
- [Lightweight CPU Isolation](kernel-standard-sched-cpuisolation.md)
\ No newline at end of file
\ No newline at end of file
......@@ -4,19 +4,19 @@
Dynamic memory management allows memory blocks of any size to be allocated from a large contiguous memory \(memory pool or heap memory\) configured in the system based on user demands when memory resources are sufficient. The memory block can be released for further use when not required. Compared with static memory management, dynamic memory management allows memory allocation on demand but causes fragmentation of memory.
The dynamic memory of the OpenHarmony LiteOS-M has optimized the memory space partitioning based on the Two-Level Segregate Fit \(TLSF\) algorithm to achieve higher performance and minimize fragmentation. [Figure 1](#fig1179964042818) shows the core algorithm of the dynamic memory.
The dynamic memory of the OpenHarmony LiteOS-M has optimized the memory space partitioning based on the Two-Level Segregate Fit \(TLSF\) algorithm to achieve higher performance and minimize fragmentation. The figure below shows the core algorithm of the dynamic memory.
**Figure 1** Dynamic memory algorithm for mini systems
![](figures/dynamic-memory-algorithm-for-mini-systems.png "dynamic-memory-algorithm-for-mini-systems")
Multiple free lists are used for management based on the size of the free memory block. The free memory blocks are divided into two parts: \[4, 127\] and \[2<sup>7</sup>, 2<sup>31</sup>\], as indicated by the size class in [Figure 1](#fig1179964042818).
Multiple free lists are used for management based on the size of the free memory block. The free memory blocks are divided into two parts: \[4, 127\] and \[2<sup>7</sup>, 2<sup>31</sup>\], as indicated by the size class in the above figure.
1. The memory in the range of \[4, 127\] \(lower part in [Figure 1](#fig1179964042818)\) is divided into 31 parts. The size of the memory block corresponding to each part is a multiple of 4 bytes. Each part corresponds to a free list and a bit that indicates whether the free list is empty. The value **1** indicates that the free list is not empty. There are 31 bits corresponding to the 31 memory parts in the range of \[4, 127\].
2. The memory greater than 127 bytes is managed in power of two increments. The size of each range is \[2^n, 2^\(n+1\)-1\], where n is an integer in \[7, 30\]. This range is divided into 24 parts, each of which is further divided into 8 second-level \(L2\) ranges, as shown in Size Class and Size SubClass in the upper part of [Figure 1](#fig1179964042818). Each L2 range corresponds to a free list and a bit that indicates whether the free list is empty. There are a total of 192 \(24 x 8\) L2 ranges, corresponding to 192 free lists and 192 bits.
1. The memory in the range of \[4, 127\] \(lower part in the above figure) is divided into 31 parts. The size of the memory block corresponding to each part is a multiple of 4 bytes. Each part corresponds to a free list and a bit that indicates whether the free list is empty. The value **1** indicates that the free list is not empty. There are 31 bits corresponding to the 31 memory parts in the range of \[4, 127\].
2. The memory greater than 127 bytes is managed in power of two increments. The size of each range is \[2^n, 2^\(n+1\)-1\], where n is an integer in \[7, 30\]. This range is divided into 24 parts, each of which is further divided into 8 second-level \(L2\) ranges, as shown in Size Class and Size SubClass in the upper part of the above figure. Each L2 range corresponds to a free list and a bit that indicates whether the free list is empty. There are a total of 192 \(24 x 8\) L2 ranges, corresponding to 192 free lists and 192 bits.
For example, insert 40-byte free memory to a free list. The 40-byte free memory corresponds to the 10th free list in the range of \[40, 43\], and the 10th bit indicates the use of the free list. The system inserts the 40-byte free memory to the 10th free list and determines whether to update the bitmap flag. When 40-byte memory is requested, the system obtains the free list corresponding to the memory block of the requested size based on the bitmap flag, and then obtains a free memory node from the free list. If the size of the allocated node is greater than the memory requested, the system splits the node and inserts the remaining node to the free list. If 580-byte free memory needs to be inserted to a free list, the 580-byte free memory corresponds to the 47th \(31 + 2 x 8\) free list in L2 range \[2^9, 2^9+2^6\], and the 47th bit indicates the use of the free list. The system inserts the 580-byte free memory to the 47th free list and determines whether to update the bitmap flag. When 580-byte memory is requested, the system obtains the free list corresponding to the memory block of the requested size based on the bitmap flag, and then obtains a free memory node from the free list. If the size of the allocated node is greater than the memory requested, the system splits the node and inserts the remaining node to the free list. If the corresponding free list is empty, the system checks for a free list meeting the requirements in a larger memory range. In actual application, the system can locate the free list that meets the requirements at a time.
[Figure 2](#fig10997102213017) shows the memory management structure.
The figure below shows the memory management structure.
**Figure 2** Dynamic memory management structure for mini systems
![](figures/dynamic-memory-management-structure-for-mini-systems.png "dynamic-memory-management-structure-for-mini-systems")
......@@ -30,7 +30,7 @@ For example, insert 40-byte free memory to a free list. The 40-byte free memory
There are three types of nodes: free node, used node, and end node. Each memory node maintains the size and use flag of the memory node and a pointer to the previous memory node in the memory pool. The free nodes and used nodes have a data area, but the end node has no data area.
The off-chip physical memory needs to be used because the on-chip RAMs of some chips cannot meet requirements. The OpenHarmony LiteOS-M kernel can logically combine multiple discontiguous memory regions so that users are unaware of the discontiguous memory regions in the underlying layer. The OpenHarmony LiteOS-M kernel memory module inserts discontiguous memory regions into a free list as free memory nodes and marks the discontiguous parts as virtual memory nodes that have been used. In this way, the discontinuous memory regions are logically combined as a unified memory pool. [Figure 3](#fig18471556115917) shows how the discontiguous memory regions are logically integrated.
The off-chip physical memory needs to be used because the on-chip RAMs of some chips cannot meet requirements. The OpenHarmony LiteOS-M kernel can logically combine multiple discontiguous memory regions so that users are unaware of the discontiguous memory regions in the underlying layer. The OpenHarmony LiteOS-M kernel memory module inserts discontiguous memory regions into a free list as free memory nodes and marks the discontiguous parts as virtual memory nodes that have been used. In this way, the discontinuous memory regions are logically combined as a unified memory pool. The figure below shows how the discontiguous memory regions are logically integrated.
**Figure 3** Integrating discontiguous memory regions
![](figures/integrating-discontiguous-memory-regions.png "integrating-discontiguous-memory-regions")
......
......@@ -4,7 +4,7 @@
The OpenHarmony LiteOS-M kernel is a lightweight operating system \(OS\) kernel designed for the IoT field. It features small size, low power consumption, and high performance. The LiteOS-M kernel has simple code structure, including the minimum function set, kernel abstraction layer \(KAL\), optional components, and project directory. It supports the Hardware Driver Foundation \(HDF\), which provides unified driver standards and access mode for device vendors to simplify porting of drivers and allow one-time development for multi-device deployment.
The OpenHarmony LiteOS-M kernel architecture consists of the hardware layer and hardware-irrelevant layers, as shown in [Figure 1](#fig1287712172318). The hardware layer is classified based on the compiler toolchain and chip architecture, and provides a unified Hardware Abstraction Layer \(HAL\) interface to improve hardware adaptation and facilitate the expansion of various types of AIoT hardware and compilation toolchains. The other modules are irrelevant to the hardware. The basic kernel module provides basic kernel capabilities. The extended modules provide capabilities of components, such as the network and file systems, as well as exception handling and debug tools. The KAL provides unified standard APIs.
The OpenHarmony LiteOS-M kernel architecture consists of the hardware layer and hardware-irrelevant layers, as shown in the figure below. The hardware layer is classified based on the compiler toolchain and chip architecture, and provides a unified Hardware Abstraction Layer \(HAL\) interface to improve hardware adaptation and facilitate the expansion of various types of AIoT hardware and compilation toolchains. The other modules are irrelevant to the hardware. The basic kernel module provides basic kernel capabilities. The extended modules provide capabilities of components, such as the network and file systems, as well as exception handling and debug tools. The KAL provides unified standard APIs.
**Figure 1** Kernel architecture
![](figures/kernel-architecture.png "kernel-architecture")
......@@ -52,7 +52,7 @@ LiteOS-M supports mainstream architectures, such as ARM Cortex-M3, ARM Cortex-M4
### Working Principles
Configure the system clock and number of ticks per second in the **target\_config.h** file of the development board. Configure the task, memory, inter-process communication \(IPC\), and exception handling modules based on service requirements. When the system boots, the modules are initialized based on the configuration. The kernel startup process includes peripheral initialization, system clock configuration, kernel initialization, and OS boot. For details, see [Figure 2](#fig74259220441).
Configure the system clock and number of ticks per second in the **target\_config.h** file of the development board. Configure the task, memory, inter-process communication \(IPC\), and exception handling modules based on service requirements. When the system boots, the modules are initialized based on the configuration. The kernel startup process includes peripheral initialization, system clock configuration, kernel initialization, and OS boot, as shown in the figure below.
**Figure 2** Kernel startup process
![](figures/kernel-startup-process.png "kernel-startup-process")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册