dev_can.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717
  1. #include "dev_can.h"
  2. #include "core_cmFunc.h"
  3. #include "dev_iap.h"
  4. #include "hal_can.h"
  5. #include "hal_conf.h"
  6. #include "queue.h"
  7. #include <stdint.h>
  8. #include <stdlib.h>
  9. #include <string.h>
  10. double pow_branch(double x, long long N)
  11. {
  12. double ans = 1.0;
  13. // 贡献的初始值为 x
  14. double x_contribute = x;
  15. // 在对 N 进行二进制拆分的同时计算答案
  16. while (N > 0)
  17. {
  18. if (N % 2 == 1)
  19. {
  20. // 如果 N 二进制表示的最低位为 1,那么需要计入贡献
  21. ans *= x_contribute;
  22. }
  23. // 将贡献不断地平方
  24. x_contribute *= x_contribute;
  25. // 舍弃 N 二进制表示的最低位,这样我们每次只要判断最低位即可
  26. N = N >> 1;
  27. }
  28. return ans;
  29. }
  30. double pow(double x, double N)
  31. {
  32. return N >= 0 ? pow_branch(x, N) : 1.0 / pow_branch(x, -N);
  33. }
  34. uint8_t recv_can_id = 0;
  35. static uint64_t base_data;
  36. void data_bit_move(uint8_t start_bit, uint8_t bit_len, uint64_t data)
  37. {
  38. uint64_t mask = 0;
  39. uint64_t source_data = (uint64_t)data;
  40. mask = pow(2, bit_len) - 1;
  41. base_data |= (mask & source_data) << start_bit;
  42. }
  43. void product_array(uint8_t send_array[8])
  44. {
  45. send_array[0] = (uint8_t)base_data;
  46. send_array[1] = (uint8_t)(base_data >> 8);
  47. send_array[2] = (uint8_t)(base_data >> 16);
  48. send_array[3] = (uint8_t)(base_data >> 24);
  49. send_array[4] = (uint8_t)(base_data >> 32);
  50. send_array[5] = (uint8_t)(base_data >> 40);
  51. send_array[6] = (uint8_t)(base_data >> 48);
  52. send_array[7] = (uint8_t)(base_data >> 56);
  53. base_data = 0;
  54. }
  55. uint8_t push_can_message_to_queue(uint32_t id, uint8_t len, uint8_t *p_data)
  56. {
  57. pdu_tag response_msg;
  58. QUEUE_STATUS result_status;
  59. response_msg.id.r = id;
  60. response_msg.reg.dlc = len;
  61. memcpy(&response_msg.data.u8_buf[0], p_data, len);
  62. if (id > 0x7FF)
  63. {
  64. response_msg.reg.ide = CAN_Id_Extended;
  65. }
  66. else
  67. {
  68. response_msg.reg.ide = CAN_Id_Standard;
  69. }
  70. #if 1
  71. __disable_irq();
  72. result_status = en_queue(&can_tx_queue, response_msg);
  73. __enable_irq();
  74. if (result_status != Q_OK)
  75. {
  76. return 0;
  77. }
  78. #else
  79. en_queue(can_tx, &response_msg, 1);
  80. #endif
  81. return 1;
  82. }
  83. static uint8_t can_tx_frame(pdu_tag can_message)
  84. {
  85. uint8_t result = CAN_TxStatus_NoMailBox;
  86. result = hal_can_msg_tx(can_message.id.r, can_message.reg.ide, can_message.data.u8_buf, can_message.reg.dlc);
  87. return result;
  88. }
  89. // void can_tx_stop(CAN_TypeDef *can_perpiph, u8 mailbox_number)
  90. // {
  91. // can_tx_mail_box_stop(can_perpiph, mailbox_number);
  92. // }
  93. // QUEUE_STATUS can_tx_process(p_can_queue_tag p_queue)
  94. // {
  95. // u8 mailbox_number = 0;
  96. // u8 query_result = CAN_TxStatus_NoMailBox;
  97. // if (queue_empty(p_queue))
  98. // return Q_OK;
  99. // mailbox_number = can_tx_frame(p_queue->can_message[p_queue->tail]);
  100. // if (mailbox_number == CAN_TxStatus_NoMailBox)
  101. // return Q_OK;
  102. // query_result = can_tx_mail_box_state(CAN1, mailbox_number);
  103. // if (query_result == CAN_TxStatus_Ok || query_result == CAN_TxStatus_Pending)
  104. // {
  105. // p_queue->tail = (p_queue->tail + 1) % MAX_QSIZE;
  106. // p_queue->count--;
  107. // return Q_OK;
  108. // }
  109. // return Q_ERR;
  110. // }
  111. void can_tx_callback(void)
  112. {
  113. pdu_tag tx_data;
  114. // de_queue(can_tx, &tx_data);
  115. if (de_queue(&can_tx_queue, tx_data) == Q_OK) // 返回值为1代表读取成功
  116. {
  117. can_tx_frame(tx_data);
  118. CAN_ITConfig(CAN1, CAN_IT_TME, ENABLE);
  119. }
  120. else
  121. {
  122. CAN_ITConfig(CAN1, CAN_IT_TME, DISABLE);
  123. }
  124. }
  125. void can_rx_callback(CanRxMsg rx_message)
  126. {
  127. pdu_tag data;
  128. uint8_t ps;
  129. uint8_t pf;
  130. switch (rx_message.ExtId)
  131. {
  132. case 0x18011801:
  133. data.id.r = 0x18011801;
  134. data.reg.dlc = rx_message.DLC;
  135. memcpy(&data.data.u8_buf[0], rx_message.Data, rx_message.DLC);
  136. en_queue(&can_rx_queue, data);
  137. case 0x18DFF4E1:
  138. data.id.r = 0x18DFF4E1;
  139. data.reg.dlc = rx_message.DLC;
  140. memcpy(&data.data.u8_buf[0], rx_message.Data, rx_message.DLC);
  141. en_queue(&can_rx_queue, data);
  142. case 0x18011802:
  143. data.id.r = 0x18011802;
  144. data.reg.dlc = rx_message.DLC;
  145. memcpy(&data.data.u8_buf[0], rx_message.Data, rx_message.DLC);
  146. #if 1
  147. en_queue(&can_rx_queue, data);
  148. #else
  149. en_queue(can_rx, &data, 1);
  150. #endif
  151. break;
  152. default:
  153. pf = (rx_message.ExtId & CAN_PGN_PF) >> 16;
  154. if (pf >= 0xF0)
  155. {
  156. data.id.r = rx_message.ExtId;
  157. recv_can_id = data.id.b.sa;
  158. memcpy(&data.data.u8_buf[0], rx_message.Data, rx_message.DLC);
  159. #if 1
  160. en_queue(&can_rx_queue, data);
  161. #else
  162. en_queue(can_rx, &data, 1);
  163. #endif
  164. }
  165. else
  166. {
  167. // ps = (rx_message.ExtId & CAN_PGN_PS) >> 8;
  168. // if (ps == 0xF4)
  169. // {
  170. // }
  171. #if 1
  172. en_queue(&can_rx_queue, data);
  173. #else
  174. en_queue(can_rx, &data, 1);
  175. #endif
  176. }
  177. }
  178. }
  179. uint8_t tx_flag = 0;
  180. void can_rx_ctl(pdu_tag rec_msg)
  181. {
  182. // rec_msg.data.u8_buf[0];
  183. // LED2 = !LED2;
  184. tx_flag = 1;
  185. }
  186. uint8_t tx_data[8] = {0};
  187. uint8_t flag = 0;
  188. void can_rx_param(pdu_tag rec_msg)
  189. {
  190. // LED2 = !LED2;
  191. tx_data[0] = rec_msg.data.u8_buf[0];
  192. tx_data[1] = rec_msg.data.u8_buf[1];
  193. tx_data[2] = rec_msg.data.u8_buf[2];
  194. tx_data[3] = rec_msg.data.u8_buf[3];
  195. if (tx_data[1] = 0xFF)
  196. {
  197. tx_flag = 1;
  198. }
  199. else
  200. {
  201. flag = 1;
  202. }
  203. // push_can_message_to_queue(rec_msg.id.r, rec_msg.reg.dlc, rec_msg.data.u8_buf);
  204. }
  205. void can_rx_update(pdu_tag rec_msg)
  206. {
  207. if ((rec_msg.data.u8_buf[0] == 'A') && (rec_msg.data.u8_buf[1] == 'P') && (rec_msg.data.u8_buf[2] == 'P') && (rec_msg.data.u8_buf[3] == 'L') && (rec_msg.data.u8_buf[4] == 'O') && (rec_msg.data.u8_buf[5] == 'A') && (rec_msg.data.u8_buf[6] == 'D') && (rec_msg.data.u8_buf[7] == 0x01))
  208. {
  209. __set_FAULTMASK(1); // 关闭所有中断
  210. NVIC_SystemReset(); // 复位
  211. }
  212. }
  213. can_rx_tab can_tab[] = {
  214. 0x18011802,
  215. can_rx_param,
  216. 0x18011801,
  217. can_rx_ctl,
  218. 0x18DFF4E1,
  219. iap_rec_handler,
  220. };
  221. #define REG32(addr) (*(volatile uint32_t *)(uint32_t)(addr))
  222. #define CAN_INTEN(canx) REG32((canx) + 0x14U)
  223. void can_start_send(void)
  224. {
  225. pdu_tag tx_msg;
  226. if (0 == ((CAN1->IER) & 0x1))
  227. {
  228. #if 0
  229. de_queue(can_tx, &tx_msg);
  230. if (can_tx.ret == 1) // 返回值为1代表读取成功
  231. {
  232. can_tx_frame(tx_msg);
  233. CAN_ITConfig(CAN1, CAN_IT_TME, ENABLE);
  234. }
  235. #else
  236. if (de_queue(&can_tx_queue, tx_msg) == Q_OK) // 返回值为1代表读取成功
  237. {
  238. can_tx_frame(tx_msg);
  239. CAN_ITConfig(CAN1, CAN_IT_TME, ENABLE);
  240. }
  241. #endif
  242. }
  243. }
  244. static uint8_t can_rx_process(void)
  245. {
  246. uint8_t i;
  247. uint8_t flg = 0;
  248. pdu_tag rec_msg;
  249. QUEUE_STATUS result;
  250. for (uint8_t j = 0; j < 15; j++)
  251. {
  252. #if 1
  253. __disable_irq();
  254. result = de_queue(&can_rx_queue, rec_msg);
  255. __enable_irq();
  256. if (Q_OK == result)
  257. {
  258. for (i = 0; i < ARR_SIZE(can_tab); i++)
  259. {
  260. if (can_tab[i].id == rec_msg.id.r)
  261. {
  262. can_tab[i].p_func(rec_msg);
  263. flg = 1;
  264. break;
  265. }
  266. else if (can_tab[i].id == (rec_msg.id.b.pf << 8 | rec_msg.id.b.ps))
  267. {
  268. can_tab[i].p_func(rec_msg);
  269. flg = 1;
  270. break;
  271. }
  272. else if (can_tab[i].id == rec_msg.id.b.pf)
  273. {
  274. can_tab[i].p_func(rec_msg);
  275. flg = 1;
  276. break;
  277. }
  278. }
  279. if (flg == 0)
  280. {
  281. // j1939_msg_push_queue(rec_msg);
  282. }
  283. flg = 0;
  284. }
  285. #else
  286. de_queue(can_rx, &rec_msg);
  287. if (can_rx.ret == 1) // 返回值为1代表读取成功
  288. {
  289. for (i = 0; i < ARR_SIZE(can_tab); i++)
  290. {
  291. if (can_tab[i].id == rec_msg.id.r)
  292. {
  293. can_tab[i].p_func(rec_msg);
  294. break;
  295. }
  296. }
  297. }
  298. #endif
  299. }
  300. }
  301. void can_tx_0x18010000_message(void)
  302. {
  303. uint8_t data[8] = {0};
  304. data[2] = 0xFF;
  305. push_can_message_to_queue(0x18010000, 8, data);
  306. }
  307. void can_tx_0x18010001_message(void)
  308. {
  309. uint8_t data[8] = {0};
  310. push_can_message_to_queue(0x18010001, 8, data);
  311. }
  312. void can_tx_0x18030001_message(void)
  313. {
  314. uint8_t data[8] = {0};
  315. data[1] = 8;
  316. push_can_message_to_queue(0x18030001, 8, data);
  317. }
  318. void can_tx_0x18010002_message(void)
  319. {
  320. uint8_t data[8] = {0};
  321. data[0] = 0x02;
  322. push_can_message_to_queue(0x18010002, 8, data);
  323. }
  324. void can_tx_0x18030003_message(void)
  325. {
  326. uint8_t data[8] = {0};
  327. data[0] = 0x02;
  328. push_can_message_to_queue(0x18030003, 8, data);
  329. }
  330. void can_tx_0x18010004_message(void)
  331. {
  332. uint8_t data[8] = {0};
  333. data[4] = 33;
  334. data[5] = 22;
  335. push_can_message_to_queue(0x18010004, 8, data);
  336. }
  337. void can_tx_0x18010005_message(void)
  338. {
  339. uint8_t data[8] = {0};
  340. data[4] = 33;
  341. data[5] = 22;
  342. push_can_message_to_queue(0x18010005, 8, data);
  343. }
  344. void can_tx_0x18010006_message(void)
  345. {
  346. uint8_t data[8] = {0};
  347. data[4] = 33;
  348. data[5] = 22;
  349. push_can_message_to_queue(0x18010006, 8, data);
  350. }
  351. void can_tx_0x18010007_message(void)
  352. {
  353. uint8_t data[8] = {0};
  354. data[4] = 33;
  355. data[5] = 22;
  356. push_can_message_to_queue(0x18010007, 8, data);
  357. }
  358. void can_tx_0x18010008_message(void)
  359. {
  360. uint8_t data[8] = {0};
  361. data[4] = 33;
  362. data[5] = 22;
  363. push_can_message_to_queue(0x18010008, 8, data);
  364. }
  365. void can_tx_0x18010009_message(void)
  366. {
  367. uint8_t data[8] = {0};
  368. data[4] = 33;
  369. data[5] = 22;
  370. push_can_message_to_queue(0x18010009, 8, data);
  371. }
  372. void can_tx_0x1801000F_message(void)
  373. {
  374. uint8_t data[8] = {0};
  375. data[0] = 1;
  376. data[1] = 5;
  377. data[2] = 3000 & 0xFF;
  378. data[3] = 3000 >> 8;
  379. data[4] = 3000 & 0xFF;
  380. data[5] = 3000 >> 8;
  381. push_can_message_to_queue(0x1801000F, 8, data);
  382. }
  383. void can_tx_0x18010010_message(void)
  384. {
  385. uint8_t data[8] = {0};
  386. // data_bit_move(0, 8, 1);
  387. // data_bit_move(8, 8, 1);
  388. // data_bit_move(32, 8, 0);
  389. // data_bit_move(40, 8, 0);
  390. // product_array(data);
  391. data[0] = 1;
  392. data[1] = 1;
  393. data[4] = 0;
  394. data[5] = 0;
  395. // push_can_message_to_queue(0x18010010, 8, data);
  396. // data[1] = 5;
  397. // push_can_message_to_queue(0x18010010, 8, data);
  398. // data[1] = 10;
  399. push_can_message_to_queue(0x18010010, 8, data);
  400. }
  401. void can_tx_0x1801000A_message(void)
  402. {
  403. uint8_t data[8] = {0};
  404. data[4] = 33;
  405. data[5] = 22;
  406. push_can_message_to_queue(0x1801000A, 8, data);
  407. }
  408. void can_tx_0x1801000B_message(void)
  409. {
  410. uint8_t data[8] = {0};
  411. data[4] = 33;
  412. data[5] = 22;
  413. push_can_message_to_queue(0x1801000B, 8, data);
  414. }
  415. void can_tx_0x1801000C_message(void)
  416. {
  417. uint8_t data[8] = {0};
  418. data[4] = 33;
  419. data[5] = 22;
  420. push_can_message_to_queue(0x1801000C, 8, data);
  421. }
  422. void can_tx_0x1801000D_message(void)
  423. {
  424. uint8_t data[8] = {0};
  425. data[4] = 33;
  426. data[5] = 22;
  427. push_can_message_to_queue(0x1801000D, 8, data);
  428. }
  429. void can_tx_0x18010012_message(void)
  430. {
  431. uint8_t data[8] = {0};
  432. data[0] = 24;
  433. data[1] = 1;
  434. data[2] = 3;
  435. data[3] = 11;
  436. data[4] = 12;
  437. data[5] = 13;
  438. data[6] = 12;
  439. data[7] = 13;
  440. push_can_message_to_queue(0x18010012, 8, data);
  441. }
  442. void can_tx_0x18010017_message(void)
  443. {
  444. uint8_t data[8] = {0};
  445. data[0] = 24;
  446. data[1] = 1;
  447. data[0] = 3;
  448. data[1] = 11;
  449. data[0] = 12;
  450. data[1] = 13;
  451. push_can_message_to_queue(0x18010017, 8, data);
  452. }
  453. void can_tx_0x18010018_message(void)
  454. {
  455. uint8_t data[8] = {0};
  456. data[0] = 2;
  457. data[1] = 0xFF;
  458. push_can_message_to_queue(0x18010018, 8, data);
  459. }
  460. void can_tx_0x18010019_message(void)
  461. {
  462. uint8_t data[8] = {0};
  463. data[0] = 2;
  464. data[1] = 0xFF;
  465. push_can_message_to_queue(0x18010019, 8, data);
  466. }
  467. void can_tx_0x1801001A_message(void)
  468. {
  469. volatile static int i = 0;
  470. uint8_t data[8] = {0};
  471. data[0] = 2 + i;
  472. data[1] = 0x12 >> i;
  473. i++;
  474. if (i > 7)
  475. {
  476. i = 0;
  477. }
  478. push_can_message_to_queue(0x1801001A, 8, data);
  479. }
  480. void can_tx_0x1801001B_message(void)
  481. {
  482. uint8_t data[8] = {0};
  483. data[0] = 2;
  484. data[1] = 0xFF;
  485. push_can_message_to_queue(0x1801001B, 8, data);
  486. }
  487. void can_tx_0x1801001C_message(void)
  488. {
  489. uint8_t data[8] = {0};
  490. data[0] = 2;
  491. data[4] = 0xFF;
  492. push_can_message_to_queue(0x1801001C, 8, data);
  493. }
  494. void can_tx_0x1801001D_message(void)
  495. {
  496. uint8_t data[8] = {0};
  497. data[0] = 3;
  498. data[2] = 0xFF;
  499. push_can_message_to_queue(0x1801001D, 8, data);
  500. }
  501. void can_tx_0x18010023_message(void)
  502. {
  503. uint8_t send_data[8] = {0};
  504. // data[0] = 'A';
  505. // data[1] = 'A';
  506. // data[2] = 'A';
  507. // data[3] = 'A';
  508. // data[4] = 'A';
  509. // data[5] = 'A';
  510. // data[6] = 'A';
  511. // data[7] = 'A';
  512. data_bit_move(0, 8, 'A');
  513. data_bit_move(8, 8, 'A');
  514. data_bit_move(16, 8, 'A');
  515. data_bit_move(24, 8, 'C');
  516. data_bit_move(32, 8, 'A');
  517. data_bit_move(40, 8, '-');
  518. data_bit_move(48, 8, 'A');
  519. data_bit_move(56, 8, 'B');
  520. product_array(send_data);
  521. push_can_message_to_queue(0x18010023, 8, send_data);
  522. }
  523. void can_tx_0x18011802_message(void)
  524. {
  525. static uint8_t fdf = 0;
  526. if (flag == 1)
  527. {
  528. push_can_message_to_queue(0x18011802, 8, tx_data);
  529. flag = 0;
  530. }
  531. uint8_t data[8] = {0};
  532. uint16_t addr = 0xA000;
  533. if (tx_flag == 1)
  534. {
  535. data[0] = (addr + fdf) & 0xFF;
  536. data[1] = (addr + fdf) >> 8;
  537. data[2] = rand() & 0xFF;
  538. data[3] = rand() >> 8;
  539. fdf++;
  540. if (fdf == 80)
  541. {
  542. tx_flag = 0;
  543. }
  544. push_can_message_to_queue(0x18011802, 8, data);
  545. }
  546. }
  547. void can_tx_0x18011803_message(void)
  548. {
  549. uint8_t data[8] = {0};
  550. uint16_t addr = 0xB000;
  551. static uint8_t fdf = 0;
  552. static int16_t a = -263;
  553. data[0] = (addr + fdf) & 0xFF;
  554. data[1] = (addr + fdf) >> 8;
  555. data[2] = a & 0xFF;
  556. data[3] = a >> 8;
  557. fdf++;
  558. a++;
  559. if (fdf > 6)
  560. {
  561. fdf = 0;
  562. }
  563. push_can_message_to_queue(0x18011803, 8, data);
  564. }
  565. void can_tx_0x18011803_2_message(void)
  566. {
  567. uint8_t data[8] = {0};
  568. static uint8_t fdf_2 = 0;
  569. uint16_t addr_vol = 0xB110;
  570. data[0] = (addr_vol + fdf_2) & 0xFF;
  571. data[1] = (addr_vol + fdf_2) >> 8;
  572. data[2] = 1;
  573. data[3] = -2 & 0xFF;
  574. data[4] = -2 >> 8;
  575. fdf_2++;
  576. if (fdf_2 > 80)
  577. {
  578. fdf_2 = 0;
  579. }
  580. push_can_message_to_queue(0x18011803, 8, data);
  581. }
  582. void send_message(void)
  583. {
  584. static volatile uint8_t times = 0;
  585. if (times >= 100)
  586. {
  587. times = 0;
  588. }
  589. if (times % 100 == 0)
  590. {
  591. can_tx_0x18010001_message();
  592. can_tx_0x18010002_message();
  593. can_tx_0x18010004_message();
  594. can_tx_0x18010005_message();
  595. }
  596. else if (times % 100 == 5)
  597. {
  598. can_tx_0x18010006_message();
  599. can_tx_0x18010007_message();
  600. can_tx_0x18010008_message();
  601. can_tx_0x18010009_message();
  602. can_tx_0x1801000A_message();
  603. }
  604. else if (times % 100 == 10)
  605. {
  606. can_tx_0x1801000B_message();
  607. can_tx_0x1801000C_message();
  608. can_tx_0x1801000D_message();
  609. can_tx_0x18010023_message();
  610. can_tx_0x18010010_message();
  611. }
  612. else if (times % 100 == 15)
  613. {
  614. can_tx_0x18010018_message();
  615. can_tx_0x18010019_message();
  616. can_tx_0x1801001A_message();
  617. can_tx_0x1801001B_message();
  618. can_tx_0x1801001C_message();
  619. }
  620. else if (times % 100 == 20)
  621. {
  622. can_tx_0x1801001D_message();
  623. can_tx_0x1801000F_message();
  624. can_tx_0x18030003_message();
  625. can_tx_0x18030001_message();
  626. can_tx_0x18010000_message();
  627. }
  628. else if (times % 100 == 25)
  629. {
  630. can_tx_0x18010017_message();
  631. can_tx_0x18010012_message();
  632. can_tx_0x18011802_message();
  633. can_tx_0x18011803_message();
  634. // can_tx_0x18011803_2_message();
  635. }
  636. else
  637. {
  638. // return;
  639. }
  640. times++;
  641. }
  642. void dev_can_network_init(void)
  643. {
  644. hal_can_init();
  645. hal_can_rx_back_init(can_rx_callback);
  646. hal_can_tx_back_init(can_tx_callback);
  647. }
  648. void can_process(void)
  649. {
  650. can_rx_process();
  651. send_message();
  652. can_start_send();
  653. }