提交 2732812b 编写于 作者: A Annie_wang

update docs

Signed-off-by: NAnnie_wang <annie.wangli@huawei.com>
上级 55733878
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
## When to Use ## 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 ## Available APIs
...@@ -15,7 +15,7 @@ Call **createDistributedObject()** to create a distributed data object instance. ...@@ -15,7 +15,7 @@ Call **createDistributedObject()** to create a distributed data object instance.
**Table 1** API for creating a distributed data object instance **Table 1** API for creating a distributed data object instance
| Package| API| Description| | 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 ### Generating a Session ID
...@@ -28,12 +28,12 @@ Call **genSessionId()** to generate a session ID randomly. The generated session ...@@ -28,12 +28,12 @@ Call **genSessionId()** to generate a session ID randomly. The generated session
### Setting a SessionID for Distributed Data Objects ### 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 **Table 3** API for setting a session ID
| Class| API| Description| | 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 ### Observing Data Changes
...@@ -43,7 +43,7 @@ Call **on()** to subscribe to data changes of a distributed data object. When th ...@@ -43,7 +43,7 @@ Call **on()** to subscribe to data changes of a distributed data object. When th
| Class| API| Description| | Class| API| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| DistributedDataObject| on(type: 'change', callback: Callback<{ sessionId: string, fields: Array&lt;string&gt; }>): void | Subscribes to data changes.| | 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 ### Observing Online or Offline Status
...@@ -90,10 +90,10 @@ The following example shows how to implement a distributed data object synchroni ...@@ -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, var remote_object = distributedObject.createDistributedObject({name:undefined, age:undefined, isVis:true,
parent:undefined, list:undefined}); parent:undefined, list:undefined});
remote_object.setSessionId(sessionId); 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: The sample code is as follows:
...@@ -108,8 +108,8 @@ The following example shows how to implement a distributed data object synchroni ...@@ -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 // To refresh the page in changeCallback, correctly bind (this) to the changeCallback.
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). 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 ...@@ -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"}]; 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: > For the distributed data object of the complex type, only the root attribute can be modified. The subordinate attributes cannot be modified. Example:
```js ```js
// Supported modification. // Supported modification.
...@@ -142,7 +142,7 @@ The following example shows how to implement a distributed data object synchroni ...@@ -142,7 +142,7 @@ The following example shows how to implement a distributed data object synchroni
The sample code is as follows: The sample code is as follows:
```js ```js
// Unsubscribe from changeCallback. // Unsubscribe from the specified data change callback.
local_object.off("change", changeCallback); local_object.off("change", changeCallback);
// Unsubscribe from all data change callbacks. // Unsubscribe from all data change callbacks.
local_object.off("change"); local_object.off("change");
...@@ -156,27 +156,27 @@ The following example shows how to implement a distributed data object synchroni ...@@ -156,27 +156,27 @@ The following example shows how to implement a distributed data object synchroni
local_object.on("status", this.statusCallback); 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: The sample code is as follows:
```js ```js
// Unsubscribe from the online status change callback. // Unsubscribe from the specified status change callback.
local_object.off("status", statusCallback); local_object.off("status", statusCallback);
// Unsubscribe from all online status change callbacks. // Unsubscribe from all status change callbacks.
local_object.off("status"); 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: The sample code is as follows:
```js ```js
local_object.setSessionId(""); 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) - [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 @@ ...@@ -2,7 +2,7 @@
## When to Use ## 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 ## Available APIs
...@@ -15,7 +15,7 @@ The table below describes the APIs provided by the OpenHarmony DDS module. ...@@ -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.| | 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**.| | 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| 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. | | 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. | | 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 ...@@ -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. 3. Create and obtain a single KV store.
1. Declare the ID of the single KV store to create. 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: The sample code is as follows:
```js ```js
...@@ -159,7 +159,7 @@ The following uses a single KV store as an example to describe the development p ...@@ -159,7 +159,7 @@ The following uses a single KV store as an example to describe the development p
deviceManager.createDeviceManager("bundleName", (err, value) => { deviceManager.createDeviceManager("bundleName", (err, value) => {
if (!err) { if (!err) {
devManager = value; devManager = value;
// get deviceIds // Obtain deviceIds.
let deviceIds = []; let deviceIds = [];
if (devManager != null) { if (devManager != null) {
var devices = devManager.getTrustedDeviceListSync(); var devices = devManager.getTrustedDeviceListSync();
...@@ -177,5 +177,5 @@ The following uses a single KV store as an example to describe the development p ...@@ -177,5 +177,5 @@ The following uses a single KV store as an example to describe the development p
``` ```
## Samples ## Samples
The following samples are provided to help you better understand the distributed data development: 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) - [`KvStore`: Distributed Data Management (eTS) (API8)](https://gitee.com/openharmony/app_samples/tree/master/data/Kvstore)
- [Distributed Database](https://gitee.com/openharmony/codelabs/tree/master/Data/JsDistributedData) - [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. ...@@ -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**. 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/> > ![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.** > After a result set is used, you must call the **close()** method to close it explicitly.
**Table 7** APIs for using the result set **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 ...@@ -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 tableName = rdbStore.obtainDistributedTableName(deviceId, "test");
let resultSet = rdbStore.querySql("SELECT * FROM " + tableName) 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 # 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. > 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 ...@@ -22,6 +22,7 @@ Creates an **RdbPredicates** object based on a **DataAabilityPredicates** object
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core **System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| name | string | Yes| Table name in the RDB store.| | name | string | Yes| Table name in the RDB store.|
......
# Distributed Data Object # 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. > 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 @@ ...@@ -10,8 +10,6 @@
import distributedObject from '@ohos.data.distributedDataObject'; import distributedObject from '@ohos.data.distributedDataObject';
``` ```
## distributedDataObject.createDistributedObject ## distributedDataObject.createDistributedObject
createDistributedObject(source: object): DistributedObject createDistributedObject(source: object): DistributedObject
......
# Result Set # 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. > 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,7 +3,7 @@ ...@@ -3,7 +3,7 @@
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. 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.
> >
...@@ -30,7 +30,7 @@ import dataStorage from '@ohos.data.storage'; ...@@ -30,7 +30,7 @@ import dataStorage from '@ohos.data.storage';
getStorageSync(path: string): 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 **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
...@@ -67,7 +67,7 @@ Reads a file and loads the data to the **Storage** instance in synchronous mode. ...@@ -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 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 **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 ...@@ -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; 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 **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 ...@@ -146,7 +146,7 @@ Reads a file and loads the data to the **Storage** instance. This API uses a pro
deleteStorageSync(path: string): void 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 **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
...@@ -165,7 +165,7 @@ Deletes the singleton **Storage** instance of a file from the memory, and delete ...@@ -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 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 **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
...@@ -191,7 +191,7 @@ Deletes the singleton **Storage** instance of a file from the memory, and delete ...@@ -191,7 +191,7 @@ Deletes the singleton **Storage** instance of a file from the memory, and delete
deleteStorage(path: string): Promise&lt;void&gt; 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 **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
...@@ -222,8 +222,6 @@ removeStorageFromCacheSync(path: string): void ...@@ -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. 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 **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Parameters** **Parameters**
...@@ -241,9 +239,7 @@ This API uses a synchronous mode. ...@@ -241,9 +239,7 @@ This API uses a synchronous mode.
removeStorageFromCache(path: string, callback: AsyncCallback&lt;void&gt;): void 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. 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.
This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
...@@ -269,9 +265,7 @@ This API uses an asynchronous callback to return the result. ...@@ -269,9 +265,7 @@ This API uses an asynchronous callback to return the result.
removeStorageFromCache(path: string): Promise&lt;void&gt; 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. 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.
This API uses a promise to return the result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
...@@ -307,8 +301,6 @@ getSync(key: string, defValue: ValueType): ValueType ...@@ -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. 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 **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Parameters** **Parameters**
...@@ -333,9 +325,7 @@ This API uses a synchronous mode. ...@@ -333,9 +325,7 @@ This API uses a synchronous mode.
get(key: string, defValue: ValueType, callback: AsyncCallback&lt;ValueType&gt;): void 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. 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.
This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
...@@ -362,9 +352,7 @@ This API uses an asynchronous callback to return the result. ...@@ -362,9 +352,7 @@ This API uses an asynchronous callback to return the result.
get(key: string, defValue: ValueType): Promise&lt;ValueType&gt; 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. 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.
This API uses a promise to return the result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
...@@ -397,8 +385,6 @@ putSync(key: string, value: ValueType): void ...@@ -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()**. 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 **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Parameters** **Parameters**
...@@ -417,9 +403,7 @@ This API uses a synchronous mode. ...@@ -417,9 +403,7 @@ This API uses a synchronous mode.
put(key: string, value: ValueType, callback: AsyncCallback&lt;void&gt;): void 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()**. 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.
This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
...@@ -446,9 +430,7 @@ This API uses an asynchronous callback to return the result. ...@@ -446,9 +430,7 @@ This API uses an asynchronous callback to return the result.
put(key: string, value: ValueType): Promise&lt;void&gt; 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()**. 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.
This API uses a promise to return the result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
...@@ -480,8 +462,6 @@ hasSync(key: string): boolean ...@@ -480,8 +462,6 @@ hasSync(key: string): boolean
Checks whether the storage object contains data with a given key. Checks whether the storage object contains data with a given key.
This API uses a synchronous mode.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Parameters** **Parameters**
...@@ -507,9 +487,7 @@ This API uses a synchronous mode. ...@@ -507,9 +487,7 @@ This API uses a synchronous mode.
has(key: string, callback: AsyncCallback&lt;boolean&gt;): boolean has(key: string, callback: AsyncCallback&lt;boolean&gt;): boolean
Checks whether the storage object contains data with a given key. Checks whether the storage object contains data with a given key. This API uses an asynchronous callback to return the result.
This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
...@@ -542,9 +520,7 @@ This API uses an asynchronous callback to return the result. ...@@ -542,9 +520,7 @@ This API uses an asynchronous callback to return the result.
has(key: string): Promise&lt;boolean&gt; has(key: string): Promise&lt;boolean&gt;
Checks whether the storage object contains data with a given key. Checks whether the storage object contains data with a given key. This API uses a promise to return the result.
This API uses a promise to return the result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
...@@ -577,8 +553,6 @@ deleteSync(key: string): void ...@@ -577,8 +553,6 @@ deleteSync(key: string): void
Deletes data with the specified key from this storage object. Deletes data with the specified key from this storage object.
This API uses a synchronous mode.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Parameters** **Parameters**
...@@ -592,13 +566,11 @@ This API uses a synchronous mode. ...@@ -592,13 +566,11 @@ This API uses a synchronous mode.
``` ```
### deletej ### delete
delete(key: string, callback: AsyncCallback&lt;void&gt;): void delete(key: string, callback: AsyncCallback&lt;void&gt;): void
Deletes data with the specified key from this storage object. Deletes data with the specified key from this storage object. This API uses an asynchronous callback to return the result.
This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
...@@ -624,9 +596,7 @@ This API uses an asynchronous callback to return the result. ...@@ -624,9 +596,7 @@ This API uses an asynchronous callback to return the result.
delete(key: string): Promise&lt;void&gt; delete(key: string): Promise&lt;void&gt;
Deletes data with the specified key from this storage object. Deletes data with the specified key from this storage object. This API uses a promise to return the result.
This API uses a promise to return the result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
...@@ -657,8 +627,6 @@ flushSync(): void ...@@ -657,8 +627,6 @@ flushSync(): void
Saves the modification of this object to the **Storage** instance and synchronizes the modification to the file. 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 **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Example** **Example**
...@@ -671,9 +639,7 @@ This API uses a synchronous mode. ...@@ -671,9 +639,7 @@ This API uses a synchronous mode.
flush(callback: AsyncCallback&lt;void&gt;): void flush(callback: AsyncCallback&lt;void&gt;): void
Saves the modification of this object to the **Storage** instance and synchronizes the modification to the file. 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.
This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
...@@ -698,9 +664,7 @@ This API uses an asynchronous callback to return the result. ...@@ -698,9 +664,7 @@ This API uses an asynchronous callback to return the result.
flush(): Promise&lt;void&gt; flush(): Promise&lt;void&gt;
Saves the modification of this object to the **Storage** instance and synchronizes the modification to the file. 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.
This API uses a promise to return the result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
...@@ -726,8 +690,6 @@ clearSync(): void ...@@ -726,8 +690,6 @@ clearSync(): void
Clears this **Storage** object. Clears this **Storage** object.
This API uses a synchronous mode.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Example** **Example**
...@@ -740,9 +702,7 @@ This API uses a synchronous mode. ...@@ -740,9 +702,7 @@ This API uses a synchronous mode.
clear(callback: AsyncCallback&lt;void&gt;): void clear(callback: AsyncCallback&lt;void&gt;): void
Clears this **Storage** object. Clears this **Storage** object. This API uses an asynchronous callback to return the result.
This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
...@@ -767,9 +727,7 @@ This API uses an asynchronous callback to return the result. ...@@ -767,9 +727,7 @@ This API uses an asynchronous callback to return the result.
clear(): Promise&lt;void&gt; clear(): Promise&lt;void&gt;
Clears this **Storage** object. Clears this **Storage** object. This API uses a promise to return the result.
This API uses a promise to return the result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
......
...@@ -2,7 +2,7 @@ ...@@ -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. 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. >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. ...@@ -2922,6 +2922,7 @@ These value types can be used only by internal applications.
| BOOLEAN |4 |Boolean. | | BOOLEAN |4 |Boolean. |
| DOUBLE |5 |Double (double-precision floating point). | | DOUBLE |5 |Double (double-precision floating point). |
## SingleKVStore ## 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. 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 ...@@ -3447,7 +3448,7 @@ Closes the **KvStoreResultSet** object obtained by **getResultSet**. This API us
| Name | Type| Mandatory | Description | | Name | Type| Mandatory | Description |
| ----- | ------ | ---- | ----------------------- | | ----- | ------ | ---- | ----------------------- |
| resultSet |[KvStoreResultSet](#kvstoreresultset8) | Yes |**KvStoreResultSet** object to close. | | 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** **Example**
......
# Data Storage # 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). From API Version 9, you are advised to use [`@ohos.data.preferences`](js-apis-data-preferences.md).
> >
...@@ -67,7 +67,7 @@ Sets the value in the cache based on the specified key. ...@@ -67,7 +67,7 @@ Sets the value in the cache based on the specified key.
| Name| Type| Mandatory| Description| | 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.| | value | string | Yes| New value to set. The maximum length is 128 bytes.|
| success | Function | No| Called when **storage.set()** is successful.| | 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.| | fail | Function | No| Called when **storage.set()** fails. In the callback, **data** indicates the error information, and **code** indicates the error code.|
......
...@@ -2,13 +2,14 @@ ...@@ -2,13 +2,14 @@
## Overview<a name="section1"></a> ## 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: The ADC APIs provide a set of common functions for ADC data transfer, including:
- Opening or closing an ADC device - Opening or closing an ADC device
- Obtaining the analog-to-digital (AD) conversion result
**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") ![](figures/ADC_physical_connection.png "ADC_physical_connection")
...@@ -51,11 +52,11 @@ ...@@ -51,11 +52,11 @@
### How to Use<a name="section4"></a> ### 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> ### Opening an ADC Device<a name="section5"></a>
......
...@@ -42,7 +42,8 @@ The DAC module is divided into the following layers: ...@@ -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 core layer provides the capabilities of binding, initializing, and releasing devices.
- The adaptation layer implements other functions. - 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 **Figure 1** Unified service mode
...@@ -68,15 +69,15 @@ The table below describes the APIs of the DAC module. For more details, see API ...@@ -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. | | DevHandle DacOpen(uint32_t number) | Opens a DAC device. |
| void DacClose(DevHandle handle) | Closes 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 ### 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 #### Opening a DAC Device
...@@ -110,7 +111,7 @@ if (dacHandle == NULL) { ...@@ -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); int32_t DacWrite(DevHandle handle, uint32_t channel, uint32_t val);
......
...@@ -2,19 +2,20 @@ ...@@ -2,19 +2,20 @@
## Overview<a name="section5361140416"></a> ## Overview<a name="section5361140416"></a>
- The Inter-Integrated Circuit \(I2C\) is a simple, bidirectional, and synchronous serial bus that uses merely two wires. The Inter-Integrated Circuit \(I2C\) is a simple, bidirectional, and synchronous serial bus that uses merely two wires.
- In an I2C communication, one controller communicates with one or more devices through the serial data line \(SDA\) and serial clock line \(SCL\), as shown in [Figure 1](#fig1135561232714).
- I2C data transfer must begin with a **START** condition and end with a **STOP** condition. Data is transmitted byte-by-byte from the most significant bit to the least significant bit. 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).
- Each I2C node is recognized by a unique address and can serve as either a controller or a device. When the controller needs to communicate with a device, it writes the device address to the bus through broadcast. A device matching this address sends a response to set up a data transfer channel.
- The I2C APIs define a set of common functions for I2C data transfer, including: I2C 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 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.
- I2C message transfer: custom transfer by using a message array
**Figure 1** Physical connection diagram for I2C<a name="fig1135561232714"></a> The I2C APIs define a set of common functions for I2C data transfer, including:
![](figures/physical-connection-diagram-for-i2c.png "physical-connection-diagram-for-i2c")
- 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> ## Available APIs<a name="section545869122317"></a>
...@@ -52,21 +53,22 @@ ...@@ -52,21 +53,22 @@
</tbody> </tbody>
</table> </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. >All functions provided in this document can be called only in kernel mode.
## Usage Guidelines<a name="section1695201514281"></a> ## Usage Guidelines<a name="section1695201514281"></a>
### How to Use<a name="section1338373417288"></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> **Figure 2** Using I2C driver APIs
![](figures/process-of-using-an-i2c-device.png "process-of-using-an-i2c-device")
![](figures/using-i2c-process.png "process-of-using-an-i2c-device")
### Opening an I2C Controller<a name="section13751110132914"></a> ### 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\); DevHandle I2cOpen\(int16\_t number\);
...@@ -117,7 +119,7 @@ if (i2cHandle == NULL) { ...@@ -117,7 +119,7 @@ if (i2cHandle == NULL) {
### Performing I2C Communication<a name="section9202183372916"></a> ### 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\); int32\_t I2cTransfer\(DevHandle handle, struct I2cMsg \*msgs, int16\_t count\);
...@@ -186,15 +188,14 @@ if (ret != 2) { ...@@ -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 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 number of message structures and the data length of each message structure, which are determined by the I2C controller.
>- The **I2cTransfer** function does not limit the data length of each message structure, which is determined by the I2C controller.
>- The **I2cTransfer** function may cause the system to sleep and therefore cannot be called in the interrupt context. >- 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> ### 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\); void I2cClose\(DevHandle \*handle\);
...@@ -209,12 +210,13 @@ void I2cClose\(DevHandle \*handle\); ...@@ -209,12 +210,13 @@ void I2cClose\(DevHandle \*handle\);
</thead> </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> <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>
<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> </td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
``` ```
I2cClose(i2cHandle); /* Close the I2C controller. */ I2cClose(i2cHandle); /* Close the I2C controller. */
``` ```
...@@ -233,7 +235,7 @@ This example shows a simple register read/write operation on TouchPad on a Hi351 ...@@ -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. 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. >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: Example:
......
...@@ -59,12 +59,11 @@ The figure below shows a simplified CSI. The D-PHY transmits data by using one p ...@@ -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> ### 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/using-MIPI-CSI-process.png)
![](figures/process-of-using-MIPI-CSI.png)
### Opening the MIPI CSI Controller Operation Handle<a name="section2.2_MIPI_CSIDes"></a> ### 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. 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](#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> **Figure 1** DSI transmitting and receiving interface<a name="fig1122611461203"></a>
![](figures/dsi-transmitting-and-receiving-interface.png "dsi-transmitting-and-receiving-interface") ![](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 **Table 1** APIs for MIPI DSI
...@@ -75,17 +75,17 @@ ...@@ -75,17 +75,17 @@
</tbody> </tbody>
</table> </table>
>![](../public_sys-resources/icon-note.gif) **NOTE:** >![](../public_sys-resources/icon-note.gif) **NOTE**<br> All functions described in this document can be called only in kernel space.
>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> **Figure 2** Using MIPI DSI driver APIs
![](figures/process-of-using-a-mipi-dsi-device.png)
![](figures/using-mipi-dsi-process.png)
### Obtaining a MIPI DSI Device Handle<a name="section5126155683811"></a> ### Obtaining a MIPI DSI Device Handle<a name="section5126155683811"></a>
...@@ -537,4 +537,3 @@ void PalMipiDsiTestSample(void) ...@@ -537,4 +537,3 @@ void PalMipiDsiTestSample(void)
MipiDsiClose(handle); MipiDsiClose(handle);
} }
``` ```
\ No newline at end of file
...@@ -5,12 +5,12 @@ ...@@ -5,12 +5,12 @@
### Pin<a name="section2"></a> ### 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, 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 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. - 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 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 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 functions of a pin to implement pin multiplexing
### Basic Concepts<a name="section3"></a> ### 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. 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 ...@@ -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> ### 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> **Figure 2** Using the pin driver APIs
![](figures/process-of-using-pin.png "Process of using the pin module")
![](figures/using-pin-process.png "Process of using the pin module")
#### Obtaining the Pin Description Handle #### Obtaining the Pin Description Handle
...@@ -122,7 +123,7 @@ int32_t PinSetPull(DevHandle handle, enum PinPullType pullType); ...@@ -122,7 +123,7 @@ int32_t PinSetPull(DevHandle handle, enum PinPullType pullType);
| pullType | Pull type to set. | | pullType | Pull type to set. |
| **Return Value**| **Description** | | **Return Value**| **Description** |
| 0 | The operation is successful.| | 0 | The operation is successful.|
| Negative value | The operation fails.| | Negative value | The operation failed.|
Example: Set the pull type to pull-up. Example: Set the pull type to pull-up.
...@@ -156,7 +157,7 @@ int32_t PinGetPull(DevHandle handle, enum PinPullType *pullType); ...@@ -156,7 +157,7 @@ int32_t PinGetPull(DevHandle handle, enum PinPullType *pullType);
| pullType | Pointer to the pull type obtained.| | pullType | Pointer to the pull type obtained.|
| **Return Value**| **Description** | | **Return Value**| **Description** |
| 0 | The operation is successful. | | 0 | The operation is successful. |
| Negative value | The operation fails. | | Negative value | The operation failed. |
Example: Obtain the pull type of a pin. Example: Obtain the pull type of a pin.
...@@ -189,7 +190,7 @@ int32_t PinSetStrength(DevHandle handle, uint32_t strength); ...@@ -189,7 +190,7 @@ int32_t PinSetStrength(DevHandle handle, uint32_t strength);
| strength | Pull strength to set. | | strength | Pull strength to set. |
| **Return Value**| **Description** | | **Return Value**| **Description** |
| 0 | The operation is successful.| | 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. Example: Set the pull strength of the pin to 2.
...@@ -223,7 +224,7 @@ int32_t PinGetStrength(DevHandle handle, uint32_t *strength); ...@@ -223,7 +224,7 @@ int32_t PinGetStrength(DevHandle handle, uint32_t *strength);
| strength | Pointer to the pull strength obtained.| | strength | Pointer to the pull strength obtained.|
| **Return Value**| **Description** | | **Return Value**| **Description** |
| 0 | The operation is successful. | | 0 | The operation is successful. |
| Negative value | The operation fails. | | Negative value | The operation failed. |
Example: Obtain the pull strength of a pin. Example: Obtain the pull strength of a pin.
...@@ -258,7 +259,7 @@ int32_t PinSetFunc(DevHandle handle, const char *funcName); ...@@ -258,7 +259,7 @@ int32_t PinSetFunc(DevHandle handle, const char *funcName);
| funcName | Pointer to the pin function to set. | | funcName | Pointer to the pin function to set. |
| **Return Value**| **Description** | | **Return Value**| **Description** |
| 0 | The operation is successful.| | 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). Example: Set the pin function to LSADC_CH1 (ADC channel 1).
...@@ -291,7 +292,7 @@ int32_t PinGetFunc(DevHandle handle, const char **funcName); ...@@ -291,7 +292,7 @@ int32_t PinGetFunc(DevHandle handle, const char **funcName);
| funcName | Pointer to the function name obtained.| | funcName | Pointer to the function name obtained.|
| **Return Value**| **Description** | | **Return Value**| **Description** |
| 0 | The operation is successful. | | 0 | The operation is successful. |
| Negative value | The operation fails. | | Negative value | The operation failed. |
Example: Obtain the pin function. Example: Obtain the pin function.
......
...@@ -48,11 +48,11 @@ Pulse width modulation (PWM) is a technology that digitally encodes analog signa ...@@ -48,11 +48,11 @@ Pulse width modulation (PWM) is a technology that digitally encodes analog signa
### How to Use ### 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 ### Opening a PWM Device Handle
...@@ -71,7 +71,7 @@ DevHandle PwmOpen(uint32_t num); ...@@ -71,7 +71,7 @@ DevHandle PwmOpen(uint32_t num);
| num | PWM device number. | | num | PWM device number. |
| **Return Value** | **Description** | | **Return Value** | **Description** |
| handle | Handle of the PWM device obtained.| | handle | Handle of the PWM device obtained.|
| NULL | The operation fails. | | NULL | The operation failed. |
Example: Open the device handle of PWM device 0. Example: Open the device handle of PWM device 0.
...@@ -126,7 +126,7 @@ int32_t PwmEnable(DevHandle handle); ...@@ -126,7 +126,7 @@ int32_t PwmEnable(DevHandle handle);
| handle | PWM device handle. | | handle | PWM device handle. |
| **Return Value** | **Description** | | **Return Value** | **Description** |
| 0 | The operation is successful. | | 0 | The operation is successful. |
| Negative number | The operation fails. | | Negative number | The operation failed. |
``` ```
...@@ -156,7 +156,7 @@ int32_t PwmDisable(DevHandle handle); ...@@ -156,7 +156,7 @@ int32_t PwmDisable(DevHandle handle);
| handle | PWM device handle. | | handle | PWM device handle. |
| **Return Value** | **Description** | | **Return Value** | **Description** |
| 0 | The operation is successful. | | 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); ...@@ -187,7 +187,7 @@ int32_t PwmSetPeriod(DevHandle handle, uint32_t period);
| period | PWM period to set, in ns.| | period | PWM period to set, in ns.|
| **Return Value**| **Description** | | **Return Value**| **Description** |
| 0 | The operation is successful. | | 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); ...@@ -218,7 +218,7 @@ int32_t PwmSetDuty(DevHandle handle, uint32_t duty);
| duty | Time that the signal is in the ON state, in ns.| | duty | Time that the signal is in the ON state, in ns.|
| **Return Value**| **Description** | | **Return Value**| **Description** |
| 0 | The operation is successful. | | 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); ...@@ -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**.| | polarity | Polarity to set, which can be **PWM\_NORMAL\_POLARITY** or **PWM\_INVERTED\_POLARITY**.|
| **Return Value**| **Description** | | **Return Value**| **Description** |
| 0 | The operation is successful. | | 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); ...@@ -280,7 +280,7 @@ int32_t PwmSetConfig(DevHandle handle, struct PwmConfig *config);
| \*config | Pointer to PWM parameters. | | \*config | Pointer to PWM parameters. |
| **Return Value**| **Description** | | **Return Value**| **Description** |
| 0 | The operation is successful. | | 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); ...@@ -317,7 +317,7 @@ int32_t PwmGetConfig(DevHandle handle, struct PwmConfig *config);
| \*config | Pointer to PWM parameters. | | \*config | Pointer to PWM parameters. |
| **Return Value**| **Description** | | **Return Value**| **Description** |
| 0 | The operation is successful. | | 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: ...@@ -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 core layer provides the capabilities of binding, initializing, and releasing devices.
- The adaptation layer implements other functions. - 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 **Figure 1** Unified service mode
...@@ -84,11 +85,11 @@ Regulators are used to: ...@@ -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. 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 #### Opening a Regulator Device Handle
...@@ -105,7 +106,7 @@ DevHandle RegulatorOpen(const char *name); ...@@ -105,7 +106,7 @@ DevHandle RegulatorOpen(const char *name);
| name | Name of the target regulator. | | name | Name of the target regulator. |
| **Return Value**| **Description** | | **Return Value**| **Description** |
| handle | The regulator device handle is returned if the operation is successful.| | 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); ...@@ -155,7 +156,7 @@ int32_t RegulatorEnable(DevHandle handle);
| handle | Device handle of the target regulator.| | handle | Device handle of the target regulator.|
| **Return Value**| **Description** | | **Return Value**| **Description** |
| 0 | The operation is successful. | | 0 | The operation is successful. |
| Negative value | The operation fails. | | Negative value | The operation failed. |
...@@ -184,7 +185,7 @@ int32_t RegulatorDisable(DevHandle handle); ...@@ -184,7 +185,7 @@ int32_t RegulatorDisable(DevHandle handle);
| handle | Device handle of the target regulator.| | handle | Device handle of the target regulator.|
| **Return Value**| **Description** | | **Return Value**| **Description** |
| 0 | The operation is successful. | | 0 | The operation is successful. |
| Negative value | The operation fails. | | Negative value | The operation failed. |
``` ```
int32_t ret; int32_t ret;
...@@ -212,7 +213,7 @@ int32_t RegulatorForceDisable(DevHandle handle); ...@@ -212,7 +213,7 @@ int32_t RegulatorForceDisable(DevHandle handle);
| handle | Device handle of the target regulator.| | handle | Device handle of the target regulator.|
| **Return Value**| **Description** | | **Return Value**| **Description** |
| 0 | The operation is successful. | | 0 | The operation is successful. |
| Negative value | The operation fails. | | Negative value | The operation failed. |
``` ```
int32_t ret; int32_t ret;
...@@ -241,7 +242,7 @@ int32_t RegulatorSetVoltage(DevHandle handle, uint32_t minUv, uint32_t maxUv); ...@@ -241,7 +242,7 @@ int32_t RegulatorSetVoltage(DevHandle handle, uint32_t minUv, uint32_t maxUv);
| maxUv | Maximum voltage to set. | | maxUv | Maximum voltage to set. |
| **Return Value**| **Description** | | **Return Value**| **Description** |
| 0 | The operation is successful. | | 0 | The operation is successful. |
| Negative value | The operation fails. | | Negative value | The operation failed. |
``` ```
int32_t ret; int32_t ret;
...@@ -272,7 +273,7 @@ int32_t RegulatorGetVoltage(DevHandle handle, uint32_t *voltage); ...@@ -272,7 +273,7 @@ int32_t RegulatorGetVoltage(DevHandle handle, uint32_t *voltage);
| *voltage | Pointer to the regulator voltage information. | | *voltage | Pointer to the regulator voltage information. |
| **Return Value**| **Description** | | **Return Value**| **Description** |
| 0 | The operation is successful. | | 0 | The operation is successful. |
| Negative value | The operation fails. | | Negative value | The operation failed. |
``` ```
int32_t ret; int32_t ret;
...@@ -302,7 +303,7 @@ int32_t RegulatorSetCurrent(DevHandle handle, uint32_t minUa, uint32_t maxUa); ...@@ -302,7 +303,7 @@ int32_t RegulatorSetCurrent(DevHandle handle, uint32_t minUa, uint32_t maxUa);
| maxUa | Maximum current to set. | | maxUa | Maximum current to set. |
| **Return Value**| **Description** | | **Return Value**| **Description** |
| 0 | The operation is successful. | | 0 | The operation is successful. |
| Negative value | The operation fails. | | Negative value | The operation failed. |
``` ```
int32_t ret; int32_t ret;
...@@ -332,7 +333,7 @@ int32_t RegulatorGetCurrent(DevHandle handle, uint32_t *regCurrent); ...@@ -332,7 +333,7 @@ int32_t RegulatorGetCurrent(DevHandle handle, uint32_t *regCurrent);
| *regCurrent | Pointer to the regulator current information. | | *regCurrent | Pointer to the regulator current information. |
| **Return Value** | **Description** | | **Return Value** | **Description** |
| 0 | The operation is successful. | | 0 | The operation is successful. |
| Negative value | The operation fails. | | Negative value | The operation failed. |
``` ```
int32_t ret; int32_t ret;
...@@ -361,7 +362,7 @@ int32_t RegulatorGetStatus(DevHandle handle, uint32_t *status); ...@@ -361,7 +362,7 @@ int32_t RegulatorGetStatus(DevHandle handle, uint32_t *status);
| *status | Pointer to the regulator status information. | | *status | Pointer to the regulator status information. |
| **Return Value**| **Description** | | **Return Value**| **Description** |
| 0 | The operation is successful. | | 0 | The operation is successful. |
| Negative value | The operation fails. | | Negative value | The operation failed. |
``` ```
int32_t ret; int32_t ret;
......
...@@ -95,7 +95,7 @@ The real-time clock \(RTC\) driver provides precise real time for the operating ...@@ -95,7 +95,7 @@ The real-time clock \(RTC\) driver provides precise real time for the operating
</tbody> </tbody>
</table> </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. >All functions provided in this document can be called only in kernel mode.
## Usage Guidelines<a name="section20636145604113"></a> ## Usage Guidelines<a name="section20636145604113"></a>
...@@ -104,16 +104,16 @@ The real-time clock \(RTC\) driver provides precise real time for the operating ...@@ -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. 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> **Figure 1** Process of using an RTC device
![](figures/process-of-using-an-rtc-device.png "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. 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. >Currently, only one RTC device is supported in the OS.
DevHandle RtcOpen\(void\); DevHandle RtcOpen\(void\);
...@@ -138,17 +138,18 @@ DevHandle RtcOpen\(void\); ...@@ -138,17 +138,18 @@ DevHandle RtcOpen\(void\);
</tr> </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> <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>
<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> </td>
</tr> </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> <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>
<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> </td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
``` ```
DevHandle handle = NULL; DevHandle handle = NULL;
...@@ -161,7 +162,7 @@ if (handle == NULL) { ...@@ -161,7 +162,7 @@ if (handle == NULL) {
### Releasing the RTC Device Handle<a name="section10744117144314"></a> ### 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\); void RtcClose\(DevHandle handle\);
...@@ -186,7 +187,7 @@ void RtcClose\(DevHandle handle\); ...@@ -186,7 +187,7 @@ void RtcClose\(DevHandle handle\);
RtcClose(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: 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 ...@@ -228,7 +229,7 @@ int32\_t RtcRegisterAlarmCallback\(DevHandle handle, enum RtcAlarmIndex alarmInd
</tr> </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> <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>
<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> </td>
</tr> </tr>
</tbody> </tbody>
...@@ -257,11 +258,11 @@ if (ret != 0) { ...@@ -257,11 +258,11 @@ if (ret != 0) {
} }
``` ```
### Performing RTC-related Operations<a name="section161927578433"></a> ### Performing RTC-related Operations
- Reading RTC time - 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\); int32\_t RtcReadTime\(DevHandle handle, struct RtcTime \*time\);
...@@ -295,7 +296,7 @@ int32\_t RtcReadTime\(DevHandle handle, struct RtcTime \*time\); ...@@ -295,7 +296,7 @@ int32\_t RtcReadTime\(DevHandle handle, struct RtcTime \*time\);
</tr> </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> <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>
<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> </td>
</tr> </tr>
</tbody> </tbody>
...@@ -314,7 +315,7 @@ if (ret != 0) { ...@@ -314,7 +315,7 @@ if (ret != 0) {
- Setting RTC time - 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\); int32\_t RtcWriteTime\(DevHandle handle, struct RtcTime \*time\);
...@@ -348,13 +349,13 @@ int32\_t RtcWriteTime\(DevHandle handle, struct RtcTime \*time\); ...@@ -348,13 +349,13 @@ int32\_t RtcWriteTime\(DevHandle handle, struct RtcTime \*time\);
</tr> </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> <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>
<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> </td>
</tr> </tr>
</tbody> </tbody>
</table> </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. >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) { ...@@ -378,7 +379,7 @@ if (ret != 0) {
- Reading the RTC alarm time - 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\); 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 ...@@ -417,7 +418,7 @@ int32\_t RtcReadAlarm\(DevHandle handle, enum RtcAlarmIndex alarmIndex, struct R
</tr> </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> <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>
<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> </td>
</tr> </tr>
</tbody> </tbody>
...@@ -436,7 +437,7 @@ if (ret != 0) { ...@@ -436,7 +437,7 @@ if (ret != 0) {
- Setting RTC alarm time - 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\); int32\_t RtcWriteAlarm\(DevHandle handle, enum RtcAlarmIndex alarmIndex, struct RtcTime \*time\);
...@@ -475,13 +476,13 @@ int32\_t RtcWriteAlarm\(DevHandle handle, enum RtcAlarmIndex alarmIndex, struct ...@@ -475,13 +476,13 @@ int32\_t RtcWriteAlarm\(DevHandle handle, enum RtcAlarmIndex alarmIndex, struct
</tr> </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> <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>
<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> </td>
</tr> </tr>
</tbody> </tbody>
</table> </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. >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) { ...@@ -505,7 +506,7 @@ if (ret != 0) {
- Enabling or disabling alarm interrupts - 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\); int32\_t RtcAlarmInterruptEnable\(DevHandle handle, enum RtcAlarmIndex alarmIndex, uint8\_t enable\);
...@@ -544,7 +545,7 @@ int32\_t RtcAlarmInterruptEnable\(DevHandle handle, enum RtcAlarmIndex alarmInde ...@@ -544,7 +545,7 @@ int32\_t RtcAlarmInterruptEnable\(DevHandle handle, enum RtcAlarmIndex alarmInde
</tr> </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> <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>
<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> </td>
</tr> </tr>
</tbody> </tbody>
...@@ -562,7 +563,7 @@ if (ret != 0) { ...@@ -562,7 +563,7 @@ if (ret != 0) {
- Reading RTC external frequency - 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\); int32\_t RtcGetFreq\(DevHandle handle, uint32\_t \*freq\);
...@@ -596,7 +597,7 @@ int32\_t RtcGetFreq\(DevHandle handle, uint32\_t \*freq\); ...@@ -596,7 +597,7 @@ int32\_t RtcGetFreq\(DevHandle handle, uint32\_t \*freq\);
</tr> </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> <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>
<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> </td>
</tr> </tr>
</tbody> </tbody>
...@@ -615,7 +616,7 @@ if (ret != 0) { ...@@ -615,7 +616,7 @@ if (ret != 0) {
- Setting the frequency of the external crystal oscillator connected to the RTC driver - 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\); int32\_t RtcSetFreq\(DevHandle handle, uint32\_t freq\);
...@@ -649,7 +650,7 @@ int32\_t RtcSetFreq\(DevHandle handle, uint32\_t freq\); ...@@ -649,7 +650,7 @@ int32\_t RtcSetFreq\(DevHandle handle, uint32\_t freq\);
</tr> </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> <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>
<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> </td>
</tr> </tr>
</tbody> </tbody>
...@@ -668,7 +669,7 @@ if (ret != 0) { ...@@ -668,7 +669,7 @@ if (ret != 0) {
- Resetting the RTC driver - 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\); int32\_t RtcReset\(DevHandle handle\);
...@@ -697,7 +698,7 @@ int32\_t RtcReset\(DevHandle handle\); ...@@ -697,7 +698,7 @@ int32\_t RtcReset\(DevHandle handle\);
</tr> </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> <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>
<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> </td>
</tr> </tr>
</tbody> </tbody>
...@@ -715,7 +716,7 @@ if (ret != 0) { ...@@ -715,7 +716,7 @@ if (ret != 0) {
- Reading the configuration of a custom RTC register - 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\); 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\); ...@@ -754,7 +755,7 @@ int32\_t RtcReadReg\(DevHandle handle, uint8\_t usrDefIndex, uint8\_t \*value\);
</tr> </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> <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>
<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> </td>
</tr> </tr>
</tbody> </tbody>
...@@ -774,7 +775,7 @@ if (ret != 0) { ...@@ -774,7 +775,7 @@ if (ret != 0) {
- Setting the configuration of a custom RTC register - 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\); 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\); ...@@ -813,7 +814,7 @@ int32\_t RtcWriteReg\(DevHandle handle, uint8\_t usrDefIndex, uint8\_t value\);
</tr> </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> <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>
<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> </td>
</tr> </tr>
</tbody> </tbody>
...@@ -927,4 +928,3 @@ void RtcTestSample(void) ...@@ -927,4 +928,3 @@ void RtcTestSample(void)
RtcClose(handle); RtcClose(handle);
} }
``` ```
\ No newline at end of file
# SDIO<a name="EN-US_TOPIC_0000001160653028"></a> # SDIO
## Overview<a name="section1155271783811"></a> ## 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. Secure Digital Input/Output \(SDIO\) is a peripheral interface evolved from the Secure Digital \(SD\) memory card interface. The SDIO interface is compatible with SD memory cards and can be connected to devices that support the SDIO interface.
- SDIO is widely used. Currently, many smartphones support SDIO, and many SDIO peripherals are developed for connections to smartphones. Common SDIO peripherals include WLAN, GPS, cameras, and Bluetooth.
- The SDIO bus has two ends, named host and device. All communication starts when the host sends a command. The device can communicate with the host as long as it can parse the command of the host. An SDIO host can connect to multiple devices, as shown in the figure below.
- CLK signal: clock signal sent from the host to the device 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.
- 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<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> ## Available APIs<a name="section12601496259"></a>
...@@ -141,19 +141,21 @@ ...@@ -141,19 +141,21 @@
</tbody> </tbody>
</table> </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. >All functions provided in this document can be called only in kernel mode.
## Usage Guidelines<a name="section1878939192515"></a> ## Usage Guidelines<a name="section1878939192515"></a>
### How to Use<a name="section1490685512255"></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> ### Opening an SDIO Controller<a name="section10782428132616"></a>
...@@ -1048,4 +1050,3 @@ ENABLE_ERR: ...@@ -1048,4 +1050,3 @@ ENABLE_ERR:
SdioClose(handle); SdioClose(handle);
} }
``` ```
\ No newline at end of file
...@@ -2,21 +2,21 @@ ...@@ -2,21 +2,21 @@
## Overview<a name="section193356154511"></a> ## Overview<a name="section193356154511"></a>
- Serial Peripheral Interface \(SPI\) is a serial bus specification used for high-speed, full-duplex, and synchronous communication. 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 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: 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 - SCLK: clock signals output from the SPI controller
- MOSI: data output from the SPI controller and input into an SPI device - 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 - 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 - 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> **Figure 1** SPI controller/device connection<a name="fig89085710359"></a>
![](figures/spi-controller-device-connection.png "spi-controller-device-connection") ![](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. 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. 2. Clock signals are provided for the selected SPI device via the SCLK.
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
- Obtaining and setting SPI device configuration parameters. - 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. >Currently, these functions are only applicable in the communication initiated by the SPI controller.
## Available APIs<a name="section1325964832615"></a> ## Available APIs<a name="section1325964832615"></a>
...@@ -104,10 +104,10 @@ ...@@ -104,10 +104,10 @@
### How to Use<a name="section32846814820"></a> ### 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> **Figure 2** Using SPI driver APIs<a name="fig1586912310348"></a>
![](figures/process-of-using-an-spi-device.png "process-of-using-an-spi-device") ![](figures/using-spi-process.png "process-of-using-an-spi-device")
### Obtaining an SPI Device Handle<a name="section1927265711481"></a> ### Obtaining an SPI Device Handle<a name="section1927265711481"></a>
...@@ -546,4 +546,3 @@ err: ...@@ -546,4 +546,3 @@ err:
SpiClose(spiHandle); SpiClose(spiHandle);
} }
``` ```
\ No newline at end of file
...@@ -2,13 +2,13 @@ ...@@ -2,13 +2,13 @@
## Overview<a name="section833012453535"></a> ## 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. 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. 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)\). 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. - 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. - 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. - 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. - 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> **Figure 1** 2-wire UART communication<a name="fig68294715408"></a>
![](figures/2-wire-uart-communication.png "2-wire-uart-communication") ![](figures/2-wire-uart-communication.png "2-wire-uart-communication")
...@@ -17,11 +17,13 @@ ...@@ -17,11 +17,13 @@
![](figures/4-wire-uart-communication.png "4-wire-uart-communication") ![](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 transmitting and receiving UARTs must ensure that they have the same settings on particular attributes such as the baud rate and data format \(start bit, data bit, parity bit, and stop bit\) before they start to communicate. During data transmission, a UART sends data to the peer end over the TX pin and receives data from the peer end over the RX pin. When the size of the buffer used by a UART for storing received data reaches the preset threshold, the RTS signal of the UART changes to **1** \(data cannot be received\), and the peer UART stops sending data to it because its CTS signal does not allow it to send data.
- The UART interface defines a set of common functions for operating a UART port, including obtaining and releasing device handles, reading and writing data of a specified length, and obtaining and setting the baud rate, as well as the device attributes.
## Available APIs<a name="section1928742202715"></a> ## 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 **Table 1** APIs for the UART driver
<a name="table1731550155318"></a> <a name="table1731550155318"></a>
...@@ -94,17 +96,17 @@ ...@@ -94,17 +96,17 @@
</tbody> </tbody>
</table> </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. >All functions provided in this document can be called only in kernel space.
## Usage Guidelines<a name="section12779050105412"></a> ## Usage Guidelines<a name="section12779050105412"></a>
### How to Use<a name="section1858116395510"></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> **Figure 3** Using UART driver APIs<a name="fig99673244388"></a>
![](figures/process-of-using-a-uart-device.png "process-of-using-a-uart-device") ![](figures/using-uart-process.png "process-of-using-a-uart-device")
### Obtaining a UART Device Handle<a name="section124512065617"></a> ### Obtaining a UART Device Handle<a name="section124512065617"></a>
...@@ -656,4 +658,3 @@ _ERR: ...@@ -656,4 +658,3 @@ _ERR:
UartClose(handle); 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 ...@@ -70,17 +70,17 @@ A watchdog, also called a watchdog timer, is a hardware timing device. If an err
</tbody> </tbody>
</table> </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. >All watchdog functions provided in this document can be called only in kernel mode.
## Usage Guidelines<a name="section10103184312813"></a> ## Usage Guidelines<a name="section10103184312813"></a>
### How to Use<a name="section10181195910815"></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> **Figure 1** Using watchdog driver APIs
![](figures/process-of-using-a-watchdog.png "process-of-using-a-watchdog") ![](figures/using-watchdog-process.png "process-of-using-a-watchdog")
### Opening a Watchdog<a name="section66089201107"></a> ### Opening a Watchdog<a name="section66089201107"></a>
...@@ -536,4 +536,3 @@ static int32_t TestCaseWatchdog(void) ...@@ -536,4 +536,3 @@ static int32_t TestCaseWatchdog(void)
return -1; return -1;
} }
``` ```
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册