WS_MCP2515.h 853 B

123456789101112131415161718192021
  1. #ifndef __WS_MCP2515_H_
  2. #define __WS_MCP2515_H_
  3. #include <SPI.h>
  4. #include <mcp_can.h>
  5. #define SPI_CLK_PIN 47
  6. #define SPI_MISO_PIN 15
  7. #define SPI_MOSI_PIN 48
  8. #define MCP2515_CS0_PIN 16
  9. #define MCP2515_CS1_PIN 1
  10. #define MCP2515_CS_PIN MCP2515_CS0_PIN
  11. #define CAN_ID 0x123 // ID of the data sent
  12. #define CAN_LEN 8 // The length of the data sent
  13. uint8_t receiveCANData(long unsigned int* canId, uint8_t* data); // Parameters: Saves a pointer to the ID, array of data
  14. uint8_t sendCANData(long unsigned int canId, uint8_t len, uint8_t* data); // Parameters: ID to be sent, length to be sent, data to be sent
  15. void MCP2515_Init(); // Example Initialize MCP2515
  16. void MCP2515_Loop();
  17. #endif