XWOS API  4.0
XWOS C/C++ API参考手册
载入中...
搜索中...
未找到
driver.c
浏览该文件的文档.
1
21#include <xwos/standard.h>
22#include <xwos/osal/irq.h>
23#include <xwcd/ds/soc/gpio.h>
24#include <xwcd/ds/soc/eirq.h>
27
28static __xwbsp_code
30
32 .base = {
33 .name = "can.transceiver.xxx10xx",
35 .remove = NULL,
38#if defined(XWCDCFG_ds_PM) && (1 == XWCDCFG_ds_PM)
41#endif
42 },
46};
47
48static __xwbsp_code
50{
51 const struct xwds_cantrcv_cfg * cfg;
52 xwer_t rc;
53
54 cfg = xxx10xx->cantrcv.cfg;
56 rc = -EINVAL;
57 } else {
58 rc = XWOK;
59 }
60 return rc;
61}
62
63/******** ******** base driver ******** ********/
66{
67 struct xwds_cantrcv_xxx10xx * xxx10xx;
68 xwer_t rc;
69
70 xxx10xx = xwds_cast(struct xwds_cantrcv_xxx10xx *, dev);
72 if (rc < 0) {
73 goto err_chkdesc;
74 }
75 return XWOK;
76
77err_chkdesc:
78 return rc;
79}
80
83{
84 struct xwds_cantrcv_xxx10xx * xxx10xx;
85 const struct xwds_resource_gpio * gpiorsc;
86 xwer_t rc;
87
88 xxx10xx = xwds_cast(struct xwds_cantrcv_xxx10xx *, dev);
89 gpiorsc = xxx10xx->gpiorsc.stb;
90 if (NULL != gpiorsc) {
91 rc = xwds_gpio_req(gpiorsc->soc, gpiorsc->port, gpiorsc->pinmask);
92 if (rc < 0) {
93 goto err_gpio_req_stb;
94 }
95 }
96 gpiorsc = xxx10xx->gpiorsc.eirq;
97 if (NULL != gpiorsc) {
98 rc = xwds_gpio_req(gpiorsc->soc, gpiorsc->port, gpiorsc->pinmask);
99 if (rc < 0) {
100 goto err_gpio_req_eirq;
101 }
102 }
103 return XWOK;
104
105err_gpio_req_eirq:
106 gpiorsc = xxx10xx->gpiorsc.stb;
107 if (NULL != gpiorsc) {
108 xwds_gpio_rls(gpiorsc->soc, gpiorsc->port, gpiorsc->pinmask);
109 }
110err_gpio_req_stb:
111 return rc;
112}
113
116{
117 struct xwds_cantrcv_xxx10xx * xxx10xx;
118 const struct xwds_resource_gpio * gpiorsc;
119
120 xxx10xx = xwds_cast(struct xwds_cantrcv_xxx10xx *, dev);
121 gpiorsc = xxx10xx->gpiorsc.eirq;
122 if (NULL != gpiorsc) {
123 xwds_gpio_rls(gpiorsc->soc, gpiorsc->port, gpiorsc->pinmask);
124 }
125 gpiorsc = xxx10xx->gpiorsc.stb;
126 if (NULL != gpiorsc) {
127 xwds_gpio_rls(gpiorsc->soc, gpiorsc->port, gpiorsc->pinmask);
128 }
129 return XWOK;
130}
131
132#if defined(XWCDCFG_ds_PM) && (1 == XWCDCFG_ds_PM)
135{
136 struct xwds_cantrcv_xxx10xx * xxx10xx;
137 const struct xwds_resource_gpio * gpiorsc;
138
139 xxx10xx = xwds_cast(struct xwds_cantrcv_xxx10xx *, dev);
140 gpiorsc = xxx10xx->gpiorsc.stb;
141 if (NULL != gpiorsc) {
142 xwds_gpio_rls(gpiorsc->soc, gpiorsc->port, gpiorsc->pinmask);
143 }
144 return XWOK;
145}
146
149{
150 struct xwds_cantrcv_xxx10xx * xxx10xx;
151 const struct xwds_resource_gpio * gpiorsc;
152 xwer_t rc;
153
154 xxx10xx = xwds_cast(struct xwds_cantrcv_xxx10xx *, dev);
155 gpiorsc = xxx10xx->gpiorsc.stb;
156 if (NULL != gpiorsc) {
157 rc = xwds_gpio_req(gpiorsc->soc, gpiorsc->port, gpiorsc->pinmask);
158 if (rc < 0) {
159 goto err_gpio_req_stb;
160 }
161 }
162 return XWOK;
163
164err_gpio_req_stb:
165 return rc;
166}
167#endif
168
171 xwsq_t opmode)
172{
173 struct xwds_cantrcv_xxx10xx * xxx10xx;
174 const struct xwds_resource_gpio * gpiorsc;
175 xwer_t rc;
176
177 xxx10xx = xwds_cast(struct xwds_cantrcv_xxx10xx *, cantrcv);
178 gpiorsc = xxx10xx->gpiorsc.stb;
179 switch (opmode) {
181 rc = xwds_gpio_reset(gpiorsc->soc,
182 gpiorsc->port,
183 gpiorsc->pinmask);
184 if (XWOK == rc) {
186 }
187 break;
190 rc = xwds_gpio_set(gpiorsc->soc,
191 gpiorsc->port,
192 gpiorsc->pinmask);
193 break;
194 default:
195 rc = -ERANGE;
196 break;
197 }
198 return rc;
199}
200
203{
204 struct xwds_cantrcv_xxx10xx * xxx10xx;
205 const struct xwds_resource_gpio * gpiorsc;
206 xwsq_t eirq;
207 xwer_t rc;
208
209 xxx10xx = xwds_cast(struct xwds_cantrcv_xxx10xx *, cantrcv);
210 gpiorsc = xxx10xx->gpiorsc.eirq;
211 eirq = xxx10xx->eirq;
212 if (gpiorsc) {
213 rc = xwds_eirq_req(gpiorsc->soc,
214 gpiorsc->port, gpiorsc->pinmask,
217 } else {
218 rc = -EOPNOTSUPP;
219 }
220
221 return rc;
222}
223
226{
227 struct xwds_cantrcv_xxx10xx * xxx10xx;
228 const struct xwds_resource_gpio * gpiorsc;
229 xwsq_t eirq;
230 xwer_t rc;
231
232 xxx10xx = xwds_cast(struct xwds_cantrcv_xxx10xx *, cantrcv);
233 gpiorsc = xxx10xx->gpiorsc.eirq;
234 eirq = xxx10xx->eirq;
235 if (gpiorsc) {
236 rc = xwds_eirq_rls(gpiorsc->soc,
237 gpiorsc->port, gpiorsc->pinmask,
238 eirq);
239 } else {
240 rc = -EOPNOTSUPP;
241 }
242 return rc;
243}
244
247 xwds_eirq_arg_t arg)
248{
249 struct xwds_cantrcv_xxx10xx * xxx10xx;
250
251 XWOS_UNUSED(soc);
252 xxx10xx = arg;
253 if (eiid == xxx10xx->eirq) {
256 }
257}
xwer_t xwds_cantrcv_xxx10xx_drv_stop(struct xwds_device *dev)
XXX10XX基本驱动:停止设备
Definition driver.c:115
xwer_t xwds_cantrcv_xxx10xx_drv_disable_wkup(struct xwds_cantrcv *cantrcv)
XXX10XX CAN接收器驱动:关闭CAN接收器的唤醒
Definition driver.c:225
xwer_t xwds_cantrcv_xxx10xx_drv_enable_wkup(struct xwds_cantrcv *cantrcv)
XXX10XX CAN接收器驱动:开启CAN接收器的唤醒
Definition driver.c:202
xwer_t xwds_cantrcv_xxx10xx_drv_set_opmode(struct xwds_cantrcv *cantrcv, xwsq_t opmode)
XXX10XX CAN接收器驱动:设置CAN接收器的运行模式
Definition driver.c:170
xwer_t xwds_cantrcv_xxx10xx_drv_suspend(struct xwds_device *dev)
XXX10XX基本驱动:暂停设备
Definition driver.c:134
void xwds_cantrcv_xxx10xx_eirq_wkup(struct xwds_soc *soc, xwid_t eiid, xwds_eirq_arg_t arg)
XXX10XX中断函数
Definition driver.c:246
const struct xwds_cantrcv_driver xwds_cantrcv_xxx10xx_drv
XXX10XX的驱动集合
Definition driver.c:31
xwer_t xwds_cantrcv_xxx10xx_drv_start(struct xwds_device *dev)
XXX10XX基本驱动:启动设备
Definition driver.c:82
static xwer_t xwds_cantrcv_xxx10xx_check_desc(struct xwds_cantrcv_xxx10xx *xxx10xx)
Definition driver.c:49
xwer_t xwds_cantrcv_xxx10xx_drv_resume(struct xwds_device *dev)
XXX10XX基本驱动:继续设备
Definition driver.c:148
玄武设备栈:CAN收发器:通用型104x/105x系列收发器:驱动
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:外部中断
@ XWDS_SOC_EIF_TM_FALLING
Definition eirq.h:42
@ XWDS_SOC_EIF_WKUP
Definition eirq.h:49
void xwds_cantrcv_drvcb_wakeup_notification(struct xwds_cantrcv *cantrcv)
CAN接收器回调函数:CAN接收器的唤醒通知
@ XWDS_CANTRCV_OPMODE_NORMAL
Definition transceiver.h:41
@ XWDS_CANTRCV_OPMODE_STANDBY
Definition transceiver.h:43
@ XWDS_CANTRCV_OPMODE_NUM
Definition transceiver.h:44
@ XWDS_CANTRCV_OPMODE_SLEEP
Definition transceiver.h:42
@ XWDS_CANTRCV_WKUPRS_BY_PIN
Definition transceiver.h:55
@ XWDS_CANTRCV_WKUPRS_BY_BUS
Definition transceiver.h:52
void * xwds_eirq_arg_t
外部中断函数参数
Definition chip.h:138
#define xwds_cast(type, dev)
Definition standard.h:40
xwer_t xwds_cantrcv_xxx10xx_drv_probe(struct xwds_device *dev)
XXX10XX基本驱动:探测设备
Definition driver.c:65
#define __xwbsp_rodata
Definition compiler.h:251
#define __xwbsp_code
Definition compiler.h:231
#define EINVAL
Invalid argument
Definition errno.h:52
#define EOPNOTSUPP
Operation not supported on socket
Definition errno.h:115
#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
#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
操作系统抽象层:异常与中断
xwer_t xwds_gpio_reset(struct xwds_soc *soc, xwid_t port, xwsq_t pinmask)
XWDS API:将SOC的GPIO设置为低电平
Definition gpio.c:170
xwer_t xwds_gpio_rls(struct xwds_soc *soc, xwid_t port, xwsq_t pinmask)
XWDS API:释放SOC的GPIO
Definition gpio.c:63
xwer_t xwds_gpio_set(struct xwds_soc *soc, xwid_t port, xwsq_t pinmask)
XWDS API:将SOC的GPIO设置为高电平
Definition gpio.c:131
xwer_t xwds_gpio_req(struct xwds_soc *soc, xwid_t port, xwsq_t pinmask)
XWDS API:申请SOC的GPIO
Definition gpio.c:27
玄武设备栈:SOC:GPIO
CAN接收器配置
Definition transceiver.h:85
BSP中需要提供的CAN接收器驱动函数表
Definition transceiver.h:96
struct xwds_driver base
Definition transceiver.h:97
XXX10XX对象
Definition device.h:37
struct xwds_cantrcv_xxx10xx::@28 gpiorsc
const struct xwds_resource_gpio * stb
Definition device.h:40
struct xwds_cantrcv cantrcv
Definition device.h:38
const struct xwds_resource_gpio * eirq
Definition device.h:41
CAN接收器
const struct xwds_cantrcv_cfg * cfg
设备(所有设备的基类)
Definition device.h:127
const char * name
Definition device.h:115
设备栈GPIO资源
Definition standard.h:98
struct xwds_soc * soc
Definition standard.h:99
SOC设备
Definition chip.h:161
玄武设备栈:CAN:总线接收器
XWOS的标准头文件