|
|
/*
|
|
|
* Copyright (c) Hisilicon Technologies Co., Ltd. 2008-2020. All rights reserved.
|
|
|
* Description: Application programming interfaces (APIs) of gpio
|
|
|
*/
|
|
|
#ifndef UAPI_GPIO_H
|
|
|
#define UAPI_GPIO_H
|
|
|
|
|
|
#include "td_type.h"
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
#if __cplusplus
|
|
|
extern "C" {
|
|
|
#endif
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
|
/* type of GPIO interrupt */
|
|
|
/* CNcomment:GPIO 中断类型 */
|
|
|
typedef enum {
|
|
|
UAPI_GPIO_INTTYPE_UP, /* spring by the up edge */ /* CNcomment:上升沿触发 */
|
|
|
UAPI_GPIO_INTTYPE_DOWN, /* spring by the down edge */ /* CNcomment:下降沿触发 */
|
|
|
UAPI_GPIO_INTTYPE_UPDOWN, /* spring by both the up and down edge */ /* CNcomment:双沿触发 */
|
|
|
UAPI_GPIO_INTTYPE_HIGH, /* spring by the high level */ /* CNcomment:高电平触发 */
|
|
|
UAPI_GPIO_INTTYPE_LOW, /* spring by the low level */ /* CNcomment:低电平触发 */
|
|
|
UAPI_GPIO_INTTYPE_MAX, /* Invalid value */ /* CNcomment:非法边界值 */
|
|
|
} uapi_gpio_interrupt_type;
|
|
|
|
|
|
/* GPIO output type */
|
|
|
/* CNcomment:GPIO 输出类型 */
|
|
|
typedef enum {
|
|
|
UAPI_GPIO_OUTPUTTYPE_CMOS,
|
|
|
UAPI_GPIO_OUTPUTTYPE_OD,
|
|
|
UAPI_GPIO_OUTPUTTYPE_MAX,
|
|
|
} uapi_gpio_output_type;
|
|
|
|
|
|
/*
|
|
|
* \brief Starts the general-purpose input/output (GPIO) device.
|
|
|
* CNcomment:\brief 打开GPIO(General Purpose Input/Output)设备。CNend
|
|
|
|
|
|
* \attention \n
|
|
|
* This API can be called repeatedly.
|
|
|
* CNcomment:重复打开会成功。CNend
|
|
|
|
|
|
* \param N/A CNcomment:无。CNend
|
|
|
* \retval 0 Success. CNcomment:成功。CNend
|
|
|
* \retval ::TD_FAILURE Initialize GPIO failed. CNcomment:打开GPIO失败。CNend
|
|
|
* \retval ::SOC_ERR_GPIO_OPEN_ERR Initialize GPIO failed. CNcomment:打开GPIO失败。CNend
|
|
|
* \see \n
|
|
|
* N/A
|
|
|
*/
|
|
|
td_s32 uapi_gpio_init(td_void);
|
|
|
|
|
|
/*
|
|
|
* \brief Stops the GPIO device.
|
|
|
* CNcomment:\brief 关闭GPIO设备。CNend
|
|
|
|
|
|
* \attention \n
|
|
|
* This API can be called repeatedly.
|
|
|
* CNcomment:重复关闭会成功。CNend
|
|
|
* \param N/A CNcomment:无。CNend
|
|
|
* \retval 0 Success. CNcomment:成功。CNend
|
|
|
* \retval ::SOC_ERR_GPIO_CLOSE_ERR Deinitialize GPIO failed. CNcomment:打开GPIO失败。CNend
|
|
|
* \see \n
|
|
|
* N/A
|
|
|
*/
|
|
|
td_s32 uapi_gpio_deinit(td_void);
|
|
|
|
|
|
/*
|
|
|
* \brief Reads data from a GPIO pin.
|
|
|
* CNcomment:\brief 从GPIO单个引脚读取数据。CNend
|
|
|
* \param[in] group_number Pin group_number, ranging is different in otherness chip type
|
|
|
* CNcomment:管脚组号,不同的芯片类型范围不一样。CNend
|
|
|
* \param[in] bit_number Pin bit_number, ranging is different in otherness chip type
|
|
|
* CNcomment:管脚所在组的bit号,取值范围为0~103,不同的芯片类型范围不一样。CNend
|
|
|
* \param[out] high_volt Pointer to the input level of a pin. CNcomment:指针类型,返回管脚输入或者输出电平。CNend
|
|
|
* \retval 0 Success. CNcomment:成功。CNend
|
|
|
* \retval ::SOC_ERR_GPIO_INVALID_PARA Parameters Invalid. CNcomment:非法参数。CNend
|
|
|
* \retval ::SOC_ERR_GPIO_NULL_PTR Pointer Parameters is NULL. CNcomment:指针参数为空指针。CNend
|
|
|
* \retval ::SOC_ERR_GPIO_NOT_INIT GPIO module is not initialiazed. CNcomment:GPIO模块没有初始化。CNend
|
|
|
* \retval ::SOC_ERR_GPIO_INVALID_OPT Invalid Operation. CNcomment:非法操作。CNend
|
|
|
* \see \n
|
|
|
* N/A
|
|
|
*/
|
|
|
td_s32 uapi_gpio_read(td_u32 group_number, td_u32 bit_number, td_bool *high_volt);
|
|
|
|
|
|
/*
|
|
|
* \brief Writes data to a GPIO pin.
|
|
|
* CNcomment:\brief 向GPIO单个引脚输出数据。CNend
|
|
|
* \attention \n
|
|
|
* N/A
|
|
|
* \param[in] group_number Pin group_number, ranging is different in otherness chip type
|
|
|
* CNcomment:管脚组号,不同的芯片类型范围不一样。CNend
|
|
|
* \param[in] bit_number Pin bit_number, ranging is different in otherness chip type
|
|
|
* CNcomment:管脚所在组的bit号,取值范围为0~103,不同的芯片类型范围不一样。CNend
|
|
|
* \param[in] high_volt Output level of a pin CNcomment:管脚输出电平。CNend
|
|
|
* 0: low level CNcomment:0: 低电平 CNend
|
|
|
* 1: high level CNcomment:1:高电平 CNend
|
|
|
* Others: high level CNcomment:其他:高电平。CNend
|
|
|
* \retval 0 Success. CNcomment:成功。CNend
|
|
|
* \retval ::SOC_ERR_GPIO_INVALID_PARA Parameters Invalid. CNcomment:非法参数。CNend
|
|
|
* \retval ::SOC_ERR_GPIO_NOT_INIT GPIO module is not initialiazed. CNcomment:GPIO模块没有初始化。CNend
|
|
|
* \retval ::SOC_ERR_GPIO_INVALID_OPT Invalid Operation. CNcomment:非法操作。CNend
|
|
|
* \see \n
|
|
|
* N/A
|
|
|
*/
|
|
|
td_s32 uapi_gpio_write(td_u32 group_number, td_u32 bit_number, td_bool high_volt);
|
|
|
|
|
|
/*
|
|
|
* \brief Sets the direction (input or output) of a GPIO pin.
|
|
|
* CNcomment:\brief 设置GPIO单个引脚输入输出方向。CNend
|
|
|
|
|
|
* \attention \n
|
|
|
* When setting the operating mode of a GPIO pin, ensure that it works in GPIO mode only.\n
|
|
|
* This is because the GPIO pin may be multiplexed.\n
|
|
|
* CNcomment:设置对应管脚的工作方式时,必须保证该管脚仅工作在GPIO模式下,GPIO管脚有可能被复用。CNend
|
|
|
|
|
|
* \param[in] group_number Pin group_number, ranging is different in otherness chip type
|
|
|
* CNcomment:管脚组号,不同的芯片类型范围不一样。CNend
|
|
|
* \param[in] bit_number Pin bit_number, ranging is different in otherness chip type
|
|
|
* CNcomment:管脚所在组的bit号,取值范围为0~103,不同的芯片类型范围不一样。CNend
|
|
|
* \param[in] input Boolean variable that indicates the direction of a pin CNcomment:布尔变量,标识管脚方向。CNend
|
|
|
* TD_TRUE: input pin TD_TRUE. CNcomment:该管脚用于输入。CNend
|
|
|
* TD_FALSE: output pin TD_FALSE. CNcomment:该管脚用于输出。CNend
|
|
|
* \retval 0 Success. CNcomment:成功。CNend
|
|
|
* \retval ::SOC_ERR_GPIO_INVALID_PARA Parameters Invalid. CNcomment:非法参数。CNend
|
|
|
* \retval ::SOC_ERR_GPIO_NOT_INIT GPIO module is not initialiazed. CNcomment:GPIO模块没有初始化。CNend
|
|
|
* \see \n
|
|
|
* N/A
|
|
|
*/
|
|
|
td_s32 uapi_gpio_set_direction(td_u32 group_number, td_u32 bit_number, td_bool input);
|
|
|
|
|
|
/*
|
|
|
* \brief Obtains the direction (input or output) of a GPIO pin.
|
|
|
* CNcomment:\brief 获取GPIO单个引脚输入输出方向。CNend
|
|
|
|
|
|
* \attention \n
|
|
|
* N/A
|
|
|
* \param[in] group_number Pin group_number, ranging is different in otherness chip type
|
|
|
* CNcomment:管脚组号,不同的芯片类型范围不一样。CNend
|
|
|
* \param[in] bit_number Pin bit_number, ranging is different in otherness chip type
|
|
|
* CNcomment:管脚所在组的bit号,取值范围为0~103,不同的芯片类型范围不一样。CNend
|
|
|
* \param[out] input Pointer to the boolean variable that indicates the direction of a pin.
|
|
|
* CNcomment:指针类型,指向布尔型变量,用来返回管脚方向。CNend
|
|
|
* \retval 0 Success. CNcomment:成功。CNend
|
|
|
* \retval ::SOC_ERR_GPIO_INVALID_PARA Parameters Invalid. CNcomment:非法参数。CNend
|
|
|
* \retval ::SOC_ERR_GPIO_NULL_PTR Pointer Parameters is NULL. CNcomment:指针参数为空指针。CNend
|
|
|
* \retval ::SOC_ERR_GPIO_NOT_INIT GPIO module is not initialiazed. CNcomment:GPIO模块没有初始化。CNend
|
|
|
* \see \n
|
|
|
* N/A
|
|
|
*/
|
|
|
td_s32 uapi_gpio_get_direction(td_u32 group_number, td_u32 bit_number, td_bool *input);
|
|
|
|
|
|
/*
|
|
|
* \brief Starts the cipher device.
|
|
|
* CNcomment:\brief 设置GPIO单个引脚的中断类型。CNend
|
|
|
* \attention \n
|
|
|
* N/A
|
|
|
* \param[in] group_number Pin group_number, ranging is different in otherness chip type
|
|
|
* CNcomment:管脚组号,不同的芯片类型范围不一样。CNend
|
|
|
* \param[in] bit_number Pin bit_number, ranging is different in otherness chip type
|
|
|
* CNcomment:管脚所在组的bit号,取值范围为0~103,不同的芯片类型范围不一样。CNend
|
|
|
* \param[in] interrupt_type interrupt type CNcomment:中断类型。CNend
|
|
|
* \retval 0 Success. CNcomment:成功。CNend
|
|
|
* \retval ::SOC_ERR_GPIO_INVALID_PARA Parameters Invalid. CNcomment:非法参数。CNend
|
|
|
* \retval ::SOC_ERR_GPIO_INTTYPE_NOT_SUPPORT interupt type is not support. CNcomment:不支持的中断类型。CNend
|
|
|
* \retval ::SOC_ERR_GPIO_NOT_INIT GPIO module is not initialiazed. CNcomment:GPIO模块没有初始化。CNend
|
|
|
* \retval ::SOC_ERR_GPIO_FAILED_SETINT set interupt type failed. CNcomment:设置中断类型失败。CNend
|
|
|
* \see \n
|
|
|
* N/A
|
|
|
*/
|
|
|
td_s32 uapi_gpio_set_interrupt_type(td_u32 group_number, td_u32 bit_number,
|
|
|
uapi_gpio_interrupt_type interrupt_type);
|
|
|
|
|
|
/*
|
|
|
* \brief set GPIO single pin interrupt enable
|
|
|
* CNcomment:\brief 设置GPIO单个引脚的中断使能。CNend
|
|
|
* \attention \n
|
|
|
* interrupte type UAPI_GPIO_INTTYPE_LOW and UAPI_GPIO_INTTYPE_HIGH is not support
|
|
|
* CNcomment:不支持UAPI_GPIO_INTTYPE_LOW 和 UAPI_GPIO_INTTYPE_HIGH中断类型。CNend
|
|
|
* \param[in] group_number Pin group_number, ranging is different in otherness chip type
|
|
|
* CNcomment:管脚组号,不同的芯片类型范围不一样。CNend
|
|
|
* \param[in] bit_number Pin bit_number, ranging is different in otherness chip type
|
|
|
* CNcomment:管脚所在组的bit号,取值范围为0~103,不同的芯片类型范围不一样。CNend
|
|
|
* \param[in] enable TD_TRUE: interrupt enable, TD_FALSE: interrupt disable
|
|
|
* CNcomment:TD_TRUE: 中断使能 ,TD_FALSE: 中断禁止。CNend
|
|
|
* \retval 0 Success. CNcomment:成功。CNend
|
|
|
* \retval ::SOC_ERR_GPIO_INVALID_PARA Parameters Invalid. CNcomment:非法参数。CNend
|
|
|
* \retval ::SOC_ERR_GPIO_NOT_INIT GPIO module is not initialiazed. CNcomment:GPIO模块没有初始化。CNend
|
|
|
* \retval ::SOC_ERR_GPIO_FAILED_SETENABLE enable interupt failed. CNcomment:使能中断失败。CNend
|
|
|
* \see \n
|
|
|
* N/A
|
|
|
*/
|
|
|
td_s32 uapi_gpio_set_interrupt_enable(td_u32 group_number, td_u32 bit_number, td_bool enable);
|
|
|
|
|
|
/*
|
|
|
* \brief query GPIO interrupt, report it if there is interrupter happen.\n
|
|
|
* CNcomment:\brief 查询GPIO中断,只要有GPIO中断就会上报上来。CNend
|
|
|
* \attention \n
|
|
|
* N/A
|
|
|
* \param[out] group_number Pin group_number, ranging is different in otherness chip type
|
|
|
* CNcomment:管脚组号,不同的芯片类型范围不一样。CNend
|
|
|
* \param[out] bit_number Pin bit_number, ranging is different in otherness chip type
|
|
|
* CNcomment:管脚所在组的bit号,取值范围为0~103,不同的芯片类型范围不一样。CNend
|
|
|
* \param[in] timeout_ms get interrupt timeout. CNcomment:获取中断超时时间。CNend
|
|
|
* \retval 0 Success. CNcomment:成功。CNend
|
|
|
* \retval ::SOC_ERR_GPIO_NULL_PTR Pointer Parameters is NULL. CNcomment:指针参数为空指针。CNend
|
|
|
* \retval ::SOC_ERR_GPIO_NOT_INIT GPIO module is not initialiazed. CNcomment:GPIO模块没有初始化。CNend
|
|
|
* \retval ::SOC_ERR_GPIO_FAILED_GETINT Query interupt failed. CNcomment:查询中断失败。CNend
|
|
|
* \see \n
|
|
|
* N/A
|
|
|
*/
|
|
|
td_s32 uapi_gpio_query_interrupt(td_u32 *group_number, td_u32 *bit_number, td_u32 timeout_ms);
|
|
|
|
|
|
/*
|
|
|
* \brief Obtains the output type (od or cmos) of a GPIO pin.
|
|
|
* CNcomment:\brief 设置GPIO单个引脚的输出类型。CNend
|
|
|
|
|
|
* \attention \n
|
|
|
* N/A
|
|
|
* \param[in] group_number Pin group_number, ranging is different in otherness chip type
|
|
|
* CNcomment:管脚组号,不同的芯片类型范围不一样。CNend
|
|
|
* \param[in] bit_number Pin bit_number, ranging is different in otherness chip type
|
|
|
* CNcomment:管脚所在组的bit号,取值范围为0~103,不同的芯片类型范围不一样。CNend
|
|
|
* \param[in] output_type Pointer to the enumerate variable that indicates the direction of a pin.
|
|
|
* CNcomment:指针类型,指向枚举型变量,用来返回管脚输出类型。CNend
|
|
|
* \retval 0 Success. CNcomment:成功。CNend
|
|
|
* \retval ::SOC_ERR_GPIO_INVALID_PARA Parameters Invalid. CNcomment:非法参数。CNend
|
|
|
* \retval ::SOC_ERR_GPIO_NOT_INIT GPIO module is not initialiazed. CNcomment:GPIO模块没有初始化。CNend
|
|
|
* \retval ::SOC_ERR_GPIO_FAILED_SETOUTPUTTYPE Get output type failed. CNcomment:设置输出类型失败。CNend
|
|
|
* \see \n
|
|
|
* N/A
|
|
|
*/
|
|
|
td_s32 uapi_gpio_set_output_type(td_u32 group_number, td_u32 bit_number, uapi_gpio_output_type output_type);
|
|
|
|
|
|
/*
|
|
|
* \brief Obtains the output type (od or cmos) of a GPIO pin.
|
|
|
* CNcomment:\brief 获取GPIO单个引脚的输出类型。CNend
|
|
|
|
|
|
* \attention \n
|
|
|
* N/A
|
|
|
* \param[in] group_number Pin group_number, ranging is different in otherness chip type
|
|
|
* CNcomment:管脚组号,不同的芯片类型范围不一样。CNend
|
|
|
* \param[in] bit_number Pin bit_number, ranging is different in otherness chip type
|
|
|
* CNcomment:管脚所在组的bit号,取值范围为0~103,不同的芯片类型范围不一样。CNend
|
|
|
* \param[out] penOutputType Pointer to the enumerate variable that indicates the output type of a pin.
|
|
|
* CNcomment:指针类型,指向枚举型变量,用来返回管脚输出类型。CNend
|
|
|
* \retval 0 Success. CNcomment:成功。CNend
|
|
|
* \retval ::SOC_ERR_GPIO_INVALID_PARA Parameters Invalid. CNcomment:非法参数。CNend
|
|
|
* \retval ::SOC_ERR_GPIO_NOT_INIT GPIO module is not initialiazed. CNcomment:GPIO模块没有初始化。CNend
|
|
|
* \retval ::SOC_ERR_GPIO_FAILED_GETOUTPUTTYPE Get output type failed. CNcomment:获取输出类型失败。CNend
|
|
|
* \see \n
|
|
|
* N/A
|
|
|
*/
|
|
|
td_s32 uapi_gpio_get_output_type(td_u32 group_number, td_u32 bit_number, uapi_gpio_output_type *output_type);
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
#if __cplusplus
|
|
|
}
|
|
|
#endif
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
|
#endif /* UAPI_GPIO_H */
|