XWOS API  4.0
XWOS C/C++ API参考手册
载入中...
搜索中...
未找到
controller.c
浏览该文件的文档.
1
21#include <xwcd/ds/standard.h>
22#include <string.h>
23#include <xwos/lib/xwlog.h>
24#include <xwos/lib/xwaop.h>
26#include <xwos/osal/sync/sem.h>
28
29static __xwds_vop
31
32static __xwds_vop
34
35static __xwds_vop
37
38static __xwds_vop
40
41#if defined(XWCDCFG_ds_PM) && (1 == XWCDCFG_ds_PM)
42static __xwds_vop
44
45static __xwds_vop
47#endif
48
50 .probe = (void *)xwds_canc_vop_probe,
52 .start = (void *)xwds_canc_vop_start,
53 .stop = (void *)xwds_canc_vop_stop,
54#if defined(XWCDCFG_ds_PM) && (1 == XWCDCFG_ds_PM)
55 .suspend = (void *)xwds_canc_vop_suspend,
57#endif
58};
59
60/******** ******** ******** constructor & destructor ******** ******** ********/
62void xwds_canc_construct(struct xwds_canc * canc)
63{
65 canc->bc.dev.vop = &xwds_canc_vop;
66}
67
69void xwds_canc_destruct(struct xwds_canc * canc)
70{
72}
73
76{
77 return xwds_device_grab(&canc->bc.dev);
78}
79
82{
83 return xwds_device_put(&canc->bc.dev);
84}
85
86/******** ******** base virtual operations ******** ********/
91static __xwds_vop
93{
94 xwer_t rc;
95
96 XWDS_VALIDATE(canc->cfg, "nullptr", -EFAULT);
97
99 rc = xwds_device_vop_probe(&canc->bc.dev);
100 return rc;
101}
102
107static __xwds_vop
109{
110 xwer_t rc;
111
112 rc = xwds_device_vop_remove(&canc->bc.dev);
113 return rc;
114}
115
120static __xwds_vop
122{
123 xwer_t rc;
124
125 rc = xwds_device_vop_start(&canc->bc.dev);
126 return rc;
127}
128
133static __xwds_vop
135{
136 xwer_t rc;
137
138 rc = xwds_device_vop_stop(&canc->bc.dev);
139 return rc;
140}
141
142#if defined(XWCDCFG_ds_PM) && (1 == XWCDCFG_ds_PM)
143/******** ******** pm ******** ********/
148static __xwds_vop
150{
151 xwer_t rc;
152
153 rc = xwds_device_vop_suspend(&canc->bc.dev);
154 return rc;
155}
156
161static __xwds_vop
163{
164 xwer_t rc;
165
166 rc = xwds_device_vop_resume(&canc->bc.dev);
167 return rc;
168}
169#endif
170
171/******** ******** ******** APIs ******** ******** ********/
173xwer_t xwds_canc_write(struct xwds_canc * canc, xwid_t txobjid,
174 struct xwds_can_msg * msg)
175{
176 const struct xwds_canc_txobj_cfg * txobjcfg;
177 const struct xwds_canc_driver * drv;
178 xwer_t rc;
179
180 XWDS_VALIDATE(canc, "nullptr", -EFAULT);
181 XWDS_VALIDATE(msg, "nullptr", -EFAULT);
182
183 rc = xwds_canc_grab(canc);
184 if (rc < 0) {
185 goto err_canc_grab;
186 }
187
188 if (txobjid >= canc->cfg->txobjs_num) {
189 rc = -ERANGE;
190 goto err_txobjid;
191 }
192
193 txobjcfg = &canc->cfg->txobjs[txobjid];
194 if (XWDS_CAN_MSG_F_EXID & msg->flag) {
195 if (!(XWDS_CANC_HWOBJ_T_ID_EXT & txobjcfg->type)) {
196 rc = -EBADSLT;
197 goto err_badtxobj;
198 }
199 } else {
200 if (!(XWDS_CANC_HWOBJ_T_ID_STD & txobjcfg->type)) {
201 rc = -EBADSLT;
202 goto err_badtxobj;
203 }
204 }
205 drv = xwds_cast(const struct xwds_canc_driver *, canc->bc.dev.drv);
206 if ((drv) && (drv->write)) {
207 rc = drv->write(canc, txobjcfg, msg);
208 } else {
209 rc = -ENOSYS;
210 }
211 if (rc < 0) {
212 goto err_drv_write;
213 }
214 xwds_canc_put(canc);
215
216 return XWOK;
217
218err_drv_write:
219err_badtxobj:
220err_txobjid:
221 xwds_canc_put(canc);
222err_canc_grab:
223 return rc;
224}
225
228{
229 const struct xwds_canc_driver * drv;
230 xwer_t rc;
231
232 XWDS_VALIDATE(canc, "nullptr", -EFAULT);
233
234 rc = xwds_canc_grab(canc);
235 if (rc < 0) {
236 goto err_canc_grab;
237 }
238 drv = xwds_cast(const struct xwds_canc_driver *, canc->bc.dev.drv);
239 if ((drv) && (drv->enable_irqs)) {
240 rc = drv->enable_irqs(canc);
241 } else {
242 rc = -ENOSYS;
243 }
244 if (rc < 0) {
245 goto err_canc_drv_enable_irqs;
246 }
247 xwds_canc_put(canc);
248 return XWOK;
249
250err_canc_drv_enable_irqs:
251 xwds_canc_put(canc);
252err_canc_grab:
253 return rc;
254}
255
258{
259 const struct xwds_canc_driver * drv;
260 xwer_t rc;
261
262 XWDS_VALIDATE(canc, "nullptr", -EFAULT);
263
264 rc = xwds_canc_grab(canc);
265 if (rc < 0) {
266 goto err_canc_grab;
267 }
268 drv = xwds_cast(const struct xwds_canc_driver *, canc->bc.dev.drv);
269 if ((drv) && (drv->disable_irqs)) {
270 rc = drv->disable_irqs(canc);
271 } else {
272 rc = -ENOSYS;
273 }
274 if (rc < 0) {
275 goto err_canc_drv_disable_irqs;
276 }
277 xwds_canc_put(canc);
278 return XWOK;
279
280err_canc_drv_disable_irqs:
281 xwds_canc_put(canc);
282err_canc_grab:
283 return rc;
284}
285
288{
289 const struct xwds_canc_driver * drv;
290 xwer_t rc;
291
292 XWDS_VALIDATE(canc, "nullptr", -EFAULT);
293 XWDS_VALIDATE((mode < XWDS_CANC_MODE_NUM), "out-of-range", -ERANGE);
294
295 rc = xwds_canc_grab(canc);
296 if (rc < 0) {
297 goto err_canc_grab;
298 }
299
300 if (canc->mode == mode) {
301 rc = -EALREADY;
302 goto err_same_mode;
303 }
304 drv = xwds_cast(const struct xwds_canc_driver *, canc->bc.dev.drv);
305 if ((drv) && (drv->set_mode)) {
306 rc = drv->set_mode(canc, mode);
307 } else {
308 rc = -ENOSYS;
309 }
310 if (rc < 0) {
311 goto err_drv_set_mode;
312 }
313 canc->mode = mode;
314
315 xwds_canc_put(canc);
317 return XWOK;
318
319err_drv_set_mode:
320err_same_mode:
321 xwds_canc_put(canc);
322err_canc_grab:
323 return rc;
324}
325
328{
329 xwer_t rc;
330 const struct xwds_canc_driver * drv;
331 const struct xwds_canc_bd_cfg * bdcfg;
332
333 XWDS_VALIDATE(canc, "nullptr", -EFAULT);
334
335 rc = xwds_canc_grab(canc);
336 if (rc < 0) {
337 goto err_canc_grab;
338 }
339 if (bdcfgid >= canc->cfg->bdcfgs_num) {
340 rc = -ERANGE;
341 goto err_nobd;
342 }
343 bdcfg = &canc->cfg->bdcfgs[bdcfgid];
344 drv = xwds_cast(const struct xwds_canc_driver *, canc->bc.dev.drv);
345 if ((drv) && (drv->set_bd)) {
346 rc = drv->set_bd(canc, bdcfg);
347 } else {
348 rc = -ENOSYS;
349 }
350 if (rc < 0) {
351 goto err_drv_set_bd;
352 }
353 xwds_canc_put(canc);
354 return XWOK;
355
356err_drv_set_bd:
357err_nobd:
358 xwds_canc_put(canc);
359err_canc_grab:
360 return rc;
361}
362
363/******** ******** RX Queue ******** ********/
366{
367 xwos_splk_init(&rxq->lock);
368 memset(rxq->q, 0, sizeof(rxq->q));
369 rxq->pos = 0;
370 rxq->num = 0;
372}
373
376 struct xwds_can_msg * msg)
377{
378 xwreg_t cpuirq;
379
380 xwos_splk_lock_cpuirqsv(&rxq->lock, &cpuirq);
381 memcpy(&rxq->q[rxq->num], msg, sizeof(struct xwds_can_msg));
382 rxq->num++;
383 if (rxq->num >= (xwssz_t)XWDS_CANC_RXQNUM) {
384 rxq->num = 0;
385 }
386 if (rxq->num == rxq->pos) {
387 /* Queue is overflow. Discard the oldest data */
388 rxq->pos++;
389 if (rxq->pos >= (xwssq_t)XWDS_CANC_RXQNUM) {
390 rxq->pos = 0;
391 }
392 xwos_splk_unlock_cpuirqrs(&rxq->lock, cpuirq);
393 } else {
394 xwos_splk_unlock_cpuirqrs(&rxq->lock, cpuirq);
395 xwos_sem_post(&rxq->sem);
396 }
397}
398
401 struct xwds_can_msg * buf,
402 xwtm_t to)
403{
404 xwer_t rc;
405 xwreg_t cpuirq;
406
407 XWDS_VALIDATE(rxq, "nullptr", -EFAULT);
408 XWDS_VALIDATE(buf, "nullptr", -EFAULT);
409
410 rc = xwos_sem_wait_to(&rxq->sem, to);
411 if (rc < 0) {
412 goto err_sem_wait_to;
413 }
414 xwos_splk_lock_cpuirqsv(&rxq->lock, &cpuirq);
415 *buf = rxq->q[rxq->pos];
416 rxq->pos++;
417 if (rxq->pos >= (xwssq_t)XWDS_CANC_RXQNUM) {
418 rxq->pos = 0;
419 }
420 xwos_splk_unlock_cpuirqrs(&rxq->lock, cpuirq);
421 return XWOK;
422
423err_sem_wait_to:
424 return rc;
425}
426
427/******** ******** Callbacks for driver ******** ********/
430 void (*cb)(struct xwds_canc *,
431 xwid_t, xwer_t))
432{
433#if !defined(XWCDCFG_ds_CAN_CONTROLLER_ROCBT) || (1 != XWCDCFG_ds_CAN_CONTROLLER_ROCBT)
434 if (canc->cbtbl) {
435 canc->cbtbl->tx_indication = cb;
436 }
437#else
438 XWOS_UNUSED(canc);
439 XWOS_UNUSED(cb);
440#endif
441}
442
445 void (*cb)(struct xwds_canc *,
446 xwid_t,
447 struct xwds_can_msg *))
448{
449#if !defined(XWCDCFG_ds_CAN_CONTROLLER_ROCBT) || (1 != XWCDCFG_ds_CAN_CONTROLLER_ROCBT)
450 if (canc->cbtbl) {
451 canc->cbtbl->rx_indication = cb;
452 }
453#else
454 XWOS_UNUSED(canc);
455 XWOS_UNUSED(cb);
456#endif
457}
458
461 void (*cb)(struct xwds_canc *))
462{
463#if !defined(XWCDCFG_ds_CAN_CONTROLLER_ROCBT) || (1 != XWCDCFG_ds_CAN_CONTROLLER_ROCBT)
464 if (canc->cbtbl) {
465 canc->cbtbl->wakeup_notification = cb;
466 }
467#else
468 XWOS_UNUSED(canc);
469 XWOS_UNUSED(cb);
470#endif
471}
472
475 void (*cb)(struct xwds_canc *, xwsq_t))
476{
477#if !defined(XWCDCFG_ds_CAN_CONTROLLER_ROCBT) || (1 != XWCDCFG_ds_CAN_CONTROLLER_ROCBT)
478 if (canc->cbtbl) {
479 canc->cbtbl->mode_indication = cb;
480 }
481#else
482 XWOS_UNUSED(canc);
483 XWOS_UNUSED(cb);
484#endif
485}
486
489 void (*cb)(struct xwds_canc *,
491{
492#if !defined(XWCDCFG_ds_CAN_CONTROLLER_ROCBT) || (1 != XWCDCFG_ds_CAN_CONTROLLER_ROCBT)
493 if (canc->cbtbl) {
494 canc->cbtbl->err_indication = cb;
495 }
496#else
497 XWOS_UNUSED(canc);
498 XWOS_UNUSED(cb);
499#endif
500}
501
504 void (*cb)(struct xwds_canc *))
505{
506#if !defined(XWCDCFG_ds_CAN_CONTROLLER_ROCBT) || (1 != XWCDCFG_ds_CAN_CONTROLLER_ROCBT)
507 if (canc->cbtbl) {
508 canc->cbtbl->busoff_indication = cb;
509 }
510#else
511 XWOS_UNUSED(canc);
512 XWOS_UNUSED(cb);
513#endif
514}
515
518 xwsq_t flag, xwsz_t dlc, xwu8_t sdu[])
519{
520 msg->id = canid;
521 msg->flag = flag;
522 msg->dlc = dlc;
523 if (sdu) {
524 memcpy(msg->sdu, sdu, dlc);
525 } else {
526 memset(msg->sdu, 0, XWDS_CANC_SDU_MAXSIZE);
527 }
528}
529
532 xwer_t rc)
533{
535
536 cbtbl = canc->cbtbl;
537 if ((cbtbl) && (cbtbl->tx_indication)) {
538 cbtbl->tx_indication(canc, txobjid, rc);
539 }
540}
541
544 struct xwds_can_msg * rxmsg)
545{
547
548 cbtbl = canc->cbtbl;
549 if ((cbtbl) && (cbtbl->rx_indication)) {
550 cbtbl->rx_indication(canc, rxobjid, rxmsg);
551 }
552}
553
556{
558
559 cbtbl = canc->cbtbl;
560 if ((cbtbl) && (cbtbl->wakeup_notification)) {
561 cbtbl->wakeup_notification(canc);
562 }
563}
564
567{
569
570 cbtbl = canc->cbtbl;
571 if ((cbtbl) && (cbtbl->mode_indication)) {
572 cbtbl->mode_indication(canc, mode);
573 }
574}
575
578 xwsq_t tec, xwsq_t rec)
579{
581
582 cbtbl = canc->cbtbl;
583 if ((cbtbl) && (cbtbl->err_indication)) {
584 cbtbl->err_indication(canc, errcode, tec, rec);
585 }
586}
587
590{
592
593 cbtbl = canc->cbtbl;
594 if ((cbtbl) && (cbtbl->busoff_indication)) {
595 cbtbl->busoff_indication(canc);
596 }
597}
static xwer_t xwds_canc_vop_remove(struct xwds_canc *canc)
XWDS VOP:移除CAN控制器
Definition controller.c:108
const struct xwds_virtual_operation xwds_canc_vop
Definition controller.c:49
static xwer_t xwds_canc_vop_start(struct xwds_canc *canc)
XWDS VOP:启动CAN控制器
Definition controller.c:121
static xwer_t xwds_canc_vop_suspend(struct xwds_canc *canc)
XWDS VOP:暂停CAN控制器
Definition controller.c:149
static xwer_t xwds_canc_vop_probe(struct xwds_canc *canc)
XWDS VOP:探测CAN控制器
Definition controller.c:92
static xwer_t xwds_canc_vop_resume(struct xwds_canc *canc)
XWDS VOP:继续CAN控制器
Definition controller.c:162
static xwer_t xwds_canc_vop_stop(struct xwds_canc *canc)
XWDS VOP:停止CAN控制器
Definition controller.c:134
玄武设备栈:CAN:总线控制器
#define XWDS_CANC_SDU_MAXSIZE
Definition controller.h:50
xwer_t xwds_canc_put(struct xwds_canc *canc)
XWDS API:减少对象的引用计数
Definition controller.c:81
xwer_t xwds_canc_grab(struct xwds_canc *canc)
XWDS API:增加对象的引用计数
Definition controller.c:75
void xwds_canc_drvcb_tx_indication(struct xwds_canc *canc, xwid_t txobjid, xwer_t rc)
XWDS Driver Callback:指示发送结果
Definition controller.c:531
void xwds_canc_destruct(struct xwds_canc *canc)
XWDS API:CAN控制器对象的析构函数
Definition controller.c:69
void xwds_canc_drvcb_mode_indication(struct xwds_canc *canc, xwsq_t mode)
XWDS Driver Callback:指示CAN控制器的模式已经切换
Definition controller.c:566
xwer_t xwds_canc_disable_irqs(struct xwds_canc *canc)
XWDS API:关闭CAN控制器的中断
Definition controller.c:257
#define __xwds_canc_cbtbl_qualifier
Definition controller.h:46
void xwds_canc_drvcb_busoff_indication(struct xwds_canc *canc)
XWDS Driver Callback:指示CAN控制器发生busoff
Definition controller.c:589
xwer_t xwds_canc_set_mode(struct xwds_canc *canc, xwsq_t mode)
XWDS API:设置CAN控制器的模式
Definition controller.c:287
void xwds_canc_drvcb_rx_indication(struct xwds_canc *canc, xwid_t rxobjid, struct xwds_can_msg *rxmsg)
XWDS Driver Callback:接收到CAN消息后的回调函数
Definition controller.c:543
void xwds_canc_rxq_publish(struct xwds_canc_rxqueue *rxq, struct xwds_can_msg *msg)
XWDS API:发布一条消息到接收缓冲队列中
Definition controller.c:375
xwer_t xwds_canc_write(struct xwds_canc *canc, xwid_t txobjid, struct xwds_can_msg *msg)
XWDS API:将一条CAN消息写入发送邮箱
Definition controller.c:173
void xwds_canc_drvcb_err_indication(struct xwds_canc *canc, xwsq_t errcode, xwsq_t tec, xwsq_t rec)
XWDS Driver Callback:指示CAN控制器发生错误
Definition controller.c:577
void xwds_canc_setcb_wakeup_notification(struct xwds_canc *canc, void(*cb)(struct xwds_canc *))
XWDS API:设置 唤醒通知 回调函数
Definition controller.c:460
void xwds_canc_setcb_err_indication(struct xwds_canc *canc, void(*cb)(struct xwds_canc *, xwsq_t, xwsq_t, xwsq_t))
XWDS API:设置 错误通知 回调函数
Definition controller.c:488
#define XWDS_CANC_RXQNUM
Definition controller.h:49
void xwds_canc_setcb_tx_indication(struct xwds_canc *canc, void(*cb)(struct xwds_canc *, xwid_t, xwer_t))
XWDS API:设置 指示发送结果 的回调函数
Definition controller.c:429
void xwds_canc_setcb_mode_indication(struct xwds_canc *canc, void(*cb)(struct xwds_canc *, xwsq_t))
XWDS API:设置 模式切换通知 回调函数
Definition controller.c:474
void xwds_canc_construct(struct xwds_canc *canc)
XWDS API:CAN控制器的构造函数
Definition controller.c:62
void xwds_canc_setcb_busoff_indication(struct xwds_canc *canc, void(*cb)(struct xwds_canc *))
XWDS API:设置 BUSOFF通知 回调函数
Definition controller.c:503
xwer_t xwds_canc_enable_irqs(struct xwds_canc *canc)
XWDS API:开启CAN控制器的中断
Definition controller.c:227
void xwds_canc_drvcb_wakeup_notification(struct xwds_canc *canc)
XWDS Driver Callback:CAN控制器的唤醒通知
Definition controller.c:555
void xwds_canc_drvcb_init_msg(struct xwds_can_msg *msg, xwu32_t canid, xwsq_t flag, xwsz_t dlc, xwu8_t sdu[])
XWDS Driver Callback:初始化CAN总线消息结构体
Definition controller.c:517
xwer_t xwds_canc_set_bd(struct xwds_canc *canc, xwid_t bdcfgid)
XWDS API:设置CAN控制器的波特率
Definition controller.c:327
void xwds_canc_rxq_init(struct xwds_canc_rxqueue *rxq)
XWDS API:初始化接收缓冲队列
Definition controller.c:365
xwer_t xwds_canc_rxq_acquire(struct xwds_canc_rxqueue *rxq, struct xwds_can_msg *buf, xwtm_t to)
XWDS API:从接收缓冲队列中获取一条消息
Definition controller.c:400
void xwds_canc_setcb_rx_indication(struct xwds_canc *canc, void(*cb)(struct xwds_canc *, xwid_t, struct xwds_can_msg *))
XWDS API:设置 指示接收结果 的回调函数
Definition controller.c:444
@ XWDS_CANC_MODE_UNINIT
Definition controller.h:132
@ XWDS_CANC_MODE_NUM
Definition controller.h:148
@ XWDS_CANC_HWOBJ_T_ID_EXT
Definition controller.h:91
@ XWDS_CANC_HWOBJ_T_ID_STD
Definition controller.h:90
@ XWDS_CAN_MSG_F_EXID
Definition controller.h:56
static xwer_t xwds_device_grab(struct xwds_device *dev)
XWDS API:增加对象的引用计数
Definition device.h:268
xwer_t xwds_device_vop_start(struct xwds_device *dev)
设备基本操作函数:启动设备
Definition device.c:105
void xwds_device_construct(struct xwds_device *dev)
XWDS API:设备的构造函数
Definition device.c:48
void xwds_device_destruct(struct xwds_device *dev)
XWDS API:设备的析构函数
Definition device.c:56
static xwer_t xwds_device_put(struct xwds_device *dev)
XWDS API:减少对象的引用计数
Definition device.h:281
xwer_t xwds_device_vop_stop(struct xwds_device *dev)
设备基本操作函数:停止设备
Definition device.c:124
xwer_t xwds_device_vop_remove(struct xwds_device *dev)
设备基本操作函数:删除设备
Definition device.c:86
xwer_t xwds_device_vop_resume(struct xwds_device *dev)
设备基本操作函数:继续设备
Definition device.c:163
xwer_t xwds_device_vop_probe(struct xwds_device *dev)
设备基本操作函数:探测设备
Definition device.c:67
xwer_t xwds_device_vop_suspend(struct xwds_device *dev)
设备基本操作函数:暂停设备
Definition device.c:144
#define xwds_cast(type, dev)
Definition standard.h:40
#define __xwds_vop
Definition standard.h:36
#define __xwds_code
Definition standard.h:31
#define __xwds_api
Definition standard.h:33
#define XWDS_VALIDATE(exp, errstr,...)
Definition standard.h:51
#define __xwds_rodata
Definition standard.h:38
#define EFAULT
Bad address
Definition errno.h:44
#define ENOSYS
Function not implemented
Definition errno.h:110
#define EBADSLT
Invalid slot
Definition errno.h:82
#define XWOK
No error
Definition errno.h:182
#define ERANGE
Result too large
Definition errno.h:64
#define EALREADY
Socket already connected
Definition errno.h:133
xws64_t xwtm_t
XWOS系统时间 (有符号)
Definition type.h:742
signed long xwer_t
Definition type.h:554
unsigned long xwid_t
Definition type.h:481
unsigned long xwsz_t
Definition type.h:339
uint8_t xwu8_t
Definition type.h:194
unsigned long xwsq_t
Definition type.h:445
signed long xwssq_t
Definition type.h:461
signed long xwssz_t
Definition type.h:355
xwptr_t xwreg_t
Definition type.h:409
uint32_t xwu32_t
Definition type.h:266
static void xwos_splk_unlock_cpuirqrs(struct xwos_splk *spl, xwreg_t cpuirq)
XWOS API:解锁自旋锁,并恢复本地CPU的中断标志
Definition spinlock.h:224
static void xwos_splk_init(struct xwos_splk *spl)
XWOS API:初始化自旋锁
Definition spinlock.h:89
static void xwos_splk_lock_cpuirqsv(struct xwos_splk *spl, xwreg_t *cpuirq)
XWOS API:上锁自旋锁,保存本地CPU的中断标志并关闭
Definition spinlock.h:192
#define XWOS_UNUSED(x)
Definition standard.h:66
static xwer_t xwos_sem_wait_to(struct xwos_sem *sem, xwtm_t to)
XWOS API:限时等待并获取信号量
Definition sem.h:418
static xwer_t xwos_sem_init(struct xwos_sem *sem, xwssq_t val, xwssq_t max)
XWOS API:静态方式初始化信号量对象
Definition sem.h:125
static xwer_t xwos_sem_post(struct xwos_sem *sem)
XWOS API:发布信号量
Definition sem.h:373
操作系统抽象层:自旋锁
CAN消息
Definition controller.h:63
xwsq_t flag
Definition controller.h:65
xwu32_t id
Definition controller.h:64
xwu8_t sdu[(8U)]
Definition controller.h:67
CAN总线控制器波特率配置
Definition controller.h:73
CAN控制器应用层回调函数表
Definition controller.h:187
void(* rx_indication)(struct xwds_canc *, xwid_t, struct xwds_can_msg *)
Definition controller.h:190
void(* wakeup_notification)(struct xwds_canc *)
Definition controller.h:192
void(* busoff_indication)(struct xwds_canc *)
Definition controller.h:196
void(* err_indication)(struct xwds_canc *, xwsq_t, xwsq_t, xwsq_t)
Definition controller.h:194
void(* tx_indication)(struct xwds_canc *, xwid_t, xwer_t)
Definition controller.h:188
void(* mode_indication)(struct xwds_canc *, xwsq_t)
Definition controller.h:193
const struct xwds_canc_bd_cfg * bdcfgs
Definition controller.h:117
const struct xwds_canc_txobj_cfg * txobjs
Definition controller.h:120
xwsz_t bdcfgs_num
Definition controller.h:118
xwsz_t txobjs_num
Definition controller.h:121
BSP中需要提供的CAN控制器驱动函数表
Definition controller.h:173
xwer_t(* disable_irqs)(struct xwds_canc *)
Definition controller.h:181
xwer_t(* set_mode)(struct xwds_canc *, xwsq_t)
Definition controller.h:177
xwer_t(* write)(struct xwds_canc *, const struct xwds_canc_txobj_cfg *, struct xwds_can_msg *)
Definition controller.h:175
xwer_t(* set_bd)(struct xwds_canc *, const struct xwds_canc_bd_cfg *)
Definition controller.h:178
xwer_t(* enable_irqs)(struct xwds_canc *)
Definition controller.h:180
CAN控制器接收队列
Definition controller.h:202
struct xwos_sem sem
Definition controller.h:204
struct xwds_can_msg q[(8U)]
Definition controller.h:203
struct xwos_splk lock
Definition controller.h:205
CAN发送对象(消息)配置
Definition controller.h:98
CAN控制器
Definition controller.h:213
xwsq_t mode
Definition controller.h:231
struct xwds_device dev
Definition controller.h:216
struct xwds_canc_cbtbl * cbtbl
Definition controller.h:227
const struct xwds_canc_cfg * cfg
Definition controller.h:226
union xwds_canc::@15 bc
const struct xwds_driver * drv
Definition device.h:133
const struct xwds_virtual_operation * vop
Definition device.h:138
基本操作的虚函数表(类似C++的虚函数表)
Definition device.h:99
xwer_t(* stop)(struct xwds_device *)
Definition device.h:103
xwer_t(* remove)(struct xwds_device *)
Definition device.h:101
xwer_t(* probe)(struct xwds_device *)
Definition device.h:100
xwer_t(* resume)(struct xwds_device *)
Definition device.h:106
操作系统抽象层:信号量
XWOS通用库:原子操作
玄武设备栈:顶级头文件
XWOS通用库:日志