dev_can.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543
  1. /*
  2. * Copyright (c) 2006-2024 RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2015-05-14 aubrcool@qq.com first version
  9. * 2015-07-06 Bernard remove RT_CAN_USING_LED.
  10. * 2022-05-08 hpmicro add CANFD support, fixed typos
  11. */
  12. #ifndef __DEV_CAN_H_
  13. #define __DEV_CAN_H_
  14. #include <rtthread.h>
  15. #ifndef RT_CANMSG_BOX_SZ
  16. #define RT_CANMSG_BOX_SZ 16
  17. #endif
  18. #ifndef RT_CANSND_BOX_NUM
  19. #define RT_CANSND_BOX_NUM 1
  20. #endif
  21. enum CAN_DLC
  22. {
  23. CAN_MSG_0BYTE = 0,
  24. CAN_MSG_1BYTE,
  25. CAN_MSG_2BYTES,
  26. CAN_MSG_3BYTES,
  27. CAN_MSG_4BYTES,
  28. CAN_MSG_5BYTES,
  29. CAN_MSG_6BYTES,
  30. CAN_MSG_7BYTES,
  31. CAN_MSG_8BYTES,
  32. CAN_MSG_12BYTES,
  33. CAN_MSG_16BYTES,
  34. CAN_MSG_20BYTES,
  35. CAN_MSG_24BYTES,
  36. CAN_MSG_32BYTES,
  37. CAN_MSG_48BYTES,
  38. CAN_MSG_64BYTES,
  39. };
  40. enum CANBAUD
  41. {
  42. CAN1MBaud = 1000UL * 1000,/* 1 MBit/sec */
  43. CAN800kBaud = 1000UL * 800, /* 800 kBit/sec */
  44. CAN500kBaud = 1000UL * 500, /* 500 kBit/sec */
  45. CAN250kBaud = 1000UL * 250, /* 250 kBit/sec */
  46. CAN125kBaud = 1000UL * 125, /* 125 kBit/sec */
  47. CAN100kBaud = 1000UL * 100, /* 100 kBit/sec */
  48. CAN50kBaud = 1000UL * 50, /* 50 kBit/sec */
  49. CAN20kBaud = 1000UL * 20, /* 20 kBit/sec */
  50. CAN10kBaud = 1000UL * 10 /* 10 kBit/sec */
  51. };
  52. #define RT_CAN_MODE_NORMAL 0
  53. #define RT_CAN_MODE_LISTEN 1
  54. #define RT_CAN_MODE_LOOPBACK 2
  55. #define RT_CAN_MODE_LOOPBACKANLISTEN 3
  56. #define RT_CAN_MODE_PRIV 0x01
  57. #define RT_CAN_MODE_NOPRIV 0x00
  58. /**
  59. * @defgroup group_CAN_Device CAN Driver
  60. * @brief CAN driver api
  61. * @ingroup group_device_driver
  62. *
  63. * <b>Example</b>
  64. * @code {.c}
  65. * #include <rtthread.h>
  66. * #include "rtdevice.h"
  67. *
  68. * #define CAN_DEV_NAME "can1" // CAN 设备名称
  69. *
  70. * static struct rt_semaphore rx_sem; // 用于接收消息的信号量
  71. * static rt_device_t can_dev; // CAN 设备句柄
  72. *
  73. * // 接收数据回调函数
  74. * static rt_err_t can_rx_call(rt_device_t dev, rt_size_t size)
  75. * {
  76. * // CAN 接收到数据后产生中断,调用此回调函数,然后发送接收信号量
  77. * rt_sem_release(&rx_sem);
  78. *
  79. * return RT_EOK;
  80. * }
  81. *
  82. * static void can_rx_thread(void *parameter)
  83. * {
  84. * int i;
  85. * rt_err_t res;
  86. * struct rt_can_msg rxmsg = {0};
  87. *
  88. * // 设置接收回调函数
  89. * rt_device_set_rx_indicate(can_dev, can_rx_call);
  90. *
  91. * #ifdef RT_CAN_USING_HDR
  92. * struct rt_can_filter_item items[5] =
  93. * {
  94. * RT_CAN_FILTER_ITEM_INIT(0x100, 0, 0, 0, 0x700, RT_NULL, RT_NULL), // std,match ID:0x100~0x1ff,hdr 为 - 1,设置默认过滤表
  95. * RT_CAN_FILTER_ITEM_INIT(0x300, 0, 0, 0, 0x700, RT_NULL, RT_NULL), // std,match ID:0x300~0x3ff,hdr 为 - 1
  96. * RT_CAN_FILTER_ITEM_INIT(0x211, 0, 0, 0, 0x7ff, RT_NULL, RT_NULL), // std,match ID:0x211,hdr 为 - 1
  97. * RT_CAN_FILTER_STD_INIT(0x486, RT_NULL, RT_NULL), // std,match ID:0x486,hdr 为 - 1
  98. * {0x555, 0, 0, 0, 0x7ff, 7,} // std,match ID:0x555,hdr 为 7,指定设置 7 号过滤表
  99. * };
  100. * struct rt_can_filter_config cfg = {5, 1, items}; // 一共有 5 个过滤表
  101. * // 设置硬件过滤表
  102. * res = rt_device_control(can_dev, RT_CAN_CMD_SET_FILTER, &cfg);
  103. * RT_ASSERT(res == RT_EOK);
  104. * #endif
  105. * res = RT_TRUE;
  106. * res = rt_device_control(can_dev, RT_CAN_CMD_START, &res);
  107. * while (1)
  108. * {
  109. * // hdr 值为 - 1,表示直接从 uselist 链表读取数据
  110. * rxmsg.hdr = -1;
  111. * // 阻塞等待接收信号量
  112. * rt_sem_take(&rx_sem, RT_WAITING_FOREVER);
  113. * // 从 CAN 读取一帧数据
  114. * rt_device_read(can_dev, 0, &rxmsg, sizeof(rxmsg));
  115. * // 打印数据 ID 及内容
  116. * rt_kprintf("ID:%x", rxmsg.id);
  117. * for (i = 0; i < 8; i++)
  118. * {
  119. * rt_kprintf("%2x", rxmsg.data[i]);
  120. * }
  121. *
  122. * rt_kprintf("\n");
  123. * }
  124. * }
  125. *
  126. * int can_sample(int argc, char *argv[])
  127. * {
  128. * struct rt_can_msg msg = {0};
  129. * rt_err_t res;
  130. * rt_size_t size;
  131. * rt_thread_t thread;
  132. * char can_name[RT_NAME_MAX];
  133. *
  134. * if (argc == 2)
  135. * {
  136. * rt_strncpy(can_name, argv[1], RT_NAME_MAX);
  137. * }
  138. * else
  139. * {
  140. * rt_strncpy(can_name, CAN_DEV_NAME, RT_NAME_MAX);
  141. * }
  142. * // 查找 CAN 设备
  143. * can_dev = rt_device_find(can_name);
  144. * if (!can_dev)
  145. * {
  146. * rt_kprintf("find %s failed!\n", can_name);
  147. * return -RT_ERROR;
  148. * }
  149. *
  150. * // 初始化 CAN 接收信号量
  151. * rt_sem_init(&rx_sem, "rx_sem", 0, RT_IPC_FLAG_FIFO);
  152. *
  153. * // 以中断接收及发送方式打开 CAN 设备
  154. * res = rt_device_open(can_dev, RT_DEVICE_FLAG_INT_TX | RT_DEVICE_FLAG_INT_RX);
  155. * RT_ASSERT(res == RT_EOK);
  156. * // 创建数据接收线程
  157. * thread = rt_thread_create("can_rx", can_rx_thread, RT_NULL, 1024, 25, 10);
  158. * if (thread != RT_NULL)
  159. * {
  160. * rt_thread_startup(thread);
  161. * }
  162. * else
  163. * {
  164. * rt_kprintf("create can_rx thread failed!\n");
  165. * }
  166. *
  167. * msg.id = 0x78; // ID 为 0x78
  168. * msg.ide = RT_CAN_STDID; // 标准格式
  169. * msg.rtr = RT_CAN_DTR; // 数据帧
  170. * msg.len = 8; // 数据长度为 8
  171. * // 待发送的 8 字节数据
  172. * msg.data[0] = 0x00;
  173. * msg.data[1] = 0x11;
  174. * msg.data[2] = 0x22;
  175. * msg.data[3] = 0x33;
  176. * msg.data[4] = 0x44;
  177. * msg.data[5] = 0x55;
  178. * msg.data[6] = 0x66;
  179. * msg.data[7] = 0x77;
  180. * // 发送一帧 CAN 数据
  181. * size = rt_device_write(can_dev, 0, &msg, sizeof(msg));
  182. * if (size == 0)
  183. * {
  184. * rt_kprintf("can dev write data failed!\n");
  185. * }
  186. *
  187. * return res;
  188. * }
  189. * // 导出到 msh 命令列表中
  190. * MSH_CMD_EXPORT(can_sample, can device sample);
  191. * @endcode
  192. */
  193. /*!
  194. * @addtogroup group_CAN_Device
  195. * @{
  196. */
  197. #define CAN_RX_FIFO0 (0x00000000U) /*!< CAN receive FIFO 0 */
  198. #define CAN_RX_FIFO1 (0x00000001U) /*!< CAN receive FIFO 1 */
  199. /**
  200. * @brief CAN filter item
  201. */
  202. struct rt_can_filter_item
  203. {
  204. rt_uint32_t id : 29;
  205. rt_uint32_t ide : 1;
  206. rt_uint32_t rtr : 1;
  207. rt_uint32_t mode : 1;
  208. rt_uint32_t mask;
  209. rt_int32_t hdr_bank;/*Should be defined as:rx.FilterBank,which should be changed to rt_int32_t hdr_bank*/
  210. rt_uint32_t rxfifo;/*Add a configuration item that CAN_RX_FIFO0/CAN_RX_FIFO1*/
  211. #ifdef RT_CAN_USING_HDR
  212. rt_err_t (*ind)(rt_device_t dev, void *args , rt_int32_t hdr, rt_size_t size);
  213. void *args;
  214. #endif /*RT_CAN_USING_HDR*/
  215. };
  216. #ifdef RT_CAN_USING_HDR
  217. #define RT_CAN_FILTER_ITEM_INIT(id,ide,rtr,mode,mask,ind,args) \
  218. {(id), (ide), (rtr), (mode),(mask), -1, CAN_RX_FIFO0,(ind), (args)}/*0:CAN_RX_FIFO0*/
  219. #define RT_CAN_FILTER_STD_INIT(id,ind,args) \
  220. RT_CAN_FILTER_ITEM_INIT(id,0,0,0,0xFFFFFFFF,ind,args)
  221. #define RT_CAN_FILTER_EXT_INIT(id,ind,args) \
  222. RT_CAN_FILTER_ITEM_INIT(id,1,0,0,0xFFFFFFFF,ind,args)
  223. #define RT_CAN_STD_RMT_FILTER_INIT(id,ind,args) \
  224. RT_CAN_FILTER_ITEM_INIT(id,0,1,0,0xFFFFFFFF,ind,args)
  225. #define RT_CAN_EXT_RMT_FILTER_INIT(id,ind,args) \
  226. RT_CAN_FILTER_ITEM_INIT(id,1,1,0,0xFFFFFFFF,ind,args)
  227. #define RT_CAN_STD_RMT_DATA_FILTER_INIT(id,ind,args) \
  228. RT_CAN_FILTER_ITEM_INIT(id,0,0,1,0xFFFFFFFF,ind,args)
  229. #define RT_CAN_EXT_RMT_DATA_FILTER_INIT(id,ind,args) \
  230. RT_CAN_FILTER_ITEM_INIT(id,1,0,1,0xFFFFFFFF,ind,args)
  231. #else
  232. #define RT_CAN_FILTER_ITEM_INIT(id,ide,rtr,mode,mask) \
  233. {(id), (ide), (rtr), (mode), (mask), -1, CAN_RX_FIFO0 }/*0:CAN_RX_FIFO0*/
  234. #define RT_CAN_FILTER_STD_INIT(id) \
  235. RT_CAN_FILTER_ITEM_INIT(id,0,0,0,0xFFFFFFFF)
  236. #define RT_CAN_FILTER_EXT_INIT(id) \
  237. RT_CAN_FILTER_ITEM_INIT(id,1,0,0,0xFFFFFFFF)
  238. #define RT_CAN_STD_RMT_FILTER_INIT(id) \
  239. RT_CAN_FILTER_ITEM_INIT(id,0,1,0,0xFFFFFFFF)
  240. #define RT_CAN_EXT_RMT_FILTER_INIT(id) \
  241. RT_CAN_FILTER_ITEM_INIT(id,1,1,0,0xFFFFFFFF)
  242. #define RT_CAN_STD_RMT_DATA_FILTER_INIT(id) \
  243. RT_CAN_FILTER_ITEM_INIT(id,0,0,1,0xFFFFFFFF)
  244. #define RT_CAN_EXT_RMT_DATA_FILTER_INIT(id) \
  245. RT_CAN_FILTER_ITEM_INIT(id,1,0,1,0xFFFFFFFF)
  246. #endif
  247. /**
  248. * @brief CAN filter configuration
  249. */
  250. struct rt_can_filter_config
  251. {
  252. rt_uint32_t count;
  253. rt_uint32_t actived;
  254. struct rt_can_filter_item *items;
  255. };
  256. /**
  257. * @brief CAN timing configuration
  258. */
  259. struct rt_can_bit_timing
  260. {
  261. rt_uint16_t prescaler; /* Pre-scaler */
  262. rt_uint16_t num_seg1; /* Bit Timing Segment 1, in terms of Tq */
  263. rt_uint16_t num_seg2; /* Bit Timing Segment 2, in terms of Tq */
  264. rt_uint8_t num_sjw; /* Synchronization Jump Width, in terms of Tq */
  265. rt_uint8_t num_sspoff; /* Secondary Sample Point Offset, in terms of Tq */
  266. };
  267. /**
  268. * @brief CAN bit timing configuration list
  269. * @note
  270. * items[0] always for CAN2.0/CANFD Arbitration Phase
  271. * items[1] always for CANFD (if it exists)
  272. */
  273. struct rt_can_bit_timing_config
  274. {
  275. rt_uint32_t count;
  276. struct rt_can_bit_timing *items;
  277. };
  278. /**
  279. * @brief CAN configuration
  280. */
  281. struct can_configure
  282. {
  283. rt_uint32_t baud_rate;
  284. rt_uint32_t msgboxsz;
  285. rt_uint32_t sndboxnumber;
  286. rt_uint32_t mode : 8;
  287. rt_uint32_t privmode : 8;
  288. rt_uint32_t reserved : 16;
  289. rt_uint32_t ticks;
  290. #ifdef RT_CAN_USING_HDR
  291. rt_uint32_t maxhdr;
  292. #endif
  293. #ifdef RT_CAN_USING_CANFD
  294. rt_uint32_t baud_rate_fd; /* CANFD data bit rate*/
  295. rt_uint32_t use_bit_timing: 8; /* Use the bit timing for CAN timing configuration */
  296. rt_uint32_t enable_canfd : 8; /* Enable CAN-FD mode */
  297. rt_uint32_t reserved1 : 16;
  298. /* The below fields take effect only if use_bit_timing is non-zero */
  299. struct rt_can_bit_timing can_timing; /* CAN bit-timing /CANFD bit-timing for arbitration phase */
  300. struct rt_can_bit_timing canfd_timing; /* CANFD bit-timing for datat phase */
  301. #endif
  302. };
  303. #define CANDEFAULTCONFIG \
  304. {\
  305. CAN1MBaud,\
  306. RT_CANMSG_BOX_SZ,\
  307. RT_CANSND_BOX_NUM,\
  308. RT_CAN_MODE_NORMAL,\
  309. };
  310. struct rt_can_ops;
  311. #define RT_CAN_CMD_SET_FILTER 0x13
  312. #define RT_CAN_CMD_SET_BAUD 0x14
  313. #define RT_CAN_CMD_SET_MODE 0x15
  314. #define RT_CAN_CMD_SET_PRIV 0x16
  315. #define RT_CAN_CMD_GET_STATUS 0x17
  316. #define RT_CAN_CMD_SET_STATUS_IND 0x18
  317. #define RT_CAN_CMD_SET_BUS_HOOK 0x19
  318. #define RT_CAN_CMD_SET_CANFD 0x1A
  319. #define RT_CAN_CMD_SET_BAUD_FD 0x1B
  320. #define RT_CAN_CMD_SET_BITTIMING 0x1C
  321. #define RT_CAN_CMD_START 0x1D
  322. #define RT_DEVICE_CAN_INT_ERR 0x1000
  323. enum RT_CAN_STATUS_MODE
  324. {
  325. NORMAL = 0,
  326. ERRWARNING = 1,
  327. ERRPASSIVE = 2,
  328. BUSOFF = 4,
  329. };
  330. enum RT_CAN_BUS_ERR
  331. {
  332. RT_CAN_BUS_NO_ERR = 0,
  333. RT_CAN_BUS_BIT_PAD_ERR = 1,
  334. RT_CAN_BUS_FORMAT_ERR = 2,
  335. RT_CAN_BUS_ACK_ERR = 3,
  336. RT_CAN_BUS_IMPLICIT_BIT_ERR = 4,
  337. RT_CAN_BUS_EXPLICIT_BIT_ERR = 5,
  338. RT_CAN_BUS_CRC_ERR = 6,
  339. };
  340. /**
  341. * @brief CAN status
  342. */
  343. struct rt_can_status
  344. {
  345. rt_uint32_t rcverrcnt;
  346. rt_uint32_t snderrcnt;
  347. rt_uint32_t errcode;
  348. rt_uint32_t rcvpkg;
  349. rt_uint32_t dropedrcvpkg;
  350. rt_uint32_t sndpkg;
  351. rt_uint32_t dropedsndpkg;
  352. rt_uint32_t bitpaderrcnt;
  353. rt_uint32_t formaterrcnt;
  354. rt_uint32_t ackerrcnt;
  355. rt_uint32_t biterrcnt;
  356. rt_uint32_t crcerrcnt;
  357. rt_uint32_t rcvchange;
  358. rt_uint32_t sndchange;
  359. rt_uint32_t lasterrtype;
  360. };
  361. #ifdef RT_CAN_USING_HDR
  362. struct rt_can_hdr
  363. {
  364. rt_uint32_t connected;
  365. rt_uint32_t msgs;
  366. struct rt_can_filter_item filter;
  367. struct rt_list_node list;
  368. };
  369. #endif
  370. struct rt_can_device;
  371. typedef rt_err_t (*rt_canstatus_ind)(struct rt_can_device *, void *);
  372. typedef struct rt_can_status_ind_type
  373. {
  374. rt_canstatus_ind ind;
  375. void *args;
  376. } *rt_can_status_ind_type_t;
  377. typedef void (*rt_can_bus_hook)(struct rt_can_device *);
  378. struct rt_can_device
  379. {
  380. struct rt_device parent;
  381. const struct rt_can_ops *ops;
  382. struct can_configure config;
  383. struct rt_can_status status;
  384. rt_uint32_t timerinitflag;
  385. struct rt_timer timer;
  386. struct rt_can_status_ind_type status_indicate;
  387. #ifdef RT_CAN_USING_HDR
  388. struct rt_can_hdr *hdr;
  389. #endif
  390. #ifdef RT_CAN_USING_BUS_HOOK
  391. rt_can_bus_hook bus_hook;
  392. #endif /*RT_CAN_USING_BUS_HOOK*/
  393. struct rt_mutex lock;
  394. void *can_rx;
  395. void *can_tx;
  396. };
  397. typedef struct rt_can_device *rt_can_t;
  398. #define RT_CAN_STDID 0
  399. #define RT_CAN_EXTID 1
  400. #define RT_CAN_DTR 0
  401. #define RT_CAN_RTR 1
  402. typedef struct rt_can_status *rt_can_status_t;
  403. struct rt_can_msg
  404. {
  405. rt_uint32_t id : 29;
  406. rt_uint32_t ide : 1;
  407. rt_uint32_t rtr : 1;
  408. rt_uint32_t rsv : 1;
  409. rt_uint32_t len : 8;
  410. rt_uint32_t priv : 8;
  411. rt_int32_t hdr_index : 8;/*Should be defined as:rx.FilterMatchIndex,which should be changed to rt_int32_t hdr_index : 8*/
  412. #ifdef RT_CAN_USING_CANFD
  413. rt_uint32_t fd_frame : 1;
  414. rt_uint32_t brs : 1;
  415. rt_uint32_t rxfifo : 2;/*Redefined to return :CAN RX FIFO0/CAN RX FIFO1*/
  416. rt_uint32_t reserved : 4;
  417. #else
  418. rt_uint32_t rxfifo : 2;/*Redefined to return :CAN RX FIFO0/CAN RX FIFO1*/
  419. rt_uint32_t reserved : 6;
  420. #endif
  421. #ifdef RT_CAN_USING_CANFD
  422. rt_uint8_t data[64];
  423. #else
  424. rt_uint8_t data[8];
  425. #endif
  426. };
  427. typedef struct rt_can_msg *rt_can_msg_t;
  428. struct rt_can_msg_list
  429. {
  430. struct rt_list_node list;
  431. #ifdef RT_CAN_USING_HDR
  432. struct rt_list_node hdrlist;
  433. struct rt_can_hdr *owner;
  434. #endif
  435. struct rt_can_msg data;
  436. };
  437. struct rt_can_rx_fifo
  438. {
  439. /* software fifo */
  440. struct rt_can_msg_list *buffer;
  441. rt_uint32_t freenumbers;
  442. struct rt_list_node freelist;
  443. struct rt_list_node uselist;
  444. };
  445. #define RT_CAN_SND_RESULT_OK 0
  446. #define RT_CAN_SND_RESULT_ERR 1
  447. #define RT_CAN_SND_RESULT_WAIT 2
  448. #define RT_CAN_EVENT_RX_IND 0x01 /* Rx indication */
  449. #define RT_CAN_EVENT_TX_DONE 0x02 /* Tx complete */
  450. #define RT_CAN_EVENT_TX_FAIL 0x03 /* Tx fail */
  451. #define RT_CAN_EVENT_RX_TIMEOUT 0x05 /* Rx timeout */
  452. #define RT_CAN_EVENT_RXOF_IND 0x06 /* Rx overflow */
  453. struct rt_can_sndbxinx_list
  454. {
  455. struct rt_list_node list;
  456. struct rt_completion completion;
  457. rt_uint32_t result;
  458. };
  459. struct rt_can_tx_fifo
  460. {
  461. struct rt_can_sndbxinx_list *buffer;
  462. struct rt_semaphore sem;
  463. struct rt_list_node freelist;
  464. };
  465. /**
  466. * @brief CAN operators
  467. */
  468. struct rt_can_ops
  469. {
  470. rt_err_t (*configure)(struct rt_can_device *can, struct can_configure *cfg);
  471. rt_err_t (*control)(struct rt_can_device *can, int cmd, void *arg);
  472. rt_ssize_t (*sendmsg)(struct rt_can_device *can, const void *buf, rt_uint32_t boxno);
  473. rt_ssize_t (*recvmsg)(struct rt_can_device *can, void *buf, rt_uint32_t boxno);
  474. };
  475. /**
  476. * @brief Register a CAN device to device list
  477. *
  478. * @param can the CAN device object
  479. * @param name the name of CAN device
  480. * @param ops the CAN device operators
  481. * @param data the private data of CAN device
  482. *
  483. * @return the error code, RT_EOK on successfully
  484. */
  485. rt_err_t rt_hw_can_register(struct rt_can_device *can,
  486. const char *name,
  487. const struct rt_can_ops *ops,
  488. void *data);
  489. /**
  490. * @brief CAN interrupt service routine
  491. *
  492. * @param can the CAN device
  493. * @param event the event mask
  494. */
  495. void rt_hw_can_isr(struct rt_can_device *can, int event);
  496. /*! @}*/
  497. #endif /*__DEV_CAN_H*/