XWOS API  4.0
XWOS C/C++ API参考手册
载入中...
搜索中...
未找到
IO扩展芯片 的协作图:

结构体

struct  xwds_iochip_driver
 BSP中需要提供的IO扩展芯片设备驱动函数表 更多...
 
struct  xwds_iochip
 IO扩展芯片 更多...
 

类型定义

typedef void * xwds_iochip_eirq_arg_t
 外部中断函数参数
 
typedef void(* xwds_iochip_eirq_f) (struct xwds_iochip *, xwid_t, xwds_iochip_eirq_arg_t)
 外部中断函数
 

函数

void xwds_iochip_construct (struct xwds_iochip *iochip)
 XWDS API:IOCHIP对象的构造函数
 
void xwds_iochip_destruct (struct xwds_iochip *iochip)
 XWDS API:IOCHIP对象的析构函数
 
xwer_t xwds_iochip_grab (struct xwds_iochip *iochip)
 XWDS API:增加对象的引用计数
 
xwer_t xwds_iochip_put (struct xwds_iochip *iochip)
 XWDS API:减少对象的引用计数
 
xwer_t xwds_iochip_gpio_req (struct xwds_iochip *iochip, xwid_t port, xwsq_t pinmask, xwtm_t to)
 XWDS API:申请IO扩展芯片的GPIO
 
xwer_t xwds_iochip_gpio_rls (struct xwds_iochip *iochip, xwid_t port, xwsq_t pinmask, xwtm_t to)
 XWDS API:释放IO扩展芯片的GPIO
 
xwer_t xwds_iochip_gpio_cfg (struct xwds_iochip *iochip, xwid_t port, xwsq_t pinmask, void *cfg, xwtm_t to)
 XWDS API:配置IO扩展芯片的GPIO
 
xwer_t xwds_iochip_gpio_set (struct xwds_iochip *iochip, xwid_t port, xwsq_t pinmask, xwtm_t to)
 XWDS API:将IO扩展芯片的GPIO设置为高电平
 
xwer_t xwds_iochip_gpio_reset (struct xwds_iochip *iochip, xwid_t port, xwsq_t pinmask, xwtm_t to)
 XWDS API:将IO扩展芯片的GPIO设置为低电平
 
xwer_t xwds_iochip_gpio_toggle (struct xwds_iochip *iochip, xwid_t port, xwsq_t pinmask, xwtm_t to)
 XWDS API:翻转IO扩展芯片的GPIO电平
 
xwer_t xwds_iochip_gpio_output (struct xwds_iochip *iochip, xwid_t port, xwsq_t pinmask, xwsq_t out, xwtm_t to)
 XWDS API:并行输出多个IO扩展芯片的GPIO
 
xwer_t xwds_iochip_gpio_input (struct xwds_iochip *iochip, xwid_t port, xwsq_t pinmask, xwsq_t *inbuf, xwtm_t to)
 XWDS API:并行读取多个IO扩展芯片的GPIO
 
#define XWDS_IOCHIP_GPIO_PORT(p)   (p)
 
#define XWDS_IOCHIP_GPIO_PIN(n)   (1U << ((xwu32_t)(n)))
 
#define XWDS_IOCHIP_GPIO_PIN_MASK(n)   (XWDS_IOCHIP_GPIO_PIN(n) - 1U)
 
enum  xwds_iochip_gpio_pin_em {
  XWDS_IOCHIP_GPIO_PIN_0 = (1U << ((xwu32_t)( 0 ))) , XWDS_IOCHIP_GPIO_PIN_1 = (1U << ((xwu32_t)( 1 ))) , XWDS_IOCHIP_GPIO_PIN_2 = (1U << ((xwu32_t)( 2 ))) , XWDS_IOCHIP_GPIO_PIN_3 = (1U << ((xwu32_t)( 3 ))) ,
  XWDS_IOCHIP_GPIO_PIN_4 = (1U << ((xwu32_t)( 4 ))) , XWDS_IOCHIP_GPIO_PIN_5 = (1U << ((xwu32_t)( 5 ))) , XWDS_IOCHIP_GPIO_PIN_6 = (1U << ((xwu32_t)( 6 ))) , XWDS_IOCHIP_GPIO_PIN_7 = (1U << ((xwu32_t)( 7 ))) ,
  XWDS_IOCHIP_GPIO_PIN_8 = (1U << ((xwu32_t)( 8 ))) , XWDS_IOCHIP_GPIO_PIN_9 = (1U << ((xwu32_t)( 9 ))) , XWDS_IOCHIP_GPIO_PIN_10 = (1U << ((xwu32_t)( 10 ))) , XWDS_IOCHIP_GPIO_PIN_11 = (1U << ((xwu32_t)( 11 ))) ,
  XWDS_IOCHIP_GPIO_PIN_12 = (1U << ((xwu32_t)( 12 ))) , XWDS_IOCHIP_GPIO_PIN_13 = (1U << ((xwu32_t)( 13 ))) , XWDS_IOCHIP_GPIO_PIN_14 = (1U << ((xwu32_t)( 14 ))) , XWDS_IOCHIP_GPIO_PIN_15 = (1U << ((xwu32_t)( 15 ))) ,
  XWDS_IOCHIP_GPIO_PIN_16 = (1U << ((xwu32_t)( 16 ))) , XWDS_IOCHIP_GPIO_PIN_17 = (1U << ((xwu32_t)( 17 ))) , XWDS_IOCHIP_GPIO_PIN_18 = (1U << ((xwu32_t)( 18 ))) , XWDS_IOCHIP_GPIO_PIN_19 = (1U << ((xwu32_t)( 19 ))) ,
  XWDS_IOCHIP_GPIO_PIN_20 = (1U << ((xwu32_t)( 20 ))) , XWDS_IOCHIP_GPIO_PIN_21 = (1U << ((xwu32_t)( 21 ))) , XWDS_IOCHIP_GPIO_PIN_22 = (1U << ((xwu32_t)( 22 ))) , XWDS_IOCHIP_GPIO_PIN_23 = (1U << ((xwu32_t)( 23 ))) ,
  XWDS_IOCHIP_GPIO_PIN_24 = (1U << ((xwu32_t)( 24 ))) , XWDS_IOCHIP_GPIO_PIN_25 = (1U << ((xwu32_t)( 25 ))) , XWDS_IOCHIP_GPIO_PIN_26 = (1U << ((xwu32_t)( 26 ))) , XWDS_IOCHIP_GPIO_PIN_27 = (1U << ((xwu32_t)( 27 ))) ,
  XWDS_IOCHIP_GPIO_PIN_28 = (1U << ((xwu32_t)( 28 ))) , XWDS_IOCHIP_GPIO_PIN_29 = (1U << ((xwu32_t)( 29 ))) , XWDS_IOCHIP_GPIO_PIN_30 = (1U << ((xwu32_t)( 30 ))) , XWDS_IOCHIP_GPIO_PIN_31 = (1U << ((xwu32_t)( 31 )))
}
 XWDS IOCHIP GPIO PIN 枚举 更多...
 

详细描述

宏定义说明

◆ XWDS_IOCHIP_GPIO_PIN

#define XWDS_IOCHIP_GPIO_PIN (   n)    (1U << ((xwu32_t)(n)))

在文件 gpio.h34 行定义.

◆ XWDS_IOCHIP_GPIO_PIN_MASK

#define XWDS_IOCHIP_GPIO_PIN_MASK (   n)    (XWDS_IOCHIP_GPIO_PIN(n) - 1U)

在文件 gpio.h35 行定义.

◆ XWDS_IOCHIP_GPIO_PORT

#define XWDS_IOCHIP_GPIO_PORT (   p)    (p)

在文件 gpio.h32 行定义.

类型定义说明

◆ xwds_iochip_eirq_arg_t

typedef void* xwds_iochip_eirq_arg_t

外部中断函数参数

在文件 chip.h40 行定义.

◆ xwds_iochip_eirq_f

typedef void(* xwds_iochip_eirq_f) (struct xwds_iochip *, xwid_t, xwds_iochip_eirq_arg_t)

外部中断函数

在文件 chip.h45 行定义.

枚举类型说明

◆ xwds_iochip_gpio_pin_em

XWDS IOCHIP GPIO PIN 枚举

枚举值
XWDS_IOCHIP_GPIO_PIN_0 

Pin 0

XWDS_IOCHIP_GPIO_PIN_1 

Pin 1

XWDS_IOCHIP_GPIO_PIN_2 

Pin 2

XWDS_IOCHIP_GPIO_PIN_3 

Pin 3

XWDS_IOCHIP_GPIO_PIN_4 

Pin 4

XWDS_IOCHIP_GPIO_PIN_5 

Pin 5

XWDS_IOCHIP_GPIO_PIN_6 

Pin 6

XWDS_IOCHIP_GPIO_PIN_7 

Pin 7

XWDS_IOCHIP_GPIO_PIN_8 

Pin 8

XWDS_IOCHIP_GPIO_PIN_9 

Pin 9

XWDS_IOCHIP_GPIO_PIN_10 

Pin 10

XWDS_IOCHIP_GPIO_PIN_11 

Pin 11

XWDS_IOCHIP_GPIO_PIN_12 

Pin 12

XWDS_IOCHIP_GPIO_PIN_13 

Pin 13

XWDS_IOCHIP_GPIO_PIN_14 

Pin 14

XWDS_IOCHIP_GPIO_PIN_15 

Pin 15

XWDS_IOCHIP_GPIO_PIN_16 

Pin 16

XWDS_IOCHIP_GPIO_PIN_17 

Pin 17

XWDS_IOCHIP_GPIO_PIN_18 

Pin 18

XWDS_IOCHIP_GPIO_PIN_19 

Pin 19

XWDS_IOCHIP_GPIO_PIN_20 

Pin 20

XWDS_IOCHIP_GPIO_PIN_21 

Pin 21

XWDS_IOCHIP_GPIO_PIN_22 

Pin 22

XWDS_IOCHIP_GPIO_PIN_23 

Pin 23

XWDS_IOCHIP_GPIO_PIN_24 

Pin 24

XWDS_IOCHIP_GPIO_PIN_25 

Pin 25

XWDS_IOCHIP_GPIO_PIN_26 

Pin 26

XWDS_IOCHIP_GPIO_PIN_27 

Pin 27

XWDS_IOCHIP_GPIO_PIN_28 

Pin 28

XWDS_IOCHIP_GPIO_PIN_29 

Pin 29

XWDS_IOCHIP_GPIO_PIN_30 

Pin 30

XWDS_IOCHIP_GPIO_PIN_31 

Pin 31

在文件 gpio.h40 行定义.

40 {
73};
#define XWDS_IOCHIP_GPIO_PIN(n)
Definition gpio.h:34
@ XWDS_IOCHIP_GPIO_PIN_16
Definition gpio.h:57
@ XWDS_IOCHIP_GPIO_PIN_20
Definition gpio.h:61
@ XWDS_IOCHIP_GPIO_PIN_26
Definition gpio.h:67
@ XWDS_IOCHIP_GPIO_PIN_6
Definition gpio.h:47
@ XWDS_IOCHIP_GPIO_PIN_1
Definition gpio.h:42
@ XWDS_IOCHIP_GPIO_PIN_9
Definition gpio.h:50
@ XWDS_IOCHIP_GPIO_PIN_23
Definition gpio.h:64
@ XWDS_IOCHIP_GPIO_PIN_31
Definition gpio.h:72
@ XWDS_IOCHIP_GPIO_PIN_30
Definition gpio.h:71
@ XWDS_IOCHIP_GPIO_PIN_21
Definition gpio.h:62
@ XWDS_IOCHIP_GPIO_PIN_19
Definition gpio.h:60
@ XWDS_IOCHIP_GPIO_PIN_13
Definition gpio.h:54
@ XWDS_IOCHIP_GPIO_PIN_2
Definition gpio.h:43
@ XWDS_IOCHIP_GPIO_PIN_27
Definition gpio.h:68
@ XWDS_IOCHIP_GPIO_PIN_29
Definition gpio.h:70
@ XWDS_IOCHIP_GPIO_PIN_8
Definition gpio.h:49
@ XWDS_IOCHIP_GPIO_PIN_24
Definition gpio.h:65
@ XWDS_IOCHIP_GPIO_PIN_14
Definition gpio.h:55
@ XWDS_IOCHIP_GPIO_PIN_25
Definition gpio.h:66
@ XWDS_IOCHIP_GPIO_PIN_11
Definition gpio.h:52
@ XWDS_IOCHIP_GPIO_PIN_4
Definition gpio.h:45
@ XWDS_IOCHIP_GPIO_PIN_18
Definition gpio.h:59
@ XWDS_IOCHIP_GPIO_PIN_12
Definition gpio.h:53
@ XWDS_IOCHIP_GPIO_PIN_5
Definition gpio.h:46
@ XWDS_IOCHIP_GPIO_PIN_15
Definition gpio.h:56
@ XWDS_IOCHIP_GPIO_PIN_0
Definition gpio.h:41
@ XWDS_IOCHIP_GPIO_PIN_7
Definition gpio.h:48
@ XWDS_IOCHIP_GPIO_PIN_3
Definition gpio.h:44
@ XWDS_IOCHIP_GPIO_PIN_17
Definition gpio.h:58
@ XWDS_IOCHIP_GPIO_PIN_28
Definition gpio.h:69
@ XWDS_IOCHIP_GPIO_PIN_10
Definition gpio.h:51
@ XWDS_IOCHIP_GPIO_PIN_22
Definition gpio.h:63

函数说明

◆ xwds_iochip_construct()

void xwds_iochip_construct ( struct xwds_iochip iochip)

XWDS API:IOCHIP对象的构造函数

参数
[in]iochipIOCHIP对象指针

在文件 chip.c58 行定义.

59{
61 iochip->bc.dev.vop = &xwds_iochip_vop;
62}
void xwds_device_construct(struct xwds_device *dev)
XWDS API:设备的构造函数
Definition device.c:48
const struct xwds_virtual_operation xwds_iochip_vop
Definition chip.c:45
const struct xwds_virtual_operation * vop
Definition device.h:138
struct xwds_device dev
Definition chip.h:97
union xwds_iochip::@19 bc
函数调用图:

◆ xwds_iochip_destruct()

void xwds_iochip_destruct ( struct xwds_iochip iochip)

XWDS API:IOCHIP对象的析构函数

参数
[in]iochipIOCHIP对象指针

在文件 chip.c65 行定义.

66{
67 xwds_device_destruct(&iochip->bc.dev);
68}
void xwds_device_destruct(struct xwds_device *dev)
XWDS API:设备的析构函数
Definition device.c:56
函数调用图:

◆ xwds_iochip_gpio_cfg()

xwer_t xwds_iochip_gpio_cfg ( struct xwds_iochip iochip,
xwid_t  port,
xwsq_t  pinmask,
void *  cfg,
xwtm_t  to 
)

XWDS API:配置IO扩展芯片的GPIO

参数
[in]iochipIOCHIP对象指针
[in]portGPIO端口
[in]pinmask引脚的掩码,取值 xwds_iochip_gpio_pin_em 中的任意项的或运算
[in]cfgGPIO配置,取值依据不同IOCHIP
[in]to期望唤醒的时间点
返回
错误码
返回值
XWOK没有错误
-EFAULT无效指针
-ERANGEGPIO PORT错误
-ENOSYS不支持的API
注解
  • 上下文:线程

<No error

在文件 gpio.c100 行定义.

103{
104 const struct xwds_iochip_driver * drv;
105 xwer_t rc;
106
107 XWDS_VALIDATE(iochip, "nullptr", -EFAULT);
108 XWDS_VALIDATE((port < iochip->gpio.port_num), "out-of-range", -ERANGE);
109 XWDS_VALIDATE(cfg, "nullptr", -EFAULT);
110
111 pinmask &= XWDS_IOCHIP_GPIO_PIN_MASK(iochip->gpio.pin_num);
112 rc = xwds_iochip_grab(iochip);
113 if (rc < 0) {
114 goto err_iochip_grab;
115 }
116 drv = xwds_cast(const struct xwds_iochip_driver *, iochip->bc.dev.drv);
117 if ((drv) && (drv->gpio_cfg)) {
118 rc = drv->gpio_cfg(iochip, port, pinmask, cfg, to);
119 } else {
120 rc = -ENOSYS;
121 }
122 if (rc < 0) {
123 goto err_drv_gpio_cfg;
124 }
125 xwds_iochip_put(iochip);
126 return XWOK;
127
128err_drv_gpio_cfg:
129 xwds_iochip_put(iochip);
130err_iochip_grab:
131 return rc;
132}
xwer_t xwds_iochip_grab(struct xwds_iochip *iochip)
XWDS API:增加对象的引用计数
Definition chip.c:71
xwer_t xwds_iochip_put(struct xwds_iochip *iochip)
XWDS API:减少对象的引用计数
Definition chip.c:77
#define XWDS_IOCHIP_GPIO_PIN_MASK(n)
Definition gpio.h:35
#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 ERANGE
Result too large
Definition errno.h:64
signed long xwer_t
Definition type.h:554
const struct xwds_driver * drv
Definition device.h:133
BSP中需要提供的IO扩展芯片设备驱动函数表
Definition chip.h:52
xwer_t(* gpio_cfg)(struct xwds_iochip *, xwid_t, xwsq_t, void *, xwtm_t)
Definition chip.h:63
xwsz_t pin_num
Definition chip.h:111
struct xwds_iochip::@20 gpio
函数调用图:

◆ xwds_iochip_gpio_input()

xwer_t xwds_iochip_gpio_input ( struct xwds_iochip iochip,
xwid_t  port,
xwsq_t  pinmask,
xwsq_t inbuf,
xwtm_t  to 
)

XWDS API:并行读取多个IO扩展芯片的GPIO

参数
[in]iochipIOCHIP对象指针
[in]portGPIO端口
[in]pinmask引脚的掩码,取值 xwds_iochip_gpio_pin_em 中的任意项的或运算
[out]inbuf输入缓冲区
[in]to期望唤醒的时间点
返回
错误码
返回值
XWOK没有错误
-EFAULT无效指针
-ERANGEGPIO PORT错误
-EPERMGPIO PIN未被申请
-ENOSYS不支持的API
注解
  • 上下文:线程

<No error

在文件 gpio.c299 行定义.

302{
303 const struct xwds_iochip_driver * drv;
304 xwsq_t pinsts;
305 xwer_t rc;
306
307 XWDS_VALIDATE(iochip, "nullptr", -EFAULT);
308 XWDS_VALIDATE((port < iochip->gpio.port_num), "out-of-range", -ERANGE);
309
310 pinmask &= XWDS_IOCHIP_GPIO_PIN_MASK(iochip->gpio.pin_num);
311 rc = xwds_iochip_grab(iochip);
312 if (rc < 0) {
313 goto err_iochip_grab;
314 }
315 pinsts = xwaop_load(xwsq_t, &iochip->gpio.pins[port], xwaop_mo_relaxed);
316 if (pinmask & (~pinsts)) {
317 rc = -EPERM;
318 goto err_pinsts;
319 }
320 drv = xwds_cast(const struct xwds_iochip_driver *, iochip->bc.dev.drv);
321 if ((drv) && (drv->gpio_input)) {
322 rc = drv->gpio_input(iochip, port, pinmask, inbuf, to);
323 } else {
324 rc = -ENOSYS;
325 }
326 if (rc < 0) {
327 goto err_drv_in;
328 }
329 xwds_iochip_put(iochip);
330 return XWOK;
331
332err_drv_in:
333err_pinsts:
334 xwds_iochip_put(iochip);
335err_iochip_grab:
336 return rc;
337}
#define EPERM
Operation not permitted
Definition errno.h:31
unsigned long xwsq_t
Definition type.h:445
@ xwaop_mo_relaxed
Definition type.h:628
#define xwaop_load(type, a, memorder)
对原子变量进行原子操作:加载
Definition xwaop.h:45
xwer_t(* gpio_input)(struct xwds_iochip *, xwid_t, xwsq_t, xwsq_t *, xwtm_t)
Definition chip.h:85
atomic_xwsq_t * pins
Definition chip.h:109
函数调用图:

◆ xwds_iochip_gpio_output()

xwer_t xwds_iochip_gpio_output ( struct xwds_iochip iochip,
xwid_t  port,
xwsq_t  pinmask,
xwsq_t  out,
xwtm_t  to 
)

XWDS API:并行输出多个IO扩展芯片的GPIO

参数
[in]iochipIOCHIP对象指针
[in]portGPIO端口
[in]pinmask引脚的掩码,取值 xwds_iochip_gpio_pin_em 中的任意项的或运算
[in]out输出值,取值 xwds_iochip_gpio_pin_em 中的任意项的或运算, 只有被pinmask掩码覆盖的部分有效,未覆盖的pin输出不会发生改变。
[in]to期望唤醒的时间点
返回
错误码
返回值
XWOK没有错误
-EFAULT无效指针
-ERANGEGPIO PORT错误
-EPERMGPIO PIN未被申请
-ENOSYS不支持的API
注解
  • 上下文:线程

<No error

在文件 gpio.c258 行定义.

261{
262 const struct xwds_iochip_driver * drv;
263 xwsq_t pinsts;
264 xwer_t rc;
265
266 XWDS_VALIDATE(iochip, "nullptr", -EFAULT);
267 XWDS_VALIDATE((port < iochip->gpio.port_num), "out-of-range", -ERANGE);
268
269 pinmask &= XWDS_IOCHIP_GPIO_PIN_MASK(iochip->gpio.pin_num);
270 rc = xwds_iochip_grab(iochip);
271 if (rc < 0) {
272 goto err_iochip_grab;
273 }
274 pinsts = xwaop_load(xwsq_t, &iochip->gpio.pins[port], xwaop_mo_relaxed);
275 if (pinmask & (~pinsts)) {
276 rc = -EPERM;
277 goto err_pinsts;
278 }
279 drv = xwds_cast(const struct xwds_iochip_driver *, iochip->bc.dev.drv);
280 if ((drv) && (drv->gpio_output)) {
281 rc = drv->gpio_output(iochip, port, pinmask, out, to);
282 } else {
283 rc = -ENOSYS;
284 }
285 if (rc < 0) {
286 goto err_drv_out;
287 }
288 xwds_iochip_put(iochip);
289 return XWOK;
290
291err_drv_out:
292err_pinsts:
293 xwds_iochip_put(iochip);
294err_iochip_grab:
295 return rc;
296}
xwer_t(* gpio_output)(struct xwds_iochip *, xwid_t, xwsq_t, xwsq_t, xwtm_t)
Definition chip.h:68
函数调用图:

◆ xwds_iochip_gpio_req()

xwer_t xwds_iochip_gpio_req ( struct xwds_iochip iochip,
xwid_t  port,
xwsq_t  pinmask,
xwtm_t  to 
)

XWDS API:申请IO扩展芯片的GPIO

参数
[in]iochipIOCHIP对象指针
[in]portGPIO端口
[in]pinmask引脚的掩码,取值 xwds_iochip_gpio_pin_em 中的任意项的或运算
[in]to期望唤醒的时间点
返回
错误码
返回值
XWOK没有错误
-EFAULT无效指针
-ERANGEGPIO PORT错误
-EBUSYGPIO PIN已被使用
注解
  • 上下文:线程

<No error

在文件 gpio.c27 行定义.

30{
31 const struct xwds_iochip_driver * drv;
32 xwer_t rc;
33
34 XWDS_VALIDATE(iochip, "nullptr", -EFAULT);
35 XWDS_VALIDATE((port < iochip->gpio.port_num), "out-of-range", -ERANGE);
36
37 pinmask &= XWDS_IOCHIP_GPIO_PIN_MASK(iochip->gpio.pin_num);
38 rc = xwds_iochip_grab(iochip);
39 if (rc < 0) {
40 goto err_iochip_grab;
41 }
42 rc = xwaop_t0ma_then_s1m(xwsq_t, &iochip->gpio.pins[port], pinmask, NULL, NULL);
43 if (rc < 0) {
44 rc = -EBUSY;
45 goto err_set_pin;
46 }
47 drv = xwds_cast(const struct xwds_iochip_driver *, iochip->bc.dev.drv);
48 if ((drv) && (drv->gpio_req)) {
49 rc = drv->gpio_req(iochip, port, pinmask, to);
50 if (rc < 0) {
51 goto err_drv_gpio_req;
52 }
53 }
54 return XWOK;
55
56err_drv_gpio_req:
57 xwaop_c0m(xwsq_t, &iochip->gpio.pins[port], pinmask, NULL, NULL);
58err_set_pin:
59 xwds_iochip_put(iochip);
60err_iochip_grab:
61 return rc;
62}
#define EBUSY
Device or resource busy
Definition errno.h:46
#define NULL
Definition type.h:28
#define xwaop_c0m(type, a, m, nv, ov)
对原子变量进行原子操作:读取-位清0操作-回写
Definition xwaop.h:1190
#define xwaop_t0ma_then_s1m(type, a, m, nv, ov)
对原子变量进行原子操作:读取-位测试-位置1操作-回写
Definition xwaop.h:1277
xwer_t(* gpio_req)(struct xwds_iochip *, xwid_t, xwsq_t, xwtm_t)
Definition chip.h:55
函数调用图:

◆ xwds_iochip_gpio_reset()

xwer_t xwds_iochip_gpio_reset ( struct xwds_iochip iochip,
xwid_t  port,
xwsq_t  pinmask,
xwtm_t  to 
)

XWDS API:将IO扩展芯片的GPIO设置为低电平

参数
[in]iochipIOCHIP对象指针
[in]portGPIO端口
[in]pinmask引脚的掩码,取值 xwds_iochip_gpio_pin_em 中的任意项的或运算
[in]to期望唤醒的时间点
返回
错误码
返回值
XWOK没有错误
-EFAULT无效指针
-ERANGEGPIO PORT错误
-EPERMGPIO PIN未被申请
-ENOSYS不支持的API
注解
  • 上下文:线程

<No error

在文件 gpio.c176 行定义.

179{
180 const struct xwds_iochip_driver * drv;
181 xwsq_t pinsts;
182 xwer_t rc;
183
184 XWDS_VALIDATE(iochip, "nullptr", -EFAULT);
185 XWDS_VALIDATE((port < iochip->gpio.port_num), "out-of-range", -ERANGE);
186
187 pinmask &= XWDS_IOCHIP_GPIO_PIN_MASK(iochip->gpio.pin_num);
188 rc = xwds_iochip_grab(iochip);
189 if (rc < 0) {
190 goto err_iochip_grab;
191 }
192 pinsts = xwaop_load(xwsq_t, &iochip->gpio.pins[port], xwaop_mo_relaxed);
193 if (pinmask & (~pinsts)) {
194 rc = -EPERM;
195 goto err_pinsts;
196 }
197 drv = xwds_cast(const struct xwds_iochip_driver *, iochip->bc.dev.drv);
198 if ((drv) && (drv->gpio_reset)) {
199 rc = drv->gpio_reset(iochip, port, pinmask, to);
200 } else {
201 rc = -ENOSYS;
202 }
203 if (rc < 0) {
204 goto err_drv_reset;
205 }
206 xwds_iochip_put(iochip);
207 return XWOK;
208
209err_drv_reset:
210err_pinsts:
211 xwds_iochip_put(iochip);
212err_iochip_grab:
213 return rc;
214}
xwer_t(* gpio_reset)(struct xwds_iochip *, xwid_t, xwsq_t, xwtm_t)
Definition chip.h:77
函数调用图:

◆ xwds_iochip_gpio_rls()

xwer_t xwds_iochip_gpio_rls ( struct xwds_iochip iochip,
xwid_t  port,
xwsq_t  pinmask,
xwtm_t  to 
)

XWDS API:释放IO扩展芯片的GPIO

参数
[in]iochipIOCHIP对象指针
[in]portGPIO端口
[in]pinmask引脚的掩码,取值 xwds_iochip_gpio_pin_em 中的任意项的或运算
[in]to期望唤醒的时间点
返回
错误码
返回值
XWOK没有错误
-EFAULT无效指针
-ERANGEGPIO PORT错误
-EPERMGPIO PIN未被申请
注解
  • 上下文:线程

<No error

在文件 gpio.c65 行定义.

68{
69 const struct xwds_iochip_driver * drv;
70 xwsq_t pinsts;
71 xwer_t rc;
72
73 XWDS_VALIDATE(iochip, "nullptr", -EFAULT);
74 XWDS_VALIDATE((port < iochip->gpio.port_num), "out-of-range", -ERANGE);
75
76 pinmask &= XWDS_IOCHIP_GPIO_PIN_MASK(iochip->gpio.pin_num);
77 pinsts = xwaop_load(xwsq_t, &iochip->gpio.pins[port], xwaop_mo_relaxed);
78 if (pinmask & (~pinsts)) {
79 rc = -EPERM;
80 goto err_pinsts;
81 }
82 drv = xwds_cast(const struct xwds_iochip_driver *, iochip->bc.dev.drv);
83 if ((drv) && (drv->gpio_rls)) {
84 rc = drv->gpio_rls(iochip, port, pinmask, to);
85 if (rc < 0) {
86 goto err_drv_gpio_rls;
87 }
88 }
89 xwaop_c0m(xwsq_t, &iochip->gpio.pins[port], pinmask, NULL, NULL);
90
91 xwds_iochip_put(iochip);
92 return XWOK;
93
94err_drv_gpio_rls:
95err_pinsts:
96 return rc;
97}
xwer_t(* gpio_rls)(struct xwds_iochip *, xwid_t, xwid_t, xwtm_t)
Definition chip.h:59
函数调用图:

◆ xwds_iochip_gpio_set()

xwer_t xwds_iochip_gpio_set ( struct xwds_iochip iochip,
xwid_t  port,
xwsq_t  pinmask,
xwtm_t  to 
)

XWDS API:将IO扩展芯片的GPIO设置为高电平

参数
[in]iochipIOCHIP对象指针
[in]portGPIO端口
[in]pinmask引脚的掩码,取值 xwds_iochip_gpio_pin_em 中的任意项的或运算
[in]to期望唤醒的时间点
返回
错误码
返回值
XWOK没有错误
-EFAULT无效指针
-ERANGEGPIO PORT错误
-EPERMGPIO PIN未被申请
-ENOSYS不支持的API
注解
  • 上下文:线程

<No error

在文件 gpio.c135 行定义.

138{
139 const struct xwds_iochip_driver * drv;
140 xwsq_t pinsts;
141 xwer_t rc;
142
143 XWDS_VALIDATE(iochip, "nullptr", -EFAULT);
144 XWDS_VALIDATE((port < iochip->gpio.port_num), "out-of-range", -ERANGE);
145
146 pinmask &= XWDS_IOCHIP_GPIO_PIN_MASK(iochip->gpio.pin_num);
147 rc = xwds_iochip_grab(iochip);
148 if (rc < 0) {
149 goto err_iochip_grab;
150 }
151 pinsts = xwaop_load(xwsq_t, &iochip->gpio.pins[port], xwaop_mo_relaxed);
152 if (pinmask & (~pinsts)) {
153 rc = -EPERM;
154 goto err_pinsts;
155 }
156 drv = xwds_cast(const struct xwds_iochip_driver *, iochip->bc.dev.drv);
157 if ((drv) && (drv->gpio_set)) {
158 rc = drv->gpio_set(iochip, port, pinmask, to);
159 } else {
160 rc = -ENOSYS;
161 }
162 if (rc < 0) {
163 goto err_drv_set;
164 }
165 xwds_iochip_put(iochip);
166 return XWOK;
167
168err_drv_set:
169err_pinsts:
170 xwds_iochip_put(iochip);
171err_iochip_grab:
172 return rc;
173}
xwer_t(* gpio_set)(struct xwds_iochip *, xwid_t, xwsq_t, xwtm_t)
Definition chip.h:73
函数调用图:

◆ xwds_iochip_gpio_toggle()

xwer_t xwds_iochip_gpio_toggle ( struct xwds_iochip iochip,
xwid_t  port,
xwsq_t  pinmask,
xwtm_t  to 
)

XWDS API:翻转IO扩展芯片的GPIO电平

参数
[in]iochipIOCHIP对象指针
[in]portGPIO端口
[in]pinmask引脚的掩码,取值 xwds_iochip_gpio_pin_em 中的任意项的或运算
[in]to期望唤醒的时间点
返回
错误码
返回值
XWOK没有错误
-EFAULT无效指针
-ERANGEGPIO PORT错误
-EPERMGPIO PIN未被申请
-ENOSYS不支持的API
注解
  • 上下文:线程

<No error

在文件 gpio.c217 行定义.

220{
221 const struct xwds_iochip_driver * drv;
222 xwsq_t pinsts;
223 xwer_t rc;
224
225 XWDS_VALIDATE(iochip, "nullptr", -EFAULT);
226 XWDS_VALIDATE((port < iochip->gpio.port_num), "out-of-range", -ERANGE);
227
228 pinmask &= XWDS_IOCHIP_GPIO_PIN_MASK(iochip->gpio.pin_num);
229 rc = xwds_iochip_grab(iochip);
230 if (rc < 0) {
231 goto err_iochip_grab;
232 }
233 pinsts = xwaop_load(xwsq_t, &iochip->gpio.pins[port], xwaop_mo_relaxed);
234 if (pinmask & (~pinsts)) {
235 rc = -EPERM;
236 goto err_pinsts;
237 }
238 drv = xwds_cast(const struct xwds_iochip_driver *, iochip->bc.dev.drv);
239 if ((drv) && (drv->gpio_toggle)) {
240 rc = drv->gpio_toggle(iochip, port, pinmask, to);
241 } else {
242 rc = -ENOSYS;
243 }
244 if (rc < 0) {
245 goto err_drv_toggle;
246 }
247 xwds_iochip_put(iochip);
248 return XWOK;
249
250err_drv_toggle:
251err_pinsts:
252 xwds_iochip_put(iochip);
253err_iochip_grab:
254 return rc;
255}
xwer_t(* gpio_toggle)(struct xwds_iochip *, xwid_t, xwsq_t, xwtm_t)
Definition chip.h:81
函数调用图:

◆ xwds_iochip_grab()

xwer_t xwds_iochip_grab ( struct xwds_iochip iochip)

XWDS API:增加对象的引用计数

参数
[in]iochipIOCHIP对象指针

在文件 chip.c71 行定义.

72{
73 return xwds_device_grab(&iochip->bc.dev);
74}
static xwer_t xwds_device_grab(struct xwds_device *dev)
XWDS API:增加对象的引用计数
Definition device.h:268
函数调用图:
这是这个函数的调用关系图:

◆ xwds_iochip_put()

xwer_t xwds_iochip_put ( struct xwds_iochip iochip)

XWDS API:减少对象的引用计数

参数
[in]iochipIOCHIP对象指针

在文件 chip.c77 行定义.

78{
79 return xwds_device_put(&iochip->bc.dev);
80}
static xwer_t xwds_device_put(struct xwds_device *dev)
XWDS API:减少对象的引用计数
Definition device.h:281
函数调用图:
这是这个函数的调用关系图: