XWOS API  4.0
XWOS C/C++ API参考手册
载入中...
搜索中...
未找到
eirq.c
浏览该文件的文档.
1
21#include <xwcd/ds/standard.h>
22#include <xwcd/ds/soc/gpio.h>
23#include <xwcd/ds/soc/eirq.h>
24
26xwer_t xwds_eirq_req(struct xwds_soc * soc, xwid_t port, xwsq_t pinmask,
27 xwid_t eiid, xwsq_t eiflag,
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}
78
80xwer_t xwds_eirq_rls(struct xwds_soc * soc, xwid_t port, xwsq_t pinmask, xwid_t eiid)
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 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:申请外部中断
Definition eirq.c:26
xwer_t xwds_eirq_rls(struct xwds_soc *soc, xwid_t port, xwsq_t pinmask, xwid_t eiid)
XWDS API:释放外部中断
Definition eirq.c:80
玄武设备栈:SOC:外部中断
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
void * xwds_eirq_arg_t
外部中断函数参数
Definition chip.h:138
#define xwds_cast(type, dev)
Definition standard.h:40
#define __xwds_api
Definition standard.h:33
#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
unsigned long xwid_t
Definition type.h:481
unsigned long xwsq_t
Definition type.h:445
#define XWOS_UNUSED(x)
Definition standard.h:66
玄武设备栈:SOC:GPIO
const struct xwds_driver * drv
Definition device.h:133
BSP中需要提供的SOC设备驱动函数表
Definition chip.h:51
xwer_t(* eirq_rls)(struct xwds_soc *, xwid_t, xwsq_t, xwid_t)
Definition chip.h:111
xwer_t(* eirq_req)(struct xwds_soc *, xwid_t, xwsq_t, xwid_t, xwsq_t)
Definition chip.h:108
SOC设备
Definition chip.h:161
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
玄武设备栈:顶级头文件