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

结构体

struct  xwds_soc_driver
 BSP中需要提供的SOC设备驱动函数表 更多...
 
struct  xwds_soc
 SOC设备 更多...
 

宏定义

#define __xwds_soc_eirq_tbl_qualifier
 
#define __xwds_soc_dma_tbl_qualifier
 

类型定义

typedef void * xwds_eirq_arg_t
 外部中断函数参数
 
typedef void(* xwds_eirq_f) (struct xwds_soc *, xwid_t, xwds_eirq_arg_t)
 外部中断函数
 
typedef void * xwds_dma_cbarg_t
 DMA完成回调函数参数
 
typedef void(* xwds_dma_f) (struct xwds_soc *, xwid_t, xwu32_t, xwds_dma_cbarg_t)
 DMA完成回调函数类型
 

函数

void xwds_soc_construct (struct xwds_soc *soc)
 XWDS API:SOC构造函数
 
void xwds_soc_destruct (struct xwds_soc *soc)
 XWDS API:SOC对象的析构函数
 
xwer_t xwds_soc_grab (struct xwds_soc *soc)
 XWDS API:增加对象的引用计数
 
xwer_t xwds_soc_put (struct xwds_soc *soc)
 XWDS API:减少对象的引用计数
 
xwer_t xwds_soc_get_reset_reason (struct xwds_soc *soc, xwu64_t *reason)
 XWDS API:获取复位原因
 
xwer_t xwds_soc_get_wkup_source (struct xwds_soc *soc, xwu64_t *source)
 XWDS API:获取唤醒源
 
xwer_t xwds_clk_req (struct xwds_soc *soc, xwid_t id)
 XWDS API:申请时钟
 
xwer_t xwds_clk_rls (struct xwds_soc *soc, xwid_t id)
 XWDS API:释放时钟
 
xwer_t xwds_clk_getfqcy (struct xwds_soc *soc, xwid_t id, xwu32_t *buf, xwsz_t *num)
 XWDS API:获取时钟频率
 
xwer_t xwds_pwr_req (struct xwds_soc *soc, xwid_t id)
 XWDS API:申请电源
 
xwer_t xwds_pwr_rls (struct xwds_soc *soc, xwid_t id)
 XWDS API:释放电源
 
xwer_t xwds_pwr_getvltg (struct xwds_soc *soc, xwid_t id, xwu32_t *buf, xwsz_t *num)
 XWDS API:获取电源电压
 
xwer_t xwds_dma_req (struct xwds_soc *soc, xwid_t ch)
 XWDS API:申请DMA的通道
 
xwer_t xwds_dma_rls (struct xwds_soc *soc, xwid_t ch)
 XWDS API:释放DMA的通道
 
xwer_t xwds_dma_cfg (struct xwds_soc *soc, xwid_t ch, void *cfg, xwds_dma_f cb, xwds_dma_cbarg_t arg)
 XWDS API:配置DMA的通道
 
xwer_t xwds_dma_enable (struct xwds_soc *soc, xwid_t ch)
 XWDS API:打开DMA的通道
 
xwer_t xwds_dma_disable (struct xwds_soc *soc, xwid_t ch)
 XWDS API:关闭DMA的通道
 
xwer_t xwds_dma_start (struct xwds_soc *soc, xwid_t ch)
 XWDS API:启动DMA的通道
 
xwer_t xwds_dma_stop (struct xwds_soc *soc, xwid_t ch)
 XWDS API:停止DMA的通道
 
#define XWDS_DMA_CH(x)   ((xwid_t)(x))
 XWDS DMA 通道
 
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:释放外部中断
 
#define XWDS_EIRQ(x)   ((xwid_t)x)
 XWDS External IRQ Number
 
enum  xwds_soc_ei_flag_em {
  XWDS_SOC_EIF_TM_RISING = ((xwbmp_t)1 << ( 0 )) , XWDS_SOC_EIF_TM_FALLING = ((xwbmp_t)1 << ( 1 )) , XWDS_SOC_EIF_TM_EITHER , XWDS_SOC_EIF_TM_LOW = ((xwbmp_t)1 << ( 2 )) ,
  XWDS_SOC_EIF_TM_HIGH = ((xwbmp_t)1 << ( 3 )) , XWDS_SOC_EIF_TM_MASK , XWDS_SOC_EIF_WKUP = ((xwbmp_t)1 << ( 4 )) , XWDS_SOC_EIF_DMA = ((xwbmp_t)1 << ( 5 ))
}
 外部中断标志 更多...
 
xwer_t xwds_gpio_req (struct xwds_soc *soc, xwid_t port, xwsq_t pinmask)
 XWDS API:申请SOC的GPIO
 
xwer_t xwds_gpio_rls (struct xwds_soc *soc, xwid_t port, xwsq_t pinmask)
 XWDS API:释放SOC的GPIO
 
xwer_t xwds_gpio_cfg (struct xwds_soc *soc, xwid_t port, xwsq_t pinmask, void *cfg)
 XWDS API:配置SOC的GPIO
 
xwer_t xwds_gpio_set (struct xwds_soc *soc, xwid_t port, xwsq_t pinmask)
 XWDS API:将SOC的GPIO设置为高电平
 
xwer_t xwds_gpio_reset (struct xwds_soc *soc, xwid_t port, xwsq_t pinmask)
 XWDS API:将SOC的GPIO设置为低电平
 
xwer_t xwds_gpio_toggle (struct xwds_soc *soc, xwid_t port, xwsq_t pinmask)
 XWDS API:翻转SOC的GPIO电平
 
xwer_t xwds_gpio_output (struct xwds_soc *soc, xwid_t port, xwsq_t pinmask, xwsq_t out)
 XWDS API:并行输出多个SOC的GPIO
 
xwer_t xwds_gpio_read_output (struct xwds_soc *soc, xwid_t port, xwsq_t pinmask, xwsq_t *outbuf)
 XWDS API:读取GPIO的输出值
 
xwer_t xwds_gpio_input (struct xwds_soc *soc, xwid_t port, xwsq_t pinmask, xwsq_t *inbuf)
 XWDS API:并行读取多个SOC的GPIO
 
#define XWDS_GPIO_PIN(n)   (1U << (n))
 
#define XWDS_GPIO_PIN_MASK(n)   (XWDS_GPIO_PIN(n) - 1U)
 
enum  xwds_gpio_port_em {
  XWDS_GPIO_PORT_A = 0 , XWDS_GPIO_PORT_B , XWDS_GPIO_PORT_C , XWDS_GPIO_PORT_D ,
  XWDS_GPIO_PORT_E , XWDS_GPIO_PORT_F , XWDS_GPIO_PORT_G , XWDS_GPIO_PORT_H ,
  XWDS_GPIO_PORT_I , XWDS_GPIO_PORT_J , XWDS_GPIO_PORT_K , XWDS_GPIO_PORT_L ,
  XWDS_GPIO_PORT_M , XWDS_GPIO_PORT_N , XWDS_GPIO_PORT_O , XWDS_GPIO_PORT_P ,
  XWDS_GPIO_PORT_Q , XWDS_GPIO_PORT_R , XWDS_GPIO_PORT_S , XWDS_GPIO_PORT_T ,
  XWDS_GPIO_PORT_U , XWDS_GPIO_PORT_V , XWDS_GPIO_PORT_W , XWDS_GPIO_PORT_X ,
  XWDS_GPIO_PORT_Y , XWDS_GPIO_PORT_Z
}
 XWDS GPIO Port 枚举 更多...
 
enum  xwds_gpio_pin_em {
  XWDS_GPIO_PIN_0 = (1U << ( 0 )) , XWDS_GPIO_PIN_1 = (1U << ( 1 )) , XWDS_GPIO_PIN_2 = (1U << ( 2 )) , XWDS_GPIO_PIN_3 = (1U << ( 3 )) ,
  XWDS_GPIO_PIN_4 = (1U << ( 4 )) , XWDS_GPIO_PIN_5 = (1U << ( 5 )) , XWDS_GPIO_PIN_6 = (1U << ( 6 )) , XWDS_GPIO_PIN_7 = (1U << ( 7 )) ,
  XWDS_GPIO_PIN_8 = (1U << ( 8 )) , XWDS_GPIO_PIN_9 = (1U << ( 9 )) , XWDS_GPIO_PIN_10 = (1U << ( 10 )) , XWDS_GPIO_PIN_11 = (1U << ( 11 )) ,
  XWDS_GPIO_PIN_12 = (1U << ( 12 )) , XWDS_GPIO_PIN_13 = (1U << ( 13 )) , XWDS_GPIO_PIN_14 = (1U << ( 14 )) , XWDS_GPIO_PIN_15 = (1U << ( 15 )) ,
  XWDS_GPIO_PIN_16 = (1U << ( 16 )) , XWDS_GPIO_PIN_17 = (1U << ( 17 )) , XWDS_GPIO_PIN_18 = (1U << ( 18 )) , XWDS_GPIO_PIN_19 = (1U << ( 19 )) ,
  XWDS_GPIO_PIN_20 = (1U << ( 20 )) , XWDS_GPIO_PIN_21 = (1U << ( 21 )) , XWDS_GPIO_PIN_22 = (1U << ( 22 )) , XWDS_GPIO_PIN_23 = (1U << ( 23 )) ,
  XWDS_GPIO_PIN_24 = (1U << ( 24 )) , XWDS_GPIO_PIN_25 = (1U << ( 25 )) , XWDS_GPIO_PIN_26 = (1U << ( 26 )) , XWDS_GPIO_PIN_27 = (1U << ( 27 )) ,
  XWDS_GPIO_PIN_28 = (1U << ( 28 )) , XWDS_GPIO_PIN_29 = (1U << ( 29 )) , XWDS_GPIO_PIN_30 = (1U << ( 30 )) , XWDS_GPIO_PIN_31 = (1U << ( 31 ))
}
 XWDS GPIO Pin 枚举 更多...
 

详细描述

宏定义说明

◆ __xwds_soc_eirq_tbl_qualifier

#define __xwds_soc_eirq_tbl_qualifier

在文件 chip.h36 行定义.

◆ __xwds_soc_dma_tbl_qualifier

#define __xwds_soc_dma_tbl_qualifier

在文件 chip.h42 行定义.

◆ XWDS_DMA_CH

#define XWDS_DMA_CH (   x)    ((xwid_t)(x))

XWDS DMA 通道

在文件 dma.h36 行定义.

◆ XWDS_EIRQ

#define XWDS_EIRQ (   x)    ((xwid_t)x)

XWDS External IRQ Number

在文件 eirq.h35 行定义.

◆ XWDS_GPIO_PIN

#define XWDS_GPIO_PIN (   n)    (1U << (n))

在文件 gpio.h32 行定义.

◆ XWDS_GPIO_PIN_MASK

#define XWDS_GPIO_PIN_MASK (   n)    (XWDS_GPIO_PIN(n) - 1U)

在文件 gpio.h33 行定义.

类型定义说明

◆ xwds_eirq_arg_t

typedef void* xwds_eirq_arg_t

外部中断函数参数

在文件 chip.h144 行定义.

◆ xwds_eirq_f

typedef void(* xwds_eirq_f) (struct xwds_soc *, xwid_t, xwds_eirq_arg_t)

外部中断函数

在文件 chip.h149 行定义.

◆ xwds_dma_cbarg_t

typedef void* xwds_dma_cbarg_t

DMA完成回调函数参数

在文件 chip.h154 行定义.

◆ xwds_dma_f

typedef void(* xwds_dma_f) (struct xwds_soc *, xwid_t, xwu32_t, xwds_dma_cbarg_t)

DMA完成回调函数类型

在文件 chip.h159 行定义.

枚举类型说明

◆ xwds_soc_ei_flag_em

外部中断标志

枚举值
XWDS_SOC_EIF_TM_RISING 

上升沿触发

XWDS_SOC_EIF_TM_FALLING 

下降沿触发

XWDS_SOC_EIF_TM_EITHER 

任意边沿触发

XWDS_SOC_EIF_TM_LOW 

低电平触发

XWDS_SOC_EIF_TM_HIGH 

高电平触发

XWDS_SOC_EIF_TM_MASK 
XWDS_SOC_EIF_WKUP 

唤醒

XWDS_SOC_EIF_DMA 

触发DMA

在文件 eirq.h40 行定义.

40 {
51};
@ XWDS_SOC_EIF_TM_EITHER
Definition eirq.h:43
@ XWDS_SOC_EIF_TM_LOW
Definition eirq.h:45
@ XWDS_SOC_EIF_TM_RISING
Definition eirq.h:41
@ XWDS_SOC_EIF_DMA
Definition eirq.h:50
@ XWDS_SOC_EIF_TM_FALLING
Definition eirq.h:42
@ XWDS_SOC_EIF_WKUP
Definition eirq.h:49
@ XWDS_SOC_EIF_TM_MASK
Definition eirq.h:47
@ XWDS_SOC_EIF_TM_HIGH
Definition eirq.h:46
#define XWBOP_BIT(n)
Definition xwbop.h:27

◆ xwds_gpio_port_em

XWDS GPIO Port 枚举

枚举值
XWDS_GPIO_PORT_A 

GPIO A

XWDS_GPIO_PORT_B 

GPIO B

XWDS_GPIO_PORT_C 

GPIO C

XWDS_GPIO_PORT_D 

GPIO D

XWDS_GPIO_PORT_E 

GPIO E

XWDS_GPIO_PORT_F 

GPIO F

XWDS_GPIO_PORT_G 

GPIO G

XWDS_GPIO_PORT_H 

GPIO H

XWDS_GPIO_PORT_I 

GPIO I

XWDS_GPIO_PORT_J 

GPIO J

XWDS_GPIO_PORT_K 

GPIO K

XWDS_GPIO_PORT_L 

GPIO L

XWDS_GPIO_PORT_M 

GPIO M

XWDS_GPIO_PORT_N 

GPIO N

XWDS_GPIO_PORT_O 

GPIO O

XWDS_GPIO_PORT_P 

GPIO P

XWDS_GPIO_PORT_Q 

GPIO Q

XWDS_GPIO_PORT_R 

GPIO R

XWDS_GPIO_PORT_S 

GPIO S

XWDS_GPIO_PORT_T 

GPIO T

XWDS_GPIO_PORT_U 

GPIO U

XWDS_GPIO_PORT_V 

GPIO V

XWDS_GPIO_PORT_W 

GPIO W

XWDS_GPIO_PORT_X 

GPIO X

XWDS_GPIO_PORT_Y 

GPIO Y

XWDS_GPIO_PORT_Z 

GPIO Z

在文件 gpio.h38 行定义.

38 {
65};
@ XWDS_GPIO_PORT_M
Definition gpio.h:51
@ XWDS_GPIO_PORT_X
Definition gpio.h:62
@ XWDS_GPIO_PORT_D
Definition gpio.h:42
@ XWDS_GPIO_PORT_N
Definition gpio.h:52
@ XWDS_GPIO_PORT_C
Definition gpio.h:41
@ XWDS_GPIO_PORT_Z
Definition gpio.h:64
@ XWDS_GPIO_PORT_H
Definition gpio.h:46
@ XWDS_GPIO_PORT_S
Definition gpio.h:57
@ XWDS_GPIO_PORT_F
Definition gpio.h:44
@ XWDS_GPIO_PORT_Y
Definition gpio.h:63
@ XWDS_GPIO_PORT_B
Definition gpio.h:40
@ XWDS_GPIO_PORT_U
Definition gpio.h:59
@ XWDS_GPIO_PORT_T
Definition gpio.h:58
@ XWDS_GPIO_PORT_W
Definition gpio.h:61
@ XWDS_GPIO_PORT_L
Definition gpio.h:50
@ XWDS_GPIO_PORT_E
Definition gpio.h:43
@ XWDS_GPIO_PORT_I
Definition gpio.h:47
@ XWDS_GPIO_PORT_Q
Definition gpio.h:55
@ XWDS_GPIO_PORT_P
Definition gpio.h:54
@ XWDS_GPIO_PORT_K
Definition gpio.h:49
@ XWDS_GPIO_PORT_R
Definition gpio.h:56
@ XWDS_GPIO_PORT_O
Definition gpio.h:53
@ XWDS_GPIO_PORT_J
Definition gpio.h:48
@ XWDS_GPIO_PORT_G
Definition gpio.h:45
@ XWDS_GPIO_PORT_V
Definition gpio.h:60
@ XWDS_GPIO_PORT_A
Definition gpio.h:39

◆ xwds_gpio_pin_em

XWDS GPIO Pin 枚举

枚举值
XWDS_GPIO_PIN_0 

Pin 0

XWDS_GPIO_PIN_1 

Pin 1

XWDS_GPIO_PIN_2 

Pin 2

XWDS_GPIO_PIN_3 

Pin 3

XWDS_GPIO_PIN_4 

Pin 4

XWDS_GPIO_PIN_5 

Pin 5

XWDS_GPIO_PIN_6 

Pin 6

XWDS_GPIO_PIN_7 

Pin 7

XWDS_GPIO_PIN_8 

Pin 8

XWDS_GPIO_PIN_9 

Pin 9

XWDS_GPIO_PIN_10 

Pin 10

XWDS_GPIO_PIN_11 

Pin 11

XWDS_GPIO_PIN_12 

Pin 12

XWDS_GPIO_PIN_13 

Pin 13

XWDS_GPIO_PIN_14 

Pin 14

XWDS_GPIO_PIN_15 

Pin 15

XWDS_GPIO_PIN_16 

Pin 16

XWDS_GPIO_PIN_17 

Pin 17

XWDS_GPIO_PIN_18 

Pin 18

XWDS_GPIO_PIN_19 

Pin 19

XWDS_GPIO_PIN_20 

Pin 20

XWDS_GPIO_PIN_21 

Pin 21

XWDS_GPIO_PIN_22 

Pin 22

XWDS_GPIO_PIN_23 

Pin 23

XWDS_GPIO_PIN_24 

Pin 24

XWDS_GPIO_PIN_25 

Pin 25

XWDS_GPIO_PIN_26 

Pin 26

XWDS_GPIO_PIN_27 

Pin 27

XWDS_GPIO_PIN_28 

Pin 28

XWDS_GPIO_PIN_29 

Pin 29

XWDS_GPIO_PIN_30 

Pin 30

XWDS_GPIO_PIN_31 

Pin 31

在文件 gpio.h70 行定义.

70 {
103};
#define XWDS_GPIO_PIN(n)
Definition gpio.h:32
@ XWDS_GPIO_PIN_12
Definition gpio.h:83
@ XWDS_GPIO_PIN_5
Definition gpio.h:76
@ XWDS_GPIO_PIN_26
Definition gpio.h:97
@ XWDS_GPIO_PIN_22
Definition gpio.h:93
@ XWDS_GPIO_PIN_9
Definition gpio.h:80
@ XWDS_GPIO_PIN_11
Definition gpio.h:82
@ XWDS_GPIO_PIN_16
Definition gpio.h:87
@ XWDS_GPIO_PIN_7
Definition gpio.h:78
@ XWDS_GPIO_PIN_10
Definition gpio.h:81
@ XWDS_GPIO_PIN_20
Definition gpio.h:91
@ XWDS_GPIO_PIN_3
Definition gpio.h:74
@ XWDS_GPIO_PIN_19
Definition gpio.h:90
@ XWDS_GPIO_PIN_4
Definition gpio.h:75
@ XWDS_GPIO_PIN_18
Definition gpio.h:89
@ XWDS_GPIO_PIN_1
Definition gpio.h:72
@ XWDS_GPIO_PIN_13
Definition gpio.h:84
@ XWDS_GPIO_PIN_30
Definition gpio.h:101
@ XWDS_GPIO_PIN_17
Definition gpio.h:88
@ XWDS_GPIO_PIN_15
Definition gpio.h:86
@ XWDS_GPIO_PIN_27
Definition gpio.h:98
@ XWDS_GPIO_PIN_2
Definition gpio.h:73
@ XWDS_GPIO_PIN_6
Definition gpio.h:77
@ XWDS_GPIO_PIN_29
Definition gpio.h:100
@ XWDS_GPIO_PIN_14
Definition gpio.h:85
@ XWDS_GPIO_PIN_28
Definition gpio.h:99
@ XWDS_GPIO_PIN_23
Definition gpio.h:94
@ XWDS_GPIO_PIN_24
Definition gpio.h:95
@ XWDS_GPIO_PIN_25
Definition gpio.h:96
@ XWDS_GPIO_PIN_31
Definition gpio.h:102
@ XWDS_GPIO_PIN_0
Definition gpio.h:71
@ XWDS_GPIO_PIN_8
Definition gpio.h:79
@ XWDS_GPIO_PIN_21
Definition gpio.h:92

函数说明

◆ xwds_soc_construct()

void xwds_soc_construct ( struct xwds_soc soc)

XWDS API:SOC构造函数

参数
[in]socSOC对象指针

在文件 chip.c58 行定义.

59{
61 soc->dev.vop = &xwds_soc_vop;
62}
void xwds_device_construct(struct xwds_device *dev)
XWDS API:设备的构造函数
Definition device.c:48
const struct xwds_virtual_operation xwds_soc_vop
Definition chip.c:45
const struct xwds_virtual_operation * vop
Definition device.h:138
struct xwds_device dev
Definition chip.h:168
函数调用图:

◆ xwds_soc_destruct()

void xwds_soc_destruct ( struct xwds_soc soc)

XWDS API:SOC对象的析构函数

参数
[in]socSOC对象指针

在文件 chip.c65 行定义.

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

◆ xwds_soc_grab()

xwer_t xwds_soc_grab ( struct xwds_soc soc)

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

参数
[in]socSOC对象指针

在文件 chip.c71 行定义.

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

◆ xwds_soc_put()

xwer_t xwds_soc_put ( struct xwds_soc soc)

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

参数
[in]socSOC对象指针

在文件 chip.c77 行定义.

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

◆ xwds_soc_get_reset_reason()

xwer_t xwds_soc_get_reset_reason ( struct xwds_soc soc,
xwu64_t reason 
)

XWDS API:获取复位原因

参数
[in]socSOC对象指针
[out]reason返回复位原因的缓冲区

在文件 chip.c83 行定义.

84{
85 const struct xwds_soc_driver * drv;
86 xwer_t rc;
87
88 XWDS_VALIDATE(soc, "nullptr", -EFAULT);
89 XWDS_VALIDATE(reason, "nullptr", -EFAULT);
90
91 rc = xwds_soc_grab(soc);
92 if (rc < 0) {
93 goto err_soc_grab;
94 }
95 drv = xwds_cast(const struct xwds_soc_driver *, soc->dev.drv);
96 if ((drv) && (drv->get_reset_reason)) {
97 rc = drv->get_reset_reason(soc, reason);
98 } else {
99 rc = -ENOSYS;
100 }
101 xwds_soc_put(soc);
102err_soc_grab:
103 return rc;
104}
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
signed long xwer_t
Definition type.h:554
const struct xwds_driver * drv
Definition device.h:133
BSP中需要提供的SOC设备驱动函数表
Definition chip.h:51
xwer_t(* get_reset_reason)(struct xwds_soc *, xwu64_t *)
Definition chip.h:53
函数调用图:

◆ xwds_soc_get_wkup_source()

xwer_t xwds_soc_get_wkup_source ( struct xwds_soc soc,
xwu64_t source 
)

XWDS API:获取唤醒源

参数
[in]socSOC对象指针
[out]source返回唤醒源的缓冲区

在文件 chip.c107 行定义.

108{
109 const struct xwds_soc_driver * drv;
110 xwer_t rc;
111
112 XWDS_VALIDATE(soc, "nullptr", -EFAULT);
113 XWDS_VALIDATE(source, "nullptr", -EFAULT);
114
115 rc = xwds_soc_grab(soc);
116 if (rc < 0) {
117 goto err_soc_grab;
118 }
119 drv = xwds_cast(const struct xwds_soc_driver *, soc->dev.drv);
120 if ((drv) && (drv->get_wkup_source)) {
121 rc = drv->get_wkup_source(soc, source);
122 } else {
123 rc = -ENOSYS;
124 }
125 xwds_soc_put(soc);
126err_soc_grab:
127 return rc;
128}
xwer_t(* get_wkup_source)(struct xwds_soc *, xwu64_t *)
Definition chip.h:55
函数调用图:

◆ xwds_clk_req()

xwer_t xwds_clk_req ( struct xwds_soc soc,
xwid_t  id 
)

XWDS API:申请时钟

参数
[in]socSOC对象指针
[in]id时钟ID
返回
错误码
返回值
XWOK没有错误
-ERANGE时钟ID错误
-ENOSYS不支持的API
注解
  • 上下文:中断、中断底半部、线程

<No error

在文件 clock.c26 行定义.

27{
28 const struct xwds_soc_driver * drv;
29 xwer_t rc;
30
31 XWDS_VALIDATE(soc, "nullptr", -EFAULT);
32 XWDS_VALIDATE((id < soc->clk.num), "out-of-range", -ERANGE);
33
34 rc = xwds_soc_grab(soc);
35 if (rc < 0) {
36 goto err_soc_grab;
37 }
38
39 drv = xwds_cast(const struct xwds_soc_driver *, soc->dev.drv);
40 if ((drv) && (drv->clk_req)) {
41 rc = drv->clk_req(soc, id);
42 } else {
43 rc = -ENOSYS;
44 }
45 if (rc < 0) {
46 goto err_drv_clk_req;
47 }
48 return XWOK;
49
50err_drv_clk_req:
51 xwds_soc_put(soc);
52err_soc_grab:
53 return rc;
54}
#define XWOK
No error
Definition errno.h:182
#define ERANGE
Result too large
Definition errno.h:64
函数调用图:

◆ xwds_pwr_req()

xwer_t xwds_pwr_req ( struct xwds_soc soc,
xwid_t  id 
)

XWDS API:申请电源

参数
[in]socSOC对象指针
[in]id电源ID
返回
错误码
返回值
XWOK没有错误
-ERANGE电源ID错误
-ENOSYS不支持的API
注解
  • 上下文:中断、中断底半部、线程

<No error

在文件 power.c26 行定义.

27{
28 const struct xwds_soc_driver * drv;
29 xwer_t rc;
30
31 XWDS_VALIDATE(soc, "nullptr", -EFAULT);
32 XWDS_VALIDATE((id < soc->pwr.num), "out-of-range", -ERANGE);
33
34 rc = xwds_soc_grab(soc);
35 if (rc < 0) {
36 goto err_soc_grab;
37 }
38
39 drv = xwds_cast(const struct xwds_soc_driver *, soc->dev.drv);
40 if ((drv) && (drv->pwr_req)) {
41 rc = drv->pwr_req(soc, id);
42 } else {
43 rc = -ENOSYS;
44 }
45 if (rc < 0) {
46 goto err_drv_pwr_req;
47 }
48 return XWOK;
49
50err_drv_pwr_req:
51 xwds_soc_put(soc);
52err_soc_grab:
53 return rc;
54}
函数调用图:

◆ xwds_clk_rls()

xwer_t xwds_clk_rls ( struct xwds_soc soc,
xwid_t  id 
)

XWDS API:释放时钟

参数
[in]socSOC对象指针
[in]id时钟ID
返回
错误码
返回值
XWOK没有错误
-ERANGE时钟ID错误
-ENOSYS不支持的API
注解
  • 上下文:中断、中断底半部、线程

<No error

在文件 clock.c57 行定义.

58{
59 const struct xwds_soc_driver * drv;
60 xwer_t rc;
61
62 XWDS_VALIDATE(soc, "nullptr", -EFAULT);
63 XWDS_VALIDATE((id < soc->clk.num), "out-of-range", -ERANGE);
64
65 drv = xwds_cast(struct xwds_soc_driver *, soc->dev.drv);
66 if ((drv) && (drv->clk_rls)) {
67 rc = drv->clk_rls(soc, id);
68 } else {
69 rc = -ENOSYS;
70 }
71 if (rc < 0) {
72 goto err_drv_clk_rls;
73 }
74
75 xwds_soc_put(soc);
76 return XWOK;
77
78err_drv_clk_rls:
79 return rc;
80}
函数调用图:

◆ xwds_clk_getfqcy()

xwer_t xwds_clk_getfqcy ( struct xwds_soc soc,
xwid_t  id,
xwu32_t buf,
xwsz_t num 
)

XWDS API:获取时钟频率

参数
[in]socSOC对象指针
[in]id时钟ID
[out]buf返回时钟频率的缓冲区的指针
[in,out]num指向缓冲区的指针,此缓冲区:
  • (I) 作为输入时,表示缓冲区数组的数量
  • (O) 作为输出时,返回实际的频率数据的数量
返回
错误码
返回值
XWOK没有错误
-EFAULT无效指针
-ERANGE时钟ID错误
-ENOSYS不支持的API
注解
  • 上下文:中断、中断底半部、线程

<No error

在文件 clock.c83 行定义.

85{
86 const struct xwds_soc_driver * drv;
87 xwer_t rc;
88
89 XWDS_VALIDATE(soc, "nullptr", -EFAULT);
90 XWDS_VALIDATE((id < soc->clk.num), "out-of-range", -ERANGE);
91 XWDS_VALIDATE(buf, "nullptr", -EFAULT);
92 XWDS_VALIDATE(num, "nullptr", -EFAULT);
93
94 rc = xwds_soc_grab(soc);
95 if (rc < 0) {
96 goto err_soc_grab;
97 }
98
99 drv = xwds_cast(struct xwds_soc_driver *, soc->dev.drv);
100 if ((drv) && (drv->clk_getfqcy)) {
101 rc = drv->clk_getfqcy(soc, id, buf, num);
102 } else {
103 rc = -ENOSYS;
104 }
105 if (rc < 0) {
106 goto err_drv_getfqcy;
107 }
108
109 xwds_soc_put(soc);
110 return XWOK;
111
112err_drv_getfqcy:
113 xwds_soc_put(soc);
114err_soc_grab:
115 return rc;
116}
函数调用图:

◆ xwds_dma_req()

xwer_t xwds_dma_req ( struct xwds_soc soc,
xwid_t  ch 
)

XWDS API:申请DMA的通道

参数
[in]socSOC对象指针
[in]chDMA通道
返回
错误码
返回值
XWOK没有错误
-EFAULT无效指针
-ERANGE无效的DMA通道
-EBUSYDMA通道繁忙
注解
  • 上下文:中断、中断底半部、线程

<No error

在文件 dma.c26 行定义.

27{
28 const struct xwds_soc_driver * drv;
29 xwer_t rc;
30
31 XWDS_VALIDATE(soc, "nullptr", -EFAULT);
32 XWDS_VALIDATE(((xwid_t)ch < soc->dma.ch_num), "out-of-range", -ERANGE);
33
34 rc = xwds_soc_grab(soc);
35 if (rc < 0) {
36 goto err_soc_grab;
37 }
38 drv = xwds_cast(const struct xwds_soc_driver *, soc->dev.drv);
39 if ((drv) && (drv->dma_req)) {
40 rc = drv->dma_req(soc, ch);
41 if (rc < 0) {
42 goto err_drv_dma_req;
43 }
44 }
45 return XWOK;
46
47err_drv_dma_req:
48 xwds_soc_put(soc);
49err_soc_grab:
50 return rc;
51}
unsigned long xwid_t
Definition type.h:481
函数调用图:

◆ xwds_dma_rls()

xwer_t xwds_dma_rls ( struct xwds_soc soc,
xwid_t  ch 
)

XWDS API:释放DMA的通道

参数
[in]socSOC对象指针
[in]chDMA通道
返回
错误码
返回值
XWOK没有错误
-EFAULT无效指针
-ERANGE无效的DMA通道
-EPERMDMA通道未被使用
注解
  • 上下文:中断、中断底半部、线程

<No error

在文件 dma.c54 行定义.

55{
56 const struct xwds_soc_driver * drv;
57 xwer_t rc;
58
59 XWDS_VALIDATE(soc, "nullptr", -EFAULT);
60 XWDS_VALIDATE(((xwid_t)ch < soc->dma.ch_num), "out-of-range", -ERANGE);
61
62 drv = xwds_cast(const struct xwds_soc_driver *, soc->dev.drv);
63 if ((drv) && (drv->dma_rls)) {
64 rc = drv->dma_rls(soc, ch);
65 if (rc < 0) {
66 goto err_drv_dma_rls;
67 }
68 }
69 xwds_soc_put(soc);
70 return XWOK;
71
72err_drv_dma_rls:
73 return rc;
74}
函数调用图:

◆ xwds_dma_cfg()

xwer_t xwds_dma_cfg ( struct xwds_soc soc,
xwid_t  ch,
void *  cfg,
xwds_dma_f  cb,
xwds_dma_cbarg_t  arg 
)

XWDS API:配置DMA的通道

参数
[in]socSOC对象指针
[in]chDMA通道
[in]cfgSOC DMA通道配置
[in]cb传输结束回调函数
[in]cfg回调函数参数
返回
错误码
返回值
XWOK没有错误
-EFAULT无效指针
-ERANGE无效的DMA通道
-EPERMDMA通道未被使用
注解
  • 上下文:中断、中断底半部、线程

<No error

在文件 dma.c77 行定义.

79{
80 const struct xwds_soc_driver * drv;
81 xwer_t rc;
82
83 XWDS_VALIDATE(soc, "nullptr", -EFAULT);
84 XWDS_VALIDATE(((xwid_t)ch < soc->dma.ch_num), "out-of-range", -ERANGE);
85
86#if defined(XWCDCFG_ds_SOC_DMA_ROCBT) && (1 == XWCDCFG_ds_SOC_DMA_ROCBT)
87 XWOS_UNUSED(cb);
88 XWOS_UNUSED(arg);
89#else
90 if (soc->dma.chcbs) {
91 soc->dma.chcbs[ch] = cb;
92 }
93 if (soc->dma.chcbargs) {
94 soc->dma.chcbargs[ch] = arg;
95 }
96#endif
97 drv = xwds_cast(const struct xwds_soc_driver *, soc->dev.drv);
98 if ((drv) && (drv->dma_cfg)) {
99 rc = drv->dma_cfg(soc, ch, cfg);
100 if (rc < 0) {
101 goto err_drv_dma_cfg;
102 }
103 }
104 return XWOK;
105
106err_drv_dma_cfg:
107#if !defined(XWCDCFG_ds_SOC_DMA_ROCBT) || (1 != XWCDCFG_ds_SOC_DMA_ROCBT)
108 if (soc->dma.chcbs) {
109 soc->dma.chcbs[ch] = NULL;
110 }
111 if (soc->dma.chcbargs) {
112 soc->dma.chcbargs[ch] = NULL;
113 }
114#endif
115 return rc;
116}
#define NULL
Definition type.h:28
#define XWOS_UNUSED(x)
Definition standard.h:66

◆ xwds_dma_enable()

xwer_t xwds_dma_enable ( struct xwds_soc soc,
xwid_t  ch 
)

XWDS API:打开DMA的通道

参数
[in]socSOC对象指针
[in]chDMA通道
返回
错误码
返回值
XWOK没有错误
-EFAULT无效指针
-ERANGE无效的DMA通道
-EPERMDMA通道未被使用
注解
  • 上下文:中断、中断底半部、线程

<No error

在文件 dma.c119 行定义.

120{
121 const struct xwds_soc_driver * drv;
122 xwer_t rc;
123
124 XWDS_VALIDATE(soc, "nullptr", -EFAULT);
125 XWDS_VALIDATE(((xwid_t)ch < soc->dma.ch_num), "out-of-range", -ERANGE);
126
127 drv = xwds_cast(const struct xwds_soc_driver *, soc->dev.drv);
128 if ((drv) && (drv->dma_enable)) {
129 rc = drv->dma_enable(soc, ch);
130 if (rc < 0) {
131 goto err_drv_dma_enable;
132 }
133 }
134 return XWOK;
135
136err_drv_dma_enable:
137 return rc;
138}

◆ xwds_dma_disable()

xwer_t xwds_dma_disable ( struct xwds_soc soc,
xwid_t  ch 
)

XWDS API:关闭DMA的通道

参数
[in]socSOC对象指针
[in]chDMA通道
返回
错误码
返回值
XWOK没有错误
-EFAULT无效指针
-ERANGE无效的DMA通道
-EPERMDMA通道未被使用
注解
  • 上下文:中断、中断底半部、线程

<No error

在文件 dma.c141 行定义.

142{
143 const struct xwds_soc_driver * drv;
144 xwer_t rc;
145
146 XWDS_VALIDATE(soc, "nullptr", -EFAULT);
147 XWDS_VALIDATE(((xwid_t)ch < soc->dma.ch_num), "out-of-range", -ERANGE);
148
149 drv = xwds_cast(const struct xwds_soc_driver *, soc->dev.drv);
150 if ((drv) && (drv->dma_disable)) {
151 rc = drv->dma_disable(soc, ch);
152 if (rc < 0) {
153 goto err_drv_dma_disable;
154 }
155 }
156 return XWOK;
157
158err_drv_dma_disable:
159 return rc;
160}

◆ xwds_dma_start()

xwer_t xwds_dma_start ( struct xwds_soc soc,
xwid_t  ch 
)

XWDS API:启动DMA的通道

参数
[in]socSOC对象指针
[in]chDMA通道
返回
错误码
返回值
XWOK没有错误
-EFAULT无效指针
-ERANGE无效的DMA通道
-EPERMDMA通道未被使用
注解
  • 上下文:中断、中断底半部、线程

<No error

在文件 dma.c163 行定义.

164{
165 const struct xwds_soc_driver * drv;
166 xwer_t rc;
167
168 XWDS_VALIDATE(soc, "nullptr", -EFAULT);
169 XWDS_VALIDATE(((xwid_t)ch < soc->dma.ch_num), "out-of-range", -ERANGE);
170
171 drv = xwds_cast(const struct xwds_soc_driver *, soc->dev.drv);
172 if ((drv) && (drv->dma_start)) {
173 rc = drv->dma_start(soc, ch);
174 if (rc < 0) {
175 goto err_drv_dma_start;
176 }
177 }
178 return XWOK;
179
180err_drv_dma_start:
181 return rc;
182}

◆ xwds_dma_stop()

xwer_t xwds_dma_stop ( struct xwds_soc soc,
xwid_t  ch 
)

XWDS API:停止DMA的通道

参数
[in]socSOC对象指针
[in]chDMA通道
返回
错误码
返回值
XWOK没有错误
-EFAULT无效指针
-ERANGE无效的DMA通道
-EPERMDMA通道未被使用
注解
  • 上下文:中断、中断底半部、线程

<No error

在文件 dma.c185 行定义.

186{
187 const struct xwds_soc_driver * drv;
188 xwer_t rc;
189
190 XWDS_VALIDATE(soc, "nullptr", -EFAULT);
191 XWDS_VALIDATE(((xwid_t)ch < soc->dma.ch_num), "out-of-range", -ERANGE);
192
193 drv = xwds_cast(const struct xwds_soc_driver *, soc->dev.drv);
194 if ((drv) && (drv->dma_stop)) {
195 rc = drv->dma_stop(soc, ch);
196 if (rc < 0) {
197 goto err_drv_dma_stop;
198 }
199 }
200 return XWOK;
201
202err_drv_dma_stop:
203 return rc;
204}

◆ 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:149
#define EBUSY
Device or resource busy
Definition errno.h:46
#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
xwer_t(* eirq_req)(struct xwds_soc *, xwid_t, xwsq_t, xwid_t, xwsq_t)
Definition chip.h:114
xwds_eirq_arg_t * isrargs
Definition chip.h:193
xwds_eirq_f * isrs
Definition chip.h:192
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:117
函数调用图:
这是这个函数的调用关系图:

◆ xwds_gpio_req()

xwer_t xwds_gpio_req ( struct xwds_soc soc,
xwid_t  port,
xwsq_t  pinmask 
)

XWDS API:申请SOC的GPIO

参数
[in]socSOC对象指针
[in]portGPIO端口,取值 xwds_gpio_port_em 中的一项
[in]pinmask引脚的掩码,取值 xwds_gpio_pin_em 中的任意项的或运算
返回
错误码
返回值
XWOK没有错误
-EFAULT无效指针
-ERANGEGPIO PORT错误
-EBUSYGPIO PIN已被使用
注解
  • 上下文:中断、中断底半部、线程

<No error

在文件 gpio.c27 行定义.

28{
29 const struct xwds_soc_driver * drv;
30 xwer_t rc;
31
32 XWDS_VALIDATE(soc, "nullptr", -EFAULT);
33 XWDS_VALIDATE((port < soc->gpio.port_num), "out-of-range", -ERANGE);
34
35 pinmask &= XWDS_GPIO_PIN_MASK(soc->gpio.pin_num);
36 rc = xwds_soc_grab(soc);
37 if (rc < 0) {
38 goto err_soc_grab;
39 }
40 rc = xwaop_t0ma_then_s1m(xwsq_t, &soc->gpio.pins[port], pinmask, NULL, NULL);
41 if (rc < 0) {
42 rc = -EBUSY;
43 goto err_set_pin;
44 }
45 drv = xwds_cast(const struct xwds_soc_driver *, soc->dev.drv);
46 if ((drv) && (drv->gpio_req)) {
47 rc = drv->gpio_req(soc, port, pinmask);
48 if (rc < 0) {
49 goto err_drv_gpio_req;
50 }
51 }
52 return XWOK;
53
54err_drv_gpio_req:
55 xwaop_c0m(xwsq_t, &soc->gpio.pins[port], pinmask, NULL, NULL);
56err_set_pin:
57 xwds_soc_put(soc);
58err_soc_grab:
59 return rc;
60}
#define XWDS_GPIO_PIN_MASK(n)
Definition gpio.h:33
unsigned long xwsq_t
Definition type.h:445
#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_soc *, xwid_t, xwsq_t)
Definition chip.h:80
struct xwds_soc::@23 gpio
xwsz_t pin_num
Definition chip.h:177
atomic_xwsq_t * pins
Definition chip.h:175
函数调用图:
这是这个函数的调用关系图:

◆ xwds_gpio_rls()

xwer_t xwds_gpio_rls ( struct xwds_soc soc,
xwid_t  port,
xwsq_t  pinmask 
)

XWDS API:释放SOC的GPIO

参数
[in]socSOC对象指针
[in]portGPIO端口,取值 xwds_gpio_port_em 中的一项
[in]pinmask引脚的掩码,取值 xwds_gpio_pin_em 中的任意项的或运算
返回
错误码
返回值
XWOK没有错误
-EFAULT无效指针
-ERANGEGPIO PORT错误
-EPERMGPIO PIN未被申请
注解
  • 上下文:中断、中断底半部、线程

<No error

在文件 gpio.c63 行定义.

64{
65 const struct xwds_soc_driver * drv;
66 xwsq_t pinsts;
67 xwer_t rc;
68
69 XWDS_VALIDATE(soc, "nullptr", -EFAULT);
70 XWDS_VALIDATE((port < soc->gpio.port_num), "out-of-range", -ERANGE);
71
72 pinmask &= XWDS_GPIO_PIN_MASK(soc->gpio.pin_num);
73 pinsts = xwaop_load(xwsq_t, &soc->gpio.pins[port], xwaop_mo_relaxed);
74 if (pinmask & (~pinsts)) {
75 rc = -EPERM;
76 goto err_pinsts;
77 }
78 drv = xwds_cast(const struct xwds_soc_driver *, soc->dev.drv);
79 if ((drv) && (drv->gpio_rls)) {
80 rc = drv->gpio_rls(soc, port, pinmask);
81 if (rc < 0) {
82 goto err_drv_gpio_rls;
83 }
84 }
85 xwaop_c0m(xwsq_t, &soc->gpio.pins[port], pinmask, NULL, NULL);
86
87 xwds_soc_put(soc);
88 return XWOK;
89
90err_drv_gpio_rls:
91err_pinsts:
92 return rc;
93}
@ xwaop_mo_relaxed
Definition type.h:628
#define xwaop_load(type, a, memorder)
对原子变量进行原子操作:加载
Definition xwaop.h:45
xwer_t(* gpio_rls)(struct xwds_soc *, xwid_t, xwid_t)
Definition chip.h:83
函数调用图:
这是这个函数的调用关系图:

◆ xwds_gpio_cfg()

xwer_t xwds_gpio_cfg ( struct xwds_soc soc,
xwid_t  port,
xwsq_t  pinmask,
void *  cfg 
)

XWDS API:配置SOC的GPIO

参数
[in]socSOC对象指针
[in]portGPIO端口,取值 xwds_gpio_port_em 中的一项
[in]pinmask引脚的掩码,取值 xwds_gpio_pin_em 中的任意项的或运算
[in]cfgGPIO配置,取值依据不同SOC
返回
错误码
返回值
XWOK没有错误
-EFAULT无效指针
-ERANGEGPIO PORT错误
-ENOSYS不支持的API
注解
  • 上下文:中断、中断底半部、线程

<No error

在文件 gpio.c96 行定义.

99{
100 const struct xwds_soc_driver * drv;
101 xwer_t rc;
102
103 XWDS_VALIDATE(soc, "nullptr", -EFAULT);
104 XWDS_VALIDATE((port < soc->gpio.port_num), "out-of-range", -ERANGE);
105 XWDS_VALIDATE(cfg, "nullptr", -EFAULT);
106
107 pinmask &= XWDS_GPIO_PIN_MASK(soc->gpio.pin_num);
108 rc = xwds_soc_grab(soc);
109 if (rc < 0) {
110 goto err_soc_grab;
111 }
112 drv = xwds_cast(const struct xwds_soc_driver *, soc->dev.drv);
113 if ((drv) && (drv->gpio_cfg)) {
114 rc = drv->gpio_cfg(soc, port, pinmask, cfg);
115 } else {
116 rc = -ENOSYS;
117 }
118 if (rc < 0) {
119 goto err_drv_gpio_cfg;
120 }
121 xwds_soc_put(soc);
122 return XWOK;
123
124err_drv_gpio_cfg:
125 xwds_soc_put(soc);
126err_soc_grab:
127 return rc;
128}
xwer_t(* gpio_cfg)(struct xwds_soc *, xwid_t, xwsq_t, void *)
Definition chip.h:86
函数调用图:

◆ xwds_gpio_set()

xwer_t xwds_gpio_set ( struct xwds_soc soc,
xwid_t  port,
xwsq_t  pinmask 
)

XWDS API:将SOC的GPIO设置为高电平

参数
[in]socSOC对象指针
[in]portGPIO端口,取值 xwds_gpio_port_em 中的一项
[in]pinmask引脚的掩码,取值 xwds_gpio_pin_em 中的任意项的或运算
返回
错误码
返回值
XWOK没有错误
-EFAULT无效指针
-ERANGEGPIO PORT错误
-EPERMGPIO PIN未被申请
-ENOSYS不支持的API
注解
  • 上下文:中断、中断底半部、线程

<No error

在文件 gpio.c131 行定义.

132{
133 const struct xwds_soc_driver * drv;
134 xwsq_t pinsts;
135 xwer_t rc;
136
137 XWDS_VALIDATE(soc, "nullptr", -EFAULT);
138 XWDS_VALIDATE((port < soc->gpio.port_num), "out-of-range", -ERANGE);
139
140 pinmask &= XWDS_GPIO_PIN_MASK(soc->gpio.pin_num);
141 rc = xwds_soc_grab(soc);
142 if (rc < 0) {
143 goto err_soc_grab;
144 }
145 pinsts = xwaop_load(xwsq_t, &soc->gpio.pins[port], xwaop_mo_relaxed);
146 if (pinmask & (~pinsts)) {
147 rc = -EPERM;
148 goto err_pinsts;
149 }
150 drv = xwds_cast(const struct xwds_soc_driver *, soc->dev.drv);
151 if ((drv) && (drv->gpio_set)) {
152 rc = drv->gpio_set(soc, port, pinmask);
153 } else {
154 rc = -ENOSYS;
155 }
156 if (rc < 0) {
157 goto err_drv_set;
158 }
159 xwds_soc_put(soc);
160 return XWOK;
161
162err_drv_set:
163err_pinsts:
164 xwds_soc_put(soc);
165err_soc_grab:
166 return rc;
167}
xwer_t(* gpio_set)(struct xwds_soc *, xwid_t, xwsq_t)
Definition chip.h:90
函数调用图:
这是这个函数的调用关系图:

◆ xwds_gpio_reset()

xwer_t xwds_gpio_reset ( struct xwds_soc soc,
xwid_t  port,
xwsq_t  pinmask 
)

XWDS API:将SOC的GPIO设置为低电平

参数
[in]socSOC对象指针
[in]portGPIO端口,取值 xwds_gpio_port_em 中的一项
[in]pinmask引脚的掩码,取值 xwds_gpio_pin_em 中的任意项的或运算
返回
错误码
返回值
XWOK没有错误
-EFAULT无效指针
-ERANGEGPIO PORT错误
-EPERMGPIO PIN未被申请
-ENOSYS不支持的API
注解
  • 上下文:中断、中断底半部、线程

<No error

在文件 gpio.c170 行定义.

171{
172 const struct xwds_soc_driver * drv;
173 xwsq_t pinsts;
174 xwer_t rc;
175
176 XWDS_VALIDATE(soc, "nullptr", -EFAULT);
177 XWDS_VALIDATE((port < soc->gpio.port_num), "out-of-range", -ERANGE);
178
179 pinmask &= XWDS_GPIO_PIN_MASK(soc->gpio.pin_num);
180 rc = xwds_soc_grab(soc);
181 if (rc < 0) {
182 goto err_soc_grab;
183 }
184 pinsts = xwaop_load(xwsq_t, &soc->gpio.pins[port], xwaop_mo_relaxed);
185 if (pinmask & (~pinsts)) {
186 rc = -EPERM;
187 goto err_pinsts;
188 }
189 drv = xwds_cast(const struct xwds_soc_driver *, soc->dev.drv);
190 if ((drv) && (drv->gpio_reset)) {
191 rc = drv->gpio_reset(soc, port, pinmask);
192 } else {
193 rc = -ENOSYS;
194 }
195 if (rc < 0) {
196 goto err_drv_reset;
197 }
198 xwds_soc_put(soc);
199 return XWOK;
200
201err_drv_reset:
202err_pinsts:
203 xwds_soc_put(soc);
204err_soc_grab:
205 return rc;
206}
xwer_t(* gpio_reset)(struct xwds_soc *, xwid_t, xwsq_t)
Definition chip.h:93
函数调用图:
这是这个函数的调用关系图:

◆ xwds_gpio_toggle()

xwer_t xwds_gpio_toggle ( struct xwds_soc soc,
xwid_t  port,
xwsq_t  pinmask 
)

XWDS API:翻转SOC的GPIO电平

参数
[in]socSOC对象指针
[in]portGPIO端口,取值 xwds_gpio_port_em 中的一项
[in]pinmask引脚的掩码,取值 xwds_gpio_pin_em 中的任意项的或运算
返回
错误码
返回值
XWOK没有错误
-EFAULT无效指针
-ERANGEGPIO PORT错误
-EPERMGPIO PIN未被申请
-ENOSYS不支持的API
注解
  • 上下文:中断、中断底半部、线程

<No error

在文件 gpio.c209 行定义.

210{
211 const struct xwds_soc_driver * drv;
212 xwsq_t pinsts;
213 xwer_t rc;
214
215 XWDS_VALIDATE(soc, "nullptr", -EFAULT);
216 XWDS_VALIDATE((port < soc->gpio.port_num), "out-of-range", -ERANGE);
217
218 pinmask &= XWDS_GPIO_PIN_MASK(soc->gpio.pin_num);
219 rc = xwds_soc_grab(soc);
220 if (rc < 0) {
221 goto err_soc_grab;
222 }
223 pinsts = xwaop_load(xwsq_t, &soc->gpio.pins[port], xwaop_mo_relaxed);
224 if (pinmask & (~pinsts)) {
225 rc = -EPERM;
226 goto err_pinsts;
227 }
228 drv = xwds_cast(const struct xwds_soc_driver *, soc->dev.drv);
229 if ((drv) && (drv->gpio_toggle)) {
230 rc = drv->gpio_toggle(soc, port, pinmask);
231 } else {
232 rc = -ENOSYS;
233 }
234 if (rc < 0) {
235 goto err_drv_toggle;
236 }
237 xwds_soc_put(soc);
238 return XWOK;
239
240err_drv_toggle:
241err_pinsts:
242 xwds_soc_put(soc);
243err_soc_grab:
244 return rc;
245}
xwer_t(* gpio_toggle)(struct xwds_soc *, xwid_t, xwsq_t)
Definition chip.h:96
函数调用图:

◆ xwds_gpio_output()

xwer_t xwds_gpio_output ( struct xwds_soc soc,
xwid_t  port,
xwsq_t  pinmask,
xwsq_t  out 
)

XWDS API:并行输出多个SOC的GPIO

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

<No error

在文件 gpio.c248 行定义.

251{
252 const struct xwds_soc_driver * drv;
253 xwsq_t pinsts;
254 xwer_t rc;
255
256 XWDS_VALIDATE(soc, "nullptr", -EFAULT);
257 XWDS_VALIDATE((port < soc->gpio.port_num), "out-of-range", -ERANGE);
258
259 pinmask &= XWDS_GPIO_PIN_MASK(soc->gpio.pin_num);
260 rc = xwds_soc_grab(soc);
261 if (rc < 0) {
262 goto err_soc_grab;
263 }
264 pinsts = xwaop_load(xwsq_t, &soc->gpio.pins[port], xwaop_mo_relaxed);
265 if (pinmask & (~pinsts)) {
266 rc = -EPERM;
267 goto err_pinsts;
268 }
269 drv = xwds_cast(const struct xwds_soc_driver *, soc->dev.drv);
270 if ((drv) && (drv->gpio_output)) {
271 rc = drv->gpio_output(soc, port, pinmask, out);
272 } else {
273 rc = -ENOSYS;
274 }
275 if (rc < 0) {
276 goto err_drv_out;
277 }
278 xwds_soc_put(soc);
279 return XWOK;
280
281err_drv_out:
282err_pinsts:
283 xwds_soc_put(soc);
284err_soc_grab:
285 return rc;
286}
xwer_t(* gpio_output)(struct xwds_soc *, xwid_t, xwsq_t, xwsq_t)
Definition chip.h:99
函数调用图:

◆ xwds_gpio_read_output()

xwer_t xwds_gpio_read_output ( struct xwds_soc soc,
xwid_t  port,
xwsq_t  pinmask,
xwsq_t outbuf 
)

XWDS API:读取GPIO的输出值

参数
[in]socSOC对象指针
[in]portGPIO端口,取值 xwds_gpio_port_em 中的一项
[in]pinmask引脚的掩码,取值 xwds_gpio_pin_em 中的任意项的或运算
[out]outbuf返回GPIO的输出值的缓冲区
返回
错误码
返回值
XWOK没有错误
-EFAULT无效指针
-ERANGEGPIO PORT错误
-EPERMGPIO PIN未被申请
-ENOSYS不支持的API
注解
  • 上下文:中断、中断底半部、线程

<No error

在文件 gpio.c289 行定义.

292{
293 const struct xwds_soc_driver * drv;
294 xwsq_t pinsts;
295 xwer_t rc;
296
297 XWDS_VALIDATE(soc, "nullptr", -EFAULT);
298 XWDS_VALIDATE((port < soc->gpio.port_num), "out-of-range", -ERANGE);
299
300 pinmask &= XWDS_GPIO_PIN_MASK(soc->gpio.pin_num);
301 rc = xwds_soc_grab(soc);
302 if (rc < 0) {
303 goto err_soc_grab;
304 }
305 pinsts = xwaop_load(xwsq_t, &soc->gpio.pins[port], xwaop_mo_relaxed);
306 if (pinmask & (~pinsts)) {
307 rc = -EPERM;
308 goto err_pinsts;
309 }
310 drv = xwds_cast(const struct xwds_soc_driver *, soc->dev.drv);
311 if ((drv) && (drv->gpio_read_output)) {
312 rc = drv->gpio_read_output(soc, port, pinmask, outbuf);
313 } else {
314 rc = -ENOSYS;
315 }
316 if (rc < 0) {
317 goto err_drv_in;
318 }
319 xwds_soc_put(soc);
320 return XWOK;
321
322err_drv_in:
323err_pinsts:
324 xwds_soc_put(soc);
325err_soc_grab:
326 return rc;
327}
xwer_t(* gpio_read_output)(struct xwds_soc *, xwid_t, xwsq_t, xwsq_t *)
Definition chip.h:103
函数调用图:

◆ xwds_gpio_input()

xwer_t xwds_gpio_input ( struct xwds_soc soc,
xwid_t  port,
xwsq_t  pinmask,
xwsq_t inbuf 
)

XWDS API:并行读取多个SOC的GPIO

参数
[in]socSOC对象指针
[in]portGPIO端口,取值 xwds_gpio_port_em 中的一项
[in]pinmask引脚的掩码,取值 xwds_gpio_pin_em 中的任意项的或运算
[out]inbuf返回GPIO的输入值的缓冲区
返回
错误码
返回值
XWOK没有错误
-EFAULT无效指针
-ERANGEGPIO PORT错误
-EPERMGPIO PIN未被申请
-ENOSYS不支持的API
注解
  • 上下文:中断、中断底半部、线程

<No error

在文件 gpio.c330 行定义.

333{
334 const struct xwds_soc_driver * drv;
335 xwsq_t pinsts;
336 xwer_t rc;
337
338 XWDS_VALIDATE(soc, "nullptr", -EFAULT);
339 XWDS_VALIDATE((port < soc->gpio.port_num), "out-of-range", -ERANGE);
340
341 pinmask &= XWDS_GPIO_PIN_MASK(soc->gpio.pin_num);
342 rc = xwds_soc_grab(soc);
343 if (rc < 0) {
344 goto err_soc_grab;
345 }
346 pinsts = xwaop_load(xwsq_t, &soc->gpio.pins[port], xwaop_mo_relaxed);
347 if (pinmask & (~pinsts)) {
348 rc = -EPERM;
349 goto err_pinsts;
350 }
351 drv = xwds_cast(const struct xwds_soc_driver *, soc->dev.drv);
352 if ((drv) && (drv->gpio_input)) {
353 rc = drv->gpio_input(soc, port, pinmask, inbuf);
354 } else {
355 rc = -ENOSYS;
356 }
357 if (rc < 0) {
358 goto err_drv_in;
359 }
360 xwds_soc_put(soc);
361 return XWOK;
362
363err_drv_in:
364err_pinsts:
365 xwds_soc_put(soc);
366err_soc_grab:
367 return rc;
368}
xwer_t(* gpio_input)(struct xwds_soc *, xwid_t, xwsq_t, xwsq_t *)
Definition chip.h:107
函数调用图:

◆ xwds_pwr_rls()

xwer_t xwds_pwr_rls ( struct xwds_soc soc,
xwid_t  id 
)

XWDS API:释放电源

参数
[in]socSOC对象指针
[in]id电源ID
返回
错误码
返回值
XWOK没有错误
-ERANGE电源ID错误
-ENOSYS不支持的API
注解
  • 上下文:中断、中断底半部、线程

<No error

在文件 power.c57 行定义.

58{
59 const struct xwds_soc_driver * drv;
60 xwer_t rc;
61
62 XWDS_VALIDATE(soc, "nullptr", -EFAULT);
63 XWDS_VALIDATE((id < soc->pwr.num), "out-of-range", -ERANGE);
64
65 drv = xwds_cast(const struct xwds_soc_driver *, soc->dev.drv);
66 if ((drv) && (drv->pwr_rls)) {
67 rc = drv->pwr_rls(soc, id);
68 } else {
69 rc = -ENOSYS;
70 }
71 if (rc < 0) {
72 goto err_drv_pwr_rls;
73 }
74
75 xwds_soc_put(soc);
76 return XWOK;
77
78err_drv_pwr_rls:
79 return rc;
80}
函数调用图:

◆ xwds_pwr_getvltg()

xwer_t xwds_pwr_getvltg ( struct xwds_soc soc,
xwid_t  id,
xwu32_t buf,
xwsz_t num 
)

XWDS API:获取电源电压

参数
[in]socSOC对象指针
[in]id电源ID
[out]buf返回电源电压的缓冲区的指针
[in,out]num指向缓冲区的指针,此缓冲区:
  • (I) 作为输入时,表示缓冲区数组的数量
  • (O) 作为输出时,返回实际的电压数据的数量
返回
错误码
返回值
XWOK没有错误
-EFAULT无效指针
-ERANGE电源ID错误
-ENOSYS不支持的API
注解
  • 上下文:中断、中断底半部、线程

<No error

在文件 power.c83 行定义.

85{
86 const struct xwds_soc_driver * drv;
87 xwer_t rc;
88
89 XWDS_VALIDATE(soc, "nullptr", -EFAULT);
90 XWDS_VALIDATE((id < soc->pwr.num), "out-of-range", -ERANGE);
91 XWDS_VALIDATE(buf, "nullptr", -EFAULT);
92 XWDS_VALIDATE(num, "nullptr", -EFAULT);
93
94 rc = xwds_soc_grab(soc);
95 if (rc < 0) {
96 goto err_soc_grab;
97 }
98
99 drv = xwds_cast(const struct xwds_soc_driver *, soc->dev.drv);
100 if ((drv) && (drv->pwr_getvltg)) {
101 rc = drv->pwr_getvltg(soc, id, buf, num);
102 } else {
103 rc = -ENOSYS;
104 }
105 if (rc < 0) {
106 goto err_drv_getvltg;
107 }
108
109 xwds_soc_put(soc);
110 return XWOK;
111
112err_drv_getvltg:
113 xwds_soc_put(soc);
114err_soc_grab:
115 return rc;
116}
函数调用图: