• gltantan
  • C/C++
  • 819KB
  • rar
  • 0
  • 10 积分
  • 1
  • 2020-08-31 10:11
CAN BUS Shield --------------------------------------------------------- [![CAN BUS Shield](]( <br> CAN-BUS is a common industrial bus because of its long travel distance, medium communication speed and high reliability. It is commonly found on modern machine tools and as an automotive diagnostic bus. This CAN-BUS Shield adopts MCP2515 CAN Bus controller with SPI interface and MCP2551 CAN transceiver to give your Arduino/Seeeduino CAN-BUS capibility. With an OBD-II converter cable added on and the OBD-II library imported, you are ready to build an onboard diagnostic device or data logger. - Implements CAN V2.0B at up to 1 Mb/s - SPI Interface up to 10 MHz - Standard (11 bit) and extended (29 bit) data and remote frames - Two receive buffers with prioritized message storage - Industrial standard 9 pin sub-D connector - Two LED indicators <br> # Usage: ## 1. Set the BaudRate This function is used to initialize the baudrate of the CAN Bus system. The available baudrates are listed as follws: #define CAN_5KBPS 1 #define CAN_10KBPS 2 #define CAN_20KBPS 3 #define CAN_25KBPS 4 #define CAN_31K25BPS 5 #define CAN_33KBPS 6 #define CAN_40KBPS 7 #define CAN_50KBPS 8 #define CAN_80KBPS 9 #define CAN_83K3BPS 10 #define CAN_95KBPS 11 #define CAN_100KBPS 12 #define CAN_125KBPS 13 #define CAN_200KBPS 14 #define CAN_250KBPS 15 #define CAN_500KBPS 16 #define CAN_666kbps 17 #define CAN_1000KBPS 18 <br> ##2. Set Receive Mask and Filter There are 2 receive mask registers and 5 filter registers on the controller chip that guarantee you get data from the target device. They are useful especially in a large network consisting of numerous nodes. We provide two functions for you to utilize these mask and filter registers. They are: init_Mask(unsigned char num, unsigned char ext, unsigned char ulData); init_Filt(unsigned char num, unsigned char ext, unsigned char ulData); **num** represents which register to use. You can fill 0 or 1 for mask and 0 to 5 for filter. **ext** represents the status of the frame. 0 means it's a mask or filter for a standard frame. 1 means it's for a extended frame. **ulData** represents the content of the mask of filter. <br> ## 3. Check Receive The MCP2515 can operate in either a polled mode, where the software checks for a received frame, or using additional pins to signal that a frame has been received or transmit completed. Use the following function to poll for received frames. INT8U MCP_CAN::checkReceive(void); The function will return 1 if a frame arrives, and 0 if nothing arrives. <br> ## 4. Get CAN ID When some data arrive, you can use the following function to get the CAN ID of the "send" node. INT32U MCP_CAN::getCanId(void); <br> ## 5. Send Data CAN.sendMsgBuf(INT8U id, INT8U ext, INT8U len, data_buf); This is a function to send data onto the bus. In which: **id** represents where the data come from. **ext** represents the status of the frame. '0' means standard frame. '1' means extended frame. **len** represents the length of this frame. **data_buf** is the content of this message. For example, In the 'send' example, we have: <pre> unsigned char stmp[8] = {0, 1, 2, 3, 4, 5, 6, 7}; CAN.sendMsgBuf(0x00, 0, 8, stmp); //send out the message 'stmp' to the bus and tell other devices this is a standard frame from 0x00. </pre> <br> ## 6. Receive Data The following function is used to receive data on the 'receive' node: CAN.readMsgBuf(unsigned char len, unsigned char buf); In conditions that masks and filters have been set. This function can only get frames that meet the requirements of masks and filters. **len** represents the data length. **buf** is where you store the data. <br> ## 7. Check additional flags When frame is received you may check whether it was remote request and whether it was an extended (29bit) frame. CAN.isRemoteRequest(); CAN.isExtendedFrame(); **return value** is '0' for a negative response and '1' for a positive <br> For more information, please refer to [wiki page]( ---- This software is written by loovee ([]( "")) for seeed studio<br> and is licensed under [The MIT License]( Check License.txt for more information.<br> Contributing to this software is warmly welcomed. You can do this basically by<br> [forking](, committing modifications and then [pulling requests]( (follow the links above<br> for operating guide). Adding change log and your contact into file header is encouraged.<br> Thanks for your contribution. Seeed Studio is an open hardware facilitation company based in Shenzhen, China. <br> Benefiting from local manufacture power and convenient global logistic system, <br> we integrate resources to serve new era of innovation. Seeed also works with <br> global distributors and partners to push open hardware movement.<br> [![Analytics](]( <script> (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//','ga'); ga('create', 'UA-65075738-1', 'auto'); ga('send', 'pageview'); </script>
    • can总线学习.zip
    • CAN总线实验装置协议V3.rar
    • 嵌入式CAN总线收发
    • CAN总线源代码
      can总线源代码 #include<linux/version.h> #include<linux/types.h> #include<linux/socket.h>
    • ARM7CAN总线程序
    • stm32 can总线
      stm32 can总线例程 里面有两个例程,可直接下载烧录
    • CAN总线C
      摘要:VC/C++源码,其它分类,CAN总线 CAN总线C源码,单片机相关的-CAN总线C源码,有说明文档。
    • CAN总线知识集锦.zip
    • DSP2812 can 总线
      dsp2812 can总线 c语言代码 软件和硬件设计
    • SigExplorer:CAN 总线信号浏览器
      CAN总线信号浏览器 该工具提供了一个 Web 界面,用于对发现的信号进行协作并组织研究。 目标是定义车辆总线网络和其中使用的信号。 可以搜索或导出数据。 目前的格式是 Kayak KCD 格式。 Kayak KCD 架构在这里: ...