未验证 提交 6fc90d83 编写于 作者: O openharmony_ci 提交者: Gitee

!7913 [翻译完成】#I5G93I

Merge pull request !7913 from Annie_wang/PR6464
...@@ -28,21 +28,21 @@ struct GpioMethod { ...@@ -28,21 +28,21 @@ struct GpioMethod {
int32_t (*unsetIrq)(struct GpioCntlr *cntlr, uint16_t local); int32_t (*unsetIrq)(struct GpioCntlr *cntlr, uint16_t local);
int32_t (*enableIrq)(struct GpioCntlr *cntlr, uint16_t local); int32_t (*enableIrq)(struct GpioCntlr *cntlr, uint16_t local);
int32_t (*disableIrq)(struct GpioCntlr *cntlr, uint16_t local); int32_t (*disableIrq)(struct GpioCntlr *cntlr, uint16_t local);
}; }
``` ```
**Table 1** Description of the callback functions in GpioMethod **Table 1** Description of the callback functions in GpioMethod
| Function| Input Parameter| Output Parameter| Return Value| Description| | Function| Input Parameter| Output Parameter| Return Value| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| write | **cntlr**: structure pointer to the GPIO controller at the core layer.<br>**local**: GPIO port number, which is of the uint16_t type.<br>**val**: input level, which is of the uint16_t type. | – | HDF_STATUS| Writes the level of a GPIO pin.| | write | **cntlr**: structure pointer to the GPIO controller at the core layer.<br>**local**: GPIO port number, which is of the uint16_t type.<br>**val**: input level, which is of the uint16_t type.| –| HDF_STATUS| Writes the level of a GPIO pin.|
| read | **cntlr**: structure pointer to the GPIO controller at the core layer.<br>**local**: GPIO port number, which is of the uint16_t type. | **val**: pointer to the output level, which is of the uint16_t type.| HDF_STATUS| Reads the level of a GPIO pin.| | read | **cntlr**: structure pointer to the GPIO controller at the core layer.<br>**local**: GPIO port number, which is of the uint16_t type.| **val**: pointer to the output level, which is of the uint16_t type.| HDF_STATUS| Reads the level of a GPIO pin.|
| setDir | **cntlr**: structure pointer to the GPIO controller at the core layer.<br>**local**: GPIO port number, which is of the uint16_t type.<br>**dir**: pin direction to set, which is of the uint16_t type. | – | HDF_STATUS| Sets the direction (input or output) for a GPIO pin.| | setDir | **cntlr**: structure pointer to the GPIO controller at the core layer.<br>**local**: GPIO port number, which is of the uint16_t type.<br>**dir**: pin direction to set, which is of the uint16_t type.| –| HDF_STATUS| Sets the direction (input or output) for a GPIO pin.|
| getDir | **cntlr**: structure pointer to the GPIO controller at the core layer.<br>**local**: GPIO port number, which is of the uint16_t type. | **dir**: pointer to the pin direction obtained, which is of the uint16_t type.| HDF_STATUS| Obtains the input or output direction of a GPIO pin.| | getDir | **cntlr**: structure pointer to the GPIO controller at the core layer.<br>**local**: GPIO port number, which is of the uint16_t type.| **dir**: pointer to the pin direction obtained, which is of the uint16_t type.| HDF_STATUS| Obtains the input or output direction of a GPIO pin.|
| setIrq | **cntlr**: structure pointer to the GPIO controller at the core layer.<br>**local**: GPIO port number, which is of the uint16_t type.<br>**mode**: trigger mode, which can be edge or level of the uint16_t type. <br>**func**: pointer to the interrupt request (IRQ) handler.<br>**arg**: void pointer to the input parameters of the IRQ handler. | – | HDF_STATUS| Sets an IRQ for a GPIO pin.| | setIrq | **cntlr**: structure pointer to the GPIO controller at the core layer.<br>**local**: GPIO port number, which is of the uint16_t type.<br>**mode**: trigger mode, which can be edge or level of the uint16_t type. <br>**func**: pointer to the interrupt request (IRQ) handler.<br>**arg**: void pointer to the input parameters of the IRQ handler.| –| HDF_STATUS| Sets an IRQ for a GPIO pin.|
| unsetIrq | **cntlr**: structure pointer to the GPIO controller at the core layer.<br>**local**: GPIO port number, which is of the uint16_t type. | – | HDF_STATUS| Cancels the IRQ settings for a GPIO pin.| | unsetIrq | **cntlr**: structure pointer to the GPIO controller at the core layer.<br>**local**: GPIO port number, which is of the uint16_t type.| –| HDF_STATUS| Cancels the IRQ settings for a GPIO pin.|
| enableIrq | **cntlr**: structure pointer to the GPIO controller at the core layer.<br>**local**: GPIO port number, which is of the uint16_t type. | – | HDF_STATUS| Enables interrupts for a GPIO pin.| | enableIrq | **cntlr**: structure pointer to the GPIO controller at the core layer.<br>**local**: GPIO port number, which is of the uint16_t type.| –| HDF_STATUS| Enables interrupts for a GPIO pin.|
| disableIrq | **cntlr**: structure pointer to the GPIO controller at the core layer.<br>**local**: GPIO port number, which is of the uint16_t type. | – | HDF_STATUS| Disables interrupts for a GPIO pin.| | disableIrq | **cntlr**: structure pointer to the GPIO controller at the core layer.<br>**local**: GPIO port number, which is of the uint16_t type.| –| HDF_STATUS| Disables interrupts for a GPIO pin.|
## How to Develop ## How to Develop
...@@ -62,8 +62,8 @@ The GPIO module adaptation involves the following steps: ...@@ -62,8 +62,8 @@ The GPIO module adaptation involves the following steps:
3. Instantiate the GPIO controller object. 3. Instantiate the GPIO controller object.
- Initialize **GpioCntlr**. - Initialize **GpioCntlr**.
- Instantiate **GpioMethod** in the **GpioCntlr** object. - Instantiate **GpioMethod** in the **GpioCntlr** object.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/> For details about the functions in **GpioMethod**, see [Available APIs](#available-apis). > For details about the functions in **GpioMethod**, see [Available APIs](#available-apis).
4. Debug the driver. 4. Debug the driver.
...@@ -112,7 +112,7 @@ The following uses **gpio_hi35xx.c** as an example to present the information re ...@@ -112,7 +112,7 @@ The following uses **gpio_hi35xx.c** as an example to present the information re
priority = 10; // Driver startup priority. priority = 10; // Driver startup priority.
permission = 0644; // Permission to create device nodes for the driver. permission = 0644; // Permission to create device nodes for the driver.
moduleName = "hisi_pl061_driver"; // (Mandatory) Driver name, which must be the same as moduleName in the driver entry. moduleName = "hisi_pl061_driver"; // (Mandatory) Driver name, which must be the same as moduleName in the driver entry.
deviceMatchAttr = "hisilicon_hi35xx_pl061";// (Mandatory) Private data of the controller. The value must be the same as the controller information in gpio_config.hcs. deviceMatchAttr = "hisilicon_hi35xx_pl061"; // (Mandatory) Private data of the controller. The value must be the same as the controller information in gpio_config.hcs.
// Add private information about all controllers in this file. // Add private information about all controllers in this file.
} }
} }
...@@ -130,7 +130,7 @@ The following uses **gpio_hi35xx.c** as an example to present the information re ...@@ -130,7 +130,7 @@ The following uses **gpio_hi35xx.c** as an example to present the information re
match_attr = "hisilicon_hi35xx_pl061"; // (Mandatory) The value must be the same as that of deviceMatchAttr in device_info.hcs. match_attr = "hisilicon_hi35xx_pl061"; // (Mandatory) The value must be the same as that of deviceMatchAttr in device_info.hcs.
groupNum = 12; // (Mandatory) GPIO group number. groupNum = 12; // (Mandatory) GPIO group number.
bitNum = 8; // (Mandatory) Number of GPIO pins in each group. bitNum = 8; // (Mandatory) Number of GPIO pins in each group.
regBase = 0x120d0000;// (Mandatory) Physical base address. regBase = 0x120d0000; // (Mandatory) Physical base address.
regStep = 0x1000; // (Mandatory) Register offset step. regStep = 0x1000; // (Mandatory) Register offset step.
irqStart = 48; // (Mandatory) Enable interrupts. irqStart = 48; // (Mandatory) Enable interrupts.
irqShare = 0; // (Mandatory) Whether to share an interrupt. irqShare = 0; // (Mandatory) Whether to share an interrupt.
...@@ -158,7 +158,7 @@ The following uses **gpio_hi35xx.c** as an example to present the information re ...@@ -158,7 +158,7 @@ The following uses **gpio_hi35xx.c** as an example to present the information re
uint8_t irqShare; // (Mandatory) Whether to share an interrupt. uint8_t irqShare; // (Mandatory) Whether to share an interrupt.
struct Pl061GpioGroup *groups; // (Optional) Set based on the actual requirements. struct Pl061GpioGroup *groups; // (Optional) Set based on the actual requirements.
}; };
struct Pl061GpioGroup {// Register address, IRQ number and function, and lock. struct Pl061GpioGroup { // Register address, IRQ number and function, and lock.
volatile unsigned char *regBase; volatile unsigned char *regBase;
unsigned int index; unsigned int index;
unsigned int irq; unsigned int irq;
...@@ -179,7 +179,6 @@ The following uses **gpio_hi35xx.c** as an example to present the information re ...@@ -179,7 +179,6 @@ The following uses **gpio_hi35xx.c** as an example to present the information re
void *priv; void *priv;
}; };
``` ```
- Instantiating the **GpioMethod** structure in **GpioCntlr** (other members are initialized by **Init**) - Instantiating the **GpioMethod** structure in **GpioCntlr** (other members are initialized by **Init**)
...@@ -208,9 +207,7 @@ The following uses **gpio_hi35xx.c** as an example to present the information re ...@@ -208,9 +207,7 @@ The following uses **gpio_hi35xx.c** as an example to present the information re
Return value: Return value:
HDF_STATUS HDF_STATUS<br/>The table below describes some status. For more information, see **HDF_STATUS** in the **/drivers/framework/include/utils/hdf_base.h** file.
The table below describes some status. For more information, see **HDF_STATUS** in the **/drivers/framework/include/utils/hdf_base.h** file.
**Table 2** HDF_STATUS **Table 2** HDF_STATUS
...@@ -259,7 +256,6 @@ The following uses **gpio_hi35xx.c** as an example to present the information re ...@@ -259,7 +256,6 @@ The following uses **gpio_hi35xx.c** as an example to present the information re
... ...
} }
``` ```
- **Release** function - **Release** function
Input parameter: Input parameter:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册