XWOS API  4.0
XWOS C/C++ API参考手册
载入中...
搜索中...
未找到
controller.h
浏览该文件的文档.
1
21#ifndef __xwcd_ds_can_controller_h__
22#define __xwcd_ds_can_controller_h__
23
24#include <xwcd/ds/standard.h>
25#include <xwos/lib/xwbop.h>
27#include <xwos/osal/sync/sem.h>
28#include <xwcd/ds/device.h>
31
43#if defined(XWCDCFG_ds_CAN_CONTROLLER_ROCBT) && (1 == XWCDCFG_ds_CAN_CONTROLLER_ROCBT)
44# define __xwds_canc_cbtbl_qualifier const
45#else
46# define __xwds_canc_cbtbl_qualifier
47#endif
48
49#define XWDS_CANC_RXQNUM (XWCDCFG_ds_CAN_CONTROLLER_RXQNUM)
50#define XWDS_CANC_SDU_MAXSIZE (XWCDCFG_ds_CAN_CONTROLLER_SDU_MAXSIZE)
51
58};
59
68};
69
76 struct {
84};
85
93};
94
101};
102
111};
112
117 const struct xwds_canc_bd_cfg * bdcfgs;
124 void * xwccfg;
125};
126
149};
150
166};
167
168struct xwds_canc;
169
175 xwer_t (* write)(struct xwds_canc *, const struct xwds_canc_txobj_cfg *,
176 struct xwds_can_msg *);
178 xwer_t (* set_bd)(struct xwds_canc *,
179 const struct xwds_canc_bd_cfg *);
182};
183
188 void (* tx_indication)(struct xwds_canc *, xwid_t,
189 xwer_t);
190 void (* rx_indication)(struct xwds_canc *, xwid_t,
191 struct xwds_can_msg *);
192 void (* wakeup_notification)(struct xwds_canc *);
193 void (* mode_indication)(struct xwds_canc *, xwsq_t);
194 void (* err_indication)(struct xwds_canc *, xwsq_t,
195 xwsq_t, xwsq_t);
196 void (* busoff_indication)(struct xwds_canc *);
197};
198
204 struct xwos_sem sem;
208};
209
213struct xwds_canc {
214 union { /* union中继承多个基类相当于C++中的virtual继承,
215 struct xwds_device只继承一次。 */
217#if (defined(XWCDCFG_ds_I2C_PERIPHERAL) && (1 == XWCDCFG_ds_I2C_PERIPHERAL))
219#endif
220#if (defined(XWCDCFG_ds_SPI_PERIPHERAL) && (1 == XWCDCFG_ds_SPI_PERIPHERAL))
222#endif
223 } bc;
225 /* attributes */
226 const struct xwds_canc_cfg * cfg;
230 /* private */
232};
233
238void xwds_canc_construct(struct xwds_canc * canc);
239
244void xwds_canc_destruct(struct xwds_canc * canc);
245
250xwer_t xwds_canc_grab(struct xwds_canc * canc);
251
256xwer_t xwds_canc_put(struct xwds_canc * canc);
257
272xwer_t xwds_canc_write(struct xwds_canc * canc, xwid_t txobjid,
273 struct xwds_can_msg * msg);
274
285
296
309xwer_t xwds_canc_set_mode(struct xwds_canc * canc, xwsq_t mode);
310
322xwer_t xwds_canc_set_bd(struct xwds_canc * canc, xwid_t bdcfgid);
323
332 void (*cb)(struct xwds_canc *,
333 xwid_t, xwer_t));
334
343 void (*cb)(struct xwds_canc *,
344 xwid_t,
345 struct xwds_can_msg *));
346
355 void (*cb)(struct xwds_canc *));
356
365 void (*cb)(struct xwds_canc *, xwsq_t));
366
375 void (*cb)(struct xwds_canc *,
376 xwsq_t, xwsq_t, xwsq_t));
377
386 void (*cb)(struct xwds_canc *));
387
388/******** ******** RX Queue ******** ********/
395void xwds_canc_rxq_init(struct xwds_canc_rxqueue * rxq);
396
405 struct xwds_can_msg * msg);
406
421 struct xwds_can_msg * buf,
422 xwtm_t to);
423
424/******** ******** Callbacks for driver ******** ********/
430void xwds_canc_drvcb_init_msg(struct xwds_can_msg * msg, xwu32_t canid,
431 xwsq_t flag, xwsz_t dlc, xwu8_t sdu[]);
432
442 xwid_t txobjid,
443 xwer_t rc);
444
456 xwid_t rxobjid,
457 struct xwds_can_msg * rxmsg);
458
466
475 xwsq_t mode);
476
487 xwsq_t errcode,
488 xwsq_t tec,
489 xwsq_t rec);
490
498
503#endif /* xwcd/ds/can/controller.h */
玄武设备栈:设备基类
#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
xwds_canc_mode_em
CAN控制器的模式
Definition controller.h:130
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
xwds_canc_hwobj_type_em
CAN对象(消息)类型
Definition controller.h:89
xwer_t xwds_canc_enable_irqs(struct xwds_canc *canc)
XWDS API:开启CAN控制器的中断
Definition controller.c:227
xwds_canc_err_em
CAN控制器的错误码
Definition controller.h:154
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
xwds_can_msgflag_em
CAN消息标志枚举
Definition controller.h:55
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_STOPPED
Definition controller.h:137
@ XWDS_CANC_MODE_MIN
Definition controller.h:131
@ XWDS_CANC_MODE_UNINIT
Definition controller.h:132
@ XWDS_CANC_MODE_NUM
Definition controller.h:148
@ XWDS_CANC_MODE_STARTED
Definition controller.h:140
@ XWDS_CANC_MODE_SLEEP
Definition controller.h:143
@ XWDS_CANC_HWOBJ_T_ID_EXT
Definition controller.h:91
@ XWDS_CANC_HWOBJ_T_ID_STD
Definition controller.h:90
@ XWDS_CANC_HWOBJ_T_ID_MIXED
Definition controller.h:92
@ CANC_ERR_CRC
Definition controller.h:160
@ CANC_ERR_STUFF
Definition controller.h:157
@ CANC_ERR_FORM
Definition controller.h:158
@ CANC_ERR_NOERR
Definition controller.h:155
@ CANC_ERR_B1
Definition controller.h:161
@ CANC_ERR_B0
Definition controller.h:162
@ CANC_ERR_ACK
Definition controller.h:159
@ CANC_ERR_ACKDELIMITER
Definition controller.h:163
@ CANC_ERR_WARNING
Definition controller.h:165
@ CANC_ERR_PASSIVE
Definition controller.h:164
@ CANC_ERR_BUS
Definition controller.h:156
@ XWDS_CAN_MSG_F_REMOTE
Definition controller.h:57
@ XWDS_CAN_MSG_F_EXID
Definition controller.h:56
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
uint32_t xwu32_t
Definition type.h:266
#define XWBOP_BIT(n)
Definition xwbop.h:27
玄武设备栈:I2C:外设
操作系统抽象层:自旋锁
玄武设备栈:SPI:外设
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
struct xwds_canc_bd_cfg::@14 time_seg
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
CAN控制器配置
Definition controller.h:116
const struct xwds_canc_bd_cfg * bdcfgs
Definition controller.h:117
const struct xwds_canc_txobj_cfg * txobjs
Definition controller.h:120
const struct xwds_canc_rxobj_cfg * rxobjs
Definition controller.h:122
xwsz_t bdcfgs_num
Definition controller.h:118
xwid_t default_bdid
Definition controller.h:119
xwsz_t rxobjs_num
Definition controller.h:123
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
struct xwds_driver base
Definition controller.h:174
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:106
xwsz_t soc_hwfilter_cfgs_num
Definition controller.h:110
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_spip spip
Definition controller.h:221
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
struct xwds_i2cp i2cp
Definition controller.h:218
union xwds_canc::@15 bc
设备(所有设备的基类)
Definition device.h:127
基本驱动函数表(所有设备驱动的基类)
Definition device.h:113
I2C外设
Definition peripheral.h:48
SPI外设控制器
Definition peripheral.h:47
XWOS API:信号量对象
Definition sem.h:95
XWOS API:自旋锁
Definition spinlock.h:73
操作系统抽象层:信号量
XWOS通用库:位操作
玄武设备栈:顶级头文件