XWOS API  4.0
XWOS C/C++ API参考手册
载入中...
搜索中...
未找到
eirq.c 文件参考

玄武设备栈:SOC:外部中断 更多...

#include <xwcd/ds/standard.h>
#include <xwcd/ds/soc/gpio.h>
#include <xwcd/ds/soc/eirq.h>
eirq.c 的引用(Include)关系图:

浏览源代码.

函数

xwer_t xwds_eirq_req (struct xwds_soc *soc, xwid_t port, xwsq_t pinmask, xwid_t eiid, xwsq_t eiflag, xwds_eirq_f isr, xwds_eirq_arg_t arg)
 XWDS API:申请外部中断
 
xwer_t xwds_eirq_rls (struct xwds_soc *soc, xwid_t port, xwsq_t pinmask, xwid_t eiid)
 XWDS API:释放外部中断
 

详细描述

玄武设备栈:SOC:外部中断

作者

在文件 eirq.c 中定义.

函数说明

◆ xwds_eirq_req()

xwer_t xwds_eirq_req ( struct xwds_soc soc,
xwid_t  port,
xwsq_t  pinmask,
xwid_t  eiid,
xwsq_t  eiflag,
xwds_eirq_f  isr,
xwds_eirq_arg_t  arg 
)

XWDS API:申请外部中断

参数
[in]socSOC对象指针
[in]portGPIO端口
[in]pinmaskGPIO PIN
[in]eiid外部中断ID
[in]eiflag触发标志
[in]isr中断响应函数
[in]arg中断响应函数参数
返回
错误码
返回值
XWOK没有错误
-EFAULT无效指针
-ERANGE外部中断ID错误
注解
  • 上下文:中断、中断底半部、线程

<No error

在文件 eirq.c26 行定义.

29{
30 const struct xwds_soc_driver * drv;
31 xwer_t rc;
32
33 XWDS_VALIDATE(soc, "nullptr", -EFAULT);
34 XWDS_VALIDATE((eiid < soc->eirq.num), "out-of-range", -ERANGE);
35
36 rc = xwds_soc_grab(soc);
37 if (rc < 0) {
38 goto err_soc_grab;
39 }
40
41#if defined(XWCDCFG_ds_SOC_EIRQ_ROISRT) && (1 == XWCDCFG_ds_SOC_EIRQ_ROISRT)
42 XWOS_UNUSED(isr);
43 XWOS_UNUSED(arg);
44 if (NULL == soc->eirq.isrs[eiid]) {
45 rc = -EPERM;
46 goto err_perm;
47 }
48#else
49 if (soc->eirq.isrs[eiid]) {
50 rc = -EBUSY;
51 goto err_perm;
52 }
53 soc->eirq.isrs[eiid] = isr ? isr : (xwds_eirq_f)err_ptr(-EBUSY);
54 soc->eirq.isrargs[eiid] = arg;
55#endif
56
57 drv = xwds_cast(const struct xwds_soc_driver *, soc->dev.drv);
58 if ((drv) && (drv->eirq_req)) {
59 rc = drv->eirq_req(soc, port, pinmask, eiid, eiflag);
60 } else {
61 rc = -ENOSYS;
62 }
63 if (rc < 0) {
64 goto err_drv_eirq_req;
65 }
66 return XWOK;
67
68err_drv_eirq_req:
69#if !defined(XWCDCFG_ds_SOC_EIRQ_ROISRT) || (1 != XWCDCFG_ds_SOC_EIRQ_ROISRT)
70 soc->eirq.isrs[eiid] = NULL;
71 soc->eirq.isrargs[eiid] = NULL;
72#endif
73err_perm:
74 xwds_soc_put(soc);
75err_soc_grab:
76 return rc;
77}
void(* xwds_eirq_f)(struct xwds_soc *, xwid_t, xwds_eirq_arg_t)
外部中断函数
Definition chip.h:143
xwer_t xwds_soc_grab(struct xwds_soc *soc)
XWDS API:增加对象的引用计数
Definition chip.c:71
xwer_t xwds_soc_put(struct xwds_soc *soc)
XWDS API:减少对象的引用计数
Definition chip.c:77
#define xwds_cast(type, dev)
Definition standard.h:40
#define XWDS_VALIDATE(exp, errstr,...)
Definition standard.h:51
#define EFAULT
Bad address
Definition errno.h:44
#define ENOSYS
Function not implemented
Definition errno.h:110
#define XWOK
No error
Definition errno.h:182
#define EBUSY
Device or resource busy
Definition errno.h:46
#define ERANGE
Result too large
Definition errno.h:64
#define EPERM
Operation not permitted
Definition errno.h:31
static __xwcc_inline void *__xwcc_must_check err_ptr(xwer_t err)
将错误码转换为指针
Definition error.h:42
signed long xwer_t
Definition type.h:554
#define NULL
Definition type.h:28
#define XWOS_UNUSED(x)
Definition standard.h:66
const struct xwds_driver * drv
Definition device.h:133
BSP中需要提供的SOC设备驱动函数表
Definition chip.h:51
xwer_t(* eirq_req)(struct xwds_soc *, xwid_t, xwsq_t, xwid_t, xwsq_t)
Definition chip.h:108
struct xwds_device dev
Definition chip.h:162
xwds_eirq_arg_t * isrargs
Definition chip.h:187
xwds_eirq_f * isrs
Definition chip.h:186
struct xwds_soc::@24 eirq
函数调用图:
这是这个函数的调用关系图:

◆ xwds_eirq_rls()

xwer_t xwds_eirq_rls ( struct xwds_soc soc,
xwid_t  port,
xwsq_t  pinmask,
xwid_t  eiid 
)

XWDS API:释放外部中断

参数
[in]socSOC对象指针
[in]portGPIO端口
[in]pinmaskGPIO PIN
[in]eiid外部中断ID
返回
错误码
返回值
XWOK没有错误
-EFAULT无效指针
-ERANGE外部中断ID错误
注解
  • 上下文:中断、中断底半部、线程

<No error

在文件 eirq.c80 行定义.

81{
82 const struct xwds_soc_driver * drv;
83 xwer_t rc;
84
85 XWDS_VALIDATE(soc, "nullptr", -EFAULT);
86 XWDS_VALIDATE((eiid < soc->eirq.num), "out-of-range", -ERANGE);
87
88 if (NULL == soc->eirq.isrs[eiid]) {
89 rc = -EPERM;
90 goto err_notinused;
91 }
92 drv = xwds_cast(const struct xwds_soc_driver *, soc->dev.drv);
93 if ((drv) && (drv->eirq_rls)) {
94 rc = drv->eirq_rls(soc, port, pinmask, eiid);
95 } else {
96 rc = -ENOSYS;
97 }
98 if (rc < 0) {
99 goto err_drv_rlsei;
100 }
101#if !defined(XWCDCFG_ds_SOC_EIRQ_ROISRT) || (1 != XWCDCFG_ds_SOC_EIRQ_ROISRT)
102 soc->eirq.isrs[eiid] = NULL;
103 soc->eirq.isrargs[eiid] = NULL;
104#endif
105
106 xwds_soc_put(soc);
107 return XWOK;
108
109err_drv_rlsei:
110err_notinused:
111 return rc;
112}
xwer_t(* eirq_rls)(struct xwds_soc *, xwid_t, xwsq_t, xwid_t)
Definition chip.h:111
函数调用图:
这是这个函数的调用关系图: